UNPKG

mermaid

Version:

Markdown-ish syntax for generating flowcharts, mindmaps, sequence diagrams, class diagrams, gantt charts, git graphs and more.

4 lines 188 kB
{ "version": 3, "sources": ["../../../src/diagrams/flowchart/flowDb.ts", "../../../src/diagrams/flowchart/flowRenderer-v3-unified.ts", "../../../src/diagrams/flowchart/parser/flow.jison", "../../../src/diagrams/flowchart/parser/flowParser.ts", "../../../src/diagrams/flowchart/styles.ts", "../../../src/diagrams/flowchart/flowDiagram.ts"], "sourcesContent": ["import { select } from 'd3';\nimport * as yaml from 'js-yaml';\nimport { getConfig, defaultConfig } from '../../diagram-api/diagramAPI.js';\nimport type { DiagramDB } from '../../diagram-api/types.js';\nimport { log } from '../../logger.js';\nimport { isValidShape, type ShapeID } from '../../rendering-util/rendering-elements/shapes.js';\nimport type { Edge, Node } from '../../rendering-util/types.js';\nimport type { EdgeMetaData, NodeMetaData } from '../../types.js';\nimport utils, { getEdgeId } from '../../utils.js';\nimport common from '../common/common.js';\nimport {\n setAccTitle,\n getAccTitle,\n getAccDescription,\n setAccDescription,\n clear as commonClear,\n setDiagramTitle,\n getDiagramTitle,\n} from '../common/commonDb.js';\nimport type {\n FlowClass,\n FlowEdge,\n FlowLink,\n FlowSubGraph,\n FlowText,\n FlowVertex,\n FlowVertexTypeParam,\n} from './types.js';\n\ninterface LinkData {\n id: string;\n}\n\nconst MERMAID_DOM_ID_PREFIX = 'flowchart-';\n\n// We are using arrow functions assigned to class instance fields instead of methods as they are required by flow JISON\nexport class FlowDB implements DiagramDB {\n private vertexCounter = 0;\n private config = getConfig();\n private vertices = new Map<string, FlowVertex>();\n private edges: FlowEdge[] & { defaultInterpolate?: string; defaultStyle?: string[] } = [];\n private classes = new Map<string, FlowClass>();\n private subGraphs: FlowSubGraph[] = [];\n private subGraphLookup = new Map<string, FlowSubGraph>();\n private tooltips = new Map<string, string>();\n private subCount = 0;\n private firstGraphFlag = true;\n private direction: string | undefined;\n private version: string | undefined; // As in graph\n private secCount = -1;\n private posCrossRef: number[] = [];\n\n // Functions to be run after graph rendering\n private funs: ((element: Element) => void)[] = []; // cspell:ignore funs\n\n constructor() {\n this.funs.push(this.setupToolTips.bind(this));\n\n // Needed for JISON since it only supports direct properties\n this.addVertex = this.addVertex.bind(this);\n this.firstGraph = this.firstGraph.bind(this);\n this.setDirection = this.setDirection.bind(this);\n this.addSubGraph = this.addSubGraph.bind(this);\n this.addLink = this.addLink.bind(this);\n this.setLink = this.setLink.bind(this);\n this.updateLink = this.updateLink.bind(this);\n this.addClass = this.addClass.bind(this);\n this.setClass = this.setClass.bind(this);\n this.destructLink = this.destructLink.bind(this);\n this.setClickEvent = this.setClickEvent.bind(this);\n this.setTooltip = this.setTooltip.bind(this);\n this.updateLinkInterpolate = this.updateLinkInterpolate.bind(this);\n this.setClickFun = this.setClickFun.bind(this);\n this.bindFunctions = this.bindFunctions.bind(this);\n\n this.lex = {\n firstGraph: this.firstGraph.bind(this),\n };\n\n this.clear();\n this.setGen('gen-2');\n }\n\n private sanitizeText(txt: string) {\n return common.sanitizeText(txt, this.config);\n }\n\n /**\n * Function to lookup domId from id in the graph definition.\n *\n * @param id - id of the node\n */\n public lookUpDomId(id: string) {\n for (const vertex of this.vertices.values()) {\n if (vertex.id === id) {\n return vertex.domId;\n }\n }\n return id;\n }\n\n /**\n * Function called by parser when a node definition has been found\n */\n public addVertex(\n id: string,\n textObj: FlowText,\n type: FlowVertexTypeParam,\n style: string[],\n classes: string[],\n dir: string,\n props = {},\n metadata: any\n ) {\n if (!id || id.trim().length === 0) {\n return;\n }\n // Extract the metadata from the shapeData, the syntax for adding metadata for nodes and edges is the same\n // so at this point we don't know if it's a node or an edge, but we can still extract the metadata\n let doc;\n if (metadata !== undefined) {\n let yamlData;\n // detect if shapeData contains a newline character\n if (!metadata.includes('\\n')) {\n yamlData = '{\\n' + metadata + '\\n}';\n } else {\n yamlData = metadata + '\\n';\n }\n doc = yaml.load(yamlData, { schema: yaml.JSON_SCHEMA }) as NodeMetaData;\n }\n\n // Check if this is an edge\n const edge = this.edges.find((e) => e.id === id);\n if (edge) {\n const edgeDoc = doc as EdgeMetaData;\n if (edgeDoc?.animate !== undefined) {\n edge.animate = edgeDoc.animate;\n }\n if (edgeDoc?.animation !== undefined) {\n edge.animation = edgeDoc.animation;\n }\n return;\n }\n\n let txt;\n\n let vertex = this.vertices.get(id);\n if (vertex === undefined) {\n vertex = {\n id,\n labelType: 'text',\n domId: MERMAID_DOM_ID_PREFIX + id + '-' + this.vertexCounter,\n styles: [],\n classes: [],\n };\n this.vertices.set(id, vertex);\n }\n this.vertexCounter++;\n\n if (textObj !== undefined) {\n this.config = getConfig();\n txt = this.sanitizeText(textObj.text.trim());\n vertex.labelType = textObj.type;\n // strip quotes if string starts and ends with a quote\n if (txt.startsWith('\"') && txt.endsWith('\"')) {\n txt = txt.substring(1, txt.length - 1);\n }\n vertex.text = txt;\n } else {\n if (vertex.text === undefined) {\n vertex.text = id;\n }\n }\n if (type !== undefined) {\n vertex.type = type;\n }\n if (style !== undefined && style !== null) {\n style.forEach((s) => {\n vertex.styles.push(s);\n });\n }\n if (classes !== undefined && classes !== null) {\n classes.forEach((s) => {\n vertex.classes.push(s);\n });\n }\n if (dir !== undefined) {\n vertex.dir = dir;\n }\n if (vertex.props === undefined) {\n vertex.props = props;\n } else if (props !== undefined) {\n Object.assign(vertex.props, props);\n }\n\n if (doc !== undefined) {\n if (doc.shape) {\n if (doc.shape !== doc.shape.toLowerCase() || doc.shape.includes('_')) {\n throw new Error(`No such shape: ${doc.shape}. Shape names should be lowercase.`);\n } else if (!isValidShape(doc.shape)) {\n throw new Error(`No such shape: ${doc.shape}.`);\n }\n vertex.type = doc?.shape;\n }\n\n if (doc?.label) {\n vertex.text = doc?.label;\n }\n if (doc?.icon) {\n vertex.icon = doc?.icon;\n if (!doc.label?.trim() && vertex.text === id) {\n vertex.text = '';\n }\n }\n if (doc?.form) {\n vertex.form = doc?.form;\n }\n if (doc?.pos) {\n vertex.pos = doc?.pos;\n }\n if (doc?.img) {\n vertex.img = doc?.img;\n if (!doc.label?.trim() && vertex.text === id) {\n vertex.text = '';\n }\n }\n if (doc?.constraint) {\n vertex.constraint = doc.constraint;\n }\n if (doc.w) {\n vertex.assetWidth = Number(doc.w);\n }\n if (doc.h) {\n vertex.assetHeight = Number(doc.h);\n }\n }\n }\n\n /**\n * Function called by parser when a link/edge definition has been found\n *\n */\n public addSingleLink(_start: string, _end: string, type: any, id?: string) {\n const start = _start;\n const end = _end;\n\n const edge: FlowEdge = {\n start: start,\n end: end,\n type: undefined,\n text: '',\n labelType: 'text',\n classes: [],\n isUserDefinedId: false,\n interpolate: this.edges.defaultInterpolate,\n };\n log.info('abc78 Got edge...', edge);\n const linkTextObj = type.text;\n\n if (linkTextObj !== undefined) {\n edge.text = this.sanitizeText(linkTextObj.text.trim());\n\n // strip quotes if string starts and ends with a quote\n if (edge.text.startsWith('\"') && edge.text.endsWith('\"')) {\n edge.text = edge.text.substring(1, edge.text.length - 1);\n }\n edge.labelType = linkTextObj.type;\n }\n\n if (type !== undefined) {\n edge.type = type.type;\n edge.stroke = type.stroke;\n edge.length = type.length > 10 ? 10 : type.length;\n }\n if (id && !this.edges.some((e) => e.id === id)) {\n edge.id = id;\n edge.isUserDefinedId = true;\n } else {\n const existingLinks = this.edges.filter((e) => e.start === edge.start && e.end === edge.end);\n if (existingLinks.length === 0) {\n edge.id = getEdgeId(edge.start, edge.end, { counter: 0, prefix: 'L' });\n } else {\n edge.id = getEdgeId(edge.start, edge.end, {\n counter: existingLinks.length + 1,\n prefix: 'L',\n });\n }\n }\n\n if (this.edges.length < (this.config.maxEdges ?? 500)) {\n log.info('Pushing edge...');\n this.edges.push(edge);\n } else {\n throw new Error(\n `Edge limit exceeded. ${this.edges.length} edges found, but the limit is ${this.config.maxEdges}.\n\nInitialize mermaid with maxEdges set to a higher number to allow more edges.\nYou cannot set this config via configuration inside the diagram as it is a secure config.\nYou have to call mermaid.initialize.`\n );\n }\n }\n\n private isLinkData(value: unknown): value is LinkData {\n return (\n value !== null &&\n typeof value === 'object' &&\n 'id' in value &&\n typeof (value as LinkData).id === 'string'\n );\n }\n\n public addLink(_start: string[], _end: string[], linkData: unknown) {\n const id = this.isLinkData(linkData) ? linkData.id.replace('@', '') : undefined;\n\n log.info('addLink', _start, _end, id);\n\n // for a group syntax like A e1@--> B & C, only the first edge should have a userDefined id\n // the rest of the edges should have auto generated ids\n for (const start of _start) {\n for (const end of _end) {\n //use the id only for last node in _start and first node in _end\n const isLastStart = start === _start[_start.length - 1];\n const isFirstEnd = end === _end[0];\n if (isLastStart && isFirstEnd) {\n this.addSingleLink(start, end, linkData, id);\n } else {\n this.addSingleLink(start, end, linkData, undefined);\n }\n }\n }\n }\n\n /**\n * Updates a link's line interpolation algorithm\n */\n public updateLinkInterpolate(positions: ('default' | number)[], interpolate: string) {\n positions.forEach((pos) => {\n if (pos === 'default') {\n this.edges.defaultInterpolate = interpolate;\n } else {\n this.edges[pos].interpolate = interpolate;\n }\n });\n }\n\n /**\n * Updates a link with a style\n *\n */\n public updateLink(positions: ('default' | number)[], style: string[]) {\n positions.forEach((pos) => {\n if (typeof pos === 'number' && pos >= this.edges.length) {\n throw new Error(\n `The index ${pos} for linkStyle is out of bounds. Valid indices for linkStyle are between 0 and ${\n this.edges.length - 1\n }. (Help: Ensure that the index is within the range of existing edges.)`\n );\n }\n if (pos === 'default') {\n this.edges.defaultStyle = style;\n } else {\n this.edges[pos].style = style;\n // if edges[pos].style does have fill not set, set it to none\n if (\n (this.edges[pos]?.style?.length ?? 0) > 0 &&\n !this.edges[pos]?.style?.some((s) => s?.startsWith('fill'))\n ) {\n this.edges[pos]?.style?.push('fill:none');\n }\n }\n });\n }\n\n public addClass(ids: string, _style: string[]) {\n const style = _style\n .join()\n .replace(/\\\\,/g, '\u00A7\u00A7\u00A7')\n .replace(/,/g, ';')\n .replace(/\u00A7\u00A7\u00A7/g, ',')\n .split(';');\n ids.split(',').forEach((id) => {\n let classNode = this.classes.get(id);\n if (classNode === undefined) {\n classNode = { id, styles: [], textStyles: [] };\n this.classes.set(id, classNode);\n }\n\n if (style !== undefined && style !== null) {\n style.forEach((s) => {\n if (/color/.exec(s)) {\n const newStyle = s.replace('fill', 'bgFill'); // .replace('color', 'fill');\n classNode.textStyles.push(newStyle);\n }\n classNode.styles.push(s);\n });\n }\n });\n }\n\n /**\n * Called by parser when a graph definition is found, stores the direction of the chart.\n *\n */\n public setDirection(dir: string) {\n this.direction = dir;\n if (/.*</.exec(this.direction)) {\n this.direction = 'RL';\n }\n if (/.*\\^/.exec(this.direction)) {\n this.direction = 'BT';\n }\n if (/.*>/.exec(this.direction)) {\n this.direction = 'LR';\n }\n if (/.*v/.exec(this.direction)) {\n this.direction = 'TB';\n }\n if (this.direction === 'TD') {\n this.direction = 'TB';\n }\n }\n\n /**\n * Called by parser when a special node is found, e.g. a clickable element.\n *\n * @param ids - Comma separated list of ids\n * @param className - Class to add\n */\n public setClass(ids: string, className: string) {\n for (const id of ids.split(',')) {\n const vertex = this.vertices.get(id);\n if (vertex) {\n vertex.classes.push(className);\n }\n const edge = this.edges.find((e) => e.id === id);\n if (edge) {\n edge.classes.push(className);\n }\n const subGraph = this.subGraphLookup.get(id);\n if (subGraph) {\n subGraph.classes.push(className);\n }\n }\n }\n\n public setTooltip(ids: string, tooltip: string) {\n if (tooltip === undefined) {\n return;\n }\n tooltip = this.sanitizeText(tooltip);\n for (const id of ids.split(',')) {\n this.tooltips.set(this.version === 'gen-1' ? this.lookUpDomId(id) : id, tooltip);\n }\n }\n\n private setClickFun(id: string, functionName: string, functionArgs: string) {\n const domId = this.lookUpDomId(id);\n // if (_id[0].match(/\\d/)) id = MERMAID_DOM_ID_PREFIX + id;\n if (getConfig().securityLevel !== 'loose') {\n return;\n }\n if (functionName === undefined) {\n return;\n }\n let argList: string[] = [];\n if (typeof functionArgs === 'string') {\n /* Splits functionArgs by ',', ignoring all ',' in double quoted strings */\n argList = functionArgs.split(/,(?=(?:(?:[^\"]*\"){2})*[^\"]*$)/);\n for (let i = 0; i < argList.length; i++) {\n let item = argList[i].trim();\n /* Removes all double quotes at the start and end of an argument */\n /* This preserves all starting and ending whitespace inside */\n if (item.startsWith('\"') && item.endsWith('\"')) {\n item = item.substr(1, item.length - 2);\n }\n argList[i] = item;\n }\n }\n\n /* if no arguments passed into callback, default to passing in id */\n if (argList.length === 0) {\n argList.push(id);\n }\n\n const vertex = this.vertices.get(id);\n if (vertex) {\n vertex.haveCallback = true;\n this.funs.push(() => {\n const elem = document.querySelector(`[id=\"${domId}\"]`);\n if (elem !== null) {\n elem.addEventListener(\n 'click',\n () => {\n utils.runFunc(functionName, ...argList);\n },\n false\n );\n }\n });\n }\n }\n\n /**\n * Called by parser when a link is found. Adds the URL to the vertex data.\n *\n * @param ids - Comma separated list of ids\n * @param linkStr - URL to create a link for\n * @param target - Target attribute for the link\n */\n public setLink(ids: string, linkStr: string, target: string) {\n ids.split(',').forEach((id) => {\n const vertex = this.vertices.get(id);\n if (vertex !== undefined) {\n vertex.link = utils.formatUrl(linkStr, this.config);\n vertex.linkTarget = target;\n }\n });\n this.setClass(ids, 'clickable');\n }\n\n public getTooltip(id: string) {\n return this.tooltips.get(id);\n }\n\n /**\n * Called by parser when a click definition is found. Registers an event handler.\n *\n * @param ids - Comma separated list of ids\n * @param functionName - Function to be called on click\n * @param functionArgs - Arguments to be passed to the function\n */\n public setClickEvent(ids: string, functionName: string, functionArgs: string) {\n ids.split(',').forEach((id) => {\n this.setClickFun(id, functionName, functionArgs);\n });\n this.setClass(ids, 'clickable');\n }\n\n public bindFunctions(element: Element) {\n this.funs.forEach((fun) => {\n fun(element);\n });\n }\n public getDirection() {\n return this.direction?.trim();\n }\n /**\n * Retrieval function for fetching the found nodes after parsing has completed.\n *\n */\n public getVertices() {\n return this.vertices;\n }\n\n /**\n * Retrieval function for fetching the found links after parsing has completed.\n *\n */\n public getEdges() {\n return this.edges;\n }\n\n /**\n * Retrieval function for fetching the found class definitions after parsing has completed.\n *\n */\n public getClasses() {\n return this.classes;\n }\n\n private setupToolTips(element: Element) {\n let tooltipElem = select('.mermaidTooltip');\n // @ts-ignore TODO: fix this\n if ((tooltipElem._groups || tooltipElem)[0][0] === null) {\n // @ts-ignore TODO: fix this\n tooltipElem = select('body')\n .append('div')\n .attr('class', 'mermaidTooltip')\n .style('opacity', 0);\n }\n\n const svg = select(element).select('svg');\n\n const nodes = svg.selectAll('g.node');\n nodes\n .on('mouseover', (e: MouseEvent) => {\n const el = select(e.currentTarget as Element);\n const title = el.attr('title');\n\n // Don't try to draw a tooltip if no data is provided\n if (title === null) {\n return;\n }\n const rect = (e.currentTarget as Element)?.getBoundingClientRect();\n\n tooltipElem.transition().duration(200).style('opacity', '.9');\n tooltipElem\n .text(el.attr('title'))\n .style('left', window.scrollX + rect.left + (rect.right - rect.left) / 2 + 'px')\n .style('top', window.scrollY + rect.bottom + 'px');\n tooltipElem.html(tooltipElem.html().replace(/&lt;br\\/&gt;/g, '<br/>'));\n el.classed('hover', true);\n })\n .on('mouseout', (e: MouseEvent) => {\n tooltipElem.transition().duration(500).style('opacity', 0);\n const el = select(e.currentTarget as Element);\n el.classed('hover', false);\n });\n }\n\n /**\n * Clears the internal graph db so that a new graph can be parsed.\n *\n */\n public clear(ver = 'gen-2') {\n this.vertices = new Map();\n this.classes = new Map();\n this.edges = [];\n this.funs = [this.setupToolTips.bind(this)];\n this.subGraphs = [];\n this.subGraphLookup = new Map();\n this.subCount = 0;\n this.tooltips = new Map();\n this.firstGraphFlag = true;\n this.version = ver;\n this.config = getConfig();\n commonClear();\n }\n\n public setGen(ver: string) {\n this.version = ver || 'gen-2';\n }\n\n public defaultStyle() {\n return 'fill:#ffa;stroke: #f66; stroke-width: 3px; stroke-dasharray: 5, 5;fill:#ffa;stroke: #666;';\n }\n\n public addSubGraph(\n _id: { text: string },\n list: string[],\n _title: { text: string; type: string }\n ) {\n let id: string | undefined = _id.text.trim();\n let title = _title.text;\n if (_id === _title && /\\s/.exec(_title.text)) {\n id = undefined;\n }\n\n const uniq = (a: any[]) => {\n const prims: any = { boolean: {}, number: {}, string: {} };\n const objs: any[] = [];\n\n let dir: string | undefined;\n\n const nodeList = a.filter(function (item) {\n const type = typeof item;\n if (item.stmt && item.stmt === 'dir') {\n dir = item.value;\n return false;\n }\n if (item.trim() === '') {\n return false;\n }\n if (type in prims) {\n return prims[type].hasOwnProperty(item) ? false : (prims[type][item] = true);\n } else {\n return objs.includes(item) ? false : objs.push(item);\n }\n });\n return { nodeList, dir };\n };\n\n const result = uniq(list.flat());\n const nodeList = result.nodeList;\n let dir = result.dir;\n const flowchartConfig = getConfig().flowchart ?? {};\n dir =\n dir ??\n (flowchartConfig.inheritDir\n ? (this.getDirection() ?? (getConfig() as any).direction ?? undefined)\n : undefined);\n\n if (this.version === 'gen-1') {\n for (let i = 0; i < nodeList.length; i++) {\n nodeList[i] = this.lookUpDomId(nodeList[i]);\n }\n }\n\n id = id ?? 'subGraph' + this.subCount;\n title = title || '';\n title = this.sanitizeText(title);\n this.subCount = this.subCount + 1;\n\n const subGraph = {\n id: id,\n nodes: nodeList,\n title: title.trim(),\n classes: [],\n dir,\n labelType: _title.type,\n };\n\n log.info('Adding', subGraph.id, subGraph.nodes, subGraph.dir);\n\n // Remove the members in the new subgraph if they already belong to another subgraph\n subGraph.nodes = this.makeUniq(subGraph, this.subGraphs).nodes;\n this.subGraphs.push(subGraph);\n this.subGraphLookup.set(id, subGraph);\n return id;\n }\n\n private getPosForId(id: string) {\n for (const [i, subGraph] of this.subGraphs.entries()) {\n if (subGraph.id === id) {\n return i;\n }\n }\n return -1;\n }\n\n private indexNodes2(id: string, pos: number): { result: boolean; count: number } {\n const nodes = this.subGraphs[pos].nodes;\n this.secCount = this.secCount + 1;\n if (this.secCount > 2000) {\n return {\n result: false,\n count: 0,\n };\n }\n this.posCrossRef[this.secCount] = pos;\n // Check if match\n if (this.subGraphs[pos].id === id) {\n return {\n result: true,\n count: 0,\n };\n }\n\n let count = 0;\n let posCount = 1;\n while (count < nodes.length) {\n const childPos = this.getPosForId(nodes[count]);\n // Ignore regular nodes (pos will be -1)\n if (childPos >= 0) {\n const res = this.indexNodes2(id, childPos);\n if (res.result) {\n return {\n result: true,\n count: posCount + res.count,\n };\n } else {\n posCount = posCount + res.count;\n }\n }\n count = count + 1;\n }\n\n return {\n result: false,\n count: posCount,\n };\n }\n\n public getDepthFirstPos(pos: number) {\n return this.posCrossRef[pos];\n }\n public indexNodes() {\n this.secCount = -1;\n if (this.subGraphs.length > 0) {\n this.indexNodes2('none', this.subGraphs.length - 1);\n }\n }\n\n public getSubGraphs() {\n return this.subGraphs;\n }\n\n public firstGraph() {\n if (this.firstGraphFlag) {\n this.firstGraphFlag = false;\n return true;\n }\n return false;\n }\n\n private destructStartLink(_str: string): FlowLink {\n let str = _str.trim();\n let type = 'arrow_open';\n\n switch (str[0]) {\n case '<':\n type = 'arrow_point';\n str = str.slice(1);\n break;\n case 'x':\n type = 'arrow_cross';\n str = str.slice(1);\n break;\n case 'o':\n type = 'arrow_circle';\n str = str.slice(1);\n break;\n }\n\n let stroke = 'normal';\n\n if (str.includes('=')) {\n stroke = 'thick';\n }\n\n if (str.includes('.')) {\n stroke = 'dotted';\n }\n\n return { type, stroke };\n }\n\n private countChar(char: string, str: string) {\n const length = str.length;\n let count = 0;\n for (let i = 0; i < length; ++i) {\n if (str[i] === char) {\n ++count;\n }\n }\n return count;\n }\n\n private destructEndLink(_str: string) {\n const str = _str.trim();\n let line = str.slice(0, -1);\n let type = 'arrow_open';\n\n switch (str.slice(-1)) {\n case 'x':\n type = 'arrow_cross';\n if (str.startsWith('x')) {\n type = 'double_' + type;\n line = line.slice(1);\n }\n break;\n case '>':\n type = 'arrow_point';\n if (str.startsWith('<')) {\n type = 'double_' + type;\n line = line.slice(1);\n }\n break;\n case 'o':\n type = 'arrow_circle';\n if (str.startsWith('o')) {\n type = 'double_' + type;\n line = line.slice(1);\n }\n break;\n }\n\n let stroke = 'normal';\n let length = line.length - 1;\n\n if (line.startsWith('=')) {\n stroke = 'thick';\n }\n\n if (line.startsWith('~')) {\n stroke = 'invisible';\n }\n\n const dots = this.countChar('.', line);\n\n if (dots) {\n stroke = 'dotted';\n length = dots;\n }\n\n return { type, stroke, length };\n }\n\n public destructLink(_str: string, _startStr: string) {\n const info = this.destructEndLink(_str);\n let startInfo;\n if (_startStr) {\n startInfo = this.destructStartLink(_startStr);\n\n if (startInfo.stroke !== info.stroke) {\n return { type: 'INVALID', stroke: 'INVALID' };\n }\n\n if (startInfo.type === 'arrow_open') {\n // -- xyz --> - take arrow type from ending\n startInfo.type = info.type;\n } else {\n // x-- xyz --> - not supported\n if (startInfo.type !== info.type) {\n return { type: 'INVALID', stroke: 'INVALID' };\n }\n\n startInfo.type = 'double_' + startInfo.type;\n }\n\n if (startInfo.type === 'double_arrow') {\n startInfo.type = 'double_arrow_point';\n }\n\n startInfo.length = info.length;\n return startInfo;\n }\n\n return info;\n }\n\n // Todo optimizer this by caching existing nodes\n public exists(allSgs: FlowSubGraph[], _id: string) {\n for (const sg of allSgs) {\n if (sg.nodes.includes(_id)) {\n return true;\n }\n }\n return false;\n }\n /**\n * Deletes an id from all subgraphs\n *\n */\n public makeUniq(sg: FlowSubGraph, allSubgraphs: FlowSubGraph[]) {\n const res: string[] = [];\n sg.nodes.forEach((_id, pos) => {\n if (!this.exists(allSubgraphs, _id)) {\n res.push(sg.nodes[pos]);\n }\n });\n return { nodes: res };\n }\n\n public lex: { firstGraph: typeof FlowDB.prototype.firstGraph };\n\n private getTypeFromVertex(vertex: FlowVertex): ShapeID {\n if (vertex.img) {\n return 'imageSquare';\n }\n if (vertex.icon) {\n if (vertex.form === 'circle') {\n return 'iconCircle';\n }\n if (vertex.form === 'square') {\n return 'iconSquare';\n }\n if (vertex.form === 'rounded') {\n return 'iconRounded';\n }\n return 'icon';\n }\n switch (vertex.type) {\n case 'square':\n case undefined:\n return 'squareRect';\n case 'round':\n return 'roundedRect';\n case 'ellipse':\n // @ts-expect-error -- Ellipses are broken, see https://github.com/mermaid-js/mermaid/issues/5976\n return 'ellipse';\n default:\n return vertex.type;\n }\n }\n\n private findNode(nodes: Node[], id: string) {\n return nodes.find((node) => node.id === id);\n }\n private destructEdgeType(type: string | undefined) {\n let arrowTypeStart = 'none';\n let arrowTypeEnd = 'arrow_point';\n switch (type) {\n case 'arrow_point':\n case 'arrow_circle':\n case 'arrow_cross':\n arrowTypeEnd = type;\n break;\n\n case 'double_arrow_point':\n case 'double_arrow_circle':\n case 'double_arrow_cross':\n arrowTypeStart = type.replace('double_', '');\n arrowTypeEnd = arrowTypeStart;\n break;\n }\n return { arrowTypeStart, arrowTypeEnd };\n }\n\n private addNodeFromVertex(\n vertex: FlowVertex,\n nodes: Node[],\n parentDB: Map<string, string>,\n subGraphDB: Map<string, boolean>,\n config: any,\n look: string\n ) {\n const parentId = parentDB.get(vertex.id);\n const isGroup = subGraphDB.get(vertex.id) ?? false;\n\n const node = this.findNode(nodes, vertex.id);\n if (node) {\n node.cssStyles = vertex.styles;\n node.cssCompiledStyles = this.getCompiledStyles(vertex.classes);\n node.cssClasses = vertex.classes.join(' ');\n } else {\n const baseNode = {\n id: vertex.id,\n label: vertex.text,\n labelStyle: '',\n parentId,\n padding: config.flowchart?.padding || 8,\n cssStyles: vertex.styles,\n cssCompiledStyles: this.getCompiledStyles(['default', 'node', ...vertex.classes]),\n cssClasses: 'default ' + vertex.classes.join(' '),\n dir: vertex.dir,\n domId: vertex.domId,\n look,\n link: vertex.link,\n linkTarget: vertex.linkTarget,\n tooltip: this.getTooltip(vertex.id),\n icon: vertex.icon,\n pos: vertex.pos,\n img: vertex.img,\n assetWidth: vertex.assetWidth,\n assetHeight: vertex.assetHeight,\n constraint: vertex.constraint,\n };\n if (isGroup) {\n nodes.push({\n ...baseNode,\n isGroup: true,\n shape: 'rect',\n });\n } else {\n nodes.push({\n ...baseNode,\n isGroup: false,\n shape: this.getTypeFromVertex(vertex),\n });\n }\n }\n }\n\n private getCompiledStyles(classDefs: string[]) {\n let compiledStyles: string[] = [];\n for (const customClass of classDefs) {\n const cssClass = this.classes.get(customClass);\n if (cssClass?.styles) {\n compiledStyles = [...compiledStyles, ...(cssClass.styles ?? [])].map((s) => s.trim());\n }\n if (cssClass?.textStyles) {\n compiledStyles = [...compiledStyles, ...(cssClass.textStyles ?? [])].map((s) => s.trim());\n }\n }\n return compiledStyles;\n }\n\n public getData() {\n const config = getConfig();\n const nodes: Node[] = [];\n const edges: Edge[] = [];\n\n const subGraphs = this.getSubGraphs();\n const parentDB = new Map<string, string>();\n const subGraphDB = new Map<string, boolean>();\n\n // Setup the subgraph data for adding nodes\n for (let i = subGraphs.length - 1; i >= 0; i--) {\n const subGraph = subGraphs[i];\n if (subGraph.nodes.length > 0) {\n subGraphDB.set(subGraph.id, true);\n }\n for (const id of subGraph.nodes) {\n parentDB.set(id, subGraph.id);\n }\n }\n\n // Data is setup, add the nodes\n for (let i = subGraphs.length - 1; i >= 0; i--) {\n const subGraph = subGraphs[i];\n nodes.push({\n id: subGraph.id,\n label: subGraph.title,\n labelStyle: '',\n parentId: parentDB.get(subGraph.id),\n padding: 8,\n cssCompiledStyles: this.getCompiledStyles(subGraph.classes),\n cssClasses: subGraph.classes.join(' '),\n shape: 'rect',\n dir: subGraph.dir,\n isGroup: true,\n look: config.look,\n });\n }\n\n const n = this.getVertices();\n n.forEach((vertex) => {\n this.addNodeFromVertex(vertex, nodes, parentDB, subGraphDB, config, config.look || 'classic');\n });\n\n const e = this.getEdges();\n e.forEach((rawEdge, index) => {\n const { arrowTypeStart, arrowTypeEnd } = this.destructEdgeType(rawEdge.type);\n const styles = [...(e.defaultStyle ?? [])];\n\n if (rawEdge.style) {\n styles.push(...rawEdge.style);\n }\n const edge: Edge = {\n id: getEdgeId(rawEdge.start, rawEdge.end, { counter: index, prefix: 'L' }, rawEdge.id),\n isUserDefinedId: rawEdge.isUserDefinedId,\n start: rawEdge.start,\n end: rawEdge.end,\n type: rawEdge.type ?? 'normal',\n label: rawEdge.text,\n labelpos: 'c',\n thickness: rawEdge.stroke,\n minlen: rawEdge.length,\n classes:\n rawEdge?.stroke === 'invisible'\n ? ''\n : 'edge-thickness-normal edge-pattern-solid flowchart-link',\n arrowTypeStart:\n rawEdge?.stroke === 'invisible' || rawEdge?.type === 'arrow_open'\n ? 'none'\n : arrowTypeStart,\n arrowTypeEnd:\n rawEdge?.stroke === 'invisible' || rawEdge?.type === 'arrow_open' ? 'none' : arrowTypeEnd,\n arrowheadStyle: 'fill: #333',\n cssCompiledStyles: this.getCompiledStyles(rawEdge.classes),\n labelStyle: styles,\n style: styles,\n pattern: rawEdge.stroke,\n look: config.look,\n animate: rawEdge.animate,\n animation: rawEdge.animation,\n curve: rawEdge.interpolate || this.edges.defaultInterpolate || config.flowchart?.curve,\n };\n\n edges.push(edge);\n });\n\n return { nodes, edges, other: {}, config };\n }\n\n public defaultConfig() {\n return defaultConfig.flowchart;\n }\n public setAccTitle = setAccTitle;\n public setAccDescription = setAccDescription;\n public setDiagramTitle = setDiagramTitle;\n public getAccTitle = getAccTitle;\n public getAccDescription = getAccDescription;\n public getDiagramTitle = getDiagramTitle;\n}\n", "import { select } from 'd3';\nimport { getConfig } from '../../diagram-api/diagramAPI.js';\nimport type { DiagramStyleClassDef } from '../../diagram-api/types.js';\nimport { log } from '../../logger.js';\nimport { getDiagramElement } from '../../rendering-util/insertElementsForSize.js';\nimport { getRegisteredLayoutAlgorithm, render } from '../../rendering-util/render.js';\nimport { setupViewPortForSVG } from '../../rendering-util/setupViewPortForSVG.js';\nimport type { LayoutData } from '../../rendering-util/types.js';\nimport utils from '../../utils.js';\n\nexport const getClasses = function (\n text: string,\n diagramObj: any\n): Map<string, DiagramStyleClassDef> {\n return diagramObj.db.getClasses();\n};\n\nexport const draw = async function (text: string, id: string, _version: string, diag: any) {\n log.info('REF0:');\n log.info('Drawing state diagram (v2)', id);\n const { securityLevel, flowchart: conf, layout } = getConfig();\n\n // Handle root and document for when rendering in sandbox mode\n let sandboxElement;\n if (securityLevel === 'sandbox') {\n sandboxElement = select('#i' + id);\n }\n\n // @ts-ignore - document is always available\n const doc = securityLevel === 'sandbox' ? sandboxElement.nodes()[0].contentDocument : document;\n\n // The getData method provided in all supported diagrams is used to extract the data from the parsed structure\n // into the Layout data format\n log.debug('Before getData: ');\n const data4Layout = diag.db.getData() as LayoutData;\n log.debug('Data: ', data4Layout);\n // Create the root SVG\n const svg = getDiagramElement(id, securityLevel);\n const direction = diag.db.getDirection();\n\n data4Layout.type = diag.type;\n data4Layout.layoutAlgorithm = getRegisteredLayoutAlgorithm(layout);\n if (data4Layout.layoutAlgorithm === 'dagre' && layout === 'elk') {\n log.warn(\n 'flowchart-elk was moved to an external package in Mermaid v11. Please refer [release notes](https://github.com/mermaid-js/mermaid/releases/tag/v11.0.0) for more details. This diagram will be rendered using `dagre` layout as a fallback.'\n );\n }\n data4Layout.direction = direction;\n data4Layout.nodeSpacing = conf?.nodeSpacing || 50;\n data4Layout.rankSpacing = conf?.rankSpacing || 50;\n data4Layout.markers = ['point', 'circle', 'cross'];\n\n data4Layout.diagramId = id;\n log.debug('REF1:', data4Layout);\n await render(data4Layout, svg);\n const padding = data4Layout.config.flowchart?.diagramPadding ?? 8;\n utils.insertTitle(\n svg,\n 'flowchartTitleText',\n conf?.titleTopMargin || 0,\n diag.db.getDiagramTitle()\n );\n setupViewPortForSVG(svg, padding, 'flowchart', conf?.useMaxWidth || false);\n\n // If node has a link, wrap it in an anchor SVG object.\n for (const vertex of data4Layout.nodes) {\n const node = select(`#${id} [id=\"${vertex.id}\"]`);\n if (!node || !vertex.link) {\n continue;\n }\n const link = doc.createElementNS('http://www.w3.org/2000/svg', 'a');\n link.setAttributeNS('http://www.w3.org/2000/svg', 'class', vertex.cssClasses);\n link.setAttributeNS('http://www.w3.org/2000/svg', 'rel', 'noopener');\n if (securityLevel === 'sandbox') {\n link.setAttributeNS('http://www.w3.org/2000/svg', 'target', '_top');\n } else if (vertex.linkTarget) {\n link.setAttributeNS('http://www.w3.org/2000/svg', 'target', vertex.linkTarget);\n }\n\n const linkNode = node.insert(function () {\n return link;\n }, ':first-child');\n\n const shape = node.select('.label-container');\n if (shape) {\n linkNode.append(function () {\n return shape.node();\n });\n }\n\n const label = node.select('.label');\n if (label) {\n linkNode.append(function () {\n return label.node();\n });\n }\n }\n};\n\nexport default {\n getClasses,\n draw,\n};\n", "/* parser generated by jison 0.4.18 */\n/*\n Returns a Parser object of the following structure:\n\n Parser: {\n yy: {}\n }\n\n Parser.prototype: {\n yy: {},\n trace: function(),\n symbols_: {associative list: name ==> number},\n terminals_: {associative list: number ==> name},\n productions_: [...],\n performAction: function anonymous(yytext, yyleng, yylineno, yy, yystate, $$, _$),\n table: [...],\n defaultActions: {...},\n parseError: function(str, hash),\n parse: function(input),\n\n lexer: {\n EOF: 1,\n parseError: function(str, hash),\n setInput: function(input),\n input: function(),\n unput: function(str),\n more: function(),\n less: function(n),\n pastInput: function(),\n upcomingInput: function(),\n showPosition: function(),\n test_match: function(regex_match_array, rule_index),\n next: function(),\n lex: function(),\n begin: function(condition),\n popState: function(),\n _currentRules: function(),\n topState: function(),\n pushState: function(condition),\n\n options: {\n ranges: boolean (optional: true ==> token location info will include a .range[] member)\n flex: boolean (optional: true ==> flex-like lexing behaviour where the rules are tested exhaustively to find the longest match)\n backtrack_lexer: boolean (optional: true ==> lexer regexes are tested in order and for each matching regex the action code is invoked; the lexer terminates the scan when a token is returned by the action code)\n },\n\n performAction: function(yy, yy_, $avoiding_name_collisions, YY_START),\n rules: [...],\n conditions: {associative list: name ==> set},\n }\n }\n\n\n token location info (@$, _$, etc.): {\n first_line: n,\n last_line: n,\n first_column: n,\n last_column: n,\n range: [start_number, end_number] (where the numbers are indexes into the input string, regular zero-based)\n }\n\n\n the parseError function receives a 'hash' object with these members for lexer and parser errors: {\n text: (matched text)\n token: (the produced terminal token, if any)\n line: (yylineno)\n }\n while parser (grammar) errors will also provide these members, i.e. parser errors deliver a superset of attributes: {\n loc: (yylloc)\n expected: (string describing the set of expected tokens)\n recoverable: (boolean: TRUE when the parser has a error recovery rule available for this particular error)\n }\n*/\nvar parser = (function(){\nvar o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,4],$V1=[1,3],$V2=[1,5],$V3=[1,8,9,10,11,27,34,36,38,44,60,84,85,86,87,88,89,102,105,106,109,111,114,115,116,121,122,123,124],$V4=[2,2],$V5=[1,13],$V6=[1,14],$V7=[1,15],$V8=[1,16],$V9=[1,23],$Va=[1,25],$Vb=[1,26],$Vc=[1,27],$Vd=[1,49],$Ve=[1,48],$Vf=[1,29],$Vg=[1,30],$Vh=[1,31],$Vi=[1,32],$Vj=[1,33],$Vk=[1,44],$Vl=[1,46],$Vm=[1,42],$Vn=[1,47],$Vo=[1,43],$Vp=[1,50],$Vq=[1,45],$Vr=[1,51],$Vs=[1,52],$Vt=[1,34],$Vu=[1,35],$Vv=[1,36],$Vw=[1,37],$Vx=[1,57],$Vy=[1,8,9,10,11,27,32,34,36,38,44,60,84,85,86,87,88,89,102,105,106,109,111,114,115,116,121,122,123,124],$Vz=[1,61],$VA=[1,60],$VB=[1,62],$VC=[8,9,11,75,77,78],$VD=[1,78],$VE=[1,91],$VF=[1,96],$VG=[1,95],$VH=[1,92],$VI=[1,88],$VJ=[1,94],$VK=[1,90],$VL=[1,97],$VM=[1,93],$VN=[1,98],$VO=[1,89],$VP=[8,9,10,11,40,75,77,78],$VQ=[8,9,10,11,40,46,75,77,78],$VR=[8,9,10,11,29,40,44,46,48,50,52,54,56,58,60,63,65,67,68,70,75,77,78,89,102,105,106,109,111,114,115,116],$VS=[8,9,11,44,60,75,77,78,89,102,105,106,109,111,114,115,116],$VT=[44,60,89,102,105,106,109,111,114,115,116],$VU=[1,121],$VV=[1,122],$VW=[1,124],$VX=[1,123],$VY=[44,60,62,74,89,102,105,106,109,111,114,115,116],$VZ=[1,133],$V_=[1,147],$V$=[1,148],$V01=[1,149],$V11=[1,150],$V21=[1,135],$V31=[1,137],$V41=[1,141],$V51=[1,142],$V61=[1,143],$V71=[1,144],$V81=[1,145],$V91=[1,146],$Va1=[1,151],$Vb1=[1,152],$Vc1=[1,131],$Vd1=[1,132],$Ve1=[1,139],$Vf1=[1,134],$Vg1=[1,138],$Vh1=[1,136],$Vi1=[8,9,10,11,27,32,34,36,38,44,60,84,85,86,87,88,89,102,105,106,109,111,114,115,116,121,122,123,124],$Vj1=[1,154],$Vk1=[1,156],$Vl1=[8,9,11],$Vm1=[8,9,10,11,14,44,60,89,105,106,109,111,114,115,116],$Vn1=[1,176],$Vo1=[1,172],$Vp1=[1,173],$Vq1=[1,177],$Vr1=[1,174],$Vs1=[1,175],$Vt1=[77,116,119],$Vu1=[8,9,10,11,12,14,27,29,32,44,60,75,84,85,86,87,88,89,90,105,109,111,114,115,116],$Vv1=[10,106],$Vw1=[31,49,51,53,55,57,62,64,66,67,69,71,116,117,118],$Vx1=[1,247],$Vy1=[1,245],$Vz1=[1,249],$VA1=[1,243],$VB1=[1,244],$VC1=[1,246],$VD1=[1,248],$VE1=[1,250],$VF1=[1,268],$VG1=[8,9,11,106],$VH1=[8,9,10,11,60,84,105,106,109,110,111,112];\nvar parser = {trace: function trace () { },\nyy: {},\nsymbols_: {\"error\":2,\"start\":3,\"graphConfig\":4,\"document\":5,\"line\":6,\"statement\":7,\"SEMI\":8,\"NEWLINE\":9,\"SPACE\":10,\"EOF\":11,\"GRAPH\":12,\"NODIR\":13,\"DIR\":14,\"FirstStmtSeparator\":15,\"ending\":16,\"endToken\":17,\"spaceList\":18,\"spaceListNewline\":19,\"vertexStatement\":20,\"separator\":21,\"styleStatement\":22,\"linkStyleStatement\":23,\"classDefStatement\":24,\"classStatement\":25,\"clickStatement\":26,\"subgraph\":27,\"textNoTags\":28,\"SQS\":29,\"text\":30,\"SQE\":31,\"end\":32,\"direction\":33,\"acc_title\":34,\"acc_title_value\":35,\"acc_descr\":36,\"acc_descr_value\":37,\"acc_descr_multiline_value\":38,\"shapeData\":39,\"SHAPE_DATA\":40,\"link\":41,\"node\":42,\"styledVertex\":43,\"AMP\":44,\"vertex\":45,\"STYLE_SEPARATOR\":46,\"idString\":47,\"DOUBLECIRCLESTART\":48,\"DOUBLECIRCLEEND\":49,\"PS\":50,\"PE\":51,\"(-\":52,\"-)\":53,\"STADIUMSTART\":54,\"STADIUMEND\":55,\"SUBROUTINESTART\":56,\"SUBROUTINEEND\":57,\"VERTEX_WITH_PROPS_START\":58,\"NODE_STRING[field]\":59,\"COLON\":60,\"NODE_STRING[value]\":61,\"PIPE\":62,\"CYLINDERSTART\":63,\"CYLINDEREND\":64,\"DIAMOND_START\":65,\"DIAMOND_STOP\":66,\"TAGEND\":67,\"TRAPSTART\":68,\"TRAPEND\":69,\"INVTRAPSTART\":70,\"INVTRAPEND\":71,\"linkStatement\":72,\"arrowText\":73,\"TESTSTR\":74,\"START_LINK\":75,\"edgeText\":76,\"LINK\":77,\"LINK_ID\":78,\"edgeTextToken\":79,\"STR\":80,\"MD_STR\":81,\"textToken\":82,\"keywords\":83,\"STYLE\":84,\"LINKSTYLE\":85,\"CLASSDEF\":86,\"CLASS\":87,\"CLICK\":88,\"DOWN\":89,\"UP\":90,\"textNoTagsToken\":91,\"stylesOpt\":92,\"idString[vertex]\":93,\"idString[class]\":94,\"CALLBACKNAME\":95,\"CALLBACKARGS\":96,\"HREF\":97,\"LINK_TARGET\":98,\"STR[link]\":99,\"STR[tooltip]\":100,\"alphaNum\":101,\"DEFAULT\":102,\"numList\":103,\"INTERPOLATE\":104,\"NUM\":105,\"COMMA\":106,\"style\":107,\"styleComponent\":108,\"NODE_STRING\":109,\"UNIT\":110,\"BRKT\":111,\"PCT\":112,\"idStringToken\":113,\"MINUS\":114,\"MULT\":115,\"UNICODE_TEXT\":116,\"TEXT\":117,\"TAGSTART\":118,\"EDGE_TEXT\":119,\"alphaNumToken\":120,\"direction_tb\":121,\"direction_bt\":122,\"direction_rl\":123,\"direction_lr\":124,\"$accept\":0,\"$end\":1},\nterminals_: {2:\"error\",8:\"SEMI\",9:\"NEWLINE\",10:\"SPACE\",11:\"EOF\",12:\"GRAPH\",13:\"NODIR\",14:\"DIR\",27:\"subgraph\",29:\"SQS\",31:\"SQE\",32:\"end\",34:\"acc_title\",35:\"acc_title_value\",36:\"acc_descr\",37:\"acc_descr_value\",38:\"acc_descr_multiline_value\",40:\"SHAPE_DATA\",44:\"AMP\",46:\"STYLE_SEPARATOR\",48:\"DOUBLECIRCLESTART\",49:\"DOUBLECIRCLEEND\",50:\"PS\",51:\"PE\",52:\"(-\",53:\"-)\",54:\"STADIUMSTART\",55:\"STADIUMEND\",56:\"SUBROUTINESTART\",57:\"SUBROUTINEEND\",58:\"VERTEX_WITH_PROPS_START\",59:\"NODE_STRING[field]\",60:\"COLON\",61:\"NODE_STRING[value]\",62:\"PIPE\",63:\"CYLINDERSTART\",64:\"CYLINDEREND\",65:\"DIAMOND_START\",66:\"DIAMOND_STOP\",67:\"TAGEND\",68:\"TRAPSTART\",69:\"TRAPEND\",70:\"INVTRAPSTART\",71:\"INVTRAPEND\",74:\"TESTSTR\",75:\"START_LINK\",77:\"LINK\",78:\"LINK_ID\",80:\"STR\",81:\"MD_STR\",84:\"STYLE\",85:\"LINKSTYLE\",86:\"CLASSDEF\",87:\"CLASS\",88:\"CLICK\",89:\"DOWN\",90:\"UP\",93:\"idString[vertex]\",94:\"idString[class]\",95:\"CALLBACKNAME\",96:\"CALLBACKARGS\",97:\"HREF\",98:\"LINK_TARGET\",99:\"STR[link]\",100:\"STR[tooltip]\",102:\"DEFAULT\",104:\"INTERPOLATE\",105:\"NUM\",106:\"COMMA\",109:\"NODE_STRING\",110:\"UNIT\",111:\"BRKT\",112:\"PCT\",114:\"MINUS\",115:\"MULT\",116:\"UNICODE_TEXT\",117:\"TEXT\",118:\"TAGSTART\",119:\"EDGE_TEXT\",121:\"direction_tb\",122:\"direction_bt\",123:\"direction_rl\",124:\"direction_lr\"},\nproductions_: [0,[3,2],[5,0],[5,2],[6,1],[6,1],[6,1],[6,1],[6,1],[4,2],[4,2],[4,2],[4,3],[16,2],[16,1],[17,1],[17,1],[17,1],[15,1],[15,1],[15,2],[19,2],[19,2],[19,1],[19,1],[18,2],[18,1],[7,2],[7,2],[7,2],[7,2],[7,2],[7,2],[7,9],[7,6],[7,4],[7,1],[7,2],[7,2],[7,1],[21,1],[21,1],[21,1],[39,2],[39,1],[20,4],[20,3],[20,4],[20,2],[20,2],[20,1],[42,1],[42,6],[42,5],[43,1],[43,3],[45,4],[45,4],[45,6],[45,4],[45,4],[45,4],[45,8],[45,4],[45,4],[45,4],[45,6],[45,4],[45,4],[45,4],[45,4],[45,4],[45,1],[41,2],[41,3],[41,3],[41,1],[41,3],[41,4],[76,1],[76,2],[76,1],[76,1],[72,1],[72,2],[73,3],[30,1],[30,2],[30,1],[30,1],[83,1],[83,1],[83,1],[83,1],[83,1],[83,1],[83,1],[83,1],[83,1],[83,1],[83,1],[28,1],[28,2],[28,1],[28,1],[24,5],[25,5],[26,2],[26,4],[26,3],[26,5],[26,3],[26,5],[26,5],[26,7],[26,2],[26,4],[26,2],[26,4],[26,4],[26,6],[22,5],[23,5],[23,5],[23,9],[23,9],[23,7],[23,7],[103,1],[103,3],[92,1],[92,3],[107,1],[107,2],[108,1],[108,1],[108,1],[108,1],[108,1],[108,1],[108,1],[108,1],[113,1],[113,1],[113,1],[113,1],[113,1],[113,1],[113,1],[113,1],[113,1],[113,1],[113,1],[82,1],[82,1],[82,1],[82,1],[91,1],[91,1],[91,1],[91,1],[91,1],[91,1],[91,1],[91,1],[91,1],[91,1],[91,1],[79,1],[79,1],[120,1],[120,1],[120,1],[120,1],[120,1],[120,1],[120,1],[120,1],[120,1],[120,1],[120,1],[47,1],[47,2],[101,1],[101,2],[33,1],[33,1],[33,1],[33,1]],\nperformAction: function anonymous(yytext, yyleng, yylineno, yy, yystate /* action[1] */, $$ /* vstack */, _$ /* lstack */) {\n/* this == yyval */\n\nvar $0 = $$.length - 1;\nswitch (yystate) {\ncase 2:\n this.$ = [];\nbreak;\ncase 3:\n\n\t if(!Array.isArray($$[$0]) || $$[$0].length > 0){\n\t $$[$0-1].push($$[$0]);\n\t }\n\t this.$=$$[$0-1];\nbreak;\ncase 4: case 183:\nthis.$=$$[$0];\nbreak;\ncase 11:\n yy.setDirection('TB');this.$ = 'TB';\nbreak;\ncase 12:\n yy.setDirection($$[$0-1]);this.$ = $$[$0-1];\nbreak;\ncase 27:\n this.$=$$[$0-1].nodes\nbreak;\ncase 28: case 29: case 30: case 31: case 32:\nthis.$=[];\nbreak;\ncase 33:\nthis.$=yy.addSubGraph($$[$0-6],$$[$0-1],$$[$0-4]);\nbreak;\ncase 34:\nthis.$=yy.addSubGraph($$[$0-3],$$[$0-1],$$[$0-3]);\nbreak;\ncase 35:\nthis.$=yy.addSubGraph(undefined,$$[$0-1],undefined);\nbreak;\ncase 37:\n this.$=$$[$0].trim();yy.setAccTitle(this.$); \nbreak;\ncase 38: case 39:\n this.$=$$[$0].trim();yy.setAccDescription(this.$); \nbreak;\ncase 43:\n this.$ = $$[$0-1] + $$[$0]; \nbreak;\ncase 44:\n this.$ = $$[$0]; \nbreak;\ncase 45:\n /* console.warn('vs shapeData',$$[$0-3].stmt,$$[$0-1], $$[$0]);*/ yy.addVertex($$[$0-1][$$[$0-1].length-1],undefined,undefined,undefined, undefined,undefined, undefined,$$[$0]); yy.addLink($$[$0-3].stmt,$$[$0-1],$$[$0-2]); this.$ = { stmt: $$[$0-1], nodes: $$[$0-1].concat($$[$0-3].nodes) } \nbreak;\ncase 46:\n /*console.warn('vs',$$[$0-2].stmt,$$[$0]);*/ yy.addLink($$[$0-2].stmt,$$[$0],$$[$0-1]); this.$ = { stmt: $$[$0], nodes: $$[$0].concat($$[$0-2].nodes) } \nbreak;\ncase 47:\n /* console.warn('vs',$$[$0-3].stmt,$$[$0-1]); */ yy.addLink($$[$0-3].stmt,$$[$0-1],$$[$0-2]); this.$ = { stmt: $$[$0-1], nodes: $$[$0-1].concat($$[$0-3].nodes) } \nbreak;\ncase 48:\n /*console.warn('vertexStatement: node spaceList', $$[$0-1]);*/ this.$ = {stmt: $$[$0-1], nodes:$$[$0-1] }\nbreak;\ncase 49:\n\n /*console.warn('vertexStatement: node shapeData', $$[$0-1][0], $$[$0]);*/\n yy.addVertex($$[$0-1][$$[$0-1].length-1],undefined,undefined,undefined, undefined,undefined, undefined,$$[$0]);\n this.$ = {stmt: $$[$0-1], nodes:$$[$0-1], shapeData: $$[$0]}\n \nbreak;\ncase 50:\n /* console.warn('vertexStatement: single node', $$[$0]); */ this.$ = {stmt: $$[$0], nodes:$$[$0] }\nbreak;\ncase 51