{ "version": 3, "sources": ["../../../src/diagrams/architecture/architectureParser.ts", "../../../src/diagrams/architecture/architectureTypes.ts", "../../../src/diagrams/architecture/architectureDb.ts", "../../../src/diagrams/architecture/architectureStyles.ts", "../../../src/diagrams/architecture/architectureRenderer.ts", "../../../src/diagrams/architecture/architectureIcons.ts", "../../../src/diagrams/architecture/svgDraw.ts", "../../../src/diagrams/architecture/architectureDiagram.ts"], "sourcesContent": ["import type { Architecture } from '@mermaid-js/parser';\nimport { parse } from '@mermaid-js/parser';\nimport type { ParserDefinition } from '../../diagram-api/types.js';\nimport { log } from '../../logger.js';\nimport { populateCommonDb } from '../common/populateCommonDb.js';\nimport { ArchitectureDB } from './architectureDb.js';\n\nconst populateDb = (ast: Architecture, db: ArchitectureDB) => {\n populateCommonDb(ast, db);\n ast.groups.map((group) => db.addGroup(group));\n ast.services.map((service) => db.addService({ ...service, type: 'service' }));\n ast.junctions.map((service) => db.addJunction({ ...service, type: 'junction' }));\n // @ts-ignore TODO our parser guarantees the type is L/R/T/B and not string. How to change to union type?\n ast.edges.map((edge) => db.addEdge(edge));\n};\n\nexport const parser: ParserDefinition = {\n parser: {\n // @ts-expect-error - ArchitectureDB is not assignable to DiagramDB\n yy: undefined,\n },\n parse: async (input: string): Promise => {\n const ast: Architecture = await parse('architecture', input);\n log.debug(ast);\n const db = parser.parser?.yy;\n if (!(db instanceof ArchitectureDB)) {\n throw new Error(\n 'parser.parser?.yy was not a ArchitectureDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.'\n );\n }\n populateDb(ast, db);\n },\n};\n", "import type { DiagramDBBase } from '../../diagram-api/types.js';\nimport type { ArchitectureDiagramConfig } from '../../config.type.js';\nimport type { D3Element } from '../../types.js';\nimport type cytoscape from 'cytoscape';\n\n/*=======================================*\\\n| Architecture Diagram Types |\n\\*=======================================*/\n\nexport type ArchitectureAlignment = 'vertical' | 'horizontal' | 'bend';\n\nexport type ArchitectureDirection = 'L' | 'R' | 'T' | 'B';\nexport type ArchitectureDirectionX = Extract;\nexport type ArchitectureDirectionY = Extract;\n\n/**\n * Contains LL, RR, TT, BB which are impossible connections\n */\nexport type InvalidArchitectureDirectionPair = `${ArchitectureDirection}${ArchitectureDirection}`;\nexport type ArchitectureDirectionPair = Exclude<\n InvalidArchitectureDirectionPair,\n 'LL' | 'RR' | 'TT' | 'BB'\n>;\nexport type ArchitectureDirectionPairXY = Exclude<\n InvalidArchitectureDirectionPair,\n 'LL' | 'RR' | 'TT' | 'BB' | 'LR' | 'RL' | 'TB' | 'BT'\n>;\n\nexport const ArchitectureDirectionName = {\n L: 'left',\n R: 'right',\n T: 'top',\n B: 'bottom',\n} as const;\n\nexport const ArchitectureDirectionArrow = {\n L: (scale: number) => `${scale},${scale / 2} 0,${scale} 0,0`,\n R: (scale: number) => `0,${scale / 2} ${scale},0 ${scale},${scale}`,\n T: (scale: number) => `0,0 ${scale},0 ${scale / 2},${scale}`,\n B: (scale: number) => `${scale / 2},0 ${scale},${scale} 0,${scale}`,\n} as const;\n\nexport const ArchitectureDirectionArrowShift = {\n L: (orig: number, arrowSize: number) => orig - arrowSize + 2,\n R: (orig: number, _arrowSize: number) => orig - 2,\n T: (orig: number, arrowSize: number) => orig - arrowSize + 2,\n B: (orig: number, _arrowSize: number) => orig - 2,\n} as const;\n\nexport const getOppositeArchitectureDirection = function (\n x: ArchitectureDirection\n): ArchitectureDirection {\n if (isArchitectureDirectionX(x)) {\n return x === 'L' ? 'R' : 'L';\n } else {\n return x === 'T' ? 'B' : 'T';\n }\n};\n\nexport const isArchitectureDirection = function (x: unknown): x is ArchitectureDirection {\n const temp = x as ArchitectureDirection;\n return temp === 'L' || temp === 'R' || temp === 'T' || temp === 'B';\n};\n\nexport const isArchitectureDirectionX = function (\n x: ArchitectureDirection\n): x is ArchitectureDirectionX {\n const temp = x as ArchitectureDirectionX;\n return temp === 'L' || temp === 'R';\n};\n\nexport const isArchitectureDirectionY = function (\n x: ArchitectureDirection\n): x is ArchitectureDirectionY {\n const temp = x as ArchitectureDirectionY;\n return temp === 'T' || temp === 'B';\n};\n\nexport const isArchitectureDirectionXY = function (\n a: ArchitectureDirection,\n b: ArchitectureDirection\n) {\n const aX_bY = isArchitectureDirectionX(a) && isArchitectureDirectionY(b);\n const aY_bX = isArchitectureDirectionY(a) && isArchitectureDirectionX(b);\n return aX_bY || aY_bX;\n};\n\nexport const isArchitecturePairXY = function (\n pair: ArchitectureDirectionPair\n): pair is ArchitectureDirectionPairXY {\n const lhs = pair[0] as ArchitectureDirection;\n const rhs = pair[1] as ArchitectureDirection;\n const aX_bY = isArchitectureDirectionX(lhs) && isArchitectureDirectionY(rhs);\n const aY_bX = isArchitectureDirectionY(lhs) && isArchitectureDirectionX(rhs);\n return aX_bY || aY_bX;\n};\n\n/**\n * Verifies that the architecture direction pair does not contain an invalid match (LL, RR, TT, BB)\n * @param x - architecture direction pair which could potentially be invalid\n * @returns true if the pair is not LL, RR, TT, or BB\n */\nexport const isValidArchitectureDirectionPair = function (\n x: InvalidArchitectureDirectionPair\n): x is ArchitectureDirectionPair {\n return x !== 'LL' && x !== 'RR' && x !== 'TT' && x !== 'BB';\n};\n\nexport type ArchitectureDirectionPairMap = Partial>;\n\n/**\n * Creates a pair of the directions of each side of an edge. This function should be used instead of manually creating it to ensure that the source is always the first character.\n *\n * Note: Undefined is returned when sourceDir and targetDir are the same. In theory this should never happen since the diagram parser throws an error if a user defines it as such.\n * @param sourceDir - source direction\n * @param targetDir - target direction\n * @returns\n */\nexport const getArchitectureDirectionPair = function (\n sourceDir: ArchitectureDirection,\n targetDir: ArchitectureDirection\n): ArchitectureDirectionPair | undefined {\n const pair: `${ArchitectureDirection}${ArchitectureDirection}` = `${sourceDir}${targetDir}`;\n return isValidArchitectureDirectionPair(pair) ? pair : undefined;\n};\n\n/**\n * Given an x,y position for an arrow and the direction of the edge it belongs to, return a factor for slightly shifting the edge\n * @param param0 - [x, y] coordinate pair\n * @param pair - architecture direction pair\n * @returns a new [x, y] coordinate pair\n */\nexport const shiftPositionByArchitectureDirectionPair = function (\n [x, y]: number[],\n pair: ArchitectureDirectionPair\n): number[] {\n const lhs = pair[0] as ArchitectureDirection;\n const rhs = pair[1] as ArchitectureDirection;\n if (isArchitectureDirectionX(lhs)) {\n if (isArchitectureDirectionY(rhs)) {\n return [x + (lhs === 'L' ? -1 : 1), y + (rhs === 'T' ? 1 : -1)];\n } else {\n return [x + (lhs === 'L' ? -1 : 1), y];\n }\n } else {\n if (isArchitectureDirectionX(rhs)) {\n return [x + (rhs === 'L' ? 1 : -1), y + (lhs === 'T' ? 1 : -1)];\n } else {\n return [x, y + (lhs === 'T' ? 1 : -1)];\n }\n }\n};\n\n/**\n * Given the directional pair of an XY edge, get the scale factors necessary to shift the coordinates inwards towards the edge\n * @param pair - XY pair of an edge\n * @returns - number[] containing [+/- 1, +/- 1]\n */\nexport const getArchitectureDirectionXYFactors = function (\n pair: ArchitectureDirectionPairXY\n): number[] {\n if (pair === 'LT' || pair === 'TL') {\n return [1, 1];\n } else if (pair === 'BL' || pair === 'LB') {\n return [1, -1];\n } else if (pair === 'BR' || pair === 'RB') {\n return [-1, -1];\n } else {\n return [-1, 1];\n }\n};\n\nexport const getArchitectureDirectionAlignment = function (\n a: ArchitectureDirection,\n b: ArchitectureDirection\n): ArchitectureAlignment {\n if (isArchitectureDirectionXY(a, b)) {\n return 'bend';\n } else if (isArchitectureDirectionX(a)) {\n return 'horizontal';\n }\n return 'vertical';\n};\n\nexport interface ArchitectureStyleOptions {\n archEdgeColor: string;\n archEdgeArrowColor: string;\n archEdgeWidth: string;\n archGroupBorderColor: string;\n archGroupBorderWidth: string;\n}\n\nexport interface ArchitectureService {\n id: string;\n type: 'service';\n edges: ArchitectureEdge[];\n icon?: string;\n iconText?: string;\n title?: string;\n in?: string;\n width?: number;\n height?: number;\n}\n\nexport interface ArchitectureJunction {\n id: string;\n type: 'junction';\n edges: ArchitectureEdge[];\n in?: string;\n width?: number;\n height?: number;\n}\n\nexport type ArchitectureNode = ArchitectureService | ArchitectureJunction;\n\nexport const isArchitectureService = function (x: ArchitectureNode): x is ArchitectureService {\n const temp = x as ArchitectureService;\n return temp.type === 'service';\n};\n\nexport const isArchitectureJunction = function (x: ArchitectureNode): x is ArchitectureJunction {\n const temp = x as ArchitectureJunction;\n return temp.type === 'junction';\n};\n\nexport interface ArchitectureGroup {\n id: string;\n icon?: string;\n title?: string;\n in?: string;\n}\n\nexport interface ArchitectureEdge
{\n lhsId: string;\n lhsDir: DT;\n lhsInto?: boolean;\n lhsGroup?: boolean;\n rhsId: string;\n rhsDir: DT;\n rhsInto?: boolean;\n rhsGroup?: boolean;\n title?: string;\n}\n\nexport interface ArchitectureDB extends DiagramDBBase {\n clear: () => void;\n addService: (service: Omit) => void;\n getServices: () => ArchitectureService[];\n addJunction: (service: Omit) => void;\n getJunctions: () => ArchitectureJunction[];\n getNodes: () => ArchitectureNode[];\n getNode: (id: string) => ArchitectureNode | null;\n addGroup: (group: ArchitectureGroup) => void;\n getGroups: () => ArchitectureGroup[];\n addEdge: (edge: ArchitectureEdge) => void;\n getEdges: () => ArchitectureEdge[];\n setElementForId: (id: string, element: D3Element) => void;\n getElementById: (id: string) => D3Element;\n getDataStructures: () => ArchitectureDataStructures;\n}\n\nexport type ArchitectureAdjacencyList = Record;\nexport type ArchitectureSpatialMap = Record;\n\n/**\n * Maps the direction that groups connect from.\n *\n * **Outer key**: ID of group A\n *\n * **Inner key**: ID of group B\n *\n * **Value**: 'vertical' or 'horizontal'\n *\n * Note: tmp[groupA][groupB] == tmp[groupB][groupA]\n */\nexport type ArchitectureGroupAlignments = Record<\n string,\n Record>\n>;\n\nexport interface ArchitectureDataStructures {\n adjList: ArchitectureAdjacencyList;\n spatialMaps: ArchitectureSpatialMap[];\n groupAlignments: ArchitectureGroupAlignments;\n}\n\nexport interface ArchitectureState extends Record {\n nodes: Record;\n groups: Record;\n edges: ArchitectureEdge[];\n registeredIds: Record;\n dataStructures?: ArchitectureDataStructures;\n elements: Record;\n config: ArchitectureDiagramConfig;\n}\n\n/*=======================================*\\\n| Cytoscape Override Types |\n\\*=======================================*/\n\nexport interface EdgeSingularData {\n id: string;\n label?: string;\n source: string;\n sourceDir: ArchitectureDirection;\n sourceArrow?: boolean;\n sourceGroup?: boolean;\n target: string;\n targetDir: ArchitectureDirection;\n targetArrow?: boolean;\n targetGroup?: boolean;\n [key: string]: any;\n}\n\nexport const edgeData = (edge: cytoscape.EdgeSingular) => {\n return edge.data() as EdgeSingularData;\n};\n\nexport interface EdgeSingular extends cytoscape.EdgeSingular {\n _private: {\n bodyBounds: unknown;\n rscratch: {\n startX: number;\n startY: number;\n midX: number;\n midY: number;\n endX: number;\n endY: number;\n };\n };\n data(): EdgeSingularData;\n data(key: T): EdgeSingularData[T];\n}\n\nexport type NodeSingularData =\n | {\n type: 'service';\n id: string;\n icon?: string;\n label?: string;\n parent?: string;\n width: number;\n height: number;\n [key: string]: any;\n }\n | {\n type: 'junction';\n id: string;\n parent?: string;\n width: number;\n height: number;\n [key: string]: any;\n }\n | {\n type: 'group';\n id: string;\n icon?: string;\n label?: string;\n parent?: string;\n [key: string]: any;\n };\n\nexport const nodeData = (node: cytoscape.NodeSingular) => {\n return node.data() as NodeSingularData;\n};\n\nexport interface NodeSingular extends cytoscape.NodeSingular {\n _private: {\n bodyBounds: {\n h: number;\n w: number;\n x1: number;\n x2: number;\n y1: number;\n y2: number;\n };\n children: cytoscape.NodeSingular[];\n };\n data(): NodeSingularData;\n data(key: T): NodeSingularData[T];\n}\n", "import { getConfig as commonGetConfig } from '../../config.js';\nimport type { ArchitectureDiagramConfig } from '../../config.type.js';\nimport DEFAULT_CONFIG from '../../defaultConfig.js';\nimport type { DiagramDB } from '../../diagram-api/types.js';\nimport type { D3Element } from '../../types.js';\nimport { cleanAndMerge } from '../../utils.js';\nimport {\n clear as commonClear,\n getAccDescription,\n getAccTitle,\n getDiagramTitle,\n setAccDescription,\n setAccTitle,\n setDiagramTitle,\n} from '../common/commonDb.js';\nimport type {\n ArchitectureAlignment,\n ArchitectureDirectionPair,\n ArchitectureDirectionPairMap,\n ArchitectureEdge,\n ArchitectureGroup,\n ArchitectureJunction,\n ArchitectureNode,\n ArchitectureService,\n ArchitectureSpatialMap,\n ArchitectureState,\n} from './architectureTypes.js';\nimport {\n getArchitectureDirectionAlignment,\n getArchitectureDirectionPair,\n isArchitectureDirection,\n isArchitectureJunction,\n isArchitectureService,\n shiftPositionByArchitectureDirectionPair,\n} from './architectureTypes.js';\n\nconst DEFAULT_ARCHITECTURE_CONFIG: Required =\n DEFAULT_CONFIG.architecture;\nexport class ArchitectureDB implements DiagramDB {\n private nodes: Record = {};\n private groups: Record = {};\n private edges: ArchitectureEdge[] = [];\n private registeredIds: Record = {};\n private dataStructures?: ArchitectureState['dataStructures'];\n private elements: Record = {};\n private diagramId = '';\n\n constructor() {\n this.clear();\n }\n\n public setDiagramId(id: string): void {\n this.diagramId = id;\n }\n\n public getDiagramId(): string {\n return this.diagramId;\n }\n\n public clear(): void {\n this.nodes = {};\n this.groups = {};\n this.edges = [];\n this.registeredIds = {};\n this.dataStructures = undefined;\n this.elements = {};\n this.diagramId = '';\n commonClear();\n }\n\n public addService({\n id,\n icon,\n in: parent,\n title,\n iconText,\n }: Omit): void {\n if (this.registeredIds[id] !== undefined) {\n throw new Error(\n `The service id [${id}] is already in use by another ${this.registeredIds[id]}`\n );\n }\n if (parent !== undefined) {\n if (id === parent) {\n throw new Error(`The service [${id}] cannot be placed within itself`);\n }\n if (this.registeredIds[parent] === undefined) {\n throw new Error(\n `The service [${id}]'s parent does not exist. Please make sure the parent is created before this service`\n );\n }\n if (this.registeredIds[parent] === 'node') {\n throw new Error(`The service [${id}]'s parent is not a group`);\n }\n }\n\n this.registeredIds[id] = 'node';\n\n this.nodes[id] = {\n id,\n type: 'service',\n icon,\n iconText,\n title,\n edges: [],\n in: parent,\n };\n }\n\n public getServices(): ArchitectureService[] {\n return Object.values(this.nodes).filter(isArchitectureService);\n }\n\n public addJunction({ id, in: parent }: Omit): void {\n if (this.registeredIds[id] !== undefined) {\n throw new Error(\n `The junction id [${id}] is already in use by another ${this.registeredIds[id]}`\n );\n }\n if (parent !== undefined) {\n if (id === parent) {\n throw new Error(`The junction [${id}] cannot be placed within itself`);\n }\n if (this.registeredIds[parent] === undefined) {\n throw new Error(\n `The junction [${id}]'s parent does not exist. Please make sure the parent is created before this junction`\n );\n }\n if (this.registeredIds[parent] === 'node') {\n throw new Error(`The junction [${id}]'s parent is not a group`);\n }\n }\n\n this.registeredIds[id] = 'node';\n\n this.nodes[id] = {\n id,\n type: 'junction',\n edges: [],\n in: parent,\n };\n }\n\n public getJunctions(): ArchitectureJunction[] {\n return Object.values(this.nodes).filter(isArchitectureJunction);\n }\n\n public getNodes(): ArchitectureNode[] {\n return Object.values(this.nodes);\n }\n\n public getNode(id: string): ArchitectureNode | null {\n return this.nodes[id] ?? null;\n }\n\n public addGroup({ id, icon, in: parent, title }: ArchitectureGroup): void {\n if (this.registeredIds?.[id] !== undefined) {\n throw new Error(\n `The group id [${id}] is already in use by another ${this.registeredIds[id]}`\n );\n }\n if (parent !== undefined) {\n if (id === parent) {\n throw new Error(`The group [${id}] cannot be placed within itself`);\n }\n if (this.registeredIds?.[parent] === undefined) {\n throw new Error(\n `The group [${id}]'s parent does not exist. Please make sure the parent is created before this group`\n );\n }\n if (this.registeredIds?.[parent] === 'node') {\n throw new Error(`The group [${id}]'s parent is not a group`);\n }\n }\n\n this.registeredIds[id] = 'group';\n\n this.groups[id] = {\n id,\n icon,\n title,\n in: parent,\n };\n }\n public getGroups(): ArchitectureGroup[] {\n return Object.values(this.groups);\n }\n public addEdge({\n lhsId,\n rhsId,\n lhsDir,\n rhsDir,\n lhsInto,\n rhsInto,\n lhsGroup,\n rhsGroup,\n title,\n }: ArchitectureEdge): void {\n if (!isArchitectureDirection(lhsDir)) {\n throw new Error(\n `Invalid direction given for left hand side of edge ${lhsId}--${rhsId}. Expected (L,R,T,B) got ${String(lhsDir)}`\n );\n }\n if (!isArchitectureDirection(rhsDir)) {\n throw new Error(\n `Invalid direction given for right hand side of edge ${lhsId}--${rhsId}. Expected (L,R,T,B) got ${String(rhsDir)}`\n );\n }\n\n if (this.nodes[lhsId] === undefined && this.groups[lhsId] === undefined) {\n throw new Error(\n `The left-hand id [${lhsId}] does not yet exist. Please create the service/group before declaring an edge to it.`\n );\n }\n if (this.nodes[rhsId] === undefined && this.groups[rhsId] === undefined) {\n throw new Error(\n `The right-hand id [${rhsId}] does not yet exist. Please create the service/group before declaring an edge to it.`\n );\n }\n\n const lhsGroupId = this.nodes[lhsId].in;\n const rhsGroupId = this.nodes[rhsId].in;\n if (lhsGroup && lhsGroupId && rhsGroupId && lhsGroupId == rhsGroupId) {\n throw new Error(\n `The left-hand id [${lhsId}] is modified to traverse the group boundary, but the edge does not pass through two groups.`\n );\n }\n if (rhsGroup && lhsGroupId && rhsGroupId && lhsGroupId == rhsGroupId) {\n throw new Error(\n `The right-hand id [${rhsId}] is modified to traverse the group boundary, but the edge does not pass through two groups.`\n );\n }\n\n const edge = {\n lhsId,\n lhsDir,\n lhsInto,\n lhsGroup,\n rhsId,\n rhsDir,\n rhsInto,\n rhsGroup,\n title,\n };\n\n this.edges.push(edge);\n if (this.nodes[lhsId] && this.nodes[rhsId]) {\n this.nodes[lhsId].edges.push(this.edges[this.edges.length - 1]);\n this.nodes[rhsId].edges.push(this.edges[this.edges.length - 1]);\n }\n }\n\n public getEdges(): ArchitectureEdge[] {\n return this.edges;\n }\n\n /**\n * Returns the current diagram's adjacency list, spatial map, & group alignments.\n * If they have not been created, run the algorithms to generate them.\n * @returns\n */\n public getDataStructures() {\n if (this.dataStructures === undefined) {\n // Tracks how groups are aligned with one another. Generated while creating the adj list\n const groupAlignments: Record<\n string,\n Record>\n > = {};\n\n // Create an adjacency list of the diagram to perform BFS on\n // Outer reduce applied on all services\n // Inner reduce applied on the edges for a service\n const adjList = Object.entries(this.nodes).reduce<\n Record\n >((prevOuter, [id, service]) => {\n prevOuter[id] = service.edges.reduce((prevInner, edge) => {\n // track the direction groups connect to one another\n const lhsGroupId = this.getNode(edge.lhsId)?.in;\n const rhsGroupId = this.getNode(edge.rhsId)?.in;\n if (lhsGroupId && rhsGroupId && lhsGroupId !== rhsGroupId) {\n const alignment = getArchitectureDirectionAlignment(edge.lhsDir, edge.rhsDir);\n if (alignment !== 'bend') {\n groupAlignments[lhsGroupId] ??= {};\n groupAlignments[lhsGroupId][rhsGroupId] = alignment;\n groupAlignments[rhsGroupId] ??= {};\n groupAlignments[rhsGroupId][lhsGroupId] = alignment;\n }\n }\n\n if (edge.lhsId === id) {\n // source is LHS\n const pair = getArchitectureDirectionPair(edge.lhsDir, edge.rhsDir);\n if (pair) {\n prevInner[pair] = edge.rhsId;\n }\n } else {\n // source is RHS\n const pair = getArchitectureDirectionPair(edge.rhsDir, edge.lhsDir);\n if (pair) {\n prevInner[pair] = edge.lhsId;\n }\n }\n return prevInner;\n }, {});\n return prevOuter;\n }, {});\n\n // Configuration for the initial pass of BFS\n const firstId = Object.keys(adjList)[0];\n const visited = { [firstId]: 1 };\n // If a key is present in this object, it has not been visited\n const notVisited = Object.keys(adjList).reduce(\n (prev, id) => (id === firstId ? prev : { ...prev, [id]: 1 }),\n {} as Record\n );\n\n // Perform BFS on the adjacency list\n const BFS = (startingId: string): ArchitectureSpatialMap => {\n const spatialMap = { [startingId]: [0, 0] };\n const queue = [startingId];\n while (queue.length > 0) {\n const id = queue.shift();\n if (id) {\n visited[id] = 1;\n delete notVisited[id];\n const adj = adjList[id];\n const [posX, posY] = spatialMap[id];\n Object.entries(adj).forEach(([dir, rhsId]) => {\n if (!visited[rhsId]) {\n spatialMap[rhsId] = shiftPositionByArchitectureDirectionPair(\n [posX, posY],\n dir as ArchitectureDirectionPair\n );\n queue.push(rhsId);\n }\n });\n }\n }\n return spatialMap;\n };\n const spatialMaps = [BFS(firstId)];\n\n // If our diagram is disconnected, keep adding additional spatial maps until all disconnected graphs have been found\n while (Object.keys(notVisited).length > 0) {\n spatialMaps.push(BFS(Object.keys(notVisited)[0]));\n }\n this.dataStructures = {\n adjList,\n spatialMaps,\n groupAlignments,\n };\n }\n return this.dataStructures;\n }\n\n public setElementForId(id: string, element: D3Element): void {\n this.elements[id] = element;\n }\n\n public getElementById(id: string): D3Element {\n return this.elements[id];\n }\n\n public getConfig(): Required {\n return cleanAndMerge({\n ...DEFAULT_ARCHITECTURE_CONFIG,\n ...commonGetConfig().architecture,\n });\n }\n\n public getConfigField(\n field: T\n ): Required[T] {\n return this.getConfig()[field];\n }\n\n public setAccTitle = setAccTitle;\n public getAccTitle = getAccTitle;\n public setDiagramTitle = setDiagramTitle;\n public getDiagramTitle = getDiagramTitle;\n public getAccDescription = getAccDescription;\n public setAccDescription = setAccDescription;\n}\n\n/**\n * Typed wrapper for resolving an architecture diagram's config fields. Returns the default value if undefined\n * @param field - the config field to access\n * @returns\n */\n// export function getConfigField(\n// field: T\n// ): Required[T] {\n// return db.getConfig()[field];\n// }\n", "import type { DiagramStylesProvider } from '../../diagram-api/types.js';\nimport type { ArchitectureStyleOptions } from './architectureTypes.js';\n\nconst getStyles: DiagramStylesProvider = (options: ArchitectureStyleOptions) =>\n `\n .edge {\n stroke-width: ${options.archEdgeWidth};\n stroke: ${options.archEdgeColor};\n fill: none;\n }\n\n .arrow {\n fill: ${options.archEdgeArrowColor};\n }\n\n .node-bkg {\n fill: none;\n stroke: ${options.archGroupBorderColor};\n stroke-width: ${options.archGroupBorderWidth};\n stroke-dasharray: 8;\n }\n .node-icon-text {\n display: flex; \n align-items: center;\n }\n \n .node-icon-text > div {\n color: #fff;\n margin: 1px;\n height: fit-content;\n text-align: center;\n overflow: hidden;\n display: -webkit-box;\n -webkit-box-orient: vertical;\n }\n`;\n\nexport default getStyles;\n", "import type { LayoutOptions, Position } from 'cytoscape';\nimport cytoscape from 'cytoscape';\nimport fcose from 'cytoscape-fcose';\nimport { select } from 'd3';\nimport type { DrawDefinition, SVG } from '../../diagram-api/types.js';\nimport type { Diagram } from '../../Diagram.js';\nimport { log } from '../../logger.js';\nimport { registerIconPacks } from '../../rendering-util/icons.js';\nimport { selectSvgElement } from '../../rendering-util/selectSvgElement.js';\nimport { setupGraphViewbox } from '../../setupGraphViewbox.js';\nimport type { ArchitectureDB } from './architectureDb.js';\nimport { architectureIcons } from './architectureIcons.js';\nimport type {\n ArchitectureAlignment,\n ArchitectureDataStructures,\n ArchitectureGroupAlignments,\n ArchitectureJunction,\n ArchitectureSpatialMap,\n EdgeSingular,\n EdgeSingularData,\n NodeSingularData,\n} from './architectureTypes.js';\nimport {\n type ArchitectureDirection,\n type ArchitectureEdge,\n type ArchitectureGroup,\n type ArchitectureService,\n ArchitectureDirectionName,\n edgeData,\n getOppositeArchitectureDirection,\n isArchitectureDirectionXY,\n isArchitectureDirectionY,\n nodeData,\n} from './architectureTypes.js';\nimport { drawEdges, drawGroups, drawJunctions, drawServices } from './svgDraw.js';\n\nregisterIconPacks([\n {\n name: architectureIcons.prefix,\n icons: architectureIcons,\n },\n]);\ncytoscape.use(fcose as any);\n\nfunction addServices(services: ArchitectureService[], cy: cytoscape.Core, db: ArchitectureDB) {\n services.forEach((service) => {\n cy.add({\n group: 'nodes',\n data: {\n type: 'service',\n id: service.id,\n icon: service.icon,\n label: service.title,\n parent: service.in,\n width: db.getConfigField('iconSize'),\n height: db.getConfigField('iconSize'),\n } as NodeSingularData,\n classes: 'node-service',\n });\n });\n}\n\nfunction addJunctions(junctions: ArchitectureJunction[], cy: cytoscape.Core, db: ArchitectureDB) {\n junctions.forEach((junction) => {\n cy.add({\n group: 'nodes',\n data: {\n type: 'junction',\n id: junction.id,\n parent: junction.in,\n width: db.getConfigField('iconSize'),\n height: db.getConfigField('iconSize'),\n } as NodeSingularData,\n classes: 'node-junction',\n });\n });\n}\n\nfunction positionNodes(db: ArchitectureDB, cy: cytoscape.Core) {\n cy.nodes().map((node) => {\n const data = nodeData(node);\n if (data.type === 'group') {\n return;\n }\n data.x = node.position().x;\n data.y = node.position().y;\n\n const nodeElem = db.getElementById(data.id);\n nodeElem.attr('transform', 'translate(' + (data.x || 0) + ',' + (data.y || 0) + ')');\n });\n}\n\nfunction addGroups(groups: ArchitectureGroup[], cy: cytoscape.Core) {\n groups.forEach((group) => {\n cy.add({\n group: 'nodes',\n data: {\n type: 'group',\n id: group.id,\n icon: group.icon,\n label: group.title,\n parent: group.in,\n } as NodeSingularData,\n classes: 'node-group',\n });\n });\n}\n\nfunction addEdges(edges: ArchitectureEdge[], cy: cytoscape.Core) {\n edges.forEach((parsedEdge) => {\n const { lhsId, rhsId, lhsInto, lhsGroup, rhsInto, lhsDir, rhsDir, rhsGroup, title } =\n parsedEdge;\n const edgeType = isArchitectureDirectionXY(parsedEdge.lhsDir, parsedEdge.rhsDir)\n ? 'segments'\n : 'straight';\n const edge: EdgeSingularData = {\n id: `${lhsId}-${rhsId}`,\n label: title,\n source: lhsId,\n sourceDir: lhsDir,\n sourceArrow: lhsInto,\n sourceGroup: lhsGroup,\n sourceEndpoint:\n lhsDir === 'L'\n ? '0 50%'\n : lhsDir === 'R'\n ? '100% 50%'\n : lhsDir === 'T'\n ? '50% 0'\n : '50% 100%',\n target: rhsId,\n targetDir: rhsDir,\n targetArrow: rhsInto,\n targetGroup: rhsGroup,\n targetEndpoint:\n rhsDir === 'L'\n ? '0 50%'\n : rhsDir === 'R'\n ? '100% 50%'\n : rhsDir === 'T'\n ? '50% 0'\n : '50% 100%',\n };\n cy.add({\n group: 'edges',\n data: edge,\n classes: edgeType,\n });\n });\n}\n\nfunction getAlignments(\n db: ArchitectureDB,\n spatialMaps: ArchitectureSpatialMap[],\n groupAlignments: ArchitectureGroupAlignments\n): fcose.FcoseAlignmentConstraint {\n /**\n * Flattens the alignment object so nodes in different groups will be in the same alignment array IFF their groups don't connect in a conflicting alignment\n *\n * i.e., two groups which connect horizontally should not have nodes with vertical alignments to one another\n *\n * See: #5952\n *\n * @param alignmentObj - alignment object with the outer key being the row/col # and the inner key being the group name mapped to the nodes on that axis in the group\n * @param alignmentDir - alignment direction\n * @returns flattened alignment object with an arbitrary key mapping to nodes in the same row/col\n */\n const flattenAlignments = (\n alignmentObj: Record>,\n alignmentDir: ArchitectureAlignment\n ): Record => {\n return Object.entries(alignmentObj).reduce(\n (prev, [dir, alignments]) => {\n // prev is the mapping of x/y coordinate to an array of the nodes in that row/column\n let cnt = 0;\n const arr = Object.entries(alignments); // [group name, array of nodes within the group on axis dir]\n if (arr.length === 1) {\n // If only one group exists in the row/column, we don't need to do anything else\n prev[dir] = arr[0][1];\n return prev;\n }\n for (let i = 0; i < arr.length - 1; i++) {\n for (let j = i + 1; j < arr.length; j++) {\n const [aGroupId, aNodeIds] = arr[i];\n const [bGroupId, bNodeIds] = arr[j];\n const alignment = groupAlignments[aGroupId]?.[bGroupId]; // Get how the two groups are intended to align (undefined if they aren't)\n\n if (alignment === alignmentDir) {\n // If the intended alignment between the two groups is the same as the alignment we are parsing\n prev[dir] ??= [];\n prev[dir] = [...prev[dir], ...aNodeIds, ...bNodeIds]; // add the node ids of both groups to the axis array in prev\n } else if (aGroupId === 'default' || bGroupId === 'default') {\n // If either of the groups are in the default space (not in a group), use the same behavior as above\n prev[dir] ??= [];\n prev[dir] = [...prev[dir], ...aNodeIds, ...bNodeIds];\n } else {\n // Otherwise, the nodes in the two groups are not intended to align\n const keyA = `${dir}-${cnt++}`;\n prev[keyA] = aNodeIds;\n const keyB = `${dir}-${cnt++}`;\n prev[keyB] = bNodeIds;\n }\n }\n }\n\n return prev;\n },\n {} as Record\n );\n };\n\n const alignments = spatialMaps.map((spatialMap) => {\n const horizontalAlignments: Record> = {};\n const verticalAlignments: Record> = {};\n\n // Group service ids in an object with their x and y coordinate as the key\n Object.entries(spatialMap).forEach(([id, [x, y]]) => {\n const nodeGroup = db.getNode(id)?.in ?? 'default';\n\n horizontalAlignments[y] ??= {};\n horizontalAlignments[y][nodeGroup] ??= [];\n horizontalAlignments[y][nodeGroup].push(id);\n\n verticalAlignments[x] ??= {};\n verticalAlignments[x][nodeGroup] ??= [];\n verticalAlignments[x][nodeGroup].push(id);\n });\n\n // Merge the values of each object into a list if the inner list has at least 2 elements\n return {\n horiz: Object.values(flattenAlignments(horizontalAlignments, 'horizontal')).filter(\n (arr) => arr.length > 1\n ),\n vert: Object.values(flattenAlignments(verticalAlignments, 'vertical')).filter(\n (arr) => arr.length > 1\n ),\n };\n });\n\n // Merge the alignment lists for each spatial map into one 2d array per axis\n const [horizontal, vertical] = alignments.reduce(\n ([prevHoriz, prevVert], { horiz, vert }) => {\n return [\n [...prevHoriz, ...horiz],\n [...prevVert, ...vert],\n ];\n },\n [[] as string[][], [] as string[][]]\n );\n\n return {\n horizontal,\n vertical,\n };\n}\n\nfunction getRelativeConstraints(\n spatialMaps: ArchitectureSpatialMap[],\n db: ArchitectureDB\n): fcose.FcoseRelativePlacementConstraint[] {\n const relativeConstraints: fcose.FcoseRelativePlacementConstraint[] = [];\n const posToStr = (pos: number[]) => `${pos[0]},${pos[1]}`;\n const strToPos = (pos: string) => pos.split(',').map((p) => parseInt(p));\n\n spatialMaps.forEach((spatialMap) => {\n const invSpatialMap = Object.fromEntries(\n Object.entries(spatialMap).map(([id, pos]) => [posToStr(pos), id])\n );\n\n // perform BFS\n const queue = [posToStr([0, 0])];\n const visited: Record = {};\n const directions: Record = {\n L: [-1, 0],\n R: [1, 0],\n T: [0, 1],\n B: [0, -1],\n };\n while (queue.length > 0) {\n const curr = queue.shift();\n if (curr) {\n visited[curr] = 1;\n const currId = invSpatialMap[curr];\n if (currId) {\n const currPos = strToPos(curr);\n Object.entries(directions).forEach(([dir, shift]) => {\n const newPos = posToStr([currPos[0] + shift[0], currPos[1] + shift[1]]);\n const newId = invSpatialMap[newPos];\n // If there is an adjacent service to the current one and it has not yet been visited\n if (newId && !visited[newPos]) {\n queue.push(newPos);\n // @ts-ignore cannot determine if left/right or top/bottom are paired together\n relativeConstraints.push({\n [ArchitectureDirectionName[dir as ArchitectureDirection]]: newId,\n [ArchitectureDirectionName[\n getOppositeArchitectureDirection(dir as ArchitectureDirection)\n ]]: currId,\n gap: 1.5 * db.getConfigField('iconSize'),\n });\n }\n });\n }\n }\n }\n });\n return relativeConstraints;\n}\n\nfunction layoutArchitecture(\n services: ArchitectureService[],\n junctions: ArchitectureJunction[],\n groups: ArchitectureGroup[],\n edges: ArchitectureEdge[],\n db: ArchitectureDB,\n { spatialMaps, groupAlignments }: ArchitectureDataStructures\n): Promise {\n return new Promise((resolve) => {\n const renderEl = select('body').append('div').attr('id', 'cy').attr('style', 'display:none');\n const cy = cytoscape({\n container: document.getElementById('cy'),\n style: [\n {\n selector: 'edge',\n style: {\n 'curve-style': 'straight',\n 'source-endpoint': 'data(sourceEndpoint)',\n 'target-endpoint': 'data(targetEndpoint)',\n },\n },\n {\n selector: 'edge[label]',\n style: {\n label: 'data(label)',\n },\n },\n {\n selector: 'edge.segments',\n style: {\n 'curve-style': 'segments',\n 'segment-weights': '0',\n 'segment-distances': [0.5],\n // @ts-ignore Incorrect library types\n 'edge-distances': 'endpoints',\n 'source-endpoint': 'data(sourceEndpoint)',\n 'target-endpoint': 'data(targetEndpoint)',\n },\n },\n {\n selector: 'node',\n style: {\n // @ts-ignore Incorrect library types\n 'compound-sizing-wrt-labels': 'include',\n },\n },\n {\n selector: 'node[label]',\n style: {\n 'text-valign': 'bottom',\n 'text-halign': 'center',\n 'font-size': `${db.getConfigField('fontSize')}px`,\n },\n },\n {\n selector: '.node-service',\n style: {\n label: 'data(label)',\n width: 'data(width)',\n height: 'data(height)',\n },\n },\n {\n selector: '.node-junction',\n style: {\n width: 'data(width)',\n height: 'data(height)',\n },\n },\n {\n selector: '.node-group',\n style: {\n // @ts-ignore Incorrect library types\n padding: `${db.getConfigField('padding')}px`,\n },\n },\n ],\n layout: {\n name: 'grid',\n boundingBox: {\n x1: 0,\n x2: 100,\n y1: 0,\n y2: 100,\n },\n },\n });\n // Remove element after layout\n renderEl.remove();\n\n addGroups(groups, cy);\n addServices(services, cy, db);\n addJunctions(junctions, cy, db);\n addEdges(edges, cy);\n // Use the spatial map to create alignment arrays for fcose\n const alignmentConstraint = getAlignments(db, spatialMaps, groupAlignments);\n\n // Create the relative constraints for fcose by using an inverse of the spatial map and performing BFS on it\n const relativePlacementConstraint = getRelativeConstraints(spatialMaps, db);\n\n const iconSize = db.getConfigField('iconSize');\n const sameGroupIdealLength = db.getConfigField('idealEdgeLengthMultiplier') * iconSize;\n const crossGroupIdealLength = 0.5 * iconSize;\n const sameGroupElasticity = db.getConfigField('edgeElasticity');\n\n const layout = cy.layout({\n name: 'fcose',\n quality: 'proof',\n randomize: db.getConfigField('randomize'),\n nodeSeparation: db.getConfigField('nodeSeparation'),\n numIter: db.getConfigField('numIter'),\n styleEnabled: false,\n animate: false,\n nodeDimensionsIncludeLabels: false,\n // Adjust the edge parameters if it passes through the border of a group\n // Hacky fix for: https://github.com/iVis-at-Bilkent/cytoscape.js-fcose/issues/67\n idealEdgeLength(edge: EdgeSingular) {\n const [nodeA, nodeB] = edge.connectedNodes();\n const { parent: parentA } = nodeData(nodeA);\n const { parent: parentB } = nodeData(nodeB);\n return parentA === parentB ? sameGroupIdealLength : crossGroupIdealLength;\n },\n edgeElasticity(edge: EdgeSingular) {\n const [nodeA, nodeB] = edge.connectedNodes();\n const { parent: parentA } = nodeData(nodeA);\n const { parent: parentB } = nodeData(nodeB);\n return parentA === parentB ? sameGroupElasticity : 0.001;\n },\n alignmentConstraint,\n relativePlacementConstraint,\n } as LayoutOptions);\n\n // Once the diagram has been generated and the service's position cords are set, adjust the XY edges to have a 90deg bend\n layout.one('layoutstop', () => {\n function getSegmentWeights(\n source: Position,\n target: Position,\n pointX: number,\n pointY: number\n ) {\n let W, D;\n const { x: sX, y: sY } = source;\n const { x: tX, y: tY } = target;\n\n D =\n (pointY - sY + ((sX - pointX) * (sY - tY)) / (sX - tX)) /\n Math.sqrt(1 + Math.pow((sY - tY) / (sX - tX), 2));\n W = Math.sqrt(Math.pow(pointY - sY, 2) + Math.pow(pointX - sX, 2) - Math.pow(D, 2));\n\n const distAB = Math.sqrt(Math.pow(tX - sX, 2) + Math.pow(tY - sY, 2));\n W = W / distAB;\n\n //check whether the point (pointX, pointY) is on right or left of the line src to tgt. for instance : a point C(X, Y) and line (AB). d=(xB-xA)(yC-yA)-(yB-yA)(xC-xA). if d>0, then C is on left of the line. if d<0, it is on right. if d=0, it is on the line.\n let delta1 = (tX - sX) * (pointY - sY) - (tY - sY) * (pointX - sX);\n switch (true) {\n case delta1 >= 0:\n delta1 = 1;\n break;\n case delta1 < 0:\n delta1 = -1;\n break;\n }\n //check whether the point (pointX, pointY) is \"behind\" the line src to tgt\n let delta2 = (tX - sX) * (pointX - sX) + (tY - sY) * (pointY - sY);\n switch (true) {\n case delta2 >= 0:\n delta2 = 1;\n break;\n case delta2 < 0:\n delta2 = -1;\n break;\n }\n\n D = Math.abs(D) * delta1; //ensure that sign of D is same as sign of delta1. Hence we need to take absolute value of D and multiply by delta1\n W = W * delta2;\n\n return {\n distances: D,\n weights: W,\n };\n }\n cy.startBatch();\n for (const edge of Object.values(cy.edges())) {\n if (edge.data?.()) {\n const { x: sX, y: sY } = edge.source().position();\n const { x: tX, y: tY } = edge.target().position();\n if (sX !== tX && sY !== tY) {\n const sEP = edge.sourceEndpoint();\n const tEP = edge.targetEndpoint();\n const { sourceDir } = edgeData(edge);\n const [pointX, pointY] = isArchitectureDirectionY(sourceDir)\n ? [sEP.x, tEP.y]\n : [tEP.x, sEP.y];\n const { weights, distances } = getSegmentWeights(sEP, tEP, pointX, pointY);\n edge.style('segment-distances', distances);\n edge.style('segment-weights', weights);\n }\n }\n }\n cy.endBatch();\n layout.run();\n });\n layout.run();\n\n cy.ready((e) => {\n log.info('Ready', e);\n resolve(cy);\n });\n });\n}\n\nexport const draw: DrawDefinition = async (text, id, _version, diagObj: Diagram) => {\n // TODO: Add title support for architecture diagrams\n\n const db = diagObj.db as ArchitectureDB;\n db.setDiagramId(id);\n\n const services = db.getServices();\n const junctions = db.getJunctions();\n const groups = db.getGroups();\n const edges = db.getEdges();\n const ds = db.getDataStructures();\n\n const svg: SVG = selectSvgElement(id);\n\n const edgesElem = svg.append('g');\n edgesElem.attr('class', 'architecture-edges');\n\n const servicesElem = svg.append('g');\n servicesElem.attr('class', 'architecture-services');\n\n const groupElem = svg.append('g');\n groupElem.attr('class', 'architecture-groups');\n\n await drawServices(db, servicesElem, services, id);\n drawJunctions(db, servicesElem, junctions, id);\n\n const cy = await layoutArchitecture(services, junctions, groups, edges, db, ds);\n\n await drawEdges(edgesElem, cy, db, id);\n await drawGroups(groupElem, cy, db, id);\n positionNodes(db, cy);\n\n setupGraphViewbox(undefined, svg, db.getConfigField('padding'), db.getConfigField('useMaxWidth'));\n};\n\nexport const renderer = { draw };\n", "import { unknownIcon } from '../../rendering-util/icons.js';\nimport type { IconifyJSON } from '@iconify/types';\n\nconst wrapIcon = (icon: string) => {\n return `${icon}`;\n};\n\nexport const architectureIcons: IconifyJSON = {\n prefix: 'mermaid-architecture',\n height: 80,\n width: 80,\n icons: {\n database: {\n body: wrapIcon(\n ''\n ),\n },\n server: {\n body: wrapIcon(\n ''\n ),\n },\n disk: {\n body: wrapIcon(\n ''\n ),\n },\n internet: {\n body: wrapIcon(\n ''\n ),\n },\n cloud: {\n body: wrapIcon(\n ''\n ),\n },\n unknown: unknownIcon,\n blank: {\n body: wrapIcon(''),\n },\n },\n};\n", "import type cytoscape from 'cytoscape';\nimport { getConfig } from '../../diagram-api/diagramAPI.js';\nimport { createText } from '../../rendering-util/createText.js';\nimport { getIconSVG } from '../../rendering-util/icons.js';\nimport type { D3Element } from '../../types.js';\nimport { sanitizeText } from '../common/common.js';\nimport type { ArchitectureDB } from './architectureDb.js';\nimport { architectureIcons } from './architectureIcons.js';\nimport {\n ArchitectureDirectionArrow,\n ArchitectureDirectionArrowShift,\n edgeData,\n getArchitectureDirectionPair,\n getArchitectureDirectionXYFactors,\n isArchitectureDirectionX,\n isArchitectureDirectionXY,\n isArchitectureDirectionY,\n isArchitecturePairXY,\n nodeData,\n type ArchitectureJunction,\n type ArchitectureService,\n} from './architectureTypes.js';\nimport { getEdgeId } from '../../utils.js';\n\nexport const drawEdges = async function (\n edgesEl: D3Element,\n cy: cytoscape.Core,\n db: ArchitectureDB,\n diagramId: string\n) {\n const padding = db.getConfigField('padding');\n const iconSize = db.getConfigField('iconSize');\n const halfIconSize = iconSize / 2;\n const arrowSize = iconSize / 6;\n const halfArrowSize = arrowSize / 2;\n\n await Promise.all(\n cy.edges().map(async (edge) => {\n const {\n source,\n sourceDir,\n sourceArrow,\n sourceGroup,\n target,\n targetDir,\n targetArrow,\n targetGroup,\n label,\n } = edgeData(edge);\n let { x: startX, y: startY } = edge[0].sourceEndpoint();\n const { x: midX, y: midY } = edge[0].midpoint();\n let { x: endX, y: endY } = edge[0].targetEndpoint();\n\n // Adjust the edge distance if it has the {group} modifier\n const groupEdgeShift = padding + 4;\n // +18 comes from the service label height that extends the padding on the bottom side of each group\n if (sourceGroup) {\n if (isArchitectureDirectionX(sourceDir)) {\n startX += sourceDir === 'L' ? -groupEdgeShift : groupEdgeShift;\n } else {\n startY += sourceDir === 'T' ? -groupEdgeShift : groupEdgeShift + 18;\n }\n }\n\n if (targetGroup) {\n if (isArchitectureDirectionX(targetDir)) {\n endX += targetDir === 'L' ? -groupEdgeShift : groupEdgeShift;\n } else {\n endY += targetDir === 'T' ? -groupEdgeShift : groupEdgeShift + 18;\n }\n }\n\n // Adjust the edge distance if it doesn't have the {group} modifier and the endpoint is a junction node\n if (!sourceGroup && db.getNode(source)?.type === 'junction') {\n if (isArchitectureDirectionX(sourceDir)) {\n startX += sourceDir === 'L' ? halfIconSize : -halfIconSize;\n } else {\n startY += sourceDir === 'T' ? halfIconSize : -halfIconSize;\n }\n }\n if (!targetGroup && db.getNode(target)?.type === 'junction') {\n if (isArchitectureDirectionX(targetDir)) {\n endX += targetDir === 'L' ? halfIconSize : -halfIconSize;\n } else {\n endY += targetDir === 'T' ? halfIconSize : -halfIconSize;\n }\n }\n\n if (edge[0]._private.rscratch) {\n // const bounds = edge[0]._private.rscratch;\n\n const g = edgesEl.insert('g');\n\n g.insert('path')\n .attr('d', `M ${startX},${startY} L ${midX},${midY} L${endX},${endY} `)\n .attr('class', 'edge')\n .attr('id', `${diagramId}-${getEdgeId(source, target, { prefix: 'L' })}`);\n\n if (sourceArrow) {\n const xShift = isArchitectureDirectionX(sourceDir)\n ? ArchitectureDirectionArrowShift[sourceDir](startX, arrowSize)\n : startX - halfArrowSize;\n const yShift = isArchitectureDirectionY(sourceDir)\n ? ArchitectureDirectionArrowShift[sourceDir](startY, arrowSize)\n : startY - halfArrowSize;\n\n g.insert('polygon')\n .attr('points', ArchitectureDirectionArrow[sourceDir](arrowSize))\n .attr('transform', `translate(${xShift},${yShift})`)\n .attr('class', 'arrow');\n }\n if (targetArrow) {\n const xShift = isArchitectureDirectionX(targetDir)\n ? ArchitectureDirectionArrowShift[targetDir](endX, arrowSize)\n : endX - halfArrowSize;\n const yShift = isArchitectureDirectionY(targetDir)\n ? ArchitectureDirectionArrowShift[targetDir](endY, arrowSize)\n : endY - halfArrowSize;\n\n g.insert('polygon')\n .attr('points', ArchitectureDirectionArrow[targetDir](arrowSize))\n .attr('transform', `translate(${xShift},${yShift})`)\n .attr('class', 'arrow');\n }\n\n if (label) {\n const axis = !isArchitectureDirectionXY(sourceDir, targetDir)\n ? isArchitectureDirectionX(sourceDir)\n ? 'X'\n : 'Y'\n : 'XY';\n\n let width = 0;\n if (axis === 'X') {\n width = Math.abs(startX - endX);\n } else if (axis === 'Y') {\n // Reduce width by a factor of 1.5 to avoid overlapping service labels\n width = Math.abs(startY - endY) / 1.5;\n } else {\n width = Math.abs(startX - endX) / 2;\n }\n\n const textElem = g.append('g');\n await createText(\n textElem,\n label,\n {\n useHtmlLabels: false,\n width,\n classes: 'architecture-service-label',\n },\n getConfig()\n );\n\n textElem\n .attr('dy', '1em')\n .attr('alignment-baseline', 'middle')\n .attr('dominant-baseline', 'middle')\n .attr('text-anchor', 'middle');\n\n if (axis === 'X') {\n textElem.attr('transform', 'translate(' + midX + ', ' + midY + ')');\n } else if (axis === 'Y') {\n textElem.attr('transform', 'translate(' + midX + ', ' + midY + ') rotate(-90)');\n } else if (axis === 'XY') {\n const pair = getArchitectureDirectionPair(sourceDir, targetDir);\n if (pair && isArchitecturePairXY(pair)) {\n const bboxOrig = textElem.node().getBoundingClientRect();\n const [x, y] = getArchitectureDirectionXYFactors(pair);\n\n textElem\n .attr('dominant-baseline', 'auto')\n .attr('transform', `rotate(${-1 * x * y * 45})`);\n\n // Calculate the new width/height with the rotation applied, and transform to the proper position\n const bboxNew = textElem.node().getBoundingClientRect();\n textElem.attr(\n 'transform',\n `\n translate(${midX}, ${midY - bboxOrig.height / 2})\n translate(${(x * bboxNew.width) / 2}, ${(y * bboxNew.height) / 2})\n rotate(${-1 * x * y * 45}, 0, ${bboxOrig.height / 2})\n `\n );\n }\n }\n }\n }\n })\n );\n};\n\nexport const drawGroups = async function (\n groupsEl: D3Element,\n cy: cytoscape.Core,\n db: ArchitectureDB,\n diagramId: string\n) {\n const padding = db.getConfigField('padding');\n const groupIconSize = padding * 0.75;\n\n const fontSize = db.getConfigField('fontSize');\n\n const iconSize = db.getConfigField('iconSize');\n const halfIconSize = iconSize / 2;\n\n await Promise.all(\n cy.nodes().map(async (node) => {\n const data = nodeData(node);\n if (data.type === 'group') {\n const { h, w, x1, y1 } = node.boundingBox();\n\n const groupsNode = groupsEl.append('rect');\n groupsNode\n .attr('id', `${diagramId}-group-${data.id}`)\n .attr('x', x1 + halfIconSize)\n .attr('y', y1 + halfIconSize)\n .attr('width', w)\n .attr('height', h)\n .attr('class', 'node-bkg');\n\n const groupLabelContainer = groupsEl.append('g');\n let shiftedX1 = x1;\n let shiftedY1 = y1;\n if (data.icon) {\n const bkgElem = groupLabelContainer.append('g');\n bkgElem.html(\n `${await getIconSVG(data.icon, { height: groupIconSize, width: groupIconSize, fallbackPrefix: architectureIcons.prefix })}`\n );\n bkgElem.attr(\n 'transform',\n 'translate(' +\n (shiftedX1 + halfIconSize + 1) +\n ', ' +\n (shiftedY1 + halfIconSize + 1) +\n ')'\n );\n shiftedX1 += groupIconSize;\n // TODO: test with more values\n // - 1 - 2 comes from the Y axis transform of the icon and label\n shiftedY1 += fontSize / 2 - 1 - 2;\n }\n if (data.label) {\n const textElem = groupLabelContainer.append('g');\n await createText(\n textElem,\n data.label,\n {\n useHtmlLabels: false,\n width: w,\n classes: 'architecture-service-label',\n },\n getConfig()\n );\n textElem\n .attr('dy', '1em')\n .attr('alignment-baseline', 'middle')\n .attr('dominant-baseline', 'start')\n .attr('text-anchor', 'start');\n\n textElem.attr(\n 'transform',\n 'translate(' +\n (shiftedX1 + halfIconSize + 4) +\n ', ' +\n (shiftedY1 + halfIconSize + 2) +\n ')'\n );\n }\n db.setElementForId(data.id, groupsNode);\n }\n })\n );\n};\n\nexport const drawServices = async function (\n db: ArchitectureDB,\n elem: D3Element,\n services: ArchitectureService[],\n diagramId: string\n): Promise {\n const config = getConfig();\n for (const service of services) {\n const serviceElem = elem.append('g');\n const iconSize = db.getConfigField('iconSize');\n\n if (service.title) {\n const textElem = serviceElem.append('g');\n await createText(\n textElem,\n service.title,\n {\n useHtmlLabels: false,\n width: iconSize * 1.5,\n classes: 'architecture-service-label',\n },\n config\n );\n\n textElem\n .attr('dy', '1em')\n .attr('alignment-baseline', 'middle')\n .attr('dominant-baseline', 'middle')\n .attr('text-anchor', 'middle');\n\n textElem.attr('transform', 'translate(' + iconSize / 2 + ', ' + iconSize + ')');\n }\n\n const bkgElem = serviceElem.append('g');\n if (service.icon) {\n // TODO: should a warning be given to end-users saying which icon names are available?\n // if (!isIconNameInUse(service.icon)) {\n // throw new Error(`Invalid SVG Icon name: \"${service.icon}\"`);\n // }\n bkgElem.html(\n `${await getIconSVG(service.icon, { height: iconSize, width: iconSize, fallbackPrefix: architectureIcons.prefix })}`\n );\n } else if (service.iconText) {\n bkgElem.html(\n `${await getIconSVG('blank', { height: iconSize, width: iconSize, fallbackPrefix: architectureIcons.prefix })}`\n );\n const textElemContainer = bkgElem.append('g');\n const fo = textElemContainer\n .append('foreignObject')\n .attr('width', iconSize)\n .attr('height', iconSize);\n const divElem = fo\n .append('div')\n .attr('class', 'node-icon-text')\n .attr('style', `height: ${iconSize}px;`)\n .append('div')\n .html(sanitizeText(service.iconText, config));\n const fontSize =\n parseInt(\n window\n .getComputedStyle(divElem.node(), null)\n .getPropertyValue('font-size')\n .replace(/\\D/g, '')\n ) ?? 16;\n divElem.attr('style', `-webkit-line-clamp: ${Math.floor((iconSize - 2) / fontSize)};`);\n } else {\n bkgElem\n .append('path')\n .attr('class', 'node-bkg')\n .attr('id', `${diagramId}-node-${service.id}`)\n .attr(\n 'd',\n `M0,${iconSize} V5 Q0,0 5,0 H${iconSize - 5} Q${iconSize},0 ${iconSize},5 V${iconSize} Z`\n );\n }\n\n serviceElem\n .attr('id', `${diagramId}-service-${service.id}`)\n .attr('class', 'architecture-service');\n\n const { width, height } = serviceElem.node().getBBox();\n service.width = width;\n service.height = height;\n db.setElementForId(service.id, serviceElem);\n }\n return 0;\n};\n\nexport const drawJunctions = function (\n db: ArchitectureDB,\n elem: D3Element,\n junctions: ArchitectureJunction[],\n diagramId: string\n) {\n junctions.forEach((junction) => {\n const junctionElem = elem.append('g');\n const iconSize = db.getConfigField('iconSize');\n\n const bkgElem = junctionElem.append('g');\n bkgElem\n .append('rect')\n .attr('id', `${diagramId}-node-${junction.id}`)\n .attr('fill-opacity', '0')\n .attr('width', iconSize)\n .attr('height', iconSize);\n\n junctionElem.attr('class', 'architecture-junction');\n\n const { width, height } = junctionElem._groups[0][0].getBBox();\n junctionElem.width = width;\n junctionElem.height = height;\n db.setElementForId(junction.id, junctionElem);\n });\n};\n", "import type { DiagramDefinition } from '../../diagram-api/types.js';\nimport { parser } from './architectureParser.js';\nimport { ArchitectureDB } from './architectureDb.js';\nimport styles from './architectureStyles.js';\nimport { renderer } from './architectureRenderer.js';\n\nexport const diagram: DiagramDefinition = {\n parser,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