UNPKG

markdown-flow-ui

Version:

A React UI library for rendering markdown with interactive flow components, typewriter effects, and plugin support

1 lines 61.6 kB
{"version":3,"file":"diagram-4IRLE6MV-Cz7plXqE.mjs","sources":["../node_modules/d3-hierarchy/src/hierarchy/count.js","../node_modules/d3-hierarchy/src/hierarchy/each.js","../node_modules/d3-hierarchy/src/hierarchy/eachBefore.js","../node_modules/d3-hierarchy/src/hierarchy/eachAfter.js","../node_modules/d3-hierarchy/src/hierarchy/find.js","../node_modules/d3-hierarchy/src/hierarchy/sum.js","../node_modules/d3-hierarchy/src/hierarchy/sort.js","../node_modules/d3-hierarchy/src/hierarchy/path.js","../node_modules/d3-hierarchy/src/hierarchy/ancestors.js","../node_modules/d3-hierarchy/src/hierarchy/descendants.js","../node_modules/d3-hierarchy/src/hierarchy/leaves.js","../node_modules/d3-hierarchy/src/hierarchy/links.js","../node_modules/d3-hierarchy/src/hierarchy/iterator.js","../node_modules/d3-hierarchy/src/hierarchy/index.js","../node_modules/d3-hierarchy/src/accessors.js","../node_modules/d3-hierarchy/src/constant.js","../node_modules/d3-hierarchy/src/treemap/round.js","../node_modules/d3-hierarchy/src/treemap/dice.js","../node_modules/d3-hierarchy/src/treemap/slice.js","../node_modules/d3-hierarchy/src/treemap/squarify.js","../node_modules/d3-hierarchy/src/treemap/index.js","../node_modules/mermaid/dist/chunks/mermaid.core/diagram-4IRLE6MV.mjs"],"sourcesContent":["function count(node) {\n var sum = 0,\n children = node.children,\n i = children && children.length;\n if (!i) sum = 1;\n else while (--i >= 0) sum += children[i].value;\n node.value = sum;\n}\n\nexport default function() {\n return this.eachAfter(count);\n}\n","export default function(callback, that) {\n let index = -1;\n for (const node of this) {\n callback.call(that, node, ++index, this);\n }\n return this;\n}\n","export default function(callback, that) {\n var node = this, nodes = [node], children, i, index = -1;\n while (node = nodes.pop()) {\n callback.call(that, node, ++index, this);\n if (children = node.children) {\n for (i = children.length - 1; i >= 0; --i) {\n nodes.push(children[i]);\n }\n }\n }\n return this;\n}\n","export default function(callback, that) {\n var node = this, nodes = [node], next = [], children, i, n, index = -1;\n while (node = nodes.pop()) {\n next.push(node);\n if (children = node.children) {\n for (i = 0, n = children.length; i < n; ++i) {\n nodes.push(children[i]);\n }\n }\n }\n while (node = next.pop()) {\n callback.call(that, node, ++index, this);\n }\n return this;\n}\n","export default function(callback, that) {\n let index = -1;\n for (const node of this) {\n if (callback.call(that, node, ++index, this)) {\n return node;\n }\n }\n}\n","export default function(value) {\n return this.eachAfter(function(node) {\n var sum = +value(node.data) || 0,\n children = node.children,\n i = children && children.length;\n while (--i >= 0) sum += children[i].value;\n node.value = sum;\n });\n}\n","export default function(compare) {\n return this.eachBefore(function(node) {\n if (node.children) {\n node.children.sort(compare);\n }\n });\n}\n","export default function(end) {\n var start = this,\n ancestor = leastCommonAncestor(start, end),\n nodes = [start];\n while (start !== ancestor) {\n start = start.parent;\n nodes.push(start);\n }\n var k = nodes.length;\n while (end !== ancestor) {\n nodes.splice(k, 0, end);\n end = end.parent;\n }\n return nodes;\n}\n\nfunction leastCommonAncestor(a, b) {\n if (a === b) return a;\n var aNodes = a.ancestors(),\n bNodes = b.ancestors(),\n c = null;\n a = aNodes.pop();\n b = bNodes.pop();\n while (a === b) {\n c = a;\n a = aNodes.pop();\n b = bNodes.pop();\n }\n return c;\n}\n","export default function() {\n var node = this, nodes = [node];\n while (node = node.parent) {\n nodes.push(node);\n }\n return nodes;\n}\n","export default function() {\n return Array.from(this);\n}\n","export default function() {\n var leaves = [];\n this.eachBefore(function(node) {\n if (!node.children) {\n leaves.push(node);\n }\n });\n return leaves;\n}\n","export default function() {\n var root = this, links = [];\n root.each(function(node) {\n if (node !== root) { // Don’t include the root’s parent, if any.\n links.push({source: node.parent, target: node});\n }\n });\n return links;\n}\n","export default function*() {\n var node = this, current, next = [node], children, i, n;\n do {\n current = next.reverse(), next = [];\n while (node = current.pop()) {\n yield node;\n if (children = node.children) {\n for (i = 0, n = children.length; i < n; ++i) {\n next.push(children[i]);\n }\n }\n }\n } while (next.length);\n}\n","import node_count from \"./count.js\";\nimport node_each from \"./each.js\";\nimport node_eachBefore from \"./eachBefore.js\";\nimport node_eachAfter from \"./eachAfter.js\";\nimport node_find from \"./find.js\";\nimport node_sum from \"./sum.js\";\nimport node_sort from \"./sort.js\";\nimport node_path from \"./path.js\";\nimport node_ancestors from \"./ancestors.js\";\nimport node_descendants from \"./descendants.js\";\nimport node_leaves from \"./leaves.js\";\nimport node_links from \"./links.js\";\nimport node_iterator from \"./iterator.js\";\n\nexport default function hierarchy(data, children) {\n if (data instanceof Map) {\n data = [undefined, data];\n if (children === undefined) children = mapChildren;\n } else if (children === undefined) {\n children = objectChildren;\n }\n\n var root = new Node(data),\n node,\n nodes = [root],\n child,\n childs,\n i,\n n;\n\n while (node = nodes.pop()) {\n if ((childs = children(node.data)) && (n = (childs = Array.from(childs)).length)) {\n node.children = childs;\n for (i = n - 1; i >= 0; --i) {\n nodes.push(child = childs[i] = new Node(childs[i]));\n child.parent = node;\n child.depth = node.depth + 1;\n }\n }\n }\n\n return root.eachBefore(computeHeight);\n}\n\nfunction node_copy() {\n return hierarchy(this).eachBefore(copyData);\n}\n\nfunction objectChildren(d) {\n return d.children;\n}\n\nfunction mapChildren(d) {\n return Array.isArray(d) ? d[1] : null;\n}\n\nfunction copyData(node) {\n if (node.data.value !== undefined) node.value = node.data.value;\n node.data = node.data.data;\n}\n\nexport function computeHeight(node) {\n var height = 0;\n do node.height = height;\n while ((node = node.parent) && (node.height < ++height));\n}\n\nexport function Node(data) {\n this.data = data;\n this.depth =\n this.height = 0;\n this.parent = null;\n}\n\nNode.prototype = hierarchy.prototype = {\n constructor: Node,\n count: node_count,\n each: node_each,\n eachAfter: node_eachAfter,\n eachBefore: node_eachBefore,\n find: node_find,\n sum: node_sum,\n sort: node_sort,\n path: node_path,\n ancestors: node_ancestors,\n descendants: node_descendants,\n leaves: node_leaves,\n links: node_links,\n copy: node_copy,\n [Symbol.iterator]: node_iterator\n};\n","export function optional(f) {\n return f == null ? null : required(f);\n}\n\nexport function required(f) {\n if (typeof f !== \"function\") throw new Error;\n return f;\n}\n","export function constantZero() {\n return 0;\n}\n\nexport default function(x) {\n return function() {\n return x;\n };\n}\n","export default function(node) {\n node.x0 = Math.round(node.x0);\n node.y0 = Math.round(node.y0);\n node.x1 = Math.round(node.x1);\n node.y1 = Math.round(node.y1);\n}\n","export default function(parent, x0, y0, x1, y1) {\n var nodes = parent.children,\n node,\n i = -1,\n n = nodes.length,\n k = parent.value && (x1 - x0) / parent.value;\n\n while (++i < n) {\n node = nodes[i], node.y0 = y0, node.y1 = y1;\n node.x0 = x0, node.x1 = x0 += node.value * k;\n }\n}\n","export default function(parent, x0, y0, x1, y1) {\n var nodes = parent.children,\n node,\n i = -1,\n n = nodes.length,\n k = parent.value && (y1 - y0) / parent.value;\n\n while (++i < n) {\n node = nodes[i], node.x0 = x0, node.x1 = x1;\n node.y0 = y0, node.y1 = y0 += node.value * k;\n }\n}\n","import treemapDice from \"./dice.js\";\nimport treemapSlice from \"./slice.js\";\n\nexport var phi = (1 + Math.sqrt(5)) / 2;\n\nexport function squarifyRatio(ratio, parent, x0, y0, x1, y1) {\n var rows = [],\n nodes = parent.children,\n row,\n nodeValue,\n i0 = 0,\n i1 = 0,\n n = nodes.length,\n dx, dy,\n value = parent.value,\n sumValue,\n minValue,\n maxValue,\n newRatio,\n minRatio,\n alpha,\n beta;\n\n while (i0 < n) {\n dx = x1 - x0, dy = y1 - y0;\n\n // Find the next non-empty node.\n do sumValue = nodes[i1++].value; while (!sumValue && i1 < n);\n minValue = maxValue = sumValue;\n alpha = Math.max(dy / dx, dx / dy) / (value * ratio);\n beta = sumValue * sumValue * alpha;\n minRatio = Math.max(maxValue / beta, beta / minValue);\n\n // Keep adding nodes while the aspect ratio maintains or improves.\n for (; i1 < n; ++i1) {\n sumValue += nodeValue = nodes[i1].value;\n if (nodeValue < minValue) minValue = nodeValue;\n if (nodeValue > maxValue) maxValue = nodeValue;\n beta = sumValue * sumValue * alpha;\n newRatio = Math.max(maxValue / beta, beta / minValue);\n if (newRatio > minRatio) { sumValue -= nodeValue; break; }\n minRatio = newRatio;\n }\n\n // Position and record the row orientation.\n rows.push(row = {value: sumValue, dice: dx < dy, children: nodes.slice(i0, i1)});\n if (row.dice) treemapDice(row, x0, y0, x1, value ? y0 += dy * sumValue / value : y1);\n else treemapSlice(row, x0, y0, value ? x0 += dx * sumValue / value : x1, y1);\n value -= sumValue, i0 = i1;\n }\n\n return rows;\n}\n\nexport default (function custom(ratio) {\n\n function squarify(parent, x0, y0, x1, y1) {\n squarifyRatio(ratio, parent, x0, y0, x1, y1);\n }\n\n squarify.ratio = function(x) {\n return custom((x = +x) > 1 ? x : 1);\n };\n\n return squarify;\n})(phi);\n","import roundNode from \"./round.js\";\nimport squarify from \"./squarify.js\";\nimport {required} from \"../accessors.js\";\nimport constant, {constantZero} from \"../constant.js\";\n\nexport default function() {\n var tile = squarify,\n round = false,\n dx = 1,\n dy = 1,\n paddingStack = [0],\n paddingInner = constantZero,\n paddingTop = constantZero,\n paddingRight = constantZero,\n paddingBottom = constantZero,\n paddingLeft = constantZero;\n\n function treemap(root) {\n root.x0 =\n root.y0 = 0;\n root.x1 = dx;\n root.y1 = dy;\n root.eachBefore(positionNode);\n paddingStack = [0];\n if (round) root.eachBefore(roundNode);\n return root;\n }\n\n function positionNode(node) {\n var p = paddingStack[node.depth],\n x0 = node.x0 + p,\n y0 = node.y0 + p,\n x1 = node.x1 - p,\n y1 = node.y1 - p;\n if (x1 < x0) x0 = x1 = (x0 + x1) / 2;\n if (y1 < y0) y0 = y1 = (y0 + y1) / 2;\n node.x0 = x0;\n node.y0 = y0;\n node.x1 = x1;\n node.y1 = y1;\n if (node.children) {\n p = paddingStack[node.depth + 1] = paddingInner(node) / 2;\n x0 += paddingLeft(node) - p;\n y0 += paddingTop(node) - p;\n x1 -= paddingRight(node) - p;\n y1 -= paddingBottom(node) - p;\n if (x1 < x0) x0 = x1 = (x0 + x1) / 2;\n if (y1 < y0) y0 = y1 = (y0 + y1) / 2;\n tile(node, x0, y0, x1, y1);\n }\n }\n\n treemap.round = function(x) {\n return arguments.length ? (round = !!x, treemap) : round;\n };\n\n treemap.size = function(x) {\n return arguments.length ? (dx = +x[0], dy = +x[1], treemap) : [dx, dy];\n };\n\n treemap.tile = function(x) {\n return arguments.length ? (tile = required(x), treemap) : tile;\n };\n\n treemap.padding = function(x) {\n return arguments.length ? treemap.paddingInner(x).paddingOuter(x) : treemap.paddingInner();\n };\n\n treemap.paddingInner = function(x) {\n return arguments.length ? (paddingInner = typeof x === \"function\" ? x : constant(+x), treemap) : paddingInner;\n };\n\n treemap.paddingOuter = function(x) {\n return arguments.length ? treemap.paddingTop(x).paddingRight(x).paddingBottom(x).paddingLeft(x) : treemap.paddingTop();\n };\n\n treemap.paddingTop = function(x) {\n return arguments.length ? (paddingTop = typeof x === \"function\" ? x : constant(+x), treemap) : paddingTop;\n };\n\n treemap.paddingRight = function(x) {\n return arguments.length ? (paddingRight = typeof x === \"function\" ? x : constant(+x), treemap) : paddingRight;\n };\n\n treemap.paddingBottom = function(x) {\n return arguments.length ? (paddingBottom = typeof x === \"function\" ? x : constant(+x), treemap) : paddingBottom;\n };\n\n treemap.paddingLeft = function(x) {\n return arguments.length ? (paddingLeft = typeof x === \"function\" ? x : constant(+x), treemap) : paddingLeft;\n };\n\n return treemap;\n}\n","import {\n setupViewPortForSVG\n} from \"./chunk-NRVI72HA.mjs\";\nimport {\n isLabelStyle,\n styles2String\n} from \"./chunk-7RNWAQOT.mjs\";\nimport {\n populateCommonDb\n} from \"./chunk-ANTBXLJU.mjs\";\nimport {\n cleanAndMerge\n} from \"./chunk-U37J5Y7L.mjs\";\nimport {\n selectSvgElement\n} from \"./chunk-T57MJCP2.mjs\";\nimport {\n __name,\n clear,\n configureSvgSize,\n defaultConfig_default,\n getAccDescription,\n getAccTitle,\n getConfig,\n getDiagramTitle,\n log,\n setAccDescription,\n setAccTitle,\n setDiagramTitle\n} from \"./chunk-VIW5F6AA.mjs\";\n\n// src/diagrams/treemap/db.ts\nvar TreeMapDB = class {\n constructor() {\n this.nodes = [];\n this.levels = /* @__PURE__ */ new Map();\n this.outerNodes = [];\n this.classes = /* @__PURE__ */ new Map();\n this.setAccTitle = setAccTitle;\n this.getAccTitle = getAccTitle;\n this.setDiagramTitle = setDiagramTitle;\n this.getDiagramTitle = getDiagramTitle;\n this.getAccDescription = getAccDescription;\n this.setAccDescription = setAccDescription;\n }\n static {\n __name(this, \"TreeMapDB\");\n }\n getNodes() {\n return this.nodes;\n }\n getConfig() {\n const defaultConfig = defaultConfig_default;\n const userConfig = getConfig();\n return cleanAndMerge({\n ...defaultConfig.treemap,\n ...userConfig.treemap ?? {}\n });\n }\n addNode(node, level) {\n this.nodes.push(node);\n this.levels.set(node, level);\n if (level === 0) {\n this.outerNodes.push(node);\n this.root ??= node;\n }\n }\n getRoot() {\n return { name: \"\", children: this.outerNodes };\n }\n addClass(id, _style) {\n const styleClass = this.classes.get(id) ?? { id, styles: [], textStyles: [] };\n const styles = _style.replace(/\\\\,/g, \"\\xA7\\xA7\\xA7\").replace(/,/g, \";\").replace(/§§§/g, \",\").split(\";\");\n if (styles) {\n styles.forEach((s) => {\n if (isLabelStyle(s)) {\n if (styleClass?.textStyles) {\n styleClass.textStyles.push(s);\n } else {\n styleClass.textStyles = [s];\n }\n }\n if (styleClass?.styles) {\n styleClass.styles.push(s);\n } else {\n styleClass.styles = [s];\n }\n });\n }\n this.classes.set(id, styleClass);\n }\n getClasses() {\n return this.classes;\n }\n getStylesForClass(classSelector) {\n return this.classes.get(classSelector)?.styles ?? [];\n }\n clear() {\n clear();\n this.nodes = [];\n this.levels = /* @__PURE__ */ new Map();\n this.outerNodes = [];\n this.classes = /* @__PURE__ */ new Map();\n this.root = void 0;\n }\n};\n\n// src/diagrams/treemap/parser.ts\nimport { parse } from \"@mermaid-js/parser\";\n\n// src/diagrams/treemap/utils.ts\nfunction buildHierarchy(items) {\n if (!items.length) {\n return [];\n }\n const root = [];\n const stack = [];\n items.forEach((item) => {\n const node = {\n name: item.name,\n children: item.type === \"Leaf\" ? void 0 : []\n };\n node.classSelector = item?.classSelector;\n if (item?.cssCompiledStyles) {\n node.cssCompiledStyles = [item.cssCompiledStyles];\n }\n if (item.type === \"Leaf\" && item.value !== void 0) {\n node.value = item.value;\n }\n while (stack.length > 0 && stack[stack.length - 1].level >= item.level) {\n stack.pop();\n }\n if (stack.length === 0) {\n root.push(node);\n } else {\n const parent = stack[stack.length - 1].node;\n if (parent.children) {\n parent.children.push(node);\n } else {\n parent.children = [node];\n }\n }\n if (item.type !== \"Leaf\") {\n stack.push({ node, level: item.level });\n }\n });\n return root;\n}\n__name(buildHierarchy, \"buildHierarchy\");\n\n// src/diagrams/treemap/parser.ts\nvar populate = /* @__PURE__ */ __name((ast, db) => {\n populateCommonDb(ast, db);\n const items = [];\n for (const row of ast.TreemapRows ?? []) {\n if (row.$type === \"ClassDefStatement\") {\n db.addClass(row.className ?? \"\", row.styleText ?? \"\");\n }\n }\n for (const row of ast.TreemapRows ?? []) {\n const item = row.item;\n if (!item) {\n continue;\n }\n const level = row.indent ? parseInt(row.indent) : 0;\n const name = getItemName(item);\n const styles = item.classSelector ? db.getStylesForClass(item.classSelector) : [];\n const cssCompiledStyles = styles.length > 0 ? styles.join(\";\") : void 0;\n const itemData = {\n level,\n name,\n type: item.$type,\n value: item.value,\n classSelector: item.classSelector,\n cssCompiledStyles\n };\n items.push(itemData);\n }\n const hierarchyNodes = buildHierarchy(items);\n const addNodesRecursively = /* @__PURE__ */ __name((nodes, level) => {\n for (const node of nodes) {\n db.addNode(node, level);\n if (node.children && node.children.length > 0) {\n addNodesRecursively(node.children, level + 1);\n }\n }\n }, \"addNodesRecursively\");\n addNodesRecursively(hierarchyNodes, 0);\n}, \"populate\");\nvar getItemName = /* @__PURE__ */ __name((item) => {\n return item.name ? String(item.name) : \"\";\n}, \"getItemName\");\nvar parser = {\n // @ts-expect-error - TreeMapDB is not assignable to DiagramDB\n parser: { yy: void 0 },\n parse: /* @__PURE__ */ __name(async (text) => {\n try {\n const parseFunc = parse;\n const ast = await parseFunc(\"treemap\", text);\n log.debug(\"Treemap AST:\", ast);\n const db = parser.parser?.yy;\n if (!(db instanceof TreeMapDB)) {\n throw new Error(\n \"parser.parser?.yy was not a TreemapDB. This is due to a bug within Mermaid, please report this issue at https://github.com/mermaid-js/mermaid/issues.\"\n );\n }\n populate(ast, db);\n } catch (error) {\n log.error(\"Error parsing treemap:\", error);\n throw error;\n }\n }, \"parse\")\n};\n\n// src/diagrams/treemap/renderer.ts\nimport { scaleOrdinal, treemap, hierarchy, format, select } from \"d3\";\nvar DEFAULT_INNER_PADDING = 10;\nvar SECTION_INNER_PADDING = 10;\nvar SECTION_HEADER_HEIGHT = 25;\nvar draw = /* @__PURE__ */ __name((_text, id, _version, diagram2) => {\n const treemapDb = diagram2.db;\n const config = treemapDb.getConfig();\n const treemapInnerPadding = config.padding ?? DEFAULT_INNER_PADDING;\n const title = treemapDb.getDiagramTitle();\n const root = treemapDb.getRoot();\n const { themeVariables } = getConfig();\n if (!root) {\n return;\n }\n const titleHeight = title ? 30 : 0;\n const svg = selectSvgElement(id);\n const width = config.nodeWidth ? config.nodeWidth * SECTION_INNER_PADDING : 960;\n const height = config.nodeHeight ? config.nodeHeight * SECTION_INNER_PADDING : 500;\n const svgWidth = width;\n const svgHeight = height + titleHeight;\n svg.attr(\"viewBox\", `0 0 ${svgWidth} ${svgHeight}`);\n configureSvgSize(svg, svgHeight, svgWidth, config.useMaxWidth);\n let valueFormat;\n try {\n const formatStr = config.valueFormat || \",\";\n if (formatStr === \"$0,0\") {\n valueFormat = /* @__PURE__ */ __name((value) => \"$\" + format(\",\")(value), \"valueFormat\");\n } else if (formatStr.startsWith(\"$\") && formatStr.includes(\",\")) {\n const precision = /\\.\\d+/.exec(formatStr);\n const precisionStr = precision ? precision[0] : \"\";\n valueFormat = /* @__PURE__ */ __name((value) => \"$\" + format(\",\" + precisionStr)(value), \"valueFormat\");\n } else if (formatStr.startsWith(\"$\")) {\n const restOfFormat = formatStr.substring(1);\n valueFormat = /* @__PURE__ */ __name((value) => \"$\" + format(restOfFormat || \"\")(value), \"valueFormat\");\n } else {\n valueFormat = format(formatStr);\n }\n } catch (error) {\n log.error(\"Error creating format function:\", error);\n valueFormat = format(\",\");\n }\n const colorScale = scaleOrdinal().range([\n \"transparent\",\n themeVariables.cScale0,\n themeVariables.cScale1,\n themeVariables.cScale2,\n themeVariables.cScale3,\n themeVariables.cScale4,\n themeVariables.cScale5,\n themeVariables.cScale6,\n themeVariables.cScale7,\n themeVariables.cScale8,\n themeVariables.cScale9,\n themeVariables.cScale10,\n themeVariables.cScale11\n ]);\n const colorScalePeer = scaleOrdinal().range([\n \"transparent\",\n themeVariables.cScalePeer0,\n themeVariables.cScalePeer1,\n themeVariables.cScalePeer2,\n themeVariables.cScalePeer3,\n themeVariables.cScalePeer4,\n themeVariables.cScalePeer5,\n themeVariables.cScalePeer6,\n themeVariables.cScalePeer7,\n themeVariables.cScalePeer8,\n themeVariables.cScalePeer9,\n themeVariables.cScalePeer10,\n themeVariables.cScalePeer11\n ]);\n const colorScaleLabel = scaleOrdinal().range([\n themeVariables.cScaleLabel0,\n themeVariables.cScaleLabel1,\n themeVariables.cScaleLabel2,\n themeVariables.cScaleLabel3,\n themeVariables.cScaleLabel4,\n themeVariables.cScaleLabel5,\n themeVariables.cScaleLabel6,\n themeVariables.cScaleLabel7,\n themeVariables.cScaleLabel8,\n themeVariables.cScaleLabel9,\n themeVariables.cScaleLabel10,\n themeVariables.cScaleLabel11\n ]);\n if (title) {\n svg.append(\"text\").attr(\"x\", svgWidth / 2).attr(\"y\", titleHeight / 2).attr(\"class\", \"treemapTitle\").attr(\"text-anchor\", \"middle\").attr(\"dominant-baseline\", \"middle\").text(title);\n }\n const g = svg.append(\"g\").attr(\"transform\", `translate(0, ${titleHeight})`).attr(\"class\", \"treemapContainer\");\n const hierarchyRoot = hierarchy(root).sum((d) => d.value ?? 0).sort((a, b) => (b.value ?? 0) - (a.value ?? 0));\n const treemapLayout = treemap().size([width, height]).paddingTop(\n (d) => d.children && d.children.length > 0 ? SECTION_HEADER_HEIGHT + SECTION_INNER_PADDING : 0\n ).paddingInner(treemapInnerPadding).paddingLeft((d) => d.children && d.children.length > 0 ? SECTION_INNER_PADDING : 0).paddingRight((d) => d.children && d.children.length > 0 ? SECTION_INNER_PADDING : 0).paddingBottom((d) => d.children && d.children.length > 0 ? SECTION_INNER_PADDING : 0).round(true);\n const treemapData = treemapLayout(hierarchyRoot);\n const branchNodes = treemapData.descendants().filter((d) => d.children && d.children.length > 0);\n const sections = g.selectAll(\".treemapSection\").data(branchNodes).enter().append(\"g\").attr(\"class\", \"treemapSection\").attr(\"transform\", (d) => `translate(${d.x0},${d.y0})`);\n sections.append(\"rect\").attr(\"width\", (d) => d.x1 - d.x0).attr(\"height\", SECTION_HEADER_HEIGHT).attr(\"class\", \"treemapSectionHeader\").attr(\"fill\", \"none\").attr(\"fill-opacity\", 0.6).attr(\"stroke-width\", 0.6).attr(\"style\", (d) => {\n if (d.depth === 0) {\n return \"display: none;\";\n }\n return \"\";\n });\n sections.append(\"clipPath\").attr(\"id\", (_d, i) => `clip-section-${id}-${i}`).append(\"rect\").attr(\"width\", (d) => Math.max(0, d.x1 - d.x0 - 12)).attr(\"height\", SECTION_HEADER_HEIGHT);\n sections.append(\"rect\").attr(\"width\", (d) => d.x1 - d.x0).attr(\"height\", (d) => d.y1 - d.y0).attr(\"class\", (_d, i) => {\n return `treemapSection section${i}`;\n }).attr(\"fill\", (d) => colorScale(d.data.name)).attr(\"fill-opacity\", 0.6).attr(\"stroke\", (d) => colorScalePeer(d.data.name)).attr(\"stroke-width\", 2).attr(\"stroke-opacity\", 0.4).attr(\"style\", (d) => {\n if (d.depth === 0) {\n return \"display: none;\";\n }\n const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });\n return styles.nodeStyles + \";\" + styles.borderStyles.join(\";\");\n });\n sections.append(\"text\").attr(\"class\", \"treemapSectionLabel\").attr(\"x\", 6).attr(\"y\", SECTION_HEADER_HEIGHT / 2).attr(\"dominant-baseline\", \"middle\").text((d) => d.depth === 0 ? \"\" : d.data.name).attr(\"font-weight\", \"bold\").attr(\"style\", (d) => {\n if (d.depth === 0) {\n return \"display: none;\";\n }\n const labelStyles = \"dominant-baseline: middle; font-size: 12px; fill:\" + colorScaleLabel(d.data.name) + \"; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;\";\n const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });\n return labelStyles + styles.labelStyles.replace(\"color:\", \"fill:\");\n }).each(function(d) {\n if (d.depth === 0) {\n return;\n }\n const self = select(this);\n const originalText = d.data.name;\n self.text(originalText);\n const totalHeaderWidth = d.x1 - d.x0;\n const labelXPosition = 6;\n let spaceForTextContent;\n if (config.showValues !== false && d.value) {\n const valueEndsAtXRelative = totalHeaderWidth - 10;\n const estimatedValueTextActualWidth = 30;\n const gapBetweenLabelAndValue = 10;\n const labelMustEndBeforeX = valueEndsAtXRelative - estimatedValueTextActualWidth - gapBetweenLabelAndValue;\n spaceForTextContent = labelMustEndBeforeX - labelXPosition;\n } else {\n const labelOwnRightPadding = 6;\n spaceForTextContent = totalHeaderWidth - labelXPosition - labelOwnRightPadding;\n }\n const minimumWidthToDisplay = 15;\n const actualAvailableWidth = Math.max(minimumWidthToDisplay, spaceForTextContent);\n const textNode = self.node();\n const currentTextContentLength = textNode.getComputedTextLength();\n if (currentTextContentLength > actualAvailableWidth) {\n const ellipsis = \"...\";\n let currentTruncatedText = originalText;\n while (currentTruncatedText.length > 0) {\n currentTruncatedText = originalText.substring(0, currentTruncatedText.length - 1);\n if (currentTruncatedText.length === 0) {\n self.text(ellipsis);\n if (textNode.getComputedTextLength() > actualAvailableWidth) {\n self.text(\"\");\n }\n break;\n }\n self.text(currentTruncatedText + ellipsis);\n if (textNode.getComputedTextLength() <= actualAvailableWidth) {\n break;\n }\n }\n }\n });\n if (config.showValues !== false) {\n sections.append(\"text\").attr(\"class\", \"treemapSectionValue\").attr(\"x\", (d) => d.x1 - d.x0 - 10).attr(\"y\", SECTION_HEADER_HEIGHT / 2).attr(\"text-anchor\", \"end\").attr(\"dominant-baseline\", \"middle\").text((d) => d.value ? valueFormat(d.value) : \"\").attr(\"font-style\", \"italic\").attr(\"style\", (d) => {\n if (d.depth === 0) {\n return \"display: none;\";\n }\n const labelStyles = \"text-anchor: end; dominant-baseline: middle; font-size: 10px; fill:\" + colorScaleLabel(d.data.name) + \"; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;\";\n const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });\n return labelStyles + styles.labelStyles.replace(\"color:\", \"fill:\");\n });\n }\n const leafNodes = treemapData.leaves();\n const cell = g.selectAll(\".treemapLeafGroup\").data(leafNodes).enter().append(\"g\").attr(\"class\", (d, i) => {\n return `treemapNode treemapLeafGroup leaf${i}${d.data.classSelector ? ` ${d.data.classSelector}` : \"\"}x`;\n }).attr(\"transform\", (d) => `translate(${d.x0},${d.y0})`);\n cell.append(\"rect\").attr(\"width\", (d) => d.x1 - d.x0).attr(\"height\", (d) => d.y1 - d.y0).attr(\"class\", \"treemapLeaf\").attr(\"fill\", (d) => {\n return d.parent ? colorScale(d.parent.data.name) : colorScale(d.data.name);\n }).attr(\"style\", (d) => {\n const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });\n return styles.nodeStyles;\n }).attr(\"fill-opacity\", 0.3).attr(\"stroke\", (d) => {\n return d.parent ? colorScale(d.parent.data.name) : colorScale(d.data.name);\n }).attr(\"stroke-width\", 3);\n cell.append(\"clipPath\").attr(\"id\", (_d, i) => `clip-${id}-${i}`).append(\"rect\").attr(\"width\", (d) => Math.max(0, d.x1 - d.x0 - 4)).attr(\"height\", (d) => Math.max(0, d.y1 - d.y0 - 4));\n const leafLabels = cell.append(\"text\").attr(\"class\", \"treemapLabel\").attr(\"x\", (d) => (d.x1 - d.x0) / 2).attr(\"y\", (d) => (d.y1 - d.y0) / 2).attr(\"style\", (d) => {\n const labelStyles = \"text-anchor: middle; dominant-baseline: middle; font-size: 38px;fill:\" + colorScaleLabel(d.data.name) + \";\";\n const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });\n return labelStyles + styles.labelStyles.replace(\"color:\", \"fill:\");\n }).attr(\"clip-path\", (_d, i) => `url(#clip-${id}-${i})`).text((d) => d.data.name);\n leafLabels.each(function(d) {\n const self = select(this);\n const nodeWidth = d.x1 - d.x0;\n const nodeHeight = d.y1 - d.y0;\n const textNode = self.node();\n const padding = 4;\n const availableWidth = nodeWidth - 2 * padding;\n const availableHeight = nodeHeight - 2 * padding;\n if (availableWidth < 10 || availableHeight < 10) {\n self.style(\"display\", \"none\");\n return;\n }\n let currentLabelFontSize = parseInt(self.style(\"font-size\"), 10);\n const minLabelFontSize = 8;\n const originalValueRelFontSize = 28;\n const valueScaleFactor = 0.6;\n const minValueFontSize = 6;\n const spacingBetweenLabelAndValue = 2;\n while (textNode.getComputedTextLength() > availableWidth && currentLabelFontSize > minLabelFontSize) {\n currentLabelFontSize--;\n self.style(\"font-size\", `${currentLabelFontSize}px`);\n }\n let prospectiveValueFontSize = Math.max(\n minValueFontSize,\n Math.min(originalValueRelFontSize, Math.round(currentLabelFontSize * valueScaleFactor))\n );\n let combinedHeight = currentLabelFontSize + spacingBetweenLabelAndValue + prospectiveValueFontSize;\n while (combinedHeight > availableHeight && currentLabelFontSize > minLabelFontSize) {\n currentLabelFontSize--;\n prospectiveValueFontSize = Math.max(\n minValueFontSize,\n Math.min(originalValueRelFontSize, Math.round(currentLabelFontSize * valueScaleFactor))\n );\n if (prospectiveValueFontSize < minValueFontSize && currentLabelFontSize === minLabelFontSize) {\n break;\n }\n self.style(\"font-size\", `${currentLabelFontSize}px`);\n combinedHeight = currentLabelFontSize + spacingBetweenLabelAndValue + prospectiveValueFontSize;\n if (prospectiveValueFontSize <= minValueFontSize && combinedHeight > availableHeight) {\n }\n }\n self.style(\"font-size\", `${currentLabelFontSize}px`);\n if (textNode.getComputedTextLength() > availableWidth || currentLabelFontSize < minLabelFontSize || availableHeight < currentLabelFontSize) {\n self.style(\"display\", \"none\");\n }\n });\n if (config.showValues !== false) {\n const leafValues = cell.append(\"text\").attr(\"class\", \"treemapValue\").attr(\"x\", (d) => (d.x1 - d.x0) / 2).attr(\"y\", function(d) {\n return (d.y1 - d.y0) / 2;\n }).attr(\"style\", (d) => {\n const labelStyles = \"text-anchor: middle; dominant-baseline: hanging; font-size: 28px;fill:\" + colorScaleLabel(d.data.name) + \";\";\n const styles = styles2String({ cssCompiledStyles: d.data.cssCompiledStyles });\n return labelStyles + styles.labelStyles.replace(\"color:\", \"fill:\");\n }).attr(\"clip-path\", (_d, i) => `url(#clip-${id}-${i})`).text((d) => d.value ? valueFormat(d.value) : \"\");\n leafValues.each(function(d) {\n const valueTextElement = select(this);\n const parentCellNode = this.parentNode;\n if (!parentCellNode) {\n valueTextElement.style(\"display\", \"none\");\n return;\n }\n const labelElement = select(parentCellNode).select(\".treemapLabel\");\n if (labelElement.empty() || labelElement.style(\"display\") === \"none\") {\n valueTextElement.style(\"display\", \"none\");\n return;\n }\n const finalLabelFontSize = parseFloat(labelElement.style(\"font-size\"));\n const originalValueFontSize = 28;\n const valueScaleFactor = 0.6;\n const minValueFontSize = 6;\n const spacingBetweenLabelAndValue = 2;\n const actualValueFontSize = Math.max(\n minValueFontSize,\n Math.min(originalValueFontSize, Math.round(finalLabelFontSize * valueScaleFactor))\n );\n valueTextElement.style(\"font-size\", `${actualValueFontSize}px`);\n const labelCenterY = (d.y1 - d.y0) / 2;\n const valueTopActualY = labelCenterY + finalLabelFontSize / 2 + spacingBetweenLabelAndValue;\n valueTextElement.attr(\"y\", valueTopActualY);\n const nodeWidth = d.x1 - d.x0;\n const nodeTotalHeight = d.y1 - d.y0;\n const cellBottomPadding = 4;\n const maxValueBottomY = nodeTotalHeight - cellBottomPadding;\n const availableWidthForValue = nodeWidth - 2 * 4;\n if (valueTextElement.node().getComputedTextLength() > availableWidthForValue || valueTopActualY + actualValueFontSize > maxValueBottomY || actualValueFontSize < minValueFontSize) {\n valueTextElement.style(\"display\", \"none\");\n } else {\n valueTextElement.style(\"display\", null);\n }\n });\n }\n const diagramPadding = config.diagramPadding ?? 8;\n setupViewPortForSVG(svg, diagramPadding, \"flowchart\", config?.useMaxWidth || false);\n}, \"draw\");\nvar getClasses = /* @__PURE__ */ __name(function(_text, diagramObj) {\n return diagramObj.db.getClasses();\n}, \"getClasses\");\nvar renderer = { draw, getClasses };\n\n// src/diagrams/treemap/styles.ts\nvar defaultTreemapStyleOptions = {\n sectionStrokeColor: \"black\",\n sectionStrokeWidth: \"1\",\n sectionFillColor: \"#efefef\",\n leafStrokeColor: \"black\",\n leafStrokeWidth: \"1\",\n leafFillColor: \"#efefef\",\n labelColor: \"black\",\n labelFontSize: \"12px\",\n valueFontSize: \"10px\",\n valueColor: \"black\",\n titleColor: \"black\",\n titleFontSize: \"14px\"\n};\nvar getStyles = /* @__PURE__ */ __name(({\n treemap: treemap2\n} = {}) => {\n const options = cleanAndMerge(defaultTreemapStyleOptions, treemap2);\n return `\n .treemapNode.section {\n stroke: ${options.sectionStrokeColor};\n stroke-width: ${options.sectionStrokeWidth};\n fill: ${options.sectionFillColor};\n }\n .treemapNode.leaf {\n stroke: ${options.leafStrokeColor};\n stroke-width: ${options.leafStrokeWidth};\n fill: ${options.leafFillColor};\n }\n .treemapLabel {\n fill: ${options.labelColor};\n font-size: ${options.labelFontSize};\n }\n .treemapValue {\n fill: ${options.valueColor};\n font-size: ${options.valueFontSize};\n }\n .treemapTitle {\n fill: ${options.titleColor};\n font-size: ${options.titleFontSize};\n }\n `;\n}, \"getStyles\");\nvar styles_default = getStyles;\n\n// src/diagrams/treemap/diagram.ts\nvar diagram = {\n parser,\n get db() {\n return new TreeMapDB();\n },\n renderer,\n styles: styles_default\n};\nexport {\n diagram\n};\n"],"names":["count","node","sum","children","i","node_count","node_each","callback","that","index","node_eachBefore","nodes","node_eachAfter","next","n","node_find","node_sum","value","node_sort","compare","node_path","end","start","ancestor","leastCommonAncestor","k","a","b","aNodes","bNodes","c","node_ancestors","node_descendants","node_leaves","leaves","node_links","root","links","node_iterator","current","hierarchy","data","mapChildren","objectChildren","Node","child","childs","computeHeight","node_copy","copyData","d","height","required","f","constantZero","constant","x","roundNode","treemapDice","parent","x0","y0","x1","y1","treemapSlice","phi","squarifyRatio","ratio","rows","row","nodeValue","i0","i1","dx","dy","sumValue","minValue","maxValue","newRatio","minRatio","alpha","beta","squarify","custom","treemap","tile","round","paddingStack","paddingInner","paddingTop","paddingRight","paddingBottom","paddingLeft","positionNode","p","TreeMapDB","_a","setAccTitle","getAccTitle","setDiagramTitle","getDiagramTitle","getAccDescription","setAccDescription","defaultConfig","defaultConfig_default","userConfig","getConfig","cleanAndMerge","level","id","_style","styleClass","styles","isLabelStyle","classSelector","clear","__name","buildHierarchy","items","stack","item","populate","ast","db","populateCommonDb","name","getItemName","cssCompiledStyles","itemData","hierarchyNodes","addNodesRecursively","parser","text","parse","log","error","DEFAULT_INNER_PADDING","SECTION_INNER_PADDING","SECTION_HEADER_HEIGHT","draw","_text","_version","diagram2","treemapDb","config","treemapInnerPadding","title","themeVariables","titleHeight","svg","selectSvgElement","width","svgWidth","svgHeight","configureSvgSize","valueFormat","formatStr","format","precision","precisionStr","restOfFormat","colorScale","scaleOrdinal","colorScalePeer","colorScaleLabel","g","hierarchyRoot","treemapData","branchNodes","sections","_d","styles2String","labelStyles","self","select","originalText","totalHeaderWidth","labelXPosition","spaceForTextContent","actualAvailableWidth","textNode","currentTruncatedText","leafNodes","cell","nodeWidth","nodeHeight","padding","availableWidth","availableHeight","currentLabelFontSize","minLabelFontSize","originalValueRelFontSize","valueScaleFactor","minValueFontSize","spacingBetweenLabelAndValue","prospectiveValueFontSize","combinedHeight","valueTextElement","parentCellNode","labelElement","finalLabelFontSize","originalValueFontSize","actualValueFontSize","valueTopActualY","maxValueBottomY","availableWidthForValue","diagramPadding","setupViewPortForSVG","getClasses","diagramObj","renderer","defaultTreemapStyleOptions","getStyles","treemap2","options","styles_default","diagram"],"mappings":";;;;;;AAAA,SAASA,GAAMC,GAAM;AACnB,MAAIC,IAAM,GACNC,IAAWF,EAAK,UAChBG,IAAID,KAAYA,EAAS;AAC7B,MAAI,CAACC,EAAG,CAAAF,IAAM;AAAA,MACT,QAAO,EAAEE,KAAK,IAAG,CAAAF,KAAOC,EAASC,CAAC,EAAE;AACzC,EAAAH,EAAK,QAAQC;AACf;AAEe,SAAAG,KAAW;AACxB,SAAO,KAAK,UAAUL,EAAK;AAC7B;ACXe,SAAAM,GAASC,GAAUC,GAAM;AACtC,MAAIC,IAAQ;AACZ,aAAWR,KAAQ;AACjB,IAAAM,EAAS,KAAKC,GAAMP,GAAM,EAAEQ,GAAO,IAAI;AAEzC,SAAO;AACT;ACNe,SAAAC,GAASH,GAAUC,GAAM;AAEtC,WADIP,IAAO,MAAMU,IAAQ,CAACV,CAAI,GAAGE,GAAUC,GAAGK,IAAQ,IAC/CR,IAAOU,EAAM;AAElB,QADAJ,EAAS,KAAKC,GAAMP,GAAM,EAAEQ,GAAO,IAAI,GACnCN,IAAWF,EAAK;AAClB,WAAKG,IAAID,EAAS,SAAS,GAAGC,KAAK,GAAG,EAAEA;AACtC,QAAAO,EAAM,KAAKR,EAASC,CAAC,CAAC;AAI5B,SAAO;AACT;ACXe,SAAAQ,GAASL,GAAUC,GAAM;AAEtC,WADIP,IAAO,MAAMU,IAAQ,CAACV,CAAI,GAAGY,IAAO,CAAA,GAAIV,GAAUC,GAAGU,GAAGL,IAAQ,IAC7DR,IAAOU,EAAM;AAElB,QADAE,EAAK,KAAKZ,CAAI,GACVE,IAAWF,EAAK;AAClB,WAAKG,IAAI,GAAGU,IAAIX,EAAS,QAAQC,IAAIU,GAAG,EAAEV;AACxC,QAAAO,EAAM,KAAKR,EAASC,CAAC,CAAC;AAI5B,SAAOH,IAAOY,EAAK;AACjB,I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