@avodado/render 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/css.ts","../src/escape.ts","../src/sanitize.ts","../src/markdown.ts","../src/blocks/meta.ts","../src/blocks/frame.ts","../src/blocks/callout.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/graph.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/version.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/json.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/alg/index.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/alg/bellman-ford.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/alg/components.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/data/priority-queue.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/alg/dijkstra.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/alg/dijkstra-all.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/alg/tarjan.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/alg/find-cycles.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/alg/floyd-warshall.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/alg/topsort.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/alg/is-acyclic.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/alg/reduce.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/alg/dfs.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/alg/postorder.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/alg/preorder.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/alg/prim.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/alg/shortest-paths.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/util.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/version.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/data/list.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/greedy-fas.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/acyclic.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/normalize.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/rank/util.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/rank/feasible-tree.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/rank/network-simplex.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/rank/index.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/parent-dummy-chains.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/nesting-graph.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/add-border-segments.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/coordinate-system.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/order/init-order.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/order/cross-count.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/order/barycenter.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/order/resolve-conflicts.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/order/sort.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/order/sort-subgraph.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/order/build-layer-graph.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/order/add-subgraph-constraints.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/order/index.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/position/bk.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/position/index.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/layout.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/debug.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/index.ts","../src/blocks/erd.ts","../src/blocks/kanban.ts","../src/blocks/sequence.ts","../src/blocks/table.ts","../src/blocks/timeline.ts","../src/blocks/tracker.ts","../src/blocks/userstory.ts","../src/blocks/prose.ts","../src/blocks/glossary.ts","../src/blocks/proscons.ts","../src/blocks/cvt.ts","../src/blocks/stats.ts","../src/highlight.ts","../src/blocks/code.ts","../src/blocks/agenda.ts","../src/blocks/tree.ts","../src/blocks/pyramid.ts","../src/blocks/funnel.ts","../src/svg/ortho.ts","../src/svg/wrapText.ts","../src/svg/edgePill.ts","../src/blocks/flow.ts","../src/blocks/state.ts","../src/blocks/dfd.ts","../src/blocks/journey.ts","../src/blocks/gantt.ts","../src/blocks/graph.ts","../src/blocks/quadrant.ts","../src/blocks/swimlane.ts","../src/svg/blockStyle.ts","../src/blocks/c4.ts","../src/blocks/uml.ts","../src/blocks/mece.ts","../src/blocks/frontend.ts","../src/blocks/cluster.ts","../src/blocks/blockGraph.ts","../src/blocks/felogic.ts","../src/blocks/wireframe.ts","../src/registry.ts","../src/svg/defs.ts","../src/themes.ts","../src/parts.ts","../src/document.ts"],"names":["Graph","opts","label","labelOrFn","v","names","name","removeEdge","e","child","parent","ancestor","children","predsV","sucsV","preds","union","succ","neighbors","filter","copy","value","parents","findParent","nodes","w","vStr","wStr","nameStr","edgeValue","valueSpecified","edgeArgsToId","edgeObj","edgeArgsToObj","incrementOrInitEntry","edgeObjToId","edgeLabel","edge","decrementOrRemoveEntry","setV","localEdge","remoteEdge","edges","map","k","isDirected","v_","w_","tmp","version","json_exports","__export","read","write","graph","json","writeNodes","writeEdges","graphLabel","g","nodeValue","node","entry","alg_exports","CycleException","bellmanFord","components","dijkstra","dijkstraAll","findCycles","floydWarshall","isAcyclic","postorder","preorder","prim","shortestPaths","tarjan","topsort","DEFAULT_WEIGHT_FUNC","source","weightFn","edgeFn","runBellmanFord","results","didADistanceUpgrade","iterations","relaxEdge","edgeWeight","relaxAllEdges","vertex","inVertex","outVertex","distance","numberOfNodes","i","visited","cmpts","cmpt","dfs","PriorityQueue","x","key","index","priority","keyIndices","keyStr","arr","min","currentPriority","l","r","largest","j","origArrI","origArrJ","defaultEdgeFn","runDijkstra","pq","vEntry","updateNeighbors","wEntry","weight","acc","stack","runFloydWarshall","d","rowK","rowI","ik","kj","ij","altDistance","args","visit","reduce","vs","order","fn","navigation","_a","doReduce","result","pri","init","runShortestPaths","negativeEdgeExists","adjList","addDummyNode","type","attrs","uniqueId","simplify","simplified","simpleLabel","asNonCompoundGraph","intersectRect","rect","point","y","dx","dy","h","sx","sy","buildLayerMatrix","layering","range","maxRank","rank","normalizeRanks","nodeRanks","applyWithChunking","removeEmptyRanks","offset","layers","delta","nodeRankFactor","addBorderNode","prefix","splitToChunks","array","chunkSize","CHUNKING_THRESHOLD","chunks","chunk","argsArray","partition","collection","time","start","notime","idCounter","id","limit","step","endCon","pick","keys","dest","mapValues","obj","funcOrProp","func","val","zipObject","props","values","GRAPH_NODE","List","__publicField","sentinel","unlink","strs","curr","filterOutLinks","list_default","DEFAULT_WEIGHT_FN","greedyFAS","state","buildState","doGreedyFAS","buckets","zeroIdx","sources","sinks","removeNode","collectPredecessors","collected","uEntry","assignBucket","fasGraph","maxIn","maxOut","prevWeight","vNode","wNode","_b","_c","run","dfsFAS","fas","undo","forwardName","normalizeEdge","vRank","wRank","labelRank","dummy","origLabel","longestPath","outEdges","outEdgesMinLens","slack","feasible_tree_default","feasibleTree","tree","size","tightTree","findMinSlackEdge","shiftRanks","nodeEdges","edgeV","edgeSlack","network_simplex_default","networkSimplex","initLowLimValues","initCutValues","calcCutValue","leaveEdge","enterEdge","exchangeEdges","t","f","visitedNodes","assignCutValue","childIsTail","graphEdge","cutValue","isOutEdge","other","pointsToHead","otherWeight","isTreeEdge","otherCutValue","root","dfsAssignLowLim","nextLim","low","vLabel","wLabel","tailLabel","flip","isDescendant","updateRanks","flipped","u","rootLabel","rank_default","ranker","networkSimplexRanker","tightTreeRanker","longestPathRanker","parent_dummy_chains_default","parentDummyChains","postorderNums","pathData","findPath","path","lca","pathIdx","pathV","ascending","vPath","wPath","lim","wParent","depths","treeDepths","depthsArr","height","nodeSep","sumWeights","top","bottom","childNode","childTop","childBottom","thisWeight","minlen","depth","cleanup","add_border_segments_default","addBorderSegments","prop","sg","sgNode","prev","adjust","rankDir","swapWidthHeight","reverseY","swapXY","swapWidthHeightOne","reverseYOne","swapXYOne","initOrder","simpleNodes","simpleNodesRanks","successors","a","b","crossCount","cc","twoLayerCrossCount","northLayer","southLayer","southPos","southEntries","firstIndex","treeSize","weightSum","barycenter","movable","inV","nodeU","resolveConflicts","entries","constraintGraph","mappedEntries","entryV","entryW","sourceSet","doResolveConflicts","handleIn","mergeEntries","handleOut","target","sum","sort","biasRight","parts","sortable","unsortable","vsIndex","compareWithBias","consumeUnsortable","last","bias","sortSubgraph","bl","br","subgraphs","barycenters","subgraphResult","mergeBarycenters","expandSubgraphs","blPredecessors","blPred","brPredecessors","brPred","buildLayerGraph","relationship","nodesWithRank","createRootNode","addSubgraphConstraints","rootPrev","prevChild","downLayerGraphs","buildLayerGraphs","upLayerGraphs","assignOrder","bestCC","best","constraints","lastBest","sweepLayerGraphs","ranks","nodesByRank","addNodeToRank","layerGraphs","cg","lg","con","sorted","layer","findType1Conflicts","conflicts","visitLayer","prevLayer","k0","scanPos","prevLayerLength","lastNode","findOtherInnerSegmentNode","k1","scanNode","uLabel","uPos","addConflict","findType2Conflicts","scan","south","southEnd","prevNorthBorder","nextNorthBorder","uNode","north","prevNorthPos","nextNorthPos","southLookahead","predecessors","firstPred","conflictsV","hasConflict","verticalAlignment","neighborFn","align","pos","prevIdx","wsRaw","ws","posA","posB","mp","il","posW","rootW","horizontalCompaction","reverseSep","xs","blockG","buildBlockGraph","borderType","iterate","setXsFunc","nextNodesFunc","elem","nextElem","pass1","inEdges","xsV","pass2","xsW","predecessorsWrapper","successorsWrapper","rootV","blockGraph","sepFn","sep","vRoot","uRoot","prevMax","findSmallestWidthAlignment","xss","currentMinAndXs","max","halfWidth","width","newMin","alignCoordinates","alignTo","alignToVals","alignToMin","alignToMax","vert","horiz","alignment","xsVals","balance","ulMap","num","alignmentKey","positionX","adjustedLayering","inner","smallestWidth","edgeSep","position","positionY","rankSep","rankAlign","prevY","maxHeight","layout","layoutGraph","buildLayoutGraph","runLayout","updateInputGraph","makeSpaceForEdgeLabels","removeSelfEdges","injectEdgeLabelProxies","assignRankMinMax","removeEdgeLabelProxies","insertSelfEdges","positionSelfEdges","removeBorderNodes","fixupEdgeLabelCoords","translateGraph","assignNodeIntersects","reversePointsForReversedEdges","inputGraph","inputLabel","layoutLabel","graphNumAttrs","graphDefaults","graphAttrs","nodeNumAttrs","nodeDefaults","edgeNumAttrs","edgeDefaults","edgeAttrs","canonicalize","selectNumberAttrs","newNode","proxyNode","minX","maxX","minY","maxY","marginX","marginY","getExtremes","p","nodeV","nodeW","p1","p2","orderShift","selfEdge","selfEdgeNode","selfNode","newAttrs","debugOrdering","layerMatrix","layerV","dagre","graphlib_esm_exports","index_default","W","H","at","N","it","st","lt","L","CHART_COLORS","A","B","ex","ey","rectFor","ln","s","P","clamp01","_"],"mappings":";;;AAWO,IAAM,QAAA,GAAW,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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AA;AAC9E,EAAA,OACE,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,OAAA,EAKU,UAAA,CAAW,KAAA,CAAM,KAAK,CAAC,CAAA;AAAA,OAAA,EACvB,KAAA,CAAM,GAAG,CAAA,QAAA,CAAA,GACnB,UAAA,GACA;AAAA;AAAA;AAAA;AAAA,CAAA,GAGA,MAAM,IAAA,GACN,CAAA;AAAA;AAAA;AAAA,CAAA;AAIJ","file":"index.js","sourcesContent":["/**\n * The house CSS — ported verbatim from `resources/doc-studio.jsx`.\n *\n * All output is namespaced under `.docskin` so the stylesheet can coexist with\n * a host page's own styles. Theme switching works by overriding the CSS\n * variables on the `.docskin` root (see {@link themes}).\n *\n * Exported as a single string so it can be inlined into a `<style>` tag in the\n * standalone HTML produced by {@link renderDocument} (or copied verbatim into\n * a static stylesheet).\n */\nexport const houseCss = `*{box-sizing:border-box;margin:0;padding:0;}\nhtml{scroll-behavior:smooth;}\n/* Design tokens live on :root so a theme (applied as :root overrides) reaches\n the whole page — body chrome included, not just .docskin content. */\n:root{\n /* Default = \"textbook\": warm cream paper, deep academic navy, terracotta accent,\n classic serif display + body. Bigger headings for a printed-page feel. */\n --navy:#233a5e; --navy-tint:#c4d0e2; --blue:#2f5c8f; --light-blue:#e8eef6;\n --charcoal:#211f1a; --slate:#4a463d; --gray:#8a8475; --light-gray:#f2efe6;\n --rule:#e4dccb; --highlight:#9c4a2f; --highlight-soft:#f3e4dc;\n --positive:#3f7d4e; --positive-soft:#e3efe2; --negative:#a13b2e; --negative-soft:#f4e0db;\n --purple:#5b4a8a; --purple-soft:#ebe6f3; --teal:#2f6f6a; --teal-soft:#e0eeec; --white:#fcfbf7;\n --radius:4px;\n --font-display:\"Inter\",\"SF Pro Display\",-apple-system,BlinkMacSystemFont,\"Segoe UI\",Helvetica,Arial,sans-serif;\n --font-body:\"Inter\",-apple-system,BlinkMacSystemFont,\"Segoe UI\",Helvetica,Arial,sans-serif;\n --font-mono:\"SF Mono\",ui-monospace,Menlo,Consolas,\"Courier New\",monospace;\n}\nbody{background:var(--white);color:var(--charcoal);font-family:var(--font-body);font-size:15px;line-height:1.6;}\n.docskin{\n background:var(--white); color:var(--charcoal); font-family:var(--font-body); font-size:15px; line-height:1.6;\n max-width:1180px; margin:0 auto; padding:0 56px 128px;\n}\n.docskin .cover-bar{height:8px;background:var(--navy);margin:0 -56px 36px;}\n.docskin .cover-pad{padding:0 0 40px;margin-bottom:56px;border-bottom:1px solid var(--rule);}\n.docskin .cover-meta{display:flex;justify-content:space-between;flex-wrap:wrap;gap:16px;font-size:11px;text-transform:uppercase;letter-spacing:.12em;color:var(--gray);font-weight:600;margin-bottom:32px;}\n.docskin .cover-meta .accent{color:var(--highlight);}\n.docskin .cover-title{font-family:var(--font-display);font-weight:700;font-size:clamp(40px,5.2vw,62px);line-height:1.08;letter-spacing:-.015em;color:var(--navy);margin:0 0 22px;}\n.docskin .cover-sub{font-size:19px;line-height:1.55;color:var(--slate);max-width:860px;margin:0 0 36px;}\n.docskin .section{padding:0;margin-bottom:64px;}\n.docskin .section > *:last-child{margin-bottom:0;}\n.docskin .section-num{font-size:11px;text-transform:uppercase;letter-spacing:.14em;color:var(--highlight);font-weight:700;margin-bottom:8px;}\n.docskin .section-head{margin-bottom:28px;padding-bottom:16px;border-bottom:2px solid var(--navy);}\n.docskin .section-head .section-title{border-bottom:0;padding-bottom:0;margin-bottom:14px;}\n.docskin .section-title{font-family:var(--font-display);font-weight:700;font-size:clamp(28px,3.6vw,40px);line-height:1.15;letter-spacing:-.01em;color:var(--navy);margin:0 0 14px;padding-bottom:12px;border-bottom:2px solid var(--navy);}\n.docskin .section-lede{font-size:15.5px;color:var(--slate);line-height:1.6;max-width:860px;margin:0;}\n.docskin .section-block{margin-bottom:64px;}\n.docskin .section-block:last-child{margin-bottom:0;}\n.docskin .diagram{margin:28px 0 36px;border:1px solid var(--rule);background:var(--white);padding:22px 26px 18px;border-radius:var(--radius);}\n.docskin .diagram-head{display:flex;flex-wrap:wrap;align-items:baseline;gap:10px;padding-bottom:12px;margin-bottom:16px;border-bottom:1px dashed var(--rule);}\n.docskin .diagram-tag{font-family:var(--font-mono);font-size:10px;font-weight:700;padding:3px 9px;background:var(--navy);color:var(--white);letter-spacing:.08em;text-transform:uppercase;}\n.docskin .diagram-tag.post{background:var(--navy);} .docskin .diagram-tag.get{background:var(--positive);} .docskin .diagram-tag.c4{background:var(--blue);}\n.docskin .diagram-title{font-family:var(--font-display);font-weight:700;font-size:16px;color:var(--charcoal);flex:1;}\n.docskin .diagram-fignum{font-size:10px;color:var(--gray);text-transform:uppercase;letter-spacing:.1em;font-weight:700;}\n.docskin .diagram-desc{font-size:13px;color:var(--slate);margin:0 0 12px;}\n.docskin .diagram svg{display:block;margin:0 auto;max-width:100%;height:auto;}\n/* sequence */\n.docskin .lane-head{fill:var(--navy);} .docskin .lane-head.ext{fill:var(--slate);}\n.docskin .lane-head-text{fill:var(--white);font-family:var(--font-body);font-size:12px;font-weight:700;text-anchor:middle;}\n.docskin .lane-head-sub{fill:var(--navy-tint);font-family:var(--font-mono);font-size:9px;text-anchor:middle;letter-spacing:.06em;}\n.docskin .lane-head-sub.ext{fill:#cbd5e1;}\n.docskin .lifeline{stroke:var(--gray);stroke-width:1;stroke-dasharray:3 3;}\n.docskin .activation{fill:var(--light-blue);stroke:var(--navy);stroke-width:1;} .docskin .activation.pg{fill:var(--positive-soft);stroke:var(--positive);}\n.docskin .msg-line{stroke:var(--charcoal);stroke-width:1.2;fill:none;}\n.docskin .msg-line.dashed{stroke-dasharray:5 3;} .docskin .msg-line.err{stroke:var(--negative);stroke-width:1.4;}\n.docskin .msg-text{fill:var(--charcoal);font-family:var(--font-mono);font-size:10.5px;}\n.docskin .msg-text.em{fill:var(--navy);font-weight:700;} .docskin .msg-text.err{fill:var(--negative);font-weight:700;} .docskin .msg-text.note{fill:var(--gray);font-style:italic;}\n.docskin .step-badge{fill:var(--navy);} .docskin .step-badge.err{fill:var(--negative);}\n.docskin .step-badge-text{fill:var(--white);font-family:var(--font-mono);font-size:10px;font-weight:700;text-anchor:middle;}\n.docskin .seq-steps{margin-top:16px;padding:14px 18px;background:var(--light-gray);border:1px solid var(--rule);}\n.docskin .seq-steps-title{font-size:10px;text-transform:uppercase;letter-spacing:.12em;color:var(--navy);font-weight:700;margin-bottom:8px;}\n.docskin .seq-steps ol{list-style:none;counter-reset:step;padding:0;margin:0;}\n.docskin .seq-steps li{counter-increment:step;padding:7px 0 8px 40px;position:relative;border-bottom:1px solid var(--rule);}\n.docskin .seq-steps li:last-child{border-bottom:none;}\n.docskin .seq-steps li::before{content:counter(step);position:absolute;left:0;top:7px;width:26px;height:20px;background:var(--navy);color:var(--white);font-family:var(--font-mono);font-size:11px;font-weight:700;text-align:center;line-height:20px;border-radius:2px;}\n.docskin .seq-steps li.err::before{background:var(--negative);}\n.docskin .step-actor{font-family:var(--font-mono);font-size:11px;font-weight:700;color:var(--navy);margin-right:8px;text-transform:uppercase;letter-spacing:.06em;}\n.docskin .step-actor.err{color:var(--negative);}\n.docskin .step-summary{font-size:13px;color:var(--charcoal);}\n/* c4 */\n.docskin .c4-name{font-family:var(--font-display);font-size:14px;font-weight:700;}\n.docskin .c4-tech{font-family:var(--font-mono);font-size:9.5px;}\n.docskin .c4-desc{font-family:var(--font-body);font-size:10px;}\n.docskin .c4-chip{font-family:var(--font-body);font-size:8px;font-weight:700;letter-spacing:.1em;text-transform:uppercase;}\n.docskin .edge-label{font-family:var(--font-body);font-size:9.5px;fill:var(--slate);text-anchor:middle;}\n.docskin .edge-label.err{fill:var(--negative);font-weight:700;}\n.docskin .c4-boundary{fill:none;stroke:var(--navy);stroke-width:1.4;stroke-dasharray:8 5;}\n.docskin .c4-boundary-label{font-family:var(--font-body);font-size:10px;font-weight:700;fill:var(--navy);letter-spacing:.08em;text-transform:uppercase;}\n.docskin .legend{display:flex;flex-wrap:wrap;gap:8px 16px;margin-top:14px;padding-top:12px;border-top:1px dashed var(--rule);}\n.docskin .legend .item{display:flex;align-items:center;gap:6px;font-size:11px;color:var(--slate);}\n.docskin .legend .sw{width:13px;height:13px;border-radius:3px;}\n/* code block */\n.docskin .code-block{margin:12px 0 16px;border:1px solid var(--rule);}\n.docskin .code-header{display:flex;justify-content:space-between;padding:6px 14px;background:var(--light-gray);font-family:var(--font-mono);font-size:11px;font-weight:700;color:var(--slate);border-bottom:1px solid var(--rule);letter-spacing:.04em;}\n.docskin .code-block pre{padding:14px 16px;font-family:var(--font-mono);font-size:12px;line-height:1.55;color:var(--charcoal);overflow-x:auto;background:var(--white);white-space:pre;margin:0;}\n.docskin .code-block .kw{color:var(--navy);font-weight:700;} .docskin .code-block .com{color:var(--gray);font-style:italic;}\n.docskin .code-block .str{color:var(--positive);} .docskin .code-block .num{color:var(--purple);} .docskin .code-block .fn{color:var(--blue);} .docskin .code-block .ty{color:var(--teal);}\n/* er */\n.docskin .er-head-text{fill:var(--white);font-family:var(--font-display);font-size:13px;font-weight:700;text-anchor:middle;}\n.docskin .er-col{font-family:var(--font-mono);font-size:10.5px;fill:var(--charcoal);} .docskin .er-col.dim{fill:var(--gray);}\n.docskin .er-key{font-family:var(--font-mono);font-size:9px;font-weight:700;fill:var(--navy);} .docskin .er-key.fk{fill:var(--highlight);}\n.docskin .er-rowline{stroke:var(--light-gray);stroke-width:1;}\n/* block / state / flow shared text */\n.docskin .blk-name{font-family:var(--font-display);font-size:13px;font-weight:700;}\n.docskin .blk-tech{font-family:var(--font-mono);font-size:9.5px;}\n.docskin .blk-chip{font-family:var(--font-body);font-size:8px;font-weight:700;letter-spacing:.1em;text-transform:uppercase;}\n.docskin .grp-label{font-family:var(--font-body);font-size:10px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;}\n.docskin .sm-name{font-family:var(--font-display);font-size:13px;font-weight:700;text-anchor:middle;}\n.docskin .fc-label{font-family:var(--font-display);font-size:12px;font-weight:700;text-anchor:middle;}\n.docskin .endpoint-card{border:1px solid var(--rule);margin:16px 0;padding:18px 22px;background:var(--white);}\n.docskin .endpoint-header{display:flex;align-items:center;gap:12px;margin-bottom:10px;padding-bottom:10px;border-bottom:1px dashed var(--rule);}\n.docskin .endpoint-method{font-family:var(--font-mono);font-size:11px;font-weight:700;padding:4px 10px;color:var(--white);letter-spacing:.08em;text-transform:uppercase;}\n.docskin .endpoint-method.get{background:var(--positive);} .docskin .endpoint-method.post{background:var(--navy);} .docskin .endpoint-method.patch{background:var(--highlight);} .docskin .endpoint-method.delete{background:var(--negative);} .docskin .endpoint-method.put{background:var(--blue);}\n.docskin .endpoint-path{font-family:var(--font-mono);font-size:15px;font-weight:700;color:var(--charcoal);flex:1;}\n.docskin .endpoint-status{font-family:var(--font-mono);font-size:11.5px;color:var(--positive);font-weight:700;}\n.docskin .endpoint-desc{font-size:13px;color:var(--slate);margin:0 0 8px;}\n.docskin .endpoint-card h4{font-size:11px;text-transform:uppercase;letter-spacing:.12em;font-weight:700;color:var(--highlight);margin:14px 0 6px;}\n.docskin .endpoint-card ul{margin:0 0 0 20px;} .docskin .endpoint-card li{font-size:13px;margin-bottom:3px;}\n.docskin code{font-family:var(--font-mono);font-size:.86em;background:var(--light-gray);padding:2px 6px;border-radius:2px;border:1px solid var(--rule);}\n.docskin .transition-table{width:100%;border-collapse:collapse;margin:16px 0 8px;font-size:12px;}\n.docskin .transition-table thead{background:var(--navy);color:#fff;}\n.docskin .transition-table th{text-align:left;padding:8px 10px;font-size:9.5px;text-transform:uppercase;letter-spacing:.1em;}\n.docskin .transition-table td{padding:8px 10px;border-bottom:1px solid var(--rule);vertical-align:top;}\n.docskin .pill{display:inline-block;font-family:var(--font-mono);font-size:10px;font-weight:700;padding:2px 7px;border-radius:2px;text-transform:uppercase;}\n.docskin .pill-init{background:var(--light-gray);color:var(--slate);border:1px solid var(--rule);}\n.docskin .pill-active{background:var(--positive-soft);color:var(--positive);border:1px solid var(--positive);}\n.docskin .pill-wait{background:var(--highlight-soft);color:var(--highlight);border:1px solid var(--highlight);}\n.docskin .pill-end{background:var(--charcoal);color:#fff;}\n/* presentation: comparison table */\n.docskin .pres-table{width:100%;border-collapse:collapse;margin:14px 0;font-size:13px;}\n.docskin .pres-table thead{background:var(--navy);color:#fff;}\n.docskin .pres-table th{padding:9px 12px;text-align:left;font-family:var(--font-body);font-size:10.5px;text-transform:uppercase;letter-spacing:.08em;font-weight:700;}\n.docskin .pres-table th.r,.docskin .pres-table td.r{text-align:right;} .docskin .pres-table th.c,.docskin .pres-table td.c{text-align:center;}\n.docskin .pres-table th.hi{background:var(--highlight);}\n.docskin .pres-table td{padding:9px 12px;border-bottom:1px solid var(--rule);}\n.docskin .pres-table tbody tr:nth-child(even){background:var(--light-gray);}\n.docskin .pres-table td.lead{font-weight:700;color:var(--navy);font-family:var(--font-display);}\n.docskin .pres-table td.hi{background:var(--highlight-soft);}\n.docskin .cell-pos{color:var(--positive);font-weight:700;} .docskin .cell-neg{color:var(--negative);font-weight:700;} .docskin .cell-warn{color:var(--highlight);font-weight:700;} .docskin .cell-muted{color:var(--gray);}\n.docskin .badge{display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;border-radius:50%;font-size:12px;font-weight:700;}\n.docskin .badge.yes{background:var(--positive-soft);color:var(--positive);} .docskin .badge.no{background:var(--negative-soft);color:var(--negative);}\n.docskin .tbl-note{font-size:11px;color:var(--gray);font-style:italic;margin-top:6px;}\n/* presentation: stat cards */\n.docskin .stat-row{display:flex;flex-wrap:wrap;gap:14px;margin:16px 0;}\n.docskin .stat-card{flex:1 1 150px;border:1px solid var(--rule);border-top:3px solid var(--navy);padding:16px 18px;background:var(--white);}\n.docskin .stat-value{font-family:var(--font-display);font-size:30px;font-weight:700;color:var(--navy);line-height:1;}\n.docskin .stat-label{font-size:10.5px;text-transform:uppercase;letter-spacing:.1em;color:var(--gray);font-weight:700;margin-top:8px;}\n.docskin .stat-delta{font-family:var(--font-mono);font-size:12px;font-weight:700;margin-top:6px;}\n.docskin .stat-delta.up{color:var(--positive);} .docskin .stat-delta.down{color:var(--negative);} .docskin .stat-delta.flat{color:var(--gray);}\n/* presentation: timeline */\n.docskin .tl{position:relative;margin:18px 0;padding-left:8px;}\n.docskin .tl::before{content:\"\";position:absolute;left:9px;top:6px;bottom:6px;width:2px;background:var(--rule);}\n.docskin .tl-item{position:relative;padding:0 0 18px 30px;}\n.docskin .tl-item:last-child{padding-bottom:0;}\n.docskin .tl-dot{position:absolute;left:2px;top:2px;width:16px;height:16px;border-radius:50%;background:var(--white);border:3px solid var(--rule);box-sizing:border-box;}\n.docskin .tl-dot.done{background:var(--positive);border-color:var(--positive);} .docskin .tl-dot.current{background:var(--highlight);border-color:var(--highlight);} .docskin .tl-dot.next{border-color:var(--navy);}\n.docskin .tl-date{font-family:var(--font-mono);font-size:10.5px;font-weight:700;color:var(--highlight);text-transform:uppercase;letter-spacing:.06em;}\n.docskin .tl-label{font-family:var(--font-display);font-size:15px;font-weight:700;color:var(--navy);margin:1px 0 2px;}\n.docskin .tl-desc{font-size:12.5px;color:var(--slate);}\n/* presentation: quadrant */\n.docskin .quad-axis{stroke:var(--charcoal);stroke-width:1.5;}\n.docskin .quad-end{font-family:var(--font-body);font-size:10px;font-weight:700;fill:var(--gray);text-transform:uppercase;letter-spacing:.06em;}\n.docskin .quad-title{font-family:var(--font-body);font-size:11px;font-weight:700;fill:var(--navy);text-transform:uppercase;letter-spacing:.08em;}\n.docskin .quad-pt-label{font-family:var(--font-body);font-size:11px;font-weight:700;fill:var(--charcoal);}\n.docskin .toc{margin:18px 0 6px;padding:14px 20px;background:var(--light-gray);border:1px solid var(--rule);border-left:4px solid var(--highlight);}\n.docskin .toc-title{font-size:10px;text-transform:uppercase;letter-spacing:.12em;color:var(--navy);font-weight:700;margin-bottom:8px;}\n.docskin .toc ol{margin:0;padding-left:20px;} .docskin .toc li{font-size:13px;margin-bottom:4px;color:var(--slate);}\n.docskin .toc li span{color:var(--gray);font-family:var(--font-mono);font-size:11px;}\n/* swimlane */\n.docskin .sl-lane-label{font-family:var(--font-display);font-size:12px;font-weight:700;fill:#fff;}\n.docskin .sl-step{font-family:var(--font-body);font-size:11px;font-weight:700;text-anchor:middle;}\n/* callouts */\n.docskin .callout{border:1px solid var(--rule);border-left:4px solid var(--navy);padding:12px 16px;margin:10px 0;}\n.docskin .callout.note{border-left-color:var(--navy);background:var(--light-blue);} .docskin .callout.tip{border-left-color:var(--positive);background:var(--positive-soft);} .docskin .callout.warn{border-left-color:var(--highlight);background:var(--highlight-soft);} .docskin .callout.danger{border-left-color:var(--negative);background:var(--negative-soft);}\n.docskin .callout-title{font-size:10.5px;text-transform:uppercase;letter-spacing:.1em;font-weight:700;margin-bottom:4px;}\n.docskin .callout.note .callout-title{color:var(--navy);} .docskin .callout.tip .callout-title{color:var(--positive);} .docskin .callout.warn .callout-title{color:#b45309;} .docskin .callout.danger .callout-title{color:var(--negative);}\n.docskin .callout-body{font-size:13px;color:var(--slate);}\n/* prose */\n.docskin .prose h2{font-family:var(--font-display);font-weight:700;font-size:clamp(24px,3vw,32px);line-height:1.15;letter-spacing:-.015em;color:var(--navy);margin:40px 0 14px;padding-bottom:12px;border-bottom:2px solid var(--navy);}\n.docskin .prose h2:first-child{margin-top:0;}\n.docskin .prose h3{font-family:var(--font-display);font-weight:700;font-size:19px;letter-spacing:-.005em;color:var(--navy);margin:36px 0 12px;}\n.docskin .prose h4{font-size:11px;text-transform:uppercase;letter-spacing:.12em;font-weight:700;color:var(--highlight);margin:22px 0 8px;}\n.docskin .prose p{font-size:14px;color:var(--charcoal);margin:0 0 14px;line-height:1.6;max-width:880px;}\n.docskin .prose ul,.docskin .prose ol{margin:0 0 14px 22px;}\n.docskin .prose li{font-size:13.5px;color:var(--charcoal);margin-bottom:4px;max-width:880px;line-height:1.55;}\n.docskin .prose blockquote{border-left:3px solid var(--highlight);padding:4px 14px;margin:14px 0;color:var(--slate);font-style:italic;font-family:var(--font-display);}\n.docskin .prose code{font-family:var(--font-mono);font-size:.86em;background:var(--light-gray);padding:2px 6px;border-radius:2px;color:var(--charcoal);border:1px solid var(--rule);}\n.docskin .prose strong{font-weight:700;color:var(--charcoal);}\n.docskin .prose em{font-style:italic;}\n/* glossary */\n.docskin .glossary{margin:10px 0;}\n.docskin .glossary .row{display:grid;grid-template-columns:170px 1fr;gap:14px;padding:9px 0;border-bottom:1px solid var(--rule);}\n.docskin .glossary dt{font-family:var(--font-mono);font-size:13px;font-weight:700;color:var(--navy);}\n.docskin .glossary dd{margin:0;font-size:13px;color:var(--slate);}\n/* pros / cons */\n.docskin .pc{display:grid;grid-template-columns:1fr 1fr;gap:16px;margin:12px 0;}\n.docskin .pc-col{border:1px solid var(--rule);padding:14px 16px;}\n.docskin .pc-col.pro{border-top:3px solid var(--positive);} .docskin .pc-col.con{border-top:3px solid var(--negative);}\n.docskin .pc-head{font-size:11px;text-transform:uppercase;letter-spacing:.1em;font-weight:700;margin-bottom:8px;}\n.docskin .pc-col.pro .pc-head{color:var(--positive);} .docskin .pc-col.con .pc-head{color:var(--negative);}\n.docskin .pc-item{font-size:13px;color:var(--slate);padding:4px 0 4px 22px;position:relative;}\n.docskin .pc-item::before{position:absolute;left:0;top:4px;font-weight:700;}\n.docskin .pc-col.pro .pc-item::before{content:\"\\\\2713\";color:var(--positive);} .docskin .pc-col.con .pc-item::before{content:\"\\\\2717\";color:var(--negative);}\n/* current / target */\n.docskin .ct{display:flex;align-items:stretch;margin:12px 0;}\n.docskin .ct-panel{flex:1;border:1px solid var(--rule);padding:14px 18px;}\n.docskin .ct-panel.cur{background:var(--light-gray);} .docskin .ct-panel.tgt{border-top:3px solid var(--navy);}\n.docskin .ct-arrow{display:flex;align-items:center;padding:0 14px;color:var(--highlight);font-size:22px;font-weight:700;}\n.docskin .ct-label{font-size:11px;text-transform:uppercase;letter-spacing:.1em;font-weight:700;color:var(--gray);margin-bottom:8px;}\n.docskin .ct-panel.tgt .ct-label{color:var(--navy);}\n.docskin .ct-item{font-size:13px;color:var(--slate);padding:3px 0;}\n/* kanban */\n.docskin .kanban{display:flex;gap:14px;margin:12px 0;overflow-x:auto;}\n.docskin .kan-col{flex:1 1 0;min-width:150px;background:var(--light-gray);border:1px solid var(--rule);}\n.docskin .kan-head{background:var(--navy);color:#fff;font-size:11px;text-transform:uppercase;letter-spacing:.08em;font-weight:700;padding:8px 12px;}\n.docskin .kan-card{background:var(--white);border:1px solid var(--rule);border-left:3px solid var(--highlight);margin:8px;padding:9px 11px;}\n.docskin .kan-card-title{font-size:13px;font-weight:700;color:var(--charcoal);}\n.docskin .kan-card-tag{display:inline-block;font-family:var(--font-mono);font-size:9px;font-weight:700;text-transform:uppercase;letter-spacing:.06em;color:var(--gray);margin-top:4px;}\n/* pass 2 chart labels */\n.docskin .dfd-name{font-family:var(--font-display);font-size:12px;font-weight:700;text-anchor:middle;}\n.docskin .dfd-num{font-family:var(--font-mono);font-size:9px;font-weight:700;}\n.docskin .gantt-label{font-family:var(--font-body);font-size:11px;fill:var(--charcoal);}\n.docskin .gantt-head{font-family:var(--font-mono);font-size:9.5px;fill:var(--gray);text-anchor:middle;}\n.docskin .funnel-label{font-family:var(--font-display);font-size:13px;font-weight:700;fill:#fff;text-anchor:middle;}\n.docskin .funnel-val{font-family:var(--font-mono);font-size:11px;fill:#fff;text-anchor:middle;opacity:.9;}\n.docskin .pyr-label{font-family:var(--font-display);font-size:13px;font-weight:700;fill:#fff;text-anchor:middle;}\n.docskin .pyr-desc{font-family:var(--font-body);font-size:10px;fill:#fff;text-anchor:middle;opacity:.85;}\n/* indented tree */\n.docskin .tree-list{margin:10px 0;font-size:13px;}\n.docskin .tree-row{display:flex;align-items:baseline;padding:3px 0;}\n.docskin .tree-row .tw{color:var(--gray);margin-right:8px;font-family:var(--font-mono);font-size:11px;}\n.docskin .tree-row.branch .tw{color:var(--navy);}\n.docskin .tree-row .tlabel{color:var(--charcoal);font-family:var(--font-mono);}\n.docskin .tree-row.branch .tlabel{font-weight:700;color:var(--navy);}\n.docskin .tree-row .tnote{color:var(--gray);font-size:11px;margin-left:10px;font-family:var(--font-body);font-style:italic;}\n/* agenda */\n.docskin .agenda{margin:10px 0;}\n.docskin .agenda-row{display:grid;grid-template-columns:88px 1fr;gap:14px;padding:10px 0;border-bottom:1px solid var(--rule);}\n.docskin .agenda-time{font-family:var(--font-mono);font-size:12px;font-weight:700;color:var(--navy);}\n.docskin .agenda-dur{font-family:var(--font-mono);font-size:10px;color:var(--gray);margin-top:2px;}\n.docskin .agenda-title{font-family:var(--font-display);font-size:14px;font-weight:700;color:var(--charcoal);}\n.docskin .agenda-owner{font-size:10.5px;color:var(--highlight);font-weight:700;text-transform:uppercase;letter-spacing:.05em;margin-left:8px;}\n.docskin .agenda-desc{font-size:12.5px;color:var(--slate);margin-top:2px;}\n/* tracker */\n.docskin .trk{width:100%;border-collapse:collapse;margin:12px 0;font-size:13px;}\n.docskin .trk thead{background:var(--navy);color:#fff;} .docskin .trk th{padding:8px 10px;text-align:left;font-size:9.5px;text-transform:uppercase;letter-spacing:.08em;font-weight:700;}\n.docskin .trk td{padding:8px 10px;border-bottom:1px solid var(--rule);vertical-align:middle;}\n.docskin .trk tr.done .trk-task{text-decoration:line-through;color:var(--gray);}\n.docskin .st{display:inline-block;font-family:var(--font-mono);font-size:9.5px;font-weight:700;padding:2px 8px;border-radius:10px;text-transform:uppercase;letter-spacing:.04em;}\n.docskin .st.todo{background:var(--light-gray);color:var(--slate);border:1px solid var(--rule);} .docskin .st.doing{background:var(--highlight-soft);color:#b45309;} .docskin .st.done{background:var(--positive-soft);color:var(--positive);} .docskin .st.blocked{background:var(--negative-soft);color:var(--negative);}\n.docskin .pri{font-family:var(--font-mono);font-size:10px;font-weight:700;} .docskin .pri.high{color:var(--negative);} .docskin .pri.med{color:var(--highlight);} .docskin .pri.low{color:var(--gray);}\n/* cluster */\n.docskin .cl-head{font-family:var(--font-display);font-size:13px;font-weight:700;fill:#fff;}\n.docskin .cl-kind{font-family:var(--font-mono);font-size:9px;fill:#cfe0f3;text-anchor:end;text-transform:uppercase;letter-spacing:.06em;}\n/* user story */\n.docskin .story{border:1px solid var(--rule);border-left:4px solid var(--navy);padding:18px 22px;margin:12px 0;background:var(--white);}\n.docskin .story-stmt{font-family:var(--font-display);font-size:18px;line-height:1.55;color:var(--charcoal);}\n.docskin .story-stmt b{color:var(--navy);}\n.docskin .story-meta{display:flex;gap:8px;margin-top:12px;flex-wrap:wrap;}\n.docskin .story-chip{font-family:var(--font-mono);font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.05em;padding:3px 9px;border-radius:3px;background:var(--light-gray);color:var(--slate);border:1px solid var(--rule);}\n.docskin .ac-title{font-size:10.5px;text-transform:uppercase;letter-spacing:.12em;color:var(--highlight);font-weight:700;margin:16px 0 8px;}\n.docskin .ac-item{border:1px solid var(--rule);padding:10px 14px;margin-bottom:8px;background:var(--white);}\n.docskin .gwt{display:grid;grid-template-columns:60px 1fr;gap:4px 12px;font-size:13px;}\n.docskin .gwt .k{font-family:var(--font-mono);font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.06em;padding-top:1px;}\n.docskin .gwt .k.g{color:var(--positive);} .docskin .gwt .k.w{color:var(--navy);} .docskin .gwt .k.t{color:var(--highlight);}\n.docskin .gwt .v{color:var(--charcoal);}\n.docskin .links-row{display:flex;gap:8px;flex-wrap:wrap;}\n.docskin .link-chip{display:inline-flex;align-items:center;gap:6px;font-size:12px;font-weight:700;color:var(--navy);border:1px solid var(--navy);background:var(--white);padding:5px 11px;border-radius:20px;cursor:pointer;}\n.docskin .link-chip .lt{color:var(--gray);font-family:var(--font-mono);font-size:9px;text-transform:uppercase;letter-spacing:.06em;}\n.docskin .footer{margin-top:8px;padding:18px 32px 28px;border-top:2px solid var(--navy);font-size:11px;color:var(--gray);text-transform:uppercase;letter-spacing:.1em;font-weight:700;display:flex;justify-content:space-between;flex-wrap:wrap;gap:10px;}\n.docskin .footer .accent{color:var(--highlight);}\n.docskin .layer-label{font-family:var(--font-display);font-size:13px;font-weight:700;fill:#fff;}\n.docskin .uml-name{font-family:var(--font-display);font-size:13px;font-weight:700;text-anchor:middle;fill:#0a3a6e;}\n.docskin .uml-stereo{font-family:var(--font-body);font-size:9px;font-style:italic;text-anchor:middle;fill:#6b7280;}\n.docskin .uml-row{font-family:var(--font-mono);font-size:10.5px;fill:var(--charcoal);}\n.docskin .uml-sep{stroke:#0e54a1;stroke-width:1;}\n.docskin .ft-note{font-family:var(--font-mono);font-size:9px;}\n.docskin .tree-link{stroke:#9ca3af;stroke-width:1.3;fill:none;}\n/* wireframe / UI mockups */\n.docskin .wf-h{font-family:var(--font-display);font-size:18px;font-weight:700;}\n.docskin .wf-sub{font-family:var(--font-body);font-size:12px;font-weight:600;}\n.docskin .wf-btn{font-family:var(--font-body);font-size:11px;font-weight:700;fill:#fff;}\n.docskin .wf-ph-text{font-family:var(--font-body);font-size:10px;fill:var(--gray);}\n.docskin .wf-status{font-family:var(--font-mono);font-size:9px;fill:var(--charcoal);font-weight:700;}\n.docskin .wf-url{font-family:var(--font-mono);font-size:8.5px;fill:var(--gray);}\n.docskin .wf-tab{font-family:var(--font-body);font-size:8px;}\n.docskin .wf-caption{font-family:var(--font-mono);font-size:10px;fill:var(--gray);letter-spacing:.04em;}\n/* parse error */\n.docskin .err{font-family:var(--font-mono);font-size:12px;color:var(--negative);background:#fdf2f2;border:1px solid #f3c9c9;padding:8px 12px;margin:12px 0;white-space:pre-wrap;}`;\n","/**\n * HTML entity escaping, matching the reference renderer's `esc` semantics.\n *\n * Escapes `&`, `<`, `>`, and `\"`. `null`/`undefined` become the empty string.\n * Non-string values are coerced via `String()`.\n */\n\nconst REPL: Record<string, string> = {\n '&': '&amp;',\n '<': '&lt;',\n '>': '&gt;',\n '\"': '&quot;',\n};\n\n/**\n * Escapes a value for safe insertion into HTML text or attribute content.\n *\n * @param value - The value to escape (any type).\n * @returns The escaped string. Empty string for `null`/`undefined`.\n */\nexport function escapeHtml(value: unknown): string {\n if (value === null || value === undefined) return '';\n return String(value).replace(/[&<>\"]/g, (c) => REPL[c] ?? c);\n}\n","/**\n * Output-safety helpers.\n *\n * Avodado documents are normally authored by trusted hands, but rendered output\n * is also shown in untrusted contexts — the playground renders documents from\n * shared URLs, and any hosted preview renders whatever a visitor pastes. So the\n * renderer treats author-supplied values (colours, link hrefs, prose HTML) as\n * untrusted and neutralises anything that could break out of its target context.\n *\n * These functions are pure and allocation-light; they run on every render.\n */\n\n/**\n * Matches a safe CSS colour value: hex (`#rgb`/`#rgba`/`#rrggbb`/`#rrggbbaa`),\n * `rgb()/rgba()`, `hsl()/hsla()`, or a bare CSS named colour. Anything with a\n * quote, semicolon, angle bracket, or `url(` is rejected — those are the\n * shapes an attacker uses to break out of a `fill=\"…\"` or `style=\"…\"` context.\n */\nconst SAFE_COLOR_RE =\n /^(#[0-9a-fA-F]{3,8}|rgba?\\([\\d.,\\s%]+\\)|hsla?\\([\\d.,\\s%]+\\)|[a-zA-Z]{1,24})$/;\n\n/**\n * Returns `value` if it is a safe CSS colour, otherwise `fallback`.\n *\n * Use this for any author-supplied colour that gets interpolated into an SVG\n * attribute (`fill`, `stroke`) or a `style` declaration.\n *\n * @param value - The candidate colour (any author string, or undefined).\n * @param fallback - The colour to use when `value` is missing or unsafe.\n */\nexport function safeColor(value: string | undefined, fallback: string): string {\n if (value === undefined) return fallback;\n const trimmed = value.trim();\n return SAFE_COLOR_RE.test(trimmed) ? trimmed : fallback;\n}\n\n/** URL schemes that can execute script or smuggle markup. */\nconst DANGEROUS_URL_RE = /^\\s*(javascript|data|vbscript):/i;\n\n/**\n * Returns `url` if its scheme is safe to put in an `href`/`src`, otherwise `#`.\n *\n * Relative URLs, fragments (`#id`), and the usual web schemes pass through;\n * `javascript:`, `data:`, and `vbscript:` are rejected.\n *\n * @param url - The candidate URL.\n */\nexport function safeUrl(url: string): string {\n return DANGEROUS_URL_RE.test(url) ? '#' : url;\n}\n","/**\n * Renders a prose segment to HTML via `marked`.\n *\n * Hardened for untrusted input (the renderer's output is shown in the\n * playground and hosted previews, which render documents from strangers):\n *\n * - Raw HTML is **not** passed through — `marked` v14 emits raw HTML by\n * default, which is an XSS vector. We decline the block `html` and inline\n * `tag` tokenizers so any literal `<tag>` falls through to text and is\n * entity-escaped. This also matches Avodado's house rule: express structure\n * through blocks, never raw HTML.\n * - Link / image hrefs with `javascript:`, `data:`, or `vbscript:` schemes are\n * rewritten to `#` (see {@link safeUrl}).\n *\n * Output is deterministic (no auto heading ids, no smartypants).\n */\n\nimport { Marked, type Tokens } from 'marked';\nimport { safeUrl } from './sanitize.js';\n\nconst marked = new Marked({ gfm: true, breaks: false });\n\nmarked.use({\n tokenizer: {\n // Decline raw HTML at both block and inline level; the text falls through\n // to the paragraph/text tokenizer, which escapes it.\n html(): undefined {\n return undefined;\n },\n tag(): undefined {\n return undefined;\n },\n },\n renderer: {\n link(token: Tokens.Link): string {\n const href = safeUrl(token.href);\n const title = token.title !== null && token.title !== undefined ? ` title=\"${token.title}\"` : '';\n const text = this.parser.parseInline(token.tokens);\n return `<a href=\"${href}\"${title}>${text}</a>`;\n },\n image(token: Tokens.Image): string {\n const href = safeUrl(token.href);\n const title = token.title !== null && token.title !== undefined ? ` title=\"${token.title}\"` : '';\n return `<img src=\"${href}\" alt=\"${token.text}\"${title}>`;\n },\n },\n});\n\n/**\n * Renders Markdown prose to an HTML string wrapped in `<div class=\"prose\">`.\n *\n * @param text - The Markdown source.\n * @returns The HTML output, wrapped in a `prose` div for styling scope.\n */\nexport function renderProse(text: string): string {\n const html = marked.parse(text, { async: false });\n return `<div class=\"prose\">${html}</div>`;\n}\n","/**\n * Meta is rendered as the document cover (not as a body block). The registry\n * entry for `meta` returns an empty string; {@link renderCover} produces the\n * cover from the {@link Document.meta} data.\n *\n * Class names match doc-studio: `.cover-bar`, `.cover-pad`, `.cover-meta`,\n * `.cover-title`, `.cover-sub`.\n */\n\nimport type { MetaData } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\n/** Renders the document cover (banner + meta line + title + optional subtitle). */\nexport function renderCover(meta: MetaData | undefined): string {\n const title = meta?.title ?? 'Untitled';\n const tag = meta?.tag ?? '';\n const subtitle = meta?.subtitle;\n const sub =\n subtitle !== undefined ? `<p class=\"cover-sub\">${escapeHtml(subtitle)}</p>` : '';\n return (\n `<div class=\"cover-bar\"></div>` +\n `<div class=\"cover-pad\">` +\n `<div class=\"cover-meta\"><span>DOCUMENT</span><span class=\"accent\">${escapeHtml(tag)}</span></div>` +\n `<h1 class=\"cover-title\">${escapeHtml(title)}</h1>` +\n sub +\n `</div>`\n );\n}\n\n/**\n * Block-registry entry for `meta`. Always returns empty: the cover is rendered\n * separately by {@link renderCover}, called from {@link renderDocument}.\n */\nexport function renderMetaBlock(): string {\n return '';\n}\n","/**\n * Wraps block content in doc-studio's \"diagram frame\" — a bordered card with\n * a header (tag pill + title + figure number) and optional description.\n *\n * Used by diagram-type blocks (sequence, erd, …) so the output matches\n * doc-studio.jsx's `DiagramFrame` component.\n */\n\nimport type { BlockType } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\ninterface FrameOptions {\n /** Tag pill text (e.g. `SEQUENCE`, `ER`, `POST`). */\n readonly tag: string;\n /** Optional CSS class added to the tag pill (e.g. `post`, `get`). */\n readonly tagClass?: string;\n /** Optional inline background color for the tag pill (used when no class). */\n readonly tagBg?: string;\n /** Title shown next to the tag (often `data.title`). Plain text. */\n readonly title?: string;\n /** Pre-rendered HTML for the title — wins over `title` if provided. */\n readonly titleHtml?: string;\n /** Optional figure number (e.g. `FIG 1.1`). */\n readonly fignum?: string;\n /** Optional description shown under the header. */\n readonly desc?: string;\n /** Optional pre-rendered HTML rendered AFTER the inner content (e.g. footers). */\n readonly footerHtml?: string;\n}\n\n/** Wraps the given inner HTML in a `.diagram` card. */\nexport function diagramFrame(opts: FrameOptions, inner: string): string {\n const tagClass = opts.tagClass !== undefined ? ` ${opts.tagClass}` : '';\n const tagStyle =\n opts.tagBg !== undefined && opts.tagClass === undefined\n ? ` style=\"background:${opts.tagBg}\"`\n : '';\n const titleHtml =\n opts.titleHtml !== undefined\n ? `<span class=\"diagram-title\">${opts.titleHtml}</span>`\n : opts.title !== undefined && opts.title.length > 0\n ? `<span class=\"diagram-title\">${escapeHtml(opts.title)}</span>`\n : '';\n const fignumHtml =\n opts.fignum !== undefined && opts.fignum.length > 0\n ? `<span class=\"diagram-fignum\">${escapeHtml(opts.fignum)}</span>`\n : '';\n const descHtml =\n opts.desc !== undefined && opts.desc.length > 0\n ? `<p class=\"diagram-desc\">${escapeHtml(opts.desc)}</p>`\n : '';\n const footerHtml = opts.footerHtml ?? '';\n return (\n `<div class=\"diagram\">` +\n `<div class=\"diagram-head\">` +\n `<span class=\"diagram-tag${tagClass}\"${tagStyle}>${escapeHtml(opts.tag)}</span>` +\n titleHtml +\n fignumHtml +\n `</div>` +\n descHtml +\n inner +\n footerHtml +\n `</div>`\n );\n}\n\n/**\n * Per-block-type label shown in `SECTION NN · LABEL`.\n *\n * Typed as `Record<BlockType, string>` so adding a new block type without a\n * label is a compile error — the same exhaustiveness guarantee the block\n * registry gives the renderers.\n */\nexport const SECTION_LABEL: Record<BlockType, string> = {\n meta: '',\n callout: 'Note',\n table: 'Comparison',\n sequence: 'Sequence',\n erd: 'Entity model',\n userstory: 'User story',\n timeline: 'Roadmap',\n kanban: 'Board',\n tracker: 'Tracker',\n prose: 'Overview',\n glossary: 'Glossary',\n proscons: 'Trade-offs',\n cvt: 'Before / after',\n stats: 'Metrics',\n code: 'Code',\n agenda: 'Agenda',\n tree: 'Hierarchy',\n pyramid: 'Pyramid',\n funnel: 'Funnel',\n flow: 'Flowchart',\n state: 'State machine',\n dfd: 'Data flow',\n journey: 'Journey',\n gantt: 'Schedule',\n graph: 'Graph',\n quadrant: 'Matrix',\n swimlane: 'Process',\n c4: 'C4 model',\n uml: 'Class model',\n mece: 'Issue tree',\n frontend: 'Component tree',\n cluster: 'Cluster',\n block: 'Architecture',\n infra: 'Deployment',\n event: 'Events',\n ddd: 'Context map',\n network: 'Security zones',\n felogic: 'Frontend logic',\n belogic: 'Backend logic',\n dag: 'DAG',\n wireframe: 'Mockup',\n};\n","/**\n * Renders a callout block — a tonal side-bar with title + body.\n *\n * Doc-studio variant: `tone` (note/tip/warn/danger) instead of the original\n * `kind`. Defaults to `note` if omitted. Title defaults to the tone's label.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\ntype Tone = 'note' | 'tip' | 'warn' | 'danger';\n\nconst DEFAULT_TITLE: Record<Tone, string> = {\n note: 'Note',\n tip: 'Tip',\n warn: 'Warning',\n danger: 'Danger',\n};\n\nexport function renderCallout(data: BlockDataMap['callout']): string {\n const tone: Tone = data.tone ?? 'note';\n const title = data.title ?? DEFAULT_TITLE[tone];\n const body = data.body ?? '';\n return (\n `<div class=\"callout ${tone}\">` +\n `<div class=\"callout-title\">${escapeHtml(title)}</div>` +\n `<div class=\"callout-body\">${escapeHtml(body)}</div>` +\n `</div>`\n );\n}\n","import type {Edge, EdgeLabelFactory, GraphOptions, NodeLabelFactory} from './types';\n\nconst DEFAULT_EDGE_NAME = \"\\x00\";\nconst GRAPH_NODE = \"\\x00\";\nconst EDGE_KEY_DELIM = \"\\x01\";\n\n// Implementation notes:\n//\n// * Node id query functions should return string ids for the nodes\n// * Edge id query functions should return an \"edgeObj\", edge object, that is\n// composed of enough information to uniquely identify an edge: {v, w, name}.\n// * Internally we use an \"edgeId\", a stringified form of the edgeObj, to\n// reference edges. This is because we need a performant way to look these\n// edges up and, object properties, which have string keys, are the closest\n// we're going to get to a performant hashtable in JavaScript.\n\nexport class Graph<GraphLabel = any, NodeLabel = any, EdgeLabel = any> {\n private _isDirected: boolean = true;\n private _isMultigraph: boolean = false;\n private _isCompound: boolean = false;\n\n // Label for the graph itself\n private _label!: GraphLabel;\n // v -> label\n private _nodes: Record<string, NodeLabel> = {};\n // v -> edgeObj\n private _in: Record<string, Record<string, Edge>> = {};\n // u -> v -> Number\n private _preds: Record<string, Record<string, number>> = {};\n // v -> edgeObj\n private _out: Record<string, Record<string, Edge>> = {};\n // v -> w -> Number\n private _sucs: Record<string, Record<string, number>> = {};\n // e -> edgeObj\n private _edgeObjs: Record<string, Edge> = {};\n // e -> label\n private _edgeLabels: Record<string, EdgeLabel> = {};\n /* Number of nodes in the graph. Should only be changed by the implementation. */\n private _nodeCount: number = 0;\n /* Number of edges in the graph. Should only be changed by the implementation. */\n private _edgeCount: number = 0;\n private _parent?: Record<string, string>;\n private _children?: Record<string, Record<string, boolean>>;\n\n constructor(opts?: GraphOptions) {\n if (opts) {\n this._isDirected = \"directed\" in opts ? opts.directed! : true;\n this._isMultigraph = \"multigraph\" in opts ? opts.multigraph! : false;\n this._isCompound = \"compound\" in opts ? opts.compound! : false;\n }\n\n if (this._isCompound) {\n // v -> parent\n this._parent = {};\n\n // v -> children\n this._children = {};\n this._children[GRAPH_NODE] = {};\n }\n }\n\n /**\n * Whether graph was created with 'directed' flag set to true or not.\n *\n * @returns whether the graph edges have an orientation.\n */\n isDirected(): boolean {\n return this._isDirected;\n }\n\n /**\n * Whether graph was created with 'multigraph' flag set to true or not.\n *\n * @returns whether the pair of nodes of the graph can have multiple edges.\n */\n isMultigraph(): boolean {\n return this._isMultigraph;\n }\n\n /* === Graph functions ========= */\n\n /**\n * Whether graph was created with 'compound' flag set to true or not.\n *\n * @returns whether a node of the graph can have subnodes.\n */\n isCompound(): boolean {\n return this._isCompound;\n }\n\n /**\n * Sets the label of the graph.\n *\n * @param label - label value.\n * @returns the graph, allowing this to be chained with other functions.\n */\n setGraph(label: GraphLabel): this {\n this._label = label;\n return this;\n }\n\n /**\n * Gets the graph label.\n *\n * @returns currently assigned label for the graph or undefined if no label assigned.\n */\n graph(): GraphLabel {\n // TODO: This should return undefined if no label was assigned, but that would be a breaking change.\n return this._label;\n }\n\n /**\n * Sets the default node label. This label will be assigned as default label\n * in case if no label was specified while setting a node.\n * Complexity: O(1).\n *\n * @param labelOrFn - default node label or label factory function.\n * @returns the graph, allowing this to be chained with other functions.\n */\n setDefaultNodeLabel(labelOrFn: NodeLabel | NodeLabelFactory<NodeLabel>): this {\n if (typeof labelOrFn !== 'function') {\n this._defaultNodeLabelFn = () => labelOrFn;\n } else {\n this._defaultNodeLabelFn = labelOrFn as NodeLabelFactory<NodeLabel>;\n }\n\n return this;\n }\n\n /**\n * Gets the number of nodes in the graph.\n * Complexity: O(1).\n *\n * @returns nodes count.\n */\n nodeCount(): number {\n return this._nodeCount;\n }\n\n\n /* === Node functions ========== */\n\n /**\n * Gets all nodes of the graph. Note, the in case of compound graph subnodes are\n * not included in list.\n * Complexity: O(1).\n *\n * @returns list of graph nodes.\n */\n nodes(): string[] {\n return Object.keys(this._nodes);\n }\n\n /**\n * Gets list of nodes without in-edges.\n * Complexity: O(|V|).\n *\n * @returns the graph source nodes.\n */\n sources(): string[] {\n return this.nodes().filter(v => Object.keys(this._in[v]!).length === 0);\n }\n\n /**\n * Gets list of nodes without out-edges.\n * Complexity: O(|V|).\n *\n * @returns the graph sink nodes.\n */\n sinks(): string[] {\n return this.nodes().filter(v => Object.keys(this._out[v]!).length === 0);\n }\n\n /**\n * Invokes setNode method for each node in names list.\n * Complexity: O(|names|).\n *\n * @param names - list of nodes names to be set.\n * @param label - value to set for each node in list.\n * @returns the graph, allowing this to be chained with other functions.\n */\n setNodes(names: string[], label?: NodeLabel): this {\n names.forEach((v) => {\n if (label !== undefined) {\n this.setNode(v, label);\n } else {\n this.setNode(v);\n }\n });\n return this;\n }\n\n /**\n * Creates or updates the value for the node v in the graph. If label is supplied\n * it is set as the value for the node. If label is not supplied and the node was\n * created by this call then the default node label will be assigned.\n * Complexity: O(1).\n *\n * @param name - node name.\n * @param label - value to set for node.\n * @returns the graph, allowing this to be chained with other functions.\n */\n setNode(name: string, label?: NodeLabel): this {\n if (name in this._nodes) {\n if (arguments.length > 1) {\n this._nodes[name] = label!;\n }\n return this;\n }\n\n this._nodes[name] = arguments.length > 1 ? label! : this._defaultNodeLabelFn(name);\n if (this._isCompound) {\n this._parent![name] = GRAPH_NODE;\n this._children![name] = {};\n this._children![GRAPH_NODE]![name] = true;\n }\n this._in[name] = {};\n this._preds[name] = {};\n this._out[name] = {};\n this._sucs[name] = {};\n ++this._nodeCount;\n return this;\n }\n\n /**\n * Gets the label of node with specified name.\n * Complexity: O(|V|).\n *\n * @param name - node name.\n * @returns label value of the node.\n */\n node(name: string): NodeLabel {\n // TODO: This should return undefined if the node doesn't exist, but that would be a breaking change.\n return this._nodes[name]!;\n }\n\n /**\n * Detects whether graph has a node with specified name or not.\n *\n * @param name - name of the node.\n * @returns true if graph has node with specified name, false - otherwise.\n */\n hasNode(name: string): boolean {\n return name in this._nodes;\n }\n\n /**\n * Remove the node with the name from the graph or do nothing if the node is not in\n * the graph. If the node was removed this function also removes any incident\n * edges.\n * Complexity: O(1).\n *\n * @param name - name of the node.\n * @returns the graph, allowing this to be chained with other functions.\n */\n removeNode(name: string): this {\n if (name in this._nodes) {\n const removeEdge = (e: string) => this.removeEdge(this._edgeObjs[e]!);\n delete this._nodes[name];\n if (this._isCompound) {\n this._removeFromParentsChildList(name);\n delete this._parent![name];\n this.children(name).forEach((child) => {\n this.setParent(child);\n });\n delete this._children![name];\n }\n Object.keys(this._in[name]!).forEach(removeEdge);\n delete this._in[name];\n delete this._preds[name];\n Object.keys(this._out[name]!).forEach(removeEdge);\n delete this._out[name];\n delete this._sucs[name];\n --this._nodeCount;\n }\n return this;\n }\n\n /**\n * Sets node parent for node v if it is defined, or removes the\n * parent for v if p is undefined. Method throws an exception in case of\n * invoking it in context of noncompound graph.\n * Average-case complexity: O(1).\n *\n * @param v - node to be child for p.\n * @param parent - node to be parent for v.\n * @returns the graph, allowing this to be chained with other functions.\n */\n setParent(v: string, parent?: string): this {\n if (!this._isCompound) {\n throw new Error(\"Cannot set parent in a non-compound graph\");\n }\n\n if (parent === undefined) {\n parent = GRAPH_NODE;\n } else {\n // Coerce parent to string\n parent += \"\";\n for (let ancestor: string | undefined | void = parent; ancestor !== undefined; ancestor = this.parent(ancestor)) {\n if (ancestor === v) {\n throw new Error(\"Setting \" + parent + \" as parent of \" + v +\n \" would create a cycle\");\n }\n }\n\n this.setNode(parent);\n }\n\n this.setNode(v);\n this._removeFromParentsChildList(v);\n this._parent![v] = parent;\n this._children![parent]![v] = true;\n return this;\n }\n\n /**\n * Gets parent node for node v.\n * Complexity: O(1).\n *\n * @param v - node to get parent of.\n * @returns parent node name or void if v has no parent.\n */\n parent(v: string): string | void {\n if (this._isCompound) {\n const parent = this._parent![v];\n if (parent !== GRAPH_NODE) {\n return parent;\n }\n }\n }\n\n /**\n * Gets list of direct children of node v.\n * Complexity: O(1).\n *\n * @param v - node to get children of.\n * @returns children nodes names list.\n */\n children(v: string = GRAPH_NODE): string[] {\n if (this._isCompound) {\n const children = this._children![v];\n if (children) {\n return Object.keys(children);\n }\n } else if (v === GRAPH_NODE) {\n return this.nodes();\n } else if (this.hasNode(v)) {\n return [];\n }\n return [];\n }\n\n /**\n * Return all nodes that are predecessors of the specified node or undefined if node v is not in\n * the graph. Behavior is undefined for undirected graphs - use neighbors instead.\n * Complexity: O(|V|).\n *\n * @param v - node identifier.\n * @returns node identifiers list or undefined if v is not in the graph.\n */\n predecessors(v: string): void | string[] {\n const predsV = this._preds[v];\n if (predsV) {\n return Object.keys(predsV);\n }\n }\n\n /**\n * Return all nodes that are successors of the specified node or undefined if node v is not in\n * the graph. Behavior is undefined for undirected graphs - use neighbors instead.\n * Complexity: O(|V|).\n *\n * @param v - node identifier.\n * @returns node identifiers list or undefined if v is not in the graph.\n */\n successors(v: string): void | string[] {\n const sucsV = this._sucs[v];\n if (sucsV) {\n return Object.keys(sucsV);\n }\n }\n\n /**\n * Return all nodes that are predecessors or successors of the specified node or undefined if\n * node v is not in the graph.\n * Complexity: O(|V|).\n *\n * @param v - node identifier.\n * @returns node identifiers list or undefined if v is not in the graph.\n */\n neighbors(v: string): void | string[] {\n const preds = this.predecessors(v);\n if (preds) {\n const union = new Set(preds);\n for (const succ of this.successors(v)!) {\n union.add(succ);\n }\n\n return Array.from(union.values());\n }\n }\n\n isLeaf(v: string): boolean {\n let neighbors: string[] | void;\n if (this.isDirected()) {\n neighbors = this.successors(v);\n } else {\n neighbors = this.neighbors(v);\n }\n return neighbors!.length === 0;\n }\n\n /**\n * Creates new graph with nodes filtered via filter. Edges incident to rejected node\n * are also removed. In case of compound graph, if parent is rejected by filter,\n * than all its children are rejected too.\n * Average-case complexity: O(|E|+|V|).\n *\n * @param filter - filtration function detecting whether the node should stay or not.\n * @returns new graph made from current and nodes filtered.\n */\n filterNodes(filter: (v: string) => boolean): this {\n const copy = new (this.constructor as typeof Graph<GraphLabel, NodeLabel, EdgeLabel>)({\n directed: this._isDirected,\n multigraph: this._isMultigraph,\n compound: this._isCompound\n });\n\n copy.setGraph(this.graph()!);\n\n Object.entries(this._nodes).forEach(([v, value]) => {\n if (filter(v)) {\n copy.setNode(v, value);\n }\n });\n\n Object.values(this._edgeObjs).forEach((e) => {\n if (copy.hasNode(e.v) && copy.hasNode(e.w)) {\n copy.setEdge(e, this.edge(e));\n }\n });\n\n const parents: Record<string, string | undefined> = {};\n const findParent = (v: string): string | undefined => {\n const parent = this.parent(v);\n if (!parent || copy.hasNode(parent)) {\n parents[v] = parent ?? undefined;\n return parent ?? undefined;\n } else if (parent in parents) {\n return parents[parent];\n } else {\n return findParent(parent);\n }\n };\n\n if (this._isCompound) {\n copy.nodes().forEach(v => copy.setParent(v, findParent(v)));\n }\n\n return copy as this;\n }\n\n /**\n * Sets the default edge label. This label will be assigned as default label\n * in case if no label was specified while setting an edge.\n * Complexity: O(1).\n *\n * @param labelOrFn - default edge label or label factory function.\n * @returns the graph, allowing this to be chained with other functions.\n */\n setDefaultEdgeLabel(labelOrFn: EdgeLabel | EdgeLabelFactory<EdgeLabel>): this {\n if (typeof labelOrFn !== 'function') {\n this._defaultEdgeLabelFn = () => labelOrFn;\n } else {\n this._defaultEdgeLabelFn = labelOrFn as EdgeLabelFactory<EdgeLabel>;\n }\n\n return this;\n }\n\n /**\n * Gets the number of edges in the graph.\n * Complexity: O(1).\n *\n * @returns edges count.\n */\n edgeCount(): number {\n return this._edgeCount;\n }\n\n /**\n * Gets edges of the graph. In case of compound graph subgraphs are not considered.\n * Complexity: O(|E|).\n *\n * @returns graph edges list.\n */\n edges(): Edge[] {\n return Object.values(this._edgeObjs);\n }\n\n /* === Edge functions ========== */\n\n /**\n * Establish an edges path over the nodes in nodes list. If some edge is already\n * exists, it will update its label, otherwise it will create an edge between pair\n * of nodes with label provided or default label if no label provided.\n * Complexity: O(|nodes|).\n *\n * @param nodes - list of nodes to be connected in series.\n * @param label - value to set for each edge between pairs of nodes.\n * @returns the graph, allowing this to be chained with other functions.\n */\n setPath(nodes: string[], label?: EdgeLabel): this {\n nodes.reduce((v, w) => {\n if (label !== undefined) {\n this.setEdge(v, w, label);\n } else {\n this.setEdge(v, w);\n }\n return w;\n });\n return this;\n }\n\n /**\n * Creates or updates the label for the edge (v, w) with the optionally supplied\n * name. If label is supplied it is set as the value for the edge. If label is not\n * supplied and the edge was created by this call then the default edge label will\n * be assigned. The name parameter is only useful with multigraphs.\n * Complexity: O(1).\n *\n * @param v - edge source node.\n * @param w - edge sink node.\n * @param label - value to associate with the edge.\n * @param name - unique name of the edge in order to identify it in multigraph.\n * @returns the graph, allowing this to be chained with other functions.\n */\n setEdge(v: string, w: string, label?: EdgeLabel, name?: string): this;\n\n /**\n * Creates or updates the label for the specified edge. If label is supplied it is\n * set as the value for the edge. If label is not supplied and the edge was created\n * by this call then the default edge label will be assigned. The name parameter is\n * only useful with multigraphs.\n * Complexity: O(1).\n *\n * @param edge - edge descriptor.\n * @param label - value to associate with the edge.\n * @returns the graph, allowing this to be chained with other functions.\n */\n setEdge(edge: Edge, label?: EdgeLabel): this;\n\n setEdge(v: string | Edge, w?: string | EdgeLabel, value?: EdgeLabel, name?: string): this {\n let vStr: string;\n let wStr: string;\n let nameStr: string | undefined;\n let edgeValue: EdgeLabel | undefined;\n let valueSpecified = false;\n\n if (typeof v === \"object\" && v !== null && \"v\" in v) {\n vStr = v.v;\n wStr = v.w;\n nameStr = v.name;\n if (arguments.length === 2) {\n edgeValue = w as EdgeLabel;\n valueSpecified = true;\n }\n } else {\n vStr = v;\n wStr = w as string;\n nameStr = name;\n if (arguments.length > 2) {\n edgeValue = value;\n valueSpecified = true;\n }\n }\n\n vStr = \"\" + vStr;\n wStr = \"\" + wStr;\n if (nameStr !== undefined) {\n nameStr = \"\" + nameStr;\n }\n\n const e = edgeArgsToId(this._isDirected, vStr, wStr, nameStr);\n if (e in this._edgeLabels) {\n if (valueSpecified) {\n this._edgeLabels[e] = edgeValue!;\n }\n return this;\n }\n\n if (nameStr !== undefined && !this._isMultigraph) {\n throw new Error(\"Cannot set a named edge when isMultigraph = false\");\n }\n\n // It didn't exist, so we need to create it.\n // First ensure the nodes exist.\n this.setNode(vStr);\n this.setNode(wStr);\n\n this._edgeLabels[e] = valueSpecified ? edgeValue! : this._defaultEdgeLabelFn(vStr, wStr, nameStr);\n\n // Ensure we add undirected edges in a consistent way.\n const edgeObj = edgeArgsToObj(this._isDirected, vStr, wStr, nameStr);\n\n vStr = edgeObj.v;\n wStr = edgeObj.w;\n\n Object.freeze(edgeObj);\n this._edgeObjs[e] = edgeObj;\n incrementOrInitEntry(this._preds[wStr]!, vStr);\n incrementOrInitEntry(this._sucs[vStr]!, wStr);\n this._in[wStr]![e] = edgeObj;\n this._out[vStr]![e] = edgeObj;\n this._edgeCount++;\n return this;\n }\n\n /**\n * Gets the label for the specified edge.\n * Complexity: O(1).\n *\n * @param v - edge source node.\n * @param w - edge sink node.\n * @param name - name of the edge (actual for multigraph).\n * @returns value associated with specified edge.\n */\n edge(v: string, w: string, name?: string): EdgeLabel;\n\n /**\n * Gets the label for the specified edge.\n * Complexity: O(1).\n *\n * @param edge - edge descriptor.\n * @returns value associated with specified edge.\n */\n edge(edge: Edge): EdgeLabel;\n\n edge(v: string | Edge, w?: string, name?: string): EdgeLabel {\n // TODO: This should return undefined if the edge doesn't exist, but that would be a breaking change.\n const e = (arguments.length === 1\n ? edgeObjToId(this._isDirected, v as Edge)\n : edgeArgsToId(this._isDirected, v as string, w!, name));\n return this._edgeLabels[e]!;\n }\n\n /**\n * Gets the label for the specified edge and converts it to an object.\n * Complexity: O(1).\n *\n * @param v - edge source node.\n * @param w - edge sink node.\n * @param name - name of the edge (actual for multigraph).\n * @returns value associated with specified edge.\n */\n edgeAsObj(v: string, w: string, name?: string): { label: EdgeLabel };\n\n /**\n * Gets the label for the specified edge and converts it to an object.\n * Complexity: O(1).\n *\n * @param edge - edge descriptor.\n * @returns value associated with specified edge.\n */\n edgeAsObj(edge: Edge): { label: EdgeLabel };\n\n edgeAsObj(v: string | Edge, w?: string, name?: string): { label: EdgeLabel } {\n const edgeLabel = arguments.length === 1\n ? this.edge(v as Edge)\n : this.edge(v as string, w!, name);\n\n if (typeof edgeLabel !== \"object\") {\n return {label: edgeLabel as EdgeLabel};\n }\n\n return edgeLabel as { label: EdgeLabel };\n }\n\n /**\n * Detects whether the graph contains specified edge or not. No subgraphs are considered.\n * Complexity: O(1).\n *\n * @param v - edge source node.\n * @param w - edge sink node.\n * @param name - name of the edge (actual for multigraph).\n * @returns whether the graph contains the specified edge or not.\n */\n hasEdge(v: string, w: string, name?: string): boolean;\n\n /**\n * Detects whether the graph contains specified edge or not. No subgraphs are considered.\n * Complexity: O(1).\n *\n * @param edge - edge descriptor.\n * @returns whether the graph contains the specified edge or not.\n */\n hasEdge(edge: Edge): boolean;\n\n hasEdge(v: string | Edge, w?: string, name?: string): boolean {\n const e = (arguments.length === 1\n ? edgeObjToId(this._isDirected, v as Edge)\n : edgeArgsToId(this._isDirected, v as string, w!, name));\n return e in this._edgeLabels;\n }\n\n /**\n * Removes the specified edge from the graph. No subgraphs are considered.\n * Complexity: O(1).\n *\n * @param v - edge source node.\n * @param w - edge sink node.\n * @param name - name of the edge (actual for multigraph).\n * @returns the graph, allowing this to be chained with other functions.\n */\n removeEdge(v: string, w: string, name?: string): this;\n\n /**\n * Removes the specified edge from the graph. No subgraphs are considered.\n * Complexity: O(1).\n *\n * @param edge - edge descriptor.\n * @returns the graph, allowing this to be chained with other functions.\n */\n removeEdge(edge: Edge): this;\n\n removeEdge(v: string | Edge, w?: string, name?: string): this {\n const e = (arguments.length === 1\n ? edgeObjToId(this._isDirected, v as Edge)\n : edgeArgsToId(this._isDirected, v as string, w!, name));\n const edge = this._edgeObjs[e];\n if (edge) {\n const vStr = edge.v;\n const wStr = edge.w;\n delete this._edgeLabels[e];\n delete this._edgeObjs[e];\n decrementOrRemoveEntry(this._preds[wStr]!, vStr);\n decrementOrRemoveEntry(this._sucs[vStr]!, wStr);\n delete this._in[wStr]![e];\n delete this._out[vStr]![e];\n this._edgeCount--;\n }\n return this;\n }\n\n /**\n * Return all edges that point to the node v. Optionally filters those edges down to just those\n * coming from node u. Behavior is void for undirected graphs - use nodeEdges instead.\n * Complexity: O(|E|).\n *\n * @param v - edge sink node.\n * @param w - edge source node.\n * @returns edges descriptors list if v is in the graph, or void otherwise.\n */\n inEdges(v: string, w?: string): void | Edge[] {\n if (this.isDirected()) {\n return this.filterEdges(this._in[v], v, w);\n }\n return this.nodeEdges(v, w);\n }\n\n /**\n * Return all edges that are pointed at by node v. Optionally filters those edges down to just\n * those point to w. Behavior is void for undirected graphs - use nodeEdges instead.\n * Complexity: O(|E|).\n *\n * @param v - edge source node.\n * @param w - edge sink node.\n * @returns edges descriptors list if v is in the graph, or void otherwise.\n */\n outEdges(v: string, w?: string): void | Edge[] {\n if (this.isDirected()) {\n return this.filterEdges(this._out[v], v, w);\n }\n return this.nodeEdges(v, w);\n }\n\n /**\n * Returns all edges to or from node v regardless of direction. Optionally filters those edges\n * down to just those between nodes v and w regardless of direction.\n * Complexity: O(|E|).\n *\n * @param v - edge adjacent node.\n * @param w - edge adjacent node.\n * @returns edges descriptors list if v is in the graph, or void otherwise.\n */\n nodeEdges(v: string, w?: string): void | Edge[] {\n if (v in this._nodes) {\n return this.filterEdges({...this._in[v]!, ...this._out[v]!}, v, w);\n }\n }\n\n // Defaults to be set when creating a new node\n private _defaultNodeLabelFn: NodeLabelFactory<NodeLabel> = () => undefined as NodeLabel;\n\n // Defaults to be set when creating a new edge\n private _defaultEdgeLabelFn: EdgeLabelFactory<EdgeLabel> = () => undefined as EdgeLabel;\n\n private _removeFromParentsChildList(v: string): void {\n delete this._children![this._parent![v]!]![v];\n }\n\n private filterEdges(setV: Record<string, Edge> | undefined, localEdge: string, remoteEdge?: string): Edge[] | undefined {\n if (!setV) {\n return;\n }\n const edges = Object.values(setV);\n if (!remoteEdge) {\n return edges;\n }\n return edges.filter((edge) => {\n return edge.v === localEdge && edge.w === remoteEdge\n || edge.v === remoteEdge && edge.w === localEdge;\n });\n }\n}\n\n\nfunction incrementOrInitEntry(map: Record<string, number>, k: string): void {\n if (map[k]) {\n map[k]++;\n } else {\n map[k] = 1;\n }\n}\n\nfunction decrementOrRemoveEntry(map: Record<string, number>, k: string): void {\n if (map[k] !== undefined && !--map[k]) {\n delete map[k];\n }\n}\n\nfunction edgeArgsToId(isDirected: boolean, v_: string, w_: string, name?: string): string {\n let v = \"\" + v_;\n let w = \"\" + w_;\n if (!isDirected && v > w) {\n const tmp = v;\n v = w;\n w = tmp;\n }\n return v + EDGE_KEY_DELIM + w + EDGE_KEY_DELIM +\n (name === undefined ? DEFAULT_EDGE_NAME : name);\n}\n\nfunction edgeArgsToObj(isDirected: boolean, v_: string, w_: string, name?: string): Edge {\n let v = \"\" + v_;\n let w = \"\" + w_;\n if (!isDirected && v > w) {\n const tmp = v;\n v = w;\n w = tmp;\n }\n const edgeObj: Edge = {v: v, w: w};\n if (name) {\n edgeObj.name = name;\n }\n return edgeObj;\n}\n\nfunction edgeObjToId(isDirected: boolean, edgeObj: Edge): string {\n return edgeArgsToId(isDirected, edgeObj.v, edgeObj.w, edgeObj.name);\n}\n","export const version = '4.0.1';\n","import {Graph} from './graph';\nimport type {GraphOptions} from './types';\n\ninterface JsonGraph {\n options: GraphOptions;\n nodes: JsonNode[];\n edges: JsonEdge[];\n value?: unknown;\n}\n\ninterface JsonNode {\n v: string;\n value?: unknown;\n parent?: string;\n}\n\ninterface JsonEdge {\n v: string;\n w: string;\n name?: string;\n value?: unknown;\n}\n\n/**\n * Creates a JSON representation of the graph that can be serialized to a string with\n * JSON.stringify. The graph can later be restored using json.read.\n *\n * @param graph - target to create JSON representation of.\n * @returns JSON serializable graph representation\n */\nexport function write(graph: Graph): JsonGraph {\n const json: JsonGraph = {\n options: {\n directed: graph.isDirected(),\n multigraph: graph.isMultigraph(),\n compound: graph.isCompound()\n },\n nodes: writeNodes(graph),\n edges: writeEdges(graph)\n };\n\n const graphLabel = graph.graph();\n if (graphLabel !== undefined) {\n json.value = structuredClone(graphLabel);\n }\n\n return json;\n}\n\nfunction writeNodes(g: Graph): JsonNode[] {\n return g.nodes().map(v => {\n const nodeValue = g.node(v);\n const parent = g.parent(v);\n const node: JsonNode = {v};\n\n if (nodeValue !== undefined) {\n node.value = nodeValue;\n }\n if (parent !== undefined) {\n node.parent = parent;\n }\n\n return node;\n });\n}\n\nfunction writeEdges(g: Graph): JsonEdge[] {\n return g.edges().map(e => {\n const edgeValue = g.edge(e);\n const edge: JsonEdge = {v: e.v, w: e.w};\n\n if (e.name !== undefined) {\n edge.name = e.name;\n }\n if (edgeValue !== undefined) {\n edge.value = edgeValue;\n }\n\n return edge;\n });\n}\n\n/**\n * Takes JSON as input and returns the graph representation.\n *\n * @param json - JSON serializable graph representation\n * @returns graph constructed according to specified representation\n *\n * @example\n * var g2 = graphlib.json.read(JSON.parse(str));\n * g2.nodes();\n * // ['a', 'b']\n * g2.edges()\n * // [ { v: 'a', w: 'b' } ]\n */\nexport function read<GraphLabel = any, NodeLabel = any, EdgeLabel = any>(\n json: JsonGraph\n): Graph<GraphLabel, NodeLabel, EdgeLabel> {\n const g = new Graph<GraphLabel, NodeLabel, EdgeLabel>(json.options);\n\n if (json.value !== undefined) {\n g.setGraph(json.value as GraphLabel);\n }\n\n json.nodes.forEach(entry => {\n g.setNode(entry.v, entry.value as NodeLabel);\n if (entry.parent) {\n g.setParent(entry.v, entry.parent);\n }\n });\n\n json.edges.forEach(entry => {\n g.setEdge({v: entry.v, w: entry.w, name: entry.name}, entry.value as EdgeLabel);\n });\n\n return g;\n}\n","export {bellmanFord} from './bellman-ford';\nexport {components} from './components';\nexport {dijkstra} from './dijkstra';\nexport {dijkstraAll} from './dijkstra-all';\nexport {findCycles} from './find-cycles';\nexport {floydWarshall} from './floyd-warshall';\nexport {isAcyclic} from './is-acyclic';\nexport {postorder} from './postorder';\nexport {preorder} from './preorder';\nexport {prim} from './prim';\nexport {shortestPaths} from './shortest-paths';\nexport {tarjan} from './tarjan';\nexport {topsort, CycleException} from './topsort';\n","import {Graph} from '../graph';\nimport type {Edge, EdgeFunction, Path, WeightFunction} from '../types';\n\nconst DEFAULT_WEIGHT_FUNC: WeightFunction = () => 1;\n\nexport function bellmanFord(\n g: Graph,\n source: string,\n weightFn?: WeightFunction,\n edgeFn?: EdgeFunction\n): Record<string, Path> {\n return runBellmanFord(\n g,\n String(source),\n weightFn || DEFAULT_WEIGHT_FUNC,\n edgeFn || function (v) {\n return g.outEdges(v)!;\n }\n );\n}\n\nfunction runBellmanFord(\n g: Graph,\n source: string,\n weightFn: WeightFunction,\n edgeFn: EdgeFunction\n): Record<string, Path> {\n const results: Record<string, Path> = {};\n let didADistanceUpgrade: boolean;\n let iterations = 0;\n const nodes = g.nodes();\n\n const relaxEdge = function (edge: Edge): void {\n const edgeWeight = weightFn(edge);\n if (results[edge.v]!.distance + edgeWeight < results[edge.w]!.distance) {\n results[edge.w] = {\n distance: results[edge.v]!.distance + edgeWeight,\n predecessor: edge.v\n };\n didADistanceUpgrade = true;\n }\n };\n\n const relaxAllEdges = function (): void {\n nodes.forEach(function (vertex) {\n edgeFn(vertex).forEach(function (edge) {\n // If the vertex on which the edgeFun in called is\n // the edge.w, then we treat the edge as if it was reversed\n const inVertex = edge.v === vertex ? edge.v : edge.w;\n const outVertex = inVertex === edge.v ? edge.w : edge.v;\n relaxEdge({v: inVertex, w: outVertex});\n });\n });\n };\n\n // Initialization\n nodes.forEach(function (v) {\n const distance = v === source ? 0 : Number.POSITIVE_INFINITY;\n results[v] = {distance: distance, predecessor: ''};\n });\n\n const numberOfNodes = nodes.length;\n\n // Relax all edges in |V|-1 iterations\n for (let i = 1; i < numberOfNodes; i++) {\n didADistanceUpgrade = false;\n iterations++;\n relaxAllEdges();\n if (!didADistanceUpgrade) {\n // Ιf no update was made in an iteration, Bellman-Ford has finished\n break;\n }\n }\n\n // Detect if the graph contains a negative weight cycle\n if (iterations === numberOfNodes - 1) {\n didADistanceUpgrade = false;\n relaxAllEdges();\n if (didADistanceUpgrade) {\n throw new Error(\"The graph contains a negative weight cycle\");\n }\n }\n\n return results;\n}\n","import {Graph} from '../graph';\n\n/**\n * Finds all connected components in a graph and returns an array of these components.\n * Each component is itself an array that contains the ids of nodes in the component.\n * Complexity: O(|V|).\n *\n * @param graph - graph to find components in.\n * @returns array of nodes list representing components\n */\nexport function components(graph: Graph): string[][] {\n const visited: Record<string, boolean> = {};\n const cmpts: string[][] = [];\n let cmpt: string[];\n\n function dfs(v: string): void {\n if (v in visited) return;\n visited[v] = true;\n cmpt.push(v);\n graph.successors(v)!.forEach(dfs);\n graph.predecessors(v)!.forEach(dfs);\n }\n\n graph.nodes().forEach(function (v) {\n cmpt = [];\n dfs(v);\n if (cmpt.length) {\n cmpts.push(cmpt);\n }\n });\n\n return cmpts;\n}\n","/**\n * A min-priority queue data structure. This algorithm is derived from Cormen,\n * et al., \"Introduction to Algorithms\". The basic idea of a min-priority\n * queue is that you can efficiently (in O(1) time) get the smallest key in\n * the queue. Adding and removing elements takes O(log n) time. A key can\n * have its priority decreased in O(log n) time.\n */\n\ninterface PriorityQueueEntry {\n key: string;\n priority: number;\n}\n\nexport class PriorityQueue {\n private _arr: PriorityQueueEntry[] = [];\n private _keyIndices: Record<string, number> = {};\n\n /**\n * Returns the number of elements in the queue. Takes `O(1)` time.\n */\n size(): number {\n return this._arr.length;\n }\n\n /**\n * Returns the keys that are in the queue. Takes `O(n)` time.\n */\n keys(): string[] {\n return this._arr.map(x => x.key);\n }\n\n /**\n * Returns `true` if **key** is in the queue and `false` if not.\n */\n has(key: string): boolean {\n return key in this._keyIndices;\n }\n\n /**\n * Returns the priority for **key**. If **key** is not present in the queue\n * then this function returns `undefined`. Takes `O(1)` time.\n */\n priority(key: string): number | undefined {\n const index = this._keyIndices[key];\n if (index !== undefined) {\n return this._arr[index]!.priority;\n }\n return undefined;\n }\n\n /**\n * Returns the key for the minimum element in this queue. If the queue is\n * empty this function throws an Error. Takes `O(1)` time.\n */\n min(): string {\n if (this.size() === 0) {\n throw new Error(\"Queue underflow\");\n }\n return this._arr[0]!.key;\n }\n\n /**\n * Inserts a new key into the priority queue. If the key already exists in\n * the queue this function returns `false`; otherwise it will return `true`.\n * Takes `O(n)` time.\n */\n add(key: string, priority: number): boolean {\n const keyIndices = this._keyIndices;\n const keyStr = String(key);\n\n if (!(keyStr in keyIndices)) {\n const arr = this._arr;\n const index = arr.length;\n keyIndices[keyStr] = index;\n arr.push({key: keyStr, priority});\n this._decrease(index);\n return true;\n }\n return false;\n }\n\n /**\n * Removes and returns the smallest key in the queue. Takes `O(log n)` time.\n */\n removeMin(): string {\n this._swap(0, this._arr.length - 1);\n const min = this._arr.pop()!;\n delete this._keyIndices[min.key];\n this._heapify(0);\n return min.key;\n }\n\n /**\n * Decreases the priority for **key** to **priority**. If the new priority is\n * greater than the previous priority, this function will throw an Error.\n */\n decrease(key: string, priority: number): void {\n const index = this._keyIndices[key];\n if (index === undefined) {\n throw new Error(`Key not found: ${key}`);\n }\n\n const currentPriority = this._arr[index]!.priority;\n if (priority > currentPriority) {\n throw new Error(\n `New priority is greater than current priority. Key: ${key} Old: ${currentPriority} New: ${priority}`\n );\n }\n this._arr[index]!.priority = priority;\n this._decrease(index);\n }\n\n private _heapify(i: number): void {\n const arr = this._arr;\n const l = 2 * i;\n const r = l + 1;\n let largest = i;\n\n if (l < arr.length) {\n largest = arr[l]!.priority < arr[largest]!.priority ? l : largest;\n if (r < arr.length) {\n largest = arr[r]!.priority < arr[largest]!.priority ? r : largest;\n }\n if (largest !== i) {\n this._swap(i, largest);\n this._heapify(largest);\n }\n }\n }\n\n private _decrease(index: number): void {\n const arr = this._arr;\n const priority = arr[index]!.priority;\n let parent: number;\n\n while (index !== 0) {\n parent = index >> 1;\n if (arr[parent]!.priority < priority) {\n break;\n }\n this._swap(index, parent);\n index = parent;\n }\n }\n\n private _swap(i: number, j: number): void {\n const arr = this._arr;\n const keyIndices = this._keyIndices;\n const origArrI = arr[i]!;\n const origArrJ = arr[j]!;\n\n arr[i] = origArrJ;\n arr[j] = origArrI;\n keyIndices[origArrJ.key] = i;\n keyIndices[origArrI.key] = j;\n }\n}\n","import {Graph} from '../graph';\nimport {PriorityQueue} from '../data/priority-queue';\nimport type {Edge, EdgeFunction, Path, WeightFunction} from '../types';\n\nconst DEFAULT_WEIGHT_FUNC: WeightFunction = () => 1;\n\n/**\n * This function is an implementation of Dijkstra's algorithm which finds the shortest\n * path from source to all other nodes in graph. This function returns a map of\n * v -> { distance, predecessor }. The distance property holds the sum of the weights\n * from source to v along the shortest path or Number.POSITIVE_INFINITY if there is no path\n * from source. The predecessor property can be used to walk the individual elements of the\n * path from source to v in reverse order.\n * Complexity: O((|E| + |V|) * log |V|).\n *\n * @param graph - graph where to search paths.\n * @param source - node to start paths from.\n * @param weightFn - function which takes edge e and returns the weight of it. If no weightFn\n * is supplied then each edge is assumed to have a weight of 1. This function throws an\n * Error if any of the traversed edges have a negative edge weight.\n * @param edgeFn - function which takes a node v and returns the ids of all edges incident to it\n * for the purposes of shortest path traversal. By default this function uses the graph.outEdges.\n * @returns shortest paths map that starts from node source\n */\nexport function dijkstra(\n graph: Graph,\n source: string,\n weightFn?: WeightFunction,\n edgeFn?: EdgeFunction\n): Record<string, Path> {\n const defaultEdgeFn: EdgeFunction = function (v) {\n return graph.outEdges(v)!;\n };\n\n return runDijkstra(graph, String(source),\n weightFn || DEFAULT_WEIGHT_FUNC,\n edgeFn || defaultEdgeFn);\n}\n\nfunction runDijkstra(\n graph: Graph,\n source: string,\n weightFn: WeightFunction,\n edgeFn: EdgeFunction\n): Record<string, Path> {\n const results: Record<string, Path> = {};\n const pq = new PriorityQueue();\n let v: string, vEntry: Path;\n\n const updateNeighbors = function (edge: Edge): void {\n const w = edge.v !== v ? edge.v : edge.w;\n const wEntry = results[w]!;\n const weight = weightFn(edge);\n const distance = vEntry.distance + weight;\n\n if (weight < 0) {\n throw new Error(\"dijkstra does not allow negative edge weights. \" +\n \"Bad edge: \" + edge + \" Weight: \" + weight);\n }\n\n if (distance < wEntry.distance) {\n wEntry.distance = distance;\n wEntry.predecessor = v;\n pq.decrease(w, distance);\n }\n };\n\n graph.nodes().forEach(function (v) {\n const distance = v === source ? 0 : Number.POSITIVE_INFINITY;\n results[v] = {distance: distance, predecessor: ''};\n pq.add(v, distance);\n });\n\n while (pq.size() > 0) {\n v = pq.removeMin()!;\n vEntry = results[v]!;\n if (vEntry.distance === Number.POSITIVE_INFINITY) {\n break;\n }\n\n edgeFn(v).forEach(updateNeighbors);\n }\n\n return results;\n}\n","import {Graph} from '../graph';\nimport type {EdgeFunction, Path, WeightFunction} from '../types';\nimport {dijkstra} from './dijkstra';\n\n/**\n * This function finds the shortest path from each node to every other reachable node in\n * the graph. It is similar to alg.dijkstra, but instead of returning a single-source\n * array, it returns a mapping of source -> alg.dijkstra(g, source, weightFn, edgeFn).\n * Complexity: O(|V| * (|E| + |V|) * log |V|).\n *\n * @param graph - graph where to search paths.\n * @param weightFn - function which takes edge e and returns the weight of it. If no weightFn\n * is supplied then each edge is assumed to have a weight of 1. This function throws an\n * Error if any of the traversed edges have a negative edge weight.\n * @param edgeFn - function which takes a node v and returns the ids of all edges incident to it\n * for the purposes of shortest path traversal. By default this function uses the graph.outEdges.\n * @returns shortest paths map.\n */\nexport function dijkstraAll(\n graph: Graph,\n weightFn?: WeightFunction,\n edgeFn?: EdgeFunction\n): Record<string, Record<string, Path>> {\n return graph.nodes().reduce(function (acc, v) {\n acc[v] = dijkstra(graph, v, weightFn, edgeFn);\n return acc;\n }, {} as Record<string, Record<string, Path>>);\n}\n","import {Graph} from '../graph';\n\ninterface VisitedEntry {\n onStack: boolean;\n lowlink: number;\n index: number;\n}\n\n/**\n * This function is an implementation of Tarjan's algorithm which finds all strongly connected\n * components in the directed graph g. Each strongly connected component is composed of nodes that\n * can reach all other nodes in the component via directed edges. A strongly connected component\n * can consist of a single node if that node cannot both reach and be reached by any other\n * specific node in the graph. Components of more than one node are guaranteed to have at least\n * one cycle.\n * Complexity: O(|V| + |E|).\n *\n * @param graph - graph to find all strongly connected components of.\n * @returns an array of components. Each component is itself an array that contains\n * the ids of all nodes in the component.\n */\nexport function tarjan(graph: Graph): string[][] {\n let index = 0;\n const stack: string[] = [];\n const visited: Record<string, VisitedEntry> = {}; // node id -> { onStack, lowlink, index }\n const results: string[][] = [];\n\n function dfs(v: string): void {\n const entry = visited[v] = {\n onStack: true,\n lowlink: index,\n index: index++\n };\n stack.push(v);\n\n graph.successors(v)!.forEach(function (w) {\n if (!(w in visited)) {\n dfs(w);\n entry.lowlink = Math.min(entry.lowlink, visited[w]!.lowlink);\n } else if (visited[w]!.onStack) {\n entry.lowlink = Math.min(entry.lowlink, visited[w]!.index);\n }\n });\n\n if (entry.lowlink === entry.index) {\n const cmpt: string[] = [];\n let w: string;\n do {\n w = stack.pop()!;\n visited[w]!.onStack = false;\n cmpt.push(w);\n } while (v !== w);\n results.push(cmpt);\n }\n }\n\n graph.nodes().forEach(function (v) {\n if (!(v in visited)) {\n dfs(v);\n }\n });\n\n return results;\n}\n","import {Graph} from '../graph';\nimport {tarjan} from './tarjan';\n\n/**\n * Given a Graph, graph, this function returns all nodes that are part of a cycle. As there\n * may be more than one cycle in a graph this function return an array of these cycles,\n * where each cycle is itself represented by an array of ids for each node involved in\n * that cycle. Method alg.isAcyclic is more efficient if you only need to determine whether a graph has a\n * cycle or not.\n * Complexity: O(|V| + |E|).\n *\n * @param graph - graph where to search cycles.\n * @returns cycles list.\n */\nexport function findCycles(graph: Graph): string[][] {\n return tarjan(graph).filter(function (cmpt) {\n return cmpt.length > 1 || (cmpt.length === 1 && graph.hasEdge(cmpt[0]!, cmpt[0]!));\n });\n}\n","import {Graph} from '../graph';\nimport type {EdgeFunction, Path, WeightFunction} from '../types';\n\nconst DEFAULT_WEIGHT_FUNC: WeightFunction = () => 1;\n\n/**\n * This function is an implementation of the Floyd-Warshall algorithm, which finds the\n * shortest path from each node to every other reachable node in the graph. It is similar\n * to alg.dijkstraAll, but it handles negative edge weights and is more efficient for some types\n * of graphs. This function returns a map of source -> { target -> { distance, predecessor }.\n * The distance property holds the sum of the weights from source to target along the shortest\n * path of Number.POSITIVE_INFINITY if there is no path from source. The predecessor property\n * can be used to walk the individual elements of the path from source to target in reverse\n * order.\n * Complexity: O(|V|^3).\n *\n * @param graph - graph where to search paths.\n * @param weightFn - function which takes edge e and returns the weight of it. If no weightFn\n * is supplied then each edge is assumed to have a weight of 1. This function throws an\n * Error if any of the traversed edges have a negative edge weight.\n * @param edgeFn - function which takes a node v and returns the ids of all edges incident to it\n * for the purposes of shortest path traversal. By default this function uses the graph.outEdges.\n * @returns shortest paths map.\n */\nexport function floydWarshall(\n graph: Graph,\n weightFn?: WeightFunction,\n edgeFn?: EdgeFunction\n): Record<string, Record<string, Path>> {\n return runFloydWarshall(graph,\n weightFn || DEFAULT_WEIGHT_FUNC,\n edgeFn || function (v) {\n return graph.outEdges(v)!;\n });\n}\n\nfunction runFloydWarshall(\n graph: Graph,\n weightFn: WeightFunction,\n edgeFn: EdgeFunction\n): Record<string, Record<string, Path>> {\n const results: Record<string, Record<string, Path>> = {};\n const nodes = graph.nodes();\n\n nodes.forEach(function (v) {\n results[v] = {};\n results[v]![v] = {distance: 0, predecessor: ''};\n nodes.forEach(function (w) {\n if (v !== w) {\n results[v]![w] = {distance: Number.POSITIVE_INFINITY, predecessor: ''};\n }\n });\n edgeFn(v).forEach(function (edge) {\n const w = edge.v === v ? edge.w : edge.v;\n const d = weightFn(edge);\n results[v]![w] = {distance: d, predecessor: v};\n });\n });\n\n nodes.forEach(function (k) {\n const rowK = results[k]!;\n nodes.forEach(function (i) {\n const rowI = results[i]!;\n nodes.forEach(function (j) {\n const ik = rowI[k]!;\n const kj = rowK[j]!;\n const ij = rowI[j]!;\n const altDistance = ik.distance + kj.distance;\n if (altDistance < ij.distance) {\n ij.distance = altDistance;\n ij.predecessor = kj.predecessor;\n }\n });\n });\n });\n\n return results;\n}\n","import {Graph} from '../graph';\n\nexport class CycleException extends Error {\n constructor(...args: unknown[]) {\n super(...args as ConstructorParameters<typeof Error>);\n }\n}\n\n/**\n * Given a graph this function applies topological sorting to it.\n * If the graph has a cycle it is impossible to generate such a list and CycleException is thrown.\n * Complexity: O(|V| + |E|).\n *\n * @param graph - graph to apply topological sorting to.\n * @returns an array of nodes such that for each edge u -> v, u appears before v in the array.\n */\nexport function topsort(graph: Graph): string[] {\n const visited: Record<string, boolean> = {};\n const stack: Record<string, boolean> = {};\n const results: string[] = [];\n\n function visit(node: string): void {\n if (node in stack) {\n throw new CycleException();\n }\n\n if (!(node in visited)) {\n stack[node] = true;\n visited[node] = true;\n graph.predecessors(node)!.forEach(visit);\n delete stack[node];\n results.push(node);\n }\n }\n\n graph.sinks().forEach(visit);\n\n if (Object.keys(visited).length !== graph.nodeCount()) {\n throw new CycleException();\n }\n\n return results;\n}\n","import {Graph} from '../graph';\nimport {CycleException, topsort} from './topsort';\n\n/**\n * Given a Graph, graph, this function returns true if the graph has no cycles and returns false if it\n * does. This algorithm returns as soon as it detects the first cycle. You can use alg.findCycles\n * to get the actual list of cycles in the graph.\n *\n * @param graph - graph to detect whether it acyclic or not.\n * @returns whether graph contain cycles or not.\n */\nexport function isAcyclic(graph: Graph): boolean {\n try {\n topsort(graph);\n } catch (e) {\n if (e instanceof CycleException) {\n return false;\n }\n throw e;\n }\n return true;\n}\n","import {Graph} from '../graph';\n\n/*\n * A helper that preforms a pre- or post-order traversal on the input graph\n * and processes the nodes in the order they are visited. If the graph is\n * undirected then this algorithm will navigate using neighbors. If the graph\n * is directed then this algorithm will navigate using successors.\n *\n * Order must be one of \"pre\" or \"post\".\n */\nexport function reduce<T>(\n g: Graph,\n vs: string | string[],\n order: string,\n fn: (acc: T, v: string) => T,\n acc: T\n): T {\n if (!Array.isArray(vs)) {\n vs = [vs];\n }\n\n const navigation = ((v: string) => (g.isDirected() ? g.successors(v) : g.neighbors(v)) ?? []);\n\n const visited: Record<string, boolean> = {};\n vs.forEach(function (v) {\n if (!g.hasNode(v)) {\n throw new Error(\"Graph does not have node: \" + v);\n }\n\n acc = doReduce(g, v, order === \"post\", visited, navigation, fn, acc);\n });\n return acc;\n}\n\nfunction doReduce<T>(\n g: Graph,\n v: string,\n postorder: boolean,\n visited: Record<string, boolean>,\n navigation: (v: string) => string[],\n fn: (acc: T, v: string) => T,\n acc: T\n): T {\n if (!(v in visited)) {\n visited[v] = true;\n\n if (!postorder) {\n acc = fn(acc, v);\n }\n navigation(v).forEach(function (w) {\n acc = doReduce(g, w, postorder, visited, navigation, fn, acc);\n });\n if (postorder) {\n acc = fn(acc, v);\n }\n }\n return acc;\n}\n","import {Graph} from '../graph';\nimport {reduce} from './reduce';\n\n/*\n * Pre- or post-order traversal on the input graph.\n * Returns an array of the nodes in the order they were visited.\n *\n * If the order is not \"post\", it will be treated as \"pre\".\n */\nexport function dfs(g: Graph, vs: string | string[], order: string): string[] {\n return reduce(g, vs, order, function (acc, v) {\n acc.push(v);\n return acc;\n }, [] as string[]);\n}\n","import {Graph} from '../graph';\nimport {dfs} from './dfs';\n\n/**\n * Performs post-order depth first traversal on the input graph. If the graph is\n * undirected then this algorithm will navigate using neighbors. If the graph\n * is directed then this algorithm will navigate using successors.\n *\n * @param graph - depth first traversal target.\n * @param vs - nodes list to traverse.\n * @returns the nodes in the order they were visited as a list of their names.\n */\nexport function postorder(graph: Graph, vs: string | string[]): string[] {\n return dfs(graph, vs, \"post\");\n}\n","import {Graph} from '../graph';\nimport {dfs} from './dfs';\n\n/**\n * Performs pre-order depth first traversal on the input graph. If the graph is\n * undirected then this algorithm will navigate using neighbors. If the graph\n * is directed then this algorithm will navigate using successors.\n *\n * @param graph - depth first traversal target.\n * @param vs - nodes list to traverse.\n * @returns the nodes in the order they were visited as a list of their names.\n */\nexport function preorder(graph: Graph, vs: string | string[]): string[] {\n return dfs(graph, vs, \"pre\");\n}\n","import {Graph} from '../graph';\nimport {PriorityQueue} from '../data/priority-queue';\nimport type {Edge, WeightFunction} from '../types';\n\n/**\n * Prim's algorithm takes a connected undirected graph and generates a minimum spanning tree. This\n * function returns the minimum spanning tree as an undirected graph. This algorithm is derived\n * from the description in \"Introduction to Algorithms\", Third Edition, Cormen, et al., Pg 634.\n * Complexity: O(|E| * log |V|);\n *\n * @param graph - graph to generate a minimum spanning tree of.\n * @param weightFn - function which takes edge e and returns the weight of it. It throws an Error if\n * the graph is not connected.\n * @returns minimum spanning tree of graph.\n */\nexport function prim(graph: Graph, weightFn: WeightFunction): Graph {\n const result = new Graph();\n const parents: Record<string, string> = {};\n const pq = new PriorityQueue();\n let v: string;\n\n function updateNeighbors(edge: Edge): void {\n const w = edge.v === v ? edge.w : edge.v;\n const pri = pq.priority(w);\n if (pri !== undefined) {\n const edgeWeight = weightFn(edge);\n if (edgeWeight < pri) {\n parents[w] = v;\n pq.decrease(w, edgeWeight);\n }\n }\n }\n\n if (graph.nodeCount() === 0) {\n return result;\n }\n\n graph.nodes().forEach(function (v) {\n pq.add(v, Number.POSITIVE_INFINITY);\n result.setNode(v);\n });\n\n // Start from an arbitrary node\n pq.decrease(graph.nodes()[0]!, 0);\n\n let init = false;\n while (pq.size() > 0) {\n v = pq.removeMin()!;\n if (v in parents) {\n result.setEdge(v, parents[v]!);\n } else if (init) {\n throw new Error(\"Input graph is not connected: \" + graph);\n } else {\n init = true;\n }\n\n graph.nodeEdges(v)!.forEach(updateNeighbors);\n }\n\n return result;\n}\n","import {dijkstra} from './dijkstra';\nimport {bellmanFord} from './bellman-ford';\nimport {Graph} from '../graph';\nimport type {EdgeFunction, Path, WeightFunction} from '../types';\n\nexport function shortestPaths(\n g: Graph,\n source: string,\n weightFn?: WeightFunction,\n edgeFn?: EdgeFunction\n): Record<string, Path> {\n return runShortestPaths(\n g,\n source,\n weightFn,\n edgeFn ?? ((v: string) => {\n const edges = g.outEdges(v);\n return edges ?? [];\n })\n );\n}\n\nfunction runShortestPaths(\n g: Graph,\n source: string,\n weightFn: WeightFunction | undefined,\n edgeFn: EdgeFunction\n): Record<string, Path> {\n if (weightFn === undefined) {\n return dijkstra(g, source, weightFn, edgeFn);\n }\n\n let negativeEdgeExists = false;\n const nodes = g.nodes();\n\n for (let i = 0; i < nodes.length; i++) {\n const adjList = edgeFn(nodes[i]!);\n\n for (let j = 0; j < adjList.length; j++) {\n const edge = adjList[j]!;\n const inVertex = edge.v === nodes[i] ? edge.v : edge.w;\n const outVertex = inVertex === edge.v ? edge.w : edge.v;\n\n if (weightFn({v: inVertex, w: outVertex}) < 0) {\n negativeEdgeExists = true;\n }\n }\n\n if (negativeEdgeExists) {\n return bellmanFord(g, source, weightFn, edgeFn);\n }\n }\n\n return dijkstra(g, source, weightFn, edgeFn);\n}\n","import {Graph} from \"./graph-lib\";\nimport type {EdgeLabel, GraphLabel, NodeLabel, PartitionResult, Point} from \"./types\";\n\nexport {\n addBorderNode,\n addDummyNode,\n applyWithChunking,\n asNonCompoundGraph,\n buildLayerMatrix,\n intersectRect,\n mapValues,\n maxRank,\n normalizeRanks,\n notime,\n partition,\n pick,\n predecessorWeights,\n range,\n removeEmptyRanks,\n simplify,\n successorWeights,\n time,\n uniqueId,\n zipObject,\n};\n\n/*\n * Adds a dummy node to the graph and return v.\n */\nfunction addDummyNode(\n graph: Graph<GraphLabel, NodeLabel, EdgeLabel>,\n type: 'root' | \"edge\" | \"border\" | \"edge-label\" | \"edge-proxy\" | \"selfedge\",\n attrs: Partial<NodeLabel>,\n name: string\n): string {\n let v: string = name;\n while (graph.hasNode(v)) {\n v = uniqueId(name);\n }\n\n attrs.dummy = type;\n graph.setNode(v, attrs as NodeLabel);\n return v;\n}\n\n/*\n * Returns a new graph with only simple edges. Handles aggregation of data\n * associated with multi-edges.\n */\nfunction simplify(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): Graph<GraphLabel, NodeLabel, EdgeLabel> {\n const simplified = new Graph<GraphLabel, NodeLabel, EdgeLabel>().setGraph(graph.graph());\n graph.nodes().forEach(v => simplified.setNode(v, graph.node(v)));\n graph.edges().forEach(e => {\n const simpleLabel: EdgeLabel = simplified.edge(e.v, e.w) || {weight: 0, minlen: 1};\n const label: EdgeLabel = graph.edge(e);\n simplified.setEdge(e.v, e.w, {\n weight: simpleLabel.weight! + label.weight!,\n minlen: Math.max(simpleLabel.minlen!, label.minlen!)\n });\n });\n return simplified;\n}\n\nfunction asNonCompoundGraph(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): Graph<GraphLabel, NodeLabel, EdgeLabel> {\n const simplified = new Graph<GraphLabel, NodeLabel, EdgeLabel>({multigraph: graph.isMultigraph()}).setGraph(graph.graph());\n graph.nodes().forEach(v => {\n if (!graph.children(v).length) {\n simplified.setNode(v, graph.node(v));\n }\n });\n graph.edges().forEach(e => {\n simplified.setEdge(e, graph.edge(e));\n });\n return simplified;\n}\n\nfunction successorWeights(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): {\n [key: string]: { [key: string]: number }\n} {\n const weightMap: { [key: string]: number }[] = graph.nodes().map(v => {\n const sucs: { [key: string]: number } = {};\n const outEdges = graph.outEdges(v);\n if (outEdges) {\n outEdges.forEach(e => {\n sucs[e.w] = (sucs[e.w] || 0) + graph.edge(e).weight!;\n });\n }\n return sucs;\n });\n return zipObject(graph.nodes(), weightMap);\n}\n\nfunction predecessorWeights(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): {\n [key: string]: { [key: string]: number }\n} {\n const weightMap: { [key: string]: number }[] = graph.nodes().map(v => {\n const preds: { [key: string]: number } = {};\n const inEdges = graph.inEdges(v);\n if (inEdges) {\n inEdges.forEach(e => {\n preds[e.v] = (preds[e.v] || 0) + graph.edge(e).weight!;\n });\n }\n return preds;\n });\n return zipObject(graph.nodes(), weightMap);\n}\n\n/*\n * Finds where a line starting at point ({x, y}) would intersect a rectangle\n * ({x, y, width, height}) if it were pointing at the rectangle's center.\n */\nfunction intersectRect(rect: NodeLabel, point: Point): Point {\n const x: number = rect.x!;\n const y: number = rect.y!;\n\n // Rectangle intersection algorithm from:\n // http://math.stackexchange.com/questions/108113/find-edge-between-two-boxes\n const dx: number = point.x - x;\n const dy: number = point.y - y;\n let w: number = rect.width / 2;\n let h: number = rect.height / 2;\n\n if (!dx && !dy) {\n throw new Error(\"Not possible to find intersection inside of the rectangle\");\n }\n\n let sx: number, sy: number;\n if (Math.abs(dy) * w > Math.abs(dx) * h) {\n // Intersection is top or bottom of rect.\n if (dy < 0) {\n h = -h;\n }\n sx = h * dx / dy;\n sy = h;\n } else {\n // Intersection is left or right of rect.\n if (dx < 0) {\n w = -w;\n }\n sx = w;\n sy = w * dy / dx;\n }\n\n return {x: x + sx, y: y + sy};\n}\n\n/*\n * Given a DAG with each node assigned \"rank\" and \"order\" properties, this\n * function will produce a matrix with the ids of each node.\n */\nfunction buildLayerMatrix(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): string[][] {\n const layering: string[][] = range(maxRank(graph) + 1).map(() => []);\n graph.nodes().forEach(v => {\n const node = graph.node(v) as NodeLabel;\n const rank: number | undefined = node.rank;\n if (rank !== undefined) {\n if (!layering[rank]) {\n layering[rank] = [];\n }\n layering[rank][node.order!] = v;\n }\n });\n return layering;\n}\n\n/*\n * Adjusts the ranks for all nodes in the graph such that all nodes v have\n * rank(v) >= 0 and at least one node w has rank(w) = 0.\n */\nfunction normalizeRanks(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n const nodeRanks: number[] = graph.nodes().map(v => {\n const rank: number | undefined = (graph.node(v) as NodeLabel).rank;\n if (rank === undefined) {\n return Number.MAX_VALUE;\n }\n\n return rank;\n });\n const min: number = applyWithChunking(Math.min, nodeRanks);\n graph.nodes().forEach(v => {\n const node = graph.node(v) as NodeLabel;\n if (Object.hasOwn(node, \"rank\")) {\n (node as NodeLabel).rank! -= min;\n }\n });\n}\n\nfunction removeEmptyRanks(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n // Ranks may not start at 0, so we need to offset them\n const nodeRanks: number[] = graph.nodes().map(v => graph.node(v).rank).filter((rank): rank is number => rank !== undefined);\n const offset: number = applyWithChunking(Math.min, nodeRanks);\n\n const layers: string[][] = [];\n graph.nodes().forEach(v => {\n const rank: number = graph.node(v).rank! - offset;\n if (!layers[rank]) {\n layers[rank] = [];\n }\n layers[rank].push(v);\n });\n\n let delta: number = 0;\n const nodeRankFactor: number = graph.graph().nodeRankFactor!;\n Array.from(layers).forEach((vs, i) => {\n if (vs === undefined && i % nodeRankFactor !== 0) {\n --delta;\n } else if (vs !== undefined && delta) {\n vs.forEach(v => graph.node(v).rank! += delta);\n }\n });\n}\n\nfunction addBorderNode(\n graph: Graph<GraphLabel, NodeLabel, EdgeLabel>,\n prefix: string,\n rank?: number,\n order?: number\n): string {\n const node: Partial<NodeLabel> = {\n width: 0,\n height: 0\n };\n if (arguments.length >= 4) {\n node.rank = rank;\n node.order = order;\n }\n return addDummyNode(graph, \"border\", node, prefix);\n}\n\nfunction splitToChunks<T>(array: T[], chunkSize: number = CHUNKING_THRESHOLD): T[][] {\n const chunks: T[][] = [];\n for (let i = 0; i < array.length; i += chunkSize) {\n const chunk: T[] = array.slice(i, i + chunkSize);\n chunks.push(chunk);\n }\n return chunks;\n}\n\nconst CHUNKING_THRESHOLD = 65535;\n\nfunction applyWithChunking(fn: (...args: number[]) => number, argsArray: number[]): number {\n if (argsArray.length > CHUNKING_THRESHOLD) {\n const chunks: number[][] = splitToChunks(argsArray);\n return fn(...chunks.map(chunk => fn(...chunk)));\n } else {\n return fn(...argsArray);\n }\n}\n\nfunction maxRank(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): number {\n const nodes: string[] = graph.nodes();\n const nodeRanks: number[] = nodes.map(v => {\n const rank: number | undefined = graph.node(v).rank;\n if (rank === undefined) {\n return Number.MIN_VALUE;\n }\n return rank;\n });\n\n return applyWithChunking(Math.max, nodeRanks);\n}\n\n/*\n * Partition a collection into two groups: `lhs` and `rhs`. If the supplied\n * function returns true for an entry it goes into `lhs`. Otherwise it goes\n * into `rhs.\n */\nfunction partition<T>(collection: T[], fn: (value: T) => boolean): PartitionResult<T> {\n const result: PartitionResult<T> = {lhs: [], rhs: []};\n collection.forEach(value => {\n if (fn(value)) {\n result.lhs.push(value);\n } else {\n result.rhs.push(value);\n }\n });\n return result;\n}\n\n/*\n * Returns a new function that wraps `fn` with a timer. The wrapper logs the\n * time it takes to execute the function.\n */\nfunction time<T>(name: string, fn: () => T): T {\n const start: number = Date.now();\n try {\n return fn();\n } finally {\n console.log(name + \" time: \" + (Date.now() - start) + \"ms\");\n }\n}\n\nfunction notime<T>(name: string, fn: () => T): T {\n return fn();\n}\n\nlet idCounter = 0;\n\nfunction uniqueId(prefix: string): string {\n const id: number = ++idCounter;\n return prefix + (\"\" + id);\n}\n\nfunction range(start: number, limit?: number, step: number = 1): number[] {\n if (limit == null) {\n limit = start;\n start = 0;\n }\n\n let endCon: (i: number) => boolean = (i) => i < limit!;\n if (step < 0) {\n endCon = (i) => limit! < i;\n }\n\n const range: number[] = [];\n for (let i = start; endCon(i); i += step) {\n range.push(i);\n }\n\n return range;\n}\n\nfunction pick<T extends Record<string, unknown>>(source: T, keys: string[]): Partial<T> {\n const dest: Partial<T> = {};\n for (const key of keys) {\n if (source[key] !== undefined) {\n (dest as Record<string, unknown>)[key] = source[key];\n }\n }\n\n return dest;\n}\n\nfunction mapValues<T, R>(obj: { [key: string]: T }, funcOrProp: ((val: T, key: string) => R) | string): {\n [key: string]: R\n} {\n let func: (val: T, key: string) => R;\n if (typeof funcOrProp === 'string') {\n func = (val: T) => (val as Record<string, R>)[funcOrProp] as R;\n } else {\n func = funcOrProp;\n }\n\n return Object.entries(obj).reduce((acc: { [key: string]: R }, [k, v]) => {\n acc[k] = func(v, k);\n return acc;\n }, {});\n}\n\nfunction zipObject<T>(props: string[], values: T[]): { [key: string]: T } {\n return props.reduce((acc: { [key: string]: T }, key, i) => {\n acc[key] = values[i]!;\n return acc;\n }, {});\n}\n\n// TODO: Remove it when the type is fixed in graphlib. from children(v: string): string[] to children(v?: string): string[];\nexport const GRAPH_NODE = \"\\x00\";\n","export const version = \"3.0.0\";\n","/*\n * Simple doubly linked list implementation derived from Cormen, et al.,\n * \"Introduction to Algorithms\".\n */\n\ninterface ListNode {\n _next?: ListNode;\n _prev?: ListNode;\n\n [key: string]: unknown;\n}\n\nclass List {\n private _sentinel: ListNode;\n\n constructor() {\n const sentinel: ListNode = {};\n sentinel._next = sentinel._prev = sentinel;\n this._sentinel = sentinel;\n }\n\n dequeue(): ListNode | undefined {\n const sentinel = this._sentinel;\n const entry = sentinel._prev;\n if (entry !== sentinel) {\n unlink(entry!);\n return entry;\n }\n return undefined;\n }\n\n enqueue(entry: ListNode): void {\n const sentinel = this._sentinel;\n if (entry._prev && entry._next) {\n unlink(entry);\n }\n entry._next = sentinel._next;\n sentinel._next!._prev = entry;\n sentinel._next = entry;\n entry._prev = sentinel;\n }\n\n toString(): string {\n const strs: string[] = [];\n const sentinel = this._sentinel;\n let curr = sentinel._prev;\n while (curr !== sentinel) {\n strs.push(JSON.stringify(curr, filterOutLinks));\n curr = curr!._prev;\n }\n return \"[\" + strs.join(\", \") + \"]\";\n }\n}\n\nfunction unlink(entry: ListNode): void {\n entry._prev!._next = entry._next;\n entry._next!._prev = entry._prev;\n delete entry._next;\n delete entry._prev;\n}\n\nfunction filterOutLinks(k: string, v: unknown): unknown {\n if (k !== \"_next\" && k !== \"_prev\") {\n return v;\n }\n return undefined;\n}\n\nexport default List;\n","import {Graph} from \"./graph-lib\";\nimport List from './data/list';\nimport type {Edge, WeightFunction} from './types';\n\n/*\n * A greedy heuristic for finding a feedback arc set for a graph. A feedback\n * arc set is a set of edges that can be removed to make a graph acyclic.\n * The algorithm comes from: P. Eades, X. Lin, and W. F. Smyth, \"A fast and\n * effective heuristic for the feedback arc set problem.\" This implementation\n * adjusts that from the paper to allow for weighted edges.\n */\n\nconst DEFAULT_WEIGHT_FN: WeightFunction = () => 1;\n\ninterface FASEntry {\n v: string;\n in: number;\n out: number;\n [key: string]: unknown;\n}\n\ninterface FASState {\n graph: Graph;\n buckets: List[];\n zeroIdx: number;\n}\n\nexport default function greedyFAS(graph: Graph, weightFn?: WeightFunction): Edge[] {\n if (graph.nodeCount() <= 1) {\n return [];\n }\n const state = buildState(graph, weightFn || DEFAULT_WEIGHT_FN);\n const results = doGreedyFAS(state.graph, state.buckets, state.zeroIdx);\n\n // Expand multi-edges\n return results.flatMap(edge => graph.outEdges(edge.v, edge.w) || []);\n}\n\nfunction doGreedyFAS(g: Graph, buckets: List[], zeroIdx: number): Edge[] {\n let results: Edge[] = [];\n const sources = buckets[buckets.length - 1]!;\n const sinks = buckets[0]!;\n\n let entry: FASEntry | undefined;\n while (g.nodeCount()) {\n while ((entry = sinks.dequeue() as FASEntry | undefined)) {\n removeNode(g, buckets, zeroIdx, entry);\n }\n while ((entry = sources.dequeue() as FASEntry | undefined)) {\n removeNode(g, buckets, zeroIdx, entry);\n }\n if (g.nodeCount()) {\n for (let i = buckets.length - 2; i > 0; --i) {\n entry = buckets[i]?.dequeue() as FASEntry | undefined;\n if (entry) {\n results = results.concat(removeNode(g, buckets, zeroIdx, entry, true) || []);\n break;\n }\n }\n }\n }\n\n return results;\n}\n\nfunction removeNode(\n graph: Graph,\n buckets: List[],\n zeroIdx: number,\n entry: FASEntry,\n collectPredecessors?: boolean\n): Edge[] | undefined {\n const collected: Edge[] = [];\n const results: Edge[] | undefined = collectPredecessors ? collected : undefined;\n\n (graph.inEdges(entry.v) || []).forEach(edge => {\n const weight = graph.edge(edge) as number;\n const uEntry = graph.node(edge.v) as FASEntry;\n\n if (collectPredecessors) {\n collected.push({v: edge.v, w: edge.w});\n }\n\n uEntry.out -= weight;\n assignBucket(buckets, zeroIdx, uEntry);\n });\n\n (graph.outEdges(entry.v) || []).forEach(edge => {\n const weight = graph.edge(edge) as number;\n const w = edge.w;\n const wEntry = graph.node(w) as FASEntry;\n wEntry.in -= weight;\n assignBucket(buckets, zeroIdx, wEntry);\n });\n\n graph.removeNode(entry.v);\n\n return results;\n}\n\nfunction buildState(graph: Graph, weightFn: WeightFunction): FASState {\n const fasGraph = new Graph();\n let maxIn = 0;\n let maxOut = 0;\n\n graph.nodes().forEach(v => {\n fasGraph.setNode(v, {v: v, in: 0, out: 0});\n });\n\n // Aggregate weights on nodes, but also sum the weights across multi-edges\n // into a single edge for the fasGraph.\n graph.edges().forEach(edge => {\n const prevWeight = (fasGraph.edge(edge.v, edge.w) as number) || 0;\n const weight = weightFn(edge);\n const edgeWeight = prevWeight + weight;\n fasGraph.setEdge(edge.v, edge.w, edgeWeight);\n const vNode = fasGraph.node(edge.v) as FASEntry;\n const wNode = fasGraph.node(edge.w) as FASEntry;\n maxOut = Math.max(maxOut, vNode.out += weight);\n maxIn = Math.max(maxIn, wNode.in += weight);\n });\n\n const buckets = range(maxOut + maxIn + 3).map(() => new List());\n const zeroIdx = maxIn + 1;\n\n fasGraph.nodes().forEach(v => {\n assignBucket(buckets, zeroIdx, fasGraph.node(v) as FASEntry);\n });\n\n return {graph: fasGraph, buckets: buckets, zeroIdx: zeroIdx};\n}\n\nfunction assignBucket(buckets: List[], zeroIdx: number, entry: FASEntry): void {\n if (!entry.out) {\n buckets[0]?.enqueue(entry);\n } else if (!entry.in) {\n buckets[buckets.length - 1]?.enqueue(entry);\n } else {\n buckets[entry.out - entry.in + zeroIdx]?.enqueue(entry);\n }\n}\n\nfunction range(limit: number): number[] {\n const range: number[] = [];\n for (let i = 0; i < limit; i++) {\n range.push(i);\n }\n\n return range;\n}\n","import {Graph} from \"@dagrejs/graphlib\";\nimport greedyFAS from \"./greedy-fas\";\nimport {uniqueId} from \"./util\";\nimport type {Edge, EdgeLabel, GraphLabel, NodeLabel, WeightFunction} from \"./types\";\n\nexport {run, undo};\n\nfunction run(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n const fas = (graph.graph().acyclicer === \"greedy\"\n ? greedyFAS(graph, weightFn(graph))\n : dfsFAS(graph));\n fas.forEach(e => {\n const label = graph.edge(e)!;\n graph.removeEdge(e);\n label.forwardName = e.name;\n label.reversed = true;\n graph.setEdge(e.w, e.v, label, uniqueId(\"rev\"));\n });\n\n function weightFn(g: Graph<GraphLabel, NodeLabel, EdgeLabel>): WeightFunction {\n return (e: Edge) => {\n return g.edge(e)!.weight!;\n };\n }\n}\n\nfunction dfsFAS(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): Edge[] {\n const fas: Edge[] = [];\n const stack: { [key: string]: boolean } = {};\n const visited: { [key: string]: boolean } = {};\n\n function dfs(v: string): void {\n if (Object.hasOwn(visited, v)) {\n return;\n }\n visited[v] = true;\n stack[v] = true;\n graph.outEdges(v)!.forEach(e => {\n if (Object.hasOwn(stack, e.w)) {\n fas.push(e);\n } else {\n dfs(e.w);\n }\n });\n delete stack[v];\n }\n\n graph.nodes().forEach(dfs);\n return fas;\n}\n\nfunction undo(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n graph.edges().forEach(e => {\n const label = graph.edge(e)!;\n if (label.reversed) {\n graph.removeEdge(e);\n\n const forwardName = label.forwardName;\n delete label.reversed;\n delete label.forwardName;\n graph.setEdge(e.w, e.v, label, forwardName);\n }\n });\n}\n","import {addDummyNode} from \"./util\";\nimport type {Edge, EdgeLabel, Graph, GraphLabel, NodeLabel} from \"./types\";\n\nexport {\n run,\n undo\n};\n\n/*\n * Breaks any long edges in the graph into short segments that span 1 layer\n * each. This operation is undoable with the denormalize function.\n *\n * Pre-conditions:\n *\n * 1. The input graph is a DAG.\n * 2. Each node in the graph has a \"rank\" property.\n *\n * Post-condition:\n *\n * 1. All edges in the graph have a length of 1.\n * 2. Dummy nodes are added where edges have been split into segments.\n * 3. The graph is augmented with a \"dummyChains\" attribute which contains\n * the first dummy in each chain of dummy nodes produced.\n */\nfunction run(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n graph.graph().dummyChains = [];\n graph.edges().forEach(edge => normalizeEdge(graph, edge));\n}\n\nfunction normalizeEdge(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>, e: Edge): void {\n let v: string = e.v;\n let vRank: number = graph.node(v).rank!;\n const w: string = e.w;\n const wRank: number = graph.node(w).rank!;\n const name: string | undefined = e.name;\n const edgeLabel: EdgeLabel = graph.edge(e);\n const labelRank: number | undefined = edgeLabel.labelRank;\n\n if (wRank === vRank + 1) return;\n\n graph.removeEdge(e);\n\n let dummy: string;\n let attrs: Partial<NodeLabel>;\n let i: number;\n for (i = 0, ++vRank; vRank < wRank; ++i, ++vRank) {\n edgeLabel.points = [];\n attrs = {\n width: 0,\n height: 0,\n edgeLabel: edgeLabel,\n edgeObj: e,\n rank: vRank\n };\n dummy = addDummyNode(graph, \"edge\", attrs, \"_d\");\n if (vRank === labelRank) {\n attrs.width = edgeLabel.width;\n attrs.height = edgeLabel.height;\n attrs.dummy = \"edge-label\";\n attrs.labelpos = edgeLabel.labelpos;\n }\n graph.setEdge(v, dummy, {weight: edgeLabel.weight}, name);\n if (i === 0) {\n graph.graph().dummyChains!.push(dummy);\n }\n v = dummy;\n }\n\n graph.setEdge(v, w, {weight: edgeLabel.weight}, name);\n}\n\nfunction undo(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n graph.graph().dummyChains!.forEach(v => {\n let node: NodeLabel = graph.node(v);\n const origLabel: EdgeLabel = node.edgeLabel!;\n let w: string;\n graph.setEdge(node.edgeObj!, origLabel);\n while (node.dummy) {\n w = graph.successors(v)![0]!;\n graph.removeNode(v);\n origLabel.points!.push({x: node.x!, y: node.y!});\n if (node.dummy === \"edge-label\") {\n origLabel.x = node.x;\n origLabel.y = node.y;\n origLabel.width = node.width;\n origLabel.height = node.height;\n }\n v = w;\n node = graph.node(v);\n }\n });\n}\n","import {applyWithChunking} from \"../util\";\nimport type {Edge, EdgeLabel, Graph, GraphLabel, NodeLabel} from \"../types\";\n\nexport {longestPath, slack};\n\n/*\n * Initializes ranks for the input graph using the longest path algorithm. This\n * algorithm scales well and is fast in practice, it yields rather poor\n * solutions. Nodes are pushed to the lowest layer possible, leaving the bottom\n * ranks wide and leaving edges longer than necessary. However, due to its\n * speed, this algorithm is good for getting an initial ranking that can be fed\n * into other algorithms.\n *\n * This algorithm does not normalize layers because it will be used by other\n * algorithms in most cases. If using this algorithm directly, be sure to\n * run normalize at the end.\n *\n * Pre-conditions:\n *\n * 1. Input graph is a DAG.\n * 2. Input graph node labels can be assigned properties.\n *\n * Post-conditions:\n *\n * 1. Each node will be assign an (unnormalized) \"rank\" property.\n */\nfunction longestPath(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n const visited: { [key: string]: boolean } = {};\n\n function dfs(v: string): number {\n const label: NodeLabel = graph.node(v);\n if (Object.hasOwn(visited, v)) {\n return label.rank!;\n }\n visited[v] = true;\n\n const outEdges = graph.outEdges(v);\n const outEdgesMinLens: number[] = outEdges ? outEdges.map(e => {\n if (e == null) {\n return Number.POSITIVE_INFINITY;\n }\n\n return dfs(e.w) - graph.edge(e).minlen!;\n }) : [];\n\n let rank: number = applyWithChunking(Math.min, outEdgesMinLens);\n\n if (rank === Number.POSITIVE_INFINITY) {\n rank = 0;\n }\n\n return (label.rank = rank);\n }\n\n graph.sources().forEach(dfs);\n}\n\n/*\n * Returns the amount of slack for the given edge. The slack is defined as the\n * difference between the length of the edge and its minimum length.\n */\nfunction slack(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>, edge: Edge): number {\n return graph.node(edge.w).rank! - graph.node(edge.v).rank! - graph.edge(edge).minlen!;\n}\n","import {Graph} from \"../graph-lib\";\nimport {slack} from \"./util\";\nimport type {Edge, EdgeLabel, GraphLabel, NodeLabel} from \"../types\";\n\n// Internal type for tree node labels\ninterface TreeNodeLabel {\n low?: number;\n lim?: number;\n parent?: string;\n}\n\n// Internal type for tree edge labels\ninterface TreeEdgeLabel {\n cutvalue?: number;\n}\n\nexport default feasibleTree;\nexport type {TreeNodeLabel, TreeEdgeLabel};\n\n/*\n * Constructs a spanning tree with tight edges and adjusted the input node's\n * ranks to achieve this. A tight edge is one that is has a length that matches\n * its \"minlen\" attribute.\n *\n * The basic structure for this function is derived from Gansner, et al., \"A\n * Technique for Drawing Directed Graphs.\"\n *\n * Pre-conditions:\n *\n * 1. Graph must be a DAG.\n * 2. Graph must be connected.\n * 3. Graph must have at least one node.\n * 5. Graph nodes must have been previously assigned a \"rank\" property that\n * respects the \"minlen\" property of incident edges.\n * 6. Graph edges must have a \"minlen\" property.\n *\n * Post-conditions:\n *\n * - Graph nodes will have their rank adjusted to ensure that all edges are\n * tight.\n *\n * Returns a tree (undirected graph) that is constructed using only \"tight\"\n * edges.\n */\nfunction feasibleTree(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): Graph<object, TreeNodeLabel, TreeEdgeLabel> {\n const tree = new Graph<object, TreeNodeLabel, TreeEdgeLabel>({directed: false});\n\n // Choose arbitrary node from which to start our tree\n const nodes = graph.nodes();\n if (nodes.length === 0) {\n throw new Error(\"Graph must have at least one node\");\n }\n const start: string = nodes[0]!;\n const size: number = graph.nodeCount();\n tree.setNode(start, {});\n\n let edge: Edge | null;\n let delta: number;\n while (tightTree(tree, graph) < size) {\n edge = findMinSlackEdge(tree, graph);\n if (!edge) break;\n delta = tree.hasNode(edge.v) ? slack(graph, edge) : -slack(graph, edge);\n shiftRanks(tree, graph, delta);\n }\n\n return tree;\n}\n\n/*\n * Finds a maximal tree of tight edges and returns the number of nodes in the\n * tree.\n */\nfunction tightTree(tree: Graph<object, TreeNodeLabel, TreeEdgeLabel>, graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): number {\n function dfs(v: string): void {\n const nodeEdges = graph.nodeEdges(v);\n if (nodeEdges) {\n nodeEdges.forEach(e => {\n const edgeV: string = e.v;\n const w: string = (v === edgeV) ? e.w : edgeV;\n if (!tree.hasNode(w) && !slack(graph, e)) {\n tree.setNode(w, {});\n tree.setEdge(v, w, {});\n dfs(w);\n }\n });\n }\n }\n\n tree.nodes().forEach(dfs);\n return tree.nodeCount();\n}\n\n/*\n * Finds the edge with the smallest slack that is incident on tree and returns\n * it.\n */\nfunction findMinSlackEdge(tree: Graph<object, TreeNodeLabel, TreeEdgeLabel>, graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): Edge | null {\n const edges: Edge[] = graph.edges();\n\n return edges.reduce((acc: [number, Edge | null], edge: Edge): [number, Edge | null] => {\n let edgeSlack: number = Number.POSITIVE_INFINITY;\n if (tree.hasNode(edge.v) !== tree.hasNode(edge.w)) {\n edgeSlack = slack(graph, edge);\n }\n\n if (edgeSlack < acc[0]) {\n return [edgeSlack, edge];\n }\n\n return acc;\n }, [Number.POSITIVE_INFINITY, null])[1];\n}\n\nfunction shiftRanks(tree: Graph<object, TreeNodeLabel, TreeEdgeLabel>, graph: Graph<GraphLabel, NodeLabel, EdgeLabel>, delta: number): void {\n tree.nodes().forEach(v => graph.node(v).rank! += delta);\n}\n","import feasibleTree, {type TreeEdgeLabel, type TreeNodeLabel} from \"./feasible-tree\";\nimport {longestPath as initRank, slack} from \"./util\";\nimport {alg} from \"../graph-lib\";\nimport {simplify} from \"../util\";\nimport type {Edge, EdgeLabel, Graph, GraphLabel, NodeLabel} from \"../types\";\n\nconst {preorder, postorder} = alg;\n\nexport default networkSimplex;\n\n// Expose some internals for testing purposes\nnetworkSimplex.initLowLimValues = initLowLimValues;\nnetworkSimplex.initCutValues = initCutValues;\nnetworkSimplex.calcCutValue = calcCutValue;\nnetworkSimplex.leaveEdge = leaveEdge;\nnetworkSimplex.enterEdge = enterEdge;\nnetworkSimplex.exchangeEdges = exchangeEdges;\n\n/*\n * The network simplex algorithm assigns ranks to each node in the input graph\n * and iteratively improves the ranking to reduce the length of edges.\n *\n * Preconditions:\n *\n * 1. The input graph must be a DAG.\n * 2. All nodes in the graph must have an object value.\n * 3. All edges in the graph must have \"minlen\" and \"weight\" attributes.\n *\n * Postconditions:\n *\n * 1. All nodes in the graph will have an assigned \"rank\" attribute that has\n * been optimized by the network simplex algorithm. Ranks start at 0.\n *\n *\n * A rough sketch of the algorithm is as follows:\n *\n * 1. Assign initial ranks to each node. We use the longest path algorithm,\n * which assigns ranks to the lowest position possible. In general this\n * leads to very wide bottom ranks and unnecessarily long edges.\n * 2. Construct a feasible tight tree. A tight tree is one such that all\n * edges in the tree have no slack (difference between length of edge\n * and minlen for the edge). This by itself greatly improves the assigned\n * rankings by shorting edges.\n * 3. Iteratively find edges that have negative cut values. Generally a\n * negative cut value indicates that the edge could be removed and a new\n * tree edge could be added to produce a more compact graph.\n *\n * Much of the algorithms here are derived from Gansner, et al., \"A Technique\n * for Drawing Directed Graphs.\" The structure of the file roughly follows the\n * structure of the overall algorithm.\n */\nfunction networkSimplex(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n graph = simplify(graph as Graph<GraphLabel, NodeLabel, EdgeLabel>) as Graph<GraphLabel, NodeLabel, EdgeLabel>;\n initRank(graph);\n\n const t = feasibleTree(graph);\n initLowLimValues(t);\n initCutValues(t, graph);\n\n let e: Edge | undefined;\n let f: Edge;\n while ((e = leaveEdge(t))) {\n f = enterEdge(t, graph, e);\n exchangeEdges(t, graph, e, f);\n }\n}\n\n/*\n * Initializes cut values for all edges in the tree.\n */\nfunction initCutValues(tree: Graph<object, TreeNodeLabel, TreeEdgeLabel>, graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n let visitedNodes: string[] = postorder(tree, tree.nodes());\n visitedNodes = visitedNodes.slice(0, visitedNodes.length - 1);\n visitedNodes.forEach(v => assignCutValue(tree, graph, v));\n}\n\nfunction assignCutValue(tree: Graph<object, TreeNodeLabel, TreeEdgeLabel>, graph: Graph<GraphLabel, NodeLabel, EdgeLabel>, child: string): void {\n const childLab: TreeNodeLabel = tree.node(child);\n const parent: string = childLab.parent!;\n const edge = tree.edge(child, parent);\n edge.cutvalue = calcCutValue(tree, graph, child);\n}\n\n/*\n * Given the tight tree, its graph, and a child in the graph calculate and\n * return the cut value for the edge between the child and its parent.\n */\nfunction calcCutValue(tree: Graph<object, TreeNodeLabel, TreeEdgeLabel>, graph: Graph<GraphLabel, NodeLabel, EdgeLabel>, child: string): number {\n const childLab: TreeNodeLabel = tree.node(child);\n const parent: string = childLab.parent!;\n // True if the child is on the tail end of the edge in the directed graph\n let childIsTail: boolean = true;\n // The graph's view of the tree edge we're inspecting\n let graphEdge: EdgeLabel | undefined = graph.edge(child, parent);\n // The accumulated cut value for the edge between this node and its parent\n let cutValue: number = 0;\n\n if (!graphEdge) {\n childIsTail = false;\n graphEdge = graph.edge(parent, child);\n }\n\n cutValue = graphEdge.weight!;\n\n const nodeEdges = graph.nodeEdges(child);\n if (nodeEdges) {\n nodeEdges.forEach(edge => {\n const isOutEdge: boolean = edge.v === child;\n const other: string = isOutEdge ? edge.w : edge.v;\n\n if (other !== parent) {\n const pointsToHead: boolean = isOutEdge === childIsTail;\n const otherWeight: number = graph.edge(edge).weight!;\n\n cutValue += pointsToHead ? otherWeight : -otherWeight;\n if (isTreeEdge(tree, child, other)) {\n const treeEdge = tree.edge(child, other);\n const otherCutValue: number = treeEdge.cutvalue!;\n cutValue += pointsToHead ? -otherCutValue : otherCutValue;\n }\n }\n });\n }\n\n return cutValue;\n}\n\nfunction initLowLimValues(tree: Graph<object, TreeNodeLabel, TreeEdgeLabel>, root?: string): void {\n if (arguments.length < 2) {\n root = tree.nodes()[0];\n }\n dfsAssignLowLim(tree, {}, 1, root!);\n}\n\nfunction dfsAssignLowLim(tree: Graph<object, TreeNodeLabel, TreeEdgeLabel>, visited: {\n [key: string]: boolean\n}, nextLim: number, v: string, parent?: string): number {\n const low: number = nextLim;\n const label: TreeNodeLabel = tree.node(v);\n\n visited[v] = true;\n const neighbors = tree.neighbors(v);\n if (neighbors) {\n neighbors.forEach(w => {\n if (!Object.hasOwn(visited, w)) {\n nextLim = dfsAssignLowLim(tree, visited, nextLim, w, v);\n }\n });\n }\n\n label.low = low;\n label.lim = nextLim++;\n if (parent) {\n label.parent = parent;\n } else {\n // TODO should be able to remove this when we incrementally update low lim\n delete label.parent;\n }\n\n return nextLim;\n}\n\nfunction leaveEdge(tree: Graph<object, TreeNodeLabel, TreeEdgeLabel>): Edge | undefined {\n return tree.edges().find(e => {\n const edge = tree.edge(e);\n return edge.cutvalue! < 0;\n });\n}\n\nfunction enterEdge(tree: Graph<object, TreeNodeLabel, TreeEdgeLabel>, graph: Graph<GraphLabel, NodeLabel, EdgeLabel>, edge: Edge): Edge {\n let v: string = edge.v;\n let w: string = edge.w;\n\n // For the rest of this function we assume that v is the tail and w is the\n // head, so if we don't have this edge in the graph we should flip it to\n // match the correct orientation.\n if (!graph.hasEdge(v, w)) {\n v = edge.w;\n w = edge.v;\n }\n\n const vLabel: TreeNodeLabel = tree.node(v);\n const wLabel: TreeNodeLabel = tree.node(w);\n let tailLabel: TreeNodeLabel = vLabel;\n let flip: boolean = false;\n\n // If the root is in the tail of the edge then we need to flip the logic that\n // checks for the head and tail nodes in the candidates function below.\n if (vLabel.lim! > wLabel.lim!) {\n tailLabel = wLabel;\n flip = true;\n }\n\n const candidates: Edge[] = graph.edges().filter(edge => {\n return flip === isDescendant(tree, tree.node(edge.v), tailLabel) &&\n flip !== isDescendant(tree, tree.node(edge.w), tailLabel);\n });\n\n return candidates.reduce((acc: Edge, edge: Edge): Edge => {\n if (slack(graph, edge) < slack(graph, acc)) {\n return edge;\n }\n\n return acc;\n });\n}\n\nfunction exchangeEdges(t: Graph<object, TreeNodeLabel, TreeEdgeLabel>, g: Graph<GraphLabel, NodeLabel, EdgeLabel>, e: Edge, f: Edge): void {\n const v: string = e.v;\n const w: string = e.w;\n t.removeEdge(v, w);\n t.setEdge(f.v, f.w, {});\n initLowLimValues(t);\n initCutValues(t, g);\n updateRanks(t, g);\n}\n\nfunction updateRanks(t: Graph<object, TreeNodeLabel, TreeEdgeLabel>, g: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n const root: string | undefined = t.nodes().find(v => {\n const node = t.node(v);\n return !node.parent;\n });\n if (!root) return;\n\n let vs: string[] = preorder(t, [root]);\n vs = vs.slice(1);\n vs.forEach(v => {\n const treeNode = t.node(v);\n const parent: string = treeNode.parent!;\n let edge: EdgeLabel | undefined = g.edge(v, parent);\n let flipped: boolean = false;\n\n if (!edge) {\n edge = g.edge(parent, v);\n flipped = true;\n }\n\n g.node(v).rank = g.node(parent).rank! + (flipped ? edge!.minlen! : -edge!.minlen!);\n });\n}\n\n/*\n * Returns true if the edge is in the tree.\n */\nfunction isTreeEdge(tree: Graph<object, TreeNodeLabel, TreeEdgeLabel>, u: string, v: string): boolean {\n return tree.hasEdge(u, v);\n}\n\n/*\n * Returns true if the specified node is descendant of the root node per the\n * assigned low and lim attributes in the tree.\n */\nfunction isDescendant(tree: Graph<object, TreeNodeLabel, TreeEdgeLabel>, vLabel: TreeNodeLabel, rootLabel: TreeNodeLabel): boolean {\n return rootLabel.low! <= vLabel.lim! && vLabel.lim! <= rootLabel.lim!;\n}\n","import {longestPath} from \"./util\";\nimport feasibleTree from \"./feasible-tree\";\nimport networkSimplex from \"./network-simplex\";\nimport type {EdgeLabel, Graph, GraphLabel, NodeLabel, RankerFunction} from \"../types\";\n\nexport default rank;\n\n/*\n * Assigns a rank to each node in the input graph that respects the \"minlen\"\n * constraint specified on edges between nodes.\n *\n * This basic structure is derived from Gansner, et al., \"A Technique for\n * Drawing Directed Graphs.\"\n *\n * Pre-conditions:\n *\n * 1. Graph must be a connected DAG\n * 2. Graph nodes must be objects\n * 3. Graph edges must have \"weight\" and \"minlen\" attributes\n *\n * Post-conditions:\n *\n * 1. Graph nodes will have a \"rank\" attribute based on the results of the\n * algorithm. Ranks can start at any index (including negative), we'll\n * fix them up later.\n */\nfunction rank(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n const ranker: RankerFunction | string | undefined = graph.graph().ranker;\n if (typeof ranker === 'function') {\n return (ranker as RankerFunction)(graph);\n }\n switch (ranker) {\n case \"network-simplex\":\n networkSimplexRanker(graph);\n break;\n case \"tight-tree\":\n tightTreeRanker(graph);\n break;\n case \"longest-path\":\n longestPathRanker(graph);\n break;\n case \"none\":\n break;\n default:\n networkSimplexRanker(graph);\n }\n}\n\n// A fast and simple ranker, but results are far from optimal.\nconst longestPathRanker: RankerFunction = longestPath;\n\nfunction tightTreeRanker(g: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n longestPath(g);\n feasibleTree(g);\n}\n\nfunction networkSimplexRanker(g: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n networkSimplex(g);\n}\n","import type {Edge, EdgeLabel, Graph, GraphLabel, NodeLabel} from \"./types\";\nimport {GRAPH_NODE} from \"./util\";\n\nexport default parentDummyChains;\n\ninterface PostorderNum {\n low: number;\n lim: number;\n}\n\ninterface PathData {\n path: (string | undefined)[];\n lca: string | undefined;\n}\n\nfunction parentDummyChains(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n const postorderNums: { [key: string]: PostorderNum } = postorder(graph);\n\n graph.graph().dummyChains!.forEach(v => {\n let node: NodeLabel = graph.node(v);\n const edgeObj: Edge = node.edgeObj!;\n const pathData: PathData = findPath(graph, postorderNums, edgeObj.v, edgeObj.w);\n const path: (string | undefined)[] = pathData.path;\n const lca: string | undefined = pathData.lca;\n let pathIdx: number = 0;\n let pathV: string | undefined = path[pathIdx];\n let ascending: boolean = true;\n\n while (v !== edgeObj.w) {\n node = graph.node(v);\n\n if (ascending) {\n while ((pathV = path[pathIdx]) !== lca &&\n graph.node(pathV!).maxRank! < node.rank!) {\n pathIdx++;\n }\n\n if (pathV === lca) {\n ascending = false;\n }\n }\n\n if (!ascending) {\n while (pathIdx < path.length - 1 &&\n graph.node((path[pathIdx + 1])!).minRank! <= node.rank!) {\n pathIdx++;\n }\n pathV = path[pathIdx];\n }\n\n if (pathV !== undefined) {\n graph.setParent(v, pathV);\n }\n v = graph.successors(v)![0]!;\n }\n });\n}\n\n// Find a path from v to w through the lowest common ancestor (LCA). Return the\n// full path and the LCA.\nfunction findPath(\n graph: Graph<GraphLabel, NodeLabel, EdgeLabel>,\n postorderNums: { [key: string]: PostorderNum },\n v: string,\n w: string\n): PathData {\n const vPath: (string | undefined)[] = [];\n const wPath: (string | undefined)[] = [];\n const low: number = Math.min(postorderNums[v]!.low, postorderNums[w]!.low);\n const lim: number = Math.max(postorderNums[v]!.lim, postorderNums[w]!.lim);\n let parent: string | undefined;\n\n // Traverse up from v to find the LCA\n parent = v;\n do {\n parent = graph.parent(parent) as string | undefined;\n vPath.push(parent);\n } while (parent &&\n (postorderNums[parent]!.low > low || lim > postorderNums[parent]!.lim));\n const lca = parent;\n\n // Traverse from w to LCA\n let wParent: string = w;\n while ((wParent = graph.parent(wParent) as string) !== lca) {\n wPath.push(wParent);\n }\n\n return {path: vPath.concat(wPath.reverse()), lca: lca};\n}\n\nfunction postorder(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): { [key: string]: PostorderNum } {\n const result: { [key: string]: PostorderNum } = {};\n let lim: number = 0;\n\n function dfs(v: string): void {\n const low: number = lim;\n graph.children(v).forEach(dfs);\n result[v] = {low: low, lim: lim++};\n }\n\n graph.children(GRAPH_NODE).forEach(dfs);\n\n return result;\n}\n","import {addBorderNode, addDummyNode, applyWithChunking, GRAPH_NODE} from \"./util\";\nimport type {EdgeLabel, Graph, GraphLabel, NodeLabel} from \"./types\";\n\nexport {\n run,\n cleanup,\n};\n\n/*\n * A nesting graph creates dummy nodes for the tops and bottoms of subgraphs,\n * adds appropriate edges to ensure that all cluster nodes are placed between\n * these boundaries, and ensures that the graph is connected.\n *\n * In addition we ensure, through the use of the minlen property, that nodes\n * and subgraph border nodes to not end up on the same rank.\n *\n * Preconditions:\n *\n * 1. Input graph is a DAG\n * 2. Nodes in the input graph has a minlen attribute\n *\n * Postconditions:\n *\n * 1. Input graph is connected.\n * 2. Dummy nodes are added for the tops and bottoms of subgraphs.\n * 3. The minlen attribute for nodes is adjusted to ensure nodes do not\n * get placed on the same rank as subgraph border nodes.\n *\n * The nesting graph idea comes from Sander, \"Layout of Compound Directed\n * Graphs.\"\n */\nfunction run(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n const root: string = addDummyNode(graph, \"root\", {}, \"_root\");\n const depths: { [key: string]: number } = treeDepths(graph);\n const depthsArr: number[] = Object.values(depths);\n const height: number = applyWithChunking(Math.max, depthsArr) - 1; // Note: depths is an Object not an array\n const nodeSep: number = 2 * height + 1;\n\n graph.graph().nestingRoot = root;\n\n // Multiply minlen by nodeSep to align nodes on non-border ranks.\n graph.edges().forEach(e => graph.edge(e).minlen! *= nodeSep);\n\n // Calculate a weight that is sufficient to keep subgraphs vertically compact\n const weight: number = sumWeights(graph) + 1;\n\n // Create border nodes and link them up\n graph.children(GRAPH_NODE).forEach(child => dfs(graph, root, nodeSep, weight, height, depths, child));\n\n // Save the multiplier for node layers for later removal of empty border\n // layers.\n graph.graph().nodeRankFactor = nodeSep;\n}\n\nfunction dfs(\n graph: Graph<GraphLabel, NodeLabel, EdgeLabel>,\n root: string,\n nodeSep: number,\n weight: number,\n height: number,\n depths: { [key: string]: number },\n v: string\n): void {\n const children: string[] = graph.children(v);\n if (!children.length) {\n if (v !== root) {\n graph.setEdge(root, v, {weight: 0, minlen: nodeSep});\n }\n return;\n }\n\n const top: string = addBorderNode(graph, \"_bt\");\n const bottom: string = addBorderNode(graph, \"_bb\");\n const label: NodeLabel = graph.node(v);\n\n graph.setParent(top, v);\n label.borderTop = top;\n graph.setParent(bottom, v);\n label.borderBottom = bottom;\n\n children.forEach(child => {\n dfs(graph, root, nodeSep, weight, height, depths, child);\n\n const childNode: NodeLabel = graph.node(child);\n const childTop: string = childNode.borderTop ? childNode.borderTop : child;\n const childBottom: string = childNode.borderBottom ? childNode.borderBottom : child;\n const thisWeight: number = childNode.borderTop ? weight : 2 * weight;\n const minlen: number = childTop !== childBottom ? 1 : height - (depths[v] ?? 0) + 1;\n\n graph.setEdge(top, childTop, {\n weight: thisWeight,\n minlen: minlen,\n nestingEdge: true\n });\n\n graph.setEdge(childBottom, bottom, {\n weight: thisWeight,\n minlen: minlen,\n nestingEdge: true\n });\n });\n\n if (!graph.parent(v)) {\n graph.setEdge(root, top, {weight: 0, minlen: height + (depths[v] ?? 0)});\n }\n}\n\nfunction treeDepths(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): { [key: string]: number } {\n const depths: { [key: string]: number } = {};\n\n function dfs(v: string, depth: number): void {\n const children: string[] = graph.children(v);\n if (children && children.length) {\n children.forEach(child => dfs(child, depth + 1));\n }\n depths[v] = depth;\n }\n\n graph.children(GRAPH_NODE).forEach(v => dfs(v, 1));\n return depths;\n}\n\nfunction sumWeights(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): number {\n return graph.edges().reduce((acc, e) => acc + graph.edge(e).weight!, 0);\n}\n\nfunction cleanup(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n const graphLabel: GraphLabel = graph.graph();\n graph.removeNode(graphLabel.nestingRoot!);\n delete graphLabel.nestingRoot;\n graph.edges().forEach(e => {\n const edge: EdgeLabel = graph.edge(e);\n if (edge.nestingEdge) {\n graph.removeEdge(e);\n }\n });\n}\n","import {addDummyNode, GRAPH_NODE} from \"./util\";\nimport type {EdgeLabel, Graph, GraphLabel, NodeLabel} from \"./types\";\n\nexport default addBorderSegments;\n\nfunction addBorderSegments(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n function dfs(v: string): void {\n const children: string[] = graph.children(v);\n const node = graph.node(v);\n if (children.length) {\n children.forEach(dfs);\n }\n\n if (Object.hasOwn(node, \"minRank\")) {\n node.borderLeft = [];\n node.borderRight = [];\n for (let rank: number = node.minRank!, maxRank: number = node.maxRank! + 1;\n rank < maxRank;\n ++rank) {\n addBorderNode(graph, \"borderLeft\", \"_bl\", v, node, rank);\n addBorderNode(graph, \"borderRight\", \"_br\", v, node, rank);\n }\n }\n }\n\n graph.children(GRAPH_NODE).forEach(dfs);\n}\n\nfunction addBorderNode(\n graph: Graph<GraphLabel, NodeLabel, EdgeLabel>,\n prop: \"borderLeft\" | \"borderRight\",\n prefix: string,\n sg: string,\n sgNode: EdgeLabel,\n rank: number\n): void {\n const label: Partial<NodeLabel> = {width: 0, height: 0, rank: rank, borderType: prop};\n const prev: string | undefined = (sgNode[prop] as string[])[rank - 1];\n const curr: string = addDummyNode(graph, \"border\", label, prefix);\n (sgNode[prop] as string[])[rank] = curr;\n graph.setParent(curr, sg);\n if (prev) {\n graph.setEdge(prev, curr, {weight: 1});\n }\n}\n","import type {EdgeLabel, Graph, GraphLabel, NodeLabel, Point} from './types';\n\nexport function adjust(graph: Graph): void {\n const rankDir = (graph.graph() as GraphLabel).rankdir?.toLowerCase();\n if (rankDir === 'lr' || rankDir === 'rl') {\n swapWidthHeight(graph);\n }\n}\n\nexport function undo(graph: Graph): void {\n const rankDir = (graph.graph() as GraphLabel).rankdir?.toLowerCase();\n if (rankDir === 'bt' || rankDir === 'rl') {\n reverseY(graph);\n }\n\n if (rankDir === 'lr' || rankDir === 'rl') {\n swapXY(graph);\n swapWidthHeight(graph);\n }\n}\n\nfunction swapWidthHeight(graph: Graph): void {\n graph.nodes().forEach(node => swapWidthHeightOne(graph.node(node) as NodeLabel));\n graph.edges().forEach(edge => swapWidthHeightOne(graph.edge(edge) as EdgeLabel));\n}\n\nfunction swapWidthHeightOne(attrs: NodeLabel | EdgeLabel): void {\n const w = attrs.width;\n attrs.width = attrs.height;\n attrs.height = w;\n}\n\nfunction reverseY(graph: Graph): void {\n graph.nodes().forEach(node => reverseYOne(graph.node(node) as NodeLabel));\n\n graph.edges().forEach(edge => {\n const edgeLabel = graph.edge(edge) as EdgeLabel;\n edgeLabel.points?.forEach(reverseYOne);\n if (Object.hasOwn(edgeLabel, 'y')) {\n reverseYOne(edgeLabel);\n }\n });\n}\n\nfunction reverseYOne(attrs: NodeLabel | EdgeLabel | Point): void {\n attrs.y = -attrs.y!;\n}\n\nfunction swapXY(graph: Graph): void {\n graph.nodes().forEach(node => swapXYOne(graph.node(node) as NodeLabel));\n\n graph.edges().forEach(edge => {\n const edgeLabel = graph.edge(edge) as EdgeLabel;\n edgeLabel.points?.forEach(swapXYOne);\n if (Object.hasOwn(edgeLabel, 'x')) {\n swapXYOne(edgeLabel);\n }\n });\n}\n\nfunction swapXYOne(attrs: NodeLabel | EdgeLabel | Point): void {\n const x = attrs.x;\n attrs.x = attrs.y;\n attrs.y = x;\n}\n","import * as util from \"../util\";\nimport type {Graph} from '../types';\n\n/*\n * Assigns an initial order value for each node by performing a DFS search\n * starting from nodes in the first rank. Nodes are assigned an order in their\n * rank as they are first visited.\n *\n * This approach comes from Gansner, et al., \"A Technique for Drawing Directed\n * Graphs.\"\n *\n * Returns a layering matrix with an array per layer and each layer sorted by\n * the order of its nodes.\n */\nexport default function initOrder(graph: Graph): string[][] {\n const visited: { [key: string]: boolean } = {};\n const simpleNodes = graph.nodes().filter(v => !graph.children(v).length);\n const simpleNodesRanks = simpleNodes.map(v => graph.node(v).rank);\n const maxRank = util.applyWithChunking(Math.max, simpleNodesRanks);\n const layers: string[][] = util.range(maxRank + 1).map(() => []);\n\n function dfs(v: string): void {\n if (visited[v]) return;\n visited[v] = true;\n const node = graph.node(v);\n layers[node.rank]!.push(v);\n const successors = graph.successors(v);\n if (successors) {\n successors.forEach(dfs);\n }\n }\n\n const orderedVs = simpleNodes.sort((a, b) => graph.node(a).rank - graph.node(b).rank);\n orderedVs.forEach(dfs);\n\n return layers;\n}\n","import {zipObject} from \"../util\";\nimport type {Graph} from '../types';\n\n/*\n * A function that takes a layering (an array of layers, each with an array of\n * ordererd nodes) and a graph and returns a weighted crossing count.\n *\n * Pre-conditions:\n *\n * 1. Input graph must be simple (not a multigraph), directed, and include\n * only simple edges.\n * 2. Edges in the input graph must have assigned weights.\n *\n * Post-conditions:\n *\n * 1. The graph and layering matrix are left unchanged.\n *\n * This algorithm is derived from Barth, et al., \"Bilayer Cross Counting.\"\n */\nexport default function crossCount(graph: Graph, layering: string[][]): number {\n let cc = 0;\n for (let i = 1; i < layering.length; ++i) {\n cc += twoLayerCrossCount(graph, layering[i - 1]!, layering[i]!);\n }\n return cc;\n}\n\ninterface SouthEntry {\n pos: number;\n weight: number;\n}\n\nfunction twoLayerCrossCount(graph: Graph, northLayer: string[], southLayer: string[]): number {\n // Sort all of the edges between the north and south layers by their position\n // in the north layer and then the south. Map these edges to the position of\n // their head in the south layer.\n const southPos: { [key: string]: number } = zipObject(southLayer, southLayer.map((v, i) => i));\n const southEntries: SouthEntry[] = northLayer.flatMap(v => {\n const edges = graph.outEdges(v);\n if (!edges) return [];\n return edges.map(e => {\n return {pos: southPos[e.w]!, weight: graph.edge(e).weight};\n }).sort((a, b) => a.pos - b.pos);\n });\n\n // Build the accumulator tree\n let firstIndex = 1;\n while (firstIndex < southLayer.length) firstIndex <<= 1;\n const treeSize = 2 * firstIndex - 1;\n firstIndex -= 1;\n const tree = new Array(treeSize).fill(0);\n\n // Calculate the weighted crossings\n let cc = 0;\n southEntries.forEach((entry: SouthEntry) => {\n let index = entry.pos + firstIndex;\n tree[index] += entry.weight;\n let weightSum = 0;\n while (index > 0) {\n if (index % 2) {\n weightSum += tree[index + 1];\n }\n index = (index - 1) >> 1;\n tree[index] += entry.weight;\n }\n cc += entry.weight * weightSum;\n });\n\n return cc;\n}\n","import type {Graph} from '../types';\n\ninterface BarycenterEntry {\n v: string;\n barycenter?: number;\n weight?: number;\n}\n\nexport default function barycenter(graph: Graph, movable: string[] = []): BarycenterEntry[] {\n return movable.map(v => {\n const inV = graph.inEdges(v);\n if (!inV || !inV.length) {\n return {v: v};\n } else {\n const result = inV.reduce((acc, e) => {\n const edge = graph.edge(e);\n const nodeU = graph.node(e.v);\n return {\n sum: acc.sum + (edge.weight * nodeU.order),\n weight: acc.weight + edge.weight\n };\n }, {sum: 0, weight: 0});\n\n return {\n v: v,\n barycenter: result.sum / result.weight,\n weight: result.weight\n };\n }\n });\n}\n","import * as util from \"../util\";\nimport type {Graph} from '../types';\n\ninterface BarycenterEntry {\n v: string;\n barycenter?: number;\n weight?: number;\n}\n\ninterface MappedEntry {\n indegree: number;\n in: MappedEntry[];\n out: MappedEntry[];\n vs: string[];\n i: number;\n barycenter?: number;\n weight?: number;\n merged?: boolean;\n [key: string]: unknown;\n}\n\nexport interface ResolvedEntry {\n vs: string[];\n i: number;\n barycenter?: number;\n weight?: number;\n}\n\n/*\n * Given a list of entries of the form {v, barycenter, weight} and a\n * constraint graph this function will resolve any conflicts between the\n * constraint graph and the barycenters for the entries. If the barycenters for\n * an entry would violate a constraint in the constraint graph then we coalesce\n * the nodes in the conflict into a new node that respects the contraint and\n * aggregates barycenter and weight information.\n *\n * This implementation is based on the description in Forster, \"A Fast and\n * Simple Hueristic for Constrained Two-Level Crossing Reduction,\" thought it\n * differs in some specific details.\n *\n * Pre-conditions:\n *\n * 1. Each entry has the form {v, barycenter, weight}, or if the node has\n * no barycenter, then {v}.\n *\n * Returns:\n *\n * A new list of entries of the form {vs, i, barycenter, weight}. The list\n * `vs` may either be a singleton or it may be an aggregation of nodes\n * ordered such that they do not violate constraints from the constraint\n * graph. The property `i` is the lowest original index of any of the\n * elements in `vs`.\n */\nexport default function resolveConflicts(entries: BarycenterEntry[], constraintGraph: Graph): ResolvedEntry[] {\n const mappedEntries: { [key: string]: MappedEntry } = {};\n entries.forEach((entry, i) => {\n const tmp: MappedEntry = {\n indegree: 0,\n \"in\": [],\n out: [],\n vs: [entry.v],\n i: i\n };\n if (entry.barycenter !== undefined) {\n tmp.barycenter = entry.barycenter;\n tmp.weight = entry.weight;\n }\n mappedEntries[entry.v] = tmp;\n });\n\n constraintGraph.edges().forEach(e => {\n const entryV = mappedEntries[e.v];\n const entryW = mappedEntries[e.w];\n if (entryV !== undefined && entryW !== undefined) {\n entryW.indegree++;\n entryV.out.push(entryW);\n }\n });\n\n const sourceSet = Object.values(mappedEntries).filter(entry => !entry.indegree);\n\n return doResolveConflicts(sourceSet);\n}\n\nfunction doResolveConflicts(sourceSet: MappedEntry[]): ResolvedEntry[] {\n const entries: MappedEntry[] = [];\n\n function handleIn(vEntry: MappedEntry): (uEntry: MappedEntry) => void {\n return (uEntry: MappedEntry) => {\n if (uEntry.merged) {\n return;\n }\n if (uEntry.barycenter === undefined ||\n vEntry.barycenter === undefined ||\n uEntry.barycenter >= vEntry.barycenter) {\n mergeEntries(vEntry, uEntry);\n }\n };\n }\n\n function handleOut(vEntry: MappedEntry): (wEntry: MappedEntry) => void {\n return (wEntry: MappedEntry) => {\n wEntry[\"in\"].push(vEntry);\n if (--wEntry.indegree === 0) {\n sourceSet.push(wEntry);\n }\n };\n }\n\n while (sourceSet.length) {\n const entry = sourceSet.pop()!;\n entries.push(entry);\n entry[\"in\"].reverse().forEach(handleIn(entry));\n entry.out.forEach(handleOut(entry));\n }\n\n return entries.filter(entry => !entry.merged).map(entry => {\n return util.pick(entry, [\"vs\", \"i\", \"barycenter\", \"weight\"]) as ResolvedEntry;\n }) as ResolvedEntry[];\n}\n\nfunction mergeEntries(target: MappedEntry, source: MappedEntry): void {\n let sum = 0;\n let weight = 0;\n\n if (target.weight) {\n sum += target.barycenter! * target.weight;\n weight += target.weight;\n }\n\n if (source.weight) {\n sum += source.barycenter! * source.weight;\n weight += source.weight;\n }\n\n target.vs = source.vs.concat(target.vs);\n target.barycenter = sum / weight;\n target.weight = weight;\n target.i = Math.min(source.i, target.i);\n source.merged = true;\n}\n","import * as util from \"../util\";\n\ninterface SortEntry {\n vs: string[];\n i: number;\n barycenter?: number;\n weight?: number;\n}\n\ninterface SortResult {\n vs: string[];\n barycenter?: number;\n weight?: number;\n}\n\nexport default function sort(entries: SortEntry[], biasRight?: boolean): SortResult {\n const parts = util.partition(entries, entry => {\n return Object.hasOwn(entry, \"barycenter\");\n });\n const sortable = parts.lhs;\n const unsortable = parts.rhs.sort((a, b) => b.i - a.i);\n const vs: string[][] = [];\n let sum = 0;\n let weight = 0;\n let vsIndex = 0;\n\n sortable.sort(compareWithBias(!!biasRight));\n\n vsIndex = consumeUnsortable(vs, unsortable, vsIndex);\n\n sortable.forEach(entry => {\n vsIndex += entry.vs.length;\n vs.push(entry.vs);\n sum += entry.barycenter! * entry.weight!;\n weight += entry.weight!;\n vsIndex = consumeUnsortable(vs, unsortable, vsIndex);\n });\n\n const result: SortResult = {vs: vs.flat(1) as string[]};\n if (weight) {\n result.barycenter = sum / weight;\n result.weight = weight;\n }\n return result;\n}\n\nfunction consumeUnsortable(vs: string[][], unsortable: SortEntry[], index: number): number {\n let last: SortEntry | undefined;\n while (unsortable.length && (last = unsortable[unsortable.length - 1])!.i <= index) {\n unsortable.pop();\n vs.push(last!.vs);\n index++;\n }\n return index;\n}\n\nfunction compareWithBias(bias: boolean): (entryV: SortEntry, entryW: SortEntry) => number {\n return (entryV: SortEntry, entryW: SortEntry) => {\n if (entryV.barycenter! < entryW.barycenter!) {\n return -1;\n } else if (entryV.barycenter! > entryW.barycenter!) {\n return 1;\n }\n\n return !bias ? entryV.i - entryW.i : entryW.i - entryV.i;\n };\n}\n","import barycenter from \"./barycenter\";\nimport resolveConflicts from \"./resolve-conflicts\";\nimport sort from \"./sort\";\nimport type {Graph} from '../types';\n\ninterface SubgraphResult {\n vs: string[];\n barycenter?: number;\n weight?: number;\n}\n\ninterface BarycenterEntry {\n v: string;\n barycenter?: number;\n weight?: number;\n}\n\nexport default function sortSubgraph(graph: Graph, v: string, constraintGraph: Graph, biasRight?: boolean): SubgraphResult {\n let movable = graph.children(v);\n const node = graph.node(v);\n const bl: string | undefined = node ? (node.borderLeft) : undefined;\n const br: string | undefined = node ? (node.borderRight) : undefined;\n const subgraphs: { [key: string]: SubgraphResult } = {};\n\n if (bl) {\n movable = movable.filter(w => w !== bl && w !== br);\n }\n\n const barycenters = barycenter(graph, movable);\n barycenters.forEach(entry => {\n if (graph.children(entry.v).length) {\n const subgraphResult = sortSubgraph(graph, entry.v, constraintGraph, biasRight);\n subgraphs[entry.v] = subgraphResult;\n if (Object.hasOwn(subgraphResult, \"barycenter\")) {\n mergeBarycenters(entry, subgraphResult);\n }\n }\n });\n\n const entries = resolveConflicts(barycenters, constraintGraph);\n expandSubgraphs(entries, subgraphs);\n\n const result = sort(entries, biasRight);\n\n if (bl && br) {\n result.vs = [bl, result.vs, br].flat(1) as string[];\n const blPredecessors = graph.predecessors(bl);\n if (blPredecessors && blPredecessors.length) {\n const blPred = graph.node(blPredecessors[0]!);\n const brPredecessors = graph.predecessors(br);\n const brPred = graph.node(brPredecessors![0]!);\n if (!Object.hasOwn(result, \"barycenter\")) {\n result.barycenter = 0;\n result.weight = 0;\n }\n result.barycenter = (result.barycenter! * result.weight! +\n blPred.order! + brPred.order!) / (result.weight! + 2);\n result.weight! += 2;\n }\n }\n\n return result;\n}\n\nfunction expandSubgraphs(entries: { vs: string[] }[], subgraphs: { [key: string]: SubgraphResult }): void {\n entries.forEach(entry => {\n entry.vs = entry.vs.flatMap(v => {\n if (subgraphs[v]) {\n return subgraphs[v].vs;\n }\n return v;\n });\n });\n}\n\nfunction mergeBarycenters(target: BarycenterEntry, other: SubgraphResult): void {\n if (target.barycenter !== undefined) {\n target.barycenter = (target.barycenter * target.weight! +\n other.barycenter! * other.weight!) /\n (target.weight! + other.weight!);\n target.weight! += other.weight!;\n } else {\n target.barycenter = other.barycenter;\n target.weight = other.weight;\n }\n}\n","import {Graph} from \"../graph-lib\";\nimport * as util from \"../util\";\nimport type {Graph as GraphType} from '../types';\n\ninterface LayerGraphLabel {\n root: string;\n}\n\n/*\n * Constructs a graph that can be used to sort a layer of nodes. The graph will\n * contain all base and subgraph nodes from the request layer in their original\n * hierarchy and any edges that are incident on these nodes and are of the type\n * requested by the \"relationship\" parameter.\n *\n * Nodes from the requested rank that do not have parents are assigned a root\n * node in the output graph, which is set in the root graph attribute. This\n * makes it easy to walk the hierarchy of movable nodes during ordering.\n *\n * Pre-conditions:\n *\n * 1. Input graph is a DAG\n * 2. Base nodes in the input graph have a rank attribute\n * 3. Subgraph nodes in the input graph has minRank and maxRank attributes\n * 4. Edges have an assigned weight\n * 5. If `nodesWithRank` is not undefined, it must contains only the nodes\n * which belong to `g` and belong to `rank`.\n *\n * Post-conditions:\n *\n * 1. Output graph has all nodes in the movable rank with preserved\n * hierarchy.\n * 2. Root nodes in the movable layer are made children of the node\n * indicated by the root attribute of the graph.\n * 3. Non-movable nodes incident on movable nodes, selected by the\n * relationship parameter, are included in the graph (without hierarchy).\n * 4. Edges incident on movable nodes, selected by the relationship\n * parameter, are added to the output graph.\n * 5. The weights for copied edges are aggregated as need, since the output\n * graph is not a multi-graph.\n */\nexport default function buildLayerGraph(\n graph: GraphType,\n rank: number,\n relationship: \"inEdges\" | \"outEdges\",\n nodesWithRank?: string[]\n): GraphType {\n if (!nodesWithRank) {\n nodesWithRank = graph.nodes();\n }\n const root = createRootNode(graph);\n const result = new Graph({compound: true})\n .setGraph({root: root} as LayerGraphLabel)\n .setDefaultNodeLabel((v: string) => graph.node(v)) as GraphType;\n\n nodesWithRank.forEach((v: string) => {\n const node = graph.node(v);\n const parent = graph.parent(v);\n\n if (node.rank === rank || node.minRank! <= rank && rank <= node.maxRank!) {\n result.setNode(v);\n result.setParent(v, parent || root);\n\n // This assumes we have only short edges!\n const edges = graph[relationship](v);\n if (edges) {\n edges.forEach(e => {\n const u = e.v === v ? e.w : e.v;\n const edge = result.edge(u, v);\n const weight = edge !== undefined ? edge.weight : 0;\n result.setEdge(u, v, {weight: graph.edge(e).weight + weight});\n });\n }\n\n if (Object.hasOwn(node, \"minRank\")) {\n result.setNode(v, {\n borderLeft: node.borderLeft![rank],\n borderRight: node.borderRight![rank]\n });\n }\n }\n });\n\n return result;\n}\n\nfunction createRootNode(graph: GraphType): string {\n let v: string;\n while (graph.hasNode((v = util.uniqueId(\"_root\")))) ;\n return v;\n}\n","import type {Graph} from '../types';\n\nexport default function addSubgraphConstraints(graph: Graph, constraintGraph: Graph, vs: string[]): void {\n const prev: { [key: string]: string } = {};\n let rootPrev: string | undefined;\n\n vs.forEach(v => {\n let child: string | undefined | void = graph.parent(v);\n let parent: string | undefined | void;\n let prevChild: string | undefined;\n while (child) {\n parent = graph.parent(child);\n if (parent) {\n prevChild = prev[parent];\n prev[parent] = child;\n } else {\n prevChild = rootPrev;\n rootPrev = child;\n }\n if (prevChild && prevChild !== child) {\n constraintGraph.setEdge(prevChild, child);\n return;\n }\n child = parent;\n }\n });\n\n /*\n function dfs(v) {\n var children = v ? g.children(v) : g.children();\n if (children.length) {\n var min = Number.POSITIVE_INFINITY,\n subgraphs = [];\n children.forEach(function(child) {\n var childMin = dfs(child);\n if (g.children(child).length) {\n subgraphs.push({ v: child, order: childMin });\n }\n min = Math.min(min, childMin);\n });\n _.sortBy(subgraphs, \"order\").reduce(function(prev, curr) {\n cg.setEdge(prev.v, curr.v);\n return curr;\n });\n return min;\n }\n return g.node(v).order;\n }\n dfs(undefined);\n */\n}\n","import initOrder from \"./init-order\";\nimport crossCount from \"./cross-count\";\nimport sortSubgraph from \"./sort-subgraph\";\nimport buildLayerGraph from \"./build-layer-graph\";\nimport addSubgraphConstraints from \"./add-subgraph-constraints\";\nimport {Graph} from \"../graph-lib\";\nimport * as util from \"../util\";\nimport type {Graph as GraphType, OrderConstraint} from '../types';\n\ninterface OrderOptions {\n customOrder?: (graph: GraphType, order: (g: GraphType, opts: OrderOptions) => void) => void;\n disableOptimalOrderHeuristic?: boolean;\n constraints?: OrderConstraint[];\n}\n\n/*\n * Applies heuristics to minimize edge crossings in the graph and sets the best\n * order solution as an order attribute on each node.\n *\n * Pre-conditions:\n *\n * 1. Graph must be DAG\n * 2. Graph nodes must be objects with a \"rank\" attribute\n * 3. Graph edges must have the \"weight\" attribute\n *\n * Post-conditions:\n *\n * 1. Graph nodes will have an \"order\" attribute based on the results of the\n * algorithm.\n */\nexport default function order(graph: GraphType, opts: OrderOptions = {}): void {\n if (typeof opts.customOrder === 'function') {\n opts.customOrder(graph, order);\n return;\n }\n\n const maxRank = util.maxRank(graph);\n const downLayerGraphs = buildLayerGraphs(graph, util.range(1, maxRank + 1), \"inEdges\");\n const upLayerGraphs = buildLayerGraphs(graph, util.range(maxRank - 1, -1, -1), \"outEdges\");\n\n let layering = initOrder(graph);\n assignOrder(graph, layering);\n\n if (opts.disableOptimalOrderHeuristic) {\n return;\n }\n\n let bestCC = Number.POSITIVE_INFINITY;\n let best: string[][];\n\n const constraints = opts.constraints || [];\n for (let i = 0, lastBest = 0; lastBest < 4; ++i, ++lastBest) {\n sweepLayerGraphs(i % 2 ? downLayerGraphs : upLayerGraphs, i % 4 >= 2, constraints);\n\n layering = util.buildLayerMatrix(graph);\n const cc = crossCount(graph, layering);\n if (cc < bestCC) {\n lastBest = 0;\n best = Object.assign({}, layering);\n bestCC = cc;\n } else if (cc === bestCC) {\n best = structuredClone(layering);\n }\n }\n\n assignOrder(graph, best!);\n}\n\nfunction buildLayerGraphs(graph: GraphType, ranks: number[], relationship: \"inEdges\" | \"outEdges\"): GraphType[] {\n // Build an index mapping from rank to the nodes with that rank.\n // This helps to avoid a quadratic search for all nodes with the same rank as\n // the current node.\n const nodesByRank = new Map<number, string[]>();\n const addNodeToRank = (rank: number, node: string): void => {\n if (!nodesByRank.has(rank)) {\n nodesByRank.set(rank, []);\n }\n nodesByRank.get(rank)!.push(node);\n };\n\n // Visit the nodes in their original order in the graph, and add each\n // node to the ranks(s) that it belongs to.\n for (const v of graph.nodes()) {\n const node = graph.node(v);\n if (typeof node.rank === \"number\") {\n addNodeToRank(node.rank, v);\n }\n // If there is a range of ranks, add it to each, but skip the `node.rank` which\n // has already had the node added.\n if (typeof node.minRank === \"number\" && typeof node.maxRank === \"number\") {\n for (let r = node.minRank; r <= node.maxRank; r++) {\n if (r !== node.rank) {\n // Don't add this node to its `node.rank` twice.\n addNodeToRank(r, v);\n }\n }\n }\n }\n\n return ranks.map(function (rank) {\n return buildLayerGraph(graph, rank, relationship, nodesByRank.get(rank) || []);\n });\n}\n\nfunction sweepLayerGraphs(layerGraphs: GraphType[], biasRight: boolean, constraints: OrderConstraint[]): void {\n const cg = new Graph() as GraphType;\n layerGraphs.forEach(function (lg) {\n constraints.forEach(con => cg.setEdge(con.left, con.right));\n\n const root = (lg.graph() as { root: string }).root;\n const sorted = sortSubgraph(lg, root, cg, biasRight);\n sorted.vs.forEach((v, i) => lg.node(v).order = i);\n addSubgraphConstraints(lg, cg, sorted.vs);\n });\n}\n\nfunction assignOrder(graph: GraphType, layering: string[][]): void {\n Object.values(layering).forEach(layer => layer.forEach((v, i) => graph.node(v).order = i));\n}\n","import {Graph} from \"../graph-lib\";\nimport * as util from \"../util\";\nimport type {EdgeLabel, GraphLabel, NodeLabel} from \"../types\";\n\n/*\n * This module provides coordinate assignment based on Brandes and Köpf, \"Fast\n * and Simple Horizontal Coordinate Assignment.\"\n */\n\nexport {\n positionX,\n findType1Conflicts,\n findType2Conflicts,\n addConflict,\n hasConflict,\n verticalAlignment,\n horizontalCompaction,\n alignCoordinates,\n findSmallestWidthAlignment,\n balance\n};\n\ntype Conflicts = { [key: string]: { [key: string]: boolean } };\ntype PositionMap = { [key: string]: number };\ntype AlignmentResult = { root: { [key: string]: string }, align: { [key: string]: string } };\ntype XssMap = { [key: string]: PositionMap };\n\n/*\n * Marks all edges in the graph with a type-1 conflict with the \"type1Conflict\"\n * property. A type-1 conflict is one where a non-inner segment crosses an\n * inner segment. An inner segment is an edge with both incident nodes marked\n * with the \"dummy\" property.\n *\n * This algorithm scans layer by layer, starting with the second, for type-1\n * conflicts between the current layer and the previous layer. For each layer\n * it scans the nodes from left to right until it reaches one that is incident\n * on an inner segment. It then scans predecessors to determine if they have\n * edges that cross that inner segment. At the end a final scan is done for all\n * nodes on the current rank to see if they cross the last visited inner\n * segment.\n *\n * This algorithm (safely) assumes that a dummy node will only be incident on a\n * single node in the layers being scanned.\n */\nfunction findType1Conflicts(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>, layering: string[][]): Conflicts {\n const conflicts: Conflicts = {};\n\n function visitLayer(prevLayer: string[], layer: string[]): string[] {\n let\n // last visited node in the previous layer that is incident on an inner\n // segment.\n k0 = 0,\n // Tracks the last node in this layer scanned for crossings with a type-1\n // segment.\n scanPos = 0;\n const prevLayerLength = prevLayer.length,\n lastNode = layer[layer.length - 1];\n\n layer.forEach((v, i) => {\n const w: string | undefined = findOtherInnerSegmentNode(graph, v);\n const k1: number = w ? graph.node(w).order! : prevLayerLength;\n\n if (w || v === lastNode) {\n layer.slice(scanPos, i + 1).forEach(scanNode => {\n const preds = graph.predecessors(scanNode);\n if (preds) {\n preds.forEach(u => {\n const uLabel = graph.node(u) as NodeLabel;\n const uPos: number = uLabel.order!;\n if ((uPos < k0 || k1 < uPos) &&\n !(uLabel.dummy && (graph.node(scanNode) as NodeLabel).dummy)) {\n addConflict(conflicts, u, scanNode);\n }\n });\n }\n });\n scanPos = i + 1;\n k0 = k1;\n }\n });\n\n return layer;\n }\n\n if (layering.length) {\n layering.reduce(visitLayer);\n }\n\n return conflicts;\n}\n\nfunction findType2Conflicts(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>, layering: string[][]): Conflicts {\n const conflicts: Conflicts = {};\n\n function scan(south: string[], southPos: number, southEnd: number, prevNorthBorder: number, nextNorthBorder: number): void {\n util.range(southPos, southEnd).forEach(i => {\n const v = south[i];\n if (v === undefined) return;\n if ((graph.node(v) as NodeLabel).dummy) {\n const preds = graph.predecessors(v);\n if (preds) {\n preds.forEach(u => {\n if (u === undefined) return;\n const uNode = graph.node(u) as NodeLabel;\n if (uNode.dummy &&\n (uNode.order! < prevNorthBorder || uNode.order! > nextNorthBorder)) {\n addConflict(conflicts, u, v);\n }\n });\n }\n }\n });\n }\n\n\n function visitLayer(north: string[], south: string[]): string[] {\n let prevNorthPos = -1;\n let nextNorthPos = -1;\n let southPos = 0;\n\n south.forEach((v, southLookahead) => {\n if ((graph.node(v) as NodeLabel).dummy === \"border\") {\n const predecessors = graph.predecessors(v);\n if (predecessors && predecessors.length) {\n const firstPred = predecessors[0];\n if (firstPred === undefined) return;\n nextNorthPos = (graph.node(firstPred) as NodeLabel).order!;\n scan(south, southPos, southLookahead, prevNorthPos, nextNorthPos);\n southPos = southLookahead;\n prevNorthPos = nextNorthPos;\n }\n }\n scan(south, southPos, south.length, nextNorthPos, north.length);\n });\n\n return south;\n }\n\n if (layering.length) {\n layering.reduce(visitLayer);\n }\n\n return conflicts;\n}\n\nfunction findOtherInnerSegmentNode(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>, v: string): string | undefined {\n if ((graph.node(v) as NodeLabel).dummy) {\n const preds = graph.predecessors(v);\n if (preds) {\n return preds.find(u => (graph.node(u) as NodeLabel).dummy);\n }\n }\n return undefined;\n}\n\nfunction addConflict(conflicts: Conflicts, v: string, w: string): void {\n if (v > w) {\n const tmp = v;\n v = w;\n w = tmp;\n }\n\n let conflictsV = conflicts[v];\n if (!conflictsV) {\n conflicts[v] = conflictsV = {};\n }\n conflictsV[w] = true;\n}\n\nfunction hasConflict(conflicts: Conflicts, v: string, w: string): boolean {\n if (v > w) {\n const tmp = v;\n v = w;\n w = tmp;\n }\n const conflictsV = conflicts[v];\n return conflictsV !== undefined && Object.hasOwn(conflictsV, w);\n}\n\n/*\n * Try to align nodes into vertical \"blocks\" where possible. This algorithm\n * attempts to align a node with one of its median neighbors. If the edge\n * connecting a neighbor is a type-1 conflict then we ignore that possibility.\n * If a previous node has already formed a block with a node after the node\n * we're trying to form a block with, we also ignore that possibility - our\n * blocks would be split in that scenario.\n */\nfunction verticalAlignment(\n graph: Graph<GraphLabel, NodeLabel, EdgeLabel>,\n layering: string[][],\n conflicts: Conflicts,\n neighborFn: (v: string) => string[]\n): AlignmentResult {\n const root: { [key: string]: string } = {};\n const align: { [key: string]: string } = {};\n const pos: PositionMap = {};\n\n // We cache the position here based on the layering because the graph and\n // layering may be out of sync. The layering matrix is manipulated to\n // generate different extreme alignments.\n layering.forEach(layer => {\n layer.forEach((v, order) => {\n root[v] = v;\n align[v] = v;\n pos[v] = order;\n });\n });\n\n layering.forEach(layer => {\n let prevIdx = -1;\n layer.forEach(v => {\n const wsRaw = neighborFn(v);\n if (wsRaw && wsRaw.length) {\n const ws: string[] = wsRaw.sort((a, b) => {\n const posA = pos[a];\n const posB = pos[b];\n return (posA !== undefined ? posA : 0) - (posB !== undefined ? posB : 0);\n });\n const mp: number = (ws.length - 1) / 2;\n for (let i = Math.floor(mp), il = Math.ceil(mp); i <= il; ++i) {\n const w: string | undefined = ws[i];\n if (w === undefined) continue;\n const posW = pos[w];\n if (posW !== undefined && align[v] === v &&\n prevIdx < posW &&\n !hasConflict(conflicts, v, w)) {\n const rootW = root[w];\n if (rootW !== undefined) {\n align[w] = v;\n align[v] = root[v] = rootW;\n prevIdx = posW;\n }\n }\n }\n }\n });\n });\n\n return {root: root, align: align};\n}\n\nfunction horizontalCompaction(\n graph: Graph<GraphLabel, NodeLabel, EdgeLabel>,\n layering: string[][],\n root: { [key: string]: string },\n align: { [key: string]: string },\n reverseSep: boolean = false\n): PositionMap {\n // This portion of the algorithm differs from BK due to a number of problems.\n // Instead of their algorithm we construct a new block graph and do two\n // sweeps. The first sweep places blocks with the smallest possible\n // coordinates. The second sweep removes unused space by moving blocks to the\n // greatest coordinates without violating separation.\n const xs: PositionMap = {};\n const blockG: Graph<NodeLabel, EdgeLabel, number> = buildBlockGraph(graph, layering, root, reverseSep);\n const borderType: string = reverseSep ? \"borderLeft\" : \"borderRight\";\n\n function iterate(setXsFunc: (elem: string) => void, nextNodesFunc: (elem: string) => string[]): void {\n const stack: string[] = blockG.nodes().slice(); // Create a copy of the node list.\n const visited: { [key: string]: boolean } = {};\n let elem: string | undefined = stack.pop();\n\n while (elem) {\n if (visited[elem]) {\n setXsFunc(elem);\n } else {\n visited[elem] = true;\n // Put the element back into the stack, so that we can process it\n // again after all of the `nextNodesFunc` items are processed.\n stack.push(elem);\n for (const nextElem of nextNodesFunc(elem)) {\n stack.push(nextElem);\n }\n }\n\n elem = stack.pop();\n }\n }\n\n // First pass, assign smallest coordinates\n function pass1(elem: string): void {\n const inEdges = blockG.inEdges(elem);\n if (inEdges) {\n xs[elem] = inEdges.reduce((acc, e) => {\n const xsV = xs[e.v] ?? 0;\n const edgeWeight = blockG.edge(e);\n return Math.max(acc, xsV + (edgeWeight !== undefined ? edgeWeight : 0));\n }, 0);\n } else {\n xs[elem] = 0;\n }\n }\n\n // Second pass, assign greatest coordinates\n function pass2(elem: string): void {\n const outEdges = blockG.outEdges(elem);\n let min = Number.POSITIVE_INFINITY;\n if (outEdges) {\n min = outEdges.reduce((acc, e) => {\n const xsW = xs[e.w];\n const edgeWeight = blockG.edge(e);\n return Math.min(acc, (xsW !== undefined ? xsW : 0) - (edgeWeight !== undefined ? edgeWeight : 0));\n }, Number.POSITIVE_INFINITY);\n }\n\n const node = graph.node(elem) as NodeLabel;\n if (min !== Number.POSITIVE_INFINITY && node.borderType !== borderType) {\n xs[elem] = Math.max(xs[elem] !== undefined ? xs[elem] : 0, min);\n }\n }\n\n function predecessorsWrapper(elem: string): string[] {\n return blockG.predecessors(elem) || [];\n }\n\n function successorsWrapper(elem: string): string[] {\n return blockG.successors(elem) || [];\n }\n\n iterate(pass1, predecessorsWrapper);\n iterate(pass2, successorsWrapper);\n\n // Assign x coordinates to all nodes\n Object.keys(align).forEach(v => {\n const rootV = root[v];\n if (rootV !== undefined) {\n xs[v] = xs[rootV] ?? 0;\n }\n });\n\n return xs;\n}\n\n\nfunction buildBlockGraph(\n graph: Graph<GraphLabel, NodeLabel, EdgeLabel>,\n layering: string[][],\n root: { [key: string]: string },\n reverseSep: boolean\n): Graph<NodeLabel, EdgeLabel, number> {\n const blockGraph = new Graph<NodeLabel, EdgeLabel, number>();\n const graphLabel: GraphLabel = graph.graph();\n const sepFn: (g: Graph<GraphLabel, NodeLabel, EdgeLabel>, v: string, u: string) => number = sep(graphLabel.nodesep!, graphLabel.edgesep!, reverseSep);\n\n layering.forEach(layer => {\n let u: string | undefined;\n layer.forEach(v => {\n const vRoot = root[v];\n if (vRoot !== undefined) {\n blockGraph.setNode(vRoot);\n if (u !== undefined) {\n const uRoot = root[u];\n if (uRoot !== undefined) {\n const prevMax: number | undefined = blockGraph.edge(uRoot, vRoot);\n blockGraph.setEdge(uRoot, vRoot, Math.max(sepFn(graph, v, u), prevMax || 0));\n }\n }\n u = v;\n }\n });\n });\n\n return blockGraph;\n}\n\n/*\n * Returns the alignment that has the smallest width of the given alignments.\n */\nfunction findSmallestWidthAlignment(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>, xss: XssMap): PositionMap {\n return Object.values(xss).reduce((currentMinAndXs: [number, PositionMap | null], xs: PositionMap) => {\n let max = Number.NEGATIVE_INFINITY;\n let min = Number.POSITIVE_INFINITY;\n\n Object.entries(xs).forEach(([v, x]) => {\n const halfWidth: number = width(graph, v) / 2;\n\n max = Math.max(x + halfWidth, max);\n min = Math.min(x - halfWidth, min);\n });\n\n const newMin: number = max - min;\n if (newMin < currentMinAndXs[0]) {\n currentMinAndXs = [newMin, xs];\n }\n return currentMinAndXs;\n }, [Number.POSITIVE_INFINITY, null])[1]!;\n}\n\n/*\n * Align the coordinates of each of the layout alignments such that\n * left-biased alignments have their minimum coordinate at the same point as\n * the minimum coordinate of the smallest width alignment and right-biased\n * alignments have their maximum coordinate at the same point as the maximum\n * coordinate of the smallest width alignment.\n */\nfunction alignCoordinates(xss: XssMap, alignTo: PositionMap): void {\n const alignToVals: number[] = Object.values(alignTo);\n const alignToMin: number = util.applyWithChunking(Math.min, alignToVals);\n const alignToMax: number = util.applyWithChunking(Math.max, alignToVals);\n\n [\"u\", \"d\"].forEach(vert => {\n [\"l\", \"r\"].forEach(horiz => {\n const alignment: string = vert + horiz;\n const xs: PositionMap | undefined = xss[alignment];\n\n if (!xs || xs === alignTo) return;\n\n const xsVals: number[] = Object.values(xs);\n let delta: number = alignToMin - util.applyWithChunking(Math.min, xsVals);\n if (horiz !== \"l\") {\n delta = alignToMax - util.applyWithChunking(Math.max, xsVals);\n }\n\n if (delta) {\n xss[alignment] = util.mapValues(xs, x => x + delta);\n }\n });\n });\n}\n\nfunction balance(xss: XssMap, align: string | undefined = undefined): PositionMap {\n const ulMap = xss.ul;\n if (!ulMap) {\n return {};\n }\n return util.mapValues(ulMap, (num: number, v: string) => {\n if (align) {\n const alignmentKey = align.toLowerCase();\n const alignment = xss[alignmentKey];\n if (alignment && alignment[v] !== undefined) {\n return alignment[v];\n }\n }\n const xs: number[] = Object.values(xss).map(xs => {\n const val = xs[v];\n return val !== undefined ? val : 0;\n }).sort((a, b) => a - b);\n return ((xs[1] ?? 0) + (xs[2] ?? 0)) / 2;\n });\n}\n\nfunction positionX(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): PositionMap {\n const layering: string[][] = util.buildLayerMatrix(graph);\n const conflicts: Conflicts = Object.assign(\n findType1Conflicts(graph, layering),\n findType2Conflicts(graph, layering));\n\n const xss: XssMap = {};\n let adjustedLayering: string[][];\n [\"u\", \"d\"].forEach(vert => {\n adjustedLayering = vert === \"u\" ? layering : Object.values(layering).reverse();\n [\"l\", \"r\"].forEach(horiz => {\n if (horiz === \"r\") {\n adjustedLayering = adjustedLayering.map(inner => {\n return Object.values(inner).reverse();\n });\n }\n\n const neighborFn = (v: string): string[] => {\n const result = vert === \"u\" ? graph.predecessors(v) : graph.successors(v);\n return result || [];\n };\n const align: AlignmentResult = verticalAlignment(graph, adjustedLayering, conflicts, neighborFn);\n let xs: PositionMap = horizontalCompaction(graph, adjustedLayering,\n align.root, align.align, horiz === \"r\");\n if (horiz === \"r\") {\n xs = util.mapValues(xs, x => -x);\n }\n xss[vert + horiz] = xs;\n });\n });\n\n\n const smallestWidth: PositionMap = findSmallestWidthAlignment(graph, xss);\n alignCoordinates(xss, smallestWidth);\n return balance(xss, graph.graph().align);\n}\n\nfunction sep(nodeSep: number, edgeSep: number, reverseSep: boolean): (g: Graph<GraphLabel, NodeLabel, EdgeLabel>, v: string, w: string) => number {\n return (g: Graph<GraphLabel, NodeLabel, EdgeLabel>, v: string, w: string): number => {\n const vLabel = g.node(v) as NodeLabel;\n const wLabel = g.node(w) as NodeLabel;\n let sum = 0;\n let delta: number | undefined;\n\n sum += vLabel.width / 2;\n if (Object.hasOwn(vLabel, \"labelpos\")) {\n switch ((vLabel.labelpos as string).toLowerCase()) {\n case \"l\":\n delta = -vLabel.width / 2;\n break;\n case \"r\":\n delta = vLabel.width / 2;\n break;\n }\n }\n if (delta) {\n sum += reverseSep ? delta : -delta;\n }\n delta = undefined;\n\n sum += (vLabel.dummy ? edgeSep : nodeSep) / 2;\n sum += (wLabel.dummy ? edgeSep : nodeSep) / 2;\n\n sum += wLabel.width / 2;\n if (Object.hasOwn(wLabel, \"labelpos\")) {\n switch ((wLabel.labelpos as string).toLowerCase()) {\n case \"l\":\n delta = wLabel.width / 2;\n break;\n case \"r\":\n delta = -wLabel.width / 2;\n break;\n }\n }\n if (delta) {\n sum += reverseSep ? delta : -delta;\n }\n\n return sum;\n };\n}\n\nfunction width(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>, v: string): number {\n return (graph.node(v) as NodeLabel).width;\n}\n","import * as util from \"../util\";\nimport {positionX} from \"./bk\";\nimport type {Graph} from '@dagrejs/graphlib';\nimport type {EdgeLabel, GraphLabel, NodeLabel} from \"../types\";\n\nexport {position};\n\nfunction position(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n graph = util.asNonCompoundGraph(graph);\n\n positionY(graph);\n Object.entries(positionX(graph)).forEach(([v, x]) => graph.node(v).x = x);\n}\n\nfunction positionY(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n const layering: string[][] = util.buildLayerMatrix(graph);\n const graphLabel = graph.graph();\n const rankSep: number = graphLabel.ranksep!;\n const rankAlign: string | undefined = graphLabel.rankalign;\n let prevY = 0;\n layering.forEach(layer => {\n const maxHeight: number = layer.reduce((acc: number, v: string) => {\n const height: number = graph.node(v).height ?? 0;\n if (acc > height) {\n return acc;\n } else {\n return height;\n }\n }, 0);\n layer.forEach(v => {\n const node = graph.node(v) as NodeLabel;\n if (rankAlign === \"top\") {\n node.y = prevY + node.height / 2;\n } else if (rankAlign === \"bottom\") {\n node.y = prevY + maxHeight - node.height / 2;\n } else {\n node.y = prevY + maxHeight / 2;\n }\n });\n prevY += maxHeight + rankSep;\n });\n}\n","import * as acyclic from \"./acyclic\";\nimport * as normalize from \"./normalize\";\nimport rank from \"./rank\";\nimport * as util from \"./util\";\nimport {normalizeRanks, removeEmptyRanks} from \"./util\";\nimport parentDummyChains from \"./parent-dummy-chains\";\nimport * as nestingGraph from \"./nesting-graph\";\nimport addBorderSegments from \"./add-border-segments\";\nimport * as coordinateSystem from \"./coordinate-system\";\nimport order from \"./order\";\nimport {position} from \"./position\";\nimport {Graph} from \"./graph-lib\";\nimport type {Edge, EdgeLabel, GraphLabel, LayoutOptions, NodeLabel, Point} from \"./types\";\n\ninterface SelfEdge {\n e: Edge;\n label: EdgeLabel;\n}\n\ninterface ExtendedNodeLabel extends NodeLabel {\n selfEdges?: SelfEdge[];\n}\n\ninterface SelfEdgeNodeLabel extends Omit<NodeLabel, 'e' | 'label'> {\n e: Edge;\n label: EdgeLabel;\n}\n\ninterface EdgeProxyNodeLabel extends Omit<NodeLabel, 'e'> {\n e: Edge;\n}\n\nexport function layout(g: Graph<GraphLabel, NodeLabel, EdgeLabel>, opts: LayoutOptions = {}): Graph<GraphLabel, NodeLabel, EdgeLabel> {\n const time = opts.debugTiming ? util.time : util.notime;\n return time(\"layout\", () => {\n const layoutGraph =\n time(\" buildLayoutGraph\", () => buildLayoutGraph(g));\n time(\" runLayout\", () => runLayout(layoutGraph, time, opts));\n time(\" updateInputGraph\", () => updateInputGraph(g, layoutGraph));\n return layoutGraph;\n });\n}\n\nfunction runLayout(\n g: Graph<GraphLabel, NodeLabel, EdgeLabel>,\n time: <T>(name: string, fn: () => T) => T,\n opts: LayoutOptions\n): void {\n time(\" makeSpaceForEdgeLabels\", () => makeSpaceForEdgeLabels(g));\n time(\" removeSelfEdges\", () => removeSelfEdges(g));\n time(\" acyclic\", () => acyclic.run(g));\n time(\" nestingGraph.run\", () => nestingGraph.run(g));\n time(\" rank\", () => rank(util.asNonCompoundGraph(g)));\n time(\" injectEdgeLabelProxies\", () => injectEdgeLabelProxies(g));\n time(\" removeEmptyRanks\", () => removeEmptyRanks(g));\n time(\" nestingGraph.cleanup\", () => nestingGraph.cleanup(g));\n time(\" normalizeRanks\", () => normalizeRanks(g));\n time(\" assignRankMinMax\", () => assignRankMinMax(g));\n time(\" removeEdgeLabelProxies\", () => removeEdgeLabelProxies(g));\n time(\" normalize.run\", () => normalize.run(g));\n time(\" parentDummyChains\", () => parentDummyChains(g));\n time(\" addBorderSegments\", () => addBorderSegments(g));\n time(\" order\", () => order(g, opts));\n time(\" insertSelfEdges\", () => insertSelfEdges(g));\n time(\" adjustCoordinateSystem\", () => coordinateSystem.adjust(g));\n time(\" position\", () => position(g));\n time(\" positionSelfEdges\", () => positionSelfEdges(g));\n time(\" removeBorderNodes\", () => removeBorderNodes(g));\n time(\" normalize.undo\", () => normalize.undo(g));\n time(\" fixupEdgeLabelCoords\", () => fixupEdgeLabelCoords(g));\n time(\" undoCoordinateSystem\", () => coordinateSystem.undo(g));\n time(\" translateGraph\", () => translateGraph(g));\n time(\" assignNodeIntersects\", () => assignNodeIntersects(g));\n time(\" reversePoints\", () => reversePointsForReversedEdges(g));\n time(\" acyclic.undo\", () => acyclic.undo(g));\n}\n\n/*\n * Copies final layout information from the layout graph back to the input\n * graph. This process only copies whitelisted attributes from the layout graph\n * to the input graph, so it serves as a good place to determine what\n * attributes can influence layout.\n */\nfunction updateInputGraph(\n inputGraph: Graph<GraphLabel, NodeLabel, EdgeLabel>,\n layoutGraph: Graph<GraphLabel, NodeLabel, EdgeLabel>\n): void {\n inputGraph.nodes().forEach(v => {\n const inputLabel = inputGraph.node(v);\n const layoutLabel = layoutGraph.node(v);\n\n if (inputLabel) {\n inputLabel.x = layoutLabel.x;\n inputLabel.y = layoutLabel.y;\n inputLabel.order = layoutLabel.order;\n inputLabel.rank = layoutLabel.rank;\n\n if (layoutGraph.children(v).length) {\n inputLabel.width = layoutLabel.width;\n inputLabel.height = layoutLabel.height;\n }\n }\n });\n\n inputGraph.edges().forEach(e => {\n const inputLabel = inputGraph.edge(e);\n const layoutLabel = layoutGraph.edge(e);\n\n inputLabel.points = layoutLabel.points;\n if (Object.hasOwn(layoutLabel, \"x\")) {\n inputLabel.x = layoutLabel.x;\n inputLabel.y = layoutLabel.y;\n }\n });\n\n inputGraph.graph().width = layoutGraph.graph().width;\n inputGraph.graph().height = layoutGraph.graph().height;\n}\n\nconst graphNumAttrs: string[] = [\"nodesep\", \"edgesep\", \"ranksep\", \"marginx\", \"marginy\"];\nconst graphDefaults: Partial<GraphLabel> = {ranksep: 50, edgesep: 20, nodesep: 50, rankdir: \"TB\", rankalign: \"center\"};\nconst graphAttrs: string[] = [\"acyclicer\", \"ranker\", \"rankdir\", \"align\", \"rankalign\"];\nconst nodeNumAttrs: string[] = [\"width\", \"height\", \"rank\"];\nconst nodeDefaults: Partial<NodeLabel> = {width: 0, height: 0};\nconst edgeNumAttrs: string[] = [\"minlen\", \"weight\", \"width\", \"height\", \"labeloffset\"];\nconst edgeDefaults: Partial<EdgeLabel> = {\n minlen: 1, weight: 1, width: 0, height: 0,\n labeloffset: 10, labelpos: \"r\"\n};\nconst edgeAttrs: string[] = [\"labelpos\"];\n\n/*\n * Constructs a new graph from the input graph, which can be used for layout.\n * This process copies only whitelisted attributes from the input graph to the\n * layout graph. Thus this function serves as a good place to determine what\n * attributes can influence layout.\n */\nfunction buildLayoutGraph(inputGraph: Graph<GraphLabel, NodeLabel, EdgeLabel>): Graph<GraphLabel, NodeLabel, EdgeLabel> {\n const g = new Graph<GraphLabel, NodeLabel, EdgeLabel>({multigraph: true, compound: true});\n const graph = canonicalize(inputGraph.graph());\n\n g.setGraph(Object.assign({},\n graphDefaults,\n selectNumberAttrs(graph, graphNumAttrs),\n util.pick(graph, graphAttrs)));\n\n inputGraph.nodes().forEach(v => {\n const node = canonicalize(inputGraph.node(v));\n const newNode = selectNumberAttrs(node, nodeNumAttrs) as NodeLabel;\n Object.keys(nodeDefaults).forEach(k => {\n if (newNode[k] === undefined) {\n newNode[k] = (nodeDefaults)[k];\n }\n });\n\n g.setNode(v, newNode);\n const parent = inputGraph.parent(v);\n if (parent !== undefined) {\n g.setParent(v, parent);\n }\n });\n\n inputGraph.edges().forEach(e => {\n const edge = canonicalize(inputGraph.edge(e));\n g.setEdge(e, Object.assign({},\n edgeDefaults,\n selectNumberAttrs(edge, edgeNumAttrs),\n util.pick(edge, edgeAttrs)));\n });\n\n return g;\n}\n\n/*\n * This idea comes from the Gansner paper: to account for edge labels in our\n * layout we split each rank in half by doubling minlen and halving ranksep.\n * Then we can place labels at these mid-points between nodes.\n *\n * We also add some minimal padding to the width to push the label for the edge\n * away from the edge itself a bit.\n */\nfunction makeSpaceForEdgeLabels(g: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n const graph = g.graph();\n graph.ranksep! /= 2;\n g.edges().forEach(e => {\n const edge = g.edge(e);\n edge.minlen! *= 2;\n if (edge.labelpos!.toLowerCase() !== \"c\") {\n if (graph.rankdir === \"TB\" || graph.rankdir === \"BT\") {\n edge.width! += edge.labeloffset!;\n } else {\n edge.height! += edge.labeloffset!;\n }\n }\n });\n}\n\n/*\n * Creates temporary dummy nodes that capture the rank in which each edge's\n * label is going to, if it has one of non-zero width and height. We do this\n * so that we can safely remove empty ranks while preserving balance for the\n * label's position.\n */\nfunction injectEdgeLabelProxies(g: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n g.edges().forEach(e => {\n const edge = g.edge(e);\n if (edge.width && edge.height) {\n const v = g.node(e.v);\n const w = g.node(e.w);\n const label: Partial<NodeLabel> = {rank: (w.rank! - v.rank!) / 2 + v.rank!, e: e as unknown as number};\n util.addDummyNode(g, \"edge-proxy\", label, \"_ep\");\n }\n });\n}\n\nfunction assignRankMinMax(g: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n let maxRank = 0;\n g.nodes().forEach(v => {\n const node = g.node(v);\n if (node.borderTop) {\n node.minRank = g.node(node.borderTop).rank;\n node.maxRank = g.node(node.borderBottom!).rank;\n maxRank = Math.max(maxRank, node.maxRank!);\n }\n });\n g.graph().maxRank = maxRank;\n}\n\nfunction removeEdgeLabelProxies(g: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n g.nodes().forEach(v => {\n const node = g.node(v);\n if (node.dummy === \"edge-proxy\") {\n const proxyNode = node as unknown as EdgeProxyNodeLabel;\n g.edge(proxyNode.e).labelRank = node.rank;\n g.removeNode(v);\n }\n });\n}\n\nfunction translateGraph(g: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n let minX = Number.POSITIVE_INFINITY;\n let maxX = 0;\n let minY = Number.POSITIVE_INFINITY;\n let maxY = 0;\n const graphLabel = g.graph();\n const marginX = graphLabel.marginx || 0;\n const marginY = graphLabel.marginy || 0;\n\n function getExtremes(attrs: NodeLabel | EdgeLabel): void {\n const x = attrs.x!;\n const y = attrs.y!;\n const w = attrs.width!;\n const h = attrs.height!;\n minX = Math.min(minX, x - w / 2);\n maxX = Math.max(maxX, x + w / 2);\n minY = Math.min(minY, y - h / 2);\n maxY = Math.max(maxY, y + h / 2);\n }\n\n g.nodes().forEach(v => getExtremes(g.node(v)));\n g.edges().forEach(e => {\n const edge = g.edge(e);\n if (Object.hasOwn(edge, \"x\")) {\n getExtremes(edge);\n }\n });\n\n minX -= marginX;\n minY -= marginY;\n\n g.nodes().forEach(v => {\n const node = g.node(v);\n node.x! -= minX;\n node.y! -= minY;\n });\n\n g.edges().forEach(e => {\n const edge = g.edge(e);\n edge.points!.forEach(p => {\n p.x -= minX;\n p.y -= minY;\n });\n if (Object.hasOwn(edge, \"x\")) {\n edge.x! -= minX;\n }\n if (Object.hasOwn(edge, \"y\")) {\n edge.y! -= minY;\n }\n });\n\n graphLabel.width = maxX - minX + marginX;\n graphLabel.height = maxY - minY + marginY;\n}\n\nfunction assignNodeIntersects(g: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n g.edges().forEach(e => {\n const edge = g.edge(e);\n const nodeV = g.node(e.v);\n const nodeW = g.node(e.w);\n let p1: Point, p2: Point;\n if (!edge.points) {\n edge.points = [];\n p1 = nodeW as Point;\n p2 = nodeV as Point;\n } else {\n p1 = edge.points[0]!;\n p2 = edge.points[edge.points.length - 1]!;\n }\n edge.points.unshift(util.intersectRect(nodeV, p1));\n edge.points.push(util.intersectRect(nodeW, p2));\n });\n}\n\nfunction fixupEdgeLabelCoords(g: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n g.edges().forEach(e => {\n const edge = g.edge(e);\n if (Object.hasOwn(edge, \"x\")) {\n if (edge.labelpos === \"l\" || edge.labelpos === \"r\") {\n edge.width! -= edge.labeloffset!;\n }\n switch (edge.labelpos) {\n case \"l\":\n edge.x! -= edge.width! / 2 + edge.labeloffset!;\n break;\n case \"r\":\n edge.x! += edge.width! / 2 + edge.labeloffset!;\n break;\n }\n }\n });\n}\n\nfunction reversePointsForReversedEdges(g: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n g.edges().forEach(e => {\n const edge = g.edge(e);\n if (edge.reversed) {\n edge.points!.reverse();\n }\n });\n}\n\nfunction removeBorderNodes(g: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n g.nodes().forEach(v => {\n if (g.children(v).length) {\n const node = g.node(v);\n const t = g.node(node.borderTop!);\n const b = g.node(node.borderBottom!);\n const l = g.node(node.borderLeft![node.borderLeft!.length - 1]!);\n const r = g.node(node.borderRight![node.borderRight!.length - 1]!);\n\n node.width = Math.abs(r.x! - l.x!);\n node.height = Math.abs(b.y! - t.y!);\n node.x = l.x! + node.width / 2;\n node.y = t.y! + node.height / 2;\n }\n });\n\n g.nodes().forEach(v => {\n if (g.node(v).dummy === \"border\") {\n g.removeNode(v);\n }\n });\n}\n\nfunction removeSelfEdges(g: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n g.edges().forEach(e => {\n if (e.v === e.w) {\n const node = g.node(e.v) as ExtendedNodeLabel;\n if (!node.selfEdges) {\n node.selfEdges = [];\n }\n node.selfEdges.push({e: e, label: g.edge(e)});\n g.removeEdge(e);\n }\n });\n}\n\nfunction insertSelfEdges(g: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n const layers = util.buildLayerMatrix(g);\n layers.forEach(layer => {\n let orderShift = 0;\n layer.forEach((v, i) => {\n const node = g.node(v) as ExtendedNodeLabel;\n node.order = i + orderShift;\n (node.selfEdges || []).forEach(selfEdge => {\n util.addDummyNode(g, \"selfedge\", {\n width: selfEdge.label.width!,\n height: selfEdge.label.height!,\n rank: node.rank,\n order: i + (++orderShift),\n e: selfEdge.e as unknown as number,\n label: selfEdge.label as unknown as string\n }, \"_se\");\n });\n delete node.selfEdges;\n });\n });\n}\n\nfunction positionSelfEdges(g: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n g.nodes().forEach(v => {\n const node = g.node(v);\n if (node.dummy === \"selfedge\") {\n const selfEdgeNode = node as unknown as SelfEdgeNodeLabel;\n const selfNode = g.node(selfEdgeNode.e.v);\n const x = selfNode.x! + selfNode.width / 2;\n const y = selfNode.y!;\n const dx = node.x! - x;\n const dy = selfNode.height / 2;\n g.setEdge(selfEdgeNode.e, selfEdgeNode.label);\n g.removeNode(v);\n selfEdgeNode.label.points = [\n {x: x + 2 * dx / 3, y: y - dy},\n {x: x + 5 * dx / 6, y: y - dy},\n {x: x + dx, y: y},\n {x: x + 5 * dx / 6, y: y + dy},\n {x: x + 2 * dx / 3, y: y + dy}\n ];\n selfEdgeNode.label.x = node.x;\n selfEdgeNode.label.y = node.y;\n }\n });\n}\n\nfunction selectNumberAttrs(obj: Record<string, unknown>, attrs: string[]): unknown {\n return util.mapValues(util.pick(obj, attrs), Number);\n}\n\nfunction canonicalize(attrs: Record<string, unknown>): Record<string, unknown> {\n const newAttrs: Record<string, unknown> = {};\n if (attrs) {\n Object.entries(attrs).forEach(([k, v]) => {\n if (typeof k === \"string\") {\n k = k.toLowerCase();\n }\n\n newAttrs[k] = v;\n });\n }\n return newAttrs;\n}\n","import * as util from './util';\nimport {Graph} from \"./graph-lib\";\nimport type {NodeLabel} from './types';\n\nexport function debugOrdering(graph: Graph): Graph {\n const layerMatrix = util.buildLayerMatrix(graph);\n\n const h = new Graph({compound: true, multigraph: true}).setGraph({});\n\n graph.nodes().forEach(node => {\n h.setNode(node, {label: node});\n h.setParent(node, 'layer' + (graph.node(node) as NodeLabel).rank);\n });\n\n graph.edges().forEach(edge => h.setEdge(edge.v, edge.w, {}, edge.name));\n\n layerMatrix.forEach((layer, i) => {\n const layerV = 'layer' + i;\n h.setNode(layerV, {rank: 'same'});\n layer.reduce((u, v) => {\n h.setEdge(u, v, {style: 'invis'});\n return v;\n });\n });\n\n return h;\n}\n","/*\n@license\n\nCopyright (c) 2012-2014 Chris Pettitt\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n*/\n\nimport * as graphlib from '@dagrejs/graphlib';\nimport {notime, time} from './lib/util';\nimport {version} from './lib/version';\nimport {layout} from './lib/layout';\nimport {debugOrdering as debug} from './lib/debug';\n\nexport {graphlib};\n\nexport {Graph} from '@dagrejs/graphlib';\nexport {version} from './lib/version';\nexport {layout} from './lib/layout';\nexport {debugOrdering as debug} from './lib/debug';\n\nexport const util = {time, notime};\n\n// Export types\nexport type {\n GraphLabel,\n NodeConfig,\n EdgeConfig,\n LayoutConfig,\n LayoutOptions,\n NodeLabel,\n EdgeLabel,\n Point,\n OrderConstraint,\n WeightFunction,\n RankerFunction,\n Edge\n} from './lib/types';\n\nconst dagre = {\n graphlib,\n version,\n layout,\n debug,\n util: {time, notime},\n};\n\nexport default dagre;\n","/**\n * Renders an entity-relationship diagram as inline SVG.\n *\n * Two-stage layout, computed at render time (pure JS, no DOM, static SVG out):\n * 1. dagre places the entity boxes (layered, no overlap, edges drawn around).\n * 2. each relation is routed at the FIELD level — from the foreign-key row in\n * the source entity to the primary-key row in the target entity — with a\n * clean orthogonal path through the gap between the boxes and an arrowhead\n * into the PK row (FK → PK).\n *\n * Entities longer than `MAX_ROWS` are truncated with a \"… +N more\" row.\n */\n\nimport dagre from '@dagrejs/dagre';\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { diagramFrame } from './frame.js';\n\ntype ErdData = BlockDataMap['erd'];\ntype ErdEntity = NonNullable<ErdData['entities']>[number];\ntype ErdColumn = NonNullable<ErdEntity['columns']>[number];\n\n/** Rows shown before an entity is truncated with a \"… +N more\" row. */\nconst MAX_ROWS = 10;\n\nconst COL_W = 216;\nconst ROW_H = 24;\nconst HEAD_H = 32;\nconst BOT_PAD = 8;\n\ninterface Box {\n readonly name: string;\n readonly cols: readonly ErdColumn[]; // full column list (for FK/PK lookup)\n readonly rows: readonly ErdColumn[]; // visible rows (after truncation)\n readonly hidden: number;\n readonly pkIdx: number; // index of the primary-key column, or -1\n readonly w: number;\n readonly h: number;\n}\n\ninterface Pt {\n readonly x: number;\n readonly y: number;\n}\n\nexport function renderErd(data: BlockDataMap['erd']): string {\n const ents = data.entities ?? [];\n const rels = data.relations ?? [];\n\n const boxes: Box[] = ents.map((e) => {\n const cols = e.columns ?? [];\n let rows = cols;\n let hidden = 0;\n if (cols.length > MAX_ROWS) {\n rows = cols.slice(0, MAX_ROWS - 1);\n hidden = cols.length - rows.length;\n }\n const bodyRows = rows.length + (hidden > 0 ? 1 : 0);\n return {\n name: e.name,\n cols,\n rows,\n hidden,\n pkIdx: cols.findIndex((c) => c.pk === true),\n w: COL_W,\n h: HEAD_H + bodyRows * ROW_H + BOT_PAD,\n };\n });\n const byName = new Map(boxes.map((b) => [b.name, b]));\n const validRels = rels.filter((r) => byName.has(r.from) && byName.has(r.to));\n\n // Stage 1: dagre places boxes (edges inform placement, but we route our own).\n const g = new dagre.graphlib.Graph({ multigraph: true });\n g.setGraph({ rankdir: 'LR', nodesep: 38, ranksep: 96, marginx: 18, marginy: 18 });\n g.setDefaultEdgeLabel(() => ({}));\n for (const b of boxes) g.setNode(b.name, { width: b.w, height: b.h });\n validRels.forEach((r, i) => g.setEdge(r.from, r.to, {}, `e${i}`));\n dagre.layout(g);\n\n const graph = g.graph();\n const W = Math.ceil(graph.width ?? 0);\n const H = Math.ceil(graph.height ?? 0);\n\n const at = new Map<string, Pt>(); // top-left of each box\n for (const b of boxes) {\n const n = g.node(b.name) as { x: number; y: number };\n at.set(b.name, { x: n.x - b.w / 2, y: n.y - b.h / 2 });\n }\n\n let s = `<svg viewBox=\"0 0 ${W} ${H}\" role=\"img\">` + `<title>Entity-relationship diagram</title>`;\n\n // Stage 2: field-level edge routing (drawn first, so boxes sit on top).\n validRels.forEach((r) => {\n const src = byName.get(r.from);\n const tgt = byName.get(r.to);\n const sp = at.get(r.from);\n const tp = at.get(r.to);\n if (!src || !tgt || !sp || !tp) return;\n\n const fkY = rowAnchorY(src, sp.y, pickFkIndex(src.cols, tgt.name));\n const pkY = rowAnchorY(tgt, tp.y, tgt.pkIdx);\n\n const rightward = tp.x + tgt.w / 2 >= sp.x + src.w / 2;\n const sx = rightward ? sp.x + src.w : sp.x; // exit side of source\n const tx = rightward ? tp.x : tp.x + tgt.w; // enter side of target\n\n const lo = Math.min(sx, tx) + 10;\n const hi = Math.max(sx, tx) - 10;\n const midX = hi > lo ? clamp((sx + tx) / 2, lo, hi) : (sx + tx) / 2;\n\n s +=\n `<path d=\"M${round(sx)},${round(fkY)} H${round(midX)} V${round(pkY)} H${round(tx)}\" fill=\"none\" stroke=\"var(--gray)\" stroke-width=\"1.5\"/>` +\n `<circle cx=\"${round(sx)}\" cy=\"${round(fkY)}\" r=\"2.6\" fill=\"var(--gray)\"/>` +\n arrowHeadH(tx, pkY, rightward);\n\n if (r.card !== undefined) {\n const w = 30;\n const cy = (fkY + pkY) / 2;\n s +=\n `<rect x=\"${round(midX - w / 2)}\" y=\"${round(cy - 9)}\" width=\"${w}\" height=\"18\" rx=\"9\" fill=\"var(--white)\" stroke=\"var(--rule)\"/>` +\n `<text x=\"${round(midX)}\" y=\"${round(cy + 3)}\" class=\"edge-label\">${escapeHtml(r.card)}</text>`;\n }\n });\n\n // Entity boxes.\n for (const b of boxes) {\n const p = at.get(b.name);\n if (!p) continue;\n const { x, y } = p;\n s +=\n `<rect x=\"${round(x)}\" y=\"${round(y)}\" width=\"${b.w}\" height=\"${b.h}\" rx=\"5\" fill=\"var(--white)\" stroke=\"var(--navy)\"/>` +\n `<path d=\"M${round(x)},${round(y + HEAD_H)} v${-(HEAD_H - 5)} a5,5 0 0 1 5,-5 h${b.w - 10} a5,5 0 0 1 5,5 v${HEAD_H - 5} z\" fill=\"var(--navy)\"/>` +\n `<text x=\"${round(x + b.w / 2)}\" y=\"${round(y + 21)}\" class=\"er-head-text\">${escapeHtml(b.name)}</text>`;\n\n b.rows.forEach((f, j) => {\n const rowTop = y + HEAD_H + j * ROW_H;\n const ty = rowTop + 16;\n if (j > 0) {\n s += `<line x1=\"${round(x)}\" y1=\"${round(rowTop)}\" x2=\"${round(x + b.w)}\" y2=\"${round(rowTop)}\" class=\"er-rowline\"/>`;\n }\n const nameX = f.pk === true || f.fk === true ? x + 40 : x + 13;\n if (f.pk === true) {\n s += `<text x=\"${round(x + 13)}\" y=\"${round(ty)}\" class=\"er-key\">PK</text>`;\n } else if (f.fk === true) {\n s += `<text x=\"${round(x + 13)}\" y=\"${round(ty)}\" class=\"er-key fk\">FK</text>`;\n }\n s +=\n `<text x=\"${round(nameX)}\" y=\"${round(ty)}\" class=\"er-col\">${escapeHtml(f.name)}</text>` +\n `<text x=\"${round(x + b.w - 13)}\" y=\"${round(ty)}\" class=\"er-col dim\" text-anchor=\"end\">${escapeHtml(f.type ?? '')}</text>`;\n });\n\n if (b.hidden > 0) {\n const rowTop = y + HEAD_H + b.rows.length * ROW_H;\n s +=\n `<line x1=\"${round(x)}\" y1=\"${round(rowTop)}\" x2=\"${round(x + b.w)}\" y2=\"${round(rowTop)}\" class=\"er-rowline\"/>` +\n `<text x=\"${round(x + b.w / 2)}\" y=\"${round(rowTop + 16)}\" class=\"er-col dim\" text-anchor=\"middle\">… +${b.hidden} more</text>`;\n }\n }\n\n s += `</svg>`;\n\n const opts: Parameters<typeof diagramFrame>[0] = {\n tag: 'ER',\n tagBg: '#6b21a8',\n ...(data.title !== undefined ? { title: data.title } : {}),\n ...(data.description !== undefined ? { desc: data.description } : {}),\n };\n return diagramFrame(opts, s);\n}\n\n/** Vertical centre of column `idx` in a box; falls back to the box centre. */\nfunction rowAnchorY(box: Box, topY: number, idx: number): number {\n if (idx >= 0 && idx < box.rows.length) return topY + HEAD_H + idx * ROW_H + ROW_H / 2;\n return topY + box.h / 2;\n}\n\n/**\n * Picks which foreign-key column references `toName`. Prefers an FK whose name\n * mentions the target entity (e.g. `user_id` → `users`); else the first FK; -1.\n */\nfunction pickFkIndex(columns: readonly ErdColumn[], toName: string): number {\n const fks = columns.map((c, i) => ({ c, i })).filter((x) => x.c.fk === true);\n const first = fks[0];\n if (first === undefined) return -1;\n const t = toName.toLowerCase();\n const singular = t.replace(/s$/, '');\n const match = fks.find((x) => {\n const n = x.c.name.toLowerCase();\n return n.includes(t) || n.includes(singular);\n });\n return (match ?? first).i;\n}\n\n/** A 10px horizontal arrowhead with its tip at (x, y), pointing right or left. */\nfunction arrowHeadH(x: number, y: number, pointRight: boolean): string {\n const dx = pointRight ? -10 : 10;\n return `<path d=\"M${round(x + dx)},${round(y - 5)} L${round(x)},${round(y)} L${round(x + dx)},${round(y + 5)}\" fill=\"none\" stroke=\"var(--navy)\" stroke-width=\"1.6\" stroke-linejoin=\"round\" stroke-linecap=\"round\"/>`;\n}\n\nconst clamp = (n: number, lo: number, hi: number): number => Math.max(lo, Math.min(hi, n));\nconst round = (n: number): number => Math.round(n * 10) / 10;\n","/**\n * Renders a kanban block. Doc-studio variant uses `columns: [{label, cards:\n * [{title, tag?}]}]` — flexible number of columns with structured cards.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\nexport function renderKanban(data: BlockDataMap['kanban']): string {\n const cols = data.columns ?? [];\n let h = `<div class=\"kanban\">`;\n for (const col of cols) {\n const cards = (col.cards ?? [])\n .map((c) => {\n const tag =\n c.tag !== undefined\n ? `<div class=\"kan-card-tag\">${escapeHtml(c.tag)}</div>`\n : '';\n return (\n `<div class=\"kan-card\">` +\n `<div class=\"kan-card-title\">${escapeHtml(c.title)}</div>` +\n tag +\n `</div>`\n );\n })\n .join('');\n h +=\n `<div class=\"kan-col\">` +\n `<div class=\"kan-head\">${escapeHtml(col.label)}</div>` +\n cards +\n `</div>`;\n }\n return h + `</div>`;\n}\n","/**\n * Renders a sequence diagram as inline SVG, plus an optional step-by-step\n * list below the SVG and an optional diagram footer with metadata pills.\n *\n * Matches the layout of `resources/sample-orders-api.html` (the canonical\n * \"rich\" rendering).\n *\n * Actors are objects (`{id, name, sub?, external?}`); messages reference\n * actors by `id`. Message `kind`:\n * - `sync` — solid arrow, bold navy label (default)\n * - `response` / `async` — dashed arrow, normal label\n * - `error` — red arrow, red bold label, step list item gets `.err`\n * - `note` — no arrow, italic gray label, badge on the from-actor's lane\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { diagramFrame } from './frame.js';\n\ntype MsgKind = 'sync' | 'response' | 'async' | 'error' | 'note';\n\ninterface KindStyle {\n readonly cls: string;\n readonly marker: 'sqArrow' | 'sqOpen' | 'sqErr' | null;\n readonly txt: string;\n}\n\nconst KIND: Record<MsgKind, KindStyle> = {\n sync: { cls: 'msg-line', marker: 'sqArrow', txt: 'msg-text em' },\n response: { cls: 'msg-line dashed', marker: 'sqOpen', txt: 'msg-text' },\n async: { cls: 'msg-line dashed', marker: 'sqOpen', txt: 'msg-text' },\n error: { cls: 'msg-line err', marker: 'sqErr', txt: 'msg-text err' },\n note: { cls: '', marker: null, txt: 'msg-text note' },\n};\n\nconst DB_PATTERN = /postgres|sql|\\bdb\\b|database|store/i;\n\nfunction renderStepList(\n rows: ReadonlyArray<{ kind: MsgKind; from: string; to: string; summary?: string; code?: string; note?: string }>,\n actorById: Map<string, { name: string }>,\n): string {\n const items = rows.filter((r) => r.summary !== undefined && r.summary.length > 0);\n if (items.length === 0) return '';\n\n const lis = items\n .map((r) => {\n const errCls = r.kind === 'error' ? ' class=\"err\"' : '';\n const actorErrCls = r.kind === 'error' ? ' err' : '';\n const fromName = actorById.get(r.from)?.name ?? r.from;\n const toName = r.kind === 'note' ? '' : ` &rarr; ${escapeHtml(actorById.get(r.to)?.name ?? r.to)}`;\n const actorLabel = `${escapeHtml(fromName)}${toName}`;\n const code =\n r.code !== undefined && r.code.length > 0\n ? `<pre class=\"sql\">${escapeHtml(r.code)}</pre>`\n : '';\n const note =\n r.note !== undefined && r.note.length > 0\n ? `<span class=\"step-note\">${escapeHtml(r.note)}</span>`\n : '';\n return (\n `<li${errCls}>` +\n `<span class=\"step-actor${actorErrCls}\">${actorLabel}</span>` +\n `<span class=\"step-summary\">${escapeHtml(r.summary ?? '')}</span>` +\n code +\n note +\n `</li>`\n );\n })\n .join('');\n\n return (\n `<div class=\"seq-steps\">` +\n `<div class=\"seq-steps-title\">Step-by-step</div>` +\n `<ol>${lis}</ol>` +\n `</div>`\n );\n}\n\nfunction renderFoot(foot: NonNullable<BlockDataMap['sequence']['foot']>): string {\n if (foot.length === 0) return '';\n const parts = foot\n .map((f) => `<span><strong>${escapeHtml(f.label)}:</strong> ${escapeHtml(f.value)}</span>`)\n .join('');\n return `<div class=\"diagram-foot\">${parts}</div>`;\n}\n\nexport function renderSequence(data: BlockDataMap['sequence']): string {\n const actors = data.actors ?? [];\n const messages = data.messages ?? [];\n const N = Math.max(actors.length, 1);\n const leftPad = 24;\n const laneW = 168;\n const gap = 58;\n const headY = 16;\n const headH = 42;\n const cx = (i: number): number => leftPad + laneW / 2 + i * (laneW + gap);\n const width = leftPad * 2 + N * laneW + (N - 1) * gap;\n const idx = (id: string): number => actors.findIndex((a) => a.id === id);\n const msgStartY = 92;\n const step = 42;\n\n type Row = {\n n: number;\n y: number;\n fromI: number;\n toI: number;\n kind: MsgKind;\n label: string;\n from: string;\n to: string;\n summary?: string;\n code?: string;\n note?: string;\n };\n const rows: Row[] = messages.map((m, k): Row => {\n const base: Row = {\n n: k + 1,\n y: msgStartY + k * step,\n fromI: idx(m.from),\n toI: idx(m.to),\n kind: (m.kind ?? 'sync') as MsgKind,\n label: m.label ?? '',\n from: m.from,\n to: m.to,\n };\n if (m.summary !== undefined) base.summary = m.summary;\n if (m.code !== undefined) base.code = m.code;\n if (m.note !== undefined) base.note = m.note;\n return base;\n });\n const bottom = msgStartY + messages.length * step + 12;\n const height = bottom + 6;\n\n const activations = actors.map((a, i) => {\n if (i === 0) return null;\n const ys = rows.filter((r) => r.fromI === i || r.toI === i).map((r) => r.y);\n if (ys.length === 0) return null;\n const db = DB_PATTERN.test(`${a.name} ${a.sub ?? ''}`);\n return { i, y1: Math.min(...ys) - 8, y2: Math.max(...ys) + 8, db };\n });\n\n let s =\n `<svg viewBox=\"0 0 ${width} ${height}\" role=\"img\">` +\n `<title>Sequence diagram</title>` +\n `<defs>` +\n `<marker id=\"sqArrow\" viewBox=\"0 0 10 10\" refX=\"8\" refY=\"5\" markerWidth=\"6\" markerHeight=\"6\" orient=\"auto-start-reverse\">` +\n `<path d=\"M0,0 L10,5 L0,10 z\" fill=\"#1a1a2e\"/></marker>` +\n `<marker id=\"sqOpen\" viewBox=\"0 0 10 10\" refX=\"8\" refY=\"5\" markerWidth=\"6\" markerHeight=\"6\" orient=\"auto-start-reverse\">` +\n `<path d=\"M0,0 L10,5 L0,10\" fill=\"none\" stroke=\"#1a1a2e\" stroke-width=\"1.2\"/></marker>` +\n `<marker id=\"sqErr\" viewBox=\"0 0 10 10\" refX=\"8\" refY=\"5\" markerWidth=\"6\" markerHeight=\"6\" orient=\"auto-start-reverse\">` +\n `<path d=\"M0,0 L10,5 L0,10 z\" fill=\"#991b1b\"/></marker>` +\n `</defs>`;\n\n for (let i = 0; i < actors.length; i++) {\n const x = cx(i);\n s += `<line x1=\"${x}\" y1=\"${headY + headH}\" x2=\"${x}\" y2=\"${bottom}\" class=\"lifeline\"/>`;\n }\n\n for (const ac of activations) {\n if (!ac) continue;\n s += `<rect x=\"${cx(ac.i) - 4}\" y=\"${ac.y1}\" width=\"8\" height=\"${ac.y2 - ac.y1}\" class=\"activation${ac.db ? ' pg' : ''}\"/>`;\n }\n\n actors.forEach((a, i) => {\n const extCls = a.external === true ? ' ext' : '';\n const sub =\n a.sub !== undefined\n ? `<text x=\"${cx(i)}\" y=\"${headY + 36}\" class=\"lane-head-sub${extCls}\">${escapeHtml(a.sub)}</text>`\n : '';\n s +=\n `<g>` +\n `<rect x=\"${cx(i) - laneW / 2}\" y=\"${headY}\" width=\"${laneW}\" height=\"${headH}\" class=\"lane-head${extCls}\"/>` +\n `<text x=\"${cx(i)}\" y=\"${headY + 22}\" class=\"lane-head-text\">${escapeHtml(a.name)}</text>` +\n sub +\n `</g>`;\n });\n\n for (const r of rows) {\n const k = KIND[r.kind];\n\n // `note` kind — just a numbered annotation at the from-actor's lane\n if (r.kind === 'note' || r.toI < 0) {\n if (r.fromI < 0) continue;\n const x = cx(r.fromI);\n s +=\n `<g>` +\n `<circle cx=\"${x + 18}\" cy=\"${r.y - 10}\" r=\"10\" class=\"step-badge\"/>` +\n `<text x=\"${x + 18}\" y=\"${r.y - 6.5}\" class=\"step-badge-text\">${r.n}</text>` +\n `<text x=\"${x + 34}\" y=\"${r.y - 6}\" class=\"msg-text note\">${escapeHtml(r.label)}</text>` +\n `</g>`;\n continue;\n }\n // self-message — loop back to the same lane\n if (r.fromI === r.toI) {\n const x = cx(r.fromI);\n const errCls = r.kind === 'error' ? ' err' : '';\n s +=\n `<g>` +\n `<circle cx=\"${x + 18}\" cy=\"${r.y - 10}\" r=\"10\" class=\"step-badge${errCls}\"/>` +\n `<text x=\"${x + 18}\" y=\"${r.y - 6.5}\" class=\"step-badge-text\">${r.n}</text>` +\n `<text x=\"${x + 34}\" y=\"${r.y - 6}\" class=\"msg-text note\">${escapeHtml(r.label)}</text>` +\n `</g>`;\n continue;\n }\n\n const x1 = cx(r.fromI);\n const x2 = cx(r.toI);\n const ltr = x2 > x1;\n const end = x2 + (ltr ? -3 : 3);\n const errBadge = r.kind === 'error' ? ' err' : '';\n // Badge sits just inside the from-lane on the side facing the target.\n const badgeX = ltr ? x1 + 18 : x1 - 18;\n // Label anchors next to the badge (start-aligned LTR, end-aligned RTL).\n // Matches the sample's `<text x=\"badgeX+18\" ... >` / `<text x=\"badgeX-18\" ... text-anchor=\"end\">` layout.\n const labelX = ltr ? badgeX + 16 : badgeX - 16;\n const labelAnchor = ltr ? 'start' : 'end';\n const markerAttr = k.marker !== null ? ` marker-end=\"url(#${k.marker})\"` : '';\n s +=\n `<line x1=\"${x1}\" y1=\"${r.y}\" x2=\"${end}\" y2=\"${r.y}\" class=\"${k.cls}\"${markerAttr}/>` +\n `<circle cx=\"${badgeX}\" cy=\"${r.y - 10}\" r=\"10\" class=\"step-badge${errBadge}\"/>` +\n `<text x=\"${badgeX}\" y=\"${r.y - 6.5}\" class=\"step-badge-text\">${r.n}</text>` +\n `<text x=\"${labelX}\" y=\"${r.y - 6}\" class=\"${k.txt}\" text-anchor=\"${labelAnchor}\">${escapeHtml(r.label)}</text>`;\n }\n\n s += `</svg>`;\n\n const actorById = new Map<string, { name: string }>();\n for (const a of actors) actorById.set(a.id, { name: a.name });\n const stepList = renderStepList(rows, actorById);\n const footHtml = data.foot !== undefined ? renderFoot(data.foot) : '';\n\n // Tag + title\n const method = data.endpoint?.method.toLowerCase();\n const tag = data.endpoint?.method ?? 'FLOW';\n const titleHtml = (() => {\n if (data.endpoint?.path !== undefined) {\n const t = data.title !== undefined ? ` &mdash; ${escapeHtml(data.title)}` : '';\n return `<code>${escapeHtml(data.endpoint.path)}</code>${t}`;\n }\n return data.title !== undefined ? escapeHtml(data.title) : '';\n })();\n\n const frameOpts: Parameters<typeof diagramFrame>[0] = {\n tag,\n ...(method !== undefined ? { tagClass: method } : { tagBg: '#374151' }),\n ...(titleHtml.length > 0 ? { titleHtml } : {}),\n ...(data.description !== undefined ? { desc: data.description } : {}),\n ...(footHtml.length > 0 ? { footerHtml: footHtml } : {}),\n };\n\n return diagramFrame(frameOpts, s + stepList);\n}\n","/**\n * Renders a table block. Doc-studio variant supports:\n * - Column objects with `align` ('l'|'c'|'r') and `highlight`\n * - Cell objects with `tone` ('pos'|'neg'|'warn'|'muted'), `lead`, `highlight`\n * - Optional `title`, `description`, `note`\n *\n * Plain string columns / cells still work.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\ntype TableData = BlockDataMap['table'];\ntype Col = NonNullable<TableData['columns']>[number];\ntype Cell = NonNullable<NonNullable<TableData['rows']>[number]>[number];\n\nfunction colClass(c: Col): string {\n if (typeof c === 'string') return '';\n const parts: string[] = [];\n if (c.align === 'r') parts.push('r');\n if (c.align === 'c') parts.push('c');\n if (c.highlight === true) parts.push('hi');\n return parts.join(' ');\n}\n\nfunction colLabel(c: Col): string {\n return typeof c === 'string' ? c : c.label;\n}\n\nfunction cellClass(c: Cell): string {\n if (typeof c === 'string' || typeof c === 'number') return '';\n const parts: string[] = [];\n if (c.tone) parts.push(`cell-${c.tone}`);\n if (c.lead === true) parts.push('lead');\n if (c.highlight === true) parts.push('hi');\n return parts.join(' ');\n}\n\nfunction cellValue(c: Cell): string {\n if (typeof c === 'string' || typeof c === 'number') return escapeHtml(c);\n return escapeHtml(c.v);\n}\n\nexport function renderTable(data: BlockDataMap['table']): string {\n const cols = data.columns ?? [];\n const rows = data.rows ?? [];\n const head = cols\n .map((c) => {\n const cls = colClass(c);\n return `<th${cls ? ` class=\"${cls}\"` : ''}>${escapeHtml(colLabel(c))}</th>`;\n })\n .join('');\n const body = rows\n .map((r) => {\n const cells = (r ?? [])\n .map((c, i) => {\n const col = cols[i];\n const cls = [col !== undefined ? colClass(col) : '', cellClass(c)]\n .filter(Boolean)\n .join(' ');\n return `<td${cls ? ` class=\"${cls}\"` : ''}>${cellValue(c)}</td>`;\n })\n .join('');\n return `<tr>${cells}</tr>`;\n })\n .join('');\n const note =\n data.note !== undefined ? `<p class=\"tbl-note\">${escapeHtml(data.note)}</p>` : '';\n return `<table class=\"pres-table\"><thead><tr>${head}</tr></thead><tbody>${body}</tbody></table>${note}`;\n}\n","/**\n * Renders a timeline block. Doc-studio variant uses `label` (not `title`),\n * `date` (not `when`), `desc` (not `detail`), and status enum\n * `done | current | next | future` (where `current` is the in-flight item).\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\nexport function renderTimeline(data: BlockDataMap['timeline']): string {\n const items = data.items ?? [];\n let h = `<div class=\"tl\">`;\n for (const it of items) {\n const st = it.status ?? 'future';\n const date =\n it.date !== undefined ? `<div class=\"tl-date\">${escapeHtml(it.date)}</div>` : '';\n const desc =\n it.desc !== undefined ? `<div class=\"tl-desc\">${escapeHtml(it.desc)}</div>` : '';\n h +=\n `<div class=\"tl-item\">` +\n `<span class=\"tl-dot ${st}\"></span>` +\n date +\n `<div class=\"tl-label\">${escapeHtml(it.label)}</div>` +\n desc +\n `</div>`;\n }\n return h + `</div>`;\n}\n","/**\n * Renders a tracker block — task table with status pills, optional priority,\n * owner, and due date columns.\n *\n * Doc-studio extras: optional `owner` (rendered as a column) and `due` (also\n * a column). Done rows get a strikethrough via `.trk tr.done .trk-task`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\nexport function renderTracker(data: BlockDataMap['tracker']): string {\n const items = data.items ?? [];\n const hasOwner = items.some((i) => i.owner !== undefined);\n const hasDue = items.some((i) => i.due !== undefined);\n\n const headCells = ['<th>Task</th>', '<th>Status</th>', '<th>Priority</th>'];\n if (hasOwner) headCells.push('<th>Owner</th>');\n if (hasDue) headCells.push('<th>Due</th>');\n\n let h = `<table class=\"trk\"><thead><tr>${headCells.join('')}</tr></thead><tbody>`;\n for (const it of items) {\n const st = it.status ?? 'todo';\n const pr = it.priority;\n const prCell =\n pr !== undefined ? `<span class=\"pri ${pr}\">${escapeHtml(pr)}</span>` : '';\n const rowCls = st === 'done' ? ' class=\"done\"' : '';\n const cells = [\n `<td class=\"trk-task\">${escapeHtml(it.task)}</td>`,\n `<td><span class=\"st ${st}\">${escapeHtml(st)}</span></td>`,\n `<td>${prCell}</td>`,\n ];\n if (hasOwner) cells.push(`<td>${escapeHtml(it.owner ?? '')}</td>`);\n if (hasDue) cells.push(`<td>${escapeHtml(it.due ?? '')}</td>`);\n h += `<tr${rowCls}>${cells.join('')}</tr>`;\n }\n return h + `</tbody></table>`;\n}\n","/**\n * Renders a userstory block — story statement, optional meta chips, optional\n * acceptance-criteria list, and optional related-links chips.\n *\n * Matches doc-studio's `.story` shell (`.story-stmt`, `.story-meta`,\n * `.story-chip`, `.ac-title`, `.ac-item`, `.gwt`, `.link-chip`).\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\nexport function renderUserStory(data: BlockDataMap['userstory']): string {\n const role = data.role ?? 'user';\n const want = data.want ?? '…';\n const soThat = data.soThat ?? '…';\n\n const chips: string[] = [];\n if (data.priority !== undefined)\n chips.push(`<span class=\"story-chip\">Priority · ${escapeHtml(data.priority)}</span>`);\n if (data.points !== undefined && data.points !== null)\n chips.push(`<span class=\"story-chip\">${escapeHtml(data.points)} pts</span>`);\n\n let h =\n `<div class=\"story\">` +\n `<div class=\"story-stmt\">As a <b>${escapeHtml(role)}</b>, I want to <b>${escapeHtml(want)}</b>, so that <b>${escapeHtml(soThat)}</b>.</div>`;\n if (chips.length > 0) {\n h += `<div class=\"story-meta\">${chips.join('')}</div>`;\n }\n h += `</div>`;\n\n const crit = data.criteria ?? [];\n if (crit.length > 0) {\n h += `<div class=\"ac-title\">Acceptance criteria</div>`;\n for (const c of crit) {\n h +=\n `<div class=\"ac-item\"><div class=\"gwt\">` +\n `<span class=\"k g\">Given</span><span class=\"v\">${escapeHtml(c.given ?? '')}</span>` +\n `<span class=\"k w\">When</span><span class=\"v\">${escapeHtml(c.when ?? '')}</span>` +\n `<span class=\"k t\">Then</span><span class=\"v\">${escapeHtml(c.then ?? '')}</span>` +\n `</div></div>`;\n }\n }\n\n const links = data.links ?? [];\n if (links.length > 0) {\n h += `<div class=\"ac-title\">Related</div><div class=\"links-row\">`;\n for (const l of links) {\n h +=\n `<span class=\"link-chip\">` +\n `<span class=\"lt\">${escapeHtml(l.mode ?? '')}</span>` +\n `${escapeHtml(l.label ?? '')}` +\n `</span>`;\n }\n h += `</div>`;\n }\n\n return h;\n}\n","/**\n * Renders a structured `prose` block — a sequence of typed sub-blocks\n * (heading, paragraph, ul, ol, quote). Useful when the author wants explicit\n * structure instead of raw markdown.\n *\n * Ported from doc-studio.jsx `Prose`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\nexport function renderProseBlock(data: BlockDataMap['prose']): string {\n const blocks = data.blocks ?? [];\n const html = blocks\n .map((b) => {\n const t = (b.type ?? 'p').toLowerCase();\n const text = b.text ?? '';\n if (t === 'h') return `<h3>${escapeHtml(text)}</h3>`;\n if (t === 'quote') return `<blockquote>${escapeHtml(text)}</blockquote>`;\n if (t === 'ul') {\n const items = (b.items ?? []).map((x) => `<li>${escapeHtml(x)}</li>`).join('');\n return `<ul>${items}</ul>`;\n }\n if (t === 'ol') {\n const items = (b.items ?? []).map((x) => `<li>${escapeHtml(x)}</li>`).join('');\n return `<ol>${items}</ol>`;\n }\n return `<p>${escapeHtml(text)}</p>`;\n })\n .join('');\n return `<div class=\"prose\">${html}</div>`;\n}\n","/**\n * Renders a glossary block — a list of term/definition rows.\n *\n * Ported from doc-studio.jsx `Glossary`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\nexport function renderGlossary(data: BlockDataMap['glossary']): string {\n const terms = data.terms ?? [];\n const rows = terms\n .map(\n (t) =>\n `<div class=\"row\"><dt>${escapeHtml(t.term)}</dt><dd>${escapeHtml(t.def)}</dd></div>`,\n )\n .join('');\n return `<div class=\"glossary\">${rows}</div>`;\n}\n","/**\n * Renders a pros-vs-cons block — two columns of bullet items with\n * positive / negative styling.\n *\n * Ported from doc-studio.jsx `ProsCons`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\nexport function renderProsCons(data: BlockDataMap['proscons']): string {\n const prosLabel = data.prosLabel ?? 'Pros';\n const consLabel = data.consLabel ?? 'Cons';\n const pros = (data.pros ?? []).map((p) => `<div class=\"pc-item\">${escapeHtml(p)}</div>`).join('');\n const cons = (data.cons ?? []).map((c) => `<div class=\"pc-item\">${escapeHtml(c)}</div>`).join('');\n return (\n `<div class=\"pc\">` +\n `<div class=\"pc-col pro\">` +\n `<div class=\"pc-head\">${escapeHtml(prosLabel)}</div>` +\n pros +\n `</div>` +\n `<div class=\"pc-col con\">` +\n `<div class=\"pc-head\">${escapeHtml(consLabel)}</div>` +\n cons +\n `</div>` +\n `</div>`\n );\n}\n","/**\n * Renders a current-vs-target block — two side-by-side panels separated by an\n * arrow, optionally captioned.\n *\n * Ported from doc-studio.jsx `CurrentTarget`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\nexport function renderCvt(data: BlockDataMap['cvt']): string {\n const cur = data.current ?? {};\n const tgt = data.target ?? {};\n const curItems = (cur.items ?? [])\n .map((x) => `<div class=\"ct-item\">${escapeHtml(x)}</div>`)\n .join('');\n const tgtItems = (tgt.items ?? [])\n .map((x) => `<div class=\"ct-item\">${escapeHtml(x)}</div>`)\n .join('');\n const curLabel = cur.label ?? 'Current';\n const tgtLabel = tgt.label ?? 'Target';\n const note =\n data.note !== undefined ? `<div class=\"tbl-note\">${escapeHtml(data.note)}</div>` : '';\n return (\n `<div>` +\n `<div class=\"ct\">` +\n `<div class=\"ct-panel cur\">` +\n `<div class=\"ct-label\">${escapeHtml(curLabel)}</div>` +\n curItems +\n `</div>` +\n `<div class=\"ct-arrow\">&rarr;</div>` +\n `<div class=\"ct-panel tgt\">` +\n `<div class=\"ct-label\">${escapeHtml(tgtLabel)}</div>` +\n tgtItems +\n `</div>` +\n `</div>` +\n note +\n `</div>`\n );\n}\n","/**\n * Renders a row of KPI / stat cards with optional delta + trend arrow.\n *\n * Ported from doc-studio.jsx `StatCards`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { safeColor } from '../sanitize.js';\n\nconst TREND_GLYPH = { up: '▲', down: '▼', flat: '—' } as const;\n\nexport function renderStats(data: BlockDataMap['stats']): string {\n const stats = data.stats ?? [];\n const cards = stats\n .map((s) => {\n const accent =\n s.accent !== undefined\n ? ` style=\"border-top-color:${safeColor(s.accent, '#0e54a1')}\"`\n : '';\n const delta =\n s.delta !== undefined\n ? `<div class=\"stat-delta ${s.trend ?? 'flat'}\">${TREND_GLYPH[s.trend ?? 'flat']} ${escapeHtml(s.delta)}</div>`\n : '';\n return (\n `<div class=\"stat-card\"${accent}>` +\n `<div class=\"stat-value\">${escapeHtml(s.value)}</div>` +\n `<div class=\"stat-label\">${escapeHtml(s.label)}</div>` +\n delta +\n `</div>`\n );\n })\n .join('');\n return `<div class=\"stat-row\">${cards}</div>`;\n}\n","/**\n * Tiny multi-language syntax highlighter — emits HTML spans (`.kw`, `.str`,\n * `.num`, `.fn`, `.ty`, `.com`) wrapped around recognized tokens.\n *\n * Ported from `resources/doc-studio.jsx` `highlightCode`. Designed for the\n * `code` block and the SQL snippets in `seq-steps`. Not a full lexer — just\n * enough to make a snippet readable.\n */\n\nimport { escapeHtml } from './escape.js';\n\nconst KW = new Set(\n (\n 'const let var function return if else for while do switch case break continue ' +\n 'class extends new await async import from export default try catch finally throw ' +\n 'typeof instanceof void delete yield static public private protected readonly ' +\n 'abstract implements interface type enum namespace def elif lambda pass with raise ' +\n 'except none true false and or not is in self nil func struct map range defer chan ' +\n 'select fallthrough echo fi done local require module package this super ' +\n 'create table alter add drop select insert update delete into values where join ' +\n 'group order by limit primary key foreign references not null default unique index ' +\n 'on check constraint cascade returning begin commit rollback'\n ).split(/\\s+/),\n);\n\nconst TY = new Set(\n (\n 'string number boolean int integer float double bool char byte long short void ' +\n 'object any unknown never bigint promise array list set optional uuid text varchar ' +\n 'timestamptz timestamp date numeric decimal jsonb json serial bigserial smallint'\n ).split(/\\s+/),\n);\n\nconst TOKEN_RE =\n /(\\/\\*[\\s\\S]*?\\*\\/|\\/\\/[^\\n]*|#[^\\n]*)|(\"(?:\\\\.|[^\"\\\\])*\"|'(?:\\\\.|[^'\\\\])*'|`(?:\\\\.|[^`\\\\])*`)|(\\b\\d[\\w.]*)|([A-Za-z_$][\\w$]*)/g;\n\n/**\n * Highlights a code snippet, returning HTML-safe string.\n *\n * @param code - Source code (any language). HTML-escaped before token wrapping.\n */\nexport function highlightCode(code: string): string {\n if (code.length === 0) return '';\n const src = String(code);\n let out = '';\n let last = 0;\n TOKEN_RE.lastIndex = 0;\n let m: RegExpExecArray | null;\n while ((m = TOKEN_RE.exec(src)) !== null) {\n if (m.index > last) out += escapeHtml(src.slice(last, m.index));\n const t = m[0];\n if (m[1] !== undefined) {\n out += `<span class=\"com\">${escapeHtml(t)}</span>`;\n } else if (m[2] !== undefined) {\n out += `<span class=\"str\">${escapeHtml(t)}</span>`;\n } else if (m[3] !== undefined) {\n out += `<span class=\"num\">${escapeHtml(t)}</span>`;\n } else {\n const lt = t.toLowerCase();\n if (KW.has(lt)) out += `<span class=\"kw\">${escapeHtml(t)}</span>`;\n else if (TY.has(lt)) out += `<span class=\"ty\">${escapeHtml(t)}</span>`;\n else if (src[TOKEN_RE.lastIndex] === '(')\n out += `<span class=\"fn\">${escapeHtml(t)}</span>`;\n else out += escapeHtml(t);\n }\n last = TOKEN_RE.lastIndex;\n }\n if (last < src.length) out += escapeHtml(src.slice(last));\n return out;\n}\n","/**\n * Renders one or more code blocks, each with a header (filename / language)\n * and a syntax-highlighted body.\n *\n * Ported from doc-studio.jsx `CodeBlock` (iterated for multiple snippets).\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { highlightCode } from '../highlight.js';\n\nexport function renderCode(data: BlockDataMap['code']): string {\n const blocks = data.blocks ?? [];\n return blocks\n .map(\n (b) =>\n `<div class=\"code-block\">` +\n `<div class=\"code-header\">` +\n `<span>${escapeHtml(b.title ?? '')}</span>` +\n `<span>${escapeHtml(b.lang ?? '')}</span>` +\n `</div>` +\n `<pre>${highlightCode(b.code)}</pre>` +\n `</div>`,\n )\n .join('');\n}\n","/**\n * Renders a meeting / event agenda — rows of `(time + duration)` paired with\n * `(title + owner + desc)`.\n *\n * Ported from doc-studio.jsx `Agenda`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\nexport function renderAgenda(data: BlockDataMap['agenda']): string {\n const items = data.items ?? [];\n const rows = items\n .map((it) => {\n const dur =\n it.duration !== undefined\n ? `<div class=\"agenda-dur\">${escapeHtml(it.duration)}</div>`\n : '';\n const owner =\n it.owner !== undefined\n ? `<span class=\"agenda-owner\">${escapeHtml(it.owner)}</span>`\n : '';\n const desc =\n it.desc !== undefined ? `<div class=\"agenda-desc\">${escapeHtml(it.desc)}</div>` : '';\n const time =\n it.time !== undefined ? `<div class=\"agenda-time\">${escapeHtml(it.time)}</div>` : '';\n return (\n `<div class=\"agenda-row\">` +\n `<div>${time}${dur}</div>` +\n `<div>` +\n `<div class=\"agenda-title\">${escapeHtml(it.title)}${owner}</div>` +\n desc +\n `</div>` +\n `</div>`\n );\n })\n .join('');\n return `<div class=\"agenda\">${rows}</div>`;\n}\n","/**\n * Renders an indented hierarchy of nodes, like a folder tree.\n *\n * Nodes are linked via `parent` id. Roots are nodes without a `parent` (or\n * whose parent id is unknown). Children are indented based on depth.\n *\n * Ported from doc-studio.jsx `Tree`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\ntype Node = NonNullable<BlockDataMap['tree']['nodes']>[number];\n\nexport function renderTree(data: BlockDataMap['tree']): string {\n const nodes = data.nodes ?? [];\n const byId = new Map<string, Node>();\n const children = new Map<string, string[]>();\n for (const n of nodes) {\n byId.set(n.id, n);\n children.set(n.id, []);\n }\n const roots: string[] = [];\n for (const n of nodes) {\n if (n.parent !== undefined && byId.has(n.parent)) {\n children.get(n.parent)?.push(n.id);\n } else {\n roots.push(n.id);\n }\n }\n\n type Out = { node: Node; depth: number; branch: boolean };\n const out: Out[] = [];\n const seen = new Set<string>();\n const walk = (id: string, depth: number): void => {\n if (seen.has(id)) return;\n seen.add(id);\n const node = byId.get(id);\n if (node === undefined) return;\n const kids = children.get(id) ?? [];\n out.push({ node, depth, branch: kids.length > 0 });\n for (const c of kids) walk(c, depth + 1);\n };\n for (const r of roots) walk(r, 0);\n\n const rows = out\n .map((row) => {\n const branchCls = row.branch ? ' branch' : '';\n const glyph = row.branch ? '▸' : '—';\n const note =\n row.node.note !== undefined\n ? `<span class=\"tnote\">${escapeHtml(row.node.note)}</span>`\n : '';\n return (\n `<div class=\"tree-row${branchCls}\" style=\"padding-left:${row.depth * 22}px\">` +\n `<span class=\"tw\">${glyph}</span>` +\n `<span class=\"tlabel\">${escapeHtml(row.node.label)}</span>` +\n note +\n `</div>`\n );\n })\n .join('');\n return `<div class=\"tree-list\">${rows}</div>`;\n}\n","/**\n * Renders a pyramid diagram (top → bottom widening trapezoids).\n *\n * Ported from doc-studio.jsx `Pyramid`. Uses the shared CHART_COLORS palette.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\nconst CHART_COLORS = ['#0e54a1', '#1a6dbe', '#0f766e', '#1f9747', '#6b21a8', '#f7952c'];\n\nexport function renderPyramid(data: BlockDataMap['pyramid']): string {\n const levels = data.levels ?? [];\n const n = Math.max(levels.length, 1);\n const W = 520;\n const top = 16;\n const rowH = Math.min(72, Math.floor(280 / n));\n const gap = 4;\n const apex = W / 2;\n const pad = 16;\n const maxW = 430;\n const H = top + n * (rowH + gap) + pad;\n\n const polygons = levels\n .map((L, i) => {\n const y = top + i * (rowH + gap);\n const wTop = maxW * (i / n);\n const wBot = maxW * ((i + 1) / n);\n const fill = CHART_COLORS[i % CHART_COLORS.length] ?? '#0e54a1';\n const desc =\n L.desc !== undefined\n ? `<text x=\"${apex}\" y=\"${y + rowH / 2 + 14}\" class=\"pyr-desc\">${escapeHtml(L.desc)}</text>`\n : '';\n return (\n `<g>` +\n `<polygon points=\"${apex - wTop / 2},${y} ${apex + wTop / 2},${y} ${apex + wBot / 2},${y + rowH} ${apex - wBot / 2},${y + rowH}\" fill=\"${fill}\"/>` +\n `<text x=\"${apex}\" y=\"${y + rowH / 2 - 1}\" class=\"pyr-label\">${escapeHtml(L.label)}</text>` +\n desc +\n `</g>`\n );\n })\n .join('');\n\n return `<svg viewBox=\"0 0 ${W} ${H}\" role=\"img\"><title>Pyramid</title>${polygons}</svg>`;\n}\n","/**\n * Renders a funnel chart — stacked trapezoids that narrow from top to bottom\n * with absolute values and computed conversion percentages.\n *\n * Ported from doc-studio.jsx `Funnel`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\nconst CHART_COLORS = ['#0e54a1', '#1a6dbe', '#0f766e', '#1f9747', '#6b21a8', '#f7952c'];\n\nfunction toNum(v: string | number): number {\n if (typeof v === 'number') return v;\n const n = parseFloat(v.replace(/[, _]/g, ''));\n return Number.isFinite(n) ? n : 0;\n}\n\nfunction fmt(v: string | number): string {\n return typeof v === 'number' ? v.toLocaleString() : v;\n}\n\nexport function renderFunnel(data: BlockDataMap['funnel']): string {\n const stages = (data.stages ?? []).filter(Boolean);\n const W = 560;\n const top = 14;\n const rowH = 62;\n const maxW = 420;\n const pad = 14;\n const cx = W / 2;\n const H = top + stages.length * rowH + pad;\n\n const vals = stages.map((s) => toNum(s.value));\n const first = vals[0] ?? 0;\n const max = Math.max(1, ...vals);\n const wOf = (v: number): number => Math.max(78, maxW * (v / max));\n\n const groups = stages\n .map((s, i) => {\n const v = vals[i] ?? 0;\n const vNext = i < stages.length - 1 ? (vals[i + 1] ?? 0) : v * 0.82;\n const wTop = wOf(v);\n const wBot = wOf(vNext);\n const y = top + i * rowH;\n const fill = CHART_COLORS[i % CHART_COLORS.length] ?? '#0e54a1';\n const pct = first > 0 ? Math.round((v / first) * 100) : 0;\n const sub = i > 0 && first > 0 ? ` · ${pct}%` : '';\n return (\n `<g>` +\n `<polygon points=\"${cx - wTop / 2},${y} ${cx + wTop / 2},${y} ${cx + wBot / 2},${y + rowH} ${cx - wBot / 2},${y + rowH}\" fill=\"${fill}\" stroke=\"#fff\" stroke-width=\"2\"/>` +\n `<text x=\"${cx}\" y=\"${y + rowH / 2 - 3}\" class=\"funnel-label\">${escapeHtml(s.label)}</text>` +\n `<text x=\"${cx}\" y=\"${y + rowH / 2 + 15}\" class=\"funnel-val\">${escapeHtml(fmt(s.value))}${sub}</text>` +\n `</g>`\n );\n })\n .join('');\n\n return `<svg viewBox=\"0 0 ${W} ${H}\" role=\"img\"><title>Funnel</title>${groups}</svg>`;\n}\n","/**\n * Manhattan / orthogonal edge routing between two rectangular nodes.\n *\n * Returns the SVG path `d` attribute and a midpoint for label placement.\n * The route turns at the midpoint along the dominant axis, so edges read\n * cleanly even when the source and target overlap on one axis.\n *\n * Ported from `resources/doc-studio.jsx` `ortho`.\n */\n\n/** A rectangular node bounding box (top-left + size). */\nexport interface Box {\n readonly x: number;\n readonly y: number;\n readonly w: number;\n readonly h: number;\n}\n\n/** Routed edge: SVG `d` plus a midpoint for the edge label. */\nexport interface Route {\n readonly d: string;\n readonly lx: number;\n readonly ly: number;\n}\n\n/**\n * Routes an orthogonal edge from box A to box B.\n *\n * @param A - Source box.\n * @param B - Target box.\n * @returns SVG path data and label midpoint.\n */\nexport function ortho(A: Box, B: Box): Route {\n const a = { x: A.x + A.w / 2, y: A.y + A.h / 2 };\n const b = { x: B.x + B.w / 2, y: B.y + B.h / 2 };\n const dx = b.x - a.x;\n const dy = b.y - a.y;\n if (Math.abs(dx) >= Math.abs(dy)) {\n const sx = dx >= 0 ? A.x + A.w : A.x;\n const ex = dx >= 0 ? B.x : B.x + B.w;\n const sy = a.y;\n const ey = b.y;\n const mx = (sx + ex) / 2;\n return { d: `M ${sx} ${sy} H ${mx} V ${ey} H ${ex}`, lx: mx, ly: (sy + ey) / 2 };\n }\n const sy = dy >= 0 ? A.y + A.h : A.y;\n const ey = dy >= 0 ? B.y : B.y + B.h;\n const sx = a.x;\n const ex = b.x;\n const my = (sy + ey) / 2;\n return { d: `M ${sx} ${sy} V ${my} H ${ex} V ${ey}`, lx: (sx + ex) / 2, ly: my };\n}\n","/**\n * Wraps text to fit within an approximate character-per-line budget, capping\n * the total number of lines. Word-aware (won't break mid-word).\n *\n * Used by diagram renderers for fixed-size labels. Ported from\n * `resources/doc-studio.jsx` `wrapText`.\n */\n\n/**\n * @param text - Source text (any value is coerced via `String(...)`).\n * @param max - Approximate maximum characters per line.\n * @param maxLines - Maximum number of lines to return (later lines dropped).\n * @returns An array of wrapped lines; empty array for empty input.\n */\nexport function wrapText(text: unknown, max: number, maxLines: number): string[] {\n if (text === undefined || text === null || text === '') return [];\n const words = String(text).split(/\\s+/);\n const lines: string[] = [];\n let cur = '';\n for (const w of words) {\n if (!cur) {\n cur = w;\n continue;\n }\n if ((cur + ' ' + w).length <= max) {\n cur += ' ' + w;\n } else {\n lines.push(cur);\n cur = w;\n if (lines.length === maxLines) break;\n }\n }\n if (cur && lines.length < maxLines) lines.push(cur);\n return lines.slice(0, maxLines);\n}\n","/**\n * Renders an SVG edge label as a small rounded pill, sized to the label text.\n *\n * Returned as an SVG `<g>` fragment so it can be appended inside an enclosing\n * `<svg>`. Returns the empty string if `label` is falsy.\n *\n * Ported from `resources/doc-studio.jsx` `EdgePill`.\n */\n\nimport { escapeHtml } from '../escape.js';\n\n/** Pill placement (midpoint of the labelled edge). */\nexport interface PillPoint {\n readonly lx: number;\n readonly ly: number;\n}\n\n/**\n * @param p - Midpoint of the edge (typically from {@link ortho}).\n * @param label - Label text. Empty/undefined yields an empty string.\n * @param err - If true, the label is rendered in the error style.\n */\nexport function edgePill(p: PillPoint, label: string | undefined, err = false): string {\n if (label === undefined || label === '') return '';\n const w = Math.max(26, label.length * 5.4);\n const errClass = err ? ' err' : '';\n return (\n `<g>` +\n `<rect x=\"${p.lx - w / 2}\" y=\"${p.ly - 9}\" width=\"${w}\" height=\"18\" rx=\"9\" fill=\"#fff\" stroke=\"#d1d5db\"/>` +\n `<text x=\"${p.lx}\" y=\"${p.ly + 3}\" class=\"edge-label${errClass}\">${escapeHtml(label)}</text>` +\n `</g>`\n );\n}\n","/**\n * Renders a flowchart — decision diamonds, stadium start/end nodes, rectangles\n * for processes, with orthogonal edges and error-coloured paths.\n *\n * Ported from doc-studio.jsx `Flowchart` + `flowStyle`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { ortho } from '../svg/ortho.js';\nimport { wrapText } from '../svg/wrapText.js';\nimport { edgePill } from '../svg/edgePill.js';\nimport { diagramFrame } from './frame.js';\n\ntype Kind = 'start' | 'end' | 'decision' | 'process';\ninterface Style {\n shape: 'rect' | 'diamond' | 'stadium';\n fill: string;\n stroke: string;\n text: string;\n}\nfunction flowStyle(kind: Kind | undefined): Style {\n switch (kind ?? 'process') {\n case 'start':\n return { shape: 'stadium', fill: '#dcf1e2', stroke: '#1f9747', text: '#0f3d22' };\n case 'end':\n return { shape: 'stadium', fill: '#1a1a2e', stroke: '#1a1a2e', text: '#fff' };\n case 'decision':\n return { shape: 'diamond', fill: '#fde7cd', stroke: '#f7952c', text: '#7a3d00' };\n default:\n return { shape: 'rect', fill: '#e5eff8', stroke: '#0e54a1', text: '#0a3a6e' };\n }\n}\n\nconst ERR_LABEL_RE = /^(no|fail|error|reject)/i;\n\ninterface FlowFrameOpts {\n readonly tag: string;\n readonly tagBg?: string;\n}\n\n/** Generates the inner SVG (no diagram frame) — shared by `flow` and `dag`. */\nexport function renderFlowSvg(data: BlockDataMap['flow']): string {\n const nodes = data.nodes ?? [];\n const edges = data.edges ?? [];\n const cellW = 176;\n const cellH = 70;\n const gapX = 60;\n const gapY = 56;\n const padX = 26;\n const padTop = 26;\n const padBot = 22;\n const cols = Math.max(1, ...nodes.map((n) => n.col + ((n.w ?? 1) - 1)));\n const rows = Math.max(1, ...nodes.map((n) => n.row));\n const xOf = (c: number): number => padX + (c - 1) * (cellW + gapX);\n const yOf = (r: number): number => padTop + (r - 1) * (cellH + gapY);\n const rectFor = (n: { col: number; row: number; w?: number | undefined }): {\n x: number;\n y: number;\n w: number;\n h: number;\n } => ({\n x: xOf(n.col),\n y: yOf(n.row),\n w: (n.w ?? 1) * cellW + ((n.w ?? 1) - 1) * gapX,\n h: cellH,\n });\n const byId = new Map(nodes.map((n) => [n.id, n]));\n const width = padX * 2 + cols * cellW + (cols - 1) * gapX;\n const height = padTop + rows * cellH + (rows - 1) * gapY + padBot;\n\n let s = `<svg viewBox=\"0 0 ${width} ${height}\" role=\"img\"><title>Flowchart</title>`;\n\n for (const e of edges) {\n const A = byId.get(e.from);\n const B = byId.get(e.to);\n if (!A || !B) continue;\n const p = ortho(rectFor(A), rectFor(B));\n const isErr = e.kind === 'error' || ERR_LABEL_RE.test(e.label ?? '');\n const stroke = isErr ? '#991b1b' : '#1a1a2e';\n const marker = isErr ? 'gErr' : 'gArrow';\n const sw = isErr ? 1.6 : 1.4;\n s +=\n `<g><path d=\"${p.d}\" fill=\"none\" stroke=\"${stroke}\" stroke-width=\"${sw}\" marker-end=\"url(#${marker})\"/>` +\n edgePill(p, e.label, isErr) +\n `</g>`;\n }\n\n for (const n of nodes) {\n const r = rectFor(n);\n const st = flowStyle(n.kind);\n const cx = r.x + r.w / 2;\n const cy = r.y + r.h / 2;\n let shape: string;\n if (st.shape === 'diamond') {\n shape = `<polygon points=\"${cx},${r.y} ${r.x + r.w},${cy} ${cx},${r.y + r.h} ${r.x},${cy}\" fill=\"${st.fill}\" stroke=\"${st.stroke}\" stroke-width=\"1.5\"/>`;\n } else if (st.shape === 'stadium') {\n shape = `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"${r.w}\" height=\"${r.h}\" rx=\"${r.h / 2}\" fill=\"${st.fill}\" stroke=\"${st.stroke}\" stroke-width=\"1.5\"/>`;\n } else {\n shape = `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"${r.w}\" height=\"${r.h}\" rx=\"7\" fill=\"${st.fill}\" stroke=\"${st.stroke}\" stroke-width=\"1.4\"/>`;\n }\n const lines = wrapText(n.label, 22, 2);\n const texts = lines\n .map(\n (ln, j) =>\n `<text x=\"${cx}\" y=\"${cy + 4 - (lines.length - 1) * 7 + j * 14}\" class=\"fc-label\" fill=\"${st.text}\">${escapeHtml(ln)}</text>`,\n )\n .join('');\n s += `<g filter=\"url(#gshadow)\">${shape}${texts}</g>`;\n }\n\n s += `</svg>`;\n return s;\n}\n\nfunction renderFlowFrame(data: BlockDataMap['flow'], frame: FlowFrameOpts): string {\n return diagramFrame(\n {\n tag: frame.tag,\n ...(frame.tagBg !== undefined ? { tagBg: frame.tagBg } : {}),\n ...(data.title !== undefined ? { title: data.title } : {}),\n ...(data.description !== undefined ? { desc: data.description } : {}),\n },\n renderFlowSvg(data),\n );\n}\n\n/** `flow` — decision flow with slate `FLOW` tag. */\nexport function renderFlow(data: BlockDataMap['flow']): string {\n return renderFlowFrame(data, { tag: 'FLOW', tagBg: '#374151' });\n}\n/** `dag` — same shape, navy `DAG` tag (pipeline / directed-acyclic graph). */\nexport function renderDag(data: BlockDataMap['dag']): string {\n return renderFlowFrame(data as BlockDataMap['flow'], { tag: 'DAG', tagBg: '#0e54a1' });\n}\n","/**\n * Renders a state machine: rounded state pills + start/terminal markers + an\n * orthogonal-routed edge per transition, plus a transition table below.\n *\n * Ported from doc-studio.jsx `StateMachine` + `TransitionTable`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { ortho } from '../svg/ortho.js';\nimport { edgePill } from '../svg/edgePill.js';\nimport { diagramFrame } from './frame.js';\n\ntype StateNode = NonNullable<BlockDataMap['state']['states']>[number];\n\nfunction rectFor(s: StateNode, cellW: number, cellH: number, gapX: number, gapY: number, padX: number, padTop: number): {\n x: number;\n y: number;\n w: number;\n h: number;\n cx: number;\n cy: number;\n} {\n const cx = padX + (s.col - 1) * (cellW + gapX) + cellW / 2;\n const cy = padTop + (s.row - 1) * (cellH + gapY) + cellH / 2;\n if (s.kind === 'start' || s.kind === 'terminal') {\n return { x: cx - 13, y: cy - 13, w: 26, h: 26, cx, cy };\n }\n const pw = Math.max(96, (s.name ?? '').length * 8 + 26);\n const ph = 46;\n return { x: cx - pw / 2, y: cy - ph / 2, w: pw, h: ph, cx, cy };\n}\n\nfunction pillCls(kind: StateNode['kind']): string {\n if (kind === 'terminal') return 'pill pill-end';\n if (kind === 'wait') return 'pill pill-wait';\n if (kind === 'start') return 'pill pill-init';\n return 'pill pill-active';\n}\n\nexport function renderState(data: BlockDataMap['state']): string {\n const states = data.states ?? [];\n const trans = data.transitions ?? [];\n const cellW = 168;\n const cellH = 64;\n const gapX = 74;\n const gapY = 60;\n const padX = 30;\n const padTop = 30;\n const padBot = 20;\n const cols = Math.max(1, ...states.map((s) => s.col));\n const rows = Math.max(1, ...states.map((s) => s.row));\n const width = padX * 2 + cols * cellW + (cols - 1) * gapX;\n const height = padTop * 2 + rows * cellH + (rows - 1) * gapY + padBot;\n const byId = new Map(states.map((s) => [s.id, s]));\n\n let s = `<svg viewBox=\"0 0 ${width} ${height}\" role=\"img\"><title>State machine</title>`;\n\n // edges first\n for (const t of trans) {\n const A = byId.get(t.from);\n const B = byId.get(t.to);\n if (!A || !B) continue;\n const label = t.event + (t.guard !== undefined ? ` ${t.guard}` : '');\n if (t.from === t.to) {\n const r = rectFor(A, cellW, cellH, gapX, gapY, padX, padTop);\n s +=\n `<g><path d=\"M ${r.cx - 12} ${r.y} C ${r.cx - 30} ${r.y - 32}, ${r.cx + 30} ${r.y - 32}, ${r.cx + 12} ${r.y}\" fill=\"none\" stroke=\"#1a1a2e\" stroke-width=\"1.3\" marker-end=\"url(#gArrow)\"/>` +\n edgePill({ lx: r.cx, ly: r.y - 28 }, label) +\n `</g>`;\n continue;\n }\n const p = ortho(\n rectFor(A, cellW, cellH, gapX, gapY, padX, padTop),\n rectFor(B, cellW, cellH, gapX, gapY, padX, padTop),\n );\n s +=\n `<g><path d=\"${p.d}\" fill=\"none\" stroke=\"#1a1a2e\" stroke-width=\"1.3\" marker-end=\"url(#gArrow)\"/>` +\n edgePill(p, label) +\n `</g>`;\n }\n\n // states\n for (const st of states) {\n const r = rectFor(st, cellW, cellH, gapX, gapY, padX, padTop);\n if (st.kind === 'start') {\n s += `<circle cx=\"${r.cx}\" cy=\"${r.cy}\" r=\"10\" fill=\"#1a1a2e\"/>`;\n } else if (st.kind === 'terminal') {\n s +=\n `<g>` +\n `<circle cx=\"${r.cx}\" cy=\"${r.cy}\" r=\"12\" fill=\"#fff\" stroke=\"#1a1a2e\" stroke-width=\"1.5\"/>` +\n `<circle cx=\"${r.cx}\" cy=\"${r.cy}\" r=\"6\" fill=\"#1a1a2e\"/>` +\n `</g>`;\n } else {\n const fill = st.kind === 'wait' ? '#fde7cd' : '#dcf1e2';\n const stroke = st.kind === 'wait' ? '#f7952c' : '#1f9747';\n s +=\n `<g filter=\"url(#gshadow)\">` +\n `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"${r.w}\" height=\"${r.h}\" rx=\"23\" fill=\"${fill}\" stroke=\"${stroke}\" stroke-width=\"1.5\"/>` +\n `<text x=\"${r.cx}\" y=\"${r.cy + 4.5}\" class=\"sm-name\" fill=\"#1a1a2e\">${escapeHtml(st.name ?? '')}</text>` +\n `</g>`;\n }\n }\n\n s += `</svg>`;\n\n // transition table\n const name = (id: string): string => byId.get(id)?.name ?? id;\n const rows2 = trans\n .map(\n (t) =>\n `<tr>` +\n `<td><span class=\"${pillCls(byId.get(t.from)?.kind)}\">${escapeHtml(name(t.from))}</span></td>` +\n `<td style=\"font-family:var(--font-mono);font-size:11px\">${escapeHtml(t.event)}</td>` +\n `<td style=\"color:#6b7280;font-size:11px\">${escapeHtml(t.guard ?? '—')}</td>` +\n `<td><span class=\"${pillCls(byId.get(t.to)?.kind)}\">${escapeHtml(name(t.to))}</span></td>` +\n `</tr>`,\n )\n .join('');\n const table =\n trans.length > 0\n ? `<table class=\"transition-table\">` +\n `<thead><tr><th>From</th><th>Event</th><th>Guard</th><th>To</th></tr></thead>` +\n `<tbody>${rows2}</tbody></table>`\n : '';\n\n return diagramFrame(\n {\n tag: 'STATE',\n tagBg: '#6b21a8',\n ...(data.title !== undefined ? { title: data.title } : {}),\n ...(data.description !== undefined ? { desc: data.description } : {}),\n },\n s + table,\n );\n}\n","/**\n * Renders a data-flow diagram — process bubbles, external rectangles, and\n * three-sided data-store boxes, with orthogonal edges.\n *\n * Ported from doc-studio.jsx `DFDDiagram` + `dfdStyle`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { ortho } from '../svg/ortho.js';\nimport { edgePill } from '../svg/edgePill.js';\nimport { diagramFrame } from './frame.js';\n\nfunction dfdStyle(kind: string | undefined): { fill: string; stroke: string; text: string } {\n switch ((kind ?? 'process').toLowerCase()) {\n case 'external':\n return { fill: '#f3f4f6', stroke: '#6b7280', text: '#374151' };\n case 'store':\n case 'datastore':\n return { fill: '#fde7cd', stroke: '#f7952c', text: '#7a3d00' };\n default:\n return { fill: '#e5eff8', stroke: '#0e54a1', text: '#0a3a6e' };\n }\n}\n\nexport function renderDfd(data: BlockDataMap['dfd']): string {\n const nodes = data.nodes ?? [];\n const edges = data.edges ?? [];\n const cellW = 168;\n const cellH = 76;\n const gapX = 60;\n const gapY = 58;\n const padX = 26;\n const padTop = 26;\n const padBot = 20;\n const cols = Math.max(1, ...nodes.map((n) => n.col));\n const rows = Math.max(1, ...nodes.map((n) => n.row));\n const xOf = (c: number): number => padX + (c - 1) * (cellW + gapX);\n const yOf = (r: number): number => padTop + (r - 1) * (cellH + gapY);\n const rectFor = (n: { col: number; row: number }): {\n x: number;\n y: number;\n w: number;\n h: number;\n } => ({ x: xOf(n.col), y: yOf(n.row), w: cellW, h: cellH });\n const byId = new Map(nodes.map((n) => [n.id, n]));\n const width = padX * 2 + cols * cellW + (cols - 1) * gapX;\n const height = padTop + rows * cellH + (rows - 1) * gapY + padBot;\n\n let s = `<svg viewBox=\"0 0 ${width} ${height}\" role=\"img\"><title>Data-flow diagram</title>`;\n\n for (const e of edges) {\n const A = byId.get(e.from);\n const B = byId.get(e.to);\n if (!A || !B) continue;\n const p = ortho(rectFor(A), rectFor(B));\n s +=\n `<g><path d=\"${p.d}\" fill=\"none\" stroke=\"#1a1a2e\" stroke-width=\"1.4\" marker-end=\"url(#gArrow)\"/>` +\n edgePill(p, e.label) +\n `</g>`;\n }\n\n for (const n of nodes) {\n const r = rectFor(n);\n const st = dfdStyle(n.kind);\n const k = (n.kind ?? 'process').toLowerCase();\n let shape: string;\n if (k === 'process') {\n shape = `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"${r.w}\" height=\"${r.h}\" rx=\"16\" fill=\"${st.fill}\" stroke=\"${st.stroke}\" stroke-width=\"1.4\"/>`;\n } else if (k === 'store' || k === 'datastore') {\n shape =\n `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"${r.w}\" height=\"${r.h}\" fill=\"${st.fill}\" stroke=\"none\"/>` +\n `<line x1=\"${r.x}\" y1=\"${r.y}\" x2=\"${r.x + r.w}\" y2=\"${r.y}\" stroke=\"${st.stroke}\" stroke-width=\"1.6\"/>` +\n `<line x1=\"${r.x}\" y1=\"${r.y + r.h}\" x2=\"${r.x + r.w}\" y2=\"${r.y + r.h}\" stroke=\"${st.stroke}\" stroke-width=\"1.6\"/>` +\n `<line x1=\"${r.x}\" y1=\"${r.y}\" x2=\"${r.x}\" y2=\"${r.y + r.h}\" stroke=\"${st.stroke}\" stroke-width=\"1.6\"/>`;\n } else {\n shape = `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"${r.w}\" height=\"${r.h}\" fill=\"${st.fill}\" stroke=\"${st.stroke}\" stroke-width=\"1.4\"/>`;\n }\n const num =\n n.num !== undefined && k === 'process'\n ? `<text x=\"${r.x + 12}\" y=\"${r.y + 18}\" class=\"dfd-num\" fill=\"${st.text}\">${escapeHtml(n.num)}</text>`\n : '';\n s +=\n `<g filter=\"url(#gshadow)\">${shape}${num}` +\n `<text x=\"${r.x + r.w / 2}\" y=\"${r.y + r.h / 2 + 4}\" class=\"dfd-name\" fill=\"${st.text}\">${escapeHtml(n.name)}</text>` +\n `</g>`;\n }\n\n s += `</svg>`;\n return diagramFrame(\n {\n tag: 'DFD',\n tagBg: '#0e54a1',\n ...(data.title !== undefined ? { title: data.title } : {}),\n ...(data.description !== undefined ? { desc: data.description } : {}),\n },\n s,\n );\n}\n","/**\n * Renders a user-journey map — a table of touchpoints across stages, plus an\n * optional emotion curve (SVG polyline) showing user sentiment per stage.\n *\n * Ported from doc-studio.jsx `JourneyMap`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\nfunction clamp01(v: number): number {\n if (v < 0) return 0;\n if (v > 1) return 1;\n return v;\n}\n\nexport function renderJourney(data: BlockDataMap['journey']): string {\n const stages = data.stages ?? [];\n const rows = data.rows ?? [];\n const emotion = data.emotion ?? [];\n const n = Math.max(stages.length, 1);\n const W = Math.max(380, n * 150);\n const H = 92;\n const pad = 20;\n const colW = (W - pad * 2) / n;\n const ex = (i: number): number => pad + colW * (i + 0.5);\n const ey = (v: number): number => H - 14 - (H - 30) * clamp01(v);\n\n const head =\n `<tr><th></th>` +\n stages.map((s) => `<th class=\"c\">${escapeHtml(s.label)}</th>`).join('') +\n `</tr>`;\n const body = rows\n .map(\n (r) =>\n `<tr><td class=\"lead\">${escapeHtml(r.label)}</td>` +\n (r.cells ?? []).map((c) => `<td class=\"c\">${escapeHtml(c)}</td>`).join('') +\n `</tr>`,\n )\n .join('');\n\n let svg = '';\n if (emotion.length > 0) {\n const points = emotion.map((v, i) => `${ex(i)},${ey(v)}`).join(' ');\n const dots = emotion\n .map((v, i) => {\n const fill = v >= 0.6 ? '#1f9747' : v <= 0.35 ? '#991b1b' : '#f7952c';\n return `<circle cx=\"${ex(i)}\" cy=\"${ey(v)}\" r=\"5\" fill=\"${fill}\" stroke=\"#fff\" stroke-width=\"1.5\"/>`;\n })\n .join('');\n svg =\n `<div style=\"margin-top:10px\">` +\n `<div style=\"font-size:10px;color:#6b7280;font-weight:700;text-transform:uppercase;letter-spacing:.08em;margin-bottom:4px\">Emotion</div>` +\n `<svg viewBox=\"0 0 ${W} ${H}\" style=\"width:100%\" role=\"img\"><title>Emotion curve</title>` +\n `<polyline points=\"${points}\" fill=\"none\" stroke=\"#0e54a1\" stroke-width=\"2\"/>` +\n dots +\n `</svg></div>`;\n }\n\n return (\n `<div>` +\n `<table class=\"pres-table\"><thead>${head}</thead><tbody>${body}</tbody></table>` +\n svg +\n `</div>`\n );\n}\n","/**\n * Renders a Gantt chart — period columns across the top, task rows with\n * horizontal bars colored by kind (done / active / milestone / default).\n *\n * Ported from doc-studio.jsx `Gantt` + `ganttColor`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\nfunction ganttColor(kind: string | undefined): string {\n switch ((kind ?? '').toLowerCase()) {\n case 'done':\n return '#1f9747';\n case 'active':\n case 'current':\n return '#f7952c';\n case 'milestone':\n return '#6b21a8';\n default:\n return '#0e54a1';\n }\n}\n\nexport function renderGantt(data: BlockDataMap['gantt']): string {\n const periods = data.periods ?? [];\n const tasks = data.tasks ?? [];\n const P = Math.max(periods.length, 1);\n const labelW = 156;\n const padX = 20;\n const padTop = 34;\n const rowH = 30;\n const barH = 18;\n const colW = 64;\n const padBot = 14;\n const width = labelW + padX * 2 + P * colW;\n const height = padTop + tasks.length * rowH + padBot;\n const xCol = (i: number): number => labelW + padX + i * colW;\n\n let s = `<svg viewBox=\"0 0 ${width} ${height}\" role=\"img\"><title>Schedule</title>`;\n for (let i = 0; i < periods.length; i++) {\n s +=\n `<g>` +\n `<line x1=\"${xCol(i)}\" y1=\"${padTop - 6}\" x2=\"${xCol(i)}\" y2=\"${height - padBot}\" stroke=\"#eef0f3\" stroke-width=\"1\"/>` +\n `<text x=\"${xCol(i) + colW / 2}\" y=\"${padTop - 12}\" class=\"gantt-head\">${escapeHtml(periods[i] ?? '')}</text>` +\n `</g>`;\n }\n s += `<line x1=\"${xCol(P)}\" y1=\"${padTop - 6}\" x2=\"${xCol(P)}\" y2=\"${height - padBot}\" stroke=\"#eef0f3\" stroke-width=\"1\"/>`;\n for (let i = 0; i < tasks.length; i++) {\n const t = tasks[i];\n if (t === undefined) continue;\n const y = padTop + i * rowH;\n const bx = xCol(t.start ?? 0);\n const span = Math.max(1, t.span ?? 1);\n const bw = span * colW - 8;\n s +=\n `<g>` +\n `<text x=\"${padX}\" y=\"${y + rowH / 2 + 4}\" class=\"gantt-label\">${escapeHtml(t.label)}</text>` +\n `<rect x=\"${bx + 4}\" y=\"${y + (rowH - barH) / 2}\" width=\"${bw}\" height=\"${barH}\" rx=\"4\" fill=\"${ganttColor(t.kind)}\" filter=\"url(#gshadow)\"/>` +\n `</g>`;\n }\n s += `</svg>`;\n return s;\n}\n","/**\n * Renders a generic node-link graph — rounded pills colored by group, with\n * orthogonal edges (directed or undirected).\n *\n * Ported from doc-studio.jsx `Graph`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { ortho } from '../svg/ortho.js';\nimport { edgePill } from '../svg/edgePill.js';\nimport { diagramFrame } from './frame.js';\n\nconst CHART_COLORS = ['#0e54a1', '#1a6dbe', '#0f766e', '#1f9747', '#6b21a8', '#f7952c'];\n\nexport function renderGraph(data: BlockDataMap['graph']): string {\n const nodes = data.nodes ?? [];\n const edges = data.edges ?? [];\n const cellW = 150;\n const cellH = 84;\n const gapX = 44;\n const gapY = 40;\n const padX = 26;\n const padTop = 24;\n const padBot = 20;\n const cols = Math.max(1, ...nodes.map((n) => n.col));\n const rows = Math.max(1, ...nodes.map((n) => n.row));\n const cxOf = (c: number): number => padX + (c - 1) * (cellW + gapX) + cellW / 2;\n const cyOf = (r: number): number => padTop + (r - 1) * (cellH + gapY) + cellH / 2;\n const rectFor = (n: { col: number; row: number; label: string }): {\n x: number;\n y: number;\n w: number;\n h: number;\n cx: number;\n cy: number;\n } => {\n const cx = cxOf(n.col);\n const cy = cyOf(n.row);\n const w = Math.max(98, n.label.length * 8 + 26);\n return { x: cx - w / 2, y: cy - 20, w, h: 40, cx, cy };\n };\n const byId = new Map(nodes.map((n) => [n.id, n]));\n const width = padX * 2 + cols * cellW + (cols - 1) * gapX;\n const height = padTop + rows * cellH + (rows - 1) * gapY + padBot;\n\n let s = `<svg viewBox=\"0 0 ${width} ${height}\" role=\"img\"><title>Graph</title>`;\n\n for (const e of edges) {\n const A = byId.get(e.from);\n const B = byId.get(e.to);\n if (!A || !B) continue;\n const p = ortho(rectFor(A), rectFor(B));\n const directed = (e.dir ?? 'directed') !== 'undirected';\n const markerAttr = directed ? ` marker-end=\"url(#gArrow)\"` : '';\n s +=\n `<g><path d=\"${p.d}\" fill=\"none\" stroke=\"#6b7280\" stroke-width=\"1.4\"${markerAttr}/>` +\n edgePill(p, e.label) +\n `</g>`;\n }\n\n for (const n of nodes) {\n const r = rectFor(n);\n const c = CHART_COLORS[(n.group ?? 0) % CHART_COLORS.length] ?? '#0e54a1';\n s +=\n `<g filter=\"url(#gshadow)\">` +\n `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"${r.w}\" height=\"${r.h}\" rx=\"20\" fill=\"#fff\" stroke=\"${c}\" stroke-width=\"1.6\"/>` +\n `<text x=\"${r.cx}\" y=\"${r.cy + 4}\" class=\"blk-name\" fill=\"${c}\" text-anchor=\"middle\" style=\"font-size:12px\">${escapeHtml(n.label)}</text>` +\n `</g>`;\n }\n\n s += `</svg>`;\n return diagramFrame(\n {\n tag: 'GRAPH',\n tagBg: '#374151',\n ...(data.title !== undefined ? { title: data.title } : {}),\n ...(data.description !== undefined ? { desc: data.description } : {}),\n },\n s,\n );\n}\n","/**\n * Renders a 2x2 matrix — labelled axes, optional low/high endpoint labels,\n * and dots for each `(x, y, label)` item.\n *\n * Ported from doc-studio.jsx `Quadrant`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { diagramFrame } from './frame.js';\n\nfunction clamp01(v: number | undefined): number {\n if (v === undefined || Number.isNaN(v)) return 0.5;\n if (v < 0) return 0;\n if (v > 1) return 1;\n return v;\n}\n\nexport function renderQuadrant(data: BlockDataMap['quadrant']): string {\n const W = 580;\n const H = 440;\n const pad = 56;\n const x0 = pad;\n const x1 = W - pad;\n const y0 = pad - 16;\n const y1 = H - pad;\n const mx = (x0 + x1) / 2;\n const my = (y0 + y1) / 2;\n const px = (v: number | undefined): number => x0 + (x1 - x0) * clamp01(v);\n const py = (v: number | undefined): number => y1 - (y1 - y0) * clamp01(v);\n const items = data.items ?? [];\n const xA = data.xAxis ?? {};\n const yA = data.yAxis ?? {};\n\n let s = `<svg viewBox=\"0 0 ${W} ${H}\" role=\"img\"><title>Quadrant</title>`;\n s += `<rect x=\"${x0}\" y=\"${y0}\" width=\"${x1 - x0}\" height=\"${y1 - y0}\" fill=\"#fafbfc\" stroke=\"#e5e7eb\"/>`;\n s += `<rect x=\"${mx}\" y=\"${y0}\" width=\"${x1 - mx}\" height=\"${my - y0}\" fill=\"#0e54a1\" fill-opacity=\"0.04\"/>`;\n s += `<line x1=\"${x0}\" y1=\"${my}\" x2=\"${x1}\" y2=\"${my}\" class=\"quad-axis\" marker-end=\"url(#gArrow)\"/>`;\n s += `<line x1=\"${mx}\" y1=\"${y1}\" x2=\"${mx}\" y2=\"${y0}\" class=\"quad-axis\" marker-end=\"url(#gArrow)\"/>`;\n\n if (xA.label !== undefined)\n s += `<text x=\"${x1}\" y=\"${y1 + 30}\" class=\"quad-title\" text-anchor=\"end\">${escapeHtml(xA.label)} →</text>`;\n if (yA.label !== undefined)\n s += `<text x=\"${mx - 8}\" y=\"${y0 - 4}\" class=\"quad-title\" text-anchor=\"end\">↑ ${escapeHtml(yA.label)}</text>`;\n if (xA.low !== undefined)\n s += `<text x=\"${x0}\" y=\"${y1 + 16}\" class=\"quad-end\" text-anchor=\"start\">${escapeHtml(xA.low)}</text>`;\n if (xA.high !== undefined)\n s += `<text x=\"${x1}\" y=\"${y1 + 16}\" class=\"quad-end\" text-anchor=\"end\">${escapeHtml(xA.high)}</text>`;\n if (yA.high !== undefined)\n s += `<text x=\"${x0 - 10}\" y=\"${y0 + 6}\" class=\"quad-end\" text-anchor=\"end\">${escapeHtml(yA.high)}</text>`;\n if (yA.low !== undefined)\n s += `<text x=\"${x0 - 10}\" y=\"${y1}\" class=\"quad-end\" text-anchor=\"end\">${escapeHtml(yA.low)}</text>`;\n\n for (const it of items) {\n const cx = px(it.x);\n const cy = py(it.y);\n const left = cx > mx;\n const tx = cx + (left ? -12 : 12);\n const anchor = left ? 'end' : 'start';\n s +=\n `<g filter=\"url(#gshadow)\">` +\n `<circle cx=\"${cx}\" cy=\"${cy}\" r=\"7\" fill=\"#f7952c\" stroke=\"#fff\" stroke-width=\"1.5\"/>` +\n `<text x=\"${tx}\" y=\"${cy + 4}\" class=\"quad-pt-label\" text-anchor=\"${anchor}\">${escapeHtml(it.label)}</text>` +\n `</g>`;\n }\n\n s += `</svg>`;\n return diagramFrame(\n {\n tag: '2×2',\n tagBg: '#0f766e',\n ...(data.title !== undefined ? { title: data.title } : {}),\n ...(data.description !== undefined ? { desc: data.description } : {}),\n },\n s,\n );\n}\n","/**\n * Renders a swimlane diagram — horizontal lanes per role with labelled steps\n * in column positions, plus orthogonal links between steps.\n *\n * Ported from doc-studio.jsx `Swimlane` + `laneColor`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { ortho } from '../svg/ortho.js';\nimport { wrapText } from '../svg/wrapText.js';\nimport { edgePill } from '../svg/edgePill.js';\nimport { diagramFrame } from './frame.js';\n\nfunction laneColor(kind: string | undefined): { fill: string; stroke: string; text: string } {\n switch ((kind ?? 'action').toLowerCase()) {\n case 'decision':\n return { fill: '#fde7cd', stroke: '#f7952c', text: '#7a3d00' };\n case 'start':\n case 'end':\n return { fill: '#dcf1e2', stroke: '#1f9747', text: '#0f3d22' };\n case 'wait':\n return { fill: '#f3f4f6', stroke: '#6b7280', text: '#374151' };\n default:\n return { fill: '#e5eff8', stroke: '#0e54a1', text: '#0a3a6e' };\n }\n}\n\nexport function renderSwimlane(data: BlockDataMap['swimlane']): string {\n const lanes = data.lanes ?? [];\n const steps = data.steps ?? [];\n const links = data.links ?? [];\n const labelW = 132;\n const padX = 18;\n const padTop = 24;\n const padBot = 20;\n const laneH = 92;\n const colW = 168;\n const gapCol = 34;\n const boxW = 150;\n const boxH = 52;\n const cols = Math.max(1, ...steps.map((s) => s.col));\n const xCol = (c: number): number => labelW + padX + (c - 1) * (colW + gapCol);\n const yLane = (l: number): number => padTop + l * laneH;\n const rectFor = (s: { col: number; lane: number }): {\n x: number;\n y: number;\n w: number;\n h: number;\n } => ({\n x: xCol(s.col) + (colW - boxW) / 2,\n y: yLane(s.lane) + (laneH - boxH) / 2,\n w: boxW,\n h: boxH,\n });\n const byId = new Map(steps.map((s) => [s.id, s]));\n const width = labelW + padX * 2 + cols * colW + (cols - 1) * gapCol;\n const height = padTop + lanes.length * laneH + padBot;\n\n let s = `<svg viewBox=\"0 0 ${width} ${height}\" role=\"img\"><title>Swimlane</title>`;\n\n for (let i = 0; i < lanes.length; i++) {\n const L = lanes[i];\n if (L === undefined) continue;\n s +=\n `<g>` +\n `<rect x=\"${padX}\" y=\"${yLane(i)}\" width=\"${width - padX * 2}\" height=\"${laneH}\" fill=\"${i % 2 ? '#fafafa' : '#fff'}\" stroke=\"#e5e7eb\"/>` +\n `<rect x=\"${padX}\" y=\"${yLane(i)}\" width=\"${labelW}\" height=\"${laneH}\" fill=\"#0e54a1\"/>` +\n `<text x=\"${padX + 14}\" y=\"${yLane(i) + laneH / 2 + 4}\" class=\"sl-lane-label\">${escapeHtml(L.label)}</text>` +\n `</g>`;\n }\n\n for (const lk of links) {\n const A = byId.get(lk.from);\n const B = byId.get(lk.to);\n if (!A || !B) continue;\n const p = ortho(rectFor(A), rectFor(B));\n s +=\n `<g><path d=\"${p.d}\" fill=\"none\" stroke=\"#1a1a2e\" stroke-width=\"1.4\" marker-end=\"url(#gArrow)\"/>` +\n edgePill(p, lk.label) +\n `</g>`;\n }\n\n for (const st of steps) {\n const r = rectFor(st);\n const c = laneColor(st.kind);\n const lines = wrapText(st.label, 20, 2);\n const texts = lines\n .map(\n (ln, j) =>\n `<text x=\"${r.x + r.w / 2}\" y=\"${r.y + r.h / 2 + 4 - (lines.length - 1) * 7 + j * 14}\" class=\"sl-step\" fill=\"${c.text}\">${escapeHtml(ln)}</text>`,\n )\n .join('');\n s +=\n `<g filter=\"url(#gshadow)\">` +\n `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"${r.w}\" height=\"${r.h}\" rx=\"7\" fill=\"${c.fill}\" stroke=\"${c.stroke}\" stroke-width=\"1.3\"/>` +\n texts +\n `</g>`;\n }\n\n s += `</svg>`;\n return diagramFrame(\n {\n tag: 'LANES',\n tagBg: '#0e54a1',\n ...(data.title !== undefined ? { title: data.title } : {}),\n ...(data.description !== undefined ? { desc: data.description } : {}),\n },\n s,\n );\n}\n","/**\n * Shared color palette + node-glyph helpers used by architecture-flavoured\n * blocks (cluster, block, infra, felogic, belogic, …).\n *\n * Ported from doc-studio.jsx `blockStyle` + `nodeGlyph`.\n */\n\n/** Color triple for a node kind: accent (stripe / border), fill, text color. */\nexport interface NodeColors {\n readonly accent: string;\n readonly fill: string;\n readonly text: string;\n}\n\n/** Maps a node `kind` (client / service / store / queue / ...) to colors. */\nexport function blockStyle(kind: string | undefined): NodeColors {\n switch ((kind ?? '').toLowerCase()) {\n case 'client':\n return { accent: '#0e54a1', fill: '#e5eff8', text: '#0a3a6e' };\n case 'service':\n case 'microservice':\n case 'compute':\n case 'container':\n return { accent: '#1f9747', fill: '#dcf1e2', text: '#0f3d22' };\n case 'data':\n return { accent: '#6b21a8', fill: '#ede9fe', text: '#4a1772' };\n case 'store':\n case 'db':\n case 'database':\n return { accent: '#f7952c', fill: '#fde7cd', text: '#7a3d00' };\n case 'bucket':\n case 'blob':\n case 'object':\n return { accent: '#b45309', fill: '#fef3c7', text: '#7a3d00' };\n case 'queue':\n return { accent: '#0f766e', fill: '#ccfbf1', text: '#0f4f49' };\n case 'cache':\n return { accent: '#0891b2', fill: '#cffafe', text: '#0e4f5c' };\n case 'gateway':\n case 'lb':\n return { accent: '#0e54a1', fill: '#cfe0f3', text: '#0a3a6e' };\n case 'function':\n case 'lambda':\n return { accent: '#7c3aed', fill: '#ede9fe', text: '#4a1772' };\n case 'cdn':\n return { accent: '#1a6dbe', fill: '#e5eff8', text: '#0a3a6e' };\n case 'external':\n return { accent: '#6b7280', fill: '#f3f4f6', text: '#374151' };\n case 'producer':\n return { accent: '#1f9747', fill: '#dcf1e2', text: '#0f3d22' };\n case 'topic':\n return { accent: '#0f766e', fill: '#ccfbf1', text: '#0f4f49' };\n case 'consumer':\n return { accent: '#1a6dbe', fill: '#e5eff8', text: '#0a3a6e' };\n case 'context':\n return { accent: '#6b21a8', fill: '#ede9fe', text: '#4a1772' };\n case 'firewall':\n return { accent: '#991b1b', fill: '#fee2e2', text: '#991b1b' };\n default:\n return { accent: '#374151', fill: '#fff', text: '#1a1a2e' };\n }\n}\n\n/**\n * Returns a small SVG glyph (database cylinder, queue bars, function ƒ, …)\n * for the given node kind, or empty string if no glyph applies.\n *\n * @param kind - Node kind.\n * @param x - Glyph top-left x.\n * @param y - Glyph top-left y.\n * @param c - Stroke / fill color.\n */\nexport function nodeGlyph(kind: string | undefined, x: number, y: number, c: string): string {\n const k = (kind ?? '').toLowerCase();\n if (k === 'store' || k === 'db' || k === 'database') {\n return (\n `<g stroke=\"${c}\" stroke-width=\"1.3\" fill=\"none\">` +\n `<ellipse cx=\"${x + 8}\" cy=\"${y + 3}\" rx=\"7\" ry=\"3\"/>` +\n `<path d=\"M${x + 1} ${y + 3} V ${y + 13}\"/>` +\n `<path d=\"M${x + 15} ${y + 3} V ${y + 13}\"/>` +\n `<path d=\"M${x + 1} ${y + 13} a 7 3 0 0 0 14 0\"/>` +\n `</g>`\n );\n }\n if (k === 'bucket' || k === 'blob' || k === 'object') {\n return (\n `<g stroke=\"${c}\" stroke-width=\"1.3\" fill=\"none\">` +\n `<ellipse cx=\"${x + 8}\" cy=\"${y + 3}\" rx=\"7\" ry=\"2.5\"/>` +\n `<path d=\"M${x + 1.5} ${y + 3} L ${x + 3.5} ${y + 14} L ${x + 12.5} ${y + 14} L ${x + 14.5} ${y + 3}\"/>` +\n `</g>`\n );\n }\n if (k === 'queue' || k === 'topic') {\n return (\n `<g stroke=\"${c}\" stroke-width=\"1.6\">` +\n `<path d=\"M${x + 2} ${y + 1} V ${y + 14}\"/>` +\n `<path d=\"M${x + 8} ${y + 1} V ${y + 14}\"/>` +\n `<path d=\"M${x + 14} ${y + 1} V ${y + 14}\"/>` +\n `</g>`\n );\n }\n if (k === 'firewall') {\n return `<path d=\"M${x + 8} ${y} L ${x + 15} ${y + 3} V ${y + 9} Q ${x + 15} ${y + 14} ${x + 8} ${y + 16} Q ${x + 1} ${y + 14} ${x + 1} ${y + 9} V ${y + 3} Z\" fill=\"none\" stroke=\"${c}\" stroke-width=\"1.3\"/>`;\n }\n if (k === 'cache') {\n // stacked slabs (memory layers) — three offset parallelograms\n const slab = (dy: number): string =>\n `<path d=\"M${x + 1} ${y + 5 + dy} L${x + 8} ${y + 2 + dy} L${x + 15} ${y + 5 + dy} L${x + 8} ${y + 8 + dy} Z\" fill=\"none\" stroke=\"${c}\" stroke-width=\"1.2\"/>`;\n return `<g>${slab(0)}${slab(3.5)}${slab(7)}</g>`;\n }\n if (k === 'function' || k === 'lambda') {\n return `<text x=\"${x + 7}\" y=\"${y + 14}\" font-family=\"Georgia, serif\" font-size=\"17\" font-style=\"italic\" font-weight=\"700\" fill=\"${c}\" text-anchor=\"middle\">ƒ</text>`;\n }\n if (k === 'cdn' || k === 'external') {\n return `<path d=\"M${x + 3} ${y + 13} a 4 4 0 0 1 0.5 -8 a 5 5 0 0 1 9.5 1.2 a 3 3 0 0 1 1 6.8 z\" fill=\"none\" stroke=\"${c}\" stroke-width=\"1.3\"/>`;\n }\n if (k === 'gateway' || k === 'lb') {\n return (\n `<g stroke=\"${c}\" stroke-width=\"1.5\" fill=\"none\">` +\n `<path d=\"M${x + 2} ${y + 1} L ${x + 8} ${y + 7} L ${x + 2} ${y + 13}\"/>` +\n `<path d=\"M${x + 8} ${y + 1} L ${x + 14} ${y + 7} L ${x + 8} ${y + 13}\"/>` +\n `</g>`\n );\n }\n if (k === 'service' || k === 'microservice' || k === 'compute' || k === 'container') {\n return (\n `<g stroke=\"${c}\" stroke-width=\"1.3\">` +\n `<rect x=\"${x + 4}\" y=\"${y + 1}\" width=\"11\" height=\"11\" rx=\"1.5\" fill=\"none\"/>` +\n `<rect x=\"${x + 1}\" y=\"${y + 4}\" width=\"11\" height=\"11\" rx=\"1.5\" fill=\"#fff\"/>` +\n `</g>`\n );\n }\n return '';\n}\n\n/** Edge-style preset: per-kind stroke, dash, marker, error flag. */\nexport interface EdgeStyle {\n readonly stroke: string;\n readonly sw: number;\n readonly dash: string;\n readonly marker: string;\n readonly err: boolean;\n}\n\n/** Edge style table — `solid | dashed | forbidden | error` → SVG attributes. */\nexport const GEDGE: Record<string, EdgeStyle> = {\n solid: { stroke: 'var(--charcoal)', sw: 1.4, dash: '', marker: 'gArrow', err: false },\n dashed: { stroke: 'var(--gray)', sw: 1.4, dash: '5 4', marker: 'gSoft', err: false },\n forbidden: { stroke: '#991b1b', sw: 2, dash: '', marker: 'gErr', err: true },\n error: { stroke: '#991b1b', sw: 1.6, dash: '', marker: 'gErr', err: true },\n};\n","/**\n * Renders a C4 model diagram (context / container / component levels).\n *\n * Per-node colour comes from a kind+family lookup (`c4Style`). Optional\n * boundary box wraps the internal nodes (container/component/store). A legend\n * sits below the SVG.\n *\n * Ported from doc-studio.jsx `C4Diagram` + `c4Style`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { ortho } from '../svg/ortho.js';\nimport { wrapText } from '../svg/wrapText.js';\nimport { edgePill } from '../svg/edgePill.js';\nimport { GEDGE } from '../svg/blockStyle.js';\nimport { diagramFrame } from './frame.js';\n\ntype Node = NonNullable<BlockDataMap['c4']['nodes']>[number];\n\ninterface C4Style {\n accent: string;\n fill: string;\n text: string;\n sub: string;\n chip: string;\n solid?: boolean;\n dash?: string;\n}\n\nfunction c4Style(n: Node): C4Style {\n const f = (n.family ?? '').toLowerCase();\n switch (n.kind) {\n case 'person':\n return {\n accent: '#0e54a1',\n fill: '#0e54a1',\n text: '#fff',\n sub: '#cfe0f3',\n chip: 'Person',\n solid: true,\n };\n case 'system':\n return {\n accent: '#1f9747',\n fill: '#dcf1e2',\n text: '#0f3d22',\n sub: '#356b49',\n chip: 'Software System',\n };\n case 'external':\n return {\n accent: '#6b7280',\n fill: '#f3f4f6',\n text: '#374151',\n sub: '#6b7280',\n chip: 'External System',\n };\n case 'store':\n return {\n accent: '#f7952c',\n fill: '#fde7cd',\n text: '#7a3d00',\n sub: '#9a5a12',\n chip: 'Database',\n };\n case 'component':\n if (f === 'repo')\n return {\n accent: '#374151',\n fill: '#f3f4f6',\n text: '#1a1a2e',\n sub: '#374151',\n chip: 'Component',\n };\n if (f === 'external')\n return {\n accent: '#6b7280',\n fill: '#fff',\n text: '#374151',\n sub: '#6b7280',\n chip: 'External',\n dash: '4 3',\n };\n if (f === 'controller')\n return {\n accent: '#0e54a1',\n fill: '#e5eff8',\n text: '#0a3a6e',\n sub: '#365f86',\n chip: 'Component',\n };\n return {\n accent: '#1f9747',\n fill: '#dcf1e2',\n text: '#0f3d22',\n sub: '#356b49',\n chip: 'Component',\n };\n default:\n if (f === 'data')\n return {\n accent: '#6b21a8',\n fill: '#ede9fe',\n text: '#4a1772',\n sub: '#6b21a8',\n chip: 'Container',\n };\n if (f === 'service')\n return {\n accent: '#1f9747',\n fill: '#dcf1e2',\n text: '#0f3d22',\n sub: '#356b49',\n chip: 'Container',\n };\n if (f === 'client')\n return {\n accent: '#0e54a1',\n fill: '#e5eff8',\n text: '#0a3a6e',\n sub: '#365f86',\n chip: 'Container',\n };\n if (f === 'store')\n return {\n accent: '#f7952c',\n fill: '#fde7cd',\n text: '#7a3d00',\n sub: '#9a5a12',\n chip: 'Database',\n };\n return {\n accent: '#0e54a1',\n fill: '#e5eff8',\n text: '#0a3a6e',\n sub: '#365f86',\n chip: 'Container',\n };\n }\n}\n\nconst LEGEND: ReadonlyArray<{ sw: string; label: string }> = [\n { sw: '#0e54a1', label: 'Person' },\n { sw: '#dcf1e2', label: 'System / service' },\n { sw: '#e5eff8', label: 'Container (client)' },\n { sw: '#ede9fe', label: 'Container (data)' },\n { sw: '#fde7cd', label: 'Database' },\n { sw: '#f3f4f6', label: 'External' },\n];\n\nexport function renderC4(data: BlockDataMap['c4']): string {\n const nodes = data.nodes ?? [];\n const edges = data.edges ?? [];\n const byId = new Map(nodes.map((n) => [n.id, n]));\n const cellW = 212;\n const cellH = 102;\n const gapX = 56;\n const gapY = 64;\n const padX = 26;\n const padTop = 46;\n const padBot = 24;\n const cols = Math.max(1, ...nodes.map((n) => n.col + ((n.w ?? 1) - 1)));\n const rows = Math.max(1, ...nodes.map((n) => n.row));\n const rectFor = (n: Node): { x: number; y: number; w: number; h: number } => ({\n x: padX + (n.col - 1) * (cellW + gapX),\n y: padTop + (n.row - 1) * (cellH + gapY),\n w: (n.w ?? 1) * cellW + ((n.w ?? 1) - 1) * gapX,\n h: cellH,\n });\n const width = padX * 2 + cols * cellW + (cols - 1) * gapX;\n const height = padTop + rows * cellH + (rows - 1) * gapY + padBot;\n\n // Boundary box around the \"internal\" nodes (container/component/store)\n let boundarySvg = '';\n if (data.boundary !== undefined) {\n const internals = nodes\n .filter((n) => n.kind === 'container' || n.kind === 'component' || n.kind === 'store')\n .map(rectFor);\n if (internals.length > 0) {\n const minX = Math.min(...internals.map((r) => r.x)) - 16;\n const minY = Math.min(...internals.map((r) => r.y)) - 26;\n const maxX = Math.max(...internals.map((r) => r.x + r.w)) + 16;\n const maxY = Math.max(...internals.map((r) => r.y + r.h)) + 16;\n const w = Math.max(120, data.boundary.label.length * 6.2);\n boundarySvg =\n `<g>` +\n `<rect x=\"${minX}\" y=\"${minY}\" width=\"${maxX - minX}\" height=\"${maxY - minY}\" rx=\"12\" class=\"c4-boundary\"/>` +\n `<rect x=\"${minX + 12}\" y=\"${minY - 8}\" width=\"${w}\" height=\"16\" fill=\"#fff\"/>` +\n `<text x=\"${minX + 16}\" y=\"${minY + 4}\" class=\"c4-boundary-label\">${escapeHtml(data.boundary.label)}</text>` +\n `</g>`;\n }\n }\n\n let s = `<svg viewBox=\"0 0 ${width} ${height}\" role=\"img\"><title>C4 diagram</title>${boundarySvg}`;\n\n for (const e of edges) {\n const A = byId.get(e.from);\n const B = byId.get(e.to);\n if (!A || !B) continue;\n const p = ortho(rectFor(A), rectFor(B));\n const st = GEDGE[e.kind ?? 'solid'] ??\n GEDGE['solid'] ?? {\n stroke: '#1a1a2e',\n sw: 1.4,\n dash: '',\n marker: 'gArrow',\n err: false,\n };\n s +=\n `<g><path d=\"${p.d}\" fill=\"none\" stroke=\"${st.stroke}\" stroke-width=\"${st.sw}\" stroke-dasharray=\"${st.dash}\" marker-end=\"url(#${st.marker})\"/>` +\n edgePill(p, e.label, st.err) +\n `</g>`;\n }\n\n for (const n of nodes) {\n const r = rectFor(n);\n const st = c4Style(n);\n const px = r.x + 16;\n const desc = wrapText(n.desc, 30, 2);\n const strokeWidth = st.solid === true ? 0 : 1.2;\n const strokeAttr = st.solid === true ? 'none' : st.accent;\n const dashAttr = st.dash !== undefined ? ` stroke-dasharray=\"${st.dash}\"` : '';\n const stripe =\n st.solid === true\n ? ''\n : `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"5\" height=\"${r.h}\" rx=\"2\" fill=\"${st.accent}\"/>`;\n const personGlyph =\n n.kind === 'person'\n ? `<g fill=\"${st.text}\"><circle cx=\"${px + 6}\" cy=\"${r.y + 19}\" r=\"6\"/><path d=\"M ${px} ${r.y + 34} a 6 7 0 0 1 12 0 z\"/></g>`\n : '';\n const chipX = n.kind === 'person' ? px + 22 : px;\n const chipFill = st.solid === true ? st.sub : st.accent;\n const techLine =\n n.tech !== undefined\n ? `<text x=\"${px}\" y=\"${r.y + 60}\" class=\"c4-tech\" fill=\"${st.sub}\">${escapeHtml(n.tech)}</text>`\n : '';\n const descLines = desc\n .map(\n (ln, j) =>\n `<text x=\"${px}\" y=\"${r.y + 77 + j * 13}\" class=\"c4-desc\" fill=\"${st.sub}\">${escapeHtml(ln)}</text>`,\n )\n .join('');\n s +=\n `<g filter=\"url(#gshadow)\">` +\n `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"${r.w}\" height=\"${r.h}\" rx=\"10\" fill=\"${st.fill}\" stroke=\"${strokeAttr}\" stroke-width=\"${strokeWidth}\"${dashAttr}/>` +\n stripe +\n personGlyph +\n `<text x=\"${chipX}\" y=\"${r.y + 22}\" class=\"c4-chip\" fill=\"${chipFill}\">${escapeHtml(st.chip)}</text>` +\n `<text x=\"${px}\" y=\"${r.y + 44}\" class=\"c4-name\" fill=\"${st.text}\">${escapeHtml(n.name)}</text>` +\n techLine +\n descLines +\n `</g>`;\n }\n\n s += `</svg>`;\n const legend =\n `<div class=\"legend\">` +\n LEGEND.map(\n (l) =>\n `<span class=\"item\"><span class=\"sw\" style=\"background:${l.sw};border:1px solid #d1d5db\"></span>${escapeHtml(l.label)}</span>`,\n ).join('') +\n `</div>`;\n\n return diagramFrame(\n {\n tag: 'C4',\n tagClass: 'c4',\n ...(data.title !== undefined ? { title: data.title } : {}),\n ...(data.description !== undefined ? { desc: data.description } : {}),\n },\n s + legend,\n );\n}\n","/**\n * Renders a UML class diagram — class boxes with stereotype, name, attributes,\n * and methods compartments; orthogonal-routed relationships with kind-specific\n * markers (inheritance triangle, composition diamond, etc.).\n *\n * Ported from doc-studio.jsx `UMLDiagram` + `umlRel`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { ortho } from '../svg/ortho.js';\nimport { edgePill } from '../svg/edgePill.js';\nimport { diagramFrame } from './frame.js';\n\ntype UmlClass = NonNullable<BlockDataMap['uml']['classes']>[number];\n\ninterface UmlRelStyle {\n dash: string;\n start?: string;\n end?: string;\n}\n\nfunction umlRel(kind: string | undefined): UmlRelStyle {\n switch ((kind ?? 'association').toLowerCase()) {\n case 'inheritance':\n case 'extends':\n return { dash: '', end: 'umlTri' };\n case 'implementation':\n case 'implements':\n return { dash: '6 4', end: 'umlTri' };\n case 'composition':\n return { dash: '', start: 'umlDiaF' };\n case 'aggregation':\n return { dash: '', start: 'umlDiaH' };\n case 'dependency':\n return { dash: '6 4', end: 'umlOpen' };\n default:\n return { dash: '', end: 'umlOpen' };\n }\n}\n\nexport function renderUml(data: BlockDataMap['uml']): string {\n const classes = data.classes ?? [];\n const rels = data.rels ?? [];\n const colW = 204;\n const gapX = 64;\n const gapY = 50;\n const padX = 26;\n const padTop = 30;\n const padBot = 22;\n const rowH = 17;\n const headH = (c: UmlClass): number => 28 + (c.stereotype !== undefined ? 12 : 0);\n const compH = (list: readonly string[] | undefined): number =>\n (list !== undefined && list.length > 0 ? list.length * rowH : 6) + 8;\n const clsH = (c: UmlClass): number => headH(c) + compH(c.attrs) + compH(c.methods);\n\n const cols = Math.max(1, ...classes.map((c) => c.col));\n const rows = Math.max(1, ...classes.map((c) => c.row));\n const bandH = new Map<number, number>();\n const bandTop = new Map<number, number>();\n let acc = padTop;\n for (let r = 1; r <= rows; r++) {\n const hs = classes.filter((c) => c.row === r).map(clsH);\n const h = hs.length > 0 ? Math.max(...hs) : 60;\n bandH.set(r, h);\n bandTop.set(r, acc);\n acc += h + gapY;\n }\n const xOf = (c: number): number => padX + (c - 1) * (colW + gapX);\n const rectFor = (c: UmlClass): { x: number; y: number; w: number; h: number } => ({\n x: xOf(c.col),\n y: bandTop.get(c.row) ?? padTop,\n w: colW,\n h: clsH(c),\n });\n const byId = new Map(classes.map((c) => [c.id, c]));\n const width = padX * 2 + cols * colW + (cols - 1) * gapX;\n const height = acc - gapY + padBot;\n\n let s =\n `<svg viewBox=\"0 0 ${width} ${height}\" role=\"img\"><title>UML class diagram</title>` +\n `<defs>` +\n `<marker id=\"umlTri\" viewBox=\"0 0 14 14\" refX=\"13\" refY=\"7\" markerWidth=\"15\" markerHeight=\"15\" orient=\"auto-start-reverse\">` +\n `<path d=\"M1,1 L13,7 L1,13 z\" fill=\"#fff\" stroke=\"#1a1a2e\" stroke-width=\"1.2\"/></marker>` +\n `<marker id=\"umlDiaF\" viewBox=\"0 0 20 12\" refX=\"19\" refY=\"6\" markerWidth=\"20\" markerHeight=\"12\" orient=\"auto-start-reverse\">` +\n `<path d=\"M1,6 L10,1 L19,6 L10,11 z\" fill=\"#1a1a2e\"/></marker>` +\n `<marker id=\"umlDiaH\" viewBox=\"0 0 20 12\" refX=\"19\" refY=\"6\" markerWidth=\"20\" markerHeight=\"12\" orient=\"auto-start-reverse\">` +\n `<path d=\"M1,6 L10,1 L19,6 L10,11 z\" fill=\"#fff\" stroke=\"#1a1a2e\" stroke-width=\"1.2\"/></marker>` +\n `<marker id=\"umlOpen\" viewBox=\"0 0 12 12\" refX=\"10\" refY=\"6\" markerWidth=\"12\" markerHeight=\"12\" orient=\"auto-start-reverse\">` +\n `<path d=\"M1,1 L11,6 L1,11\" fill=\"none\" stroke=\"#1a1a2e\" stroke-width=\"1.3\"/></marker>` +\n `</defs>`;\n\n for (const rl of rels) {\n const A = byId.get(rl.from);\n const B = byId.get(rl.to);\n if (!A || !B) continue;\n const p = ortho(rectFor(A), rectFor(B));\n const st = umlRel(rl.kind);\n const start = st.start !== undefined ? ` marker-start=\"url(#${st.start})\"` : '';\n const end = st.end !== undefined ? ` marker-end=\"url(#${st.end})\"` : '';\n s +=\n `<g><path d=\"${p.d}\" fill=\"none\" stroke=\"#1a1a2e\" stroke-width=\"1.3\" stroke-dasharray=\"${st.dash}\"${start}${end}/>` +\n edgePill(p, rl.label) +\n `</g>`;\n }\n\n for (const c of classes) {\n const r = rectFor(c);\n const hh = headH(c);\n const aH = compH(c.attrs);\n const nameY = r.y + (c.stereotype !== undefined ? 24 : 19);\n const stereo =\n c.stereotype !== undefined\n ? `<text x=\"${r.x + r.w / 2}\" y=\"${r.y + 13}\" class=\"uml-stereo\">«${escapeHtml(c.stereotype)}»</text>`\n : '';\n const attrs = (c.attrs ?? [])\n .map(\n (a, j) =>\n `<text x=\"${r.x + 10}\" y=\"${r.y + hh + 14 + j * rowH}\" class=\"uml-row\">${escapeHtml(a)}</text>`,\n )\n .join('');\n const methods = (c.methods ?? [])\n .map(\n (m, j) =>\n `<text x=\"${r.x + 10}\" y=\"${r.y + hh + aH + 14 + j * rowH}\" class=\"uml-row\">${escapeHtml(m)}</text>`,\n )\n .join('');\n s +=\n `<g filter=\"url(#gshadow)\">` +\n `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"${r.w}\" height=\"${r.h}\" rx=\"3\" fill=\"#fff\" stroke=\"#0e54a1\" stroke-width=\"1.3\"/>` +\n stereo +\n `<text x=\"${r.x + r.w / 2}\" y=\"${nameY}\" class=\"uml-name\">${escapeHtml(c.name)}</text>` +\n `<line x1=\"${r.x}\" y1=\"${r.y + hh}\" x2=\"${r.x + r.w}\" y2=\"${r.y + hh}\" class=\"uml-sep\"/>` +\n attrs +\n `<line x1=\"${r.x}\" y1=\"${r.y + hh + aH}\" x2=\"${r.x + r.w}\" y2=\"${r.y + hh + aH}\" class=\"uml-sep\"/>` +\n methods +\n `</g>`;\n }\n\n s += `</svg>`;\n return diagramFrame(\n {\n tag: 'UML',\n tagBg: '#6b21a8',\n ...(data.title !== undefined ? { title: data.title } : {}),\n ...(data.description !== undefined ? { desc: data.description } : {}),\n },\n s,\n );\n}\n","/**\n * Renders a MECE (Mutually Exclusive, Collectively Exhaustive) issue tree —\n * a left-to-right hierarchical tree with depth-based colour stripes.\n *\n * Layout uses DFS positioning: leaves stack vertically, branches center over\n * their first/last child.\n *\n * Ported from doc-studio.jsx `MECETree` + `meceStyle`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { wrapText } from '../svg/wrapText.js';\nimport { diagramFrame } from './frame.js';\n\ntype Node = NonNullable<BlockDataMap['mece']['nodes']>[number];\n\nconst CHART_COLORS = ['#0e54a1', '#1a6dbe', '#0f766e', '#1f9747', '#6b21a8', '#f7952c'];\n\ninterface MeceStyle {\n fill: string;\n text: string;\n accent: string;\n solid?: boolean;\n}\n\nfunction meceStyle(d: number): MeceStyle {\n if (d === 0) return { fill: '#0e54a1', text: '#fff', accent: '#0e54a1', solid: true };\n const c = CHART_COLORS[d % CHART_COLORS.length] ?? '#0e54a1';\n return { fill: '#fff', text: c, accent: c };\n}\n\nexport function renderMece(data: BlockDataMap['mece']): string {\n const nodes = data.nodes ?? [];\n const byId = new Map<string, Node>();\n const children = new Map<string, string[]>();\n for (const n of nodes) {\n byId.set(n.id, n);\n children.set(n.id, []);\n }\n const roots: string[] = [];\n for (const n of nodes) {\n if (n.parent !== undefined && byId.has(n.parent)) children.get(n.parent)?.push(n.id);\n else roots.push(n.id);\n }\n\n const pos = new Map<string, number>();\n const depth = new Map<string, number>();\n const seen = new Set<string>();\n let leaf = 0;\n let maxDepth = 0;\n const dfs = (id: string, d: number): void => {\n if (seen.has(id)) return;\n seen.add(id);\n depth.set(id, d);\n if (d > maxDepth) maxDepth = d;\n const ch = children.get(id) ?? [];\n if (ch.length === 0) {\n pos.set(id, leaf);\n leaf += 1;\n } else {\n for (const c of ch) dfs(c, d + 1);\n const first = pos.get(ch[0] ?? '') ?? 0;\n const last = pos.get(ch[ch.length - 1] ?? '') ?? 0;\n pos.set(id, (first + last) / 2);\n }\n };\n for (const r of roots) dfs(r, 0);\n\n const nodeW = 168;\n const nodeH = 50;\n const gapY = 16;\n const colGap = 56;\n const padX = 24;\n const padTop = 18;\n const padBot = 18;\n const xOf = (id: string): number => padX + (depth.get(id) ?? 0) * (nodeW + colGap);\n const yOf = (id: string): number => padTop + (pos.get(id) ?? 0) * (nodeH + gapY);\n const width = padX * 2 + (maxDepth + 1) * nodeW + maxDepth * colGap;\n const height = padTop + Math.max(leaf, 1) * (nodeH + gapY) - gapY + padBot;\n\n let s = `<svg viewBox=\"0 0 ${width} ${height}\" role=\"img\"><title>Issue tree</title>`;\n\n // links\n for (const n of nodes) {\n if (n.parent === undefined || !byId.has(n.parent) || !pos.has(n.id)) continue;\n const px = xOf(n.parent) + nodeW;\n const pcy = yOf(n.parent) + nodeH / 2;\n const cx = xOf(n.id);\n const ccy = yOf(n.id) + nodeH / 2;\n const midX = (px + cx) / 2;\n s += `<path class=\"tree-link\" d=\"M ${px} ${pcy} H ${midX} V ${ccy} H ${cx}\"/>`;\n }\n\n // nodes — wrap label to fit inside the box (max width ~150px, ~20 chars per line).\n // If a note is present, the label is single-line; otherwise allow up to two lines.\n for (const n of nodes) {\n if (!pos.has(n.id)) continue;\n const x = xOf(n.id);\n const y = yOf(n.id);\n const st = meceStyle(depth.get(n.id) ?? 0);\n const stroke = st.solid === true ? 'none' : st.accent;\n const stripe =\n st.solid === true\n ? ''\n : `<rect x=\"${x}\" y=\"${y}\" width=\"5\" height=\"${nodeH}\" rx=\"2\" fill=\"${st.accent}\"/>`;\n const labelX = x + (st.solid === true ? nodeW / 2 : 14);\n const anchor = st.solid === true ? 'middle' : 'start';\n const lines = wrapText(n.label, st.solid === true ? 22 : 20, n.note !== undefined ? 1 : 2);\n const startY =\n lines.length === 2\n ? y + 22\n : y + (n.note !== undefined ? 22 : 30);\n const labelTexts = lines\n .map(\n (ln, j) =>\n `<text x=\"${labelX}\" y=\"${startY + j * 14}\" class=\"blk-name\" fill=\"${st.text}\" text-anchor=\"${anchor}\">${escapeHtml(ln)}</text>`,\n )\n .join('');\n const note =\n n.note !== undefined\n ? `<text x=\"${labelX}\" y=\"${y + 38}\" class=\"ft-note\" fill=\"${st.solid === true ? '#cfe0f3' : st.accent}\" text-anchor=\"${anchor}\">${escapeHtml(n.note)}</text>`\n : '';\n s +=\n `<g filter=\"url(#gshadow)\">` +\n `<rect x=\"${x}\" y=\"${y}\" width=\"${nodeW}\" height=\"${nodeH}\" rx=\"6\" fill=\"${st.fill}\" stroke=\"${stroke}\" stroke-width=\"1.3\"/>` +\n stripe +\n labelTexts +\n note +\n `</g>`;\n }\n\n s += `</svg>`;\n return diagramFrame(\n {\n tag: 'MECE',\n tagBg: '#0f766e',\n ...(data.title !== undefined ? { title: data.title } : {}),\n ...(data.description !== undefined ? { desc: data.description } : {}),\n },\n s,\n );\n}\n","/**\n * Renders a top-down component tree — typical React/Vue hierarchy. Each node\n * has a `kind` (root, layout, page, component, leaf, provider, hook, store)\n * that drives its colour.\n *\n * Layout uses DFS positioning, children laid out left-to-right, parents\n * centered above their first/last child.\n *\n * Ported from doc-studio.jsx `ComponentTree` + `ftStyle`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { wrapText } from '../svg/wrapText.js';\nimport { diagramFrame } from './frame.js';\n\ntype Node = NonNullable<BlockDataMap['frontend']['nodes']>[number];\n\ninterface FtStyle {\n accent: string;\n fill: string;\n text: string;\n solid?: boolean;\n}\n\nfunction ftStyle(kind: string | undefined): FtStyle {\n switch ((kind ?? 'component').toLowerCase()) {\n case 'root':\n return { accent: '#0e54a1', fill: '#0e54a1', text: '#fff', solid: true };\n case 'layout':\n return { accent: '#0f766e', fill: '#ccfbf1', text: '#0f4f49' };\n case 'page':\n return { accent: '#0e54a1', fill: '#e5eff8', text: '#0a3a6e' };\n case 'component':\n return { accent: '#1f9747', fill: '#dcf1e2', text: '#0f3d22' };\n case 'leaf':\n return { accent: '#6b7280', fill: '#f3f4f6', text: '#374151' };\n case 'provider':\n case 'context':\n return { accent: '#6b21a8', fill: '#ede9fe', text: '#4a1772' };\n case 'hook':\n return { accent: '#7c3aed', fill: '#ede9fe', text: '#4a1772' };\n case 'store':\n case 'state':\n return { accent: '#f7952c', fill: '#fde7cd', text: '#7a3d00' };\n default:\n return { accent: '#1f9747', fill: '#dcf1e2', text: '#0f3d22' };\n }\n}\n\nexport function renderFrontend(data: BlockDataMap['frontend']): string {\n const nodes = data.nodes ?? [];\n const byId = new Map<string, Node>();\n const children = new Map<string, string[]>();\n for (const n of nodes) {\n byId.set(n.id, n);\n children.set(n.id, []);\n }\n const roots: string[] = [];\n for (const n of nodes) {\n if (n.parent !== undefined && byId.has(n.parent)) children.get(n.parent)?.push(n.id);\n else roots.push(n.id);\n }\n\n const pos = new Map<string, number>();\n const depth = new Map<string, number>();\n const seen = new Set<string>();\n let leaf = 0;\n let maxDepth = 0;\n const dfs = (id: string, d: number): void => {\n if (seen.has(id)) return;\n seen.add(id);\n depth.set(id, d);\n if (d > maxDepth) maxDepth = d;\n const ch = children.get(id) ?? [];\n if (ch.length === 0) {\n pos.set(id, leaf);\n leaf += 1;\n } else {\n for (const c of ch) dfs(c, d + 1);\n const first = pos.get(ch[0] ?? '') ?? 0;\n const last = pos.get(ch[ch.length - 1] ?? '') ?? 0;\n pos.set(id, (first + last) / 2);\n }\n };\n for (const r of roots) dfs(r, 0);\n\n const nodeW = 158;\n const nodeH = 56;\n const gapX = 24;\n const levelGap = 96;\n const padX = 24;\n const padTop = 18;\n const padBot = 18;\n const slot = Math.max(leaf, 1);\n const xOf = (id: string): number => padX + (pos.get(id) ?? 0) * (nodeW + gapX);\n const yOf = (id: string): number => padTop + (depth.get(id) ?? 0) * levelGap;\n const width = padX * 2 + slot * (nodeW + gapX) - gapX;\n const height = padTop + maxDepth * levelGap + nodeH + padBot;\n\n let s = `<svg viewBox=\"0 0 ${width} ${height}\" role=\"img\"><title>Component tree</title>`;\n\n // links\n for (const n of nodes) {\n if (n.parent === undefined || !byId.has(n.parent) || !pos.has(n.id)) continue;\n const pcx = xOf(n.parent) + nodeW / 2;\n const pby = yOf(n.parent) + nodeH;\n const ccx = xOf(n.id) + nodeW / 2;\n const cty = yOf(n.id);\n const midY = (pby + cty) / 2;\n s += `<path class=\"tree-link\" d=\"M ${pcx} ${pby} V ${midY} H ${ccx} V ${cty}\"/>`;\n }\n\n // nodes — wrap name to fit inside the box (~158px, ~20 chars per line).\n // With a note: single-line name. Without a note: up to two lines.\n for (const n of nodes) {\n if (!pos.has(n.id)) continue;\n const x = xOf(n.id);\n const y = yOf(n.id);\n const st = ftStyle(n.kind);\n const stroke = st.solid === true ? 'none' : st.accent;\n const stripe =\n st.solid === true\n ? ''\n : `<rect x=\"${x}\" y=\"${y}\" width=\"5\" height=\"${nodeH}\" rx=\"2\" fill=\"${st.accent}\"/>`;\n const labelX = x + (st.solid === true ? nodeW / 2 : 14);\n const anchor = st.solid === true ? 'middle' : 'start';\n const lines = wrapText(n.name, st.solid === true ? 20 : 18, n.note !== undefined ? 1 : 2);\n const startY =\n lines.length === 2\n ? y + 25\n : y + (n.note !== undefined ? 25 : 33);\n const labelTexts = lines\n .map(\n (ln, j) =>\n `<text x=\"${labelX}\" y=\"${startY + j * 14}\" class=\"blk-name\" fill=\"${st.text}\" text-anchor=\"${anchor}\">${escapeHtml(ln)}</text>`,\n )\n .join('');\n const note =\n n.note !== undefined\n ? `<text x=\"${labelX}\" y=\"${y + 41}\" class=\"ft-note\" fill=\"${st.solid === true ? '#cfe0f3' : st.accent}\" text-anchor=\"${anchor}\">${escapeHtml(n.note)}</text>`\n : '';\n s +=\n `<g filter=\"url(#gshadow)\">` +\n `<rect x=\"${x}\" y=\"${y}\" width=\"${nodeW}\" height=\"${nodeH}\" rx=\"8\" fill=\"${st.fill}\" stroke=\"${stroke}\" stroke-width=\"1.2\"/>` +\n stripe +\n labelTexts +\n note +\n `</g>`;\n }\n\n s += `</svg>`;\n return diagramFrame(\n {\n tag: 'FE',\n tagBg: '#0f766e',\n ...(data.title !== undefined ? { title: data.title } : {}),\n ...(data.description !== undefined ? { desc: data.description } : {}),\n },\n s,\n );\n}\n","/**\n * Renders a cluster diagram (Kubernetes-style) — nested cluster boxes with\n * service tiles inside, optional replica counts as bar marks, and\n * orthogonal-routed edges between services across clusters.\n *\n * Ported from doc-studio.jsx `ClusterDiagram`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { ortho } from '../svg/ortho.js';\nimport { edgePill } from '../svg/edgePill.js';\nimport { blockStyle, nodeGlyph, GEDGE } from '../svg/blockStyle.js';\nimport { diagramFrame } from './frame.js';\n\ntype Service = NonNullable<BlockDataMap['cluster']['services']>[number];\n\nexport function renderCluster(data: BlockDataMap['cluster']): string {\n const clusters = data.clusters ?? [];\n const services = data.services ?? [];\n const edges = data.edges ?? [];\n const svcByCluster = new Map<string, Service[]>();\n for (const c of clusters) svcByCluster.set(c.id, []);\n for (const sv of services) {\n const list = svcByCluster.get(sv.cluster);\n if (list !== undefined) list.push(sv);\n }\n const serviceW = 158;\n const serviceH = 78;\n const gapS = 22;\n const cPadX = 26;\n const cHeader = 38;\n const cPadTop = 18;\n const cPadBot = 22;\n const cGap = 28;\n const outerPad = 26;\n\n let maxPerCluster = 1;\n for (const list of svcByCluster.values()) {\n if (list.length > maxPerCluster) maxPerCluster = list.length;\n }\n const cols = Math.min(4, Math.max(1, maxPerCluster));\n const clusterW = cols * serviceW + (cols - 1) * gapS + cPadX * 2;\n const width = outerPad * 2 + clusterW;\n\n interface Rect {\n x: number;\n y: number;\n w: number;\n h: number;\n }\n const rects = new Map<string, Rect>();\n interface ClusterBox {\n c: NonNullable<BlockDataMap['cluster']['clusters']>[number];\n x: number;\n y: number;\n w: number;\n h: number;\n }\n const clusterBoxes: ClusterBox[] = [];\n\n let y = outerPad;\n for (const c of clusters) {\n const list = svcByCluster.get(c.id) ?? [];\n const rows = Math.max(1, Math.ceil(list.length / cols));\n const h = cHeader + cPadTop + rows * serviceH + (rows - 1) * gapS + cPadBot;\n const cx = outerPad;\n clusterBoxes.push({ c, x: cx, y, w: clusterW, h });\n list.forEach((sv, i) => {\n const r = Math.floor(i / cols);\n const col = i % cols;\n rects.set(sv.id, {\n x: cx + cPadX + col * (serviceW + gapS),\n y: y + cHeader + cPadTop + r * (serviceH + gapS),\n w: serviceW,\n h: serviceH,\n });\n });\n y += h + cGap;\n }\n const height = y - cGap + outerPad;\n\n let s = `<svg viewBox=\"0 0 ${width} ${height}\" role=\"img\"><title>Cluster diagram</title>`;\n\n // cluster shells\n for (const cb of clusterBoxes) {\n const kindLabel =\n cb.c.kind !== undefined\n ? `<text x=\"${cb.x + cb.w - 14}\" y=\"${cb.y + 21}\" class=\"cl-kind\">${escapeHtml(cb.c.kind)}</text>`\n : '';\n s +=\n `<g>` +\n `<rect x=\"${cb.x}\" y=\"${cb.y}\" width=\"${cb.w}\" height=\"${cb.h}\" rx=\"12\" fill=\"#0e54a1\" fill-opacity=\"0.035\" stroke=\"#0e54a1\" stroke-width=\"1.4\" stroke-dasharray=\"8 5\"/>` +\n `<rect x=\"${cb.x}\" y=\"${cb.y}\" width=\"${cb.w}\" height=\"${cHeader}\" rx=\"12\" fill=\"#0e54a1\"/>` +\n `<rect x=\"${cb.x}\" y=\"${cb.y + cHeader - 12}\" width=\"${cb.w}\" height=\"12\" fill=\"#0e54a1\"/>` +\n `<text x=\"${cb.x + 16}\" y=\"${cb.y + 21}\" class=\"cl-head\">${escapeHtml(cb.c.label)}</text>` +\n kindLabel +\n `</g>`;\n }\n\n // edges\n for (const e of edges) {\n const A = rects.get(e.from);\n const B = rects.get(e.to);\n if (!A || !B) continue;\n const p = ortho(A, B);\n const st = GEDGE[e.kind ?? 'solid'] ?? GEDGE['solid'] ?? {\n stroke: '#1a1a2e',\n sw: 1.4,\n dash: '',\n marker: 'gArrow',\n err: false,\n };\n s +=\n `<g><path d=\"${p.d}\" fill=\"none\" stroke=\"${st.stroke}\" stroke-width=\"${st.sw}\" stroke-dasharray=\"${st.dash}\" marker-end=\"url(#${st.marker})\"/>` +\n edgePill(p, e.label, st.err) +\n `</g>`;\n }\n\n // services\n for (const sv of services) {\n const r = rects.get(sv.id);\n if (r === undefined) continue;\n const st = blockStyle(sv.kind);\n const gl = nodeGlyph(sv.kind, r.x + 14, r.y + 14, st.accent);\n const nx = gl.length > 0 ? r.x + 38 : r.x + 14;\n const reps = sv.replicas ?? 0;\n const techLine =\n sv.tech !== undefined\n ? `<text x=\"${nx}\" y=\"${r.y + 42}\" class=\"blk-tech\" fill=\"${st.accent}\">${escapeHtml(sv.tech)}</text>`\n : '';\n const repIndicator =\n reps > 0\n ? (() => {\n const shown = Math.min(reps, 5);\n let bars = '';\n for (let j = 0; j < shown; j++) {\n bars += `<rect x=\"${r.x + 12 + j * 8}\" y=\"${r.y + r.h - 14}\" width=\"5\" height=\"8\" rx=\"1\" fill=\"${st.accent}\" opacity=\"0.7\"/>`;\n }\n return (\n `<g>` +\n bars +\n `<text x=\"${r.x + 12 + shown * 8 + 4}\" y=\"${r.y + r.h - 7}\" class=\"blk-tech\" fill=\"${st.accent}\">×${reps}</text>` +\n `</g>`\n );\n })()\n : '';\n s +=\n `<g filter=\"url(#gshadow)\">` +\n `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"${r.w}\" height=\"${r.h}\" rx=\"8\" fill=\"${st.fill}\" stroke=\"${st.accent}\" stroke-width=\"1.2\"/>` +\n `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"5\" height=\"${r.h}\" rx=\"2\" fill=\"${st.accent}\"/>` +\n gl +\n `<text x=\"${nx}\" y=\"${r.y + (sv.tech !== undefined ? 26 : 30)}\" class=\"blk-name\" fill=\"${st.text}\" style=\"font-size:12px\">${escapeHtml(sv.label)}</text>` +\n techLine +\n repIndicator +\n `</g>`;\n }\n\n s += `</svg>`;\n return diagramFrame(\n {\n tag: 'CLUSTER',\n tagBg: '#0e54a1',\n ...(data.title !== undefined ? { title: data.title } : {}),\n ...(data.description !== undefined ? { desc: data.description } : {}),\n },\n s,\n );\n}\n","/**\n * Block-graph rendering — backs `block`, `infra`, `event`, `ddd`, and\n * `network`. Two layout modes share the same data shape:\n *\n * - **Layered:** if `spec.layers` is present, nodes are placed in horizontal\n * bands by their `layer` index.\n * - **Grid:** otherwise nodes use `(col, row, w?)` placements, optionally\n * wrapped in dashed group boxes.\n *\n * Ported from doc-studio.jsx `GridBlock` + `LayeredBlock` + `BlockDiagram`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { ortho } from '../svg/ortho.js';\nimport { edgePill } from '../svg/edgePill.js';\nimport { blockStyle, nodeGlyph, GEDGE } from '../svg/blockStyle.js';\nimport { safeColor } from '../sanitize.js';\nimport { diagramFrame } from './frame.js';\n\ntype Data = BlockDataMap['block'];\ntype Group = NonNullable<Data['groups']>[number];\ntype Node = NonNullable<Data['nodes']>[number];\n\ninterface FrameOpts {\n readonly tag: string;\n readonly tagBg?: string;\n readonly tagClass?: string;\n}\n\nconst FALLBACK_EDGE = {\n stroke: '#1a1a2e',\n sw: 1.4,\n dash: '',\n marker: 'gArrow',\n err: false,\n} as const;\n\nfunction renderGrid(data: Data): string {\n const groups = data.groups ?? [];\n const nodes = data.nodes ?? [];\n const edges = data.edges ?? [];\n const cellW = 184;\n const cellH = 82;\n const gapX = 56;\n const gapY = 58;\n const padX = 26;\n const padTop = 30;\n const padBot = 20;\n const cols = Math.max(\n 1,\n ...nodes.map((n) => (n.col ?? 1) + ((n.w ?? 1) - 1)),\n ...groups.map((g) => g.col + (g.cols ?? 1) - 1),\n );\n const rows = Math.max(\n 1,\n ...nodes.map((n) => n.row ?? 1),\n ...groups.map((g) => g.row + (g.rows ?? 1) - 1),\n );\n const xOf = (c: number): number => padX + (c - 1) * (cellW + gapX);\n const yOf = (r: number): number => padTop + (r - 1) * (cellH + gapY);\n const rectFor = (n: Node): { x: number; y: number; w: number; h: number } => ({\n x: xOf(n.col ?? 1),\n y: yOf(n.row ?? 1),\n w: (n.w ?? 1) * cellW + ((n.w ?? 1) - 1) * gapX,\n h: cellH,\n });\n const groupRect = (g: Group): { x: number; y: number; w: number; h: number } => ({\n x: xOf(g.col) - 16,\n y: yOf(g.row) - 22,\n w: (g.cols ?? 1) * cellW + ((g.cols ?? 1) - 1) * gapX + 32,\n h: (g.rows ?? 1) * cellH + ((g.rows ?? 1) - 1) * gapY + 38,\n });\n const byId = new Map(nodes.map((n) => [n.id, n]));\n const width = padX * 2 + cols * cellW + (cols - 1) * gapX;\n const height = padTop + rows * cellH + (rows - 1) * gapY + padBot;\n\n // Largest groups first so smaller ones layer on top.\n const sortedGroups = [...groups].sort(\n (a, b) => (b.cols ?? 1) * (b.rows ?? 1) - (a.cols ?? 1) * (a.rows ?? 1),\n );\n\n let s = `<svg viewBox=\"0 0 ${width} ${height}\" role=\"img\"><title>Block diagram</title>`;\n\n for (const g of sortedGroups) {\n const r = groupRect(g);\n const col = safeColor(g.color, '#0e54a1');\n // AWS-console-style zone: dashed tinted boundary + a solid label badge.\n // 2D containers (e.g. a VPC) get a centered title pill on the top border;\n // band-shaped zones (e.g. subnets) get a top-left tab — so a VPC and the\n // subnet sharing its corner never collide.\n const badgeW = 16 + g.label.length * 6.4;\n const isContainer = (g.cols ?? 1) >= 2 && (g.rows ?? 1) >= 2;\n const zone = `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"${r.w}\" height=\"${r.h}\" rx=\"10\" fill=\"${col}\" fill-opacity=\"0.06\" stroke=\"${col}\" stroke-opacity=\"0.55\" stroke-width=\"1.3\" stroke-dasharray=\"7 5\"/>`;\n const label = isContainer\n ? `<rect x=\"${r.x + (r.w - badgeW) / 2}\" y=\"${r.y - 1}\" width=\"${badgeW}\" height=\"20\" rx=\"10\" fill=\"${col}\"/>` +\n `<text x=\"${r.x + r.w / 2}\" y=\"${r.y + 13}\" class=\"grp-label\" fill=\"#fff\" text-anchor=\"middle\">${escapeHtml(g.label)}</text>`\n : `<path d=\"M${r.x} ${r.y + 20} L${r.x} ${r.y + 10} a10 10 0 0 1 10 -10 h${badgeW - 10} v20 z\" fill=\"${col}\"/>` +\n `<text x=\"${r.x + badgeW / 2}\" y=\"${r.y + 14}\" class=\"grp-label\" fill=\"#fff\" text-anchor=\"middle\">${escapeHtml(g.label)}</text>`;\n s += `<g>${zone}${label}</g>`;\n }\n\n for (const e of edges) {\n const A = byId.get(e.from);\n const B = byId.get(e.to);\n if (!A || !B) continue;\n const p = ortho(rectFor(A), rectFor(B));\n const st = GEDGE[e.kind ?? 'solid'] ?? GEDGE['solid'] ?? FALLBACK_EDGE;\n s +=\n `<g><path d=\"${p.d}\" fill=\"none\" stroke=\"${st.stroke}\" stroke-width=\"${st.sw}\" stroke-dasharray=\"${st.dash}\" marker-end=\"url(#${st.marker})\"/>` +\n edgePill(p, e.label, st.err) +\n `</g>`;\n }\n\n for (const n of nodes) {\n const r = rectFor(n);\n const st = blockStyle(n.kind);\n const gl = nodeGlyph(n.kind, r.x + 16, r.y + 16, st.accent);\n const nx = gl.length > 0 ? r.x + 42 : r.x + 16;\n const chip =\n gl.length === 0 && n.kind !== undefined\n ? `<text x=\"${r.x + 16}\" y=\"${r.y + 22}\" class=\"blk-chip\" fill=\"${st.accent}\">${escapeHtml(n.kind)}</text>`\n : '';\n const tech =\n n.tech !== undefined\n ? `<text x=\"${nx}\" y=\"${r.y + (gl.length > 0 ? 50 : 60)}\" class=\"blk-tech\" fill=\"${st.accent}\">${escapeHtml(n.tech)}</text>`\n : '';\n s +=\n `<g filter=\"url(#gshadow)\">` +\n `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"${r.w}\" height=\"${r.h}\" rx=\"9\" fill=\"${st.fill}\" stroke=\"${st.accent}\" stroke-width=\"1.2\"/>` +\n `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"5\" height=\"${r.h}\" rx=\"2\" fill=\"${st.accent}\"/>` +\n gl +\n chip +\n `<text x=\"${nx}\" y=\"${r.y + (gl.length > 0 ? 34 : 44)}\" class=\"blk-name\" fill=\"${st.text}\">${escapeHtml(n.name)}</text>` +\n tech +\n `</g>`;\n }\n\n s += `</svg>`;\n return s;\n}\n\nfunction renderLayered(data: Data): string {\n const layers = data.layers ?? [];\n const nodes = data.nodes ?? [];\n const edges = data.edges ?? [];\n const byLayer: Node[][] = layers.map((_, i) =>\n nodes.filter((n) => (n.layer ?? 0) === i),\n );\n const outerPad = 28;\n const titleH = data.systemLabel !== undefined ? 32 : 16;\n const labelW = 132;\n const bandPadX = 16;\n const bandPadY = 14;\n const bandGap = 12;\n const nodeW = 158;\n const nodeH = 56;\n const nodeGap = 22;\n const rowW = (c: number): number => c * nodeW + (c - 1) * nodeGap;\n const contentW = Math.max(220, ...byLayer.map((a) => rowW(Math.max(a.length, 1))));\n const bandInnerW = contentW + bandPadX * 2;\n const bandH = nodeH + bandPadY * 2;\n const innerX = outerPad + 14;\n const contentX = innerX + labelW;\n const width = contentX + bandInnerW + 14 + outerPad;\n const top = outerPad + titleH;\n const bandY = (i: number): number => top + i * (bandH + bandGap);\n const height = bandY(layers.length) - bandGap + outerPad;\n\n const rects = new Map<string, { x: number; y: number; w: number; h: number }>();\n byLayer.forEach((arr, i) => {\n const startX = contentX + (bandInnerW - rowW(arr.length)) / 2;\n arr.forEach((n, j) => {\n rects.set(n.id, {\n x: startX + j * (nodeW + nodeGap),\n y: bandY(i) + bandPadY,\n w: nodeW,\n h: nodeH,\n });\n });\n });\n\n let s =\n `<svg viewBox=\"0 0 ${width} ${height}\" role=\"img\"><title>Layered architecture</title>` +\n `<rect x=\"${outerPad}\" y=\"${outerPad}\" width=\"${width - outerPad * 2}\" height=\"${height - outerPad * 2}\" rx=\"12\" fill=\"none\" stroke=\"#0e54a1\" stroke-width=\"1.5\"/>`;\n if (data.systemLabel !== undefined) {\n s += `<text x=\"${outerPad + 14}\" y=\"${outerPad + 18}\" class=\"grp-label\" fill=\"#0e54a1\">${escapeHtml(data.systemLabel)}</text>`;\n }\n for (let i = 0; i < layers.length; i++) {\n const L = layers[i];\n if (L === undefined) continue;\n s +=\n `<g>` +\n `<rect x=\"${innerX}\" y=\"${bandY(i)}\" width=\"${labelW + bandInnerW}\" height=\"${bandH}\" rx=\"6\" fill=\"#f3f4f6\" stroke=\"#d1d5db\"/>` +\n `<rect x=\"${innerX}\" y=\"${bandY(i)}\" width=\"${labelW}\" height=\"${bandH}\" rx=\"6\" fill=\"#0e54a1\"/>` +\n `<rect x=\"${innerX + labelW - 8}\" y=\"${bandY(i)}\" width=\"8\" height=\"${bandH}\" fill=\"#0e54a1\"/>` +\n `<text x=\"${innerX + 14}\" y=\"${bandY(i) + bandH / 2 + 4}\" class=\"layer-label\">${escapeHtml(L.label)}</text>` +\n `</g>`;\n }\n\n for (const e of edges) {\n const A = rects.get(e.from);\n const B = rects.get(e.to);\n if (!A || !B) continue;\n const p = ortho(A, B);\n const st = GEDGE[e.kind ?? 'solid'] ?? GEDGE['solid'] ?? FALLBACK_EDGE;\n s +=\n `<g><path d=\"${p.d}\" fill=\"none\" stroke=\"${st.stroke}\" stroke-width=\"${st.sw}\" stroke-dasharray=\"${st.dash}\" marker-end=\"url(#${st.marker})\"/>` +\n edgePill(p, e.label, st.err) +\n `</g>`;\n }\n\n for (const n of nodes) {\n const r = rects.get(n.id);\n if (r === undefined) continue;\n const st = blockStyle(n.kind);\n const gl = nodeGlyph(n.kind, r.x + 12, r.y + 12, st.accent);\n const nx = gl.length > 0 ? r.x + 34 : r.x + 14;\n const tech =\n n.tech !== undefined\n ? `<text x=\"${nx}\" y=\"${r.y + 42}\" class=\"blk-tech\" fill=\"${st.accent}\">${escapeHtml(n.tech)}</text>`\n : '';\n s +=\n `<g filter=\"url(#gshadow)\">` +\n `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"${r.w}\" height=\"${r.h}\" rx=\"8\" fill=\"${st.fill}\" stroke=\"${st.accent}\" stroke-width=\"1.2\"/>` +\n `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"5\" height=\"${r.h}\" rx=\"2\" fill=\"${st.accent}\"/>` +\n gl +\n `<text x=\"${nx}\" y=\"${r.y + (n.tech !== undefined ? 26 : 33)}\" class=\"blk-name\" fill=\"${st.text}\">${escapeHtml(n.name)}</text>` +\n tech +\n `</g>`;\n }\n\n s += `</svg>`;\n return s;\n}\n\nfunction renderBlockGraph(data: Data, frame: FrameOpts): string {\n const svg = data.layers !== undefined && data.layers.length > 0 ? renderLayered(data) : renderGrid(data);\n const opts: Parameters<typeof diagramFrame>[0] = {\n tag: frame.tag,\n ...(frame.tagClass !== undefined ? { tagClass: frame.tagClass } : {}),\n ...(frame.tagBg !== undefined ? { tagBg: frame.tagBg } : {}),\n ...(data.title !== undefined ? { title: data.title } : {}),\n ...(data.description !== undefined ? { desc: data.description } : {}),\n };\n return diagramFrame(opts, svg);\n}\n\n/** `block` block — generic architecture (grid or layered). */\nexport function renderBlock(data: BlockDataMap['block']): string {\n return renderBlockGraph(data, { tag: 'ARCH', tagBg: '#0f766e' });\n}\n/** `infra` block — deployment topology. */\nexport function renderInfra(data: BlockDataMap['infra']): string {\n return renderBlockGraph(data, { tag: 'INFRA', tagBg: '#0078d4' });\n}\n/** `event` block — pub/sub choreography. */\nexport function renderEvent(data: BlockDataMap['event']): string {\n return renderBlockGraph(data, { tag: 'EVENT', tagBg: '#0f766e' });\n}\n/** `ddd` block — bounded-context map. */\nexport function renderDdd(data: BlockDataMap['ddd']): string {\n return renderBlockGraph(data, { tag: 'DDD', tagBg: '#6b21a8' });\n}\n/** `network` block — security zones / network topology. */\nexport function renderNetwork(data: BlockDataMap['network']): string {\n return renderBlockGraph(data, { tag: 'ZONES', tagBg: '#991b1b' });\n}\n","/**\n * Frontend / backend module-graph rendering — design-pattern nodes (engine,\n * interface, strategy, controller, service, repo, worker, middleware, model,\n * db, cache, queue, hook, store, external) with kind-specific styling and\n * UML stereotype banners on interface nodes.\n *\n * Backs `felogic` and `belogic` (same shape, different frame colour).\n *\n * Ported from doc-studio.jsx `FrontendLogic` + `feStyle` + `feEdge`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { ortho } from '../svg/ortho.js';\nimport { edgePill } from '../svg/edgePill.js';\nimport { nodeGlyph } from '../svg/blockStyle.js';\nimport { safeColor } from '../sanitize.js';\nimport { diagramFrame } from './frame.js';\n\ntype Data = BlockDataMap['felogic'];\ntype Group = NonNullable<Data['groups']>[number];\ntype Node = NonNullable<Data['nodes']>[number];\n\ninterface FeStyle {\n accent: string;\n fill: string;\n text: string;\n solid?: boolean;\n dash?: string;\n stereo?: string;\n cloud?: boolean;\n}\n\nfunction feStyle(kind: string | undefined): FeStyle {\n switch ((kind ?? 'component').toLowerCase()) {\n case 'engine':\n case 'core':\n return { accent: '#0e54a1', fill: '#0e54a1', text: '#fff', solid: true };\n case 'interface':\n return { accent: '#6b21a8', fill: '#fff', text: '#4a1772', dash: '5 4', stereo: 'interface' };\n case 'strategy':\n case 'adapter':\n case 'impl':\n return { accent: '#7c3aed', fill: '#ede9fe', text: '#4a1772' };\n case 'controller':\n case 'handler':\n case 'route':\n return { accent: '#0e54a1', fill: '#cfe0f3', text: '#0a3a6e' };\n case 'service':\n case 'usecase':\n case 'apiclient':\n case 'client':\n return { accent: '#1a6dbe', fill: '#e5eff8', text: '#0a3a6e' };\n case 'repository':\n case 'repo':\n case 'dao':\n return { accent: '#0f766e', fill: '#ccfbf1', text: '#0f4f49' };\n case 'worker':\n case 'consumer':\n return { accent: '#1f9747', fill: '#dcf1e2', text: '#0f3d22' };\n case 'middleware':\n return { accent: '#6b7280', fill: '#f3f4f6', text: '#374151' };\n case 'model':\n case 'entity':\n return { accent: '#6b21a8', fill: '#ede9fe', text: '#4a1772' };\n case 'db':\n case 'store':\n case 'database':\n return { accent: '#f7952c', fill: '#fde7cd', text: '#7a3d00' };\n case 'cache':\n return { accent: '#0891b2', fill: '#cffafe', text: '#0e4f5c' };\n case 'queue':\n case 'bus':\n case 'broker':\n return { accent: '#0f766e', fill: '#ccfbf1', text: '#0f4f49' };\n case 'state':\n case 'store_state':\n return { accent: '#f7952c', fill: '#fde7cd', text: '#7a3d00' };\n case 'hook':\n return { accent: '#7c3aed', fill: '#ede9fe', text: '#4a1772' };\n case 'external':\n case 'backend':\n case 'egress':\n case 'api':\n case 'thirdparty':\n return { accent: '#6b7280', fill: '#f3f4f6', text: '#374151', cloud: true };\n default:\n return { accent: '#1f9747', fill: '#dcf1e2', text: '#0f3d22' };\n }\n}\n\ninterface FeEdgeStyle {\n stroke: string;\n sw: number;\n dash: string;\n marker: string;\n}\n\nfunction feEdge(kind: string | undefined): FeEdgeStyle {\n switch ((kind ?? 'uses').toLowerCase()) {\n case 'implements':\n return { stroke: '#6b21a8', sw: 1.4, dash: '5 4', marker: 'gTri' };\n case 'egress':\n case 'https':\n case 'api':\n return { stroke: '#0e54a1', sw: 2, dash: '', marker: 'gArrow' };\n case 'reads':\n case 'dashed':\n case 'async':\n return { stroke: '#6b7280', sw: 1.4, dash: '5 4', marker: 'gSoft' };\n default:\n return { stroke: '#1a1a2e', sw: 1.4, dash: '', marker: 'gArrow' };\n }\n}\n\nconst GLYPH_KINDS = new Set([\n 'db',\n 'store',\n 'database',\n 'bucket',\n 'blob',\n 'object',\n 'queue',\n 'bus',\n 'broker',\n 'cache',\n 'external',\n 'backend',\n 'api',\n 'thirdparty',\n 'function',\n]);\nconst GLYPH_REMAP: Record<string, string> = {\n database: 'db',\n store: 'db',\n bus: 'queue',\n broker: 'queue',\n backend: 'external',\n api: 'external',\n thirdparty: 'external',\n};\n\ninterface FrameOpts {\n readonly tag: string;\n readonly tagBg?: string;\n}\n\nfunction renderFelogicGraph(data: Data, frame: FrameOpts): string {\n const groups = data.groups ?? [];\n const nodes = data.nodes ?? [];\n const edges = data.edges ?? [];\n const cellW = 178;\n const cellH = 80;\n const gapX = 54;\n const gapY = 60;\n const padX = 26;\n const padTop = 30;\n const padBot = 20;\n const cols = Math.max(\n 1,\n ...nodes.map((n) => n.col + ((n.w ?? 1) - 1)),\n ...groups.map((g) => g.col + (g.cols ?? 1) - 1),\n );\n const rows = Math.max(\n 1,\n ...nodes.map((n) => n.row),\n ...groups.map((g) => g.row + (g.rows ?? 1) - 1),\n );\n const xOf = (c: number): number => padX + (c - 1) * (cellW + gapX);\n const yOf = (r: number): number => padTop + (r - 1) * (cellH + gapY);\n const rectFor = (n: Node): { x: number; y: number; w: number; h: number } => ({\n x: xOf(n.col),\n y: yOf(n.row),\n w: (n.w ?? 1) * cellW + ((n.w ?? 1) - 1) * gapX,\n h: cellH,\n });\n const groupRect = (g: Group): { x: number; y: number; w: number; h: number } => ({\n x: xOf(g.col) - 16,\n y: yOf(g.row) - 22,\n w: (g.cols ?? 1) * cellW + ((g.cols ?? 1) - 1) * gapX + 32,\n h: (g.rows ?? 1) * cellH + ((g.rows ?? 1) - 1) * gapY + 38,\n });\n const byId = new Map(nodes.map((n) => [n.id, n]));\n const width = padX * 2 + cols * cellW + (cols - 1) * gapX;\n const height = padTop + rows * cellH + (rows - 1) * gapY + padBot;\n const sortedGroups = [...groups].sort(\n (a, b) => (b.cols ?? 1) * (b.rows ?? 1) - (a.cols ?? 1) * (a.rows ?? 1),\n );\n\n let s = `<svg viewBox=\"0 0 ${width} ${height}\" role=\"img\"><title>Module graph</title>`;\n\n for (const g of sortedGroups) {\n const r = groupRect(g);\n const col = safeColor(g.color, '#0e54a1');\n s +=\n `<g>` +\n `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"${r.w}\" height=\"${r.h}\" rx=\"10\" fill=\"${col}\" fill-opacity=\"0.05\" stroke=\"${col}\" stroke-opacity=\"0.5\" stroke-width=\"1.2\" stroke-dasharray=\"7 5\"/>` +\n `<text x=\"${r.x + 14}\" y=\"${r.y + 15}\" class=\"grp-label\" fill=\"${col}\">${escapeHtml(g.label)}</text>` +\n `</g>`;\n }\n\n for (const e of edges) {\n const A = byId.get(e.from);\n const B = byId.get(e.to);\n if (!A || !B) continue;\n const p = ortho(rectFor(A), rectFor(B));\n const st = feEdge(e.kind);\n s +=\n `<g><path d=\"${p.d}\" fill=\"none\" stroke=\"${st.stroke}\" stroke-width=\"${st.sw}\" stroke-dasharray=\"${st.dash}\" marker-end=\"url(#${st.marker})\"/>` +\n edgePill(p, e.label) +\n `</g>`;\n }\n\n for (const n of nodes) {\n const r = rectFor(n);\n const st = feStyle(n.kind);\n const k = (n.kind ?? '').toLowerCase();\n const gl = GLYPH_KINDS.has(k) ? nodeGlyph(GLYPH_REMAP[k] ?? k, r.x + 16, r.y + 16, st.accent) : '';\n const nx = st.solid === true ? r.x + r.w / 2 : gl.length > 0 ? r.x + 42 : r.x + 16;\n const anchor = st.solid === true ? 'middle' : 'start';\n const nameY = r.y + (st.stereo !== undefined ? 38 : n.note !== undefined ? 36 : 44);\n const noteY = r.y + (st.stereo !== undefined ? 56 : 52);\n const stroke = st.solid === true ? 'none' : st.accent;\n const dashAttr = st.dash !== undefined ? ` stroke-dasharray=\"${st.dash}\"` : '';\n const stripe =\n st.solid === true\n ? ''\n : `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"5\" height=\"${r.h}\" rx=\"2\" fill=\"${st.accent}\"/>`;\n const stereo =\n st.stereo !== undefined\n ? `<text x=\"${r.x + r.w / 2}\" y=\"${r.y + 20}\" class=\"uml-stereo\">«${escapeHtml(st.stereo)}»</text>`\n : '';\n const note =\n n.note !== undefined\n ? `<text x=\"${nx}\" y=\"${noteY}\" class=\"blk-tech\" fill=\"${st.solid === true ? '#cfe0f3' : st.accent}\" text-anchor=\"${anchor}\">${escapeHtml(n.note)}</text>`\n : '';\n s +=\n `<g filter=\"url(#gshadow)\">` +\n `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"${r.w}\" height=\"${r.h}\" rx=\"9\" fill=\"${st.fill}\" stroke=\"${stroke}\" stroke-width=\"1.2\"${dashAttr}/>` +\n stripe +\n gl +\n stereo +\n `<text x=\"${nx}\" y=\"${nameY}\" class=\"blk-name\" fill=\"${st.text}\" text-anchor=\"${anchor}\">${escapeHtml(n.name)}</text>` +\n note +\n `</g>`;\n }\n\n s += `</svg>`;\n return diagramFrame(\n {\n tag: frame.tag,\n ...(frame.tagBg !== undefined ? { tagBg: frame.tagBg } : {}),\n ...(data.title !== undefined ? { title: data.title } : {}),\n ...(data.description !== undefined ? { desc: data.description } : {}),\n },\n s,\n );\n}\n\n/** `felogic` — frontend module graph (purple LOGIC tag). */\nexport function renderFelogic(data: BlockDataMap['felogic']): string {\n return renderFelogicGraph(data, { tag: 'LOGIC', tagBg: '#6b21a8' });\n}\n/** `belogic` — backend module graph (navy LOGIC tag). */\nexport function renderBelogic(data: BlockDataMap['belogic']): string {\n return renderFelogicGraph(data, { tag: 'LOGIC', tagBg: '#0e54a1' });\n}\n","/**\n * Renders UI mockups — low-fidelity wireframes inside device frames\n * (desktop window, browser, or phone). Each screen is a vertical stack of\n * UI elements (header, button, list, card, …) drawn as neutral placeholders,\n * Excalidraw-flavoured.\n *\n * Screens lay out left-to-right in a row. Element heights are fixed per type;\n * the frame grows to fit its content (phones keep a minimum height).\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { wrapText } from '../svg/wrapText.js';\nimport { diagramFrame } from './frame.js';\n\ntype Screen = NonNullable<BlockDataMap['wireframe']['screens']>[number];\ntype Element = NonNullable<Screen['elements']>[number];\n\n/** Inner content width per device (the drawable area inside the frame chrome). */\nfunction contentWidth(device: string): number {\n if (device === 'phone') return 200;\n return 380; // desktop / browser\n}\n\n/** Vertical space one element consumes (its drawn height + the gap below). */\nfunction elementHeight(el: Element): number {\n const rows = Math.max(1, el.rows ?? 1);\n switch (el.type) {\n case 'header':\n return 34;\n case 'subheader':\n return 26;\n case 'text':\n return 16 + (rows - 1) * 12;\n case 'button':\n return 42;\n case 'input':\n case 'search':\n return 42;\n case 'image':\n return 96;\n case 'avatar':\n return 52;\n case 'card':\n return rows * 64 + (rows - 1) * 10;\n case 'list':\n return rows * 40;\n case 'nav':\n return 34;\n case 'tabs':\n return 52;\n case 'divider':\n return 14;\n case 'badge':\n return 26;\n case 'toggle':\n return 30;\n case 'spacer':\n return 18 * rows;\n default:\n return 24;\n }\n}\n\nconst PH = 'fill=\"var(--light-gray)\" stroke=\"var(--rule)\" stroke-width=\"1\"';\n\n/** Draws one element at (x, y) within a content column of width w. Returns SVG. */\nfunction drawElement(el: Element, x: number, y: number, w: number): string {\n const rows = Math.max(1, el.rows ?? 1);\n const label = el.label ?? '';\n const accent =\n el.tone === 'danger'\n ? 'var(--negative)'\n : el.tone === 'muted'\n ? 'var(--gray)'\n : 'var(--navy)';\n const anchorX = el.align === 'c' ? x + w / 2 : el.align === 'r' ? x + w : x;\n const anchor = el.align === 'c' ? 'middle' : el.align === 'r' ? 'end' : 'start';\n\n switch (el.type) {\n case 'header':\n return `<text x=\"${anchorX}\" y=\"${y + 22}\" class=\"wf-h\" fill=\"var(--charcoal)\" text-anchor=\"${anchor}\">${escapeHtml(label || 'Heading')}</text>`;\n case 'subheader':\n return `<text x=\"${anchorX}\" y=\"${y + 17}\" class=\"wf-sub\" fill=\"var(--gray)\" text-anchor=\"${anchor}\">${escapeHtml(label || 'Subheading')}</text>`;\n case 'text': {\n let s = '';\n for (let i = 0; i < rows; i++) {\n const lw = i === rows - 1 ? w * 0.66 : w;\n s += `<rect x=\"${x}\" y=\"${y + i * 12}\" width=\"${lw}\" height=\"6\" rx=\"3\" fill=\"var(--rule)\"/>`;\n }\n return s;\n }\n case 'button':\n return (\n `<rect x=\"${x}\" y=\"${y}\" width=\"${w}\" height=\"34\" rx=\"8\" fill=\"${accent}\"/>` +\n `<text x=\"${x + w / 2}\" y=\"${y + 22}\" class=\"wf-btn\" text-anchor=\"middle\">${escapeHtml(label || 'Button')}</text>`\n );\n case 'input':\n case 'search': {\n const icon =\n el.type === 'search'\n ? `<circle cx=\"${x + 16}\" cy=\"${y + 17}\" r=\"5\" fill=\"none\" stroke=\"var(--gray)\" stroke-width=\"1.4\"/><path d=\"M${x + 20} ${y + 21} l4 4\" stroke=\"var(--gray)\" stroke-width=\"1.4\"/>`\n : '';\n const tx = el.type === 'search' ? x + 30 : x + 12;\n return (\n `<rect x=\"${x}\" y=\"${y}\" width=\"${w}\" height=\"34\" rx=\"8\" fill=\"var(--white)\" stroke=\"var(--rule)\" stroke-width=\"1.2\"/>` +\n icon +\n `<text x=\"${tx}\" y=\"${y + 21}\" class=\"wf-ph-text\">${escapeHtml(label || 'Type here…')}</text>`\n );\n }\n case 'image':\n return (\n `<rect x=\"${x}\" y=\"${y}\" width=\"${w}\" height=\"88\" rx=\"8\" ${PH}/>` +\n `<path d=\"M${x} ${y + 88} L${x + w * 0.4} ${y + 40} L${x + w * 0.62} ${y + 66} L${x + w * 0.78} ${y + 50} L${x + w} ${y + 88}\" fill=\"none\" stroke=\"var(--gray)\" stroke-width=\"1.3\"/>` +\n `<circle cx=\"${x + w * 0.74} \" cy=\"${y + 26}\" r=\"7\" fill=\"none\" stroke=\"var(--gray)\" stroke-width=\"1.3\"/>`\n );\n case 'avatar':\n return (\n `<circle cx=\"${x + 22}\" cy=\"${y + 22}\" r=\"20\" ${PH}/>` +\n `<circle cx=\"${x + 22}\" cy=\"${y + 17}\" r=\"7\" fill=\"var(--gray)\"/>` +\n `<path d=\"M${x + 9} ${y + 40} a13 11 0 0 1 26 0\" fill=\"var(--gray)\"/>` +\n (label\n ? `<text x=\"${x + 52}\" y=\"${y + 27}\" class=\"wf-sub\" fill=\"var(--charcoal)\">${escapeHtml(label)}</text>`\n : '')\n );\n case 'card': {\n let s = '';\n for (let i = 0; i < rows; i++) {\n const cy = y + i * 74;\n s +=\n `<rect x=\"${x}\" y=\"${cy}\" width=\"${w}\" height=\"64\" rx=\"10\" fill=\"var(--white)\" stroke=\"var(--rule)\" stroke-width=\"1.2\"/>` +\n `<rect x=\"${x + 12}\" y=\"${cy + 12}\" width=\"40\" height=\"40\" rx=\"8\" ${PH}/>` +\n `<rect x=\"${x + 64}\" y=\"${cy + 16}\" width=\"${w - 92}\" height=\"7\" rx=\"3.5\" fill=\"var(--rule)\"/>` +\n `<rect x=\"${x + 64}\" y=\"${cy + 34}\" width=\"${(w - 92) * 0.6}\" height=\"6\" rx=\"3\" fill=\"var(--rule)\"/>`;\n }\n const cap = label\n ? `<text x=\"${x + 64}\" y=\"${y + 30}\" class=\"wf-ph-text\"></text>`\n : '';\n return s + cap;\n }\n case 'list': {\n let s = '';\n for (let i = 0; i < rows; i++) {\n const ly = y + i * 40;\n s +=\n `<circle cx=\"${x + 16}\" cy=\"${ly + 20}\" r=\"12\" ${PH}/>` +\n `<rect x=\"${x + 38}\" y=\"${ly + 12}\" width=\"${w - 76}\" height=\"6\" rx=\"3\" fill=\"var(--rule)\"/>` +\n `<rect x=\"${x + 38}\" y=\"${ly + 24}\" width=\"${(w - 76) * 0.55}\" height=\"5\" rx=\"2.5\" fill=\"var(--rule)\"/>` +\n `<path d=\"M${x + w - 14} ${ly + 15} l5 5 l-5 5\" fill=\"none\" stroke=\"var(--gray)\" stroke-width=\"1.4\"/>` +\n (i < rows - 1\n ? `<line x1=\"${x + 38}\" y1=\"${ly + 40}\" x2=\"${x + w}\" y2=\"${ly + 40}\" stroke=\"var(--light-gray)\" stroke-width=\"1\"/>`\n : '');\n }\n return s;\n }\n case 'nav': {\n // a row of pill items; label is comma-separated item names.\n const items = (label || 'Home, Docs, Pricing, About').split(',').map((t) => t.trim());\n let s = '';\n let nx = x;\n for (const it of items) {\n const pw = 16 + it.length * 6.2;\n s +=\n `<rect x=\"${nx}\" y=\"${y + 4}\" width=\"${pw}\" height=\"22\" rx=\"11\" fill=\"var(--light-gray)\"/>` +\n `<text x=\"${nx + pw / 2}\" y=\"${y + 19}\" class=\"wf-ph-text\" text-anchor=\"middle\">${escapeHtml(it)}</text>`;\n nx += pw + 8;\n }\n return s;\n }\n case 'tabs': {\n const items = (label || 'Home, Search, Bell, Profile').split(',').map((t) => t.trim());\n const seg = w / items.length;\n let s = `<line x1=\"${x}\" y1=\"${y}\" x2=\"${x + w}\" y2=\"${y}\" stroke=\"var(--rule)\" stroke-width=\"1\"/>`;\n items.forEach((it, i) => {\n const cx = x + seg * i + seg / 2;\n s +=\n `<circle cx=\"${cx}\" cy=\"${y + 18}\" r=\"8\" fill=\"none\" stroke=\"${i === 0 ? accent : 'var(--gray)'}\" stroke-width=\"1.6\"/>` +\n `<text x=\"${cx}\" y=\"${y + 42}\" class=\"wf-tab\" text-anchor=\"middle\" fill=\"${i === 0 ? accent : 'var(--gray)'}\">${escapeHtml(it)}</text>`;\n });\n return s;\n }\n case 'divider':\n return `<line x1=\"${x}\" y1=\"${y + 7}\" x2=\"${x + w}\" y2=\"${y + 7}\" stroke=\"var(--rule)\" stroke-width=\"1\"/>`;\n case 'badge': {\n const pw = 22 + label.length * 6.4;\n return (\n `<rect x=\"${anchorX - (anchor === 'middle' ? pw / 2 : anchor === 'end' ? pw : 0)}\" y=\"${y}\" width=\"${pw}\" height=\"22\" rx=\"11\" fill=\"${accent}\"/>` +\n `<text x=\"${anchorX - (anchor === 'middle' ? 0 : anchor === 'end' ? pw / 2 : -pw / 2)}\" y=\"${y + 15}\" class=\"wf-btn\" text-anchor=\"middle\">${escapeHtml(label || 'New')}</text>`\n );\n }\n case 'toggle':\n return (\n (label\n ? `<text x=\"${x}\" y=\"${y + 19}\" class=\"wf-sub\" fill=\"var(--charcoal)\">${escapeHtml(label)}</text>`\n : '') +\n `<rect x=\"${x + w - 44}\" y=\"${y + 6}\" width=\"44\" height=\"22\" rx=\"11\" fill=\"${accent}\"/>` +\n `<circle cx=\"${x + w - 16}\" cy=\"${y + 17}\" r=\"8\" fill=\"#fff\"/>`\n );\n case 'spacer':\n return '';\n default:\n return '';\n }\n}\n\n/** Renders one device frame and its stacked content. Returns {svg, width, height}. */\nfunction drawScreen(screen: Screen, idx: number): { svg: string; width: number; height: number } {\n const device = screen.device ?? 'browser';\n const cw = contentWidth(device);\n const pad = 16;\n const els = screen.elements ?? [];\n let contentH = 0;\n for (const el of els) contentH += elementHeight(el) + 10;\n contentH = Math.max(contentH, 80);\n\n // chrome heights\n const isPhone = device === 'phone';\n const isBrowser = device === 'browser';\n const titleBarH = 30;\n const addressBarH = isBrowser ? 26 : 0;\n const chromeTop = titleBarH + addressBarH;\n const homeBarH = isPhone ? 24 : 0;\n\n const frameW = cw + pad * 2;\n const screenH = contentH + pad;\n const frameH = chromeTop + screenH + homeBarH;\n const rx = isPhone ? 30 : 14;\n const sw = isPhone ? 2.4 : 1.8;\n const clip = `wfclip${idx}`;\n\n // Inner chrome + content, drawn first and clipped to the rounded frame so\n // nothing spills the corners. The border stroke is drawn LAST, on top, so the\n // outline is always crisp and visible above the fills.\n let inner = '';\n if (isPhone) {\n inner += `<rect x=\"0\" y=\"0\" width=\"${frameW}\" height=\"${titleBarH}\" fill=\"var(--light-gray)\"/>`;\n inner += `<rect x=\"${frameW / 2 - 26}\" y=\"6\" width=\"52\" height=\"9\" rx=\"4.5\" fill=\"var(--charcoal)\"/>`;\n if (screen.title)\n inner += `<text x=\"16\" y=\"20\" class=\"wf-status\">${escapeHtml(screen.title)}</text>`;\n inner += `<text x=\"${frameW - 16}\" y=\"20\" class=\"wf-status\" text-anchor=\"end\">100%</text>`;\n } else {\n inner += `<rect x=\"0\" y=\"0\" width=\"${frameW}\" height=\"${titleBarH}\" fill=\"var(--light-gray)\"/>`;\n inner += `<line x1=\"0\" y1=\"${titleBarH}\" x2=\"${frameW}\" y2=\"${titleBarH}\" stroke=\"var(--rule)\" stroke-width=\"1\"/>`;\n inner += `<circle cx=\"18\" cy=\"15\" r=\"5\" fill=\"var(--negative)\"/><circle cx=\"34\" cy=\"15\" r=\"5\" fill=\"var(--highlight)\"/><circle cx=\"50\" cy=\"15\" r=\"5\" fill=\"var(--positive)\"/>`;\n if (screen.title && !isBrowser)\n inner += `<text x=\"${frameW / 2}\" y=\"20\" class=\"wf-status\" text-anchor=\"middle\">${escapeHtml(screen.title)}</text>`;\n if (isBrowser) {\n const url = screen.url ?? screen.title ?? 'example.com';\n inner += `<rect x=\"68\" y=\"${titleBarH + 5}\" width=\"${frameW - 84}\" height=\"16\" rx=\"8\" fill=\"var(--white)\" stroke=\"var(--rule)\" stroke-width=\"1\"/>`;\n inner += `<text x=\"78\" y=\"${titleBarH + 16}\" class=\"wf-url\">${escapeHtml(url)}</text>`;\n }\n }\n\n let cy = chromeTop + pad;\n for (const el of els) {\n inner += drawElement(el, pad, cy, cw);\n cy += elementHeight(el) + 10;\n }\n if (isPhone) {\n inner += `<rect x=\"${frameW / 2 - 30}\" y=\"${frameH - 15}\" width=\"60\" height=\"5\" rx=\"2.5\" fill=\"var(--charcoal)\" opacity=\"0.55\"/>`;\n }\n\n const s =\n `<g filter=\"url(#gshadow)\">` +\n `<defs><clipPath id=\"${clip}\"><rect x=\"0\" y=\"0\" width=\"${frameW}\" height=\"${frameH}\" rx=\"${rx}\"/></clipPath></defs>` +\n // solid backing so the drop shadow reads against any page colour\n `<rect x=\"0\" y=\"0\" width=\"${frameW}\" height=\"${frameH}\" rx=\"${rx}\" fill=\"var(--white)\"/>` +\n `<g clip-path=\"url(#${clip})\">${inner}</g>` +\n // border on top — always visible above the fills\n `<rect x=\"0\" y=\"0\" width=\"${frameW}\" height=\"${frameH}\" rx=\"${rx}\" fill=\"none\" stroke=\"var(--charcoal)\" stroke-width=\"${sw}\"/>` +\n `</g>`;\n return { svg: s, width: frameW, height: frameH };\n}\n\nexport function renderWireframe(data: BlockDataMap['wireframe']): string {\n const screens = data.screens ?? [];\n const gap = 36;\n const capH = 22;\n const padX = 8;\n const padY = 8;\n\n const drawn = screens.map((screen, i) => drawScreen(screen, i));\n const totalW = drawn.reduce((a, d) => a + d.width, 0) + gap * Math.max(0, drawn.length - 1);\n const maxH = drawn.reduce((a, d) => Math.max(a, d.height), 0);\n const width = totalW + padX * 2;\n const height = maxH + capH + padY * 2;\n\n let s = `<svg viewBox=\"0 0 ${width} ${height}\" role=\"img\"><title>${escapeHtml(data.title ?? 'UI mockup')}</title>`;\n let x = padX;\n drawn.forEach((d, i) => {\n const screen = screens[i];\n s += `<g transform=\"translate(${x}, ${padY})\">${d.svg}</g>`;\n const cap = screen?.label;\n if (cap !== undefined && cap.length > 0) {\n const lines = wrapText(cap, Math.floor(d.width / 6), 2);\n lines.forEach((ln, j) => {\n s += `<text x=\"${x + d.width / 2}\" y=\"${padY + maxH + 16 + j * 12}\" class=\"wf-caption\" text-anchor=\"middle\">${escapeHtml(ln)}</text>`;\n });\n }\n x += d.width + gap;\n });\n s += `</svg>`;\n\n return diagramFrame(\n {\n tag: 'UI',\n tagBg: '#6b21a8',\n ...(data.title !== undefined ? { title: data.title } : {}),\n ...(data.description !== undefined ? { desc: data.description } : {}),\n },\n s,\n );\n}\n","/**\n * HTML renderer registry — mirrors the core block registry's exhaustiveness.\n *\n * Each block type maps to a function that takes its typed data and returns an\n * HTML string. The mapped type `{ [K in BlockType]: ... }` ensures omitting a\n * block type is a compile error — adding a new BlockType in core fails tsc here\n * until the renderer is added.\n */\n\nimport type { BlockDataMap, BlockType } from '@avodado/core';\n\nimport { renderCallout } from './blocks/callout.js';\nimport { renderErd } from './blocks/erd.js';\nimport { renderKanban } from './blocks/kanban.js';\nimport { renderMetaBlock } from './blocks/meta.js';\nimport { renderSequence } from './blocks/sequence.js';\nimport { renderTable } from './blocks/table.js';\nimport { renderTimeline } from './blocks/timeline.js';\nimport { renderTracker } from './blocks/tracker.js';\nimport { renderUserStory } from './blocks/userstory.js';\nimport { renderProseBlock } from './blocks/prose.js';\nimport { renderGlossary } from './blocks/glossary.js';\nimport { renderProsCons } from './blocks/proscons.js';\nimport { renderCvt } from './blocks/cvt.js';\nimport { renderStats } from './blocks/stats.js';\nimport { renderCode } from './blocks/code.js';\nimport { renderAgenda } from './blocks/agenda.js';\nimport { renderTree } from './blocks/tree.js';\nimport { renderPyramid } from './blocks/pyramid.js';\nimport { renderFunnel } from './blocks/funnel.js';\nimport { renderFlow } from './blocks/flow.js';\nimport { renderState } from './blocks/state.js';\nimport { renderDfd } from './blocks/dfd.js';\nimport { renderJourney } from './blocks/journey.js';\nimport { renderGantt } from './blocks/gantt.js';\nimport { renderGraph } from './blocks/graph.js';\nimport { renderQuadrant } from './blocks/quadrant.js';\nimport { renderSwimlane } from './blocks/swimlane.js';\nimport { renderC4 } from './blocks/c4.js';\nimport { renderUml } from './blocks/uml.js';\nimport { renderMece } from './blocks/mece.js';\nimport { renderFrontend } from './blocks/frontend.js';\nimport { renderCluster } from './blocks/cluster.js';\nimport {\n renderBlock,\n renderInfra,\n renderEvent,\n renderDdd,\n renderNetwork,\n} from './blocks/blockGraph.js';\nimport { renderFelogic, renderBelogic } from './blocks/felogic.js';\nimport { renderDag } from './blocks/flow.js';\nimport { renderWireframe } from './blocks/wireframe.js';\n\n/** Per-block HTML renderer signature. */\nexport type HtmlRenderer<K extends BlockType> = (data: BlockDataMap[K]) => string;\n\n/** Mapped type — adding a {@link BlockType} without an entry fails tsc. */\nexport type HtmlRendererRegistry = { readonly [K in BlockType]: HtmlRenderer<K> };\n\n/** The HTML renderer registry. `meta` is intentionally a no-op (cover is rendered separately). */\nexport const htmlRenderers: HtmlRendererRegistry = {\n meta: renderMetaBlock,\n callout: renderCallout,\n table: renderTable,\n sequence: renderSequence,\n erd: renderErd,\n userstory: renderUserStory,\n timeline: renderTimeline,\n kanban: renderKanban,\n tracker: renderTracker,\n prose: renderProseBlock,\n glossary: renderGlossary,\n proscons: renderProsCons,\n cvt: renderCvt,\n stats: renderStats,\n code: renderCode,\n agenda: renderAgenda,\n tree: renderTree,\n pyramid: renderPyramid,\n funnel: renderFunnel,\n flow: renderFlow,\n state: renderState,\n dfd: renderDfd,\n journey: renderJourney,\n gantt: renderGantt,\n graph: renderGraph,\n quadrant: renderQuadrant,\n swimlane: renderSwimlane,\n c4: renderC4,\n uml: renderUml,\n mece: renderMece,\n frontend: renderFrontend,\n cluster: renderCluster,\n block: renderBlock,\n infra: renderInfra,\n event: renderEvent,\n ddd: renderDdd,\n network: renderNetwork,\n felogic: renderFelogic,\n belogic: renderBelogic,\n dag: renderDag,\n wireframe: renderWireframe,\n};\n","/**\n * Global SVG `<defs>` shared by multiple block renderers (markers used as edge\n * arrow heads, a drop-shadow filter for boxed nodes).\n *\n * Emitted once near the top of the rendered body so subsequent SVGs can\n * reference them by id. Ported from `resources/doc-studio.jsx` `GlobalDefs`.\n */\n\n/**\n * Returns the SVG element containing global marker + filter definitions.\n * The element is invisible (width/height = 0) but the defs are scoped to the\n * document so any subsequent `<svg>` can use `marker-end=\"url(#gArrow)\"` etc.\n */\nexport function globalDefsSvg(): string {\n return (\n `<svg width=\"0\" height=\"0\" style=\"position:absolute\" aria-hidden=\"true\">` +\n `<defs>` +\n `<marker id=\"gArrow\" viewBox=\"0 0 10 10\" refX=\"9\" refY=\"5\" markerWidth=\"7\" markerHeight=\"7\" orient=\"auto-start-reverse\">` +\n `<path d=\"M0,0 L10,5 L0,10 z\" fill=\"var(--charcoal)\"/></marker>` +\n `<marker id=\"gSoft\" viewBox=\"0 0 10 10\" refX=\"9\" refY=\"5\" markerWidth=\"7\" markerHeight=\"7\" orient=\"auto-start-reverse\">` +\n `<path d=\"M0,0 L10,5 L0,10 z\" fill=\"var(--gray)\"/></marker>` +\n `<marker id=\"gErr\" viewBox=\"0 0 10 10\" refX=\"9\" refY=\"5\" markerWidth=\"7\" markerHeight=\"7\" orient=\"auto-start-reverse\">` +\n `<path d=\"M0,0 L10,5 L0,10 z\" fill=\"#991b1b\"/></marker>` +\n `<marker id=\"gTri\" viewBox=\"0 0 14 14\" refX=\"13\" refY=\"7\" markerWidth=\"14\" markerHeight=\"14\" orient=\"auto-start-reverse\">` +\n `<path d=\"M1,1 L13,7 L1,13 z\" fill=\"#fff\" stroke=\"#6b21a8\" stroke-width=\"1.2\"/></marker>` +\n `<filter id=\"gshadow\" x=\"-20%\" y=\"-20%\" width=\"140%\" height=\"170%\">` +\n `<feDropShadow dx=\"0\" dy=\"2\" stdDeviation=\"3\" flood-color=\"#0e54a1\" flood-opacity=\"0.13\"/></filter>` +\n `</defs>` +\n `</svg>`\n );\n}\n","/**\n * Theme system. Each theme is a set of CSS variable overrides applied via\n * `style=\"--navy: …; --blue: …\"` on the `.docskin` root element. The full\n * stylesheet (see {@link houseCss}) reads those variables.\n *\n * Adding a new theme = add an entry here. No CSS changes needed.\n *\n * Ported verbatim from `resources/doc-studio.jsx` `THEMES`.\n */\n\n/** Built-in theme names. */\nexport type ThemeName = 'textbook' | 'minimal' | 'teal' | 'plum' | 'slate' | 'dark' | 'soft';\n\n/** Default theme used when none is specified. */\nexport const DEFAULT_THEME: ThemeName = 'textbook';\n\ninterface ThemeDef {\n /** Human-readable label, for UI surfaces. */\n readonly label: string;\n /** CSS variable overrides applied at the `.docskin` root. */\n readonly vars: Readonly<Record<string, string>>;\n}\n\n/** The built-in themes. */\nexport const themes: Readonly<Record<ThemeName, ThemeDef>> = {\n // Default: warm textbook look (cream paper, deep academic navy, terracotta\n // accent, serif display + body) — the base :root tokens, no overrides needed.\n textbook: {\n label: 'Textbook',\n vars: {},\n },\n // Clean, modern, white: near-black ink, a single blue accent (#0070f3),\n // geometric sans, more rounding. (The former default.)\n minimal: {\n label: 'Minimal',\n vars: {\n '--navy': '#000000',\n '--navy-tint': '#d4d4d4',\n '--blue': '#0070f3',\n '--light-blue': '#e5f0ff',\n '--charcoal': '#111111',\n '--slate': '#444444',\n '--gray': '#888888',\n '--light-gray': '#fafafa',\n '--rule': '#eaeaea',\n '--highlight': '#0070f3',\n '--highlight-soft': '#e5f0ff',\n '--white': '#ffffff',\n '--radius': '8px',\n '--font-display':\n '\"Inter\",\"SF Pro Display\",-apple-system,BlinkMacSystemFont,\"Segoe UI\",Helvetica,Arial,sans-serif',\n '--font-body':\n '\"Inter\",-apple-system,BlinkMacSystemFont,\"Segoe UI\",Helvetica,Arial,sans-serif',\n },\n },\n teal: {\n label: 'Teal',\n vars: {\n '--navy': '#0f766e',\n '--blue': '#0e7490',\n '--highlight': '#f59e0b',\n },\n },\n plum: {\n label: 'Plum',\n vars: {\n '--navy': '#6b21a8',\n '--blue': '#7c3aed',\n '--highlight': '#db2777',\n },\n },\n slate: {\n label: 'Slate sans',\n vars: {\n '--navy': '#334155',\n '--blue': '#475569',\n '--highlight': '#0d9488',\n '--font-display': '\"Helvetica Neue\", Arial, sans-serif',\n },\n },\n // Full dark mode. Surfaces (--white) and ink (--charcoal) flip; neutrals are\n // remapped so hairlines/edges read as light-on-dark. Accent hues are brightened\n // for contrast. Node \"chip\" pastels (in the SVG palette) stay light by design —\n // they read as colored cards on the dark canvas.\n dark: {\n label: 'Dark',\n vars: {\n '--white': '#161b26', // surfaces: page + cards + diagram bg\n '--charcoal': '#e6e9f2', // primary ink + structural strokes\n '--slate': '#c2c9d6', // secondary text\n '--gray': '#94a0b4', // muted text / dashed edges\n '--light-gray': '#222a39', // subtle panels / zone fills / bars\n '--rule': '#333f54', // hairlines / borders\n '--navy': '#5b9cff', // primary accent (headings, links, primary nodes)\n '--navy-tint': '#1e2a44',\n '--blue': '#7fb0ff',\n '--light-blue': '#16233a',\n '--highlight': '#f7a64a',\n '--highlight-soft': '#3a2c17',\n '--positive': '#3ecf7a',\n '--positive-soft': '#16301f',\n '--negative': '#ff6b6b',\n '--negative-soft': '#3a1d1d',\n '--purple': '#b78bff',\n '--purple-soft': '#271d3a',\n '--teal': '#4fd1c5',\n '--teal-soft': '#13302d',\n '--radius': '14px',\n },\n },\n // Soft modern light theme: rounded surfaces, indigo accent, warm-gray ink.\n soft: {\n label: 'Soft',\n vars: {\n '--navy': '#4f46e5',\n '--blue': '#6366f1',\n '--charcoal': '#1f2433',\n '--slate': '#4b5366',\n '--gray': '#8b93a7',\n '--rule': '#e6e8ef',\n '--light-gray': '#f5f6fa',\n '--highlight': '#f59e0b',\n '--radius': '16px',\n '--font-display': '\"Helvetica Neue\", Arial, sans-serif',\n },\n },\n};\n\n/**\n * Returns the CSS variable overrides for a theme as an inline-style string\n * (e.g. `\"--navy:#0f766e;--blue:#0e7490;\"`). Empty string for the default\n * textbook theme.\n */\nexport function themeStyle(name: ThemeName): string {\n const vars = themes[name].vars;\n const parts: string[] = [];\n for (const k of Object.keys(vars)) parts.push(`${k}:${vars[k]};`);\n return parts.join('');\n}\n","/**\n * Renders a parsed {@link Document} into its composable PARTS — the CSS, the\n * theme-variable string, the inner body HTML (for a `<div class=\"docskin\">`),\n * the title, and a section index for navigation.\n *\n * {@link renderDocument} (in `document.ts`) wraps these parts into a standalone\n * `<!doctype html>` page. Embedding consumers (e.g. a React app) inject the\n * parts directly: one `<style>` with `css`, a scoped `<style>` that sets the\n * theme vars, and the `body` inside their own `.docskin` host. This avoids\n * nesting a full HTML document inside the page and enables live theme switching\n * (swap only the theme-vars style) and section-level navigation (each section\n * carries an `id`).\n */\n\nimport type { BlockDataMap, BlockType, Document, Segment, TypedSegment } from '@avodado/core';\nimport { houseCss } from './css.js';\nimport { escapeHtml } from './escape.js';\nimport { renderCover } from './blocks/meta.js';\nimport { SECTION_LABEL } from './blocks/frame.js';\nimport { renderProse } from './markdown.js';\nimport { htmlRenderers } from './registry.js';\nimport { globalDefsSvg } from './svg/defs.js';\nimport { DEFAULT_THEME, themeStyle, type ThemeName } from './themes.js';\n\n/** Options shared by {@link renderDocumentParts} and the page renderer. */\nexport interface RenderPartsOptions {\n /** Theme name. Defaults to `textbook`. */\n readonly theme?: ThemeName;\n /**\n * Custom CSS-variable overrides applied after the named theme (they win),\n * e.g. `{ '--navy': '#123456' }`.\n */\n readonly themeVars?: Readonly<Record<string, string>>;\n}\n\n/** One navigable section of a rendered document. */\nexport interface DocumentSection {\n /** DOM id of the `<section>` (e.g. `section-01`). */\n readonly id: string;\n /** 1-based section number. */\n readonly num: number;\n /** Section label (e.g. `Roadmap`, `Sequence`). */\n readonly label: string;\n /** The block's title, if it has one. */\n readonly title?: string;\n}\n\n/** The composable pieces of a rendered document. */\nexport interface DocumentParts {\n /** Theme-independent house stylesheet. Inject once. */\n readonly css: string;\n /** Theme variable declarations (e.g. `--navy:#0f766e;`), or `''` for default. */\n readonly themeVars: string;\n /** Inner HTML for a `<div class=\"docskin\">` host: defs + cover + sections. */\n readonly body: string;\n /** Document title (from the `meta` block). */\n readonly title: string;\n /** Section index for navigation. */\n readonly sections: readonly DocumentSection[];\n}\n\ninterface RenderCtx {\n sectionNum: number;\n sections: DocumentSection[];\n}\n\nfunction pad2(n: number): string {\n return n < 10 ? `0${n}` : String(n);\n}\n\n/** Reads optional title/lede from a block's data, defensively typed. */\nfunction readTitleAndLede(data: unknown): { title?: string; lede?: string } {\n if (data === null || typeof data !== 'object') return {};\n const d = data as { title?: unknown; lede?: unknown };\n const out: { title?: string; lede?: string } = {};\n if (typeof d.title === 'string' && d.title.length > 0) out.title = d.title;\n if (typeof d.lede === 'string' && d.lede.length > 0) out.lede = d.lede;\n return out;\n}\n\nfunction renderSectionHead(num: number, kind: BlockType, title?: string, lede?: string): string {\n const label = SECTION_LABEL[kind];\n const titleHtml =\n title !== undefined ? `<h2 class=\"section-title\">${escapeHtml(title)}</h2>` : '';\n const ledeHtml = lede !== undefined ? `<p class=\"section-lede\">${escapeHtml(lede)}</p>` : '';\n return (\n `<div class=\"section-head\">` +\n `<div class=\"section-num\">SECTION ${pad2(num)} · ${escapeHtml(label)}</div>` +\n titleHtml +\n ledeHtml +\n `</div>`\n );\n}\n\n/**\n * Dispatches a typed block to its renderer. The registry is keyed by the same\n * `BlockType` discriminant as the segment, so this single contained cast asserts\n * the invariant rather than leaking casts to every call site.\n */\nfunction dispatchBlock<K extends BlockType>(kind: K, data: BlockDataMap[K]): string {\n const fn = htmlRenderers[kind] as (data: BlockDataMap[K]) => string;\n return fn(data);\n}\n\nfunction renderTypedSegment(seg: TypedSegment, ctx: RenderCtx): string {\n if (seg.kind === 'meta') return '';\n if (seg.parseError !== undefined) {\n return `<div class=\"err\">${escapeHtml(seg.kind)} block — parse error:\\n${escapeHtml(seg.parseError)}</div>`;\n }\n if (seg.data === null || seg.data === undefined) return '';\n\n const body = dispatchBlock(seg.kind, seg.data as BlockDataMap[typeof seg.kind]);\n\n ctx.sectionNum += 1;\n const num = ctx.sectionNum;\n const { title, lede } = readTitleAndLede(seg.data);\n const id = `section-${pad2(num)}`;\n ctx.sections.push({\n id,\n num,\n label: SECTION_LABEL[seg.kind],\n ...(title !== undefined ? { title } : {}),\n });\n const head = renderSectionHead(num, seg.kind, title, lede);\n\n return `<section id=\"${id}\" class=\"section-block\">${head}${body}</section>`;\n}\n\nfunction renderSegment(seg: Segment, ctx: RenderCtx): string {\n if (seg.kind === 'markdown') return renderProse(seg.text);\n return renderTypedSegment(seg, ctx);\n}\n\n/** Builds the theme-variable declaration string (named theme + overrides). */\nexport function buildThemeVars(\n theme: ThemeName,\n vars?: Readonly<Record<string, string>>,\n): string {\n let css = themeStyle(theme);\n if (vars !== undefined) {\n for (const k of Object.keys(vars)) css += `${k}:${vars[k]};`;\n }\n return css;\n}\n\n/**\n * Renders a document into its composable parts.\n *\n * @param doc - The parsed Avodado document.\n * @param opts - Optional theme + variable overrides.\n * @returns The CSS, theme vars, body HTML, title, and section index.\n */\nexport function renderDocumentParts(doc: Document, opts: RenderPartsOptions = {}): DocumentParts {\n const title = doc.meta?.title ?? 'Untitled';\n const theme = opts.theme ?? DEFAULT_THEME;\n const themeVars = buildThemeVars(theme, opts.themeVars);\n const ctx: RenderCtx = { sectionNum: 0, sections: [] };\n const body =\n globalDefsSvg() +\n renderCover(doc.meta) +\n doc.segments.map((s) => renderSegment(s, ctx)).join('');\n return { css: houseCss, themeVars, body, title, sections: ctx.sections };\n}\n","/**\n * Renders a parsed {@link Document} to a standalone HTML string.\n *\n * - Inlines the house CSS in `<style>` so the output is self-contained.\n * - Wraps the body in `<div class=\"docskin\">` so the CSS rules apply.\n * - Applies an optional theme by setting CSS variables on `:root`.\n *\n * The actual rendering is done by {@link renderDocumentParts} (in `parts.ts`);\n * this function just wraps those parts into a full HTML page. Embedding\n * consumers (e.g. a React app) should use `renderDocumentParts` directly.\n *\n * @example\n * ```ts\n * import { parseDocument } from '@avodado/core';\n * import { renderDocument } from '@avodado/render';\n *\n * const html = renderDocument(parseDocument(md, 'orders'), { theme: 'teal' });\n * ```\n */\n\nimport type { Document } from '@avodado/core';\nimport { escapeHtml } from './escape.js';\nimport { renderDocumentParts, type RenderPartsOptions } from './parts.js';\n\n/** Options for {@link renderDocument}. */\nexport type RenderOptions = RenderPartsOptions;\n\n/**\n * Renders a document to a standalone HTML page.\n *\n * @param doc - The parsed Avodado document.\n * @param opts - Optional render options (theme).\n * @returns A complete HTML string (`<!doctype html>…</html>`).\n */\nexport function renderDocument(doc: Document, opts: RenderOptions = {}): string {\n const parts = renderDocumentParts(doc, opts);\n const themeBlock =\n parts.themeVars.length > 0 ? `\\n<style>:root{${parts.themeVars}}</style>` : '';\n return (\n `<!doctype html>\\n` +\n `<html lang=\"en\">\\n` +\n `<head>\\n` +\n `<meta charset=\"utf-8\">\\n` +\n `<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\\n` +\n `<title>${escapeHtml(parts.title)}</title>\\n` +\n `<style>${parts.css}</style>` +\n themeBlock +\n `\\n</head>\\n` +\n `<body>\\n` +\n `<div class=\"docskin\">\\n` +\n parts.body +\n `</div>\\n` +\n `</body>\\n` +\n `</html>\\n`\n );\n}\n"]}
1
+ {"version":3,"sources":["../src/css.ts","../src/escape.ts","../src/sanitize.ts","../src/markdown.ts","../src/blocks/meta.ts","../src/blocks/frame.ts","../src/blocks/callout.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/graph.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/version.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/json.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/alg/index.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/alg/bellman-ford.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/alg/components.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/data/priority-queue.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/alg/dijkstra.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/alg/dijkstra-all.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/alg/tarjan.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/alg/find-cycles.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/alg/floyd-warshall.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/alg/topsort.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/alg/is-acyclic.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/alg/reduce.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/alg/dfs.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/alg/postorder.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/alg/preorder.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/alg/prim.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/node_modules/@dagrejs/graphlib/lib/alg/shortest-paths.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/util.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/version.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/data/list.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/greedy-fas.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/acyclic.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/normalize.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/rank/util.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/rank/feasible-tree.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/rank/network-simplex.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/rank/index.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/parent-dummy-chains.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/nesting-graph.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/add-border-segments.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/coordinate-system.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/order/init-order.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/order/cross-count.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/order/barycenter.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/order/resolve-conflicts.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/order/sort.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/order/sort-subgraph.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/order/build-layer-graph.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/order/add-subgraph-constraints.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/order/index.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/position/bk.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/position/index.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/layout.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/lib/debug.ts","../../../node_modules/.pnpm/@dagrejs+dagre@3.0.0/node_modules/@dagrejs/dagre/index.ts","../src/blocks/erd.ts","../src/blocks/kanban.ts","../src/blocks/sequence.ts","../src/blocks/table.ts","../src/blocks/timeline.ts","../src/blocks/tracker.ts","../src/blocks/userstory.ts","../src/blocks/prose.ts","../src/blocks/glossary.ts","../src/blocks/proscons.ts","../src/blocks/cvt.ts","../src/blocks/stats.ts","../src/highlight.ts","../src/blocks/code.ts","../src/blocks/agenda.ts","../src/blocks/tree.ts","../src/blocks/pyramid.ts","../src/blocks/funnel.ts","../src/svg/ortho.ts","../src/svg/wrapText.ts","../src/svg/edgePill.ts","../src/blocks/autoLayout.ts","../src/blocks/flow.ts","../src/blocks/state.ts","../src/blocks/dfd.ts","../src/blocks/journey.ts","../src/blocks/gantt.ts","../src/blocks/graph.ts","../src/blocks/quadrant.ts","../src/blocks/swimlane.ts","../src/svg/blockStyle.ts","../src/blocks/c4.ts","../src/blocks/uml.ts","../src/blocks/mece.ts","../src/blocks/frontend.ts","../src/blocks/cluster.ts","../src/blocks/blockGraph.ts","../src/blocks/felogic.ts","../src/blocks/wireframe.ts","../src/registry.ts","../src/svg/defs.ts","../src/themes.ts","../src/parts.ts","../src/document.ts"],"names":["Graph","opts","label","labelOrFn","v","names","name","removeEdge","e","child","parent","ancestor","children","predsV","sucsV","preds","union","succ","neighbors","filter","copy","value","parents","findParent","nodes","w","vStr","wStr","nameStr","edgeValue","valueSpecified","edgeArgsToId","edgeObj","edgeArgsToObj","incrementOrInitEntry","edgeObjToId","edgeLabel","edge","decrementOrRemoveEntry","setV","localEdge","remoteEdge","edges","map","k","isDirected","v_","w_","tmp","version","json_exports","__export","read","write","graph","json","writeNodes","writeEdges","graphLabel","g","nodeValue","node","entry","alg_exports","CycleException","bellmanFord","components","dijkstra","dijkstraAll","findCycles","floydWarshall","isAcyclic","postorder","preorder","prim","shortestPaths","tarjan","topsort","DEFAULT_WEIGHT_FUNC","source","weightFn","edgeFn","runBellmanFord","results","didADistanceUpgrade","iterations","relaxEdge","edgeWeight","relaxAllEdges","vertex","inVertex","outVertex","distance","numberOfNodes","i","visited","cmpts","cmpt","dfs","PriorityQueue","x","key","index","priority","keyIndices","keyStr","arr","min","currentPriority","l","r","largest","j","origArrI","origArrJ","defaultEdgeFn","runDijkstra","pq","vEntry","updateNeighbors","wEntry","weight","acc","stack","runFloydWarshall","d","rowK","rowI","ik","kj","ij","altDistance","args","visit","reduce","vs","order","fn","navigation","_a","doReduce","result","pri","init","runShortestPaths","negativeEdgeExists","adjList","addDummyNode","type","attrs","uniqueId","simplify","simplified","simpleLabel","asNonCompoundGraph","intersectRect","rect","point","y","dx","dy","h","sx","sy","buildLayerMatrix","layering","range","maxRank","rank","normalizeRanks","nodeRanks","applyWithChunking","removeEmptyRanks","offset","layers","delta","nodeRankFactor","addBorderNode","prefix","splitToChunks","array","chunkSize","CHUNKING_THRESHOLD","chunks","chunk","argsArray","partition","collection","time","start","notime","idCounter","id","limit","step","endCon","pick","keys","dest","mapValues","obj","funcOrProp","func","val","zipObject","props","values","GRAPH_NODE","List","__publicField","sentinel","unlink","strs","curr","filterOutLinks","list_default","DEFAULT_WEIGHT_FN","greedyFAS","state","buildState","doGreedyFAS","buckets","zeroIdx","sources","sinks","removeNode","collectPredecessors","collected","uEntry","assignBucket","fasGraph","maxIn","maxOut","prevWeight","vNode","wNode","_b","_c","run","dfsFAS","fas","undo","forwardName","normalizeEdge","vRank","wRank","labelRank","dummy","origLabel","longestPath","outEdges","outEdgesMinLens","slack","feasible_tree_default","feasibleTree","tree","size","tightTree","findMinSlackEdge","shiftRanks","nodeEdges","edgeV","edgeSlack","network_simplex_default","networkSimplex","initLowLimValues","initCutValues","calcCutValue","leaveEdge","enterEdge","exchangeEdges","t","f","visitedNodes","assignCutValue","childIsTail","graphEdge","cutValue","isOutEdge","other","pointsToHead","otherWeight","isTreeEdge","otherCutValue","root","dfsAssignLowLim","nextLim","low","vLabel","wLabel","tailLabel","flip","isDescendant","updateRanks","flipped","u","rootLabel","rank_default","ranker","networkSimplexRanker","tightTreeRanker","longestPathRanker","parent_dummy_chains_default","parentDummyChains","postorderNums","pathData","findPath","path","lca","pathIdx","pathV","ascending","vPath","wPath","lim","wParent","depths","treeDepths","depthsArr","height","nodeSep","sumWeights","top","bottom","childNode","childTop","childBottom","thisWeight","minlen","depth","cleanup","add_border_segments_default","addBorderSegments","prop","sg","sgNode","prev","adjust","rankDir","swapWidthHeight","reverseY","swapXY","swapWidthHeightOne","reverseYOne","swapXYOne","initOrder","simpleNodes","simpleNodesRanks","successors","a","b","crossCount","cc","twoLayerCrossCount","northLayer","southLayer","southPos","southEntries","firstIndex","treeSize","weightSum","barycenter","movable","inV","nodeU","resolveConflicts","entries","constraintGraph","mappedEntries","entryV","entryW","sourceSet","doResolveConflicts","handleIn","mergeEntries","handleOut","target","sum","sort","biasRight","parts","sortable","unsortable","vsIndex","compareWithBias","consumeUnsortable","last","bias","sortSubgraph","bl","br","subgraphs","barycenters","subgraphResult","mergeBarycenters","expandSubgraphs","blPredecessors","blPred","brPredecessors","brPred","buildLayerGraph","relationship","nodesWithRank","createRootNode","addSubgraphConstraints","rootPrev","prevChild","downLayerGraphs","buildLayerGraphs","upLayerGraphs","assignOrder","bestCC","best","constraints","lastBest","sweepLayerGraphs","ranks","nodesByRank","addNodeToRank","layerGraphs","cg","lg","con","sorted","layer","findType1Conflicts","conflicts","visitLayer","prevLayer","k0","scanPos","prevLayerLength","lastNode","findOtherInnerSegmentNode","k1","scanNode","uLabel","uPos","addConflict","findType2Conflicts","scan","south","southEnd","prevNorthBorder","nextNorthBorder","uNode","north","prevNorthPos","nextNorthPos","southLookahead","predecessors","firstPred","conflictsV","hasConflict","verticalAlignment","neighborFn","align","pos","prevIdx","wsRaw","ws","posA","posB","mp","il","posW","rootW","horizontalCompaction","reverseSep","xs","blockG","buildBlockGraph","borderType","iterate","setXsFunc","nextNodesFunc","elem","nextElem","pass1","inEdges","xsV","pass2","xsW","predecessorsWrapper","successorsWrapper","rootV","blockGraph","sepFn","sep","vRoot","uRoot","prevMax","findSmallestWidthAlignment","xss","currentMinAndXs","max","halfWidth","width","newMin","alignCoordinates","alignTo","alignToVals","alignToMin","alignToMax","vert","horiz","alignment","xsVals","balance","ulMap","num","alignmentKey","positionX","adjustedLayering","inner","smallestWidth","edgeSep","position","positionY","rankSep","rankAlign","prevY","maxHeight","layout","layoutGraph","buildLayoutGraph","runLayout","updateInputGraph","makeSpaceForEdgeLabels","removeSelfEdges","injectEdgeLabelProxies","assignRankMinMax","removeEdgeLabelProxies","insertSelfEdges","positionSelfEdges","removeBorderNodes","fixupEdgeLabelCoords","translateGraph","assignNodeIntersects","reversePointsForReversedEdges","inputGraph","inputLabel","layoutLabel","graphNumAttrs","graphDefaults","graphAttrs","nodeNumAttrs","nodeDefaults","edgeNumAttrs","edgeDefaults","edgeAttrs","canonicalize","selectNumberAttrs","newNode","proxyNode","minX","maxX","minY","maxY","marginX","marginY","getExtremes","p","nodeV","nodeW","p1","p2","orderShift","selfEdge","selfEdgeNode","selfNode","newAttrs","debugOrdering","layerMatrix","layerV","dagre","graphlib_esm_exports","index_default","W","H","at","N","it","st","lt","L","CHART_COLORS","A","B","ex","ey","rectFor","ln","s","P","clamp01","_"],"mappings":";;;AAWO,IAAM,QAAA,GAAW,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAA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AAM,KAAA,GAAQ,mBAAA,CAAoB,GAAA,EAAK,IAAI,CAAA;AAC3C,EAAA,MAAM,UAAA,GACJ,KAAA,CAAM,SAAA,CAAU,MAAA,GAAS,CAAA,GAAI;AAAA,aAAA,EAAkB,KAAA,CAAM,SAAS,CAAA,SAAA,CAAA,GAAc,EAAA;AAC9E,EAAA,OACE,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA,OAAA,EAKU,UAAA,CAAW,KAAA,CAAM,KAAK,CAAC,CAAA;AAAA,OAAA,EACvB,KAAA,CAAM,GAAG,CAAA,QAAA,CAAA,GACnB,UAAA,GACA;AAAA;AAAA;AAAA;AAAA,CAAA,GAGA,MAAM,IAAA,GACN,CAAA;AAAA;AAAA;AAAA,CAAA;AAIJ","file":"index.js","sourcesContent":["/**\n * The house CSS — ported verbatim from `resources/doc-studio.jsx`.\n *\n * All output is namespaced under `.docskin` so the stylesheet can coexist with\n * a host page's own styles. Theme switching works by overriding the CSS\n * variables on the `.docskin` root (see {@link themes}).\n *\n * Exported as a single string so it can be inlined into a `<style>` tag in the\n * standalone HTML produced by {@link renderDocument} (or copied verbatim into\n * a static stylesheet).\n */\nexport const houseCss = `*{box-sizing:border-box;margin:0;padding:0;}\nhtml{scroll-behavior:smooth;}\n/* Design tokens live on :root so a theme (applied as :root overrides) reaches\n the whole page — body chrome included, not just .docskin content. */\n:root{\n /* Default = \"textbook\": warm cream paper, deep academic navy, terracotta accent,\n classic serif display + body. Bigger headings for a printed-page feel. */\n --navy:#233a5e; --navy-tint:#c4d0e2; --blue:#2f5c8f; --light-blue:#e8eef6;\n --charcoal:#211f1a; --slate:#4a463d; --gray:#8a8475; --light-gray:#f2efe6;\n --rule:#e4dccb; --highlight:#9c4a2f; --highlight-soft:#f3e4dc;\n --positive:#3f7d4e; --positive-soft:#e3efe2; --negative:#a13b2e; --negative-soft:#f4e0db;\n --purple:#5b4a8a; --purple-soft:#ebe6f3; --teal:#2f6f6a; --teal-soft:#e0eeec; --white:#fcfbf7;\n --radius:4px;\n --font-display:\"Inter\",\"SF Pro Display\",-apple-system,BlinkMacSystemFont,\"Segoe UI\",Helvetica,Arial,sans-serif;\n --font-body:\"Inter\",-apple-system,BlinkMacSystemFont,\"Segoe UI\",Helvetica,Arial,sans-serif;\n --font-mono:\"SF Mono\",ui-monospace,Menlo,Consolas,\"Courier New\",monospace;\n}\nbody{background:var(--white);color:var(--charcoal);font-family:var(--font-body);font-size:15px;line-height:1.6;}\n.docskin{\n background:var(--white); color:var(--charcoal); font-family:var(--font-body); font-size:15px; line-height:1.6;\n max-width:1180px; margin:0 auto; padding:0 56px 128px;\n}\n.docskin .cover-bar{height:8px;background:var(--navy);margin:0 -56px 36px;}\n.docskin .cover-pad{padding:0 0 40px;margin-bottom:56px;border-bottom:1px solid var(--rule);}\n.docskin .cover-meta{display:flex;justify-content:space-between;flex-wrap:wrap;gap:16px;font-size:11px;text-transform:uppercase;letter-spacing:.12em;color:var(--gray);font-weight:600;margin-bottom:32px;}\n.docskin .cover-meta .accent{color:var(--highlight);}\n.docskin .cover-title{font-family:var(--font-display);font-weight:700;font-size:clamp(40px,5.2vw,62px);line-height:1.08;letter-spacing:-.015em;color:var(--navy);margin:0 0 22px;}\n.docskin .cover-sub{font-size:19px;line-height:1.55;color:var(--slate);max-width:860px;margin:0 0 36px;}\n.docskin .section{padding:0;margin-bottom:64px;}\n.docskin .section > *:last-child{margin-bottom:0;}\n.docskin .section-num{font-size:11px;text-transform:uppercase;letter-spacing:.14em;color:var(--highlight);font-weight:700;margin-bottom:8px;}\n.docskin .section-head{margin-bottom:28px;padding-bottom:16px;border-bottom:2px solid var(--navy);}\n.docskin .section-head .section-title{border-bottom:0;padding-bottom:0;margin-bottom:14px;}\n.docskin .section-title{font-family:var(--font-display);font-weight:700;font-size:clamp(28px,3.6vw,40px);line-height:1.15;letter-spacing:-.01em;color:var(--navy);margin:0 0 14px;padding-bottom:12px;border-bottom:2px solid var(--navy);}\n.docskin .section-lede{font-size:15.5px;color:var(--slate);line-height:1.6;max-width:860px;margin:0;}\n.docskin .section-block{margin-bottom:64px;}\n.docskin .section-block:last-child{margin-bottom:0;}\n.docskin .diagram{margin:28px 0 36px;border:1px solid var(--rule);background:var(--white);padding:22px 26px 18px;border-radius:var(--radius);}\n.docskin .diagram-head{display:flex;flex-wrap:wrap;align-items:baseline;gap:10px;padding-bottom:12px;margin-bottom:16px;border-bottom:1px dashed var(--rule);}\n.docskin .diagram-tag{font-family:var(--font-mono);font-size:10px;font-weight:700;padding:3px 9px;background:var(--navy);color:var(--white);letter-spacing:.08em;text-transform:uppercase;}\n.docskin .diagram-tag.post{background:var(--navy);} .docskin .diagram-tag.get{background:var(--positive);} .docskin .diagram-tag.c4{background:var(--blue);}\n.docskin .diagram-title{font-family:var(--font-display);font-weight:700;font-size:16px;color:var(--charcoal);flex:1;}\n.docskin .diagram-fignum{font-size:10px;color:var(--gray);text-transform:uppercase;letter-spacing:.1em;font-weight:700;}\n.docskin .diagram-desc{font-size:13px;color:var(--slate);margin:0 0 12px;}\n.docskin .diagram svg{display:block;margin:0 auto;max-width:100%;height:auto;}\n/* sequence */\n.docskin .lane-head{fill:var(--navy);} .docskin .lane-head.ext{fill:var(--slate);}\n.docskin .lane-head-text{fill:var(--white);font-family:var(--font-body);font-size:12px;font-weight:700;text-anchor:middle;}\n.docskin .lane-head-sub{fill:var(--navy-tint);font-family:var(--font-mono);font-size:9px;text-anchor:middle;letter-spacing:.06em;}\n.docskin .lane-head-sub.ext{fill:#cbd5e1;}\n.docskin .lifeline{stroke:var(--gray);stroke-width:1;stroke-dasharray:3 3;}\n.docskin .activation{fill:var(--light-blue);stroke:var(--navy);stroke-width:1;} .docskin .activation.pg{fill:var(--positive-soft);stroke:var(--positive);}\n.docskin .msg-line{stroke:var(--charcoal);stroke-width:1.2;fill:none;}\n.docskin .msg-line.dashed{stroke-dasharray:5 3;} .docskin .msg-line.err{stroke:var(--negative);stroke-width:1.4;}\n.docskin .msg-text{fill:var(--charcoal);font-family:var(--font-mono);font-size:10.5px;}\n.docskin .msg-text.em{fill:var(--navy);font-weight:700;} .docskin .msg-text.err{fill:var(--negative);font-weight:700;} .docskin .msg-text.note{fill:var(--gray);font-style:italic;}\n.docskin .step-badge{fill:var(--navy);} .docskin .step-badge.err{fill:var(--negative);}\n.docskin .step-badge-text{fill:var(--white);font-family:var(--font-mono);font-size:10px;font-weight:700;text-anchor:middle;}\n.docskin .seq-steps{margin-top:16px;padding:14px 18px;background:var(--light-gray);border:1px solid var(--rule);}\n.docskin .seq-steps-title{font-size:10px;text-transform:uppercase;letter-spacing:.12em;color:var(--navy);font-weight:700;margin-bottom:8px;}\n.docskin .seq-steps ol{list-style:none;counter-reset:step;padding:0;margin:0;}\n.docskin .seq-steps li{counter-increment:step;padding:7px 0 8px 40px;position:relative;border-bottom:1px solid var(--rule);}\n.docskin .seq-steps li:last-child{border-bottom:none;}\n.docskin .seq-steps li::before{content:counter(step);position:absolute;left:0;top:7px;width:26px;height:20px;background:var(--navy);color:var(--white);font-family:var(--font-mono);font-size:11px;font-weight:700;text-align:center;line-height:20px;border-radius:2px;}\n.docskin .seq-steps li.err::before{background:var(--negative);}\n.docskin .step-actor{font-family:var(--font-mono);font-size:11px;font-weight:700;color:var(--navy);margin-right:8px;text-transform:uppercase;letter-spacing:.06em;}\n.docskin .step-actor.err{color:var(--negative);}\n.docskin .step-summary{font-size:13px;color:var(--charcoal);}\n/* c4 */\n.docskin .c4-name{font-family:var(--font-display);font-size:14px;font-weight:700;}\n.docskin .c4-tech{font-family:var(--font-mono);font-size:9.5px;}\n.docskin .c4-desc{font-family:var(--font-body);font-size:10px;}\n.docskin .c4-chip{font-family:var(--font-body);font-size:8px;font-weight:700;letter-spacing:.1em;text-transform:uppercase;}\n.docskin .edge-label{font-family:var(--font-body);font-size:9.5px;fill:var(--slate);text-anchor:middle;}\n.docskin .edge-label.err{fill:var(--negative);font-weight:700;}\n.docskin .c4-boundary{fill:none;stroke:var(--navy);stroke-width:1.4;stroke-dasharray:8 5;}\n.docskin .c4-boundary-label{font-family:var(--font-body);font-size:10px;font-weight:700;fill:var(--navy);letter-spacing:.08em;text-transform:uppercase;}\n.docskin .legend{display:flex;flex-wrap:wrap;gap:8px 16px;margin-top:14px;padding-top:12px;border-top:1px dashed var(--rule);}\n.docskin .legend .item{display:flex;align-items:center;gap:6px;font-size:11px;color:var(--slate);}\n.docskin .legend .sw{width:13px;height:13px;border-radius:3px;}\n/* code block */\n.docskin .code-block{margin:12px 0 16px;border:1px solid var(--rule);}\n.docskin .code-header{display:flex;justify-content:space-between;padding:6px 14px;background:var(--light-gray);font-family:var(--font-mono);font-size:11px;font-weight:700;color:var(--slate);border-bottom:1px solid var(--rule);letter-spacing:.04em;}\n.docskin .code-block pre{padding:14px 16px;font-family:var(--font-mono);font-size:12px;line-height:1.55;color:var(--charcoal);overflow-x:auto;background:var(--white);white-space:pre;margin:0;}\n.docskin .code-block .kw{color:var(--navy);font-weight:700;} .docskin .code-block .com{color:var(--gray);font-style:italic;}\n.docskin .code-block .str{color:var(--positive);} .docskin .code-block .num{color:var(--purple);} .docskin .code-block .fn{color:var(--blue);} .docskin .code-block .ty{color:var(--teal);}\n/* er */\n.docskin .er-head-text{fill:var(--white);font-family:var(--font-display);font-size:13px;font-weight:700;text-anchor:middle;}\n.docskin .er-col{font-family:var(--font-mono);font-size:10.5px;fill:var(--charcoal);} .docskin .er-col.dim{fill:var(--gray);}\n.docskin .er-key{font-family:var(--font-mono);font-size:9px;font-weight:700;fill:var(--navy);} .docskin .er-key.fk{fill:var(--highlight);}\n.docskin .er-rowline{stroke:var(--light-gray);stroke-width:1;}\n/* block / state / flow shared text */\n.docskin .blk-name{font-family:var(--font-display);font-size:13px;font-weight:700;}\n.docskin .blk-tech{font-family:var(--font-mono);font-size:9.5px;}\n.docskin .blk-chip{font-family:var(--font-body);font-size:8px;font-weight:700;letter-spacing:.1em;text-transform:uppercase;}\n.docskin .grp-label{font-family:var(--font-body);font-size:10px;font-weight:700;letter-spacing:.06em;text-transform:uppercase;}\n.docskin .sm-name{font-family:var(--font-display);font-size:13px;font-weight:700;text-anchor:middle;}\n.docskin .fc-label{font-family:var(--font-display);font-size:12px;font-weight:700;text-anchor:middle;}\n.docskin .endpoint-card{border:1px solid var(--rule);margin:16px 0;padding:18px 22px;background:var(--white);}\n.docskin .endpoint-header{display:flex;align-items:center;gap:12px;margin-bottom:10px;padding-bottom:10px;border-bottom:1px dashed var(--rule);}\n.docskin .endpoint-method{font-family:var(--font-mono);font-size:11px;font-weight:700;padding:4px 10px;color:var(--white);letter-spacing:.08em;text-transform:uppercase;}\n.docskin .endpoint-method.get{background:var(--positive);} .docskin .endpoint-method.post{background:var(--navy);} .docskin .endpoint-method.patch{background:var(--highlight);} .docskin .endpoint-method.delete{background:var(--negative);} .docskin .endpoint-method.put{background:var(--blue);}\n.docskin .endpoint-path{font-family:var(--font-mono);font-size:15px;font-weight:700;color:var(--charcoal);flex:1;}\n.docskin .endpoint-status{font-family:var(--font-mono);font-size:11.5px;color:var(--positive);font-weight:700;}\n.docskin .endpoint-desc{font-size:13px;color:var(--slate);margin:0 0 8px;}\n.docskin .endpoint-card h4{font-size:11px;text-transform:uppercase;letter-spacing:.12em;font-weight:700;color:var(--highlight);margin:14px 0 6px;}\n.docskin .endpoint-card ul{margin:0 0 0 20px;} .docskin .endpoint-card li{font-size:13px;margin-bottom:3px;}\n.docskin code{font-family:var(--font-mono);font-size:.86em;background:var(--light-gray);padding:2px 6px;border-radius:2px;border:1px solid var(--rule);}\n.docskin .transition-table{width:100%;border-collapse:collapse;margin:16px 0 8px;font-size:12px;}\n.docskin .transition-table thead{background:var(--navy);color:#fff;}\n.docskin .transition-table th{text-align:left;padding:8px 10px;font-size:9.5px;text-transform:uppercase;letter-spacing:.1em;}\n.docskin .transition-table td{padding:8px 10px;border-bottom:1px solid var(--rule);vertical-align:top;}\n.docskin .pill{display:inline-block;font-family:var(--font-mono);font-size:10px;font-weight:700;padding:2px 7px;border-radius:2px;text-transform:uppercase;}\n.docskin .pill-init{background:var(--light-gray);color:var(--slate);border:1px solid var(--rule);}\n.docskin .pill-active{background:var(--positive-soft);color:var(--positive);border:1px solid var(--positive);}\n.docskin .pill-wait{background:var(--highlight-soft);color:var(--highlight);border:1px solid var(--highlight);}\n.docskin .pill-end{background:var(--charcoal);color:#fff;}\n/* presentation: comparison table */\n.docskin .pres-table{width:100%;border-collapse:collapse;margin:14px 0;font-size:13px;}\n.docskin .pres-table thead{background:var(--navy);color:#fff;}\n.docskin .pres-table th{padding:9px 12px;text-align:left;font-family:var(--font-body);font-size:10.5px;text-transform:uppercase;letter-spacing:.08em;font-weight:700;}\n.docskin .pres-table th.r,.docskin .pres-table td.r{text-align:right;} .docskin .pres-table th.c,.docskin .pres-table td.c{text-align:center;}\n.docskin .pres-table th.hi{background:var(--highlight);}\n.docskin .pres-table td{padding:9px 12px;border-bottom:1px solid var(--rule);}\n.docskin .pres-table tbody tr:nth-child(even){background:var(--light-gray);}\n.docskin .pres-table td.lead{font-weight:700;color:var(--navy);font-family:var(--font-display);}\n.docskin .pres-table td.hi{background:var(--highlight-soft);}\n.docskin .cell-pos{color:var(--positive);font-weight:700;} .docskin .cell-neg{color:var(--negative);font-weight:700;} .docskin .cell-warn{color:var(--highlight);font-weight:700;} .docskin .cell-muted{color:var(--gray);}\n.docskin .badge{display:inline-flex;align-items:center;justify-content:center;width:20px;height:20px;border-radius:50%;font-size:12px;font-weight:700;}\n.docskin .badge.yes{background:var(--positive-soft);color:var(--positive);} .docskin .badge.no{background:var(--negative-soft);color:var(--negative);}\n.docskin .tbl-note{font-size:11px;color:var(--gray);font-style:italic;margin-top:6px;}\n/* presentation: stat cards */\n.docskin .stat-row{display:flex;flex-wrap:wrap;gap:14px;margin:16px 0;}\n.docskin .stat-card{flex:1 1 150px;border:1px solid var(--rule);border-top:3px solid var(--navy);padding:16px 18px;background:var(--white);}\n.docskin .stat-value{font-family:var(--font-display);font-size:30px;font-weight:700;color:var(--navy);line-height:1;}\n.docskin .stat-label{font-size:10.5px;text-transform:uppercase;letter-spacing:.1em;color:var(--gray);font-weight:700;margin-top:8px;}\n.docskin .stat-delta{font-family:var(--font-mono);font-size:12px;font-weight:700;margin-top:6px;}\n.docskin .stat-delta.up{color:var(--positive);} .docskin .stat-delta.down{color:var(--negative);} .docskin .stat-delta.flat{color:var(--gray);}\n/* presentation: timeline */\n.docskin .tl{position:relative;margin:18px 0;padding-left:8px;}\n.docskin .tl::before{content:\"\";position:absolute;left:9px;top:6px;bottom:6px;width:2px;background:var(--rule);}\n.docskin .tl-item{position:relative;padding:0 0 18px 30px;}\n.docskin .tl-item:last-child{padding-bottom:0;}\n.docskin .tl-dot{position:absolute;left:2px;top:2px;width:16px;height:16px;border-radius:50%;background:var(--white);border:3px solid var(--rule);box-sizing:border-box;}\n.docskin .tl-dot.done{background:var(--positive);border-color:var(--positive);} .docskin .tl-dot.current{background:var(--highlight);border-color:var(--highlight);} .docskin .tl-dot.next{border-color:var(--navy);}\n.docskin .tl-date{font-family:var(--font-mono);font-size:10.5px;font-weight:700;color:var(--highlight);text-transform:uppercase;letter-spacing:.06em;}\n.docskin .tl-label{font-family:var(--font-display);font-size:15px;font-weight:700;color:var(--navy);margin:1px 0 2px;}\n.docskin .tl-desc{font-size:12.5px;color:var(--slate);}\n/* presentation: quadrant */\n.docskin .quad-axis{stroke:var(--charcoal);stroke-width:1.5;}\n.docskin .quad-end{font-family:var(--font-body);font-size:10px;font-weight:700;fill:var(--gray);text-transform:uppercase;letter-spacing:.06em;}\n.docskin .quad-title{font-family:var(--font-body);font-size:11px;font-weight:700;fill:var(--navy);text-transform:uppercase;letter-spacing:.08em;}\n.docskin .quad-pt-label{font-family:var(--font-body);font-size:11px;font-weight:700;fill:var(--charcoal);}\n.docskin .toc{margin:18px 0 6px;padding:14px 20px;background:var(--light-gray);border:1px solid var(--rule);border-left:4px solid var(--highlight);}\n.docskin .toc-title{font-size:10px;text-transform:uppercase;letter-spacing:.12em;color:var(--navy);font-weight:700;margin-bottom:8px;}\n.docskin .toc ol{margin:0;padding-left:20px;} .docskin .toc li{font-size:13px;margin-bottom:4px;color:var(--slate);}\n.docskin .toc li span{color:var(--gray);font-family:var(--font-mono);font-size:11px;}\n/* swimlane */\n.docskin .sl-lane-label{font-family:var(--font-display);font-size:12px;font-weight:700;fill:#fff;}\n.docskin .sl-step{font-family:var(--font-body);font-size:11px;font-weight:700;text-anchor:middle;}\n/* callouts */\n.docskin .callout{border:1px solid var(--rule);border-left:4px solid var(--navy);padding:12px 16px;margin:10px 0;}\n.docskin .callout.note{border-left-color:var(--navy);background:var(--light-blue);} .docskin .callout.tip{border-left-color:var(--positive);background:var(--positive-soft);} .docskin .callout.warn{border-left-color:var(--highlight);background:var(--highlight-soft);} .docskin .callout.danger{border-left-color:var(--negative);background:var(--negative-soft);}\n.docskin .callout-title{font-size:10.5px;text-transform:uppercase;letter-spacing:.1em;font-weight:700;margin-bottom:4px;}\n.docskin .callout.note .callout-title{color:var(--navy);} .docskin .callout.tip .callout-title{color:var(--positive);} .docskin .callout.warn .callout-title{color:#b45309;} .docskin .callout.danger .callout-title{color:var(--negative);}\n.docskin .callout-body{font-size:13px;color:var(--slate);}\n/* prose */\n.docskin .prose h2{font-family:var(--font-display);font-weight:700;font-size:clamp(24px,3vw,32px);line-height:1.15;letter-spacing:-.015em;color:var(--navy);margin:40px 0 14px;padding-bottom:12px;border-bottom:2px solid var(--navy);}\n.docskin .prose h2:first-child{margin-top:0;}\n.docskin .prose h3{font-family:var(--font-display);font-weight:700;font-size:19px;letter-spacing:-.005em;color:var(--navy);margin:36px 0 12px;}\n.docskin .prose h4{font-size:11px;text-transform:uppercase;letter-spacing:.12em;font-weight:700;color:var(--highlight);margin:22px 0 8px;}\n.docskin .prose p{font-size:14px;color:var(--charcoal);margin:0 0 14px;line-height:1.6;max-width:880px;}\n.docskin .prose ul,.docskin .prose ol{margin:0 0 14px 22px;}\n.docskin .prose li{font-size:13.5px;color:var(--charcoal);margin-bottom:4px;max-width:880px;line-height:1.55;}\n.docskin .prose blockquote{border-left:3px solid var(--highlight);padding:4px 14px;margin:14px 0;color:var(--slate);font-style:italic;font-family:var(--font-display);}\n.docskin .prose code{font-family:var(--font-mono);font-size:.86em;background:var(--light-gray);padding:2px 6px;border-radius:2px;color:var(--charcoal);border:1px solid var(--rule);}\n.docskin .prose strong{font-weight:700;color:var(--charcoal);}\n.docskin .prose em{font-style:italic;}\n/* glossary */\n.docskin .glossary{margin:10px 0;}\n.docskin .glossary .row{display:grid;grid-template-columns:170px 1fr;gap:14px;padding:9px 0;border-bottom:1px solid var(--rule);}\n.docskin .glossary dt{font-family:var(--font-mono);font-size:13px;font-weight:700;color:var(--navy);}\n.docskin .glossary dd{margin:0;font-size:13px;color:var(--slate);}\n/* pros / cons */\n.docskin .pc{display:grid;grid-template-columns:1fr 1fr;gap:16px;margin:12px 0;}\n.docskin .pc-col{border:1px solid var(--rule);padding:14px 16px;}\n.docskin .pc-col.pro{border-top:3px solid var(--positive);} .docskin .pc-col.con{border-top:3px solid var(--negative);}\n.docskin .pc-head{font-size:11px;text-transform:uppercase;letter-spacing:.1em;font-weight:700;margin-bottom:8px;}\n.docskin .pc-col.pro .pc-head{color:var(--positive);} .docskin .pc-col.con .pc-head{color:var(--negative);}\n.docskin .pc-item{font-size:13px;color:var(--slate);padding:4px 0 4px 22px;position:relative;}\n.docskin .pc-item::before{position:absolute;left:0;top:4px;font-weight:700;}\n.docskin .pc-col.pro .pc-item::before{content:\"\\\\2713\";color:var(--positive);} .docskin .pc-col.con .pc-item::before{content:\"\\\\2717\";color:var(--negative);}\n/* current / target */\n.docskin .ct{display:flex;align-items:stretch;margin:12px 0;}\n.docskin .ct-panel{flex:1;border:1px solid var(--rule);padding:14px 18px;}\n.docskin .ct-panel.cur{background:var(--light-gray);} .docskin .ct-panel.tgt{border-top:3px solid var(--navy);}\n.docskin .ct-arrow{display:flex;align-items:center;padding:0 14px;color:var(--highlight);font-size:22px;font-weight:700;}\n.docskin .ct-label{font-size:11px;text-transform:uppercase;letter-spacing:.1em;font-weight:700;color:var(--gray);margin-bottom:8px;}\n.docskin .ct-panel.tgt .ct-label{color:var(--navy);}\n.docskin .ct-item{font-size:13px;color:var(--slate);padding:3px 0;}\n/* kanban */\n.docskin .kanban{display:flex;gap:14px;margin:12px 0;overflow-x:auto;}\n.docskin .kan-col{flex:1 1 0;min-width:150px;background:var(--light-gray);border:1px solid var(--rule);}\n.docskin .kan-head{background:var(--navy);color:#fff;font-size:11px;text-transform:uppercase;letter-spacing:.08em;font-weight:700;padding:8px 12px;}\n.docskin .kan-card{background:var(--white);border:1px solid var(--rule);border-left:3px solid var(--highlight);margin:8px;padding:9px 11px;}\n.docskin .kan-card-title{font-size:13px;font-weight:700;color:var(--charcoal);}\n.docskin .kan-card-tag{display:inline-block;font-family:var(--font-mono);font-size:9px;font-weight:700;text-transform:uppercase;letter-spacing:.06em;color:var(--gray);margin-top:4px;}\n/* pass 2 chart labels */\n.docskin .dfd-name{font-family:var(--font-display);font-size:12px;font-weight:700;text-anchor:middle;}\n.docskin .dfd-num{font-family:var(--font-mono);font-size:9px;font-weight:700;}\n.docskin .gantt-label{font-family:var(--font-body);font-size:11px;fill:var(--charcoal);}\n.docskin .gantt-head{font-family:var(--font-mono);font-size:9.5px;fill:var(--gray);text-anchor:middle;}\n.docskin .funnel-label{font-family:var(--font-display);font-size:13px;font-weight:700;fill:#fff;text-anchor:middle;}\n.docskin .funnel-val{font-family:var(--font-mono);font-size:11px;fill:#fff;text-anchor:middle;opacity:.9;}\n.docskin .pyr-label{font-family:var(--font-display);font-size:13px;font-weight:700;fill:#fff;text-anchor:middle;}\n.docskin .pyr-desc{font-family:var(--font-body);font-size:10px;fill:#fff;text-anchor:middle;opacity:.85;}\n/* indented tree */\n.docskin .tree-list{margin:10px 0;font-size:13px;}\n.docskin .tree-row{display:flex;align-items:baseline;padding:3px 0;}\n.docskin .tree-row .tw{color:var(--gray);margin-right:8px;font-family:var(--font-mono);font-size:11px;}\n.docskin .tree-row.branch .tw{color:var(--navy);}\n.docskin .tree-row .tlabel{color:var(--charcoal);font-family:var(--font-mono);}\n.docskin .tree-row.branch .tlabel{font-weight:700;color:var(--navy);}\n.docskin .tree-row .tnote{color:var(--gray);font-size:11px;margin-left:10px;font-family:var(--font-body);font-style:italic;}\n/* agenda */\n.docskin .agenda{margin:10px 0;}\n.docskin .agenda-row{display:grid;grid-template-columns:88px 1fr;gap:14px;padding:10px 0;border-bottom:1px solid var(--rule);}\n.docskin .agenda-time{font-family:var(--font-mono);font-size:12px;font-weight:700;color:var(--navy);}\n.docskin .agenda-dur{font-family:var(--font-mono);font-size:10px;color:var(--gray);margin-top:2px;}\n.docskin .agenda-title{font-family:var(--font-display);font-size:14px;font-weight:700;color:var(--charcoal);}\n.docskin .agenda-owner{font-size:10.5px;color:var(--highlight);font-weight:700;text-transform:uppercase;letter-spacing:.05em;margin-left:8px;}\n.docskin .agenda-desc{font-size:12.5px;color:var(--slate);margin-top:2px;}\n/* tracker */\n.docskin .trk{width:100%;border-collapse:collapse;margin:12px 0;font-size:13px;}\n.docskin .trk thead{background:var(--navy);color:#fff;} .docskin .trk th{padding:8px 10px;text-align:left;font-size:9.5px;text-transform:uppercase;letter-spacing:.08em;font-weight:700;}\n.docskin .trk td{padding:8px 10px;border-bottom:1px solid var(--rule);vertical-align:middle;}\n.docskin .trk tr.done .trk-task{text-decoration:line-through;color:var(--gray);}\n.docskin .st{display:inline-block;font-family:var(--font-mono);font-size:9.5px;font-weight:700;padding:2px 8px;border-radius:10px;text-transform:uppercase;letter-spacing:.04em;}\n.docskin .st.todo{background:var(--light-gray);color:var(--slate);border:1px solid var(--rule);} .docskin .st.doing{background:var(--highlight-soft);color:#b45309;} .docskin .st.done{background:var(--positive-soft);color:var(--positive);} .docskin .st.blocked{background:var(--negative-soft);color:var(--negative);}\n.docskin .pri{font-family:var(--font-mono);font-size:10px;font-weight:700;} .docskin .pri.high{color:var(--negative);} .docskin .pri.med{color:var(--highlight);} .docskin .pri.low{color:var(--gray);}\n/* cluster */\n.docskin .cl-head{font-family:var(--font-display);font-size:13px;font-weight:700;fill:#fff;}\n.docskin .cl-kind{font-family:var(--font-mono);font-size:9px;fill:#cfe0f3;text-anchor:end;text-transform:uppercase;letter-spacing:.06em;}\n/* user story */\n.docskin .story{border:1px solid var(--rule);border-left:4px solid var(--navy);padding:18px 22px;margin:12px 0;background:var(--white);}\n.docskin .story-stmt{font-family:var(--font-display);font-size:18px;line-height:1.55;color:var(--charcoal);}\n.docskin .story-stmt b{color:var(--navy);}\n.docskin .story-meta{display:flex;gap:8px;margin-top:12px;flex-wrap:wrap;}\n.docskin .story-chip{font-family:var(--font-mono);font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.05em;padding:3px 9px;border-radius:3px;background:var(--light-gray);color:var(--slate);border:1px solid var(--rule);}\n.docskin .ac-title{font-size:10.5px;text-transform:uppercase;letter-spacing:.12em;color:var(--highlight);font-weight:700;margin:16px 0 8px;}\n.docskin .ac-item{border:1px solid var(--rule);padding:10px 14px;margin-bottom:8px;background:var(--white);}\n.docskin .gwt{display:grid;grid-template-columns:60px 1fr;gap:4px 12px;font-size:13px;}\n.docskin .gwt .k{font-family:var(--font-mono);font-size:10px;font-weight:700;text-transform:uppercase;letter-spacing:.06em;padding-top:1px;}\n.docskin .gwt .k.g{color:var(--positive);} .docskin .gwt .k.w{color:var(--navy);} .docskin .gwt .k.t{color:var(--highlight);}\n.docskin .gwt .v{color:var(--charcoal);}\n.docskin .links-row{display:flex;gap:8px;flex-wrap:wrap;}\n.docskin .link-chip{display:inline-flex;align-items:center;gap:6px;font-size:12px;font-weight:700;color:var(--navy);border:1px solid var(--navy);background:var(--white);padding:5px 11px;border-radius:20px;cursor:pointer;}\n.docskin .link-chip .lt{color:var(--gray);font-family:var(--font-mono);font-size:9px;text-transform:uppercase;letter-spacing:.06em;}\n.docskin .footer{margin-top:8px;padding:18px 32px 28px;border-top:2px solid var(--navy);font-size:11px;color:var(--gray);text-transform:uppercase;letter-spacing:.1em;font-weight:700;display:flex;justify-content:space-between;flex-wrap:wrap;gap:10px;}\n.docskin .footer .accent{color:var(--highlight);}\n.docskin .layer-label{font-family:var(--font-display);font-size:13px;font-weight:700;fill:#fff;}\n.docskin .uml-name{font-family:var(--font-display);font-size:13px;font-weight:700;text-anchor:middle;fill:#0a3a6e;}\n.docskin .uml-stereo{font-family:var(--font-body);font-size:9px;font-style:italic;text-anchor:middle;fill:#6b7280;}\n.docskin .uml-row{font-family:var(--font-mono);font-size:10.5px;fill:var(--charcoal);}\n.docskin .uml-sep{stroke:#0e54a1;stroke-width:1;}\n.docskin .ft-note{font-family:var(--font-mono);font-size:9px;}\n.docskin .tree-link{stroke:#9ca3af;stroke-width:1.3;fill:none;}\n/* wireframe / UI mockups */\n.docskin .wf-h{font-family:var(--font-display);font-size:18px;font-weight:700;}\n.docskin .wf-sub{font-family:var(--font-body);font-size:12px;font-weight:600;}\n.docskin .wf-btn{font-family:var(--font-body);font-size:11px;font-weight:700;fill:#fff;}\n.docskin .wf-ph-text{font-family:var(--font-body);font-size:10px;fill:var(--gray);}\n.docskin .wf-status{font-family:var(--font-mono);font-size:9px;fill:var(--charcoal);font-weight:700;}\n.docskin .wf-url{font-family:var(--font-mono);font-size:8.5px;fill:var(--gray);}\n.docskin .wf-tab{font-family:var(--font-body);font-size:8px;}\n.docskin .wf-caption{font-family:var(--font-mono);font-size:10px;fill:var(--gray);letter-spacing:.04em;}\n/* parse error */\n.docskin .err{font-family:var(--font-mono);font-size:12px;color:var(--negative);background:#fdf2f2;border:1px solid #f3c9c9;padding:8px 12px;margin:12px 0;white-space:pre-wrap;}`;\n","/**\n * HTML entity escaping, matching the reference renderer's `esc` semantics.\n *\n * Escapes `&`, `<`, `>`, and `\"`. `null`/`undefined` become the empty string.\n * Non-string values are coerced via `String()`.\n */\n\nconst REPL: Record<string, string> = {\n '&': '&amp;',\n '<': '&lt;',\n '>': '&gt;',\n '\"': '&quot;',\n};\n\n/**\n * Escapes a value for safe insertion into HTML text or attribute content.\n *\n * @param value - The value to escape (any type).\n * @returns The escaped string. Empty string for `null`/`undefined`.\n */\nexport function escapeHtml(value: unknown): string {\n if (value === null || value === undefined) return '';\n return String(value).replace(/[&<>\"]/g, (c) => REPL[c] ?? c);\n}\n","/**\n * Output-safety helpers.\n *\n * Avodado documents are normally authored by trusted hands, but rendered output\n * is also shown in untrusted contexts — the playground renders documents from\n * shared URLs, and any hosted preview renders whatever a visitor pastes. So the\n * renderer treats author-supplied values (colours, link hrefs, prose HTML) as\n * untrusted and neutralises anything that could break out of its target context.\n *\n * These functions are pure and allocation-light; they run on every render.\n */\n\n/**\n * Matches a safe CSS colour value: hex (`#rgb`/`#rgba`/`#rrggbb`/`#rrggbbaa`),\n * `rgb()/rgba()`, `hsl()/hsla()`, or a bare CSS named colour. Anything with a\n * quote, semicolon, angle bracket, or `url(` is rejected — those are the\n * shapes an attacker uses to break out of a `fill=\"…\"` or `style=\"…\"` context.\n */\nconst SAFE_COLOR_RE =\n /^(#[0-9a-fA-F]{3,8}|rgba?\\([\\d.,\\s%]+\\)|hsla?\\([\\d.,\\s%]+\\)|[a-zA-Z]{1,24})$/;\n\n/**\n * Returns `value` if it is a safe CSS colour, otherwise `fallback`.\n *\n * Use this for any author-supplied colour that gets interpolated into an SVG\n * attribute (`fill`, `stroke`) or a `style` declaration.\n *\n * @param value - The candidate colour (any author string, or undefined).\n * @param fallback - The colour to use when `value` is missing or unsafe.\n */\nexport function safeColor(value: string | undefined, fallback: string): string {\n if (value === undefined) return fallback;\n const trimmed = value.trim();\n return SAFE_COLOR_RE.test(trimmed) ? trimmed : fallback;\n}\n\n/** URL schemes that can execute script or smuggle markup. */\nconst DANGEROUS_URL_RE = /^\\s*(javascript|data|vbscript):/i;\n\n/**\n * Returns `url` if its scheme is safe to put in an `href`/`src`, otherwise `#`.\n *\n * Relative URLs, fragments (`#id`), and the usual web schemes pass through;\n * `javascript:`, `data:`, and `vbscript:` are rejected.\n *\n * @param url - The candidate URL.\n */\nexport function safeUrl(url: string): string {\n return DANGEROUS_URL_RE.test(url) ? '#' : url;\n}\n","/**\n * Renders a prose segment to HTML via `marked`.\n *\n * Hardened for untrusted input (the renderer's output is shown in the\n * playground and hosted previews, which render documents from strangers):\n *\n * - Raw HTML is **not** passed through — `marked` v14 emits raw HTML by\n * default, which is an XSS vector. We decline the block `html` and inline\n * `tag` tokenizers so any literal `<tag>` falls through to text and is\n * entity-escaped. This also matches Avodado's house rule: express structure\n * through blocks, never raw HTML.\n * - Link / image hrefs with `javascript:`, `data:`, or `vbscript:` schemes are\n * rewritten to `#` (see {@link safeUrl}).\n *\n * Output is deterministic (no auto heading ids, no smartypants).\n */\n\nimport { Marked, type Tokens } from 'marked';\nimport { safeUrl } from './sanitize.js';\n\nconst marked = new Marked({ gfm: true, breaks: false });\n\nmarked.use({\n tokenizer: {\n // Decline raw HTML at both block and inline level; the text falls through\n // to the paragraph/text tokenizer, which escapes it.\n html(): undefined {\n return undefined;\n },\n tag(): undefined {\n return undefined;\n },\n },\n renderer: {\n link(token: Tokens.Link): string {\n const href = safeUrl(token.href);\n const title = token.title !== null && token.title !== undefined ? ` title=\"${token.title}\"` : '';\n const text = this.parser.parseInline(token.tokens);\n return `<a href=\"${href}\"${title}>${text}</a>`;\n },\n image(token: Tokens.Image): string {\n const href = safeUrl(token.href);\n const title = token.title !== null && token.title !== undefined ? ` title=\"${token.title}\"` : '';\n return `<img src=\"${href}\" alt=\"${token.text}\"${title}>`;\n },\n },\n});\n\n/**\n * Renders Markdown prose to an HTML string wrapped in `<div class=\"prose\">`.\n *\n * @param text - The Markdown source.\n * @returns The HTML output, wrapped in a `prose` div for styling scope.\n */\nexport function renderProse(text: string): string {\n const html = marked.parse(text, { async: false });\n return `<div class=\"prose\">${html}</div>`;\n}\n","/**\n * Meta is rendered as the document cover (not as a body block). The registry\n * entry for `meta` returns an empty string; {@link renderCover} produces the\n * cover from the {@link Document.meta} data.\n *\n * Class names match doc-studio: `.cover-bar`, `.cover-pad`, `.cover-meta`,\n * `.cover-title`, `.cover-sub`.\n */\n\nimport type { MetaData } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\n/** Renders the document cover (banner + meta line + title + optional subtitle). */\nexport function renderCover(meta: MetaData | undefined): string {\n const title = meta?.title ?? 'Untitled';\n const tag = meta?.tag ?? '';\n const subtitle = meta?.subtitle;\n const sub =\n subtitle !== undefined ? `<p class=\"cover-sub\">${escapeHtml(subtitle)}</p>` : '';\n return (\n `<div class=\"cover-bar\"></div>` +\n `<div class=\"cover-pad\">` +\n `<div class=\"cover-meta\"><span>DOCUMENT</span><span class=\"accent\">${escapeHtml(tag)}</span></div>` +\n `<h1 class=\"cover-title\">${escapeHtml(title)}</h1>` +\n sub +\n `</div>`\n );\n}\n\n/**\n * Block-registry entry for `meta`. Always returns empty: the cover is rendered\n * separately by {@link renderCover}, called from {@link renderDocument}.\n */\nexport function renderMetaBlock(): string {\n return '';\n}\n","/**\n * Wraps block content in doc-studio's \"diagram frame\" — a bordered card with\n * a header (tag pill + title + figure number) and optional description.\n *\n * Used by diagram-type blocks (sequence, erd, …) so the output matches\n * doc-studio.jsx's `DiagramFrame` component.\n */\n\nimport type { BlockType } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\ninterface FrameOptions {\n /** Tag pill text (e.g. `SEQUENCE`, `ER`, `POST`). */\n readonly tag: string;\n /** Optional CSS class added to the tag pill (e.g. `post`, `get`). */\n readonly tagClass?: string;\n /** Optional inline background color for the tag pill (used when no class). */\n readonly tagBg?: string;\n /** Title shown next to the tag (often `data.title`). Plain text. */\n readonly title?: string;\n /** Pre-rendered HTML for the title — wins over `title` if provided. */\n readonly titleHtml?: string;\n /** Optional figure number (e.g. `FIG 1.1`). */\n readonly fignum?: string;\n /** Optional description shown under the header. */\n readonly desc?: string;\n /** Optional pre-rendered HTML rendered AFTER the inner content (e.g. footers). */\n readonly footerHtml?: string;\n}\n\n/** Wraps the given inner HTML in a `.diagram` card. */\nexport function diagramFrame(opts: FrameOptions, inner: string): string {\n const tagClass = opts.tagClass !== undefined ? ` ${opts.tagClass}` : '';\n const tagStyle =\n opts.tagBg !== undefined && opts.tagClass === undefined\n ? ` style=\"background:${opts.tagBg}\"`\n : '';\n const titleHtml =\n opts.titleHtml !== undefined\n ? `<span class=\"diagram-title\">${opts.titleHtml}</span>`\n : opts.title !== undefined && opts.title.length > 0\n ? `<span class=\"diagram-title\">${escapeHtml(opts.title)}</span>`\n : '';\n const fignumHtml =\n opts.fignum !== undefined && opts.fignum.length > 0\n ? `<span class=\"diagram-fignum\">${escapeHtml(opts.fignum)}</span>`\n : '';\n const descHtml =\n opts.desc !== undefined && opts.desc.length > 0\n ? `<p class=\"diagram-desc\">${escapeHtml(opts.desc)}</p>`\n : '';\n const footerHtml = opts.footerHtml ?? '';\n return (\n `<div class=\"diagram\">` +\n `<div class=\"diagram-head\">` +\n `<span class=\"diagram-tag${tagClass}\"${tagStyle}>${escapeHtml(opts.tag)}</span>` +\n titleHtml +\n fignumHtml +\n `</div>` +\n descHtml +\n inner +\n footerHtml +\n `</div>`\n );\n}\n\n/**\n * Per-block-type label shown in `SECTION NN · LABEL`.\n *\n * Typed as `Record<BlockType, string>` so adding a new block type without a\n * label is a compile error — the same exhaustiveness guarantee the block\n * registry gives the renderers.\n */\nexport const SECTION_LABEL: Record<BlockType, string> = {\n meta: '',\n callout: 'Note',\n table: 'Comparison',\n sequence: 'Sequence',\n erd: 'Entity model',\n userstory: 'User story',\n timeline: 'Roadmap',\n kanban: 'Board',\n tracker: 'Tracker',\n prose: 'Overview',\n glossary: 'Glossary',\n proscons: 'Trade-offs',\n cvt: 'Before / after',\n stats: 'Metrics',\n code: 'Code',\n agenda: 'Agenda',\n tree: 'Hierarchy',\n pyramid: 'Pyramid',\n funnel: 'Funnel',\n flow: 'Flowchart',\n state: 'State machine',\n dfd: 'Data flow',\n journey: 'Journey',\n gantt: 'Schedule',\n graph: 'Graph',\n quadrant: 'Matrix',\n swimlane: 'Process',\n c4: 'C4 model',\n uml: 'Class model',\n mece: 'Issue tree',\n frontend: 'Component tree',\n cluster: 'Cluster',\n block: 'Architecture',\n infra: 'Deployment',\n event: 'Events',\n ddd: 'Context map',\n network: 'Security zones',\n felogic: 'Frontend logic',\n belogic: 'Backend logic',\n dag: 'DAG',\n wireframe: 'Mockup',\n};\n","/**\n * Renders a callout block — a tonal side-bar with title + body.\n *\n * Doc-studio variant: `tone` (note/tip/warn/danger) instead of the original\n * `kind`. Defaults to `note` if omitted. Title defaults to the tone's label.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\ntype Tone = 'note' | 'tip' | 'warn' | 'danger';\n\nconst DEFAULT_TITLE: Record<Tone, string> = {\n note: 'Note',\n tip: 'Tip',\n warn: 'Warning',\n danger: 'Danger',\n};\n\nexport function renderCallout(data: BlockDataMap['callout']): string {\n const tone: Tone = data.tone ?? 'note';\n const title = data.title ?? DEFAULT_TITLE[tone];\n const body = data.body ?? '';\n return (\n `<div class=\"callout ${tone}\">` +\n `<div class=\"callout-title\">${escapeHtml(title)}</div>` +\n `<div class=\"callout-body\">${escapeHtml(body)}</div>` +\n `</div>`\n );\n}\n","import type {Edge, EdgeLabelFactory, GraphOptions, NodeLabelFactory} from './types';\n\nconst DEFAULT_EDGE_NAME = \"\\x00\";\nconst GRAPH_NODE = \"\\x00\";\nconst EDGE_KEY_DELIM = \"\\x01\";\n\n// Implementation notes:\n//\n// * Node id query functions should return string ids for the nodes\n// * Edge id query functions should return an \"edgeObj\", edge object, that is\n// composed of enough information to uniquely identify an edge: {v, w, name}.\n// * Internally we use an \"edgeId\", a stringified form of the edgeObj, to\n// reference edges. This is because we need a performant way to look these\n// edges up and, object properties, which have string keys, are the closest\n// we're going to get to a performant hashtable in JavaScript.\n\nexport class Graph<GraphLabel = any, NodeLabel = any, EdgeLabel = any> {\n private _isDirected: boolean = true;\n private _isMultigraph: boolean = false;\n private _isCompound: boolean = false;\n\n // Label for the graph itself\n private _label!: GraphLabel;\n // v -> label\n private _nodes: Record<string, NodeLabel> = {};\n // v -> edgeObj\n private _in: Record<string, Record<string, Edge>> = {};\n // u -> v -> Number\n private _preds: Record<string, Record<string, number>> = {};\n // v -> edgeObj\n private _out: Record<string, Record<string, Edge>> = {};\n // v -> w -> Number\n private _sucs: Record<string, Record<string, number>> = {};\n // e -> edgeObj\n private _edgeObjs: Record<string, Edge> = {};\n // e -> label\n private _edgeLabels: Record<string, EdgeLabel> = {};\n /* Number of nodes in the graph. Should only be changed by the implementation. */\n private _nodeCount: number = 0;\n /* Number of edges in the graph. Should only be changed by the implementation. */\n private _edgeCount: number = 0;\n private _parent?: Record<string, string>;\n private _children?: Record<string, Record<string, boolean>>;\n\n constructor(opts?: GraphOptions) {\n if (opts) {\n this._isDirected = \"directed\" in opts ? opts.directed! : true;\n this._isMultigraph = \"multigraph\" in opts ? opts.multigraph! : false;\n this._isCompound = \"compound\" in opts ? opts.compound! : false;\n }\n\n if (this._isCompound) {\n // v -> parent\n this._parent = {};\n\n // v -> children\n this._children = {};\n this._children[GRAPH_NODE] = {};\n }\n }\n\n /**\n * Whether graph was created with 'directed' flag set to true or not.\n *\n * @returns whether the graph edges have an orientation.\n */\n isDirected(): boolean {\n return this._isDirected;\n }\n\n /**\n * Whether graph was created with 'multigraph' flag set to true or not.\n *\n * @returns whether the pair of nodes of the graph can have multiple edges.\n */\n isMultigraph(): boolean {\n return this._isMultigraph;\n }\n\n /* === Graph functions ========= */\n\n /**\n * Whether graph was created with 'compound' flag set to true or not.\n *\n * @returns whether a node of the graph can have subnodes.\n */\n isCompound(): boolean {\n return this._isCompound;\n }\n\n /**\n * Sets the label of the graph.\n *\n * @param label - label value.\n * @returns the graph, allowing this to be chained with other functions.\n */\n setGraph(label: GraphLabel): this {\n this._label = label;\n return this;\n }\n\n /**\n * Gets the graph label.\n *\n * @returns currently assigned label for the graph or undefined if no label assigned.\n */\n graph(): GraphLabel {\n // TODO: This should return undefined if no label was assigned, but that would be a breaking change.\n return this._label;\n }\n\n /**\n * Sets the default node label. This label will be assigned as default label\n * in case if no label was specified while setting a node.\n * Complexity: O(1).\n *\n * @param labelOrFn - default node label or label factory function.\n * @returns the graph, allowing this to be chained with other functions.\n */\n setDefaultNodeLabel(labelOrFn: NodeLabel | NodeLabelFactory<NodeLabel>): this {\n if (typeof labelOrFn !== 'function') {\n this._defaultNodeLabelFn = () => labelOrFn;\n } else {\n this._defaultNodeLabelFn = labelOrFn as NodeLabelFactory<NodeLabel>;\n }\n\n return this;\n }\n\n /**\n * Gets the number of nodes in the graph.\n * Complexity: O(1).\n *\n * @returns nodes count.\n */\n nodeCount(): number {\n return this._nodeCount;\n }\n\n\n /* === Node functions ========== */\n\n /**\n * Gets all nodes of the graph. Note, the in case of compound graph subnodes are\n * not included in list.\n * Complexity: O(1).\n *\n * @returns list of graph nodes.\n */\n nodes(): string[] {\n return Object.keys(this._nodes);\n }\n\n /**\n * Gets list of nodes without in-edges.\n * Complexity: O(|V|).\n *\n * @returns the graph source nodes.\n */\n sources(): string[] {\n return this.nodes().filter(v => Object.keys(this._in[v]!).length === 0);\n }\n\n /**\n * Gets list of nodes without out-edges.\n * Complexity: O(|V|).\n *\n * @returns the graph sink nodes.\n */\n sinks(): string[] {\n return this.nodes().filter(v => Object.keys(this._out[v]!).length === 0);\n }\n\n /**\n * Invokes setNode method for each node in names list.\n * Complexity: O(|names|).\n *\n * @param names - list of nodes names to be set.\n * @param label - value to set for each node in list.\n * @returns the graph, allowing this to be chained with other functions.\n */\n setNodes(names: string[], label?: NodeLabel): this {\n names.forEach((v) => {\n if (label !== undefined) {\n this.setNode(v, label);\n } else {\n this.setNode(v);\n }\n });\n return this;\n }\n\n /**\n * Creates or updates the value for the node v in the graph. If label is supplied\n * it is set as the value for the node. If label is not supplied and the node was\n * created by this call then the default node label will be assigned.\n * Complexity: O(1).\n *\n * @param name - node name.\n * @param label - value to set for node.\n * @returns the graph, allowing this to be chained with other functions.\n */\n setNode(name: string, label?: NodeLabel): this {\n if (name in this._nodes) {\n if (arguments.length > 1) {\n this._nodes[name] = label!;\n }\n return this;\n }\n\n this._nodes[name] = arguments.length > 1 ? label! : this._defaultNodeLabelFn(name);\n if (this._isCompound) {\n this._parent![name] = GRAPH_NODE;\n this._children![name] = {};\n this._children![GRAPH_NODE]![name] = true;\n }\n this._in[name] = {};\n this._preds[name] = {};\n this._out[name] = {};\n this._sucs[name] = {};\n ++this._nodeCount;\n return this;\n }\n\n /**\n * Gets the label of node with specified name.\n * Complexity: O(|V|).\n *\n * @param name - node name.\n * @returns label value of the node.\n */\n node(name: string): NodeLabel {\n // TODO: This should return undefined if the node doesn't exist, but that would be a breaking change.\n return this._nodes[name]!;\n }\n\n /**\n * Detects whether graph has a node with specified name or not.\n *\n * @param name - name of the node.\n * @returns true if graph has node with specified name, false - otherwise.\n */\n hasNode(name: string): boolean {\n return name in this._nodes;\n }\n\n /**\n * Remove the node with the name from the graph or do nothing if the node is not in\n * the graph. If the node was removed this function also removes any incident\n * edges.\n * Complexity: O(1).\n *\n * @param name - name of the node.\n * @returns the graph, allowing this to be chained with other functions.\n */\n removeNode(name: string): this {\n if (name in this._nodes) {\n const removeEdge = (e: string) => this.removeEdge(this._edgeObjs[e]!);\n delete this._nodes[name];\n if (this._isCompound) {\n this._removeFromParentsChildList(name);\n delete this._parent![name];\n this.children(name).forEach((child) => {\n this.setParent(child);\n });\n delete this._children![name];\n }\n Object.keys(this._in[name]!).forEach(removeEdge);\n delete this._in[name];\n delete this._preds[name];\n Object.keys(this._out[name]!).forEach(removeEdge);\n delete this._out[name];\n delete this._sucs[name];\n --this._nodeCount;\n }\n return this;\n }\n\n /**\n * Sets node parent for node v if it is defined, or removes the\n * parent for v if p is undefined. Method throws an exception in case of\n * invoking it in context of noncompound graph.\n * Average-case complexity: O(1).\n *\n * @param v - node to be child for p.\n * @param parent - node to be parent for v.\n * @returns the graph, allowing this to be chained with other functions.\n */\n setParent(v: string, parent?: string): this {\n if (!this._isCompound) {\n throw new Error(\"Cannot set parent in a non-compound graph\");\n }\n\n if (parent === undefined) {\n parent = GRAPH_NODE;\n } else {\n // Coerce parent to string\n parent += \"\";\n for (let ancestor: string | undefined | void = parent; ancestor !== undefined; ancestor = this.parent(ancestor)) {\n if (ancestor === v) {\n throw new Error(\"Setting \" + parent + \" as parent of \" + v +\n \" would create a cycle\");\n }\n }\n\n this.setNode(parent);\n }\n\n this.setNode(v);\n this._removeFromParentsChildList(v);\n this._parent![v] = parent;\n this._children![parent]![v] = true;\n return this;\n }\n\n /**\n * Gets parent node for node v.\n * Complexity: O(1).\n *\n * @param v - node to get parent of.\n * @returns parent node name or void if v has no parent.\n */\n parent(v: string): string | void {\n if (this._isCompound) {\n const parent = this._parent![v];\n if (parent !== GRAPH_NODE) {\n return parent;\n }\n }\n }\n\n /**\n * Gets list of direct children of node v.\n * Complexity: O(1).\n *\n * @param v - node to get children of.\n * @returns children nodes names list.\n */\n children(v: string = GRAPH_NODE): string[] {\n if (this._isCompound) {\n const children = this._children![v];\n if (children) {\n return Object.keys(children);\n }\n } else if (v === GRAPH_NODE) {\n return this.nodes();\n } else if (this.hasNode(v)) {\n return [];\n }\n return [];\n }\n\n /**\n * Return all nodes that are predecessors of the specified node or undefined if node v is not in\n * the graph. Behavior is undefined for undirected graphs - use neighbors instead.\n * Complexity: O(|V|).\n *\n * @param v - node identifier.\n * @returns node identifiers list or undefined if v is not in the graph.\n */\n predecessors(v: string): void | string[] {\n const predsV = this._preds[v];\n if (predsV) {\n return Object.keys(predsV);\n }\n }\n\n /**\n * Return all nodes that are successors of the specified node or undefined if node v is not in\n * the graph. Behavior is undefined for undirected graphs - use neighbors instead.\n * Complexity: O(|V|).\n *\n * @param v - node identifier.\n * @returns node identifiers list or undefined if v is not in the graph.\n */\n successors(v: string): void | string[] {\n const sucsV = this._sucs[v];\n if (sucsV) {\n return Object.keys(sucsV);\n }\n }\n\n /**\n * Return all nodes that are predecessors or successors of the specified node or undefined if\n * node v is not in the graph.\n * Complexity: O(|V|).\n *\n * @param v - node identifier.\n * @returns node identifiers list or undefined if v is not in the graph.\n */\n neighbors(v: string): void | string[] {\n const preds = this.predecessors(v);\n if (preds) {\n const union = new Set(preds);\n for (const succ of this.successors(v)!) {\n union.add(succ);\n }\n\n return Array.from(union.values());\n }\n }\n\n isLeaf(v: string): boolean {\n let neighbors: string[] | void;\n if (this.isDirected()) {\n neighbors = this.successors(v);\n } else {\n neighbors = this.neighbors(v);\n }\n return neighbors!.length === 0;\n }\n\n /**\n * Creates new graph with nodes filtered via filter. Edges incident to rejected node\n * are also removed. In case of compound graph, if parent is rejected by filter,\n * than all its children are rejected too.\n * Average-case complexity: O(|E|+|V|).\n *\n * @param filter - filtration function detecting whether the node should stay or not.\n * @returns new graph made from current and nodes filtered.\n */\n filterNodes(filter: (v: string) => boolean): this {\n const copy = new (this.constructor as typeof Graph<GraphLabel, NodeLabel, EdgeLabel>)({\n directed: this._isDirected,\n multigraph: this._isMultigraph,\n compound: this._isCompound\n });\n\n copy.setGraph(this.graph()!);\n\n Object.entries(this._nodes).forEach(([v, value]) => {\n if (filter(v)) {\n copy.setNode(v, value);\n }\n });\n\n Object.values(this._edgeObjs).forEach((e) => {\n if (copy.hasNode(e.v) && copy.hasNode(e.w)) {\n copy.setEdge(e, this.edge(e));\n }\n });\n\n const parents: Record<string, string | undefined> = {};\n const findParent = (v: string): string | undefined => {\n const parent = this.parent(v);\n if (!parent || copy.hasNode(parent)) {\n parents[v] = parent ?? undefined;\n return parent ?? undefined;\n } else if (parent in parents) {\n return parents[parent];\n } else {\n return findParent(parent);\n }\n };\n\n if (this._isCompound) {\n copy.nodes().forEach(v => copy.setParent(v, findParent(v)));\n }\n\n return copy as this;\n }\n\n /**\n * Sets the default edge label. This label will be assigned as default label\n * in case if no label was specified while setting an edge.\n * Complexity: O(1).\n *\n * @param labelOrFn - default edge label or label factory function.\n * @returns the graph, allowing this to be chained with other functions.\n */\n setDefaultEdgeLabel(labelOrFn: EdgeLabel | EdgeLabelFactory<EdgeLabel>): this {\n if (typeof labelOrFn !== 'function') {\n this._defaultEdgeLabelFn = () => labelOrFn;\n } else {\n this._defaultEdgeLabelFn = labelOrFn as EdgeLabelFactory<EdgeLabel>;\n }\n\n return this;\n }\n\n /**\n * Gets the number of edges in the graph.\n * Complexity: O(1).\n *\n * @returns edges count.\n */\n edgeCount(): number {\n return this._edgeCount;\n }\n\n /**\n * Gets edges of the graph. In case of compound graph subgraphs are not considered.\n * Complexity: O(|E|).\n *\n * @returns graph edges list.\n */\n edges(): Edge[] {\n return Object.values(this._edgeObjs);\n }\n\n /* === Edge functions ========== */\n\n /**\n * Establish an edges path over the nodes in nodes list. If some edge is already\n * exists, it will update its label, otherwise it will create an edge between pair\n * of nodes with label provided or default label if no label provided.\n * Complexity: O(|nodes|).\n *\n * @param nodes - list of nodes to be connected in series.\n * @param label - value to set for each edge between pairs of nodes.\n * @returns the graph, allowing this to be chained with other functions.\n */\n setPath(nodes: string[], label?: EdgeLabel): this {\n nodes.reduce((v, w) => {\n if (label !== undefined) {\n this.setEdge(v, w, label);\n } else {\n this.setEdge(v, w);\n }\n return w;\n });\n return this;\n }\n\n /**\n * Creates or updates the label for the edge (v, w) with the optionally supplied\n * name. If label is supplied it is set as the value for the edge. If label is not\n * supplied and the edge was created by this call then the default edge label will\n * be assigned. The name parameter is only useful with multigraphs.\n * Complexity: O(1).\n *\n * @param v - edge source node.\n * @param w - edge sink node.\n * @param label - value to associate with the edge.\n * @param name - unique name of the edge in order to identify it in multigraph.\n * @returns the graph, allowing this to be chained with other functions.\n */\n setEdge(v: string, w: string, label?: EdgeLabel, name?: string): this;\n\n /**\n * Creates or updates the label for the specified edge. If label is supplied it is\n * set as the value for the edge. If label is not supplied and the edge was created\n * by this call then the default edge label will be assigned. The name parameter is\n * only useful with multigraphs.\n * Complexity: O(1).\n *\n * @param edge - edge descriptor.\n * @param label - value to associate with the edge.\n * @returns the graph, allowing this to be chained with other functions.\n */\n setEdge(edge: Edge, label?: EdgeLabel): this;\n\n setEdge(v: string | Edge, w?: string | EdgeLabel, value?: EdgeLabel, name?: string): this {\n let vStr: string;\n let wStr: string;\n let nameStr: string | undefined;\n let edgeValue: EdgeLabel | undefined;\n let valueSpecified = false;\n\n if (typeof v === \"object\" && v !== null && \"v\" in v) {\n vStr = v.v;\n wStr = v.w;\n nameStr = v.name;\n if (arguments.length === 2) {\n edgeValue = w as EdgeLabel;\n valueSpecified = true;\n }\n } else {\n vStr = v;\n wStr = w as string;\n nameStr = name;\n if (arguments.length > 2) {\n edgeValue = value;\n valueSpecified = true;\n }\n }\n\n vStr = \"\" + vStr;\n wStr = \"\" + wStr;\n if (nameStr !== undefined) {\n nameStr = \"\" + nameStr;\n }\n\n const e = edgeArgsToId(this._isDirected, vStr, wStr, nameStr);\n if (e in this._edgeLabels) {\n if (valueSpecified) {\n this._edgeLabels[e] = edgeValue!;\n }\n return this;\n }\n\n if (nameStr !== undefined && !this._isMultigraph) {\n throw new Error(\"Cannot set a named edge when isMultigraph = false\");\n }\n\n // It didn't exist, so we need to create it.\n // First ensure the nodes exist.\n this.setNode(vStr);\n this.setNode(wStr);\n\n this._edgeLabels[e] = valueSpecified ? edgeValue! : this._defaultEdgeLabelFn(vStr, wStr, nameStr);\n\n // Ensure we add undirected edges in a consistent way.\n const edgeObj = edgeArgsToObj(this._isDirected, vStr, wStr, nameStr);\n\n vStr = edgeObj.v;\n wStr = edgeObj.w;\n\n Object.freeze(edgeObj);\n this._edgeObjs[e] = edgeObj;\n incrementOrInitEntry(this._preds[wStr]!, vStr);\n incrementOrInitEntry(this._sucs[vStr]!, wStr);\n this._in[wStr]![e] = edgeObj;\n this._out[vStr]![e] = edgeObj;\n this._edgeCount++;\n return this;\n }\n\n /**\n * Gets the label for the specified edge.\n * Complexity: O(1).\n *\n * @param v - edge source node.\n * @param w - edge sink node.\n * @param name - name of the edge (actual for multigraph).\n * @returns value associated with specified edge.\n */\n edge(v: string, w: string, name?: string): EdgeLabel;\n\n /**\n * Gets the label for the specified edge.\n * Complexity: O(1).\n *\n * @param edge - edge descriptor.\n * @returns value associated with specified edge.\n */\n edge(edge: Edge): EdgeLabel;\n\n edge(v: string | Edge, w?: string, name?: string): EdgeLabel {\n // TODO: This should return undefined if the edge doesn't exist, but that would be a breaking change.\n const e = (arguments.length === 1\n ? edgeObjToId(this._isDirected, v as Edge)\n : edgeArgsToId(this._isDirected, v as string, w!, name));\n return this._edgeLabels[e]!;\n }\n\n /**\n * Gets the label for the specified edge and converts it to an object.\n * Complexity: O(1).\n *\n * @param v - edge source node.\n * @param w - edge sink node.\n * @param name - name of the edge (actual for multigraph).\n * @returns value associated with specified edge.\n */\n edgeAsObj(v: string, w: string, name?: string): { label: EdgeLabel };\n\n /**\n * Gets the label for the specified edge and converts it to an object.\n * Complexity: O(1).\n *\n * @param edge - edge descriptor.\n * @returns value associated with specified edge.\n */\n edgeAsObj(edge: Edge): { label: EdgeLabel };\n\n edgeAsObj(v: string | Edge, w?: string, name?: string): { label: EdgeLabel } {\n const edgeLabel = arguments.length === 1\n ? this.edge(v as Edge)\n : this.edge(v as string, w!, name);\n\n if (typeof edgeLabel !== \"object\") {\n return {label: edgeLabel as EdgeLabel};\n }\n\n return edgeLabel as { label: EdgeLabel };\n }\n\n /**\n * Detects whether the graph contains specified edge or not. No subgraphs are considered.\n * Complexity: O(1).\n *\n * @param v - edge source node.\n * @param w - edge sink node.\n * @param name - name of the edge (actual for multigraph).\n * @returns whether the graph contains the specified edge or not.\n */\n hasEdge(v: string, w: string, name?: string): boolean;\n\n /**\n * Detects whether the graph contains specified edge or not. No subgraphs are considered.\n * Complexity: O(1).\n *\n * @param edge - edge descriptor.\n * @returns whether the graph contains the specified edge or not.\n */\n hasEdge(edge: Edge): boolean;\n\n hasEdge(v: string | Edge, w?: string, name?: string): boolean {\n const e = (arguments.length === 1\n ? edgeObjToId(this._isDirected, v as Edge)\n : edgeArgsToId(this._isDirected, v as string, w!, name));\n return e in this._edgeLabels;\n }\n\n /**\n * Removes the specified edge from the graph. No subgraphs are considered.\n * Complexity: O(1).\n *\n * @param v - edge source node.\n * @param w - edge sink node.\n * @param name - name of the edge (actual for multigraph).\n * @returns the graph, allowing this to be chained with other functions.\n */\n removeEdge(v: string, w: string, name?: string): this;\n\n /**\n * Removes the specified edge from the graph. No subgraphs are considered.\n * Complexity: O(1).\n *\n * @param edge - edge descriptor.\n * @returns the graph, allowing this to be chained with other functions.\n */\n removeEdge(edge: Edge): this;\n\n removeEdge(v: string | Edge, w?: string, name?: string): this {\n const e = (arguments.length === 1\n ? edgeObjToId(this._isDirected, v as Edge)\n : edgeArgsToId(this._isDirected, v as string, w!, name));\n const edge = this._edgeObjs[e];\n if (edge) {\n const vStr = edge.v;\n const wStr = edge.w;\n delete this._edgeLabels[e];\n delete this._edgeObjs[e];\n decrementOrRemoveEntry(this._preds[wStr]!, vStr);\n decrementOrRemoveEntry(this._sucs[vStr]!, wStr);\n delete this._in[wStr]![e];\n delete this._out[vStr]![e];\n this._edgeCount--;\n }\n return this;\n }\n\n /**\n * Return all edges that point to the node v. Optionally filters those edges down to just those\n * coming from node u. Behavior is void for undirected graphs - use nodeEdges instead.\n * Complexity: O(|E|).\n *\n * @param v - edge sink node.\n * @param w - edge source node.\n * @returns edges descriptors list if v is in the graph, or void otherwise.\n */\n inEdges(v: string, w?: string): void | Edge[] {\n if (this.isDirected()) {\n return this.filterEdges(this._in[v], v, w);\n }\n return this.nodeEdges(v, w);\n }\n\n /**\n * Return all edges that are pointed at by node v. Optionally filters those edges down to just\n * those point to w. Behavior is void for undirected graphs - use nodeEdges instead.\n * Complexity: O(|E|).\n *\n * @param v - edge source node.\n * @param w - edge sink node.\n * @returns edges descriptors list if v is in the graph, or void otherwise.\n */\n outEdges(v: string, w?: string): void | Edge[] {\n if (this.isDirected()) {\n return this.filterEdges(this._out[v], v, w);\n }\n return this.nodeEdges(v, w);\n }\n\n /**\n * Returns all edges to or from node v regardless of direction. Optionally filters those edges\n * down to just those between nodes v and w regardless of direction.\n * Complexity: O(|E|).\n *\n * @param v - edge adjacent node.\n * @param w - edge adjacent node.\n * @returns edges descriptors list if v is in the graph, or void otherwise.\n */\n nodeEdges(v: string, w?: string): void | Edge[] {\n if (v in this._nodes) {\n return this.filterEdges({...this._in[v]!, ...this._out[v]!}, v, w);\n }\n }\n\n // Defaults to be set when creating a new node\n private _defaultNodeLabelFn: NodeLabelFactory<NodeLabel> = () => undefined as NodeLabel;\n\n // Defaults to be set when creating a new edge\n private _defaultEdgeLabelFn: EdgeLabelFactory<EdgeLabel> = () => undefined as EdgeLabel;\n\n private _removeFromParentsChildList(v: string): void {\n delete this._children![this._parent![v]!]![v];\n }\n\n private filterEdges(setV: Record<string, Edge> | undefined, localEdge: string, remoteEdge?: string): Edge[] | undefined {\n if (!setV) {\n return;\n }\n const edges = Object.values(setV);\n if (!remoteEdge) {\n return edges;\n }\n return edges.filter((edge) => {\n return edge.v === localEdge && edge.w === remoteEdge\n || edge.v === remoteEdge && edge.w === localEdge;\n });\n }\n}\n\n\nfunction incrementOrInitEntry(map: Record<string, number>, k: string): void {\n if (map[k]) {\n map[k]++;\n } else {\n map[k] = 1;\n }\n}\n\nfunction decrementOrRemoveEntry(map: Record<string, number>, k: string): void {\n if (map[k] !== undefined && !--map[k]) {\n delete map[k];\n }\n}\n\nfunction edgeArgsToId(isDirected: boolean, v_: string, w_: string, name?: string): string {\n let v = \"\" + v_;\n let w = \"\" + w_;\n if (!isDirected && v > w) {\n const tmp = v;\n v = w;\n w = tmp;\n }\n return v + EDGE_KEY_DELIM + w + EDGE_KEY_DELIM +\n (name === undefined ? DEFAULT_EDGE_NAME : name);\n}\n\nfunction edgeArgsToObj(isDirected: boolean, v_: string, w_: string, name?: string): Edge {\n let v = \"\" + v_;\n let w = \"\" + w_;\n if (!isDirected && v > w) {\n const tmp = v;\n v = w;\n w = tmp;\n }\n const edgeObj: Edge = {v: v, w: w};\n if (name) {\n edgeObj.name = name;\n }\n return edgeObj;\n}\n\nfunction edgeObjToId(isDirected: boolean, edgeObj: Edge): string {\n return edgeArgsToId(isDirected, edgeObj.v, edgeObj.w, edgeObj.name);\n}\n","export const version = '4.0.1';\n","import {Graph} from './graph';\nimport type {GraphOptions} from './types';\n\ninterface JsonGraph {\n options: GraphOptions;\n nodes: JsonNode[];\n edges: JsonEdge[];\n value?: unknown;\n}\n\ninterface JsonNode {\n v: string;\n value?: unknown;\n parent?: string;\n}\n\ninterface JsonEdge {\n v: string;\n w: string;\n name?: string;\n value?: unknown;\n}\n\n/**\n * Creates a JSON representation of the graph that can be serialized to a string with\n * JSON.stringify. The graph can later be restored using json.read.\n *\n * @param graph - target to create JSON representation of.\n * @returns JSON serializable graph representation\n */\nexport function write(graph: Graph): JsonGraph {\n const json: JsonGraph = {\n options: {\n directed: graph.isDirected(),\n multigraph: graph.isMultigraph(),\n compound: graph.isCompound()\n },\n nodes: writeNodes(graph),\n edges: writeEdges(graph)\n };\n\n const graphLabel = graph.graph();\n if (graphLabel !== undefined) {\n json.value = structuredClone(graphLabel);\n }\n\n return json;\n}\n\nfunction writeNodes(g: Graph): JsonNode[] {\n return g.nodes().map(v => {\n const nodeValue = g.node(v);\n const parent = g.parent(v);\n const node: JsonNode = {v};\n\n if (nodeValue !== undefined) {\n node.value = nodeValue;\n }\n if (parent !== undefined) {\n node.parent = parent;\n }\n\n return node;\n });\n}\n\nfunction writeEdges(g: Graph): JsonEdge[] {\n return g.edges().map(e => {\n const edgeValue = g.edge(e);\n const edge: JsonEdge = {v: e.v, w: e.w};\n\n if (e.name !== undefined) {\n edge.name = e.name;\n }\n if (edgeValue !== undefined) {\n edge.value = edgeValue;\n }\n\n return edge;\n });\n}\n\n/**\n * Takes JSON as input and returns the graph representation.\n *\n * @param json - JSON serializable graph representation\n * @returns graph constructed according to specified representation\n *\n * @example\n * var g2 = graphlib.json.read(JSON.parse(str));\n * g2.nodes();\n * // ['a', 'b']\n * g2.edges()\n * // [ { v: 'a', w: 'b' } ]\n */\nexport function read<GraphLabel = any, NodeLabel = any, EdgeLabel = any>(\n json: JsonGraph\n): Graph<GraphLabel, NodeLabel, EdgeLabel> {\n const g = new Graph<GraphLabel, NodeLabel, EdgeLabel>(json.options);\n\n if (json.value !== undefined) {\n g.setGraph(json.value as GraphLabel);\n }\n\n json.nodes.forEach(entry => {\n g.setNode(entry.v, entry.value as NodeLabel);\n if (entry.parent) {\n g.setParent(entry.v, entry.parent);\n }\n });\n\n json.edges.forEach(entry => {\n g.setEdge({v: entry.v, w: entry.w, name: entry.name}, entry.value as EdgeLabel);\n });\n\n return g;\n}\n","export {bellmanFord} from './bellman-ford';\nexport {components} from './components';\nexport {dijkstra} from './dijkstra';\nexport {dijkstraAll} from './dijkstra-all';\nexport {findCycles} from './find-cycles';\nexport {floydWarshall} from './floyd-warshall';\nexport {isAcyclic} from './is-acyclic';\nexport {postorder} from './postorder';\nexport {preorder} from './preorder';\nexport {prim} from './prim';\nexport {shortestPaths} from './shortest-paths';\nexport {tarjan} from './tarjan';\nexport {topsort, CycleException} from './topsort';\n","import {Graph} from '../graph';\nimport type {Edge, EdgeFunction, Path, WeightFunction} from '../types';\n\nconst DEFAULT_WEIGHT_FUNC: WeightFunction = () => 1;\n\nexport function bellmanFord(\n g: Graph,\n source: string,\n weightFn?: WeightFunction,\n edgeFn?: EdgeFunction\n): Record<string, Path> {\n return runBellmanFord(\n g,\n String(source),\n weightFn || DEFAULT_WEIGHT_FUNC,\n edgeFn || function (v) {\n return g.outEdges(v)!;\n }\n );\n}\n\nfunction runBellmanFord(\n g: Graph,\n source: string,\n weightFn: WeightFunction,\n edgeFn: EdgeFunction\n): Record<string, Path> {\n const results: Record<string, Path> = {};\n let didADistanceUpgrade: boolean;\n let iterations = 0;\n const nodes = g.nodes();\n\n const relaxEdge = function (edge: Edge): void {\n const edgeWeight = weightFn(edge);\n if (results[edge.v]!.distance + edgeWeight < results[edge.w]!.distance) {\n results[edge.w] = {\n distance: results[edge.v]!.distance + edgeWeight,\n predecessor: edge.v\n };\n didADistanceUpgrade = true;\n }\n };\n\n const relaxAllEdges = function (): void {\n nodes.forEach(function (vertex) {\n edgeFn(vertex).forEach(function (edge) {\n // If the vertex on which the edgeFun in called is\n // the edge.w, then we treat the edge as if it was reversed\n const inVertex = edge.v === vertex ? edge.v : edge.w;\n const outVertex = inVertex === edge.v ? edge.w : edge.v;\n relaxEdge({v: inVertex, w: outVertex});\n });\n });\n };\n\n // Initialization\n nodes.forEach(function (v) {\n const distance = v === source ? 0 : Number.POSITIVE_INFINITY;\n results[v] = {distance: distance, predecessor: ''};\n });\n\n const numberOfNodes = nodes.length;\n\n // Relax all edges in |V|-1 iterations\n for (let i = 1; i < numberOfNodes; i++) {\n didADistanceUpgrade = false;\n iterations++;\n relaxAllEdges();\n if (!didADistanceUpgrade) {\n // Ιf no update was made in an iteration, Bellman-Ford has finished\n break;\n }\n }\n\n // Detect if the graph contains a negative weight cycle\n if (iterations === numberOfNodes - 1) {\n didADistanceUpgrade = false;\n relaxAllEdges();\n if (didADistanceUpgrade) {\n throw new Error(\"The graph contains a negative weight cycle\");\n }\n }\n\n return results;\n}\n","import {Graph} from '../graph';\n\n/**\n * Finds all connected components in a graph and returns an array of these components.\n * Each component is itself an array that contains the ids of nodes in the component.\n * Complexity: O(|V|).\n *\n * @param graph - graph to find components in.\n * @returns array of nodes list representing components\n */\nexport function components(graph: Graph): string[][] {\n const visited: Record<string, boolean> = {};\n const cmpts: string[][] = [];\n let cmpt: string[];\n\n function dfs(v: string): void {\n if (v in visited) return;\n visited[v] = true;\n cmpt.push(v);\n graph.successors(v)!.forEach(dfs);\n graph.predecessors(v)!.forEach(dfs);\n }\n\n graph.nodes().forEach(function (v) {\n cmpt = [];\n dfs(v);\n if (cmpt.length) {\n cmpts.push(cmpt);\n }\n });\n\n return cmpts;\n}\n","/**\n * A min-priority queue data structure. This algorithm is derived from Cormen,\n * et al., \"Introduction to Algorithms\". The basic idea of a min-priority\n * queue is that you can efficiently (in O(1) time) get the smallest key in\n * the queue. Adding and removing elements takes O(log n) time. A key can\n * have its priority decreased in O(log n) time.\n */\n\ninterface PriorityQueueEntry {\n key: string;\n priority: number;\n}\n\nexport class PriorityQueue {\n private _arr: PriorityQueueEntry[] = [];\n private _keyIndices: Record<string, number> = {};\n\n /**\n * Returns the number of elements in the queue. Takes `O(1)` time.\n */\n size(): number {\n return this._arr.length;\n }\n\n /**\n * Returns the keys that are in the queue. Takes `O(n)` time.\n */\n keys(): string[] {\n return this._arr.map(x => x.key);\n }\n\n /**\n * Returns `true` if **key** is in the queue and `false` if not.\n */\n has(key: string): boolean {\n return key in this._keyIndices;\n }\n\n /**\n * Returns the priority for **key**. If **key** is not present in the queue\n * then this function returns `undefined`. Takes `O(1)` time.\n */\n priority(key: string): number | undefined {\n const index = this._keyIndices[key];\n if (index !== undefined) {\n return this._arr[index]!.priority;\n }\n return undefined;\n }\n\n /**\n * Returns the key for the minimum element in this queue. If the queue is\n * empty this function throws an Error. Takes `O(1)` time.\n */\n min(): string {\n if (this.size() === 0) {\n throw new Error(\"Queue underflow\");\n }\n return this._arr[0]!.key;\n }\n\n /**\n * Inserts a new key into the priority queue. If the key already exists in\n * the queue this function returns `false`; otherwise it will return `true`.\n * Takes `O(n)` time.\n */\n add(key: string, priority: number): boolean {\n const keyIndices = this._keyIndices;\n const keyStr = String(key);\n\n if (!(keyStr in keyIndices)) {\n const arr = this._arr;\n const index = arr.length;\n keyIndices[keyStr] = index;\n arr.push({key: keyStr, priority});\n this._decrease(index);\n return true;\n }\n return false;\n }\n\n /**\n * Removes and returns the smallest key in the queue. Takes `O(log n)` time.\n */\n removeMin(): string {\n this._swap(0, this._arr.length - 1);\n const min = this._arr.pop()!;\n delete this._keyIndices[min.key];\n this._heapify(0);\n return min.key;\n }\n\n /**\n * Decreases the priority for **key** to **priority**. If the new priority is\n * greater than the previous priority, this function will throw an Error.\n */\n decrease(key: string, priority: number): void {\n const index = this._keyIndices[key];\n if (index === undefined) {\n throw new Error(`Key not found: ${key}`);\n }\n\n const currentPriority = this._arr[index]!.priority;\n if (priority > currentPriority) {\n throw new Error(\n `New priority is greater than current priority. Key: ${key} Old: ${currentPriority} New: ${priority}`\n );\n }\n this._arr[index]!.priority = priority;\n this._decrease(index);\n }\n\n private _heapify(i: number): void {\n const arr = this._arr;\n const l = 2 * i;\n const r = l + 1;\n let largest = i;\n\n if (l < arr.length) {\n largest = arr[l]!.priority < arr[largest]!.priority ? l : largest;\n if (r < arr.length) {\n largest = arr[r]!.priority < arr[largest]!.priority ? r : largest;\n }\n if (largest !== i) {\n this._swap(i, largest);\n this._heapify(largest);\n }\n }\n }\n\n private _decrease(index: number): void {\n const arr = this._arr;\n const priority = arr[index]!.priority;\n let parent: number;\n\n while (index !== 0) {\n parent = index >> 1;\n if (arr[parent]!.priority < priority) {\n break;\n }\n this._swap(index, parent);\n index = parent;\n }\n }\n\n private _swap(i: number, j: number): void {\n const arr = this._arr;\n const keyIndices = this._keyIndices;\n const origArrI = arr[i]!;\n const origArrJ = arr[j]!;\n\n arr[i] = origArrJ;\n arr[j] = origArrI;\n keyIndices[origArrJ.key] = i;\n keyIndices[origArrI.key] = j;\n }\n}\n","import {Graph} from '../graph';\nimport {PriorityQueue} from '../data/priority-queue';\nimport type {Edge, EdgeFunction, Path, WeightFunction} from '../types';\n\nconst DEFAULT_WEIGHT_FUNC: WeightFunction = () => 1;\n\n/**\n * This function is an implementation of Dijkstra's algorithm which finds the shortest\n * path from source to all other nodes in graph. This function returns a map of\n * v -> { distance, predecessor }. The distance property holds the sum of the weights\n * from source to v along the shortest path or Number.POSITIVE_INFINITY if there is no path\n * from source. The predecessor property can be used to walk the individual elements of the\n * path from source to v in reverse order.\n * Complexity: O((|E| + |V|) * log |V|).\n *\n * @param graph - graph where to search paths.\n * @param source - node to start paths from.\n * @param weightFn - function which takes edge e and returns the weight of it. If no weightFn\n * is supplied then each edge is assumed to have a weight of 1. This function throws an\n * Error if any of the traversed edges have a negative edge weight.\n * @param edgeFn - function which takes a node v and returns the ids of all edges incident to it\n * for the purposes of shortest path traversal. By default this function uses the graph.outEdges.\n * @returns shortest paths map that starts from node source\n */\nexport function dijkstra(\n graph: Graph,\n source: string,\n weightFn?: WeightFunction,\n edgeFn?: EdgeFunction\n): Record<string, Path> {\n const defaultEdgeFn: EdgeFunction = function (v) {\n return graph.outEdges(v)!;\n };\n\n return runDijkstra(graph, String(source),\n weightFn || DEFAULT_WEIGHT_FUNC,\n edgeFn || defaultEdgeFn);\n}\n\nfunction runDijkstra(\n graph: Graph,\n source: string,\n weightFn: WeightFunction,\n edgeFn: EdgeFunction\n): Record<string, Path> {\n const results: Record<string, Path> = {};\n const pq = new PriorityQueue();\n let v: string, vEntry: Path;\n\n const updateNeighbors = function (edge: Edge): void {\n const w = edge.v !== v ? edge.v : edge.w;\n const wEntry = results[w]!;\n const weight = weightFn(edge);\n const distance = vEntry.distance + weight;\n\n if (weight < 0) {\n throw new Error(\"dijkstra does not allow negative edge weights. \" +\n \"Bad edge: \" + edge + \" Weight: \" + weight);\n }\n\n if (distance < wEntry.distance) {\n wEntry.distance = distance;\n wEntry.predecessor = v;\n pq.decrease(w, distance);\n }\n };\n\n graph.nodes().forEach(function (v) {\n const distance = v === source ? 0 : Number.POSITIVE_INFINITY;\n results[v] = {distance: distance, predecessor: ''};\n pq.add(v, distance);\n });\n\n while (pq.size() > 0) {\n v = pq.removeMin()!;\n vEntry = results[v]!;\n if (vEntry.distance === Number.POSITIVE_INFINITY) {\n break;\n }\n\n edgeFn(v).forEach(updateNeighbors);\n }\n\n return results;\n}\n","import {Graph} from '../graph';\nimport type {EdgeFunction, Path, WeightFunction} from '../types';\nimport {dijkstra} from './dijkstra';\n\n/**\n * This function finds the shortest path from each node to every other reachable node in\n * the graph. It is similar to alg.dijkstra, but instead of returning a single-source\n * array, it returns a mapping of source -> alg.dijkstra(g, source, weightFn, edgeFn).\n * Complexity: O(|V| * (|E| + |V|) * log |V|).\n *\n * @param graph - graph where to search paths.\n * @param weightFn - function which takes edge e and returns the weight of it. If no weightFn\n * is supplied then each edge is assumed to have a weight of 1. This function throws an\n * Error if any of the traversed edges have a negative edge weight.\n * @param edgeFn - function which takes a node v and returns the ids of all edges incident to it\n * for the purposes of shortest path traversal. By default this function uses the graph.outEdges.\n * @returns shortest paths map.\n */\nexport function dijkstraAll(\n graph: Graph,\n weightFn?: WeightFunction,\n edgeFn?: EdgeFunction\n): Record<string, Record<string, Path>> {\n return graph.nodes().reduce(function (acc, v) {\n acc[v] = dijkstra(graph, v, weightFn, edgeFn);\n return acc;\n }, {} as Record<string, Record<string, Path>>);\n}\n","import {Graph} from '../graph';\n\ninterface VisitedEntry {\n onStack: boolean;\n lowlink: number;\n index: number;\n}\n\n/**\n * This function is an implementation of Tarjan's algorithm which finds all strongly connected\n * components in the directed graph g. Each strongly connected component is composed of nodes that\n * can reach all other nodes in the component via directed edges. A strongly connected component\n * can consist of a single node if that node cannot both reach and be reached by any other\n * specific node in the graph. Components of more than one node are guaranteed to have at least\n * one cycle.\n * Complexity: O(|V| + |E|).\n *\n * @param graph - graph to find all strongly connected components of.\n * @returns an array of components. Each component is itself an array that contains\n * the ids of all nodes in the component.\n */\nexport function tarjan(graph: Graph): string[][] {\n let index = 0;\n const stack: string[] = [];\n const visited: Record<string, VisitedEntry> = {}; // node id -> { onStack, lowlink, index }\n const results: string[][] = [];\n\n function dfs(v: string): void {\n const entry = visited[v] = {\n onStack: true,\n lowlink: index,\n index: index++\n };\n stack.push(v);\n\n graph.successors(v)!.forEach(function (w) {\n if (!(w in visited)) {\n dfs(w);\n entry.lowlink = Math.min(entry.lowlink, visited[w]!.lowlink);\n } else if (visited[w]!.onStack) {\n entry.lowlink = Math.min(entry.lowlink, visited[w]!.index);\n }\n });\n\n if (entry.lowlink === entry.index) {\n const cmpt: string[] = [];\n let w: string;\n do {\n w = stack.pop()!;\n visited[w]!.onStack = false;\n cmpt.push(w);\n } while (v !== w);\n results.push(cmpt);\n }\n }\n\n graph.nodes().forEach(function (v) {\n if (!(v in visited)) {\n dfs(v);\n }\n });\n\n return results;\n}\n","import {Graph} from '../graph';\nimport {tarjan} from './tarjan';\n\n/**\n * Given a Graph, graph, this function returns all nodes that are part of a cycle. As there\n * may be more than one cycle in a graph this function return an array of these cycles,\n * where each cycle is itself represented by an array of ids for each node involved in\n * that cycle. Method alg.isAcyclic is more efficient if you only need to determine whether a graph has a\n * cycle or not.\n * Complexity: O(|V| + |E|).\n *\n * @param graph - graph where to search cycles.\n * @returns cycles list.\n */\nexport function findCycles(graph: Graph): string[][] {\n return tarjan(graph).filter(function (cmpt) {\n return cmpt.length > 1 || (cmpt.length === 1 && graph.hasEdge(cmpt[0]!, cmpt[0]!));\n });\n}\n","import {Graph} from '../graph';\nimport type {EdgeFunction, Path, WeightFunction} from '../types';\n\nconst DEFAULT_WEIGHT_FUNC: WeightFunction = () => 1;\n\n/**\n * This function is an implementation of the Floyd-Warshall algorithm, which finds the\n * shortest path from each node to every other reachable node in the graph. It is similar\n * to alg.dijkstraAll, but it handles negative edge weights and is more efficient for some types\n * of graphs. This function returns a map of source -> { target -> { distance, predecessor }.\n * The distance property holds the sum of the weights from source to target along the shortest\n * path of Number.POSITIVE_INFINITY if there is no path from source. The predecessor property\n * can be used to walk the individual elements of the path from source to target in reverse\n * order.\n * Complexity: O(|V|^3).\n *\n * @param graph - graph where to search paths.\n * @param weightFn - function which takes edge e and returns the weight of it. If no weightFn\n * is supplied then each edge is assumed to have a weight of 1. This function throws an\n * Error if any of the traversed edges have a negative edge weight.\n * @param edgeFn - function which takes a node v and returns the ids of all edges incident to it\n * for the purposes of shortest path traversal. By default this function uses the graph.outEdges.\n * @returns shortest paths map.\n */\nexport function floydWarshall(\n graph: Graph,\n weightFn?: WeightFunction,\n edgeFn?: EdgeFunction\n): Record<string, Record<string, Path>> {\n return runFloydWarshall(graph,\n weightFn || DEFAULT_WEIGHT_FUNC,\n edgeFn || function (v) {\n return graph.outEdges(v)!;\n });\n}\n\nfunction runFloydWarshall(\n graph: Graph,\n weightFn: WeightFunction,\n edgeFn: EdgeFunction\n): Record<string, Record<string, Path>> {\n const results: Record<string, Record<string, Path>> = {};\n const nodes = graph.nodes();\n\n nodes.forEach(function (v) {\n results[v] = {};\n results[v]![v] = {distance: 0, predecessor: ''};\n nodes.forEach(function (w) {\n if (v !== w) {\n results[v]![w] = {distance: Number.POSITIVE_INFINITY, predecessor: ''};\n }\n });\n edgeFn(v).forEach(function (edge) {\n const w = edge.v === v ? edge.w : edge.v;\n const d = weightFn(edge);\n results[v]![w] = {distance: d, predecessor: v};\n });\n });\n\n nodes.forEach(function (k) {\n const rowK = results[k]!;\n nodes.forEach(function (i) {\n const rowI = results[i]!;\n nodes.forEach(function (j) {\n const ik = rowI[k]!;\n const kj = rowK[j]!;\n const ij = rowI[j]!;\n const altDistance = ik.distance + kj.distance;\n if (altDistance < ij.distance) {\n ij.distance = altDistance;\n ij.predecessor = kj.predecessor;\n }\n });\n });\n });\n\n return results;\n}\n","import {Graph} from '../graph';\n\nexport class CycleException extends Error {\n constructor(...args: unknown[]) {\n super(...args as ConstructorParameters<typeof Error>);\n }\n}\n\n/**\n * Given a graph this function applies topological sorting to it.\n * If the graph has a cycle it is impossible to generate such a list and CycleException is thrown.\n * Complexity: O(|V| + |E|).\n *\n * @param graph - graph to apply topological sorting to.\n * @returns an array of nodes such that for each edge u -> v, u appears before v in the array.\n */\nexport function topsort(graph: Graph): string[] {\n const visited: Record<string, boolean> = {};\n const stack: Record<string, boolean> = {};\n const results: string[] = [];\n\n function visit(node: string): void {\n if (node in stack) {\n throw new CycleException();\n }\n\n if (!(node in visited)) {\n stack[node] = true;\n visited[node] = true;\n graph.predecessors(node)!.forEach(visit);\n delete stack[node];\n results.push(node);\n }\n }\n\n graph.sinks().forEach(visit);\n\n if (Object.keys(visited).length !== graph.nodeCount()) {\n throw new CycleException();\n }\n\n return results;\n}\n","import {Graph} from '../graph';\nimport {CycleException, topsort} from './topsort';\n\n/**\n * Given a Graph, graph, this function returns true if the graph has no cycles and returns false if it\n * does. This algorithm returns as soon as it detects the first cycle. You can use alg.findCycles\n * to get the actual list of cycles in the graph.\n *\n * @param graph - graph to detect whether it acyclic or not.\n * @returns whether graph contain cycles or not.\n */\nexport function isAcyclic(graph: Graph): boolean {\n try {\n topsort(graph);\n } catch (e) {\n if (e instanceof CycleException) {\n return false;\n }\n throw e;\n }\n return true;\n}\n","import {Graph} from '../graph';\n\n/*\n * A helper that preforms a pre- or post-order traversal on the input graph\n * and processes the nodes in the order they are visited. If the graph is\n * undirected then this algorithm will navigate using neighbors. If the graph\n * is directed then this algorithm will navigate using successors.\n *\n * Order must be one of \"pre\" or \"post\".\n */\nexport function reduce<T>(\n g: Graph,\n vs: string | string[],\n order: string,\n fn: (acc: T, v: string) => T,\n acc: T\n): T {\n if (!Array.isArray(vs)) {\n vs = [vs];\n }\n\n const navigation = ((v: string) => (g.isDirected() ? g.successors(v) : g.neighbors(v)) ?? []);\n\n const visited: Record<string, boolean> = {};\n vs.forEach(function (v) {\n if (!g.hasNode(v)) {\n throw new Error(\"Graph does not have node: \" + v);\n }\n\n acc = doReduce(g, v, order === \"post\", visited, navigation, fn, acc);\n });\n return acc;\n}\n\nfunction doReduce<T>(\n g: Graph,\n v: string,\n postorder: boolean,\n visited: Record<string, boolean>,\n navigation: (v: string) => string[],\n fn: (acc: T, v: string) => T,\n acc: T\n): T {\n if (!(v in visited)) {\n visited[v] = true;\n\n if (!postorder) {\n acc = fn(acc, v);\n }\n navigation(v).forEach(function (w) {\n acc = doReduce(g, w, postorder, visited, navigation, fn, acc);\n });\n if (postorder) {\n acc = fn(acc, v);\n }\n }\n return acc;\n}\n","import {Graph} from '../graph';\nimport {reduce} from './reduce';\n\n/*\n * Pre- or post-order traversal on the input graph.\n * Returns an array of the nodes in the order they were visited.\n *\n * If the order is not \"post\", it will be treated as \"pre\".\n */\nexport function dfs(g: Graph, vs: string | string[], order: string): string[] {\n return reduce(g, vs, order, function (acc, v) {\n acc.push(v);\n return acc;\n }, [] as string[]);\n}\n","import {Graph} from '../graph';\nimport {dfs} from './dfs';\n\n/**\n * Performs post-order depth first traversal on the input graph. If the graph is\n * undirected then this algorithm will navigate using neighbors. If the graph\n * is directed then this algorithm will navigate using successors.\n *\n * @param graph - depth first traversal target.\n * @param vs - nodes list to traverse.\n * @returns the nodes in the order they were visited as a list of their names.\n */\nexport function postorder(graph: Graph, vs: string | string[]): string[] {\n return dfs(graph, vs, \"post\");\n}\n","import {Graph} from '../graph';\nimport {dfs} from './dfs';\n\n/**\n * Performs pre-order depth first traversal on the input graph. If the graph is\n * undirected then this algorithm will navigate using neighbors. If the graph\n * is directed then this algorithm will navigate using successors.\n *\n * @param graph - depth first traversal target.\n * @param vs - nodes list to traverse.\n * @returns the nodes in the order they were visited as a list of their names.\n */\nexport function preorder(graph: Graph, vs: string | string[]): string[] {\n return dfs(graph, vs, \"pre\");\n}\n","import {Graph} from '../graph';\nimport {PriorityQueue} from '../data/priority-queue';\nimport type {Edge, WeightFunction} from '../types';\n\n/**\n * Prim's algorithm takes a connected undirected graph and generates a minimum spanning tree. This\n * function returns the minimum spanning tree as an undirected graph. This algorithm is derived\n * from the description in \"Introduction to Algorithms\", Third Edition, Cormen, et al., Pg 634.\n * Complexity: O(|E| * log |V|);\n *\n * @param graph - graph to generate a minimum spanning tree of.\n * @param weightFn - function which takes edge e and returns the weight of it. It throws an Error if\n * the graph is not connected.\n * @returns minimum spanning tree of graph.\n */\nexport function prim(graph: Graph, weightFn: WeightFunction): Graph {\n const result = new Graph();\n const parents: Record<string, string> = {};\n const pq = new PriorityQueue();\n let v: string;\n\n function updateNeighbors(edge: Edge): void {\n const w = edge.v === v ? edge.w : edge.v;\n const pri = pq.priority(w);\n if (pri !== undefined) {\n const edgeWeight = weightFn(edge);\n if (edgeWeight < pri) {\n parents[w] = v;\n pq.decrease(w, edgeWeight);\n }\n }\n }\n\n if (graph.nodeCount() === 0) {\n return result;\n }\n\n graph.nodes().forEach(function (v) {\n pq.add(v, Number.POSITIVE_INFINITY);\n result.setNode(v);\n });\n\n // Start from an arbitrary node\n pq.decrease(graph.nodes()[0]!, 0);\n\n let init = false;\n while (pq.size() > 0) {\n v = pq.removeMin()!;\n if (v in parents) {\n result.setEdge(v, parents[v]!);\n } else if (init) {\n throw new Error(\"Input graph is not connected: \" + graph);\n } else {\n init = true;\n }\n\n graph.nodeEdges(v)!.forEach(updateNeighbors);\n }\n\n return result;\n}\n","import {dijkstra} from './dijkstra';\nimport {bellmanFord} from './bellman-ford';\nimport {Graph} from '../graph';\nimport type {EdgeFunction, Path, WeightFunction} from '../types';\n\nexport function shortestPaths(\n g: Graph,\n source: string,\n weightFn?: WeightFunction,\n edgeFn?: EdgeFunction\n): Record<string, Path> {\n return runShortestPaths(\n g,\n source,\n weightFn,\n edgeFn ?? ((v: string) => {\n const edges = g.outEdges(v);\n return edges ?? [];\n })\n );\n}\n\nfunction runShortestPaths(\n g: Graph,\n source: string,\n weightFn: WeightFunction | undefined,\n edgeFn: EdgeFunction\n): Record<string, Path> {\n if (weightFn === undefined) {\n return dijkstra(g, source, weightFn, edgeFn);\n }\n\n let negativeEdgeExists = false;\n const nodes = g.nodes();\n\n for (let i = 0; i < nodes.length; i++) {\n const adjList = edgeFn(nodes[i]!);\n\n for (let j = 0; j < adjList.length; j++) {\n const edge = adjList[j]!;\n const inVertex = edge.v === nodes[i] ? edge.v : edge.w;\n const outVertex = inVertex === edge.v ? edge.w : edge.v;\n\n if (weightFn({v: inVertex, w: outVertex}) < 0) {\n negativeEdgeExists = true;\n }\n }\n\n if (negativeEdgeExists) {\n return bellmanFord(g, source, weightFn, edgeFn);\n }\n }\n\n return dijkstra(g, source, weightFn, edgeFn);\n}\n","import {Graph} from \"./graph-lib\";\nimport type {EdgeLabel, GraphLabel, NodeLabel, PartitionResult, Point} from \"./types\";\n\nexport {\n addBorderNode,\n addDummyNode,\n applyWithChunking,\n asNonCompoundGraph,\n buildLayerMatrix,\n intersectRect,\n mapValues,\n maxRank,\n normalizeRanks,\n notime,\n partition,\n pick,\n predecessorWeights,\n range,\n removeEmptyRanks,\n simplify,\n successorWeights,\n time,\n uniqueId,\n zipObject,\n};\n\n/*\n * Adds a dummy node to the graph and return v.\n */\nfunction addDummyNode(\n graph: Graph<GraphLabel, NodeLabel, EdgeLabel>,\n type: 'root' | \"edge\" | \"border\" | \"edge-label\" | \"edge-proxy\" | \"selfedge\",\n attrs: Partial<NodeLabel>,\n name: string\n): string {\n let v: string = name;\n while (graph.hasNode(v)) {\n v = uniqueId(name);\n }\n\n attrs.dummy = type;\n graph.setNode(v, attrs as NodeLabel);\n return v;\n}\n\n/*\n * Returns a new graph with only simple edges. Handles aggregation of data\n * associated with multi-edges.\n */\nfunction simplify(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): Graph<GraphLabel, NodeLabel, EdgeLabel> {\n const simplified = new Graph<GraphLabel, NodeLabel, EdgeLabel>().setGraph(graph.graph());\n graph.nodes().forEach(v => simplified.setNode(v, graph.node(v)));\n graph.edges().forEach(e => {\n const simpleLabel: EdgeLabel = simplified.edge(e.v, e.w) || {weight: 0, minlen: 1};\n const label: EdgeLabel = graph.edge(e);\n simplified.setEdge(e.v, e.w, {\n weight: simpleLabel.weight! + label.weight!,\n minlen: Math.max(simpleLabel.minlen!, label.minlen!)\n });\n });\n return simplified;\n}\n\nfunction asNonCompoundGraph(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): Graph<GraphLabel, NodeLabel, EdgeLabel> {\n const simplified = new Graph<GraphLabel, NodeLabel, EdgeLabel>({multigraph: graph.isMultigraph()}).setGraph(graph.graph());\n graph.nodes().forEach(v => {\n if (!graph.children(v).length) {\n simplified.setNode(v, graph.node(v));\n }\n });\n graph.edges().forEach(e => {\n simplified.setEdge(e, graph.edge(e));\n });\n return simplified;\n}\n\nfunction successorWeights(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): {\n [key: string]: { [key: string]: number }\n} {\n const weightMap: { [key: string]: number }[] = graph.nodes().map(v => {\n const sucs: { [key: string]: number } = {};\n const outEdges = graph.outEdges(v);\n if (outEdges) {\n outEdges.forEach(e => {\n sucs[e.w] = (sucs[e.w] || 0) + graph.edge(e).weight!;\n });\n }\n return sucs;\n });\n return zipObject(graph.nodes(), weightMap);\n}\n\nfunction predecessorWeights(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): {\n [key: string]: { [key: string]: number }\n} {\n const weightMap: { [key: string]: number }[] = graph.nodes().map(v => {\n const preds: { [key: string]: number } = {};\n const inEdges = graph.inEdges(v);\n if (inEdges) {\n inEdges.forEach(e => {\n preds[e.v] = (preds[e.v] || 0) + graph.edge(e).weight!;\n });\n }\n return preds;\n });\n return zipObject(graph.nodes(), weightMap);\n}\n\n/*\n * Finds where a line starting at point ({x, y}) would intersect a rectangle\n * ({x, y, width, height}) if it were pointing at the rectangle's center.\n */\nfunction intersectRect(rect: NodeLabel, point: Point): Point {\n const x: number = rect.x!;\n const y: number = rect.y!;\n\n // Rectangle intersection algorithm from:\n // http://math.stackexchange.com/questions/108113/find-edge-between-two-boxes\n const dx: number = point.x - x;\n const dy: number = point.y - y;\n let w: number = rect.width / 2;\n let h: number = rect.height / 2;\n\n if (!dx && !dy) {\n throw new Error(\"Not possible to find intersection inside of the rectangle\");\n }\n\n let sx: number, sy: number;\n if (Math.abs(dy) * w > Math.abs(dx) * h) {\n // Intersection is top or bottom of rect.\n if (dy < 0) {\n h = -h;\n }\n sx = h * dx / dy;\n sy = h;\n } else {\n // Intersection is left or right of rect.\n if (dx < 0) {\n w = -w;\n }\n sx = w;\n sy = w * dy / dx;\n }\n\n return {x: x + sx, y: y + sy};\n}\n\n/*\n * Given a DAG with each node assigned \"rank\" and \"order\" properties, this\n * function will produce a matrix with the ids of each node.\n */\nfunction buildLayerMatrix(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): string[][] {\n const layering: string[][] = range(maxRank(graph) + 1).map(() => []);\n graph.nodes().forEach(v => {\n const node = graph.node(v) as NodeLabel;\n const rank: number | undefined = node.rank;\n if (rank !== undefined) {\n if (!layering[rank]) {\n layering[rank] = [];\n }\n layering[rank][node.order!] = v;\n }\n });\n return layering;\n}\n\n/*\n * Adjusts the ranks for all nodes in the graph such that all nodes v have\n * rank(v) >= 0 and at least one node w has rank(w) = 0.\n */\nfunction normalizeRanks(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n const nodeRanks: number[] = graph.nodes().map(v => {\n const rank: number | undefined = (graph.node(v) as NodeLabel).rank;\n if (rank === undefined) {\n return Number.MAX_VALUE;\n }\n\n return rank;\n });\n const min: number = applyWithChunking(Math.min, nodeRanks);\n graph.nodes().forEach(v => {\n const node = graph.node(v) as NodeLabel;\n if (Object.hasOwn(node, \"rank\")) {\n (node as NodeLabel).rank! -= min;\n }\n });\n}\n\nfunction removeEmptyRanks(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n // Ranks may not start at 0, so we need to offset them\n const nodeRanks: number[] = graph.nodes().map(v => graph.node(v).rank).filter((rank): rank is number => rank !== undefined);\n const offset: number = applyWithChunking(Math.min, nodeRanks);\n\n const layers: string[][] = [];\n graph.nodes().forEach(v => {\n const rank: number = graph.node(v).rank! - offset;\n if (!layers[rank]) {\n layers[rank] = [];\n }\n layers[rank].push(v);\n });\n\n let delta: number = 0;\n const nodeRankFactor: number = graph.graph().nodeRankFactor!;\n Array.from(layers).forEach((vs, i) => {\n if (vs === undefined && i % nodeRankFactor !== 0) {\n --delta;\n } else if (vs !== undefined && delta) {\n vs.forEach(v => graph.node(v).rank! += delta);\n }\n });\n}\n\nfunction addBorderNode(\n graph: Graph<GraphLabel, NodeLabel, EdgeLabel>,\n prefix: string,\n rank?: number,\n order?: number\n): string {\n const node: Partial<NodeLabel> = {\n width: 0,\n height: 0\n };\n if (arguments.length >= 4) {\n node.rank = rank;\n node.order = order;\n }\n return addDummyNode(graph, \"border\", node, prefix);\n}\n\nfunction splitToChunks<T>(array: T[], chunkSize: number = CHUNKING_THRESHOLD): T[][] {\n const chunks: T[][] = [];\n for (let i = 0; i < array.length; i += chunkSize) {\n const chunk: T[] = array.slice(i, i + chunkSize);\n chunks.push(chunk);\n }\n return chunks;\n}\n\nconst CHUNKING_THRESHOLD = 65535;\n\nfunction applyWithChunking(fn: (...args: number[]) => number, argsArray: number[]): number {\n if (argsArray.length > CHUNKING_THRESHOLD) {\n const chunks: number[][] = splitToChunks(argsArray);\n return fn(...chunks.map(chunk => fn(...chunk)));\n } else {\n return fn(...argsArray);\n }\n}\n\nfunction maxRank(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): number {\n const nodes: string[] = graph.nodes();\n const nodeRanks: number[] = nodes.map(v => {\n const rank: number | undefined = graph.node(v).rank;\n if (rank === undefined) {\n return Number.MIN_VALUE;\n }\n return rank;\n });\n\n return applyWithChunking(Math.max, nodeRanks);\n}\n\n/*\n * Partition a collection into two groups: `lhs` and `rhs`. If the supplied\n * function returns true for an entry it goes into `lhs`. Otherwise it goes\n * into `rhs.\n */\nfunction partition<T>(collection: T[], fn: (value: T) => boolean): PartitionResult<T> {\n const result: PartitionResult<T> = {lhs: [], rhs: []};\n collection.forEach(value => {\n if (fn(value)) {\n result.lhs.push(value);\n } else {\n result.rhs.push(value);\n }\n });\n return result;\n}\n\n/*\n * Returns a new function that wraps `fn` with a timer. The wrapper logs the\n * time it takes to execute the function.\n */\nfunction time<T>(name: string, fn: () => T): T {\n const start: number = Date.now();\n try {\n return fn();\n } finally {\n console.log(name + \" time: \" + (Date.now() - start) + \"ms\");\n }\n}\n\nfunction notime<T>(name: string, fn: () => T): T {\n return fn();\n}\n\nlet idCounter = 0;\n\nfunction uniqueId(prefix: string): string {\n const id: number = ++idCounter;\n return prefix + (\"\" + id);\n}\n\nfunction range(start: number, limit?: number, step: number = 1): number[] {\n if (limit == null) {\n limit = start;\n start = 0;\n }\n\n let endCon: (i: number) => boolean = (i) => i < limit!;\n if (step < 0) {\n endCon = (i) => limit! < i;\n }\n\n const range: number[] = [];\n for (let i = start; endCon(i); i += step) {\n range.push(i);\n }\n\n return range;\n}\n\nfunction pick<T extends Record<string, unknown>>(source: T, keys: string[]): Partial<T> {\n const dest: Partial<T> = {};\n for (const key of keys) {\n if (source[key] !== undefined) {\n (dest as Record<string, unknown>)[key] = source[key];\n }\n }\n\n return dest;\n}\n\nfunction mapValues<T, R>(obj: { [key: string]: T }, funcOrProp: ((val: T, key: string) => R) | string): {\n [key: string]: R\n} {\n let func: (val: T, key: string) => R;\n if (typeof funcOrProp === 'string') {\n func = (val: T) => (val as Record<string, R>)[funcOrProp] as R;\n } else {\n func = funcOrProp;\n }\n\n return Object.entries(obj).reduce((acc: { [key: string]: R }, [k, v]) => {\n acc[k] = func(v, k);\n return acc;\n }, {});\n}\n\nfunction zipObject<T>(props: string[], values: T[]): { [key: string]: T } {\n return props.reduce((acc: { [key: string]: T }, key, i) => {\n acc[key] = values[i]!;\n return acc;\n }, {});\n}\n\n// TODO: Remove it when the type is fixed in graphlib. from children(v: string): string[] to children(v?: string): string[];\nexport const GRAPH_NODE = \"\\x00\";\n","export const version = \"3.0.0\";\n","/*\n * Simple doubly linked list implementation derived from Cormen, et al.,\n * \"Introduction to Algorithms\".\n */\n\ninterface ListNode {\n _next?: ListNode;\n _prev?: ListNode;\n\n [key: string]: unknown;\n}\n\nclass List {\n private _sentinel: ListNode;\n\n constructor() {\n const sentinel: ListNode = {};\n sentinel._next = sentinel._prev = sentinel;\n this._sentinel = sentinel;\n }\n\n dequeue(): ListNode | undefined {\n const sentinel = this._sentinel;\n const entry = sentinel._prev;\n if (entry !== sentinel) {\n unlink(entry!);\n return entry;\n }\n return undefined;\n }\n\n enqueue(entry: ListNode): void {\n const sentinel = this._sentinel;\n if (entry._prev && entry._next) {\n unlink(entry);\n }\n entry._next = sentinel._next;\n sentinel._next!._prev = entry;\n sentinel._next = entry;\n entry._prev = sentinel;\n }\n\n toString(): string {\n const strs: string[] = [];\n const sentinel = this._sentinel;\n let curr = sentinel._prev;\n while (curr !== sentinel) {\n strs.push(JSON.stringify(curr, filterOutLinks));\n curr = curr!._prev;\n }\n return \"[\" + strs.join(\", \") + \"]\";\n }\n}\n\nfunction unlink(entry: ListNode): void {\n entry._prev!._next = entry._next;\n entry._next!._prev = entry._prev;\n delete entry._next;\n delete entry._prev;\n}\n\nfunction filterOutLinks(k: string, v: unknown): unknown {\n if (k !== \"_next\" && k !== \"_prev\") {\n return v;\n }\n return undefined;\n}\n\nexport default List;\n","import {Graph} from \"./graph-lib\";\nimport List from './data/list';\nimport type {Edge, WeightFunction} from './types';\n\n/*\n * A greedy heuristic for finding a feedback arc set for a graph. A feedback\n * arc set is a set of edges that can be removed to make a graph acyclic.\n * The algorithm comes from: P. Eades, X. Lin, and W. F. Smyth, \"A fast and\n * effective heuristic for the feedback arc set problem.\" This implementation\n * adjusts that from the paper to allow for weighted edges.\n */\n\nconst DEFAULT_WEIGHT_FN: WeightFunction = () => 1;\n\ninterface FASEntry {\n v: string;\n in: number;\n out: number;\n [key: string]: unknown;\n}\n\ninterface FASState {\n graph: Graph;\n buckets: List[];\n zeroIdx: number;\n}\n\nexport default function greedyFAS(graph: Graph, weightFn?: WeightFunction): Edge[] {\n if (graph.nodeCount() <= 1) {\n return [];\n }\n const state = buildState(graph, weightFn || DEFAULT_WEIGHT_FN);\n const results = doGreedyFAS(state.graph, state.buckets, state.zeroIdx);\n\n // Expand multi-edges\n return results.flatMap(edge => graph.outEdges(edge.v, edge.w) || []);\n}\n\nfunction doGreedyFAS(g: Graph, buckets: List[], zeroIdx: number): Edge[] {\n let results: Edge[] = [];\n const sources = buckets[buckets.length - 1]!;\n const sinks = buckets[0]!;\n\n let entry: FASEntry | undefined;\n while (g.nodeCount()) {\n while ((entry = sinks.dequeue() as FASEntry | undefined)) {\n removeNode(g, buckets, zeroIdx, entry);\n }\n while ((entry = sources.dequeue() as FASEntry | undefined)) {\n removeNode(g, buckets, zeroIdx, entry);\n }\n if (g.nodeCount()) {\n for (let i = buckets.length - 2; i > 0; --i) {\n entry = buckets[i]?.dequeue() as FASEntry | undefined;\n if (entry) {\n results = results.concat(removeNode(g, buckets, zeroIdx, entry, true) || []);\n break;\n }\n }\n }\n }\n\n return results;\n}\n\nfunction removeNode(\n graph: Graph,\n buckets: List[],\n zeroIdx: number,\n entry: FASEntry,\n collectPredecessors?: boolean\n): Edge[] | undefined {\n const collected: Edge[] = [];\n const results: Edge[] | undefined = collectPredecessors ? collected : undefined;\n\n (graph.inEdges(entry.v) || []).forEach(edge => {\n const weight = graph.edge(edge) as number;\n const uEntry = graph.node(edge.v) as FASEntry;\n\n if (collectPredecessors) {\n collected.push({v: edge.v, w: edge.w});\n }\n\n uEntry.out -= weight;\n assignBucket(buckets, zeroIdx, uEntry);\n });\n\n (graph.outEdges(entry.v) || []).forEach(edge => {\n const weight = graph.edge(edge) as number;\n const w = edge.w;\n const wEntry = graph.node(w) as FASEntry;\n wEntry.in -= weight;\n assignBucket(buckets, zeroIdx, wEntry);\n });\n\n graph.removeNode(entry.v);\n\n return results;\n}\n\nfunction buildState(graph: Graph, weightFn: WeightFunction): FASState {\n const fasGraph = new Graph();\n let maxIn = 0;\n let maxOut = 0;\n\n graph.nodes().forEach(v => {\n fasGraph.setNode(v, {v: v, in: 0, out: 0});\n });\n\n // Aggregate weights on nodes, but also sum the weights across multi-edges\n // into a single edge for the fasGraph.\n graph.edges().forEach(edge => {\n const prevWeight = (fasGraph.edge(edge.v, edge.w) as number) || 0;\n const weight = weightFn(edge);\n const edgeWeight = prevWeight + weight;\n fasGraph.setEdge(edge.v, edge.w, edgeWeight);\n const vNode = fasGraph.node(edge.v) as FASEntry;\n const wNode = fasGraph.node(edge.w) as FASEntry;\n maxOut = Math.max(maxOut, vNode.out += weight);\n maxIn = Math.max(maxIn, wNode.in += weight);\n });\n\n const buckets = range(maxOut + maxIn + 3).map(() => new List());\n const zeroIdx = maxIn + 1;\n\n fasGraph.nodes().forEach(v => {\n assignBucket(buckets, zeroIdx, fasGraph.node(v) as FASEntry);\n });\n\n return {graph: fasGraph, buckets: buckets, zeroIdx: zeroIdx};\n}\n\nfunction assignBucket(buckets: List[], zeroIdx: number, entry: FASEntry): void {\n if (!entry.out) {\n buckets[0]?.enqueue(entry);\n } else if (!entry.in) {\n buckets[buckets.length - 1]?.enqueue(entry);\n } else {\n buckets[entry.out - entry.in + zeroIdx]?.enqueue(entry);\n }\n}\n\nfunction range(limit: number): number[] {\n const range: number[] = [];\n for (let i = 0; i < limit; i++) {\n range.push(i);\n }\n\n return range;\n}\n","import {Graph} from \"@dagrejs/graphlib\";\nimport greedyFAS from \"./greedy-fas\";\nimport {uniqueId} from \"./util\";\nimport type {Edge, EdgeLabel, GraphLabel, NodeLabel, WeightFunction} from \"./types\";\n\nexport {run, undo};\n\nfunction run(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n const fas = (graph.graph().acyclicer === \"greedy\"\n ? greedyFAS(graph, weightFn(graph))\n : dfsFAS(graph));\n fas.forEach(e => {\n const label = graph.edge(e)!;\n graph.removeEdge(e);\n label.forwardName = e.name;\n label.reversed = true;\n graph.setEdge(e.w, e.v, label, uniqueId(\"rev\"));\n });\n\n function weightFn(g: Graph<GraphLabel, NodeLabel, EdgeLabel>): WeightFunction {\n return (e: Edge) => {\n return g.edge(e)!.weight!;\n };\n }\n}\n\nfunction dfsFAS(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): Edge[] {\n const fas: Edge[] = [];\n const stack: { [key: string]: boolean } = {};\n const visited: { [key: string]: boolean } = {};\n\n function dfs(v: string): void {\n if (Object.hasOwn(visited, v)) {\n return;\n }\n visited[v] = true;\n stack[v] = true;\n graph.outEdges(v)!.forEach(e => {\n if (Object.hasOwn(stack, e.w)) {\n fas.push(e);\n } else {\n dfs(e.w);\n }\n });\n delete stack[v];\n }\n\n graph.nodes().forEach(dfs);\n return fas;\n}\n\nfunction undo(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n graph.edges().forEach(e => {\n const label = graph.edge(e)!;\n if (label.reversed) {\n graph.removeEdge(e);\n\n const forwardName = label.forwardName;\n delete label.reversed;\n delete label.forwardName;\n graph.setEdge(e.w, e.v, label, forwardName);\n }\n });\n}\n","import {addDummyNode} from \"./util\";\nimport type {Edge, EdgeLabel, Graph, GraphLabel, NodeLabel} from \"./types\";\n\nexport {\n run,\n undo\n};\n\n/*\n * Breaks any long edges in the graph into short segments that span 1 layer\n * each. This operation is undoable with the denormalize function.\n *\n * Pre-conditions:\n *\n * 1. The input graph is a DAG.\n * 2. Each node in the graph has a \"rank\" property.\n *\n * Post-condition:\n *\n * 1. All edges in the graph have a length of 1.\n * 2. Dummy nodes are added where edges have been split into segments.\n * 3. The graph is augmented with a \"dummyChains\" attribute which contains\n * the first dummy in each chain of dummy nodes produced.\n */\nfunction run(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n graph.graph().dummyChains = [];\n graph.edges().forEach(edge => normalizeEdge(graph, edge));\n}\n\nfunction normalizeEdge(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>, e: Edge): void {\n let v: string = e.v;\n let vRank: number = graph.node(v).rank!;\n const w: string = e.w;\n const wRank: number = graph.node(w).rank!;\n const name: string | undefined = e.name;\n const edgeLabel: EdgeLabel = graph.edge(e);\n const labelRank: number | undefined = edgeLabel.labelRank;\n\n if (wRank === vRank + 1) return;\n\n graph.removeEdge(e);\n\n let dummy: string;\n let attrs: Partial<NodeLabel>;\n let i: number;\n for (i = 0, ++vRank; vRank < wRank; ++i, ++vRank) {\n edgeLabel.points = [];\n attrs = {\n width: 0,\n height: 0,\n edgeLabel: edgeLabel,\n edgeObj: e,\n rank: vRank\n };\n dummy = addDummyNode(graph, \"edge\", attrs, \"_d\");\n if (vRank === labelRank) {\n attrs.width = edgeLabel.width;\n attrs.height = edgeLabel.height;\n attrs.dummy = \"edge-label\";\n attrs.labelpos = edgeLabel.labelpos;\n }\n graph.setEdge(v, dummy, {weight: edgeLabel.weight}, name);\n if (i === 0) {\n graph.graph().dummyChains!.push(dummy);\n }\n v = dummy;\n }\n\n graph.setEdge(v, w, {weight: edgeLabel.weight}, name);\n}\n\nfunction undo(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n graph.graph().dummyChains!.forEach(v => {\n let node: NodeLabel = graph.node(v);\n const origLabel: EdgeLabel = node.edgeLabel!;\n let w: string;\n graph.setEdge(node.edgeObj!, origLabel);\n while (node.dummy) {\n w = graph.successors(v)![0]!;\n graph.removeNode(v);\n origLabel.points!.push({x: node.x!, y: node.y!});\n if (node.dummy === \"edge-label\") {\n origLabel.x = node.x;\n origLabel.y = node.y;\n origLabel.width = node.width;\n origLabel.height = node.height;\n }\n v = w;\n node = graph.node(v);\n }\n });\n}\n","import {applyWithChunking} from \"../util\";\nimport type {Edge, EdgeLabel, Graph, GraphLabel, NodeLabel} from \"../types\";\n\nexport {longestPath, slack};\n\n/*\n * Initializes ranks for the input graph using the longest path algorithm. This\n * algorithm scales well and is fast in practice, it yields rather poor\n * solutions. Nodes are pushed to the lowest layer possible, leaving the bottom\n * ranks wide and leaving edges longer than necessary. However, due to its\n * speed, this algorithm is good for getting an initial ranking that can be fed\n * into other algorithms.\n *\n * This algorithm does not normalize layers because it will be used by other\n * algorithms in most cases. If using this algorithm directly, be sure to\n * run normalize at the end.\n *\n * Pre-conditions:\n *\n * 1. Input graph is a DAG.\n * 2. Input graph node labels can be assigned properties.\n *\n * Post-conditions:\n *\n * 1. Each node will be assign an (unnormalized) \"rank\" property.\n */\nfunction longestPath(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n const visited: { [key: string]: boolean } = {};\n\n function dfs(v: string): number {\n const label: NodeLabel = graph.node(v);\n if (Object.hasOwn(visited, v)) {\n return label.rank!;\n }\n visited[v] = true;\n\n const outEdges = graph.outEdges(v);\n const outEdgesMinLens: number[] = outEdges ? outEdges.map(e => {\n if (e == null) {\n return Number.POSITIVE_INFINITY;\n }\n\n return dfs(e.w) - graph.edge(e).minlen!;\n }) : [];\n\n let rank: number = applyWithChunking(Math.min, outEdgesMinLens);\n\n if (rank === Number.POSITIVE_INFINITY) {\n rank = 0;\n }\n\n return (label.rank = rank);\n }\n\n graph.sources().forEach(dfs);\n}\n\n/*\n * Returns the amount of slack for the given edge. The slack is defined as the\n * difference between the length of the edge and its minimum length.\n */\nfunction slack(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>, edge: Edge): number {\n return graph.node(edge.w).rank! - graph.node(edge.v).rank! - graph.edge(edge).minlen!;\n}\n","import {Graph} from \"../graph-lib\";\nimport {slack} from \"./util\";\nimport type {Edge, EdgeLabel, GraphLabel, NodeLabel} from \"../types\";\n\n// Internal type for tree node labels\ninterface TreeNodeLabel {\n low?: number;\n lim?: number;\n parent?: string;\n}\n\n// Internal type for tree edge labels\ninterface TreeEdgeLabel {\n cutvalue?: number;\n}\n\nexport default feasibleTree;\nexport type {TreeNodeLabel, TreeEdgeLabel};\n\n/*\n * Constructs a spanning tree with tight edges and adjusted the input node's\n * ranks to achieve this. A tight edge is one that is has a length that matches\n * its \"minlen\" attribute.\n *\n * The basic structure for this function is derived from Gansner, et al., \"A\n * Technique for Drawing Directed Graphs.\"\n *\n * Pre-conditions:\n *\n * 1. Graph must be a DAG.\n * 2. Graph must be connected.\n * 3. Graph must have at least one node.\n * 5. Graph nodes must have been previously assigned a \"rank\" property that\n * respects the \"minlen\" property of incident edges.\n * 6. Graph edges must have a \"minlen\" property.\n *\n * Post-conditions:\n *\n * - Graph nodes will have their rank adjusted to ensure that all edges are\n * tight.\n *\n * Returns a tree (undirected graph) that is constructed using only \"tight\"\n * edges.\n */\nfunction feasibleTree(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): Graph<object, TreeNodeLabel, TreeEdgeLabel> {\n const tree = new Graph<object, TreeNodeLabel, TreeEdgeLabel>({directed: false});\n\n // Choose arbitrary node from which to start our tree\n const nodes = graph.nodes();\n if (nodes.length === 0) {\n throw new Error(\"Graph must have at least one node\");\n }\n const start: string = nodes[0]!;\n const size: number = graph.nodeCount();\n tree.setNode(start, {});\n\n let edge: Edge | null;\n let delta: number;\n while (tightTree(tree, graph) < size) {\n edge = findMinSlackEdge(tree, graph);\n if (!edge) break;\n delta = tree.hasNode(edge.v) ? slack(graph, edge) : -slack(graph, edge);\n shiftRanks(tree, graph, delta);\n }\n\n return tree;\n}\n\n/*\n * Finds a maximal tree of tight edges and returns the number of nodes in the\n * tree.\n */\nfunction tightTree(tree: Graph<object, TreeNodeLabel, TreeEdgeLabel>, graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): number {\n function dfs(v: string): void {\n const nodeEdges = graph.nodeEdges(v);\n if (nodeEdges) {\n nodeEdges.forEach(e => {\n const edgeV: string = e.v;\n const w: string = (v === edgeV) ? e.w : edgeV;\n if (!tree.hasNode(w) && !slack(graph, e)) {\n tree.setNode(w, {});\n tree.setEdge(v, w, {});\n dfs(w);\n }\n });\n }\n }\n\n tree.nodes().forEach(dfs);\n return tree.nodeCount();\n}\n\n/*\n * Finds the edge with the smallest slack that is incident on tree and returns\n * it.\n */\nfunction findMinSlackEdge(tree: Graph<object, TreeNodeLabel, TreeEdgeLabel>, graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): Edge | null {\n const edges: Edge[] = graph.edges();\n\n return edges.reduce((acc: [number, Edge | null], edge: Edge): [number, Edge | null] => {\n let edgeSlack: number = Number.POSITIVE_INFINITY;\n if (tree.hasNode(edge.v) !== tree.hasNode(edge.w)) {\n edgeSlack = slack(graph, edge);\n }\n\n if (edgeSlack < acc[0]) {\n return [edgeSlack, edge];\n }\n\n return acc;\n }, [Number.POSITIVE_INFINITY, null])[1];\n}\n\nfunction shiftRanks(tree: Graph<object, TreeNodeLabel, TreeEdgeLabel>, graph: Graph<GraphLabel, NodeLabel, EdgeLabel>, delta: number): void {\n tree.nodes().forEach(v => graph.node(v).rank! += delta);\n}\n","import feasibleTree, {type TreeEdgeLabel, type TreeNodeLabel} from \"./feasible-tree\";\nimport {longestPath as initRank, slack} from \"./util\";\nimport {alg} from \"../graph-lib\";\nimport {simplify} from \"../util\";\nimport type {Edge, EdgeLabel, Graph, GraphLabel, NodeLabel} from \"../types\";\n\nconst {preorder, postorder} = alg;\n\nexport default networkSimplex;\n\n// Expose some internals for testing purposes\nnetworkSimplex.initLowLimValues = initLowLimValues;\nnetworkSimplex.initCutValues = initCutValues;\nnetworkSimplex.calcCutValue = calcCutValue;\nnetworkSimplex.leaveEdge = leaveEdge;\nnetworkSimplex.enterEdge = enterEdge;\nnetworkSimplex.exchangeEdges = exchangeEdges;\n\n/*\n * The network simplex algorithm assigns ranks to each node in the input graph\n * and iteratively improves the ranking to reduce the length of edges.\n *\n * Preconditions:\n *\n * 1. The input graph must be a DAG.\n * 2. All nodes in the graph must have an object value.\n * 3. All edges in the graph must have \"minlen\" and \"weight\" attributes.\n *\n * Postconditions:\n *\n * 1. All nodes in the graph will have an assigned \"rank\" attribute that has\n * been optimized by the network simplex algorithm. Ranks start at 0.\n *\n *\n * A rough sketch of the algorithm is as follows:\n *\n * 1. Assign initial ranks to each node. We use the longest path algorithm,\n * which assigns ranks to the lowest position possible. In general this\n * leads to very wide bottom ranks and unnecessarily long edges.\n * 2. Construct a feasible tight tree. A tight tree is one such that all\n * edges in the tree have no slack (difference between length of edge\n * and minlen for the edge). This by itself greatly improves the assigned\n * rankings by shorting edges.\n * 3. Iteratively find edges that have negative cut values. Generally a\n * negative cut value indicates that the edge could be removed and a new\n * tree edge could be added to produce a more compact graph.\n *\n * Much of the algorithms here are derived from Gansner, et al., \"A Technique\n * for Drawing Directed Graphs.\" The structure of the file roughly follows the\n * structure of the overall algorithm.\n */\nfunction networkSimplex(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n graph = simplify(graph as Graph<GraphLabel, NodeLabel, EdgeLabel>) as Graph<GraphLabel, NodeLabel, EdgeLabel>;\n initRank(graph);\n\n const t = feasibleTree(graph);\n initLowLimValues(t);\n initCutValues(t, graph);\n\n let e: Edge | undefined;\n let f: Edge;\n while ((e = leaveEdge(t))) {\n f = enterEdge(t, graph, e);\n exchangeEdges(t, graph, e, f);\n }\n}\n\n/*\n * Initializes cut values for all edges in the tree.\n */\nfunction initCutValues(tree: Graph<object, TreeNodeLabel, TreeEdgeLabel>, graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n let visitedNodes: string[] = postorder(tree, tree.nodes());\n visitedNodes = visitedNodes.slice(0, visitedNodes.length - 1);\n visitedNodes.forEach(v => assignCutValue(tree, graph, v));\n}\n\nfunction assignCutValue(tree: Graph<object, TreeNodeLabel, TreeEdgeLabel>, graph: Graph<GraphLabel, NodeLabel, EdgeLabel>, child: string): void {\n const childLab: TreeNodeLabel = tree.node(child);\n const parent: string = childLab.parent!;\n const edge = tree.edge(child, parent);\n edge.cutvalue = calcCutValue(tree, graph, child);\n}\n\n/*\n * Given the tight tree, its graph, and a child in the graph calculate and\n * return the cut value for the edge between the child and its parent.\n */\nfunction calcCutValue(tree: Graph<object, TreeNodeLabel, TreeEdgeLabel>, graph: Graph<GraphLabel, NodeLabel, EdgeLabel>, child: string): number {\n const childLab: TreeNodeLabel = tree.node(child);\n const parent: string = childLab.parent!;\n // True if the child is on the tail end of the edge in the directed graph\n let childIsTail: boolean = true;\n // The graph's view of the tree edge we're inspecting\n let graphEdge: EdgeLabel | undefined = graph.edge(child, parent);\n // The accumulated cut value for the edge between this node and its parent\n let cutValue: number = 0;\n\n if (!graphEdge) {\n childIsTail = false;\n graphEdge = graph.edge(parent, child);\n }\n\n cutValue = graphEdge.weight!;\n\n const nodeEdges = graph.nodeEdges(child);\n if (nodeEdges) {\n nodeEdges.forEach(edge => {\n const isOutEdge: boolean = edge.v === child;\n const other: string = isOutEdge ? edge.w : edge.v;\n\n if (other !== parent) {\n const pointsToHead: boolean = isOutEdge === childIsTail;\n const otherWeight: number = graph.edge(edge).weight!;\n\n cutValue += pointsToHead ? otherWeight : -otherWeight;\n if (isTreeEdge(tree, child, other)) {\n const treeEdge = tree.edge(child, other);\n const otherCutValue: number = treeEdge.cutvalue!;\n cutValue += pointsToHead ? -otherCutValue : otherCutValue;\n }\n }\n });\n }\n\n return cutValue;\n}\n\nfunction initLowLimValues(tree: Graph<object, TreeNodeLabel, TreeEdgeLabel>, root?: string): void {\n if (arguments.length < 2) {\n root = tree.nodes()[0];\n }\n dfsAssignLowLim(tree, {}, 1, root!);\n}\n\nfunction dfsAssignLowLim(tree: Graph<object, TreeNodeLabel, TreeEdgeLabel>, visited: {\n [key: string]: boolean\n}, nextLim: number, v: string, parent?: string): number {\n const low: number = nextLim;\n const label: TreeNodeLabel = tree.node(v);\n\n visited[v] = true;\n const neighbors = tree.neighbors(v);\n if (neighbors) {\n neighbors.forEach(w => {\n if (!Object.hasOwn(visited, w)) {\n nextLim = dfsAssignLowLim(tree, visited, nextLim, w, v);\n }\n });\n }\n\n label.low = low;\n label.lim = nextLim++;\n if (parent) {\n label.parent = parent;\n } else {\n // TODO should be able to remove this when we incrementally update low lim\n delete label.parent;\n }\n\n return nextLim;\n}\n\nfunction leaveEdge(tree: Graph<object, TreeNodeLabel, TreeEdgeLabel>): Edge | undefined {\n return tree.edges().find(e => {\n const edge = tree.edge(e);\n return edge.cutvalue! < 0;\n });\n}\n\nfunction enterEdge(tree: Graph<object, TreeNodeLabel, TreeEdgeLabel>, graph: Graph<GraphLabel, NodeLabel, EdgeLabel>, edge: Edge): Edge {\n let v: string = edge.v;\n let w: string = edge.w;\n\n // For the rest of this function we assume that v is the tail and w is the\n // head, so if we don't have this edge in the graph we should flip it to\n // match the correct orientation.\n if (!graph.hasEdge(v, w)) {\n v = edge.w;\n w = edge.v;\n }\n\n const vLabel: TreeNodeLabel = tree.node(v);\n const wLabel: TreeNodeLabel = tree.node(w);\n let tailLabel: TreeNodeLabel = vLabel;\n let flip: boolean = false;\n\n // If the root is in the tail of the edge then we need to flip the logic that\n // checks for the head and tail nodes in the candidates function below.\n if (vLabel.lim! > wLabel.lim!) {\n tailLabel = wLabel;\n flip = true;\n }\n\n const candidates: Edge[] = graph.edges().filter(edge => {\n return flip === isDescendant(tree, tree.node(edge.v), tailLabel) &&\n flip !== isDescendant(tree, tree.node(edge.w), tailLabel);\n });\n\n return candidates.reduce((acc: Edge, edge: Edge): Edge => {\n if (slack(graph, edge) < slack(graph, acc)) {\n return edge;\n }\n\n return acc;\n });\n}\n\nfunction exchangeEdges(t: Graph<object, TreeNodeLabel, TreeEdgeLabel>, g: Graph<GraphLabel, NodeLabel, EdgeLabel>, e: Edge, f: Edge): void {\n const v: string = e.v;\n const w: string = e.w;\n t.removeEdge(v, w);\n t.setEdge(f.v, f.w, {});\n initLowLimValues(t);\n initCutValues(t, g);\n updateRanks(t, g);\n}\n\nfunction updateRanks(t: Graph<object, TreeNodeLabel, TreeEdgeLabel>, g: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n const root: string | undefined = t.nodes().find(v => {\n const node = t.node(v);\n return !node.parent;\n });\n if (!root) return;\n\n let vs: string[] = preorder(t, [root]);\n vs = vs.slice(1);\n vs.forEach(v => {\n const treeNode = t.node(v);\n const parent: string = treeNode.parent!;\n let edge: EdgeLabel | undefined = g.edge(v, parent);\n let flipped: boolean = false;\n\n if (!edge) {\n edge = g.edge(parent, v);\n flipped = true;\n }\n\n g.node(v).rank = g.node(parent).rank! + (flipped ? edge!.minlen! : -edge!.minlen!);\n });\n}\n\n/*\n * Returns true if the edge is in the tree.\n */\nfunction isTreeEdge(tree: Graph<object, TreeNodeLabel, TreeEdgeLabel>, u: string, v: string): boolean {\n return tree.hasEdge(u, v);\n}\n\n/*\n * Returns true if the specified node is descendant of the root node per the\n * assigned low and lim attributes in the tree.\n */\nfunction isDescendant(tree: Graph<object, TreeNodeLabel, TreeEdgeLabel>, vLabel: TreeNodeLabel, rootLabel: TreeNodeLabel): boolean {\n return rootLabel.low! <= vLabel.lim! && vLabel.lim! <= rootLabel.lim!;\n}\n","import {longestPath} from \"./util\";\nimport feasibleTree from \"./feasible-tree\";\nimport networkSimplex from \"./network-simplex\";\nimport type {EdgeLabel, Graph, GraphLabel, NodeLabel, RankerFunction} from \"../types\";\n\nexport default rank;\n\n/*\n * Assigns a rank to each node in the input graph that respects the \"minlen\"\n * constraint specified on edges between nodes.\n *\n * This basic structure is derived from Gansner, et al., \"A Technique for\n * Drawing Directed Graphs.\"\n *\n * Pre-conditions:\n *\n * 1. Graph must be a connected DAG\n * 2. Graph nodes must be objects\n * 3. Graph edges must have \"weight\" and \"minlen\" attributes\n *\n * Post-conditions:\n *\n * 1. Graph nodes will have a \"rank\" attribute based on the results of the\n * algorithm. Ranks can start at any index (including negative), we'll\n * fix them up later.\n */\nfunction rank(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n const ranker: RankerFunction | string | undefined = graph.graph().ranker;\n if (typeof ranker === 'function') {\n return (ranker as RankerFunction)(graph);\n }\n switch (ranker) {\n case \"network-simplex\":\n networkSimplexRanker(graph);\n break;\n case \"tight-tree\":\n tightTreeRanker(graph);\n break;\n case \"longest-path\":\n longestPathRanker(graph);\n break;\n case \"none\":\n break;\n default:\n networkSimplexRanker(graph);\n }\n}\n\n// A fast and simple ranker, but results are far from optimal.\nconst longestPathRanker: RankerFunction = longestPath;\n\nfunction tightTreeRanker(g: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n longestPath(g);\n feasibleTree(g);\n}\n\nfunction networkSimplexRanker(g: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n networkSimplex(g);\n}\n","import type {Edge, EdgeLabel, Graph, GraphLabel, NodeLabel} from \"./types\";\nimport {GRAPH_NODE} from \"./util\";\n\nexport default parentDummyChains;\n\ninterface PostorderNum {\n low: number;\n lim: number;\n}\n\ninterface PathData {\n path: (string | undefined)[];\n lca: string | undefined;\n}\n\nfunction parentDummyChains(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n const postorderNums: { [key: string]: PostorderNum } = postorder(graph);\n\n graph.graph().dummyChains!.forEach(v => {\n let node: NodeLabel = graph.node(v);\n const edgeObj: Edge = node.edgeObj!;\n const pathData: PathData = findPath(graph, postorderNums, edgeObj.v, edgeObj.w);\n const path: (string | undefined)[] = pathData.path;\n const lca: string | undefined = pathData.lca;\n let pathIdx: number = 0;\n let pathV: string | undefined = path[pathIdx];\n let ascending: boolean = true;\n\n while (v !== edgeObj.w) {\n node = graph.node(v);\n\n if (ascending) {\n while ((pathV = path[pathIdx]) !== lca &&\n graph.node(pathV!).maxRank! < node.rank!) {\n pathIdx++;\n }\n\n if (pathV === lca) {\n ascending = false;\n }\n }\n\n if (!ascending) {\n while (pathIdx < path.length - 1 &&\n graph.node((path[pathIdx + 1])!).minRank! <= node.rank!) {\n pathIdx++;\n }\n pathV = path[pathIdx];\n }\n\n if (pathV !== undefined) {\n graph.setParent(v, pathV);\n }\n v = graph.successors(v)![0]!;\n }\n });\n}\n\n// Find a path from v to w through the lowest common ancestor (LCA). Return the\n// full path and the LCA.\nfunction findPath(\n graph: Graph<GraphLabel, NodeLabel, EdgeLabel>,\n postorderNums: { [key: string]: PostorderNum },\n v: string,\n w: string\n): PathData {\n const vPath: (string | undefined)[] = [];\n const wPath: (string | undefined)[] = [];\n const low: number = Math.min(postorderNums[v]!.low, postorderNums[w]!.low);\n const lim: number = Math.max(postorderNums[v]!.lim, postorderNums[w]!.lim);\n let parent: string | undefined;\n\n // Traverse up from v to find the LCA\n parent = v;\n do {\n parent = graph.parent(parent) as string | undefined;\n vPath.push(parent);\n } while (parent &&\n (postorderNums[parent]!.low > low || lim > postorderNums[parent]!.lim));\n const lca = parent;\n\n // Traverse from w to LCA\n let wParent: string = w;\n while ((wParent = graph.parent(wParent) as string) !== lca) {\n wPath.push(wParent);\n }\n\n return {path: vPath.concat(wPath.reverse()), lca: lca};\n}\n\nfunction postorder(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): { [key: string]: PostorderNum } {\n const result: { [key: string]: PostorderNum } = {};\n let lim: number = 0;\n\n function dfs(v: string): void {\n const low: number = lim;\n graph.children(v).forEach(dfs);\n result[v] = {low: low, lim: lim++};\n }\n\n graph.children(GRAPH_NODE).forEach(dfs);\n\n return result;\n}\n","import {addBorderNode, addDummyNode, applyWithChunking, GRAPH_NODE} from \"./util\";\nimport type {EdgeLabel, Graph, GraphLabel, NodeLabel} from \"./types\";\n\nexport {\n run,\n cleanup,\n};\n\n/*\n * A nesting graph creates dummy nodes for the tops and bottoms of subgraphs,\n * adds appropriate edges to ensure that all cluster nodes are placed between\n * these boundaries, and ensures that the graph is connected.\n *\n * In addition we ensure, through the use of the minlen property, that nodes\n * and subgraph border nodes to not end up on the same rank.\n *\n * Preconditions:\n *\n * 1. Input graph is a DAG\n * 2. Nodes in the input graph has a minlen attribute\n *\n * Postconditions:\n *\n * 1. Input graph is connected.\n * 2. Dummy nodes are added for the tops and bottoms of subgraphs.\n * 3. The minlen attribute for nodes is adjusted to ensure nodes do not\n * get placed on the same rank as subgraph border nodes.\n *\n * The nesting graph idea comes from Sander, \"Layout of Compound Directed\n * Graphs.\"\n */\nfunction run(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n const root: string = addDummyNode(graph, \"root\", {}, \"_root\");\n const depths: { [key: string]: number } = treeDepths(graph);\n const depthsArr: number[] = Object.values(depths);\n const height: number = applyWithChunking(Math.max, depthsArr) - 1; // Note: depths is an Object not an array\n const nodeSep: number = 2 * height + 1;\n\n graph.graph().nestingRoot = root;\n\n // Multiply minlen by nodeSep to align nodes on non-border ranks.\n graph.edges().forEach(e => graph.edge(e).minlen! *= nodeSep);\n\n // Calculate a weight that is sufficient to keep subgraphs vertically compact\n const weight: number = sumWeights(graph) + 1;\n\n // Create border nodes and link them up\n graph.children(GRAPH_NODE).forEach(child => dfs(graph, root, nodeSep, weight, height, depths, child));\n\n // Save the multiplier for node layers for later removal of empty border\n // layers.\n graph.graph().nodeRankFactor = nodeSep;\n}\n\nfunction dfs(\n graph: Graph<GraphLabel, NodeLabel, EdgeLabel>,\n root: string,\n nodeSep: number,\n weight: number,\n height: number,\n depths: { [key: string]: number },\n v: string\n): void {\n const children: string[] = graph.children(v);\n if (!children.length) {\n if (v !== root) {\n graph.setEdge(root, v, {weight: 0, minlen: nodeSep});\n }\n return;\n }\n\n const top: string = addBorderNode(graph, \"_bt\");\n const bottom: string = addBorderNode(graph, \"_bb\");\n const label: NodeLabel = graph.node(v);\n\n graph.setParent(top, v);\n label.borderTop = top;\n graph.setParent(bottom, v);\n label.borderBottom = bottom;\n\n children.forEach(child => {\n dfs(graph, root, nodeSep, weight, height, depths, child);\n\n const childNode: NodeLabel = graph.node(child);\n const childTop: string = childNode.borderTop ? childNode.borderTop : child;\n const childBottom: string = childNode.borderBottom ? childNode.borderBottom : child;\n const thisWeight: number = childNode.borderTop ? weight : 2 * weight;\n const minlen: number = childTop !== childBottom ? 1 : height - (depths[v] ?? 0) + 1;\n\n graph.setEdge(top, childTop, {\n weight: thisWeight,\n minlen: minlen,\n nestingEdge: true\n });\n\n graph.setEdge(childBottom, bottom, {\n weight: thisWeight,\n minlen: minlen,\n nestingEdge: true\n });\n });\n\n if (!graph.parent(v)) {\n graph.setEdge(root, top, {weight: 0, minlen: height + (depths[v] ?? 0)});\n }\n}\n\nfunction treeDepths(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): { [key: string]: number } {\n const depths: { [key: string]: number } = {};\n\n function dfs(v: string, depth: number): void {\n const children: string[] = graph.children(v);\n if (children && children.length) {\n children.forEach(child => dfs(child, depth + 1));\n }\n depths[v] = depth;\n }\n\n graph.children(GRAPH_NODE).forEach(v => dfs(v, 1));\n return depths;\n}\n\nfunction sumWeights(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): number {\n return graph.edges().reduce((acc, e) => acc + graph.edge(e).weight!, 0);\n}\n\nfunction cleanup(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n const graphLabel: GraphLabel = graph.graph();\n graph.removeNode(graphLabel.nestingRoot!);\n delete graphLabel.nestingRoot;\n graph.edges().forEach(e => {\n const edge: EdgeLabel = graph.edge(e);\n if (edge.nestingEdge) {\n graph.removeEdge(e);\n }\n });\n}\n","import {addDummyNode, GRAPH_NODE} from \"./util\";\nimport type {EdgeLabel, Graph, GraphLabel, NodeLabel} from \"./types\";\n\nexport default addBorderSegments;\n\nfunction addBorderSegments(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n function dfs(v: string): void {\n const children: string[] = graph.children(v);\n const node = graph.node(v);\n if (children.length) {\n children.forEach(dfs);\n }\n\n if (Object.hasOwn(node, \"minRank\")) {\n node.borderLeft = [];\n node.borderRight = [];\n for (let rank: number = node.minRank!, maxRank: number = node.maxRank! + 1;\n rank < maxRank;\n ++rank) {\n addBorderNode(graph, \"borderLeft\", \"_bl\", v, node, rank);\n addBorderNode(graph, \"borderRight\", \"_br\", v, node, rank);\n }\n }\n }\n\n graph.children(GRAPH_NODE).forEach(dfs);\n}\n\nfunction addBorderNode(\n graph: Graph<GraphLabel, NodeLabel, EdgeLabel>,\n prop: \"borderLeft\" | \"borderRight\",\n prefix: string,\n sg: string,\n sgNode: EdgeLabel,\n rank: number\n): void {\n const label: Partial<NodeLabel> = {width: 0, height: 0, rank: rank, borderType: prop};\n const prev: string | undefined = (sgNode[prop] as string[])[rank - 1];\n const curr: string = addDummyNode(graph, \"border\", label, prefix);\n (sgNode[prop] as string[])[rank] = curr;\n graph.setParent(curr, sg);\n if (prev) {\n graph.setEdge(prev, curr, {weight: 1});\n }\n}\n","import type {EdgeLabel, Graph, GraphLabel, NodeLabel, Point} from './types';\n\nexport function adjust(graph: Graph): void {\n const rankDir = (graph.graph() as GraphLabel).rankdir?.toLowerCase();\n if (rankDir === 'lr' || rankDir === 'rl') {\n swapWidthHeight(graph);\n }\n}\n\nexport function undo(graph: Graph): void {\n const rankDir = (graph.graph() as GraphLabel).rankdir?.toLowerCase();\n if (rankDir === 'bt' || rankDir === 'rl') {\n reverseY(graph);\n }\n\n if (rankDir === 'lr' || rankDir === 'rl') {\n swapXY(graph);\n swapWidthHeight(graph);\n }\n}\n\nfunction swapWidthHeight(graph: Graph): void {\n graph.nodes().forEach(node => swapWidthHeightOne(graph.node(node) as NodeLabel));\n graph.edges().forEach(edge => swapWidthHeightOne(graph.edge(edge) as EdgeLabel));\n}\n\nfunction swapWidthHeightOne(attrs: NodeLabel | EdgeLabel): void {\n const w = attrs.width;\n attrs.width = attrs.height;\n attrs.height = w;\n}\n\nfunction reverseY(graph: Graph): void {\n graph.nodes().forEach(node => reverseYOne(graph.node(node) as NodeLabel));\n\n graph.edges().forEach(edge => {\n const edgeLabel = graph.edge(edge) as EdgeLabel;\n edgeLabel.points?.forEach(reverseYOne);\n if (Object.hasOwn(edgeLabel, 'y')) {\n reverseYOne(edgeLabel);\n }\n });\n}\n\nfunction reverseYOne(attrs: NodeLabel | EdgeLabel | Point): void {\n attrs.y = -attrs.y!;\n}\n\nfunction swapXY(graph: Graph): void {\n graph.nodes().forEach(node => swapXYOne(graph.node(node) as NodeLabel));\n\n graph.edges().forEach(edge => {\n const edgeLabel = graph.edge(edge) as EdgeLabel;\n edgeLabel.points?.forEach(swapXYOne);\n if (Object.hasOwn(edgeLabel, 'x')) {\n swapXYOne(edgeLabel);\n }\n });\n}\n\nfunction swapXYOne(attrs: NodeLabel | EdgeLabel | Point): void {\n const x = attrs.x;\n attrs.x = attrs.y;\n attrs.y = x;\n}\n","import * as util from \"../util\";\nimport type {Graph} from '../types';\n\n/*\n * Assigns an initial order value for each node by performing a DFS search\n * starting from nodes in the first rank. Nodes are assigned an order in their\n * rank as they are first visited.\n *\n * This approach comes from Gansner, et al., \"A Technique for Drawing Directed\n * Graphs.\"\n *\n * Returns a layering matrix with an array per layer and each layer sorted by\n * the order of its nodes.\n */\nexport default function initOrder(graph: Graph): string[][] {\n const visited: { [key: string]: boolean } = {};\n const simpleNodes = graph.nodes().filter(v => !graph.children(v).length);\n const simpleNodesRanks = simpleNodes.map(v => graph.node(v).rank);\n const maxRank = util.applyWithChunking(Math.max, simpleNodesRanks);\n const layers: string[][] = util.range(maxRank + 1).map(() => []);\n\n function dfs(v: string): void {\n if (visited[v]) return;\n visited[v] = true;\n const node = graph.node(v);\n layers[node.rank]!.push(v);\n const successors = graph.successors(v);\n if (successors) {\n successors.forEach(dfs);\n }\n }\n\n const orderedVs = simpleNodes.sort((a, b) => graph.node(a).rank - graph.node(b).rank);\n orderedVs.forEach(dfs);\n\n return layers;\n}\n","import {zipObject} from \"../util\";\nimport type {Graph} from '../types';\n\n/*\n * A function that takes a layering (an array of layers, each with an array of\n * ordererd nodes) and a graph and returns a weighted crossing count.\n *\n * Pre-conditions:\n *\n * 1. Input graph must be simple (not a multigraph), directed, and include\n * only simple edges.\n * 2. Edges in the input graph must have assigned weights.\n *\n * Post-conditions:\n *\n * 1. The graph and layering matrix are left unchanged.\n *\n * This algorithm is derived from Barth, et al., \"Bilayer Cross Counting.\"\n */\nexport default function crossCount(graph: Graph, layering: string[][]): number {\n let cc = 0;\n for (let i = 1; i < layering.length; ++i) {\n cc += twoLayerCrossCount(graph, layering[i - 1]!, layering[i]!);\n }\n return cc;\n}\n\ninterface SouthEntry {\n pos: number;\n weight: number;\n}\n\nfunction twoLayerCrossCount(graph: Graph, northLayer: string[], southLayer: string[]): number {\n // Sort all of the edges between the north and south layers by their position\n // in the north layer and then the south. Map these edges to the position of\n // their head in the south layer.\n const southPos: { [key: string]: number } = zipObject(southLayer, southLayer.map((v, i) => i));\n const southEntries: SouthEntry[] = northLayer.flatMap(v => {\n const edges = graph.outEdges(v);\n if (!edges) return [];\n return edges.map(e => {\n return {pos: southPos[e.w]!, weight: graph.edge(e).weight};\n }).sort((a, b) => a.pos - b.pos);\n });\n\n // Build the accumulator tree\n let firstIndex = 1;\n while (firstIndex < southLayer.length) firstIndex <<= 1;\n const treeSize = 2 * firstIndex - 1;\n firstIndex -= 1;\n const tree = new Array(treeSize).fill(0);\n\n // Calculate the weighted crossings\n let cc = 0;\n southEntries.forEach((entry: SouthEntry) => {\n let index = entry.pos + firstIndex;\n tree[index] += entry.weight;\n let weightSum = 0;\n while (index > 0) {\n if (index % 2) {\n weightSum += tree[index + 1];\n }\n index = (index - 1) >> 1;\n tree[index] += entry.weight;\n }\n cc += entry.weight * weightSum;\n });\n\n return cc;\n}\n","import type {Graph} from '../types';\n\ninterface BarycenterEntry {\n v: string;\n barycenter?: number;\n weight?: number;\n}\n\nexport default function barycenter(graph: Graph, movable: string[] = []): BarycenterEntry[] {\n return movable.map(v => {\n const inV = graph.inEdges(v);\n if (!inV || !inV.length) {\n return {v: v};\n } else {\n const result = inV.reduce((acc, e) => {\n const edge = graph.edge(e);\n const nodeU = graph.node(e.v);\n return {\n sum: acc.sum + (edge.weight * nodeU.order),\n weight: acc.weight + edge.weight\n };\n }, {sum: 0, weight: 0});\n\n return {\n v: v,\n barycenter: result.sum / result.weight,\n weight: result.weight\n };\n }\n });\n}\n","import * as util from \"../util\";\nimport type {Graph} from '../types';\n\ninterface BarycenterEntry {\n v: string;\n barycenter?: number;\n weight?: number;\n}\n\ninterface MappedEntry {\n indegree: number;\n in: MappedEntry[];\n out: MappedEntry[];\n vs: string[];\n i: number;\n barycenter?: number;\n weight?: number;\n merged?: boolean;\n [key: string]: unknown;\n}\n\nexport interface ResolvedEntry {\n vs: string[];\n i: number;\n barycenter?: number;\n weight?: number;\n}\n\n/*\n * Given a list of entries of the form {v, barycenter, weight} and a\n * constraint graph this function will resolve any conflicts between the\n * constraint graph and the barycenters for the entries. If the barycenters for\n * an entry would violate a constraint in the constraint graph then we coalesce\n * the nodes in the conflict into a new node that respects the contraint and\n * aggregates barycenter and weight information.\n *\n * This implementation is based on the description in Forster, \"A Fast and\n * Simple Hueristic for Constrained Two-Level Crossing Reduction,\" thought it\n * differs in some specific details.\n *\n * Pre-conditions:\n *\n * 1. Each entry has the form {v, barycenter, weight}, or if the node has\n * no barycenter, then {v}.\n *\n * Returns:\n *\n * A new list of entries of the form {vs, i, barycenter, weight}. The list\n * `vs` may either be a singleton or it may be an aggregation of nodes\n * ordered such that they do not violate constraints from the constraint\n * graph. The property `i` is the lowest original index of any of the\n * elements in `vs`.\n */\nexport default function resolveConflicts(entries: BarycenterEntry[], constraintGraph: Graph): ResolvedEntry[] {\n const mappedEntries: { [key: string]: MappedEntry } = {};\n entries.forEach((entry, i) => {\n const tmp: MappedEntry = {\n indegree: 0,\n \"in\": [],\n out: [],\n vs: [entry.v],\n i: i\n };\n if (entry.barycenter !== undefined) {\n tmp.barycenter = entry.barycenter;\n tmp.weight = entry.weight;\n }\n mappedEntries[entry.v] = tmp;\n });\n\n constraintGraph.edges().forEach(e => {\n const entryV = mappedEntries[e.v];\n const entryW = mappedEntries[e.w];\n if (entryV !== undefined && entryW !== undefined) {\n entryW.indegree++;\n entryV.out.push(entryW);\n }\n });\n\n const sourceSet = Object.values(mappedEntries).filter(entry => !entry.indegree);\n\n return doResolveConflicts(sourceSet);\n}\n\nfunction doResolveConflicts(sourceSet: MappedEntry[]): ResolvedEntry[] {\n const entries: MappedEntry[] = [];\n\n function handleIn(vEntry: MappedEntry): (uEntry: MappedEntry) => void {\n return (uEntry: MappedEntry) => {\n if (uEntry.merged) {\n return;\n }\n if (uEntry.barycenter === undefined ||\n vEntry.barycenter === undefined ||\n uEntry.barycenter >= vEntry.barycenter) {\n mergeEntries(vEntry, uEntry);\n }\n };\n }\n\n function handleOut(vEntry: MappedEntry): (wEntry: MappedEntry) => void {\n return (wEntry: MappedEntry) => {\n wEntry[\"in\"].push(vEntry);\n if (--wEntry.indegree === 0) {\n sourceSet.push(wEntry);\n }\n };\n }\n\n while (sourceSet.length) {\n const entry = sourceSet.pop()!;\n entries.push(entry);\n entry[\"in\"].reverse().forEach(handleIn(entry));\n entry.out.forEach(handleOut(entry));\n }\n\n return entries.filter(entry => !entry.merged).map(entry => {\n return util.pick(entry, [\"vs\", \"i\", \"barycenter\", \"weight\"]) as ResolvedEntry;\n }) as ResolvedEntry[];\n}\n\nfunction mergeEntries(target: MappedEntry, source: MappedEntry): void {\n let sum = 0;\n let weight = 0;\n\n if (target.weight) {\n sum += target.barycenter! * target.weight;\n weight += target.weight;\n }\n\n if (source.weight) {\n sum += source.barycenter! * source.weight;\n weight += source.weight;\n }\n\n target.vs = source.vs.concat(target.vs);\n target.barycenter = sum / weight;\n target.weight = weight;\n target.i = Math.min(source.i, target.i);\n source.merged = true;\n}\n","import * as util from \"../util\";\n\ninterface SortEntry {\n vs: string[];\n i: number;\n barycenter?: number;\n weight?: number;\n}\n\ninterface SortResult {\n vs: string[];\n barycenter?: number;\n weight?: number;\n}\n\nexport default function sort(entries: SortEntry[], biasRight?: boolean): SortResult {\n const parts = util.partition(entries, entry => {\n return Object.hasOwn(entry, \"barycenter\");\n });\n const sortable = parts.lhs;\n const unsortable = parts.rhs.sort((a, b) => b.i - a.i);\n const vs: string[][] = [];\n let sum = 0;\n let weight = 0;\n let vsIndex = 0;\n\n sortable.sort(compareWithBias(!!biasRight));\n\n vsIndex = consumeUnsortable(vs, unsortable, vsIndex);\n\n sortable.forEach(entry => {\n vsIndex += entry.vs.length;\n vs.push(entry.vs);\n sum += entry.barycenter! * entry.weight!;\n weight += entry.weight!;\n vsIndex = consumeUnsortable(vs, unsortable, vsIndex);\n });\n\n const result: SortResult = {vs: vs.flat(1) as string[]};\n if (weight) {\n result.barycenter = sum / weight;\n result.weight = weight;\n }\n return result;\n}\n\nfunction consumeUnsortable(vs: string[][], unsortable: SortEntry[], index: number): number {\n let last: SortEntry | undefined;\n while (unsortable.length && (last = unsortable[unsortable.length - 1])!.i <= index) {\n unsortable.pop();\n vs.push(last!.vs);\n index++;\n }\n return index;\n}\n\nfunction compareWithBias(bias: boolean): (entryV: SortEntry, entryW: SortEntry) => number {\n return (entryV: SortEntry, entryW: SortEntry) => {\n if (entryV.barycenter! < entryW.barycenter!) {\n return -1;\n } else if (entryV.barycenter! > entryW.barycenter!) {\n return 1;\n }\n\n return !bias ? entryV.i - entryW.i : entryW.i - entryV.i;\n };\n}\n","import barycenter from \"./barycenter\";\nimport resolveConflicts from \"./resolve-conflicts\";\nimport sort from \"./sort\";\nimport type {Graph} from '../types';\n\ninterface SubgraphResult {\n vs: string[];\n barycenter?: number;\n weight?: number;\n}\n\ninterface BarycenterEntry {\n v: string;\n barycenter?: number;\n weight?: number;\n}\n\nexport default function sortSubgraph(graph: Graph, v: string, constraintGraph: Graph, biasRight?: boolean): SubgraphResult {\n let movable = graph.children(v);\n const node = graph.node(v);\n const bl: string | undefined = node ? (node.borderLeft) : undefined;\n const br: string | undefined = node ? (node.borderRight) : undefined;\n const subgraphs: { [key: string]: SubgraphResult } = {};\n\n if (bl) {\n movable = movable.filter(w => w !== bl && w !== br);\n }\n\n const barycenters = barycenter(graph, movable);\n barycenters.forEach(entry => {\n if (graph.children(entry.v).length) {\n const subgraphResult = sortSubgraph(graph, entry.v, constraintGraph, biasRight);\n subgraphs[entry.v] = subgraphResult;\n if (Object.hasOwn(subgraphResult, \"barycenter\")) {\n mergeBarycenters(entry, subgraphResult);\n }\n }\n });\n\n const entries = resolveConflicts(barycenters, constraintGraph);\n expandSubgraphs(entries, subgraphs);\n\n const result = sort(entries, biasRight);\n\n if (bl && br) {\n result.vs = [bl, result.vs, br].flat(1) as string[];\n const blPredecessors = graph.predecessors(bl);\n if (blPredecessors && blPredecessors.length) {\n const blPred = graph.node(blPredecessors[0]!);\n const brPredecessors = graph.predecessors(br);\n const brPred = graph.node(brPredecessors![0]!);\n if (!Object.hasOwn(result, \"barycenter\")) {\n result.barycenter = 0;\n result.weight = 0;\n }\n result.barycenter = (result.barycenter! * result.weight! +\n blPred.order! + brPred.order!) / (result.weight! + 2);\n result.weight! += 2;\n }\n }\n\n return result;\n}\n\nfunction expandSubgraphs(entries: { vs: string[] }[], subgraphs: { [key: string]: SubgraphResult }): void {\n entries.forEach(entry => {\n entry.vs = entry.vs.flatMap(v => {\n if (subgraphs[v]) {\n return subgraphs[v].vs;\n }\n return v;\n });\n });\n}\n\nfunction mergeBarycenters(target: BarycenterEntry, other: SubgraphResult): void {\n if (target.barycenter !== undefined) {\n target.barycenter = (target.barycenter * target.weight! +\n other.barycenter! * other.weight!) /\n (target.weight! + other.weight!);\n target.weight! += other.weight!;\n } else {\n target.barycenter = other.barycenter;\n target.weight = other.weight;\n }\n}\n","import {Graph} from \"../graph-lib\";\nimport * as util from \"../util\";\nimport type {Graph as GraphType} from '../types';\n\ninterface LayerGraphLabel {\n root: string;\n}\n\n/*\n * Constructs a graph that can be used to sort a layer of nodes. The graph will\n * contain all base and subgraph nodes from the request layer in their original\n * hierarchy and any edges that are incident on these nodes and are of the type\n * requested by the \"relationship\" parameter.\n *\n * Nodes from the requested rank that do not have parents are assigned a root\n * node in the output graph, which is set in the root graph attribute. This\n * makes it easy to walk the hierarchy of movable nodes during ordering.\n *\n * Pre-conditions:\n *\n * 1. Input graph is a DAG\n * 2. Base nodes in the input graph have a rank attribute\n * 3. Subgraph nodes in the input graph has minRank and maxRank attributes\n * 4. Edges have an assigned weight\n * 5. If `nodesWithRank` is not undefined, it must contains only the nodes\n * which belong to `g` and belong to `rank`.\n *\n * Post-conditions:\n *\n * 1. Output graph has all nodes in the movable rank with preserved\n * hierarchy.\n * 2. Root nodes in the movable layer are made children of the node\n * indicated by the root attribute of the graph.\n * 3. Non-movable nodes incident on movable nodes, selected by the\n * relationship parameter, are included in the graph (without hierarchy).\n * 4. Edges incident on movable nodes, selected by the relationship\n * parameter, are added to the output graph.\n * 5. The weights for copied edges are aggregated as need, since the output\n * graph is not a multi-graph.\n */\nexport default function buildLayerGraph(\n graph: GraphType,\n rank: number,\n relationship: \"inEdges\" | \"outEdges\",\n nodesWithRank?: string[]\n): GraphType {\n if (!nodesWithRank) {\n nodesWithRank = graph.nodes();\n }\n const root = createRootNode(graph);\n const result = new Graph({compound: true})\n .setGraph({root: root} as LayerGraphLabel)\n .setDefaultNodeLabel((v: string) => graph.node(v)) as GraphType;\n\n nodesWithRank.forEach((v: string) => {\n const node = graph.node(v);\n const parent = graph.parent(v);\n\n if (node.rank === rank || node.minRank! <= rank && rank <= node.maxRank!) {\n result.setNode(v);\n result.setParent(v, parent || root);\n\n // This assumes we have only short edges!\n const edges = graph[relationship](v);\n if (edges) {\n edges.forEach(e => {\n const u = e.v === v ? e.w : e.v;\n const edge = result.edge(u, v);\n const weight = edge !== undefined ? edge.weight : 0;\n result.setEdge(u, v, {weight: graph.edge(e).weight + weight});\n });\n }\n\n if (Object.hasOwn(node, \"minRank\")) {\n result.setNode(v, {\n borderLeft: node.borderLeft![rank],\n borderRight: node.borderRight![rank]\n });\n }\n }\n });\n\n return result;\n}\n\nfunction createRootNode(graph: GraphType): string {\n let v: string;\n while (graph.hasNode((v = util.uniqueId(\"_root\")))) ;\n return v;\n}\n","import type {Graph} from '../types';\n\nexport default function addSubgraphConstraints(graph: Graph, constraintGraph: Graph, vs: string[]): void {\n const prev: { [key: string]: string } = {};\n let rootPrev: string | undefined;\n\n vs.forEach(v => {\n let child: string | undefined | void = graph.parent(v);\n let parent: string | undefined | void;\n let prevChild: string | undefined;\n while (child) {\n parent = graph.parent(child);\n if (parent) {\n prevChild = prev[parent];\n prev[parent] = child;\n } else {\n prevChild = rootPrev;\n rootPrev = child;\n }\n if (prevChild && prevChild !== child) {\n constraintGraph.setEdge(prevChild, child);\n return;\n }\n child = parent;\n }\n });\n\n /*\n function dfs(v) {\n var children = v ? g.children(v) : g.children();\n if (children.length) {\n var min = Number.POSITIVE_INFINITY,\n subgraphs = [];\n children.forEach(function(child) {\n var childMin = dfs(child);\n if (g.children(child).length) {\n subgraphs.push({ v: child, order: childMin });\n }\n min = Math.min(min, childMin);\n });\n _.sortBy(subgraphs, \"order\").reduce(function(prev, curr) {\n cg.setEdge(prev.v, curr.v);\n return curr;\n });\n return min;\n }\n return g.node(v).order;\n }\n dfs(undefined);\n */\n}\n","import initOrder from \"./init-order\";\nimport crossCount from \"./cross-count\";\nimport sortSubgraph from \"./sort-subgraph\";\nimport buildLayerGraph from \"./build-layer-graph\";\nimport addSubgraphConstraints from \"./add-subgraph-constraints\";\nimport {Graph} from \"../graph-lib\";\nimport * as util from \"../util\";\nimport type {Graph as GraphType, OrderConstraint} from '../types';\n\ninterface OrderOptions {\n customOrder?: (graph: GraphType, order: (g: GraphType, opts: OrderOptions) => void) => void;\n disableOptimalOrderHeuristic?: boolean;\n constraints?: OrderConstraint[];\n}\n\n/*\n * Applies heuristics to minimize edge crossings in the graph and sets the best\n * order solution as an order attribute on each node.\n *\n * Pre-conditions:\n *\n * 1. Graph must be DAG\n * 2. Graph nodes must be objects with a \"rank\" attribute\n * 3. Graph edges must have the \"weight\" attribute\n *\n * Post-conditions:\n *\n * 1. Graph nodes will have an \"order\" attribute based on the results of the\n * algorithm.\n */\nexport default function order(graph: GraphType, opts: OrderOptions = {}): void {\n if (typeof opts.customOrder === 'function') {\n opts.customOrder(graph, order);\n return;\n }\n\n const maxRank = util.maxRank(graph);\n const downLayerGraphs = buildLayerGraphs(graph, util.range(1, maxRank + 1), \"inEdges\");\n const upLayerGraphs = buildLayerGraphs(graph, util.range(maxRank - 1, -1, -1), \"outEdges\");\n\n let layering = initOrder(graph);\n assignOrder(graph, layering);\n\n if (opts.disableOptimalOrderHeuristic) {\n return;\n }\n\n let bestCC = Number.POSITIVE_INFINITY;\n let best: string[][];\n\n const constraints = opts.constraints || [];\n for (let i = 0, lastBest = 0; lastBest < 4; ++i, ++lastBest) {\n sweepLayerGraphs(i % 2 ? downLayerGraphs : upLayerGraphs, i % 4 >= 2, constraints);\n\n layering = util.buildLayerMatrix(graph);\n const cc = crossCount(graph, layering);\n if (cc < bestCC) {\n lastBest = 0;\n best = Object.assign({}, layering);\n bestCC = cc;\n } else if (cc === bestCC) {\n best = structuredClone(layering);\n }\n }\n\n assignOrder(graph, best!);\n}\n\nfunction buildLayerGraphs(graph: GraphType, ranks: number[], relationship: \"inEdges\" | \"outEdges\"): GraphType[] {\n // Build an index mapping from rank to the nodes with that rank.\n // This helps to avoid a quadratic search for all nodes with the same rank as\n // the current node.\n const nodesByRank = new Map<number, string[]>();\n const addNodeToRank = (rank: number, node: string): void => {\n if (!nodesByRank.has(rank)) {\n nodesByRank.set(rank, []);\n }\n nodesByRank.get(rank)!.push(node);\n };\n\n // Visit the nodes in their original order in the graph, and add each\n // node to the ranks(s) that it belongs to.\n for (const v of graph.nodes()) {\n const node = graph.node(v);\n if (typeof node.rank === \"number\") {\n addNodeToRank(node.rank, v);\n }\n // If there is a range of ranks, add it to each, but skip the `node.rank` which\n // has already had the node added.\n if (typeof node.minRank === \"number\" && typeof node.maxRank === \"number\") {\n for (let r = node.minRank; r <= node.maxRank; r++) {\n if (r !== node.rank) {\n // Don't add this node to its `node.rank` twice.\n addNodeToRank(r, v);\n }\n }\n }\n }\n\n return ranks.map(function (rank) {\n return buildLayerGraph(graph, rank, relationship, nodesByRank.get(rank) || []);\n });\n}\n\nfunction sweepLayerGraphs(layerGraphs: GraphType[], biasRight: boolean, constraints: OrderConstraint[]): void {\n const cg = new Graph() as GraphType;\n layerGraphs.forEach(function (lg) {\n constraints.forEach(con => cg.setEdge(con.left, con.right));\n\n const root = (lg.graph() as { root: string }).root;\n const sorted = sortSubgraph(lg, root, cg, biasRight);\n sorted.vs.forEach((v, i) => lg.node(v).order = i);\n addSubgraphConstraints(lg, cg, sorted.vs);\n });\n}\n\nfunction assignOrder(graph: GraphType, layering: string[][]): void {\n Object.values(layering).forEach(layer => layer.forEach((v, i) => graph.node(v).order = i));\n}\n","import {Graph} from \"../graph-lib\";\nimport * as util from \"../util\";\nimport type {EdgeLabel, GraphLabel, NodeLabel} from \"../types\";\n\n/*\n * This module provides coordinate assignment based on Brandes and Köpf, \"Fast\n * and Simple Horizontal Coordinate Assignment.\"\n */\n\nexport {\n positionX,\n findType1Conflicts,\n findType2Conflicts,\n addConflict,\n hasConflict,\n verticalAlignment,\n horizontalCompaction,\n alignCoordinates,\n findSmallestWidthAlignment,\n balance\n};\n\ntype Conflicts = { [key: string]: { [key: string]: boolean } };\ntype PositionMap = { [key: string]: number };\ntype AlignmentResult = { root: { [key: string]: string }, align: { [key: string]: string } };\ntype XssMap = { [key: string]: PositionMap };\n\n/*\n * Marks all edges in the graph with a type-1 conflict with the \"type1Conflict\"\n * property. A type-1 conflict is one where a non-inner segment crosses an\n * inner segment. An inner segment is an edge with both incident nodes marked\n * with the \"dummy\" property.\n *\n * This algorithm scans layer by layer, starting with the second, for type-1\n * conflicts between the current layer and the previous layer. For each layer\n * it scans the nodes from left to right until it reaches one that is incident\n * on an inner segment. It then scans predecessors to determine if they have\n * edges that cross that inner segment. At the end a final scan is done for all\n * nodes on the current rank to see if they cross the last visited inner\n * segment.\n *\n * This algorithm (safely) assumes that a dummy node will only be incident on a\n * single node in the layers being scanned.\n */\nfunction findType1Conflicts(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>, layering: string[][]): Conflicts {\n const conflicts: Conflicts = {};\n\n function visitLayer(prevLayer: string[], layer: string[]): string[] {\n let\n // last visited node in the previous layer that is incident on an inner\n // segment.\n k0 = 0,\n // Tracks the last node in this layer scanned for crossings with a type-1\n // segment.\n scanPos = 0;\n const prevLayerLength = prevLayer.length,\n lastNode = layer[layer.length - 1];\n\n layer.forEach((v, i) => {\n const w: string | undefined = findOtherInnerSegmentNode(graph, v);\n const k1: number = w ? graph.node(w).order! : prevLayerLength;\n\n if (w || v === lastNode) {\n layer.slice(scanPos, i + 1).forEach(scanNode => {\n const preds = graph.predecessors(scanNode);\n if (preds) {\n preds.forEach(u => {\n const uLabel = graph.node(u) as NodeLabel;\n const uPos: number = uLabel.order!;\n if ((uPos < k0 || k1 < uPos) &&\n !(uLabel.dummy && (graph.node(scanNode) as NodeLabel).dummy)) {\n addConflict(conflicts, u, scanNode);\n }\n });\n }\n });\n scanPos = i + 1;\n k0 = k1;\n }\n });\n\n return layer;\n }\n\n if (layering.length) {\n layering.reduce(visitLayer);\n }\n\n return conflicts;\n}\n\nfunction findType2Conflicts(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>, layering: string[][]): Conflicts {\n const conflicts: Conflicts = {};\n\n function scan(south: string[], southPos: number, southEnd: number, prevNorthBorder: number, nextNorthBorder: number): void {\n util.range(southPos, southEnd).forEach(i => {\n const v = south[i];\n if (v === undefined) return;\n if ((graph.node(v) as NodeLabel).dummy) {\n const preds = graph.predecessors(v);\n if (preds) {\n preds.forEach(u => {\n if (u === undefined) return;\n const uNode = graph.node(u) as NodeLabel;\n if (uNode.dummy &&\n (uNode.order! < prevNorthBorder || uNode.order! > nextNorthBorder)) {\n addConflict(conflicts, u, v);\n }\n });\n }\n }\n });\n }\n\n\n function visitLayer(north: string[], south: string[]): string[] {\n let prevNorthPos = -1;\n let nextNorthPos = -1;\n let southPos = 0;\n\n south.forEach((v, southLookahead) => {\n if ((graph.node(v) as NodeLabel).dummy === \"border\") {\n const predecessors = graph.predecessors(v);\n if (predecessors && predecessors.length) {\n const firstPred = predecessors[0];\n if (firstPred === undefined) return;\n nextNorthPos = (graph.node(firstPred) as NodeLabel).order!;\n scan(south, southPos, southLookahead, prevNorthPos, nextNorthPos);\n southPos = southLookahead;\n prevNorthPos = nextNorthPos;\n }\n }\n scan(south, southPos, south.length, nextNorthPos, north.length);\n });\n\n return south;\n }\n\n if (layering.length) {\n layering.reduce(visitLayer);\n }\n\n return conflicts;\n}\n\nfunction findOtherInnerSegmentNode(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>, v: string): string | undefined {\n if ((graph.node(v) as NodeLabel).dummy) {\n const preds = graph.predecessors(v);\n if (preds) {\n return preds.find(u => (graph.node(u) as NodeLabel).dummy);\n }\n }\n return undefined;\n}\n\nfunction addConflict(conflicts: Conflicts, v: string, w: string): void {\n if (v > w) {\n const tmp = v;\n v = w;\n w = tmp;\n }\n\n let conflictsV = conflicts[v];\n if (!conflictsV) {\n conflicts[v] = conflictsV = {};\n }\n conflictsV[w] = true;\n}\n\nfunction hasConflict(conflicts: Conflicts, v: string, w: string): boolean {\n if (v > w) {\n const tmp = v;\n v = w;\n w = tmp;\n }\n const conflictsV = conflicts[v];\n return conflictsV !== undefined && Object.hasOwn(conflictsV, w);\n}\n\n/*\n * Try to align nodes into vertical \"blocks\" where possible. This algorithm\n * attempts to align a node with one of its median neighbors. If the edge\n * connecting a neighbor is a type-1 conflict then we ignore that possibility.\n * If a previous node has already formed a block with a node after the node\n * we're trying to form a block with, we also ignore that possibility - our\n * blocks would be split in that scenario.\n */\nfunction verticalAlignment(\n graph: Graph<GraphLabel, NodeLabel, EdgeLabel>,\n layering: string[][],\n conflicts: Conflicts,\n neighborFn: (v: string) => string[]\n): AlignmentResult {\n const root: { [key: string]: string } = {};\n const align: { [key: string]: string } = {};\n const pos: PositionMap = {};\n\n // We cache the position here based on the layering because the graph and\n // layering may be out of sync. The layering matrix is manipulated to\n // generate different extreme alignments.\n layering.forEach(layer => {\n layer.forEach((v, order) => {\n root[v] = v;\n align[v] = v;\n pos[v] = order;\n });\n });\n\n layering.forEach(layer => {\n let prevIdx = -1;\n layer.forEach(v => {\n const wsRaw = neighborFn(v);\n if (wsRaw && wsRaw.length) {\n const ws: string[] = wsRaw.sort((a, b) => {\n const posA = pos[a];\n const posB = pos[b];\n return (posA !== undefined ? posA : 0) - (posB !== undefined ? posB : 0);\n });\n const mp: number = (ws.length - 1) / 2;\n for (let i = Math.floor(mp), il = Math.ceil(mp); i <= il; ++i) {\n const w: string | undefined = ws[i];\n if (w === undefined) continue;\n const posW = pos[w];\n if (posW !== undefined && align[v] === v &&\n prevIdx < posW &&\n !hasConflict(conflicts, v, w)) {\n const rootW = root[w];\n if (rootW !== undefined) {\n align[w] = v;\n align[v] = root[v] = rootW;\n prevIdx = posW;\n }\n }\n }\n }\n });\n });\n\n return {root: root, align: align};\n}\n\nfunction horizontalCompaction(\n graph: Graph<GraphLabel, NodeLabel, EdgeLabel>,\n layering: string[][],\n root: { [key: string]: string },\n align: { [key: string]: string },\n reverseSep: boolean = false\n): PositionMap {\n // This portion of the algorithm differs from BK due to a number of problems.\n // Instead of their algorithm we construct a new block graph and do two\n // sweeps. The first sweep places blocks with the smallest possible\n // coordinates. The second sweep removes unused space by moving blocks to the\n // greatest coordinates without violating separation.\n const xs: PositionMap = {};\n const blockG: Graph<NodeLabel, EdgeLabel, number> = buildBlockGraph(graph, layering, root, reverseSep);\n const borderType: string = reverseSep ? \"borderLeft\" : \"borderRight\";\n\n function iterate(setXsFunc: (elem: string) => void, nextNodesFunc: (elem: string) => string[]): void {\n const stack: string[] = blockG.nodes().slice(); // Create a copy of the node list.\n const visited: { [key: string]: boolean } = {};\n let elem: string | undefined = stack.pop();\n\n while (elem) {\n if (visited[elem]) {\n setXsFunc(elem);\n } else {\n visited[elem] = true;\n // Put the element back into the stack, so that we can process it\n // again after all of the `nextNodesFunc` items are processed.\n stack.push(elem);\n for (const nextElem of nextNodesFunc(elem)) {\n stack.push(nextElem);\n }\n }\n\n elem = stack.pop();\n }\n }\n\n // First pass, assign smallest coordinates\n function pass1(elem: string): void {\n const inEdges = blockG.inEdges(elem);\n if (inEdges) {\n xs[elem] = inEdges.reduce((acc, e) => {\n const xsV = xs[e.v] ?? 0;\n const edgeWeight = blockG.edge(e);\n return Math.max(acc, xsV + (edgeWeight !== undefined ? edgeWeight : 0));\n }, 0);\n } else {\n xs[elem] = 0;\n }\n }\n\n // Second pass, assign greatest coordinates\n function pass2(elem: string): void {\n const outEdges = blockG.outEdges(elem);\n let min = Number.POSITIVE_INFINITY;\n if (outEdges) {\n min = outEdges.reduce((acc, e) => {\n const xsW = xs[e.w];\n const edgeWeight = blockG.edge(e);\n return Math.min(acc, (xsW !== undefined ? xsW : 0) - (edgeWeight !== undefined ? edgeWeight : 0));\n }, Number.POSITIVE_INFINITY);\n }\n\n const node = graph.node(elem) as NodeLabel;\n if (min !== Number.POSITIVE_INFINITY && node.borderType !== borderType) {\n xs[elem] = Math.max(xs[elem] !== undefined ? xs[elem] : 0, min);\n }\n }\n\n function predecessorsWrapper(elem: string): string[] {\n return blockG.predecessors(elem) || [];\n }\n\n function successorsWrapper(elem: string): string[] {\n return blockG.successors(elem) || [];\n }\n\n iterate(pass1, predecessorsWrapper);\n iterate(pass2, successorsWrapper);\n\n // Assign x coordinates to all nodes\n Object.keys(align).forEach(v => {\n const rootV = root[v];\n if (rootV !== undefined) {\n xs[v] = xs[rootV] ?? 0;\n }\n });\n\n return xs;\n}\n\n\nfunction buildBlockGraph(\n graph: Graph<GraphLabel, NodeLabel, EdgeLabel>,\n layering: string[][],\n root: { [key: string]: string },\n reverseSep: boolean\n): Graph<NodeLabel, EdgeLabel, number> {\n const blockGraph = new Graph<NodeLabel, EdgeLabel, number>();\n const graphLabel: GraphLabel = graph.graph();\n const sepFn: (g: Graph<GraphLabel, NodeLabel, EdgeLabel>, v: string, u: string) => number = sep(graphLabel.nodesep!, graphLabel.edgesep!, reverseSep);\n\n layering.forEach(layer => {\n let u: string | undefined;\n layer.forEach(v => {\n const vRoot = root[v];\n if (vRoot !== undefined) {\n blockGraph.setNode(vRoot);\n if (u !== undefined) {\n const uRoot = root[u];\n if (uRoot !== undefined) {\n const prevMax: number | undefined = blockGraph.edge(uRoot, vRoot);\n blockGraph.setEdge(uRoot, vRoot, Math.max(sepFn(graph, v, u), prevMax || 0));\n }\n }\n u = v;\n }\n });\n });\n\n return blockGraph;\n}\n\n/*\n * Returns the alignment that has the smallest width of the given alignments.\n */\nfunction findSmallestWidthAlignment(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>, xss: XssMap): PositionMap {\n return Object.values(xss).reduce((currentMinAndXs: [number, PositionMap | null], xs: PositionMap) => {\n let max = Number.NEGATIVE_INFINITY;\n let min = Number.POSITIVE_INFINITY;\n\n Object.entries(xs).forEach(([v, x]) => {\n const halfWidth: number = width(graph, v) / 2;\n\n max = Math.max(x + halfWidth, max);\n min = Math.min(x - halfWidth, min);\n });\n\n const newMin: number = max - min;\n if (newMin < currentMinAndXs[0]) {\n currentMinAndXs = [newMin, xs];\n }\n return currentMinAndXs;\n }, [Number.POSITIVE_INFINITY, null])[1]!;\n}\n\n/*\n * Align the coordinates of each of the layout alignments such that\n * left-biased alignments have their minimum coordinate at the same point as\n * the minimum coordinate of the smallest width alignment and right-biased\n * alignments have their maximum coordinate at the same point as the maximum\n * coordinate of the smallest width alignment.\n */\nfunction alignCoordinates(xss: XssMap, alignTo: PositionMap): void {\n const alignToVals: number[] = Object.values(alignTo);\n const alignToMin: number = util.applyWithChunking(Math.min, alignToVals);\n const alignToMax: number = util.applyWithChunking(Math.max, alignToVals);\n\n [\"u\", \"d\"].forEach(vert => {\n [\"l\", \"r\"].forEach(horiz => {\n const alignment: string = vert + horiz;\n const xs: PositionMap | undefined = xss[alignment];\n\n if (!xs || xs === alignTo) return;\n\n const xsVals: number[] = Object.values(xs);\n let delta: number = alignToMin - util.applyWithChunking(Math.min, xsVals);\n if (horiz !== \"l\") {\n delta = alignToMax - util.applyWithChunking(Math.max, xsVals);\n }\n\n if (delta) {\n xss[alignment] = util.mapValues(xs, x => x + delta);\n }\n });\n });\n}\n\nfunction balance(xss: XssMap, align: string | undefined = undefined): PositionMap {\n const ulMap = xss.ul;\n if (!ulMap) {\n return {};\n }\n return util.mapValues(ulMap, (num: number, v: string) => {\n if (align) {\n const alignmentKey = align.toLowerCase();\n const alignment = xss[alignmentKey];\n if (alignment && alignment[v] !== undefined) {\n return alignment[v];\n }\n }\n const xs: number[] = Object.values(xss).map(xs => {\n const val = xs[v];\n return val !== undefined ? val : 0;\n }).sort((a, b) => a - b);\n return ((xs[1] ?? 0) + (xs[2] ?? 0)) / 2;\n });\n}\n\nfunction positionX(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): PositionMap {\n const layering: string[][] = util.buildLayerMatrix(graph);\n const conflicts: Conflicts = Object.assign(\n findType1Conflicts(graph, layering),\n findType2Conflicts(graph, layering));\n\n const xss: XssMap = {};\n let adjustedLayering: string[][];\n [\"u\", \"d\"].forEach(vert => {\n adjustedLayering = vert === \"u\" ? layering : Object.values(layering).reverse();\n [\"l\", \"r\"].forEach(horiz => {\n if (horiz === \"r\") {\n adjustedLayering = adjustedLayering.map(inner => {\n return Object.values(inner).reverse();\n });\n }\n\n const neighborFn = (v: string): string[] => {\n const result = vert === \"u\" ? graph.predecessors(v) : graph.successors(v);\n return result || [];\n };\n const align: AlignmentResult = verticalAlignment(graph, adjustedLayering, conflicts, neighborFn);\n let xs: PositionMap = horizontalCompaction(graph, adjustedLayering,\n align.root, align.align, horiz === \"r\");\n if (horiz === \"r\") {\n xs = util.mapValues(xs, x => -x);\n }\n xss[vert + horiz] = xs;\n });\n });\n\n\n const smallestWidth: PositionMap = findSmallestWidthAlignment(graph, xss);\n alignCoordinates(xss, smallestWidth);\n return balance(xss, graph.graph().align);\n}\n\nfunction sep(nodeSep: number, edgeSep: number, reverseSep: boolean): (g: Graph<GraphLabel, NodeLabel, EdgeLabel>, v: string, w: string) => number {\n return (g: Graph<GraphLabel, NodeLabel, EdgeLabel>, v: string, w: string): number => {\n const vLabel = g.node(v) as NodeLabel;\n const wLabel = g.node(w) as NodeLabel;\n let sum = 0;\n let delta: number | undefined;\n\n sum += vLabel.width / 2;\n if (Object.hasOwn(vLabel, \"labelpos\")) {\n switch ((vLabel.labelpos as string).toLowerCase()) {\n case \"l\":\n delta = -vLabel.width / 2;\n break;\n case \"r\":\n delta = vLabel.width / 2;\n break;\n }\n }\n if (delta) {\n sum += reverseSep ? delta : -delta;\n }\n delta = undefined;\n\n sum += (vLabel.dummy ? edgeSep : nodeSep) / 2;\n sum += (wLabel.dummy ? edgeSep : nodeSep) / 2;\n\n sum += wLabel.width / 2;\n if (Object.hasOwn(wLabel, \"labelpos\")) {\n switch ((wLabel.labelpos as string).toLowerCase()) {\n case \"l\":\n delta = wLabel.width / 2;\n break;\n case \"r\":\n delta = -wLabel.width / 2;\n break;\n }\n }\n if (delta) {\n sum += reverseSep ? delta : -delta;\n }\n\n return sum;\n };\n}\n\nfunction width(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>, v: string): number {\n return (graph.node(v) as NodeLabel).width;\n}\n","import * as util from \"../util\";\nimport {positionX} from \"./bk\";\nimport type {Graph} from '@dagrejs/graphlib';\nimport type {EdgeLabel, GraphLabel, NodeLabel} from \"../types\";\n\nexport {position};\n\nfunction position(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n graph = util.asNonCompoundGraph(graph);\n\n positionY(graph);\n Object.entries(positionX(graph)).forEach(([v, x]) => graph.node(v).x = x);\n}\n\nfunction positionY(graph: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n const layering: string[][] = util.buildLayerMatrix(graph);\n const graphLabel = graph.graph();\n const rankSep: number = graphLabel.ranksep!;\n const rankAlign: string | undefined = graphLabel.rankalign;\n let prevY = 0;\n layering.forEach(layer => {\n const maxHeight: number = layer.reduce((acc: number, v: string) => {\n const height: number = graph.node(v).height ?? 0;\n if (acc > height) {\n return acc;\n } else {\n return height;\n }\n }, 0);\n layer.forEach(v => {\n const node = graph.node(v) as NodeLabel;\n if (rankAlign === \"top\") {\n node.y = prevY + node.height / 2;\n } else if (rankAlign === \"bottom\") {\n node.y = prevY + maxHeight - node.height / 2;\n } else {\n node.y = prevY + maxHeight / 2;\n }\n });\n prevY += maxHeight + rankSep;\n });\n}\n","import * as acyclic from \"./acyclic\";\nimport * as normalize from \"./normalize\";\nimport rank from \"./rank\";\nimport * as util from \"./util\";\nimport {normalizeRanks, removeEmptyRanks} from \"./util\";\nimport parentDummyChains from \"./parent-dummy-chains\";\nimport * as nestingGraph from \"./nesting-graph\";\nimport addBorderSegments from \"./add-border-segments\";\nimport * as coordinateSystem from \"./coordinate-system\";\nimport order from \"./order\";\nimport {position} from \"./position\";\nimport {Graph} from \"./graph-lib\";\nimport type {Edge, EdgeLabel, GraphLabel, LayoutOptions, NodeLabel, Point} from \"./types\";\n\ninterface SelfEdge {\n e: Edge;\n label: EdgeLabel;\n}\n\ninterface ExtendedNodeLabel extends NodeLabel {\n selfEdges?: SelfEdge[];\n}\n\ninterface SelfEdgeNodeLabel extends Omit<NodeLabel, 'e' | 'label'> {\n e: Edge;\n label: EdgeLabel;\n}\n\ninterface EdgeProxyNodeLabel extends Omit<NodeLabel, 'e'> {\n e: Edge;\n}\n\nexport function layout(g: Graph<GraphLabel, NodeLabel, EdgeLabel>, opts: LayoutOptions = {}): Graph<GraphLabel, NodeLabel, EdgeLabel> {\n const time = opts.debugTiming ? util.time : util.notime;\n return time(\"layout\", () => {\n const layoutGraph =\n time(\" buildLayoutGraph\", () => buildLayoutGraph(g));\n time(\" runLayout\", () => runLayout(layoutGraph, time, opts));\n time(\" updateInputGraph\", () => updateInputGraph(g, layoutGraph));\n return layoutGraph;\n });\n}\n\nfunction runLayout(\n g: Graph<GraphLabel, NodeLabel, EdgeLabel>,\n time: <T>(name: string, fn: () => T) => T,\n opts: LayoutOptions\n): void {\n time(\" makeSpaceForEdgeLabels\", () => makeSpaceForEdgeLabels(g));\n time(\" removeSelfEdges\", () => removeSelfEdges(g));\n time(\" acyclic\", () => acyclic.run(g));\n time(\" nestingGraph.run\", () => nestingGraph.run(g));\n time(\" rank\", () => rank(util.asNonCompoundGraph(g)));\n time(\" injectEdgeLabelProxies\", () => injectEdgeLabelProxies(g));\n time(\" removeEmptyRanks\", () => removeEmptyRanks(g));\n time(\" nestingGraph.cleanup\", () => nestingGraph.cleanup(g));\n time(\" normalizeRanks\", () => normalizeRanks(g));\n time(\" assignRankMinMax\", () => assignRankMinMax(g));\n time(\" removeEdgeLabelProxies\", () => removeEdgeLabelProxies(g));\n time(\" normalize.run\", () => normalize.run(g));\n time(\" parentDummyChains\", () => parentDummyChains(g));\n time(\" addBorderSegments\", () => addBorderSegments(g));\n time(\" order\", () => order(g, opts));\n time(\" insertSelfEdges\", () => insertSelfEdges(g));\n time(\" adjustCoordinateSystem\", () => coordinateSystem.adjust(g));\n time(\" position\", () => position(g));\n time(\" positionSelfEdges\", () => positionSelfEdges(g));\n time(\" removeBorderNodes\", () => removeBorderNodes(g));\n time(\" normalize.undo\", () => normalize.undo(g));\n time(\" fixupEdgeLabelCoords\", () => fixupEdgeLabelCoords(g));\n time(\" undoCoordinateSystem\", () => coordinateSystem.undo(g));\n time(\" translateGraph\", () => translateGraph(g));\n time(\" assignNodeIntersects\", () => assignNodeIntersects(g));\n time(\" reversePoints\", () => reversePointsForReversedEdges(g));\n time(\" acyclic.undo\", () => acyclic.undo(g));\n}\n\n/*\n * Copies final layout information from the layout graph back to the input\n * graph. This process only copies whitelisted attributes from the layout graph\n * to the input graph, so it serves as a good place to determine what\n * attributes can influence layout.\n */\nfunction updateInputGraph(\n inputGraph: Graph<GraphLabel, NodeLabel, EdgeLabel>,\n layoutGraph: Graph<GraphLabel, NodeLabel, EdgeLabel>\n): void {\n inputGraph.nodes().forEach(v => {\n const inputLabel = inputGraph.node(v);\n const layoutLabel = layoutGraph.node(v);\n\n if (inputLabel) {\n inputLabel.x = layoutLabel.x;\n inputLabel.y = layoutLabel.y;\n inputLabel.order = layoutLabel.order;\n inputLabel.rank = layoutLabel.rank;\n\n if (layoutGraph.children(v).length) {\n inputLabel.width = layoutLabel.width;\n inputLabel.height = layoutLabel.height;\n }\n }\n });\n\n inputGraph.edges().forEach(e => {\n const inputLabel = inputGraph.edge(e);\n const layoutLabel = layoutGraph.edge(e);\n\n inputLabel.points = layoutLabel.points;\n if (Object.hasOwn(layoutLabel, \"x\")) {\n inputLabel.x = layoutLabel.x;\n inputLabel.y = layoutLabel.y;\n }\n });\n\n inputGraph.graph().width = layoutGraph.graph().width;\n inputGraph.graph().height = layoutGraph.graph().height;\n}\n\nconst graphNumAttrs: string[] = [\"nodesep\", \"edgesep\", \"ranksep\", \"marginx\", \"marginy\"];\nconst graphDefaults: Partial<GraphLabel> = {ranksep: 50, edgesep: 20, nodesep: 50, rankdir: \"TB\", rankalign: \"center\"};\nconst graphAttrs: string[] = [\"acyclicer\", \"ranker\", \"rankdir\", \"align\", \"rankalign\"];\nconst nodeNumAttrs: string[] = [\"width\", \"height\", \"rank\"];\nconst nodeDefaults: Partial<NodeLabel> = {width: 0, height: 0};\nconst edgeNumAttrs: string[] = [\"minlen\", \"weight\", \"width\", \"height\", \"labeloffset\"];\nconst edgeDefaults: Partial<EdgeLabel> = {\n minlen: 1, weight: 1, width: 0, height: 0,\n labeloffset: 10, labelpos: \"r\"\n};\nconst edgeAttrs: string[] = [\"labelpos\"];\n\n/*\n * Constructs a new graph from the input graph, which can be used for layout.\n * This process copies only whitelisted attributes from the input graph to the\n * layout graph. Thus this function serves as a good place to determine what\n * attributes can influence layout.\n */\nfunction buildLayoutGraph(inputGraph: Graph<GraphLabel, NodeLabel, EdgeLabel>): Graph<GraphLabel, NodeLabel, EdgeLabel> {\n const g = new Graph<GraphLabel, NodeLabel, EdgeLabel>({multigraph: true, compound: true});\n const graph = canonicalize(inputGraph.graph());\n\n g.setGraph(Object.assign({},\n graphDefaults,\n selectNumberAttrs(graph, graphNumAttrs),\n util.pick(graph, graphAttrs)));\n\n inputGraph.nodes().forEach(v => {\n const node = canonicalize(inputGraph.node(v));\n const newNode = selectNumberAttrs(node, nodeNumAttrs) as NodeLabel;\n Object.keys(nodeDefaults).forEach(k => {\n if (newNode[k] === undefined) {\n newNode[k] = (nodeDefaults)[k];\n }\n });\n\n g.setNode(v, newNode);\n const parent = inputGraph.parent(v);\n if (parent !== undefined) {\n g.setParent(v, parent);\n }\n });\n\n inputGraph.edges().forEach(e => {\n const edge = canonicalize(inputGraph.edge(e));\n g.setEdge(e, Object.assign({},\n edgeDefaults,\n selectNumberAttrs(edge, edgeNumAttrs),\n util.pick(edge, edgeAttrs)));\n });\n\n return g;\n}\n\n/*\n * This idea comes from the Gansner paper: to account for edge labels in our\n * layout we split each rank in half by doubling minlen and halving ranksep.\n * Then we can place labels at these mid-points between nodes.\n *\n * We also add some minimal padding to the width to push the label for the edge\n * away from the edge itself a bit.\n */\nfunction makeSpaceForEdgeLabels(g: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n const graph = g.graph();\n graph.ranksep! /= 2;\n g.edges().forEach(e => {\n const edge = g.edge(e);\n edge.minlen! *= 2;\n if (edge.labelpos!.toLowerCase() !== \"c\") {\n if (graph.rankdir === \"TB\" || graph.rankdir === \"BT\") {\n edge.width! += edge.labeloffset!;\n } else {\n edge.height! += edge.labeloffset!;\n }\n }\n });\n}\n\n/*\n * Creates temporary dummy nodes that capture the rank in which each edge's\n * label is going to, if it has one of non-zero width and height. We do this\n * so that we can safely remove empty ranks while preserving balance for the\n * label's position.\n */\nfunction injectEdgeLabelProxies(g: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n g.edges().forEach(e => {\n const edge = g.edge(e);\n if (edge.width && edge.height) {\n const v = g.node(e.v);\n const w = g.node(e.w);\n const label: Partial<NodeLabel> = {rank: (w.rank! - v.rank!) / 2 + v.rank!, e: e as unknown as number};\n util.addDummyNode(g, \"edge-proxy\", label, \"_ep\");\n }\n });\n}\n\nfunction assignRankMinMax(g: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n let maxRank = 0;\n g.nodes().forEach(v => {\n const node = g.node(v);\n if (node.borderTop) {\n node.minRank = g.node(node.borderTop).rank;\n node.maxRank = g.node(node.borderBottom!).rank;\n maxRank = Math.max(maxRank, node.maxRank!);\n }\n });\n g.graph().maxRank = maxRank;\n}\n\nfunction removeEdgeLabelProxies(g: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n g.nodes().forEach(v => {\n const node = g.node(v);\n if (node.dummy === \"edge-proxy\") {\n const proxyNode = node as unknown as EdgeProxyNodeLabel;\n g.edge(proxyNode.e).labelRank = node.rank;\n g.removeNode(v);\n }\n });\n}\n\nfunction translateGraph(g: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n let minX = Number.POSITIVE_INFINITY;\n let maxX = 0;\n let minY = Number.POSITIVE_INFINITY;\n let maxY = 0;\n const graphLabel = g.graph();\n const marginX = graphLabel.marginx || 0;\n const marginY = graphLabel.marginy || 0;\n\n function getExtremes(attrs: NodeLabel | EdgeLabel): void {\n const x = attrs.x!;\n const y = attrs.y!;\n const w = attrs.width!;\n const h = attrs.height!;\n minX = Math.min(minX, x - w / 2);\n maxX = Math.max(maxX, x + w / 2);\n minY = Math.min(minY, y - h / 2);\n maxY = Math.max(maxY, y + h / 2);\n }\n\n g.nodes().forEach(v => getExtremes(g.node(v)));\n g.edges().forEach(e => {\n const edge = g.edge(e);\n if (Object.hasOwn(edge, \"x\")) {\n getExtremes(edge);\n }\n });\n\n minX -= marginX;\n minY -= marginY;\n\n g.nodes().forEach(v => {\n const node = g.node(v);\n node.x! -= minX;\n node.y! -= minY;\n });\n\n g.edges().forEach(e => {\n const edge = g.edge(e);\n edge.points!.forEach(p => {\n p.x -= minX;\n p.y -= minY;\n });\n if (Object.hasOwn(edge, \"x\")) {\n edge.x! -= minX;\n }\n if (Object.hasOwn(edge, \"y\")) {\n edge.y! -= minY;\n }\n });\n\n graphLabel.width = maxX - minX + marginX;\n graphLabel.height = maxY - minY + marginY;\n}\n\nfunction assignNodeIntersects(g: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n g.edges().forEach(e => {\n const edge = g.edge(e);\n const nodeV = g.node(e.v);\n const nodeW = g.node(e.w);\n let p1: Point, p2: Point;\n if (!edge.points) {\n edge.points = [];\n p1 = nodeW as Point;\n p2 = nodeV as Point;\n } else {\n p1 = edge.points[0]!;\n p2 = edge.points[edge.points.length - 1]!;\n }\n edge.points.unshift(util.intersectRect(nodeV, p1));\n edge.points.push(util.intersectRect(nodeW, p2));\n });\n}\n\nfunction fixupEdgeLabelCoords(g: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n g.edges().forEach(e => {\n const edge = g.edge(e);\n if (Object.hasOwn(edge, \"x\")) {\n if (edge.labelpos === \"l\" || edge.labelpos === \"r\") {\n edge.width! -= edge.labeloffset!;\n }\n switch (edge.labelpos) {\n case \"l\":\n edge.x! -= edge.width! / 2 + edge.labeloffset!;\n break;\n case \"r\":\n edge.x! += edge.width! / 2 + edge.labeloffset!;\n break;\n }\n }\n });\n}\n\nfunction reversePointsForReversedEdges(g: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n g.edges().forEach(e => {\n const edge = g.edge(e);\n if (edge.reversed) {\n edge.points!.reverse();\n }\n });\n}\n\nfunction removeBorderNodes(g: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n g.nodes().forEach(v => {\n if (g.children(v).length) {\n const node = g.node(v);\n const t = g.node(node.borderTop!);\n const b = g.node(node.borderBottom!);\n const l = g.node(node.borderLeft![node.borderLeft!.length - 1]!);\n const r = g.node(node.borderRight![node.borderRight!.length - 1]!);\n\n node.width = Math.abs(r.x! - l.x!);\n node.height = Math.abs(b.y! - t.y!);\n node.x = l.x! + node.width / 2;\n node.y = t.y! + node.height / 2;\n }\n });\n\n g.nodes().forEach(v => {\n if (g.node(v).dummy === \"border\") {\n g.removeNode(v);\n }\n });\n}\n\nfunction removeSelfEdges(g: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n g.edges().forEach(e => {\n if (e.v === e.w) {\n const node = g.node(e.v) as ExtendedNodeLabel;\n if (!node.selfEdges) {\n node.selfEdges = [];\n }\n node.selfEdges.push({e: e, label: g.edge(e)});\n g.removeEdge(e);\n }\n });\n}\n\nfunction insertSelfEdges(g: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n const layers = util.buildLayerMatrix(g);\n layers.forEach(layer => {\n let orderShift = 0;\n layer.forEach((v, i) => {\n const node = g.node(v) as ExtendedNodeLabel;\n node.order = i + orderShift;\n (node.selfEdges || []).forEach(selfEdge => {\n util.addDummyNode(g, \"selfedge\", {\n width: selfEdge.label.width!,\n height: selfEdge.label.height!,\n rank: node.rank,\n order: i + (++orderShift),\n e: selfEdge.e as unknown as number,\n label: selfEdge.label as unknown as string\n }, \"_se\");\n });\n delete node.selfEdges;\n });\n });\n}\n\nfunction positionSelfEdges(g: Graph<GraphLabel, NodeLabel, EdgeLabel>): void {\n g.nodes().forEach(v => {\n const node = g.node(v);\n if (node.dummy === \"selfedge\") {\n const selfEdgeNode = node as unknown as SelfEdgeNodeLabel;\n const selfNode = g.node(selfEdgeNode.e.v);\n const x = selfNode.x! + selfNode.width / 2;\n const y = selfNode.y!;\n const dx = node.x! - x;\n const dy = selfNode.height / 2;\n g.setEdge(selfEdgeNode.e, selfEdgeNode.label);\n g.removeNode(v);\n selfEdgeNode.label.points = [\n {x: x + 2 * dx / 3, y: y - dy},\n {x: x + 5 * dx / 6, y: y - dy},\n {x: x + dx, y: y},\n {x: x + 5 * dx / 6, y: y + dy},\n {x: x + 2 * dx / 3, y: y + dy}\n ];\n selfEdgeNode.label.x = node.x;\n selfEdgeNode.label.y = node.y;\n }\n });\n}\n\nfunction selectNumberAttrs(obj: Record<string, unknown>, attrs: string[]): unknown {\n return util.mapValues(util.pick(obj, attrs), Number);\n}\n\nfunction canonicalize(attrs: Record<string, unknown>): Record<string, unknown> {\n const newAttrs: Record<string, unknown> = {};\n if (attrs) {\n Object.entries(attrs).forEach(([k, v]) => {\n if (typeof k === \"string\") {\n k = k.toLowerCase();\n }\n\n newAttrs[k] = v;\n });\n }\n return newAttrs;\n}\n","import * as util from './util';\nimport {Graph} from \"./graph-lib\";\nimport type {NodeLabel} from './types';\n\nexport function debugOrdering(graph: Graph): Graph {\n const layerMatrix = util.buildLayerMatrix(graph);\n\n const h = new Graph({compound: true, multigraph: true}).setGraph({});\n\n graph.nodes().forEach(node => {\n h.setNode(node, {label: node});\n h.setParent(node, 'layer' + (graph.node(node) as NodeLabel).rank);\n });\n\n graph.edges().forEach(edge => h.setEdge(edge.v, edge.w, {}, edge.name));\n\n layerMatrix.forEach((layer, i) => {\n const layerV = 'layer' + i;\n h.setNode(layerV, {rank: 'same'});\n layer.reduce((u, v) => {\n h.setEdge(u, v, {style: 'invis'});\n return v;\n });\n });\n\n return h;\n}\n","/*\n@license\n\nCopyright (c) 2012-2014 Chris Pettitt\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n*/\n\nimport * as graphlib from '@dagrejs/graphlib';\nimport {notime, time} from './lib/util';\nimport {version} from './lib/version';\nimport {layout} from './lib/layout';\nimport {debugOrdering as debug} from './lib/debug';\n\nexport {graphlib};\n\nexport {Graph} from '@dagrejs/graphlib';\nexport {version} from './lib/version';\nexport {layout} from './lib/layout';\nexport {debugOrdering as debug} from './lib/debug';\n\nexport const util = {time, notime};\n\n// Export types\nexport type {\n GraphLabel,\n NodeConfig,\n EdgeConfig,\n LayoutConfig,\n LayoutOptions,\n NodeLabel,\n EdgeLabel,\n Point,\n OrderConstraint,\n WeightFunction,\n RankerFunction,\n Edge\n} from './lib/types';\n\nconst dagre = {\n graphlib,\n version,\n layout,\n debug,\n util: {time, notime},\n};\n\nexport default dagre;\n","/**\n * Renders an entity-relationship diagram as inline SVG.\n *\n * Two-stage layout, computed at render time (pure JS, no DOM, static SVG out):\n * 1. dagre places the entity boxes (layered, no overlap, edges drawn around).\n * 2. each relation is routed at the FIELD level — from the foreign-key row in\n * the source entity to the primary-key row in the target entity — with a\n * clean orthogonal path through the gap between the boxes and an arrowhead\n * into the PK row (FK → PK).\n *\n * Entities longer than `MAX_ROWS` are truncated with a \"… +N more\" row.\n */\n\nimport dagre from '@dagrejs/dagre';\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { diagramFrame } from './frame.js';\n\ntype ErdData = BlockDataMap['erd'];\ntype ErdEntity = NonNullable<ErdData['entities']>[number];\ntype ErdColumn = NonNullable<ErdEntity['columns']>[number];\n\n/** Rows shown before an entity is truncated with a \"… +N more\" row. */\nconst MAX_ROWS = 10;\n\nconst COL_W = 216;\nconst ROW_H = 24;\nconst HEAD_H = 32;\nconst BOT_PAD = 8;\n\ninterface Box {\n readonly name: string;\n readonly cols: readonly ErdColumn[]; // full column list (for FK/PK lookup)\n readonly rows: readonly ErdColumn[]; // visible rows (after truncation)\n readonly hidden: number;\n readonly pkIdx: number; // index of the primary-key column, or -1\n readonly w: number;\n readonly h: number;\n}\n\ninterface Pt {\n readonly x: number;\n readonly y: number;\n}\n\nexport function renderErd(data: BlockDataMap['erd']): string {\n const ents = data.entities ?? [];\n const rels = data.relations ?? [];\n\n const boxes: Box[] = ents.map((e) => {\n const cols = e.columns ?? [];\n let rows = cols;\n let hidden = 0;\n if (cols.length > MAX_ROWS) {\n rows = cols.slice(0, MAX_ROWS - 1);\n hidden = cols.length - rows.length;\n }\n const bodyRows = rows.length + (hidden > 0 ? 1 : 0);\n return {\n name: e.name,\n cols,\n rows,\n hidden,\n pkIdx: cols.findIndex((c) => c.pk === true),\n w: COL_W,\n h: HEAD_H + bodyRows * ROW_H + BOT_PAD,\n };\n });\n const byName = new Map(boxes.map((b) => [b.name, b]));\n const validRels = rels.filter((r) => byName.has(r.from) && byName.has(r.to));\n\n // Stage 1: dagre places boxes (edges inform placement, but we route our own).\n const g = new dagre.graphlib.Graph({ multigraph: true });\n g.setGraph({ rankdir: 'LR', nodesep: 38, ranksep: 96, marginx: 18, marginy: 18 });\n g.setDefaultEdgeLabel(() => ({}));\n for (const b of boxes) g.setNode(b.name, { width: b.w, height: b.h });\n validRels.forEach((r, i) => g.setEdge(r.from, r.to, {}, `e${i}`));\n dagre.layout(g);\n\n const graph = g.graph();\n const W = Math.ceil(graph.width ?? 0);\n const H = Math.ceil(graph.height ?? 0);\n\n const at = new Map<string, Pt>(); // top-left of each box\n for (const b of boxes) {\n const n = g.node(b.name) as { x: number; y: number };\n at.set(b.name, { x: n.x - b.w / 2, y: n.y - b.h / 2 });\n }\n\n let s = `<svg viewBox=\"0 0 ${W} ${H}\" role=\"img\">` + `<title>Entity-relationship diagram</title>`;\n\n // Stage 2: field-level edge routing (drawn first, so boxes sit on top).\n validRels.forEach((r) => {\n const src = byName.get(r.from);\n const tgt = byName.get(r.to);\n const sp = at.get(r.from);\n const tp = at.get(r.to);\n if (!src || !tgt || !sp || !tp) return;\n\n const fkY = rowAnchorY(src, sp.y, pickFkIndex(src.cols, tgt.name));\n const pkY = rowAnchorY(tgt, tp.y, tgt.pkIdx);\n\n const rightward = tp.x + tgt.w / 2 >= sp.x + src.w / 2;\n const sx = rightward ? sp.x + src.w : sp.x; // exit side of source\n const tx = rightward ? tp.x : tp.x + tgt.w; // enter side of target\n\n const lo = Math.min(sx, tx) + 10;\n const hi = Math.max(sx, tx) - 10;\n const midX = hi > lo ? clamp((sx + tx) / 2, lo, hi) : (sx + tx) / 2;\n\n const card = parseCard(r.card);\n s +=\n `<path d=\"M${round(sx)},${round(fkY)} H${round(midX)} V${round(pkY)} H${round(tx)}\" fill=\"none\" stroke=\"var(--gray)\" stroke-width=\"1.5\"/>` +\n crowFoot(sx, fkY, rightward ? 1 : -1, card.fromMany) +\n crowFoot(tx, pkY, rightward ? -1 : 1, card.toMany);\n\n if (r.label !== undefined && r.label !== '') {\n const w = Math.max(30, r.label.length * 6.4);\n const cy = (fkY + pkY) / 2;\n s +=\n `<rect x=\"${round(midX - w / 2)}\" y=\"${round(cy - 9)}\" width=\"${round(w)}\" height=\"18\" rx=\"9\" fill=\"var(--white)\" stroke=\"var(--rule)\"/>` +\n `<text x=\"${round(midX)}\" y=\"${round(cy + 3)}\" class=\"edge-label\">${escapeHtml(r.label)}</text>`;\n }\n });\n\n // Entity boxes.\n for (const b of boxes) {\n const p = at.get(b.name);\n if (!p) continue;\n const { x, y } = p;\n s +=\n `<rect x=\"${round(x)}\" y=\"${round(y)}\" width=\"${b.w}\" height=\"${b.h}\" rx=\"5\" fill=\"var(--white)\" stroke=\"var(--navy)\"/>` +\n `<path d=\"M${round(x)},${round(y + HEAD_H)} v${-(HEAD_H - 5)} a5,5 0 0 1 5,-5 h${b.w - 10} a5,5 0 0 1 5,5 v${HEAD_H - 5} z\" fill=\"var(--navy)\"/>` +\n `<text x=\"${round(x + b.w / 2)}\" y=\"${round(y + 21)}\" class=\"er-head-text\">${escapeHtml(b.name)}</text>`;\n\n b.rows.forEach((f, j) => {\n const rowTop = y + HEAD_H + j * ROW_H;\n const ty = rowTop + 16;\n if (j > 0) {\n s += `<line x1=\"${round(x)}\" y1=\"${round(rowTop)}\" x2=\"${round(x + b.w)}\" y2=\"${round(rowTop)}\" class=\"er-rowline\"/>`;\n }\n const nameX = f.pk === true || f.fk === true ? x + 40 : x + 13;\n if (f.pk === true) {\n s += `<text x=\"${round(x + 13)}\" y=\"${round(ty)}\" class=\"er-key\">PK</text>`;\n } else if (f.fk === true) {\n s += `<text x=\"${round(x + 13)}\" y=\"${round(ty)}\" class=\"er-key fk\">FK</text>`;\n }\n s +=\n `<text x=\"${round(nameX)}\" y=\"${round(ty)}\" class=\"er-col\">${escapeHtml(f.name)}</text>` +\n `<text x=\"${round(x + b.w - 13)}\" y=\"${round(ty)}\" class=\"er-col dim\" text-anchor=\"end\">${escapeHtml(f.type ?? '')}</text>`;\n });\n\n if (b.hidden > 0) {\n const rowTop = y + HEAD_H + b.rows.length * ROW_H;\n s +=\n `<line x1=\"${round(x)}\" y1=\"${round(rowTop)}\" x2=\"${round(x + b.w)}\" y2=\"${round(rowTop)}\" class=\"er-rowline\"/>` +\n `<text x=\"${round(x + b.w / 2)}\" y=\"${round(rowTop + 16)}\" class=\"er-col dim\" text-anchor=\"middle\">… +${b.hidden} more</text>`;\n }\n }\n\n s += `</svg>`;\n\n const opts: Parameters<typeof diagramFrame>[0] = {\n tag: 'ER',\n tagBg: '#6b21a8',\n ...(data.title !== undefined ? { title: data.title } : {}),\n ...(data.description !== undefined ? { desc: data.description } : {}),\n };\n return diagramFrame(opts, s);\n}\n\n/** Vertical centre of column `idx` in a box; falls back to the box centre. */\nfunction rowAnchorY(box: Box, topY: number, idx: number): number {\n if (idx >= 0 && idx < box.rows.length) return topY + HEAD_H + idx * ROW_H + ROW_H / 2;\n return topY + box.h / 2;\n}\n\n/**\n * Picks which foreign-key column references `toName`. Prefers an FK whose name\n * mentions the target entity (e.g. `user_id` → `users`); else the first FK; -1.\n */\nfunction pickFkIndex(columns: readonly ErdColumn[], toName: string): number {\n const fks = columns.map((c, i) => ({ c, i })).filter((x) => x.c.fk === true);\n const first = fks[0];\n if (first === undefined) return -1;\n const t = toName.toLowerCase();\n const singular = t.replace(/s$/, '');\n const match = fks.find((x) => {\n const n = x.c.name.toLowerCase();\n return n.includes(t) || n.includes(singular);\n });\n return (match ?? first).i;\n}\n\n/** Splits a `card` value ('1:N', 'N:1', '1:1', 'N:M') into per-end multiplicity.\n * Defaults to many → one (the typical FK → PK shape) when absent. */\nfunction parseCard(card: string | undefined): { fromMany: boolean; toMany: boolean } {\n if (card === undefined) return { fromMany: true, toMany: false };\n const parts = card.split(':');\n const many = (p: string | undefined): boolean => p !== undefined && p.trim().toUpperCase() !== '1';\n return { fromMany: many(parts[0]), toMany: many(parts[1]) };\n}\n\n/**\n * A crow's-foot end at the box edge (bx, y). `outward` (±1) is the direction the\n * edge leaves the box. `many` draws the three-pronged \"many\" fork; otherwise a\n * single perpendicular \"one\" tick.\n */\nfunction crowFoot(bx: number, y: number, outward: number, many: boolean): string {\n if (many) {\n const ax = bx + outward * 14;\n return (\n `<path d=\"M${round(ax)},${round(y)} L${round(bx)},${round(y - 7)} ` +\n `M${round(ax)},${round(y)} L${round(bx)},${round(y)} ` +\n `M${round(ax)},${round(y)} L${round(bx)},${round(y + 7)}\" ` +\n `fill=\"none\" stroke=\"var(--navy)\" stroke-width=\"1.4\" stroke-linecap=\"round\"/>`\n );\n }\n const tx = bx + outward * 9;\n return `<line x1=\"${round(tx)}\" y1=\"${round(y - 6)}\" x2=\"${round(tx)}\" y2=\"${round(y + 6)}\" stroke=\"var(--navy)\" stroke-width=\"1.4\" stroke-linecap=\"round\"/>`;\n}\n\nconst clamp = (n: number, lo: number, hi: number): number => Math.max(lo, Math.min(hi, n));\nconst round = (n: number): number => Math.round(n * 10) / 10;\n","/**\n * Renders a kanban block. Doc-studio variant uses `columns: [{label, cards:\n * [{title, tag?}]}]` — flexible number of columns with structured cards.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\nexport function renderKanban(data: BlockDataMap['kanban']): string {\n const cols = data.columns ?? [];\n let h = `<div class=\"kanban\">`;\n for (const col of cols) {\n const cards = (col.cards ?? [])\n .map((c) => {\n const tag =\n c.tag !== undefined\n ? `<div class=\"kan-card-tag\">${escapeHtml(c.tag)}</div>`\n : '';\n return (\n `<div class=\"kan-card\">` +\n `<div class=\"kan-card-title\">${escapeHtml(c.title)}</div>` +\n tag +\n `</div>`\n );\n })\n .join('');\n h +=\n `<div class=\"kan-col\">` +\n `<div class=\"kan-head\">${escapeHtml(col.label)}</div>` +\n cards +\n `</div>`;\n }\n return h + `</div>`;\n}\n","/**\n * Renders a sequence diagram as inline SVG, plus an optional step-by-step\n * list below the SVG and an optional diagram footer with metadata pills.\n *\n * Matches the layout of `resources/sample-orders-api.html` (the canonical\n * \"rich\" rendering).\n *\n * Actors are objects (`{id, name, sub?, external?}`); messages reference\n * actors by `id`. Message `kind`:\n * - `sync` — solid arrow, bold navy label (default)\n * - `response` / `async` — dashed arrow, normal label\n * - `error` — red arrow, red bold label, step list item gets `.err`\n * - `note` — no arrow, italic gray label, badge on the from-actor's lane\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { diagramFrame } from './frame.js';\n\ntype MsgKind = 'sync' | 'response' | 'async' | 'error' | 'note';\n\ninterface KindStyle {\n readonly cls: string;\n readonly marker: 'sqArrow' | 'sqOpen' | 'sqErr' | null;\n readonly txt: string;\n}\n\nconst KIND: Record<MsgKind, KindStyle> = {\n sync: { cls: 'msg-line', marker: 'sqArrow', txt: 'msg-text em' },\n response: { cls: 'msg-line dashed', marker: 'sqOpen', txt: 'msg-text' },\n async: { cls: 'msg-line dashed', marker: 'sqOpen', txt: 'msg-text' },\n error: { cls: 'msg-line err', marker: 'sqErr', txt: 'msg-text err' },\n note: { cls: '', marker: null, txt: 'msg-text note' },\n};\n\nconst DB_PATTERN = /postgres|sql|\\bdb\\b|database|store/i;\n\nfunction renderStepList(\n rows: ReadonlyArray<{ kind: MsgKind; from: string; to: string; summary?: string; code?: string; note?: string }>,\n actorById: Map<string, { name: string }>,\n): string {\n const items = rows.filter((r) => r.summary !== undefined && r.summary.length > 0);\n if (items.length === 0) return '';\n\n const lis = items\n .map((r) => {\n const errCls = r.kind === 'error' ? ' class=\"err\"' : '';\n const actorErrCls = r.kind === 'error' ? ' err' : '';\n const fromName = actorById.get(r.from)?.name ?? r.from;\n const toName = r.kind === 'note' ? '' : ` &rarr; ${escapeHtml(actorById.get(r.to)?.name ?? r.to)}`;\n const actorLabel = `${escapeHtml(fromName)}${toName}`;\n const code =\n r.code !== undefined && r.code.length > 0\n ? `<pre class=\"sql\">${escapeHtml(r.code)}</pre>`\n : '';\n const note =\n r.note !== undefined && r.note.length > 0\n ? `<span class=\"step-note\">${escapeHtml(r.note)}</span>`\n : '';\n return (\n `<li${errCls}>` +\n `<span class=\"step-actor${actorErrCls}\">${actorLabel}</span>` +\n `<span class=\"step-summary\">${escapeHtml(r.summary ?? '')}</span>` +\n code +\n note +\n `</li>`\n );\n })\n .join('');\n\n return (\n `<div class=\"seq-steps\">` +\n `<div class=\"seq-steps-title\">Step-by-step</div>` +\n `<ol>${lis}</ol>` +\n `</div>`\n );\n}\n\nfunction renderFoot(foot: NonNullable<BlockDataMap['sequence']['foot']>): string {\n if (foot.length === 0) return '';\n const parts = foot\n .map((f) => `<span><strong>${escapeHtml(f.label)}:</strong> ${escapeHtml(f.value)}</span>`)\n .join('');\n return `<div class=\"diagram-foot\">${parts}</div>`;\n}\n\nexport function renderSequence(data: BlockDataMap['sequence']): string {\n const actors = data.actors ?? [];\n const messages = data.messages ?? [];\n const N = Math.max(actors.length, 1);\n const leftPad = 24;\n const laneW = 168;\n const gap = 58;\n const headY = 16;\n const headH = 42;\n const cx = (i: number): number => leftPad + laneW / 2 + i * (laneW + gap);\n const width = leftPad * 2 + N * laneW + (N - 1) * gap;\n const idx = (id: string): number => actors.findIndex((a) => a.id === id);\n const msgStartY = 92;\n const step = 42;\n\n type Row = {\n n: number;\n y: number;\n fromI: number;\n toI: number;\n kind: MsgKind;\n label: string;\n from: string;\n to: string;\n summary?: string;\n code?: string;\n note?: string;\n };\n const rows: Row[] = messages.map((m, k): Row => {\n const base: Row = {\n n: k + 1,\n y: msgStartY + k * step,\n fromI: idx(m.from),\n toI: idx(m.to),\n kind: (m.kind ?? 'sync') as MsgKind,\n label: m.label ?? '',\n from: m.from,\n to: m.to,\n };\n if (m.summary !== undefined) base.summary = m.summary;\n if (m.code !== undefined) base.code = m.code;\n if (m.note !== undefined) base.note = m.note;\n return base;\n });\n const bottom = msgStartY + messages.length * step + 12;\n const height = bottom + 6;\n\n const activations = actors.map((a, i) => {\n if (i === 0) return null;\n const ys = rows.filter((r) => r.fromI === i || r.toI === i).map((r) => r.y);\n if (ys.length === 0) return null;\n const db = DB_PATTERN.test(`${a.name} ${a.sub ?? ''}`);\n return { i, y1: Math.min(...ys) - 8, y2: Math.max(...ys) + 8, db };\n });\n\n let s =\n `<svg viewBox=\"0 0 ${width} ${height}\" role=\"img\">` +\n `<title>Sequence diagram</title>` +\n `<defs>` +\n `<marker id=\"sqArrow\" viewBox=\"0 0 10 10\" refX=\"8\" refY=\"5\" markerWidth=\"6\" markerHeight=\"6\" orient=\"auto-start-reverse\">` +\n `<path d=\"M0,0 L10,5 L0,10 z\" fill=\"#1a1a2e\"/></marker>` +\n `<marker id=\"sqOpen\" viewBox=\"0 0 10 10\" refX=\"8\" refY=\"5\" markerWidth=\"6\" markerHeight=\"6\" orient=\"auto-start-reverse\">` +\n `<path d=\"M0,0 L10,5 L0,10\" fill=\"none\" stroke=\"#1a1a2e\" stroke-width=\"1.2\"/></marker>` +\n `<marker id=\"sqErr\" viewBox=\"0 0 10 10\" refX=\"8\" refY=\"5\" markerWidth=\"6\" markerHeight=\"6\" orient=\"auto-start-reverse\">` +\n `<path d=\"M0,0 L10,5 L0,10 z\" fill=\"#991b1b\"/></marker>` +\n `</defs>`;\n\n for (let i = 0; i < actors.length; i++) {\n const x = cx(i);\n s += `<line x1=\"${x}\" y1=\"${headY + headH}\" x2=\"${x}\" y2=\"${bottom}\" class=\"lifeline\"/>`;\n }\n\n for (const ac of activations) {\n if (!ac) continue;\n s += `<rect x=\"${cx(ac.i) - 4}\" y=\"${ac.y1}\" width=\"8\" height=\"${ac.y2 - ac.y1}\" class=\"activation${ac.db ? ' pg' : ''}\"/>`;\n }\n\n actors.forEach((a, i) => {\n const extCls = a.external === true ? ' ext' : '';\n const sub =\n a.sub !== undefined\n ? `<text x=\"${cx(i)}\" y=\"${headY + 36}\" class=\"lane-head-sub${extCls}\">${escapeHtml(a.sub)}</text>`\n : '';\n s +=\n `<g>` +\n `<rect x=\"${cx(i) - laneW / 2}\" y=\"${headY}\" width=\"${laneW}\" height=\"${headH}\" class=\"lane-head${extCls}\"/>` +\n `<text x=\"${cx(i)}\" y=\"${headY + 22}\" class=\"lane-head-text\">${escapeHtml(a.name)}</text>` +\n sub +\n `</g>`;\n });\n\n for (const r of rows) {\n const k = KIND[r.kind];\n\n // `note` kind — just a numbered annotation at the from-actor's lane\n if (r.kind === 'note' || r.toI < 0) {\n if (r.fromI < 0) continue;\n const x = cx(r.fromI);\n s +=\n `<g>` +\n `<circle cx=\"${x + 18}\" cy=\"${r.y - 10}\" r=\"10\" class=\"step-badge\"/>` +\n `<text x=\"${x + 18}\" y=\"${r.y - 6.5}\" class=\"step-badge-text\">${r.n}</text>` +\n `<text x=\"${x + 34}\" y=\"${r.y - 6}\" class=\"msg-text note\">${escapeHtml(r.label)}</text>` +\n `</g>`;\n continue;\n }\n // self-message — loop back to the same lane\n if (r.fromI === r.toI) {\n const x = cx(r.fromI);\n const errCls = r.kind === 'error' ? ' err' : '';\n s +=\n `<g>` +\n `<circle cx=\"${x + 18}\" cy=\"${r.y - 10}\" r=\"10\" class=\"step-badge${errCls}\"/>` +\n `<text x=\"${x + 18}\" y=\"${r.y - 6.5}\" class=\"step-badge-text\">${r.n}</text>` +\n `<text x=\"${x + 34}\" y=\"${r.y - 6}\" class=\"msg-text note\">${escapeHtml(r.label)}</text>` +\n `</g>`;\n continue;\n }\n\n const x1 = cx(r.fromI);\n const x2 = cx(r.toI);\n const ltr = x2 > x1;\n const end = x2 + (ltr ? -3 : 3);\n const errBadge = r.kind === 'error' ? ' err' : '';\n // Badge sits just inside the from-lane on the side facing the target.\n const badgeX = ltr ? x1 + 18 : x1 - 18;\n // Label anchors next to the badge (start-aligned LTR, end-aligned RTL).\n // Matches the sample's `<text x=\"badgeX+18\" ... >` / `<text x=\"badgeX-18\" ... text-anchor=\"end\">` layout.\n const labelX = ltr ? badgeX + 16 : badgeX - 16;\n const labelAnchor = ltr ? 'start' : 'end';\n const markerAttr = k.marker !== null ? ` marker-end=\"url(#${k.marker})\"` : '';\n s +=\n `<line x1=\"${x1}\" y1=\"${r.y}\" x2=\"${end}\" y2=\"${r.y}\" class=\"${k.cls}\"${markerAttr}/>` +\n `<circle cx=\"${badgeX}\" cy=\"${r.y - 10}\" r=\"10\" class=\"step-badge${errBadge}\"/>` +\n `<text x=\"${badgeX}\" y=\"${r.y - 6.5}\" class=\"step-badge-text\">${r.n}</text>` +\n `<text x=\"${labelX}\" y=\"${r.y - 6}\" class=\"${k.txt}\" text-anchor=\"${labelAnchor}\">${escapeHtml(r.label)}</text>`;\n }\n\n s += `</svg>`;\n\n const actorById = new Map<string, { name: string }>();\n for (const a of actors) actorById.set(a.id, { name: a.name });\n const stepList = renderStepList(rows, actorById);\n const footHtml = data.foot !== undefined ? renderFoot(data.foot) : '';\n\n // Tag + title\n const method = data.endpoint?.method.toLowerCase();\n const tag = data.endpoint?.method ?? 'FLOW';\n const titleHtml = (() => {\n if (data.endpoint?.path !== undefined) {\n const t = data.title !== undefined ? ` &mdash; ${escapeHtml(data.title)}` : '';\n return `<code>${escapeHtml(data.endpoint.path)}</code>${t}`;\n }\n return data.title !== undefined ? escapeHtml(data.title) : '';\n })();\n\n const frameOpts: Parameters<typeof diagramFrame>[0] = {\n tag,\n ...(method !== undefined ? { tagClass: method } : { tagBg: '#374151' }),\n ...(titleHtml.length > 0 ? { titleHtml } : {}),\n ...(data.description !== undefined ? { desc: data.description } : {}),\n ...(footHtml.length > 0 ? { footerHtml: footHtml } : {}),\n };\n\n return diagramFrame(frameOpts, s + stepList);\n}\n","/**\n * Renders a table block. Doc-studio variant supports:\n * - Column objects with `align` ('l'|'c'|'r') and `highlight`\n * - Cell objects with `tone` ('pos'|'neg'|'warn'|'muted'), `lead`, `highlight`\n * - Optional `title`, `description`, `note`\n *\n * Plain string columns / cells still work.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\ntype TableData = BlockDataMap['table'];\ntype Col = NonNullable<TableData['columns']>[number];\ntype Cell = NonNullable<NonNullable<TableData['rows']>[number]>[number];\n\nfunction colClass(c: Col): string {\n if (typeof c === 'string') return '';\n const parts: string[] = [];\n if (c.align === 'r') parts.push('r');\n if (c.align === 'c') parts.push('c');\n if (c.highlight === true) parts.push('hi');\n return parts.join(' ');\n}\n\nfunction colLabel(c: Col): string {\n return typeof c === 'string' ? c : c.label;\n}\n\nfunction cellClass(c: Cell): string {\n if (typeof c === 'string' || typeof c === 'number') return '';\n const parts: string[] = [];\n if (c.tone) parts.push(`cell-${c.tone}`);\n if (c.lead === true) parts.push('lead');\n if (c.highlight === true) parts.push('hi');\n return parts.join(' ');\n}\n\nfunction cellValue(c: Cell): string {\n if (typeof c === 'string' || typeof c === 'number') return escapeHtml(c);\n return escapeHtml(c.v);\n}\n\nexport function renderTable(data: BlockDataMap['table']): string {\n const cols = data.columns ?? [];\n const rows = data.rows ?? [];\n const head = cols\n .map((c) => {\n const cls = colClass(c);\n return `<th${cls ? ` class=\"${cls}\"` : ''}>${escapeHtml(colLabel(c))}</th>`;\n })\n .join('');\n const body = rows\n .map((r) => {\n const cells = (r ?? [])\n .map((c, i) => {\n const col = cols[i];\n const cls = [col !== undefined ? colClass(col) : '', cellClass(c)]\n .filter(Boolean)\n .join(' ');\n return `<td${cls ? ` class=\"${cls}\"` : ''}>${cellValue(c)}</td>`;\n })\n .join('');\n return `<tr>${cells}</tr>`;\n })\n .join('');\n const note =\n data.note !== undefined ? `<p class=\"tbl-note\">${escapeHtml(data.note)}</p>` : '';\n return `<table class=\"pres-table\"><thead><tr>${head}</tr></thead><tbody>${body}</tbody></table>${note}`;\n}\n","/**\n * Renders a timeline block. Doc-studio variant uses `label` (not `title`),\n * `date` (not `when`), `desc` (not `detail`), and status enum\n * `done | current | next | future` (where `current` is the in-flight item).\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\nexport function renderTimeline(data: BlockDataMap['timeline']): string {\n const items = data.items ?? [];\n let h = `<div class=\"tl\">`;\n for (const it of items) {\n const st = it.status ?? 'future';\n const date =\n it.date !== undefined ? `<div class=\"tl-date\">${escapeHtml(it.date)}</div>` : '';\n const desc =\n it.desc !== undefined ? `<div class=\"tl-desc\">${escapeHtml(it.desc)}</div>` : '';\n h +=\n `<div class=\"tl-item\">` +\n `<span class=\"tl-dot ${st}\"></span>` +\n date +\n `<div class=\"tl-label\">${escapeHtml(it.label)}</div>` +\n desc +\n `</div>`;\n }\n return h + `</div>`;\n}\n","/**\n * Renders a tracker block — task table with status pills, optional priority,\n * owner, and due date columns.\n *\n * Doc-studio extras: optional `owner` (rendered as a column) and `due` (also\n * a column). Done rows get a strikethrough via `.trk tr.done .trk-task`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\nexport function renderTracker(data: BlockDataMap['tracker']): string {\n const items = data.items ?? [];\n const hasOwner = items.some((i) => i.owner !== undefined);\n const hasDue = items.some((i) => i.due !== undefined);\n\n const headCells = ['<th>Task</th>', '<th>Status</th>', '<th>Priority</th>'];\n if (hasOwner) headCells.push('<th>Owner</th>');\n if (hasDue) headCells.push('<th>Due</th>');\n\n let h = `<table class=\"trk\"><thead><tr>${headCells.join('')}</tr></thead><tbody>`;\n for (const it of items) {\n const st = it.status ?? 'todo';\n const pr = it.priority;\n const prCell =\n pr !== undefined ? `<span class=\"pri ${pr}\">${escapeHtml(pr)}</span>` : '';\n const rowCls = st === 'done' ? ' class=\"done\"' : '';\n const cells = [\n `<td class=\"trk-task\">${escapeHtml(it.task)}</td>`,\n `<td><span class=\"st ${st}\">${escapeHtml(st)}</span></td>`,\n `<td>${prCell}</td>`,\n ];\n if (hasOwner) cells.push(`<td>${escapeHtml(it.owner ?? '')}</td>`);\n if (hasDue) cells.push(`<td>${escapeHtml(it.due ?? '')}</td>`);\n h += `<tr${rowCls}>${cells.join('')}</tr>`;\n }\n return h + `</tbody></table>`;\n}\n","/**\n * Renders a userstory block — story statement, optional meta chips, optional\n * acceptance-criteria list, and optional related-links chips.\n *\n * Matches doc-studio's `.story` shell (`.story-stmt`, `.story-meta`,\n * `.story-chip`, `.ac-title`, `.ac-item`, `.gwt`, `.link-chip`).\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\nexport function renderUserStory(data: BlockDataMap['userstory']): string {\n const role = data.role ?? 'user';\n const want = data.want ?? '…';\n const soThat = data.soThat ?? '…';\n\n const chips: string[] = [];\n if (data.priority !== undefined)\n chips.push(`<span class=\"story-chip\">Priority · ${escapeHtml(data.priority)}</span>`);\n if (data.points !== undefined && data.points !== null)\n chips.push(`<span class=\"story-chip\">${escapeHtml(data.points)} pts</span>`);\n\n let h =\n `<div class=\"story\">` +\n `<div class=\"story-stmt\">As a <b>${escapeHtml(role)}</b>, I want to <b>${escapeHtml(want)}</b>, so that <b>${escapeHtml(soThat)}</b>.</div>`;\n if (chips.length > 0) {\n h += `<div class=\"story-meta\">${chips.join('')}</div>`;\n }\n h += `</div>`;\n\n const crit = data.criteria ?? [];\n if (crit.length > 0) {\n h += `<div class=\"ac-title\">Acceptance criteria</div>`;\n for (const c of crit) {\n h +=\n `<div class=\"ac-item\"><div class=\"gwt\">` +\n `<span class=\"k g\">Given</span><span class=\"v\">${escapeHtml(c.given ?? '')}</span>` +\n `<span class=\"k w\">When</span><span class=\"v\">${escapeHtml(c.when ?? '')}</span>` +\n `<span class=\"k t\">Then</span><span class=\"v\">${escapeHtml(c.then ?? '')}</span>` +\n `</div></div>`;\n }\n }\n\n const links = data.links ?? [];\n if (links.length > 0) {\n h += `<div class=\"ac-title\">Related</div><div class=\"links-row\">`;\n for (const l of links) {\n h +=\n `<span class=\"link-chip\">` +\n `<span class=\"lt\">${escapeHtml(l.mode ?? '')}</span>` +\n `${escapeHtml(l.label ?? '')}` +\n `</span>`;\n }\n h += `</div>`;\n }\n\n return h;\n}\n","/**\n * Renders a structured `prose` block — a sequence of typed sub-blocks\n * (heading, paragraph, ul, ol, quote). Useful when the author wants explicit\n * structure instead of raw markdown.\n *\n * Ported from doc-studio.jsx `Prose`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\nexport function renderProseBlock(data: BlockDataMap['prose']): string {\n const blocks = data.blocks ?? [];\n const html = blocks\n .map((b) => {\n const t = (b.type ?? 'p').toLowerCase();\n const text = b.text ?? '';\n if (t === 'h') return `<h3>${escapeHtml(text)}</h3>`;\n if (t === 'quote') return `<blockquote>${escapeHtml(text)}</blockquote>`;\n if (t === 'ul') {\n const items = (b.items ?? []).map((x) => `<li>${escapeHtml(x)}</li>`).join('');\n return `<ul>${items}</ul>`;\n }\n if (t === 'ol') {\n const items = (b.items ?? []).map((x) => `<li>${escapeHtml(x)}</li>`).join('');\n return `<ol>${items}</ol>`;\n }\n return `<p>${escapeHtml(text)}</p>`;\n })\n .join('');\n return `<div class=\"prose\">${html}</div>`;\n}\n","/**\n * Renders a glossary block — a list of term/definition rows.\n *\n * Ported from doc-studio.jsx `Glossary`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\nexport function renderGlossary(data: BlockDataMap['glossary']): string {\n const terms = data.terms ?? [];\n const rows = terms\n .map(\n (t) =>\n `<div class=\"row\"><dt>${escapeHtml(t.term)}</dt><dd>${escapeHtml(t.def)}</dd></div>`,\n )\n .join('');\n return `<div class=\"glossary\">${rows}</div>`;\n}\n","/**\n * Renders a pros-vs-cons block — two columns of bullet items with\n * positive / negative styling.\n *\n * Ported from doc-studio.jsx `ProsCons`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\nexport function renderProsCons(data: BlockDataMap['proscons']): string {\n const prosLabel = data.prosLabel ?? 'Pros';\n const consLabel = data.consLabel ?? 'Cons';\n const pros = (data.pros ?? []).map((p) => `<div class=\"pc-item\">${escapeHtml(p)}</div>`).join('');\n const cons = (data.cons ?? []).map((c) => `<div class=\"pc-item\">${escapeHtml(c)}</div>`).join('');\n return (\n `<div class=\"pc\">` +\n `<div class=\"pc-col pro\">` +\n `<div class=\"pc-head\">${escapeHtml(prosLabel)}</div>` +\n pros +\n `</div>` +\n `<div class=\"pc-col con\">` +\n `<div class=\"pc-head\">${escapeHtml(consLabel)}</div>` +\n cons +\n `</div>` +\n `</div>`\n );\n}\n","/**\n * Renders a current-vs-target block — two side-by-side panels separated by an\n * arrow, optionally captioned.\n *\n * Ported from doc-studio.jsx `CurrentTarget`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\nexport function renderCvt(data: BlockDataMap['cvt']): string {\n const cur = data.current ?? {};\n const tgt = data.target ?? {};\n const curItems = (cur.items ?? [])\n .map((x) => `<div class=\"ct-item\">${escapeHtml(x)}</div>`)\n .join('');\n const tgtItems = (tgt.items ?? [])\n .map((x) => `<div class=\"ct-item\">${escapeHtml(x)}</div>`)\n .join('');\n const curLabel = cur.label ?? 'Current';\n const tgtLabel = tgt.label ?? 'Target';\n const note =\n data.note !== undefined ? `<div class=\"tbl-note\">${escapeHtml(data.note)}</div>` : '';\n return (\n `<div>` +\n `<div class=\"ct\">` +\n `<div class=\"ct-panel cur\">` +\n `<div class=\"ct-label\">${escapeHtml(curLabel)}</div>` +\n curItems +\n `</div>` +\n `<div class=\"ct-arrow\">&rarr;</div>` +\n `<div class=\"ct-panel tgt\">` +\n `<div class=\"ct-label\">${escapeHtml(tgtLabel)}</div>` +\n tgtItems +\n `</div>` +\n `</div>` +\n note +\n `</div>`\n );\n}\n","/**\n * Renders a row of KPI / stat cards with optional delta + trend arrow.\n *\n * Ported from doc-studio.jsx `StatCards`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { safeColor } from '../sanitize.js';\n\nconst TREND_GLYPH = { up: '▲', down: '▼', flat: '—' } as const;\n\nexport function renderStats(data: BlockDataMap['stats']): string {\n const stats = data.stats ?? [];\n const cards = stats\n .map((s) => {\n const accent =\n s.accent !== undefined\n ? ` style=\"border-top-color:${safeColor(s.accent, '#0e54a1')}\"`\n : '';\n const delta =\n s.delta !== undefined\n ? `<div class=\"stat-delta ${s.trend ?? 'flat'}\">${TREND_GLYPH[s.trend ?? 'flat']} ${escapeHtml(s.delta)}</div>`\n : '';\n return (\n `<div class=\"stat-card\"${accent}>` +\n `<div class=\"stat-value\">${escapeHtml(s.value)}</div>` +\n `<div class=\"stat-label\">${escapeHtml(s.label)}</div>` +\n delta +\n `</div>`\n );\n })\n .join('');\n return `<div class=\"stat-row\">${cards}</div>`;\n}\n","/**\n * Tiny multi-language syntax highlighter — emits HTML spans (`.kw`, `.str`,\n * `.num`, `.fn`, `.ty`, `.com`) wrapped around recognized tokens.\n *\n * Ported from `resources/doc-studio.jsx` `highlightCode`. Designed for the\n * `code` block and the SQL snippets in `seq-steps`. Not a full lexer — just\n * enough to make a snippet readable.\n */\n\nimport { escapeHtml } from './escape.js';\n\nconst KW = new Set(\n (\n 'const let var function return if else for while do switch case break continue ' +\n 'class extends new await async import from export default try catch finally throw ' +\n 'typeof instanceof void delete yield static public private protected readonly ' +\n 'abstract implements interface type enum namespace def elif lambda pass with raise ' +\n 'except none true false and or not is in self nil func struct map range defer chan ' +\n 'select fallthrough echo fi done local require module package this super ' +\n 'create table alter add drop select insert update delete into values where join ' +\n 'group order by limit primary key foreign references not null default unique index ' +\n 'on check constraint cascade returning begin commit rollback'\n ).split(/\\s+/),\n);\n\nconst TY = new Set(\n (\n 'string number boolean int integer float double bool char byte long short void ' +\n 'object any unknown never bigint promise array list set optional uuid text varchar ' +\n 'timestamptz timestamp date numeric decimal jsonb json serial bigserial smallint'\n ).split(/\\s+/),\n);\n\nconst TOKEN_RE =\n /(\\/\\*[\\s\\S]*?\\*\\/|\\/\\/[^\\n]*|#[^\\n]*)|(\"(?:\\\\.|[^\"\\\\])*\"|'(?:\\\\.|[^'\\\\])*'|`(?:\\\\.|[^`\\\\])*`)|(\\b\\d[\\w.]*)|([A-Za-z_$][\\w$]*)/g;\n\n/**\n * Highlights a code snippet, returning HTML-safe string.\n *\n * @param code - Source code (any language). HTML-escaped before token wrapping.\n */\nexport function highlightCode(code: string): string {\n if (code.length === 0) return '';\n const src = String(code);\n let out = '';\n let last = 0;\n TOKEN_RE.lastIndex = 0;\n let m: RegExpExecArray | null;\n while ((m = TOKEN_RE.exec(src)) !== null) {\n if (m.index > last) out += escapeHtml(src.slice(last, m.index));\n const t = m[0];\n if (m[1] !== undefined) {\n out += `<span class=\"com\">${escapeHtml(t)}</span>`;\n } else if (m[2] !== undefined) {\n out += `<span class=\"str\">${escapeHtml(t)}</span>`;\n } else if (m[3] !== undefined) {\n out += `<span class=\"num\">${escapeHtml(t)}</span>`;\n } else {\n const lt = t.toLowerCase();\n if (KW.has(lt)) out += `<span class=\"kw\">${escapeHtml(t)}</span>`;\n else if (TY.has(lt)) out += `<span class=\"ty\">${escapeHtml(t)}</span>`;\n else if (src[TOKEN_RE.lastIndex] === '(')\n out += `<span class=\"fn\">${escapeHtml(t)}</span>`;\n else out += escapeHtml(t);\n }\n last = TOKEN_RE.lastIndex;\n }\n if (last < src.length) out += escapeHtml(src.slice(last));\n return out;\n}\n","/**\n * Renders one or more code blocks, each with a header (filename / language)\n * and a syntax-highlighted body.\n *\n * Ported from doc-studio.jsx `CodeBlock` (iterated for multiple snippets).\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { highlightCode } from '../highlight.js';\n\nexport function renderCode(data: BlockDataMap['code']): string {\n const blocks = data.blocks ?? [];\n return blocks\n .map(\n (b) =>\n `<div class=\"code-block\">` +\n `<div class=\"code-header\">` +\n `<span>${escapeHtml(b.title ?? '')}</span>` +\n `<span>${escapeHtml(b.lang ?? '')}</span>` +\n `</div>` +\n `<pre>${highlightCode(b.code)}</pre>` +\n `</div>`,\n )\n .join('');\n}\n","/**\n * Renders a meeting / event agenda — rows of `(time + duration)` paired with\n * `(title + owner + desc)`.\n *\n * Ported from doc-studio.jsx `Agenda`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\nexport function renderAgenda(data: BlockDataMap['agenda']): string {\n const items = data.items ?? [];\n const rows = items\n .map((it) => {\n const dur =\n it.duration !== undefined\n ? `<div class=\"agenda-dur\">${escapeHtml(it.duration)}</div>`\n : '';\n const owner =\n it.owner !== undefined\n ? `<span class=\"agenda-owner\">${escapeHtml(it.owner)}</span>`\n : '';\n const desc =\n it.desc !== undefined ? `<div class=\"agenda-desc\">${escapeHtml(it.desc)}</div>` : '';\n const time =\n it.time !== undefined ? `<div class=\"agenda-time\">${escapeHtml(it.time)}</div>` : '';\n return (\n `<div class=\"agenda-row\">` +\n `<div>${time}${dur}</div>` +\n `<div>` +\n `<div class=\"agenda-title\">${escapeHtml(it.title)}${owner}</div>` +\n desc +\n `</div>` +\n `</div>`\n );\n })\n .join('');\n return `<div class=\"agenda\">${rows}</div>`;\n}\n","/**\n * Renders an indented hierarchy of nodes, like a folder tree.\n *\n * Nodes are linked via `parent` id. Roots are nodes without a `parent` (or\n * whose parent id is unknown). Children are indented based on depth.\n *\n * Ported from doc-studio.jsx `Tree`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\ntype Node = NonNullable<BlockDataMap['tree']['nodes']>[number];\n\nexport function renderTree(data: BlockDataMap['tree']): string {\n const nodes = data.nodes ?? [];\n const byId = new Map<string, Node>();\n const children = new Map<string, string[]>();\n for (const n of nodes) {\n byId.set(n.id, n);\n children.set(n.id, []);\n }\n const roots: string[] = [];\n for (const n of nodes) {\n if (n.parent !== undefined && byId.has(n.parent)) {\n children.get(n.parent)?.push(n.id);\n } else {\n roots.push(n.id);\n }\n }\n\n type Out = { node: Node; depth: number; branch: boolean };\n const out: Out[] = [];\n const seen = new Set<string>();\n const walk = (id: string, depth: number): void => {\n if (seen.has(id)) return;\n seen.add(id);\n const node = byId.get(id);\n if (node === undefined) return;\n const kids = children.get(id) ?? [];\n out.push({ node, depth, branch: kids.length > 0 });\n for (const c of kids) walk(c, depth + 1);\n };\n for (const r of roots) walk(r, 0);\n\n const rows = out\n .map((row) => {\n const branchCls = row.branch ? ' branch' : '';\n const glyph = row.branch ? '▸' : '—';\n const note =\n row.node.note !== undefined\n ? `<span class=\"tnote\">${escapeHtml(row.node.note)}</span>`\n : '';\n return (\n `<div class=\"tree-row${branchCls}\" style=\"padding-left:${row.depth * 22}px\">` +\n `<span class=\"tw\">${glyph}</span>` +\n `<span class=\"tlabel\">${escapeHtml(row.node.label)}</span>` +\n note +\n `</div>`\n );\n })\n .join('');\n return `<div class=\"tree-list\">${rows}</div>`;\n}\n","/**\n * Renders a pyramid diagram (top → bottom widening trapezoids).\n *\n * Ported from doc-studio.jsx `Pyramid`. Uses the shared CHART_COLORS palette.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\nconst CHART_COLORS = ['#0e54a1', '#1a6dbe', '#0f766e', '#1f9747', '#6b21a8', '#f7952c'];\n\nexport function renderPyramid(data: BlockDataMap['pyramid']): string {\n const levels = data.levels ?? [];\n const n = Math.max(levels.length, 1);\n const W = 520;\n const top = 16;\n const rowH = Math.min(72, Math.floor(280 / n));\n const gap = 4;\n const apex = W / 2;\n const pad = 16;\n const maxW = 430;\n const H = top + n * (rowH + gap) + pad;\n\n const polygons = levels\n .map((L, i) => {\n const y = top + i * (rowH + gap);\n const wTop = maxW * (i / n);\n const wBot = maxW * ((i + 1) / n);\n const fill = CHART_COLORS[i % CHART_COLORS.length] ?? '#0e54a1';\n const desc =\n L.desc !== undefined\n ? `<text x=\"${apex}\" y=\"${y + rowH / 2 + 14}\" class=\"pyr-desc\">${escapeHtml(L.desc)}</text>`\n : '';\n return (\n `<g>` +\n `<polygon points=\"${apex - wTop / 2},${y} ${apex + wTop / 2},${y} ${apex + wBot / 2},${y + rowH} ${apex - wBot / 2},${y + rowH}\" fill=\"${fill}\"/>` +\n `<text x=\"${apex}\" y=\"${y + rowH / 2 - 1}\" class=\"pyr-label\">${escapeHtml(L.label)}</text>` +\n desc +\n `</g>`\n );\n })\n .join('');\n\n return `<svg viewBox=\"0 0 ${W} ${H}\" role=\"img\"><title>Pyramid</title>${polygons}</svg>`;\n}\n","/**\n * Renders a funnel chart — stacked trapezoids that narrow from top to bottom\n * with absolute values and computed conversion percentages.\n *\n * Ported from doc-studio.jsx `Funnel`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\nconst CHART_COLORS = ['#0e54a1', '#1a6dbe', '#0f766e', '#1f9747', '#6b21a8', '#f7952c'];\n\nfunction toNum(v: string | number): number {\n if (typeof v === 'number') return v;\n const n = parseFloat(v.replace(/[, _]/g, ''));\n return Number.isFinite(n) ? n : 0;\n}\n\nfunction fmt(v: string | number): string {\n return typeof v === 'number' ? v.toLocaleString() : v;\n}\n\nexport function renderFunnel(data: BlockDataMap['funnel']): string {\n const stages = (data.stages ?? []).filter(Boolean);\n const W = 560;\n const top = 14;\n const rowH = 62;\n const maxW = 420;\n const pad = 14;\n const cx = W / 2;\n const H = top + stages.length * rowH + pad;\n\n const vals = stages.map((s) => toNum(s.value));\n const first = vals[0] ?? 0;\n const max = Math.max(1, ...vals);\n const wOf = (v: number): number => Math.max(78, maxW * (v / max));\n\n const groups = stages\n .map((s, i) => {\n const v = vals[i] ?? 0;\n const vNext = i < stages.length - 1 ? (vals[i + 1] ?? 0) : v * 0.82;\n const wTop = wOf(v);\n const wBot = wOf(vNext);\n const y = top + i * rowH;\n const fill = CHART_COLORS[i % CHART_COLORS.length] ?? '#0e54a1';\n const pct = first > 0 ? Math.round((v / first) * 100) : 0;\n const sub = i > 0 && first > 0 ? ` · ${pct}%` : '';\n return (\n `<g>` +\n `<polygon points=\"${cx - wTop / 2},${y} ${cx + wTop / 2},${y} ${cx + wBot / 2},${y + rowH} ${cx - wBot / 2},${y + rowH}\" fill=\"${fill}\" stroke=\"#fff\" stroke-width=\"2\"/>` +\n `<text x=\"${cx}\" y=\"${y + rowH / 2 - 3}\" class=\"funnel-label\">${escapeHtml(s.label)}</text>` +\n `<text x=\"${cx}\" y=\"${y + rowH / 2 + 15}\" class=\"funnel-val\">${escapeHtml(fmt(s.value))}${sub}</text>` +\n `</g>`\n );\n })\n .join('');\n\n return `<svg viewBox=\"0 0 ${W} ${H}\" role=\"img\"><title>Funnel</title>${groups}</svg>`;\n}\n","/**\n * Manhattan / orthogonal edge routing between two rectangular nodes.\n *\n * Returns the SVG path `d` attribute and a midpoint for label placement.\n * The route turns at the midpoint along the dominant axis, so edges read\n * cleanly even when the source and target overlap on one axis.\n *\n * Ported from `resources/doc-studio.jsx` `ortho`.\n */\n\n/** A rectangular node bounding box (top-left + size). */\nexport interface Box {\n readonly x: number;\n readonly y: number;\n readonly w: number;\n readonly h: number;\n}\n\n/** Routed edge: SVG `d` plus a midpoint for the edge label. */\nexport interface Route {\n readonly d: string;\n readonly lx: number;\n readonly ly: number;\n}\n\n/**\n * Routes an orthogonal edge from box A to box B.\n *\n * @param A - Source box.\n * @param B - Target box.\n * @returns SVG path data and label midpoint.\n */\nexport function ortho(A: Box, B: Box): Route {\n const a = { x: A.x + A.w / 2, y: A.y + A.h / 2 };\n const b = { x: B.x + B.w / 2, y: B.y + B.h / 2 };\n const dx = b.x - a.x;\n const dy = b.y - a.y;\n if (Math.abs(dx) >= Math.abs(dy)) {\n const sx = dx >= 0 ? A.x + A.w : A.x;\n const ex = dx >= 0 ? B.x : B.x + B.w;\n const sy = a.y;\n const ey = b.y;\n const mx = (sx + ex) / 2;\n return { d: `M ${sx} ${sy} H ${mx} V ${ey} H ${ex}`, lx: mx, ly: (sy + ey) / 2 };\n }\n const sy = dy >= 0 ? A.y + A.h : A.y;\n const ey = dy >= 0 ? B.y : B.y + B.h;\n const sx = a.x;\n const ex = b.x;\n const my = (sy + ey) / 2;\n return { d: `M ${sx} ${sy} V ${my} H ${ex} V ${ey}`, lx: (sx + ex) / 2, ly: my };\n}\n","/**\n * Wraps text to fit within an approximate character-per-line budget, capping\n * the total number of lines. Word-aware (won't break mid-word).\n *\n * Used by diagram renderers for fixed-size labels. Ported from\n * `resources/doc-studio.jsx` `wrapText`.\n */\n\n/**\n * @param text - Source text (any value is coerced via `String(...)`).\n * @param max - Approximate maximum characters per line.\n * @param maxLines - Maximum number of lines to return (later lines dropped).\n * @returns An array of wrapped lines; empty array for empty input.\n */\nexport function wrapText(text: unknown, max: number, maxLines: number): string[] {\n if (text === undefined || text === null || text === '') return [];\n const words = String(text).split(/\\s+/);\n const lines: string[] = [];\n let cur = '';\n for (const w of words) {\n if (!cur) {\n cur = w;\n continue;\n }\n if ((cur + ' ' + w).length <= max) {\n cur += ' ' + w;\n } else {\n lines.push(cur);\n cur = w;\n if (lines.length === maxLines) break;\n }\n }\n if (cur && lines.length < maxLines) lines.push(cur);\n return lines.slice(0, maxLines);\n}\n","/**\n * Renders an SVG edge label as a small rounded pill, sized to the label text.\n *\n * Returned as an SVG `<g>` fragment so it can be appended inside an enclosing\n * `<svg>`. Returns the empty string if `label` is falsy.\n *\n * Ported from `resources/doc-studio.jsx` `EdgePill`.\n */\n\nimport { escapeHtml } from '../escape.js';\n\n/** Pill placement (midpoint of the labelled edge). */\nexport interface PillPoint {\n readonly lx: number;\n readonly ly: number;\n}\n\n/**\n * @param p - Midpoint of the edge (typically from {@link ortho}).\n * @param label - Label text. Empty/undefined yields an empty string.\n * @param err - If true, the label is rendered in the error style.\n */\nexport function edgePill(p: PillPoint, label: string | undefined, err = false): string {\n if (label === undefined || label === '') return '';\n const w = Math.max(26, label.length * 5.4);\n const errClass = err ? ' err' : '';\n return (\n `<g>` +\n `<rect x=\"${p.lx - w / 2}\" y=\"${p.ly - 9}\" width=\"${w}\" height=\"18\" rx=\"9\" fill=\"#fff\" stroke=\"#d1d5db\"/>` +\n `<text x=\"${p.lx}\" y=\"${p.ly + 3}\" class=\"edge-label${errClass}\">${escapeHtml(label)}</text>` +\n `</g>`\n );\n}\n","/**\n * Auto-layout for the coordinate-grid diagram blocks (flow, c4, state, dfd, uml).\n *\n * These renderers place nodes on an integer `col`/`row` grid. When an author\n * supplies coordinates we honour them exactly; when any are missing we derive a\n * clean layered grid from the edges using dagre (pure JS, no DOM) — ranks become\n * one axis, order-within-rank the other — so you can declare just nodes + edges\n * and still get a sensible diagram. The downstream renderers are unchanged.\n */\n\nimport dagre from '@dagrejs/dagre';\n\ninterface HasGrid {\n readonly id: string;\n readonly col?: number | undefined;\n readonly row?: number | undefined;\n}\n\ninterface Edge {\n readonly from: string;\n readonly to: string;\n}\n\n/**\n * Returns the items with `col`/`row` guaranteed. If every item already has both,\n * they're used verbatim; otherwise all are placed by {@link autoGrid}.\n */\nexport function ensureGrid<T extends HasGrid>(\n items: readonly T[],\n edges: readonly Edge[],\n rankdir: 'TB' | 'LR',\n): Array<T & { col: number; row: number }> {\n const allPlaced =\n items.length > 0 && items.every((n) => n.col !== undefined && n.row !== undefined);\n if (allPlaced) {\n return items.map((n) => ({ ...n, col: n.col as number, row: n.row as number }));\n }\n const grid = autoGrid(\n items.map((n) => n.id),\n edges,\n rankdir,\n );\n return items.map((n) => {\n const g = grid.get(n.id) ?? { col: 1, row: 1 };\n return { ...n, col: g.col, row: g.row };\n });\n}\n\n/**\n * Lays out a directed graph with dagre using uniform node sizes (we only want\n * topology, not pixels), then snaps the result to an integer grid: for `TB`,\n * each distinct rank is a row and nodes are ordered into columns within it; for\n * `LR`, the axes swap.\n */\nfunction autoGrid(\n ids: readonly string[],\n edges: readonly Edge[],\n rankdir: 'TB' | 'LR',\n): Map<string, { col: number; row: number }> {\n const idSet = new Set(ids);\n const g = new dagre.graphlib.Graph();\n g.setGraph({ rankdir, nodesep: 16, ranksep: 16, marginx: 0, marginy: 0 });\n g.setDefaultEdgeLabel(() => ({}));\n for (const id of ids) g.setNode(id, { width: 10, height: 10 });\n for (const e of edges) {\n if (e.from !== e.to && idSet.has(e.from) && idSet.has(e.to)) g.setEdge(e.from, e.to);\n }\n dagre.layout(g);\n\n const pos = ids.map((id) => {\n const n = g.node(id) as { x?: number; y?: number } | undefined;\n return { id, x: Math.round(n?.x ?? 0), y: Math.round(n?.y ?? 0) };\n });\n\n const out = new Map<string, { col: number; row: number }>();\n // Group by the rank axis (same-rank nodes share a coordinate because all node\n // sizes are equal), then order within the rank along the other axis.\n if (rankdir === 'TB') {\n const ranks = [...new Set(pos.map((p) => p.y))].sort((a, b) => a - b);\n ranks.forEach((yv, ri) => {\n pos\n .filter((p) => p.y === yv)\n .sort((a, b) => a.x - b.x)\n .forEach((p, ci) => out.set(p.id, { col: ci + 1, row: ri + 1 }));\n });\n } else {\n const ranks = [...new Set(pos.map((p) => p.x))].sort((a, b) => a - b);\n ranks.forEach((xv, ci) => {\n pos\n .filter((p) => p.x === xv)\n .sort((a, b) => a.y - b.y)\n .forEach((p, ri) => out.set(p.id, { col: ci + 1, row: ri + 1 }));\n });\n }\n return out;\n}\n","/**\n * Renders a flowchart — decision diamonds, stadium start/end nodes, rectangles\n * for processes, with orthogonal edges and error-coloured paths.\n *\n * Ported from doc-studio.jsx `Flowchart` + `flowStyle`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { ortho } from '../svg/ortho.js';\nimport { wrapText } from '../svg/wrapText.js';\nimport { edgePill } from '../svg/edgePill.js';\nimport { diagramFrame } from './frame.js';\nimport { ensureGrid } from './autoLayout.js';\n\ntype Kind = 'start' | 'end' | 'decision' | 'process';\ninterface Style {\n shape: 'rect' | 'diamond' | 'stadium';\n fill: string;\n stroke: string;\n text: string;\n}\nfunction flowStyle(kind: Kind | undefined): Style {\n switch (kind ?? 'process') {\n case 'start':\n return { shape: 'stadium', fill: '#dcf1e2', stroke: '#1f9747', text: '#0f3d22' };\n case 'end':\n return { shape: 'stadium', fill: '#1a1a2e', stroke: '#1a1a2e', text: '#fff' };\n case 'decision':\n return { shape: 'diamond', fill: '#fde7cd', stroke: '#f7952c', text: '#7a3d00' };\n default:\n return { shape: 'rect', fill: '#e5eff8', stroke: '#0e54a1', text: '#0a3a6e' };\n }\n}\n\nconst ERR_LABEL_RE = /^(no|fail|error|reject)/i;\n\ninterface FlowFrameOpts {\n readonly tag: string;\n readonly tagBg?: string;\n}\n\n/** Generates the inner SVG (no diagram frame) — shared by `flow` and `dag`. */\nexport function renderFlowSvg(data: BlockDataMap['flow']): string {\n const edges = data.edges ?? [];\n const nodes = ensureGrid(data.nodes ?? [], edges, 'TB');\n const cellW = 176;\n const cellH = 70;\n const gapX = 60;\n const gapY = 56;\n const padX = 26;\n const padTop = 26;\n const padBot = 22;\n const cols = Math.max(1, ...nodes.map((n) => n.col + ((n.w ?? 1) - 1)));\n const rows = Math.max(1, ...nodes.map((n) => n.row));\n const xOf = (c: number): number => padX + (c - 1) * (cellW + gapX);\n const yOf = (r: number): number => padTop + (r - 1) * (cellH + gapY);\n const rectFor = (n: { col: number; row: number; w?: number | undefined }): {\n x: number;\n y: number;\n w: number;\n h: number;\n } => ({\n x: xOf(n.col),\n y: yOf(n.row),\n w: (n.w ?? 1) * cellW + ((n.w ?? 1) - 1) * gapX,\n h: cellH,\n });\n const byId = new Map(nodes.map((n) => [n.id, n]));\n const width = padX * 2 + cols * cellW + (cols - 1) * gapX;\n const height = padTop + rows * cellH + (rows - 1) * gapY + padBot;\n\n let s = `<svg viewBox=\"0 0 ${width} ${height}\" role=\"img\"><title>Flowchart</title>`;\n\n for (const e of edges) {\n const A = byId.get(e.from);\n const B = byId.get(e.to);\n if (!A || !B) continue;\n const p = ortho(rectFor(A), rectFor(B));\n const isErr = e.kind === 'error' || ERR_LABEL_RE.test(e.label ?? '');\n const stroke = isErr ? '#991b1b' : '#1a1a2e';\n const marker = isErr ? 'gErr' : 'gArrow';\n const sw = isErr ? 1.6 : 1.4;\n s +=\n `<g><path d=\"${p.d}\" fill=\"none\" stroke=\"${stroke}\" stroke-width=\"${sw}\" marker-end=\"url(#${marker})\"/>` +\n edgePill(p, e.label, isErr) +\n `</g>`;\n }\n\n for (const n of nodes) {\n const r = rectFor(n);\n const st = flowStyle(n.kind);\n const cx = r.x + r.w / 2;\n const cy = r.y + r.h / 2;\n let shape: string;\n if (st.shape === 'diamond') {\n shape = `<polygon points=\"${cx},${r.y} ${r.x + r.w},${cy} ${cx},${r.y + r.h} ${r.x},${cy}\" fill=\"${st.fill}\" stroke=\"${st.stroke}\" stroke-width=\"1.5\"/>`;\n } else if (st.shape === 'stadium') {\n shape = `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"${r.w}\" height=\"${r.h}\" rx=\"${r.h / 2}\" fill=\"${st.fill}\" stroke=\"${st.stroke}\" stroke-width=\"1.5\"/>`;\n } else {\n shape = `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"${r.w}\" height=\"${r.h}\" rx=\"7\" fill=\"${st.fill}\" stroke=\"${st.stroke}\" stroke-width=\"1.4\"/>`;\n }\n const lines = wrapText(n.label, 22, 2);\n const texts = lines\n .map(\n (ln, j) =>\n `<text x=\"${cx}\" y=\"${cy + 4 - (lines.length - 1) * 7 + j * 14}\" class=\"fc-label\" fill=\"${st.text}\">${escapeHtml(ln)}</text>`,\n )\n .join('');\n s += `<g filter=\"url(#gshadow)\">${shape}${texts}</g>`;\n }\n\n s += `</svg>`;\n return s;\n}\n\nfunction renderFlowFrame(data: BlockDataMap['flow'], frame: FlowFrameOpts): string {\n return diagramFrame(\n {\n tag: frame.tag,\n ...(frame.tagBg !== undefined ? { tagBg: frame.tagBg } : {}),\n ...(data.title !== undefined ? { title: data.title } : {}),\n ...(data.description !== undefined ? { desc: data.description } : {}),\n },\n renderFlowSvg(data),\n );\n}\n\n/** `flow` — decision flow with slate `FLOW` tag. */\nexport function renderFlow(data: BlockDataMap['flow']): string {\n return renderFlowFrame(data, { tag: 'FLOW', tagBg: '#374151' });\n}\n/** `dag` — same shape, navy `DAG` tag (pipeline / directed-acyclic graph). */\nexport function renderDag(data: BlockDataMap['dag']): string {\n return renderFlowFrame(data as BlockDataMap['flow'], { tag: 'DAG', tagBg: '#0e54a1' });\n}\n","/**\n * Renders a state machine: rounded state pills + start/terminal markers + an\n * orthogonal-routed edge per transition, plus a transition table below.\n *\n * Ported from doc-studio.jsx `StateMachine` + `TransitionTable`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { ortho } from '../svg/ortho.js';\nimport { edgePill } from '../svg/edgePill.js';\nimport { diagramFrame } from './frame.js';\nimport { ensureGrid } from './autoLayout.js';\n\ntype StateNode = NonNullable<BlockDataMap['state']['states']>[number];\n\nfunction rectFor(s: StateNode & { col: number; row: number }, cellW: number, cellH: number, gapX: number, gapY: number, padX: number, padTop: number): {\n x: number;\n y: number;\n w: number;\n h: number;\n cx: number;\n cy: number;\n} {\n const cx = padX + (s.col - 1) * (cellW + gapX) + cellW / 2;\n const cy = padTop + (s.row - 1) * (cellH + gapY) + cellH / 2;\n if (s.kind === 'start' || s.kind === 'terminal') {\n return { x: cx - 13, y: cy - 13, w: 26, h: 26, cx, cy };\n }\n const pw = Math.max(96, (s.name ?? '').length * 8 + 26);\n const ph = 46;\n return { x: cx - pw / 2, y: cy - ph / 2, w: pw, h: ph, cx, cy };\n}\n\nfunction pillCls(kind: StateNode['kind']): string {\n if (kind === 'terminal') return 'pill pill-end';\n if (kind === 'wait') return 'pill pill-wait';\n if (kind === 'start') return 'pill pill-init';\n return 'pill pill-active';\n}\n\nexport function renderState(data: BlockDataMap['state']): string {\n const trans = data.transitions ?? [];\n const states = ensureGrid(data.states ?? [], trans, 'LR');\n const cellW = 168;\n const cellH = 64;\n const gapX = 74;\n const gapY = 60;\n const padX = 30;\n const padTop = 30;\n const padBot = 20;\n const cols = Math.max(1, ...states.map((s) => s.col));\n const rows = Math.max(1, ...states.map((s) => s.row));\n const width = padX * 2 + cols * cellW + (cols - 1) * gapX;\n const height = padTop * 2 + rows * cellH + (rows - 1) * gapY + padBot;\n const byId = new Map(states.map((s) => [s.id, s]));\n\n let s = `<svg viewBox=\"0 0 ${width} ${height}\" role=\"img\"><title>State machine</title>`;\n\n // edges first\n for (const t of trans) {\n const A = byId.get(t.from);\n const B = byId.get(t.to);\n if (!A || !B) continue;\n const label = t.event + (t.guard !== undefined ? ` ${t.guard}` : '');\n if (t.from === t.to) {\n const r = rectFor(A, cellW, cellH, gapX, gapY, padX, padTop);\n s +=\n `<g><path d=\"M ${r.cx - 12} ${r.y} C ${r.cx - 30} ${r.y - 32}, ${r.cx + 30} ${r.y - 32}, ${r.cx + 12} ${r.y}\" fill=\"none\" stroke=\"#1a1a2e\" stroke-width=\"1.3\" marker-end=\"url(#gArrow)\"/>` +\n edgePill({ lx: r.cx, ly: r.y - 28 }, label) +\n `</g>`;\n continue;\n }\n const p = ortho(\n rectFor(A, cellW, cellH, gapX, gapY, padX, padTop),\n rectFor(B, cellW, cellH, gapX, gapY, padX, padTop),\n );\n s +=\n `<g><path d=\"${p.d}\" fill=\"none\" stroke=\"#1a1a2e\" stroke-width=\"1.3\" marker-end=\"url(#gArrow)\"/>` +\n edgePill(p, label) +\n `</g>`;\n }\n\n // states\n for (const st of states) {\n const r = rectFor(st, cellW, cellH, gapX, gapY, padX, padTop);\n if (st.kind === 'start') {\n s += `<circle cx=\"${r.cx}\" cy=\"${r.cy}\" r=\"10\" fill=\"#1a1a2e\"/>`;\n } else if (st.kind === 'terminal') {\n s +=\n `<g>` +\n `<circle cx=\"${r.cx}\" cy=\"${r.cy}\" r=\"12\" fill=\"#fff\" stroke=\"#1a1a2e\" stroke-width=\"1.5\"/>` +\n `<circle cx=\"${r.cx}\" cy=\"${r.cy}\" r=\"6\" fill=\"#1a1a2e\"/>` +\n `</g>`;\n } else {\n const fill = st.kind === 'wait' ? '#fde7cd' : '#dcf1e2';\n const stroke = st.kind === 'wait' ? '#f7952c' : '#1f9747';\n s +=\n `<g filter=\"url(#gshadow)\">` +\n `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"${r.w}\" height=\"${r.h}\" rx=\"23\" fill=\"${fill}\" stroke=\"${stroke}\" stroke-width=\"1.5\"/>` +\n `<text x=\"${r.cx}\" y=\"${r.cy + 4.5}\" class=\"sm-name\" fill=\"#1a1a2e\">${escapeHtml(st.name ?? '')}</text>` +\n `</g>`;\n }\n }\n\n s += `</svg>`;\n\n // transition table\n const name = (id: string): string => byId.get(id)?.name ?? id;\n const rows2 = trans\n .map(\n (t) =>\n `<tr>` +\n `<td><span class=\"${pillCls(byId.get(t.from)?.kind)}\">${escapeHtml(name(t.from))}</span></td>` +\n `<td style=\"font-family:var(--font-mono);font-size:11px\">${escapeHtml(t.event)}</td>` +\n `<td style=\"color:#6b7280;font-size:11px\">${escapeHtml(t.guard ?? '—')}</td>` +\n `<td><span class=\"${pillCls(byId.get(t.to)?.kind)}\">${escapeHtml(name(t.to))}</span></td>` +\n `</tr>`,\n )\n .join('');\n const table =\n trans.length > 0\n ? `<table class=\"transition-table\">` +\n `<thead><tr><th>From</th><th>Event</th><th>Guard</th><th>To</th></tr></thead>` +\n `<tbody>${rows2}</tbody></table>`\n : '';\n\n return diagramFrame(\n {\n tag: 'STATE',\n tagBg: '#6b21a8',\n ...(data.title !== undefined ? { title: data.title } : {}),\n ...(data.description !== undefined ? { desc: data.description } : {}),\n },\n s + table,\n );\n}\n","/**\n * Renders a data-flow diagram — process bubbles, external rectangles, and\n * three-sided data-store boxes, with orthogonal edges.\n *\n * Ported from doc-studio.jsx `DFDDiagram` + `dfdStyle`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { ortho } from '../svg/ortho.js';\nimport { edgePill } from '../svg/edgePill.js';\nimport { diagramFrame } from './frame.js';\nimport { ensureGrid } from './autoLayout.js';\n\nfunction dfdStyle(kind: string | undefined): { fill: string; stroke: string; text: string } {\n switch ((kind ?? 'process').toLowerCase()) {\n case 'external':\n return { fill: '#f3f4f6', stroke: '#6b7280', text: '#374151' };\n case 'store':\n case 'datastore':\n return { fill: '#fde7cd', stroke: '#f7952c', text: '#7a3d00' };\n default:\n return { fill: '#e5eff8', stroke: '#0e54a1', text: '#0a3a6e' };\n }\n}\n\nexport function renderDfd(data: BlockDataMap['dfd']): string {\n const edges = data.edges ?? [];\n const nodes = ensureGrid(data.nodes ?? [], edges, 'LR');\n const cellW = 168;\n const cellH = 76;\n const gapX = 60;\n const gapY = 58;\n const padX = 26;\n const padTop = 26;\n const padBot = 20;\n const cols = Math.max(1, ...nodes.map((n) => n.col));\n const rows = Math.max(1, ...nodes.map((n) => n.row));\n const xOf = (c: number): number => padX + (c - 1) * (cellW + gapX);\n const yOf = (r: number): number => padTop + (r - 1) * (cellH + gapY);\n const rectFor = (n: { col: number; row: number }): {\n x: number;\n y: number;\n w: number;\n h: number;\n } => ({ x: xOf(n.col), y: yOf(n.row), w: cellW, h: cellH });\n const byId = new Map(nodes.map((n) => [n.id, n]));\n const width = padX * 2 + cols * cellW + (cols - 1) * gapX;\n const height = padTop + rows * cellH + (rows - 1) * gapY + padBot;\n\n let s = `<svg viewBox=\"0 0 ${width} ${height}\" role=\"img\"><title>Data-flow diagram</title>`;\n\n for (const e of edges) {\n const A = byId.get(e.from);\n const B = byId.get(e.to);\n if (!A || !B) continue;\n const p = ortho(rectFor(A), rectFor(B));\n s +=\n `<g><path d=\"${p.d}\" fill=\"none\" stroke=\"#1a1a2e\" stroke-width=\"1.4\" marker-end=\"url(#gArrow)\"/>` +\n edgePill(p, e.label) +\n `</g>`;\n }\n\n for (const n of nodes) {\n const r = rectFor(n);\n const st = dfdStyle(n.kind);\n const k = (n.kind ?? 'process').toLowerCase();\n let shape: string;\n if (k === 'process') {\n shape = `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"${r.w}\" height=\"${r.h}\" rx=\"16\" fill=\"${st.fill}\" stroke=\"${st.stroke}\" stroke-width=\"1.4\"/>`;\n } else if (k === 'store' || k === 'datastore') {\n shape =\n `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"${r.w}\" height=\"${r.h}\" fill=\"${st.fill}\" stroke=\"none\"/>` +\n `<line x1=\"${r.x}\" y1=\"${r.y}\" x2=\"${r.x + r.w}\" y2=\"${r.y}\" stroke=\"${st.stroke}\" stroke-width=\"1.6\"/>` +\n `<line x1=\"${r.x}\" y1=\"${r.y + r.h}\" x2=\"${r.x + r.w}\" y2=\"${r.y + r.h}\" stroke=\"${st.stroke}\" stroke-width=\"1.6\"/>` +\n `<line x1=\"${r.x}\" y1=\"${r.y}\" x2=\"${r.x}\" y2=\"${r.y + r.h}\" stroke=\"${st.stroke}\" stroke-width=\"1.6\"/>`;\n } else {\n shape = `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"${r.w}\" height=\"${r.h}\" fill=\"${st.fill}\" stroke=\"${st.stroke}\" stroke-width=\"1.4\"/>`;\n }\n const num =\n n.num !== undefined && k === 'process'\n ? `<text x=\"${r.x + 12}\" y=\"${r.y + 18}\" class=\"dfd-num\" fill=\"${st.text}\">${escapeHtml(n.num)}</text>`\n : '';\n s +=\n `<g filter=\"url(#gshadow)\">${shape}${num}` +\n `<text x=\"${r.x + r.w / 2}\" y=\"${r.y + r.h / 2 + 4}\" class=\"dfd-name\" fill=\"${st.text}\">${escapeHtml(n.name)}</text>` +\n `</g>`;\n }\n\n s += `</svg>`;\n return diagramFrame(\n {\n tag: 'DFD',\n tagBg: '#0e54a1',\n ...(data.title !== undefined ? { title: data.title } : {}),\n ...(data.description !== undefined ? { desc: data.description } : {}),\n },\n s,\n );\n}\n","/**\n * Renders a user-journey map — a table of touchpoints across stages, plus an\n * optional emotion curve (SVG polyline) showing user sentiment per stage.\n *\n * Ported from doc-studio.jsx `JourneyMap`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\nfunction clamp01(v: number): number {\n if (v < 0) return 0;\n if (v > 1) return 1;\n return v;\n}\n\nexport function renderJourney(data: BlockDataMap['journey']): string {\n const stages = data.stages ?? [];\n const rows = data.rows ?? [];\n const emotion = data.emotion ?? [];\n const n = Math.max(stages.length, 1);\n const W = Math.max(380, n * 150);\n const H = 92;\n const pad = 20;\n const colW = (W - pad * 2) / n;\n const ex = (i: number): number => pad + colW * (i + 0.5);\n const ey = (v: number): number => H - 14 - (H - 30) * clamp01(v);\n\n const head =\n `<tr><th></th>` +\n stages.map((s) => `<th class=\"c\">${escapeHtml(s.label)}</th>`).join('') +\n `</tr>`;\n const body = rows\n .map(\n (r) =>\n `<tr><td class=\"lead\">${escapeHtml(r.label)}</td>` +\n (r.cells ?? []).map((c) => `<td class=\"c\">${escapeHtml(c)}</td>`).join('') +\n `</tr>`,\n )\n .join('');\n\n let svg = '';\n if (emotion.length > 0) {\n const points = emotion.map((v, i) => `${ex(i)},${ey(v)}`).join(' ');\n const dots = emotion\n .map((v, i) => {\n const fill = v >= 0.6 ? '#1f9747' : v <= 0.35 ? '#991b1b' : '#f7952c';\n return `<circle cx=\"${ex(i)}\" cy=\"${ey(v)}\" r=\"5\" fill=\"${fill}\" stroke=\"#fff\" stroke-width=\"1.5\"/>`;\n })\n .join('');\n svg =\n `<div style=\"margin-top:10px\">` +\n `<div style=\"font-size:10px;color:#6b7280;font-weight:700;text-transform:uppercase;letter-spacing:.08em;margin-bottom:4px\">Emotion</div>` +\n `<svg viewBox=\"0 0 ${W} ${H}\" style=\"width:100%\" role=\"img\"><title>Emotion curve</title>` +\n `<polyline points=\"${points}\" fill=\"none\" stroke=\"#0e54a1\" stroke-width=\"2\"/>` +\n dots +\n `</svg></div>`;\n }\n\n return (\n `<div>` +\n `<table class=\"pres-table\"><thead>${head}</thead><tbody>${body}</tbody></table>` +\n svg +\n `</div>`\n );\n}\n","/**\n * Renders a Gantt chart — period columns across the top, task rows with\n * horizontal bars colored by kind (done / active / milestone / default).\n *\n * Ported from doc-studio.jsx `Gantt` + `ganttColor`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\n\nfunction ganttColor(kind: string | undefined): string {\n switch ((kind ?? '').toLowerCase()) {\n case 'done':\n return '#1f9747';\n case 'active':\n case 'current':\n return '#f7952c';\n case 'milestone':\n return '#6b21a8';\n default:\n return '#0e54a1';\n }\n}\n\nexport function renderGantt(data: BlockDataMap['gantt']): string {\n const periods = data.periods ?? [];\n const tasks = data.tasks ?? [];\n const P = Math.max(periods.length, 1);\n const labelW = 156;\n const padX = 20;\n const padTop = 34;\n const rowH = 30;\n const barH = 18;\n const colW = 64;\n const padBot = 14;\n const width = labelW + padX * 2 + P * colW;\n const height = padTop + tasks.length * rowH + padBot;\n const xCol = (i: number): number => labelW + padX + i * colW;\n\n let s = `<svg viewBox=\"0 0 ${width} ${height}\" role=\"img\"><title>Schedule</title>`;\n for (let i = 0; i < periods.length; i++) {\n s +=\n `<g>` +\n `<line x1=\"${xCol(i)}\" y1=\"${padTop - 6}\" x2=\"${xCol(i)}\" y2=\"${height - padBot}\" stroke=\"#eef0f3\" stroke-width=\"1\"/>` +\n `<text x=\"${xCol(i) + colW / 2}\" y=\"${padTop - 12}\" class=\"gantt-head\">${escapeHtml(periods[i] ?? '')}</text>` +\n `</g>`;\n }\n s += `<line x1=\"${xCol(P)}\" y1=\"${padTop - 6}\" x2=\"${xCol(P)}\" y2=\"${height - padBot}\" stroke=\"#eef0f3\" stroke-width=\"1\"/>`;\n for (let i = 0; i < tasks.length; i++) {\n const t = tasks[i];\n if (t === undefined) continue;\n const y = padTop + i * rowH;\n const bx = xCol(t.start ?? 0);\n const span = Math.max(1, t.span ?? 1);\n const bw = span * colW - 8;\n s +=\n `<g>` +\n `<text x=\"${padX}\" y=\"${y + rowH / 2 + 4}\" class=\"gantt-label\">${escapeHtml(t.label)}</text>` +\n `<rect x=\"${bx + 4}\" y=\"${y + (rowH - barH) / 2}\" width=\"${bw}\" height=\"${barH}\" rx=\"4\" fill=\"${ganttColor(t.kind)}\" filter=\"url(#gshadow)\"/>` +\n `</g>`;\n }\n s += `</svg>`;\n return s;\n}\n","/**\n * Renders a generic node-link graph — rounded pills colored by group, with\n * orthogonal edges (directed or undirected).\n *\n * Ported from doc-studio.jsx `Graph`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { ortho } from '../svg/ortho.js';\nimport { edgePill } from '../svg/edgePill.js';\nimport { diagramFrame } from './frame.js';\n\nconst CHART_COLORS = ['#0e54a1', '#1a6dbe', '#0f766e', '#1f9747', '#6b21a8', '#f7952c'];\n\nexport function renderGraph(data: BlockDataMap['graph']): string {\n const nodes = data.nodes ?? [];\n const edges = data.edges ?? [];\n const cellW = 150;\n const cellH = 84;\n const gapX = 44;\n const gapY = 40;\n const padX = 26;\n const padTop = 24;\n const padBot = 20;\n const cols = Math.max(1, ...nodes.map((n) => n.col));\n const rows = Math.max(1, ...nodes.map((n) => n.row));\n const cxOf = (c: number): number => padX + (c - 1) * (cellW + gapX) + cellW / 2;\n const cyOf = (r: number): number => padTop + (r - 1) * (cellH + gapY) + cellH / 2;\n const rectFor = (n: { col: number; row: number; label: string }): {\n x: number;\n y: number;\n w: number;\n h: number;\n cx: number;\n cy: number;\n } => {\n const cx = cxOf(n.col);\n const cy = cyOf(n.row);\n const w = Math.max(98, n.label.length * 8 + 26);\n return { x: cx - w / 2, y: cy - 20, w, h: 40, cx, cy };\n };\n const byId = new Map(nodes.map((n) => [n.id, n]));\n const width = padX * 2 + cols * cellW + (cols - 1) * gapX;\n const height = padTop + rows * cellH + (rows - 1) * gapY + padBot;\n\n let s = `<svg viewBox=\"0 0 ${width} ${height}\" role=\"img\"><title>Graph</title>`;\n\n for (const e of edges) {\n const A = byId.get(e.from);\n const B = byId.get(e.to);\n if (!A || !B) continue;\n const p = ortho(rectFor(A), rectFor(B));\n const directed = (e.dir ?? 'directed') !== 'undirected';\n const markerAttr = directed ? ` marker-end=\"url(#gArrow)\"` : '';\n s +=\n `<g><path d=\"${p.d}\" fill=\"none\" stroke=\"#6b7280\" stroke-width=\"1.4\"${markerAttr}/>` +\n edgePill(p, e.label) +\n `</g>`;\n }\n\n for (const n of nodes) {\n const r = rectFor(n);\n const c = CHART_COLORS[(n.group ?? 0) % CHART_COLORS.length] ?? '#0e54a1';\n s +=\n `<g filter=\"url(#gshadow)\">` +\n `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"${r.w}\" height=\"${r.h}\" rx=\"20\" fill=\"#fff\" stroke=\"${c}\" stroke-width=\"1.6\"/>` +\n `<text x=\"${r.cx}\" y=\"${r.cy + 4}\" class=\"blk-name\" fill=\"${c}\" text-anchor=\"middle\" style=\"font-size:12px\">${escapeHtml(n.label)}</text>` +\n `</g>`;\n }\n\n s += `</svg>`;\n return diagramFrame(\n {\n tag: 'GRAPH',\n tagBg: '#374151',\n ...(data.title !== undefined ? { title: data.title } : {}),\n ...(data.description !== undefined ? { desc: data.description } : {}),\n },\n s,\n );\n}\n","/**\n * Renders a 2x2 matrix — labelled axes, optional low/high endpoint labels,\n * and dots for each `(x, y, label)` item.\n *\n * Ported from doc-studio.jsx `Quadrant`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { diagramFrame } from './frame.js';\n\nfunction clamp01(v: number | undefined): number {\n if (v === undefined || Number.isNaN(v)) return 0.5;\n if (v < 0) return 0;\n if (v > 1) return 1;\n return v;\n}\n\nexport function renderQuadrant(data: BlockDataMap['quadrant']): string {\n const W = 580;\n const H = 440;\n const pad = 56;\n const x0 = pad;\n const x1 = W - pad;\n const y0 = pad - 16;\n const y1 = H - pad;\n const mx = (x0 + x1) / 2;\n const my = (y0 + y1) / 2;\n const px = (v: number | undefined): number => x0 + (x1 - x0) * clamp01(v);\n const py = (v: number | undefined): number => y1 - (y1 - y0) * clamp01(v);\n const items = data.items ?? [];\n const xA = data.xAxis ?? {};\n const yA = data.yAxis ?? {};\n\n let s = `<svg viewBox=\"0 0 ${W} ${H}\" role=\"img\"><title>Quadrant</title>`;\n s += `<rect x=\"${x0}\" y=\"${y0}\" width=\"${x1 - x0}\" height=\"${y1 - y0}\" fill=\"#fafbfc\" stroke=\"#e5e7eb\"/>`;\n s += `<rect x=\"${mx}\" y=\"${y0}\" width=\"${x1 - mx}\" height=\"${my - y0}\" fill=\"#0e54a1\" fill-opacity=\"0.04\"/>`;\n s += `<line x1=\"${x0}\" y1=\"${my}\" x2=\"${x1}\" y2=\"${my}\" class=\"quad-axis\" marker-end=\"url(#gArrow)\"/>`;\n s += `<line x1=\"${mx}\" y1=\"${y1}\" x2=\"${mx}\" y2=\"${y0}\" class=\"quad-axis\" marker-end=\"url(#gArrow)\"/>`;\n\n if (xA.label !== undefined)\n s += `<text x=\"${x1}\" y=\"${y1 + 30}\" class=\"quad-title\" text-anchor=\"end\">${escapeHtml(xA.label)} →</text>`;\n if (yA.label !== undefined)\n s += `<text x=\"${mx - 8}\" y=\"${y0 - 4}\" class=\"quad-title\" text-anchor=\"end\">↑ ${escapeHtml(yA.label)}</text>`;\n if (xA.low !== undefined)\n s += `<text x=\"${x0}\" y=\"${y1 + 16}\" class=\"quad-end\" text-anchor=\"start\">${escapeHtml(xA.low)}</text>`;\n if (xA.high !== undefined)\n s += `<text x=\"${x1}\" y=\"${y1 + 16}\" class=\"quad-end\" text-anchor=\"end\">${escapeHtml(xA.high)}</text>`;\n if (yA.high !== undefined)\n s += `<text x=\"${x0 - 10}\" y=\"${y0 + 6}\" class=\"quad-end\" text-anchor=\"end\">${escapeHtml(yA.high)}</text>`;\n if (yA.low !== undefined)\n s += `<text x=\"${x0 - 10}\" y=\"${y1}\" class=\"quad-end\" text-anchor=\"end\">${escapeHtml(yA.low)}</text>`;\n\n for (const it of items) {\n const cx = px(it.x);\n const cy = py(it.y);\n const left = cx > mx;\n const tx = cx + (left ? -12 : 12);\n const anchor = left ? 'end' : 'start';\n s +=\n `<g filter=\"url(#gshadow)\">` +\n `<circle cx=\"${cx}\" cy=\"${cy}\" r=\"7\" fill=\"#f7952c\" stroke=\"#fff\" stroke-width=\"1.5\"/>` +\n `<text x=\"${tx}\" y=\"${cy + 4}\" class=\"quad-pt-label\" text-anchor=\"${anchor}\">${escapeHtml(it.label)}</text>` +\n `</g>`;\n }\n\n s += `</svg>`;\n return diagramFrame(\n {\n tag: '2×2',\n tagBg: '#0f766e',\n ...(data.title !== undefined ? { title: data.title } : {}),\n ...(data.description !== undefined ? { desc: data.description } : {}),\n },\n s,\n );\n}\n","/**\n * Renders a swimlane diagram — horizontal lanes per role with labelled steps\n * in column positions, plus orthogonal links between steps.\n *\n * Ported from doc-studio.jsx `Swimlane` + `laneColor`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { ortho } from '../svg/ortho.js';\nimport { wrapText } from '../svg/wrapText.js';\nimport { edgePill } from '../svg/edgePill.js';\nimport { diagramFrame } from './frame.js';\n\nfunction laneColor(kind: string | undefined): { fill: string; stroke: string; text: string } {\n switch ((kind ?? 'action').toLowerCase()) {\n case 'decision':\n return { fill: '#fde7cd', stroke: '#f7952c', text: '#7a3d00' };\n case 'start':\n case 'end':\n return { fill: '#dcf1e2', stroke: '#1f9747', text: '#0f3d22' };\n case 'wait':\n return { fill: '#f3f4f6', stroke: '#6b7280', text: '#374151' };\n default:\n return { fill: '#e5eff8', stroke: '#0e54a1', text: '#0a3a6e' };\n }\n}\n\nexport function renderSwimlane(data: BlockDataMap['swimlane']): string {\n const lanes = data.lanes ?? [];\n const steps = data.steps ?? [];\n const links = data.links ?? [];\n const labelW = 132;\n const padX = 18;\n const padTop = 24;\n const padBot = 20;\n const laneH = 92;\n const colW = 168;\n const gapCol = 34;\n const boxW = 150;\n const boxH = 52;\n const cols = Math.max(1, ...steps.map((s) => s.col));\n const xCol = (c: number): number => labelW + padX + (c - 1) * (colW + gapCol);\n const yLane = (l: number): number => padTop + l * laneH;\n const rectFor = (s: { col: number; lane: number }): {\n x: number;\n y: number;\n w: number;\n h: number;\n } => ({\n x: xCol(s.col) + (colW - boxW) / 2,\n y: yLane(s.lane) + (laneH - boxH) / 2,\n w: boxW,\n h: boxH,\n });\n const byId = new Map(steps.map((s) => [s.id, s]));\n const width = labelW + padX * 2 + cols * colW + (cols - 1) * gapCol;\n const height = padTop + lanes.length * laneH + padBot;\n\n let s = `<svg viewBox=\"0 0 ${width} ${height}\" role=\"img\"><title>Swimlane</title>`;\n\n for (let i = 0; i < lanes.length; i++) {\n const L = lanes[i];\n if (L === undefined) continue;\n s +=\n `<g>` +\n `<rect x=\"${padX}\" y=\"${yLane(i)}\" width=\"${width - padX * 2}\" height=\"${laneH}\" fill=\"${i % 2 ? '#fafafa' : '#fff'}\" stroke=\"#e5e7eb\"/>` +\n `<rect x=\"${padX}\" y=\"${yLane(i)}\" width=\"${labelW}\" height=\"${laneH}\" fill=\"#0e54a1\"/>` +\n `<text x=\"${padX + 14}\" y=\"${yLane(i) + laneH / 2 + 4}\" class=\"sl-lane-label\">${escapeHtml(L.label)}</text>` +\n `</g>`;\n }\n\n for (const lk of links) {\n const A = byId.get(lk.from);\n const B = byId.get(lk.to);\n if (!A || !B) continue;\n const p = ortho(rectFor(A), rectFor(B));\n s +=\n `<g><path d=\"${p.d}\" fill=\"none\" stroke=\"#1a1a2e\" stroke-width=\"1.4\" marker-end=\"url(#gArrow)\"/>` +\n edgePill(p, lk.label) +\n `</g>`;\n }\n\n for (const st of steps) {\n const r = rectFor(st);\n const c = laneColor(st.kind);\n const lines = wrapText(st.label, 20, 2);\n const texts = lines\n .map(\n (ln, j) =>\n `<text x=\"${r.x + r.w / 2}\" y=\"${r.y + r.h / 2 + 4 - (lines.length - 1) * 7 + j * 14}\" class=\"sl-step\" fill=\"${c.text}\">${escapeHtml(ln)}</text>`,\n )\n .join('');\n s +=\n `<g filter=\"url(#gshadow)\">` +\n `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"${r.w}\" height=\"${r.h}\" rx=\"7\" fill=\"${c.fill}\" stroke=\"${c.stroke}\" stroke-width=\"1.3\"/>` +\n texts +\n `</g>`;\n }\n\n s += `</svg>`;\n return diagramFrame(\n {\n tag: 'LANES',\n tagBg: '#0e54a1',\n ...(data.title !== undefined ? { title: data.title } : {}),\n ...(data.description !== undefined ? { desc: data.description } : {}),\n },\n s,\n );\n}\n","/**\n * Shared color palette + node-glyph helpers used by architecture-flavoured\n * blocks (cluster, block, infra, felogic, belogic, …).\n *\n * Ported from doc-studio.jsx `blockStyle` + `nodeGlyph`.\n */\n\n/** Color triple for a node kind: accent (stripe / border), fill, text color. */\nexport interface NodeColors {\n readonly accent: string;\n readonly fill: string;\n readonly text: string;\n}\n\n/** Maps a node `kind` (client / service / store / queue / ...) to colors. */\nexport function blockStyle(kind: string | undefined): NodeColors {\n switch ((kind ?? '').toLowerCase()) {\n case 'client':\n return { accent: '#0e54a1', fill: '#e5eff8', text: '#0a3a6e' };\n case 'service':\n case 'microservice':\n case 'compute':\n case 'container':\n return { accent: '#1f9747', fill: '#dcf1e2', text: '#0f3d22' };\n case 'data':\n return { accent: '#6b21a8', fill: '#ede9fe', text: '#4a1772' };\n case 'store':\n case 'db':\n case 'database':\n return { accent: '#f7952c', fill: '#fde7cd', text: '#7a3d00' };\n case 'bucket':\n case 'blob':\n case 'object':\n return { accent: '#b45309', fill: '#fef3c7', text: '#7a3d00' };\n case 'queue':\n return { accent: '#0f766e', fill: '#ccfbf1', text: '#0f4f49' };\n case 'cache':\n return { accent: '#0891b2', fill: '#cffafe', text: '#0e4f5c' };\n case 'gateway':\n case 'lb':\n return { accent: '#0e54a1', fill: '#cfe0f3', text: '#0a3a6e' };\n case 'function':\n case 'lambda':\n return { accent: '#7c3aed', fill: '#ede9fe', text: '#4a1772' };\n case 'cdn':\n return { accent: '#1a6dbe', fill: '#e5eff8', text: '#0a3a6e' };\n case 'external':\n return { accent: '#6b7280', fill: '#f3f4f6', text: '#374151' };\n case 'producer':\n return { accent: '#1f9747', fill: '#dcf1e2', text: '#0f3d22' };\n case 'topic':\n return { accent: '#0f766e', fill: '#ccfbf1', text: '#0f4f49' };\n case 'consumer':\n return { accent: '#1a6dbe', fill: '#e5eff8', text: '#0a3a6e' };\n case 'context':\n return { accent: '#6b21a8', fill: '#ede9fe', text: '#4a1772' };\n case 'firewall':\n return { accent: '#991b1b', fill: '#fee2e2', text: '#991b1b' };\n default:\n return { accent: '#374151', fill: '#fff', text: '#1a1a2e' };\n }\n}\n\n/**\n * Returns a small SVG glyph (database cylinder, queue bars, function ƒ, …)\n * for the given node kind, or empty string if no glyph applies.\n *\n * @param kind - Node kind.\n * @param x - Glyph top-left x.\n * @param y - Glyph top-left y.\n * @param c - Stroke / fill color.\n */\nexport function nodeGlyph(kind: string | undefined, x: number, y: number, c: string): string {\n const k = (kind ?? '').toLowerCase();\n if (k === 'store' || k === 'db' || k === 'database') {\n return (\n `<g stroke=\"${c}\" stroke-width=\"1.3\" fill=\"none\">` +\n `<ellipse cx=\"${x + 8}\" cy=\"${y + 3}\" rx=\"7\" ry=\"3\"/>` +\n `<path d=\"M${x + 1} ${y + 3} V ${y + 13}\"/>` +\n `<path d=\"M${x + 15} ${y + 3} V ${y + 13}\"/>` +\n `<path d=\"M${x + 1} ${y + 13} a 7 3 0 0 0 14 0\"/>` +\n `</g>`\n );\n }\n if (k === 'bucket' || k === 'blob' || k === 'object') {\n return (\n `<g stroke=\"${c}\" stroke-width=\"1.3\" fill=\"none\">` +\n `<ellipse cx=\"${x + 8}\" cy=\"${y + 3}\" rx=\"7\" ry=\"2.5\"/>` +\n `<path d=\"M${x + 1.5} ${y + 3} L ${x + 3.5} ${y + 14} L ${x + 12.5} ${y + 14} L ${x + 14.5} ${y + 3}\"/>` +\n `</g>`\n );\n }\n if (k === 'queue' || k === 'topic') {\n return (\n `<g stroke=\"${c}\" stroke-width=\"1.6\">` +\n `<path d=\"M${x + 2} ${y + 1} V ${y + 14}\"/>` +\n `<path d=\"M${x + 8} ${y + 1} V ${y + 14}\"/>` +\n `<path d=\"M${x + 14} ${y + 1} V ${y + 14}\"/>` +\n `</g>`\n );\n }\n if (k === 'firewall') {\n return `<path d=\"M${x + 8} ${y} L ${x + 15} ${y + 3} V ${y + 9} Q ${x + 15} ${y + 14} ${x + 8} ${y + 16} Q ${x + 1} ${y + 14} ${x + 1} ${y + 9} V ${y + 3} Z\" fill=\"none\" stroke=\"${c}\" stroke-width=\"1.3\"/>`;\n }\n if (k === 'cache') {\n // stacked slabs (memory layers) — three offset parallelograms\n const slab = (dy: number): string =>\n `<path d=\"M${x + 1} ${y + 5 + dy} L${x + 8} ${y + 2 + dy} L${x + 15} ${y + 5 + dy} L${x + 8} ${y + 8 + dy} Z\" fill=\"none\" stroke=\"${c}\" stroke-width=\"1.2\"/>`;\n return `<g>${slab(0)}${slab(3.5)}${slab(7)}</g>`;\n }\n if (k === 'function' || k === 'lambda') {\n return `<text x=\"${x + 7}\" y=\"${y + 14}\" font-family=\"Georgia, serif\" font-size=\"17\" font-style=\"italic\" font-weight=\"700\" fill=\"${c}\" text-anchor=\"middle\">ƒ</text>`;\n }\n if (k === 'cdn' || k === 'external') {\n return `<path d=\"M${x + 3} ${y + 13} a 4 4 0 0 1 0.5 -8 a 5 5 0 0 1 9.5 1.2 a 3 3 0 0 1 1 6.8 z\" fill=\"none\" stroke=\"${c}\" stroke-width=\"1.3\"/>`;\n }\n if (k === 'gateway' || k === 'lb') {\n return (\n `<g stroke=\"${c}\" stroke-width=\"1.5\" fill=\"none\">` +\n `<path d=\"M${x + 2} ${y + 1} L ${x + 8} ${y + 7} L ${x + 2} ${y + 13}\"/>` +\n `<path d=\"M${x + 8} ${y + 1} L ${x + 14} ${y + 7} L ${x + 8} ${y + 13}\"/>` +\n `</g>`\n );\n }\n if (k === 'service' || k === 'microservice' || k === 'compute' || k === 'container') {\n return (\n `<g stroke=\"${c}\" stroke-width=\"1.3\">` +\n `<rect x=\"${x + 4}\" y=\"${y + 1}\" width=\"11\" height=\"11\" rx=\"1.5\" fill=\"none\"/>` +\n `<rect x=\"${x + 1}\" y=\"${y + 4}\" width=\"11\" height=\"11\" rx=\"1.5\" fill=\"#fff\"/>` +\n `</g>`\n );\n }\n return '';\n}\n\n/** Edge-style preset: per-kind stroke, dash, marker, error flag. */\nexport interface EdgeStyle {\n readonly stroke: string;\n readonly sw: number;\n readonly dash: string;\n readonly marker: string;\n readonly err: boolean;\n}\n\n/** Edge style table — `solid | dashed | forbidden | error` → SVG attributes. */\nexport const GEDGE: Record<string, EdgeStyle> = {\n solid: { stroke: 'var(--charcoal)', sw: 1.4, dash: '', marker: 'gArrow', err: false },\n dashed: { stroke: 'var(--gray)', sw: 1.4, dash: '5 4', marker: 'gSoft', err: false },\n forbidden: { stroke: '#991b1b', sw: 2, dash: '', marker: 'gErr', err: true },\n error: { stroke: '#991b1b', sw: 1.6, dash: '', marker: 'gErr', err: true },\n};\n","/**\n * Renders a C4 model diagram (context / container / component levels).\n *\n * Per-node colour comes from a kind+family lookup (`c4Style`). Optional\n * boundary box wraps the internal nodes (container/component/store). A legend\n * sits below the SVG.\n *\n * Ported from doc-studio.jsx `C4Diagram` + `c4Style`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { ortho } from '../svg/ortho.js';\nimport { wrapText } from '../svg/wrapText.js';\nimport { edgePill } from '../svg/edgePill.js';\nimport { GEDGE } from '../svg/blockStyle.js';\nimport { diagramFrame } from './frame.js';\nimport { ensureGrid } from './autoLayout.js';\n\ntype Node = NonNullable<BlockDataMap['c4']['nodes']>[number];\n\ninterface C4Style {\n accent: string;\n fill: string;\n text: string;\n sub: string;\n chip: string;\n solid?: boolean;\n dash?: string;\n}\n\nfunction c4Style(n: Node): C4Style {\n const f = (n.family ?? '').toLowerCase();\n switch (n.kind) {\n case 'person':\n return {\n accent: '#0e54a1',\n fill: '#0e54a1',\n text: '#fff',\n sub: '#cfe0f3',\n chip: 'Person',\n solid: true,\n };\n case 'system':\n return {\n accent: '#1f9747',\n fill: '#dcf1e2',\n text: '#0f3d22',\n sub: '#356b49',\n chip: 'Software System',\n };\n case 'external':\n return {\n accent: '#6b7280',\n fill: '#f3f4f6',\n text: '#374151',\n sub: '#6b7280',\n chip: 'External System',\n };\n case 'store':\n return {\n accent: '#f7952c',\n fill: '#fde7cd',\n text: '#7a3d00',\n sub: '#9a5a12',\n chip: 'Database',\n };\n case 'component':\n if (f === 'repo')\n return {\n accent: '#374151',\n fill: '#f3f4f6',\n text: '#1a1a2e',\n sub: '#374151',\n chip: 'Component',\n };\n if (f === 'external')\n return {\n accent: '#6b7280',\n fill: '#fff',\n text: '#374151',\n sub: '#6b7280',\n chip: 'External',\n dash: '4 3',\n };\n if (f === 'controller')\n return {\n accent: '#0e54a1',\n fill: '#e5eff8',\n text: '#0a3a6e',\n sub: '#365f86',\n chip: 'Component',\n };\n return {\n accent: '#1f9747',\n fill: '#dcf1e2',\n text: '#0f3d22',\n sub: '#356b49',\n chip: 'Component',\n };\n default:\n if (f === 'data')\n return {\n accent: '#6b21a8',\n fill: '#ede9fe',\n text: '#4a1772',\n sub: '#6b21a8',\n chip: 'Container',\n };\n if (f === 'service')\n return {\n accent: '#1f9747',\n fill: '#dcf1e2',\n text: '#0f3d22',\n sub: '#356b49',\n chip: 'Container',\n };\n if (f === 'client')\n return {\n accent: '#0e54a1',\n fill: '#e5eff8',\n text: '#0a3a6e',\n sub: '#365f86',\n chip: 'Container',\n };\n if (f === 'store')\n return {\n accent: '#f7952c',\n fill: '#fde7cd',\n text: '#7a3d00',\n sub: '#9a5a12',\n chip: 'Database',\n };\n return {\n accent: '#0e54a1',\n fill: '#e5eff8',\n text: '#0a3a6e',\n sub: '#365f86',\n chip: 'Container',\n };\n }\n}\n\nconst LEGEND: ReadonlyArray<{ sw: string; label: string }> = [\n { sw: '#0e54a1', label: 'Person' },\n { sw: '#dcf1e2', label: 'System / service' },\n { sw: '#e5eff8', label: 'Container (client)' },\n { sw: '#ede9fe', label: 'Container (data)' },\n { sw: '#fde7cd', label: 'Database' },\n { sw: '#f3f4f6', label: 'External' },\n];\n\nexport function renderC4(data: BlockDataMap['c4']): string {\n const edges = data.edges ?? [];\n const nodes = ensureGrid(data.nodes ?? [], edges, 'TB');\n const byId = new Map(nodes.map((n) => [n.id, n]));\n const cellW = 212;\n const cellH = 102;\n const gapX = 56;\n const gapY = 64;\n const padX = 26;\n const padTop = 46;\n const padBot = 24;\n const cols = Math.max(1, ...nodes.map((n) => n.col + ((n.w ?? 1) - 1)));\n const rows = Math.max(1, ...nodes.map((n) => n.row));\n const rectFor = (n: Node & { col: number; row: number }): {\n x: number;\n y: number;\n w: number;\n h: number;\n } => ({\n x: padX + (n.col - 1) * (cellW + gapX),\n y: padTop + (n.row - 1) * (cellH + gapY),\n w: (n.w ?? 1) * cellW + ((n.w ?? 1) - 1) * gapX,\n h: cellH,\n });\n const width = padX * 2 + cols * cellW + (cols - 1) * gapX;\n const height = padTop + rows * cellH + (rows - 1) * gapY + padBot;\n\n // Boundary box around the \"internal\" nodes (container/component/store)\n let boundarySvg = '';\n if (data.boundary !== undefined) {\n const internals = nodes\n .filter((n) => n.kind === 'container' || n.kind === 'component' || n.kind === 'store')\n .map(rectFor);\n if (internals.length > 0) {\n const minX = Math.min(...internals.map((r) => r.x)) - 16;\n const minY = Math.min(...internals.map((r) => r.y)) - 26;\n const maxX = Math.max(...internals.map((r) => r.x + r.w)) + 16;\n const maxY = Math.max(...internals.map((r) => r.y + r.h)) + 16;\n const w = Math.max(120, data.boundary.label.length * 6.2);\n boundarySvg =\n `<g>` +\n `<rect x=\"${minX}\" y=\"${minY}\" width=\"${maxX - minX}\" height=\"${maxY - minY}\" rx=\"12\" class=\"c4-boundary\"/>` +\n `<rect x=\"${minX + 12}\" y=\"${minY - 8}\" width=\"${w}\" height=\"16\" fill=\"#fff\"/>` +\n `<text x=\"${minX + 16}\" y=\"${minY + 4}\" class=\"c4-boundary-label\">${escapeHtml(data.boundary.label)}</text>` +\n `</g>`;\n }\n }\n\n let s = `<svg viewBox=\"0 0 ${width} ${height}\" role=\"img\"><title>C4 diagram</title>${boundarySvg}`;\n\n for (const e of edges) {\n const A = byId.get(e.from);\n const B = byId.get(e.to);\n if (!A || !B) continue;\n const p = ortho(rectFor(A), rectFor(B));\n const st = GEDGE[e.kind ?? 'solid'] ??\n GEDGE['solid'] ?? {\n stroke: '#1a1a2e',\n sw: 1.4,\n dash: '',\n marker: 'gArrow',\n err: false,\n };\n s +=\n `<g><path d=\"${p.d}\" fill=\"none\" stroke=\"${st.stroke}\" stroke-width=\"${st.sw}\" stroke-dasharray=\"${st.dash}\" marker-end=\"url(#${st.marker})\"/>` +\n edgePill(p, e.label, st.err) +\n `</g>`;\n }\n\n for (const n of nodes) {\n const r = rectFor(n);\n const st = c4Style(n);\n const px = r.x + 16;\n const desc = wrapText(n.desc, 30, 2);\n const strokeWidth = st.solid === true ? 0 : 1.2;\n const strokeAttr = st.solid === true ? 'none' : st.accent;\n const dashAttr = st.dash !== undefined ? ` stroke-dasharray=\"${st.dash}\"` : '';\n const stripe =\n st.solid === true\n ? ''\n : `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"5\" height=\"${r.h}\" rx=\"2\" fill=\"${st.accent}\"/>`;\n const personGlyph =\n n.kind === 'person'\n ? `<g fill=\"${st.text}\"><circle cx=\"${px + 6}\" cy=\"${r.y + 19}\" r=\"6\"/><path d=\"M ${px} ${r.y + 34} a 6 7 0 0 1 12 0 z\"/></g>`\n : '';\n const chipX = n.kind === 'person' ? px + 22 : px;\n const chipFill = st.solid === true ? st.sub : st.accent;\n const techLine =\n n.tech !== undefined\n ? `<text x=\"${px}\" y=\"${r.y + 60}\" class=\"c4-tech\" fill=\"${st.sub}\">${escapeHtml(n.tech)}</text>`\n : '';\n const descLines = desc\n .map(\n (ln, j) =>\n `<text x=\"${px}\" y=\"${r.y + 77 + j * 13}\" class=\"c4-desc\" fill=\"${st.sub}\">${escapeHtml(ln)}</text>`,\n )\n .join('');\n s +=\n `<g filter=\"url(#gshadow)\">` +\n `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"${r.w}\" height=\"${r.h}\" rx=\"10\" fill=\"${st.fill}\" stroke=\"${strokeAttr}\" stroke-width=\"${strokeWidth}\"${dashAttr}/>` +\n stripe +\n personGlyph +\n `<text x=\"${chipX}\" y=\"${r.y + 22}\" class=\"c4-chip\" fill=\"${chipFill}\">${escapeHtml(st.chip)}</text>` +\n `<text x=\"${px}\" y=\"${r.y + 44}\" class=\"c4-name\" fill=\"${st.text}\">${escapeHtml(n.name)}</text>` +\n techLine +\n descLines +\n `</g>`;\n }\n\n s += `</svg>`;\n const legend =\n `<div class=\"legend\">` +\n LEGEND.map(\n (l) =>\n `<span class=\"item\"><span class=\"sw\" style=\"background:${l.sw};border:1px solid #d1d5db\"></span>${escapeHtml(l.label)}</span>`,\n ).join('') +\n `</div>`;\n\n return diagramFrame(\n {\n tag: 'C4',\n tagClass: 'c4',\n ...(data.title !== undefined ? { title: data.title } : {}),\n ...(data.description !== undefined ? { desc: data.description } : {}),\n },\n s + legend,\n );\n}\n","/**\n * Renders a UML class diagram — class boxes with stereotype, name, attributes,\n * and methods compartments; orthogonal-routed relationships with kind-specific\n * markers (inheritance triangle, composition diamond, etc.).\n *\n * Ported from doc-studio.jsx `UMLDiagram` + `umlRel`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { ortho } from '../svg/ortho.js';\nimport { edgePill } from '../svg/edgePill.js';\nimport { diagramFrame } from './frame.js';\nimport { ensureGrid } from './autoLayout.js';\n\ntype UmlClass = NonNullable<BlockDataMap['uml']['classes']>[number];\n\ninterface UmlRelStyle {\n dash: string;\n start?: string;\n end?: string;\n}\n\nfunction umlRel(kind: string | undefined): UmlRelStyle {\n switch ((kind ?? 'association').toLowerCase()) {\n case 'inheritance':\n case 'extends':\n return { dash: '', end: 'umlTri' };\n case 'implementation':\n case 'implements':\n return { dash: '6 4', end: 'umlTri' };\n case 'composition':\n return { dash: '', start: 'umlDiaF' };\n case 'aggregation':\n return { dash: '', start: 'umlDiaH' };\n case 'dependency':\n return { dash: '6 4', end: 'umlOpen' };\n default:\n return { dash: '', end: 'umlOpen' };\n }\n}\n\nexport function renderUml(data: BlockDataMap['uml']): string {\n const rels = data.rels ?? [];\n const classes = ensureGrid(data.classes ?? [], rels, 'TB');\n const colW = 204;\n const gapX = 64;\n const gapY = 50;\n const padX = 26;\n const padTop = 30;\n const padBot = 22;\n const rowH = 17;\n const headH = (c: UmlClass): number => 28 + (c.stereotype !== undefined ? 12 : 0);\n const compH = (list: readonly string[] | undefined): number =>\n (list !== undefined && list.length > 0 ? list.length * rowH : 6) + 8;\n const clsH = (c: UmlClass): number => headH(c) + compH(c.attrs) + compH(c.methods);\n\n const cols = Math.max(1, ...classes.map((c) => c.col));\n const rows = Math.max(1, ...classes.map((c) => c.row));\n const bandH = new Map<number, number>();\n const bandTop = new Map<number, number>();\n let acc = padTop;\n for (let r = 1; r <= rows; r++) {\n const hs = classes.filter((c) => c.row === r).map(clsH);\n const h = hs.length > 0 ? Math.max(...hs) : 60;\n bandH.set(r, h);\n bandTop.set(r, acc);\n acc += h + gapY;\n }\n const xOf = (c: number): number => padX + (c - 1) * (colW + gapX);\n const rectFor = (c: UmlClass & { col: number; row: number }): {\n x: number;\n y: number;\n w: number;\n h: number;\n } => ({\n x: xOf(c.col),\n y: bandTop.get(c.row) ?? padTop,\n w: colW,\n h: clsH(c),\n });\n const byId = new Map(classes.map((c) => [c.id, c]));\n const width = padX * 2 + cols * colW + (cols - 1) * gapX;\n const height = acc - gapY + padBot;\n\n let s =\n `<svg viewBox=\"0 0 ${width} ${height}\" role=\"img\"><title>UML class diagram</title>` +\n `<defs>` +\n `<marker id=\"umlTri\" viewBox=\"0 0 14 14\" refX=\"13\" refY=\"7\" markerWidth=\"15\" markerHeight=\"15\" orient=\"auto-start-reverse\">` +\n `<path d=\"M1,1 L13,7 L1,13 z\" fill=\"#fff\" stroke=\"#1a1a2e\" stroke-width=\"1.2\"/></marker>` +\n `<marker id=\"umlDiaF\" viewBox=\"0 0 20 12\" refX=\"19\" refY=\"6\" markerWidth=\"20\" markerHeight=\"12\" orient=\"auto-start-reverse\">` +\n `<path d=\"M1,6 L10,1 L19,6 L10,11 z\" fill=\"#1a1a2e\"/></marker>` +\n `<marker id=\"umlDiaH\" viewBox=\"0 0 20 12\" refX=\"19\" refY=\"6\" markerWidth=\"20\" markerHeight=\"12\" orient=\"auto-start-reverse\">` +\n `<path d=\"M1,6 L10,1 L19,6 L10,11 z\" fill=\"#fff\" stroke=\"#1a1a2e\" stroke-width=\"1.2\"/></marker>` +\n `<marker id=\"umlOpen\" viewBox=\"0 0 12 12\" refX=\"10\" refY=\"6\" markerWidth=\"12\" markerHeight=\"12\" orient=\"auto-start-reverse\">` +\n `<path d=\"M1,1 L11,6 L1,11\" fill=\"none\" stroke=\"#1a1a2e\" stroke-width=\"1.3\"/></marker>` +\n `</defs>`;\n\n for (const rl of rels) {\n const A = byId.get(rl.from);\n const B = byId.get(rl.to);\n if (!A || !B) continue;\n const p = ortho(rectFor(A), rectFor(B));\n const st = umlRel(rl.kind);\n const start = st.start !== undefined ? ` marker-start=\"url(#${st.start})\"` : '';\n const end = st.end !== undefined ? ` marker-end=\"url(#${st.end})\"` : '';\n s +=\n `<g><path d=\"${p.d}\" fill=\"none\" stroke=\"#1a1a2e\" stroke-width=\"1.3\" stroke-dasharray=\"${st.dash}\"${start}${end}/>` +\n edgePill(p, rl.label) +\n `</g>`;\n }\n\n for (const c of classes) {\n const r = rectFor(c);\n const hh = headH(c);\n const aH = compH(c.attrs);\n const nameY = r.y + (c.stereotype !== undefined ? 24 : 19);\n const stereo =\n c.stereotype !== undefined\n ? `<text x=\"${r.x + r.w / 2}\" y=\"${r.y + 13}\" class=\"uml-stereo\">«${escapeHtml(c.stereotype)}»</text>`\n : '';\n const attrs = (c.attrs ?? [])\n .map(\n (a, j) =>\n `<text x=\"${r.x + 10}\" y=\"${r.y + hh + 14 + j * rowH}\" class=\"uml-row\">${escapeHtml(a)}</text>`,\n )\n .join('');\n const methods = (c.methods ?? [])\n .map(\n (m, j) =>\n `<text x=\"${r.x + 10}\" y=\"${r.y + hh + aH + 14 + j * rowH}\" class=\"uml-row\">${escapeHtml(m)}</text>`,\n )\n .join('');\n s +=\n `<g filter=\"url(#gshadow)\">` +\n `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"${r.w}\" height=\"${r.h}\" rx=\"3\" fill=\"#fff\" stroke=\"#0e54a1\" stroke-width=\"1.3\"/>` +\n stereo +\n `<text x=\"${r.x + r.w / 2}\" y=\"${nameY}\" class=\"uml-name\">${escapeHtml(c.name)}</text>` +\n `<line x1=\"${r.x}\" y1=\"${r.y + hh}\" x2=\"${r.x + r.w}\" y2=\"${r.y + hh}\" class=\"uml-sep\"/>` +\n attrs +\n `<line x1=\"${r.x}\" y1=\"${r.y + hh + aH}\" x2=\"${r.x + r.w}\" y2=\"${r.y + hh + aH}\" class=\"uml-sep\"/>` +\n methods +\n `</g>`;\n }\n\n s += `</svg>`;\n return diagramFrame(\n {\n tag: 'UML',\n tagBg: '#6b21a8',\n ...(data.title !== undefined ? { title: data.title } : {}),\n ...(data.description !== undefined ? { desc: data.description } : {}),\n },\n s,\n );\n}\n","/**\n * Renders a MECE (Mutually Exclusive, Collectively Exhaustive) issue tree —\n * a left-to-right hierarchical tree with depth-based colour stripes.\n *\n * Layout uses DFS positioning: leaves stack vertically, branches center over\n * their first/last child.\n *\n * Ported from doc-studio.jsx `MECETree` + `meceStyle`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { wrapText } from '../svg/wrapText.js';\nimport { diagramFrame } from './frame.js';\n\ntype Node = NonNullable<BlockDataMap['mece']['nodes']>[number];\n\nconst CHART_COLORS = ['#0e54a1', '#1a6dbe', '#0f766e', '#1f9747', '#6b21a8', '#f7952c'];\n\ninterface MeceStyle {\n fill: string;\n text: string;\n accent: string;\n solid?: boolean;\n}\n\nfunction meceStyle(d: number): MeceStyle {\n if (d === 0) return { fill: '#0e54a1', text: '#fff', accent: '#0e54a1', solid: true };\n const c = CHART_COLORS[d % CHART_COLORS.length] ?? '#0e54a1';\n return { fill: '#fff', text: c, accent: c };\n}\n\nexport function renderMece(data: BlockDataMap['mece']): string {\n const nodes = data.nodes ?? [];\n const byId = new Map<string, Node>();\n const children = new Map<string, string[]>();\n for (const n of nodes) {\n byId.set(n.id, n);\n children.set(n.id, []);\n }\n const roots: string[] = [];\n for (const n of nodes) {\n if (n.parent !== undefined && byId.has(n.parent)) children.get(n.parent)?.push(n.id);\n else roots.push(n.id);\n }\n\n const pos = new Map<string, number>();\n const depth = new Map<string, number>();\n const seen = new Set<string>();\n let leaf = 0;\n let maxDepth = 0;\n const dfs = (id: string, d: number): void => {\n if (seen.has(id)) return;\n seen.add(id);\n depth.set(id, d);\n if (d > maxDepth) maxDepth = d;\n const ch = children.get(id) ?? [];\n if (ch.length === 0) {\n pos.set(id, leaf);\n leaf += 1;\n } else {\n for (const c of ch) dfs(c, d + 1);\n const first = pos.get(ch[0] ?? '') ?? 0;\n const last = pos.get(ch[ch.length - 1] ?? '') ?? 0;\n pos.set(id, (first + last) / 2);\n }\n };\n for (const r of roots) dfs(r, 0);\n\n const nodeW = 168;\n const nodeH = 50;\n const gapY = 16;\n const colGap = 56;\n const padX = 24;\n const padTop = 18;\n const padBot = 18;\n const xOf = (id: string): number => padX + (depth.get(id) ?? 0) * (nodeW + colGap);\n const yOf = (id: string): number => padTop + (pos.get(id) ?? 0) * (nodeH + gapY);\n const width = padX * 2 + (maxDepth + 1) * nodeW + maxDepth * colGap;\n const height = padTop + Math.max(leaf, 1) * (nodeH + gapY) - gapY + padBot;\n\n let s = `<svg viewBox=\"0 0 ${width} ${height}\" role=\"img\"><title>Issue tree</title>`;\n\n // links\n for (const n of nodes) {\n if (n.parent === undefined || !byId.has(n.parent) || !pos.has(n.id)) continue;\n const px = xOf(n.parent) + nodeW;\n const pcy = yOf(n.parent) + nodeH / 2;\n const cx = xOf(n.id);\n const ccy = yOf(n.id) + nodeH / 2;\n const midX = (px + cx) / 2;\n s += `<path class=\"tree-link\" d=\"M ${px} ${pcy} H ${midX} V ${ccy} H ${cx}\"/>`;\n }\n\n // nodes — wrap label to fit inside the box (max width ~150px, ~20 chars per line).\n // If a note is present, the label is single-line; otherwise allow up to two lines.\n for (const n of nodes) {\n if (!pos.has(n.id)) continue;\n const x = xOf(n.id);\n const y = yOf(n.id);\n const st = meceStyle(depth.get(n.id) ?? 0);\n const stroke = st.solid === true ? 'none' : st.accent;\n const stripe =\n st.solid === true\n ? ''\n : `<rect x=\"${x}\" y=\"${y}\" width=\"5\" height=\"${nodeH}\" rx=\"2\" fill=\"${st.accent}\"/>`;\n const labelX = x + (st.solid === true ? nodeW / 2 : 14);\n const anchor = st.solid === true ? 'middle' : 'start';\n const lines = wrapText(n.label, st.solid === true ? 22 : 20, n.note !== undefined ? 1 : 2);\n const startY =\n lines.length === 2\n ? y + 22\n : y + (n.note !== undefined ? 22 : 30);\n const labelTexts = lines\n .map(\n (ln, j) =>\n `<text x=\"${labelX}\" y=\"${startY + j * 14}\" class=\"blk-name\" fill=\"${st.text}\" text-anchor=\"${anchor}\">${escapeHtml(ln)}</text>`,\n )\n .join('');\n const note =\n n.note !== undefined\n ? `<text x=\"${labelX}\" y=\"${y + 38}\" class=\"ft-note\" fill=\"${st.solid === true ? '#cfe0f3' : st.accent}\" text-anchor=\"${anchor}\">${escapeHtml(n.note)}</text>`\n : '';\n s +=\n `<g filter=\"url(#gshadow)\">` +\n `<rect x=\"${x}\" y=\"${y}\" width=\"${nodeW}\" height=\"${nodeH}\" rx=\"6\" fill=\"${st.fill}\" stroke=\"${stroke}\" stroke-width=\"1.3\"/>` +\n stripe +\n labelTexts +\n note +\n `</g>`;\n }\n\n s += `</svg>`;\n return diagramFrame(\n {\n tag: 'MECE',\n tagBg: '#0f766e',\n ...(data.title !== undefined ? { title: data.title } : {}),\n ...(data.description !== undefined ? { desc: data.description } : {}),\n },\n s,\n );\n}\n","/**\n * Renders a top-down component tree — typical React/Vue hierarchy. Each node\n * has a `kind` (root, layout, page, component, leaf, provider, hook, store)\n * that drives its colour.\n *\n * Layout uses DFS positioning, children laid out left-to-right, parents\n * centered above their first/last child.\n *\n * Ported from doc-studio.jsx `ComponentTree` + `ftStyle`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { wrapText } from '../svg/wrapText.js';\nimport { diagramFrame } from './frame.js';\n\ntype Node = NonNullable<BlockDataMap['frontend']['nodes']>[number];\n\ninterface FtStyle {\n accent: string;\n fill: string;\n text: string;\n solid?: boolean;\n}\n\nfunction ftStyle(kind: string | undefined): FtStyle {\n switch ((kind ?? 'component').toLowerCase()) {\n case 'root':\n return { accent: '#0e54a1', fill: '#0e54a1', text: '#fff', solid: true };\n case 'layout':\n return { accent: '#0f766e', fill: '#ccfbf1', text: '#0f4f49' };\n case 'page':\n return { accent: '#0e54a1', fill: '#e5eff8', text: '#0a3a6e' };\n case 'component':\n return { accent: '#1f9747', fill: '#dcf1e2', text: '#0f3d22' };\n case 'leaf':\n return { accent: '#6b7280', fill: '#f3f4f6', text: '#374151' };\n case 'provider':\n case 'context':\n return { accent: '#6b21a8', fill: '#ede9fe', text: '#4a1772' };\n case 'hook':\n return { accent: '#7c3aed', fill: '#ede9fe', text: '#4a1772' };\n case 'store':\n case 'state':\n return { accent: '#f7952c', fill: '#fde7cd', text: '#7a3d00' };\n default:\n return { accent: '#1f9747', fill: '#dcf1e2', text: '#0f3d22' };\n }\n}\n\nexport function renderFrontend(data: BlockDataMap['frontend']): string {\n const nodes = data.nodes ?? [];\n const byId = new Map<string, Node>();\n const children = new Map<string, string[]>();\n for (const n of nodes) {\n byId.set(n.id, n);\n children.set(n.id, []);\n }\n const roots: string[] = [];\n for (const n of nodes) {\n if (n.parent !== undefined && byId.has(n.parent)) children.get(n.parent)?.push(n.id);\n else roots.push(n.id);\n }\n\n const pos = new Map<string, number>();\n const depth = new Map<string, number>();\n const seen = new Set<string>();\n let leaf = 0;\n let maxDepth = 0;\n const dfs = (id: string, d: number): void => {\n if (seen.has(id)) return;\n seen.add(id);\n depth.set(id, d);\n if (d > maxDepth) maxDepth = d;\n const ch = children.get(id) ?? [];\n if (ch.length === 0) {\n pos.set(id, leaf);\n leaf += 1;\n } else {\n for (const c of ch) dfs(c, d + 1);\n const first = pos.get(ch[0] ?? '') ?? 0;\n const last = pos.get(ch[ch.length - 1] ?? '') ?? 0;\n pos.set(id, (first + last) / 2);\n }\n };\n for (const r of roots) dfs(r, 0);\n\n const nodeW = 158;\n const nodeH = 56;\n const gapX = 24;\n const levelGap = 96;\n const padX = 24;\n const padTop = 18;\n const padBot = 18;\n const slot = Math.max(leaf, 1);\n const xOf = (id: string): number => padX + (pos.get(id) ?? 0) * (nodeW + gapX);\n const yOf = (id: string): number => padTop + (depth.get(id) ?? 0) * levelGap;\n const width = padX * 2 + slot * (nodeW + gapX) - gapX;\n const height = padTop + maxDepth * levelGap + nodeH + padBot;\n\n let s = `<svg viewBox=\"0 0 ${width} ${height}\" role=\"img\"><title>Component tree</title>`;\n\n // links\n for (const n of nodes) {\n if (n.parent === undefined || !byId.has(n.parent) || !pos.has(n.id)) continue;\n const pcx = xOf(n.parent) + nodeW / 2;\n const pby = yOf(n.parent) + nodeH;\n const ccx = xOf(n.id) + nodeW / 2;\n const cty = yOf(n.id);\n const midY = (pby + cty) / 2;\n s += `<path class=\"tree-link\" d=\"M ${pcx} ${pby} V ${midY} H ${ccx} V ${cty}\"/>`;\n }\n\n // nodes — wrap name to fit inside the box (~158px, ~20 chars per line).\n // With a note: single-line name. Without a note: up to two lines.\n for (const n of nodes) {\n if (!pos.has(n.id)) continue;\n const x = xOf(n.id);\n const y = yOf(n.id);\n const st = ftStyle(n.kind);\n const stroke = st.solid === true ? 'none' : st.accent;\n const stripe =\n st.solid === true\n ? ''\n : `<rect x=\"${x}\" y=\"${y}\" width=\"5\" height=\"${nodeH}\" rx=\"2\" fill=\"${st.accent}\"/>`;\n const labelX = x + (st.solid === true ? nodeW / 2 : 14);\n const anchor = st.solid === true ? 'middle' : 'start';\n const lines = wrapText(n.name, st.solid === true ? 20 : 18, n.note !== undefined ? 1 : 2);\n const startY =\n lines.length === 2\n ? y + 25\n : y + (n.note !== undefined ? 25 : 33);\n const labelTexts = lines\n .map(\n (ln, j) =>\n `<text x=\"${labelX}\" y=\"${startY + j * 14}\" class=\"blk-name\" fill=\"${st.text}\" text-anchor=\"${anchor}\">${escapeHtml(ln)}</text>`,\n )\n .join('');\n const note =\n n.note !== undefined\n ? `<text x=\"${labelX}\" y=\"${y + 41}\" class=\"ft-note\" fill=\"${st.solid === true ? '#cfe0f3' : st.accent}\" text-anchor=\"${anchor}\">${escapeHtml(n.note)}</text>`\n : '';\n s +=\n `<g filter=\"url(#gshadow)\">` +\n `<rect x=\"${x}\" y=\"${y}\" width=\"${nodeW}\" height=\"${nodeH}\" rx=\"8\" fill=\"${st.fill}\" stroke=\"${stroke}\" stroke-width=\"1.2\"/>` +\n stripe +\n labelTexts +\n note +\n `</g>`;\n }\n\n s += `</svg>`;\n return diagramFrame(\n {\n tag: 'FE',\n tagBg: '#0f766e',\n ...(data.title !== undefined ? { title: data.title } : {}),\n ...(data.description !== undefined ? { desc: data.description } : {}),\n },\n s,\n );\n}\n","/**\n * Renders a cluster diagram (Kubernetes-style) — nested cluster boxes with\n * service tiles inside, optional replica counts as bar marks, and\n * orthogonal-routed edges between services across clusters.\n *\n * Ported from doc-studio.jsx `ClusterDiagram`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { ortho } from '../svg/ortho.js';\nimport { edgePill } from '../svg/edgePill.js';\nimport { blockStyle, nodeGlyph, GEDGE } from '../svg/blockStyle.js';\nimport { diagramFrame } from './frame.js';\n\ntype Service = NonNullable<BlockDataMap['cluster']['services']>[number];\n\nexport function renderCluster(data: BlockDataMap['cluster']): string {\n const clusters = data.clusters ?? [];\n const services = data.services ?? [];\n const edges = data.edges ?? [];\n const svcByCluster = new Map<string, Service[]>();\n for (const c of clusters) svcByCluster.set(c.id, []);\n for (const sv of services) {\n const list = svcByCluster.get(sv.cluster);\n if (list !== undefined) list.push(sv);\n }\n const serviceW = 158;\n const serviceH = 78;\n const gapS = 22;\n const cPadX = 26;\n const cHeader = 38;\n const cPadTop = 18;\n const cPadBot = 22;\n const cGap = 28;\n const outerPad = 26;\n\n let maxPerCluster = 1;\n for (const list of svcByCluster.values()) {\n if (list.length > maxPerCluster) maxPerCluster = list.length;\n }\n const cols = Math.min(4, Math.max(1, maxPerCluster));\n const clusterW = cols * serviceW + (cols - 1) * gapS + cPadX * 2;\n const width = outerPad * 2 + clusterW;\n\n interface Rect {\n x: number;\n y: number;\n w: number;\n h: number;\n }\n const rects = new Map<string, Rect>();\n interface ClusterBox {\n c: NonNullable<BlockDataMap['cluster']['clusters']>[number];\n x: number;\n y: number;\n w: number;\n h: number;\n }\n const clusterBoxes: ClusterBox[] = [];\n\n let y = outerPad;\n for (const c of clusters) {\n const list = svcByCluster.get(c.id) ?? [];\n const rows = Math.max(1, Math.ceil(list.length / cols));\n const h = cHeader + cPadTop + rows * serviceH + (rows - 1) * gapS + cPadBot;\n const cx = outerPad;\n clusterBoxes.push({ c, x: cx, y, w: clusterW, h });\n list.forEach((sv, i) => {\n const r = Math.floor(i / cols);\n const col = i % cols;\n rects.set(sv.id, {\n x: cx + cPadX + col * (serviceW + gapS),\n y: y + cHeader + cPadTop + r * (serviceH + gapS),\n w: serviceW,\n h: serviceH,\n });\n });\n y += h + cGap;\n }\n const height = y - cGap + outerPad;\n\n let s = `<svg viewBox=\"0 0 ${width} ${height}\" role=\"img\"><title>Cluster diagram</title>`;\n\n // cluster shells\n for (const cb of clusterBoxes) {\n const kindLabel =\n cb.c.kind !== undefined\n ? `<text x=\"${cb.x + cb.w - 14}\" y=\"${cb.y + 21}\" class=\"cl-kind\">${escapeHtml(cb.c.kind)}</text>`\n : '';\n s +=\n `<g>` +\n `<rect x=\"${cb.x}\" y=\"${cb.y}\" width=\"${cb.w}\" height=\"${cb.h}\" rx=\"12\" fill=\"#0e54a1\" fill-opacity=\"0.035\" stroke=\"#0e54a1\" stroke-width=\"1.4\" stroke-dasharray=\"8 5\"/>` +\n `<rect x=\"${cb.x}\" y=\"${cb.y}\" width=\"${cb.w}\" height=\"${cHeader}\" rx=\"12\" fill=\"#0e54a1\"/>` +\n `<rect x=\"${cb.x}\" y=\"${cb.y + cHeader - 12}\" width=\"${cb.w}\" height=\"12\" fill=\"#0e54a1\"/>` +\n `<text x=\"${cb.x + 16}\" y=\"${cb.y + 21}\" class=\"cl-head\">${escapeHtml(cb.c.label)}</text>` +\n kindLabel +\n `</g>`;\n }\n\n // edges\n for (const e of edges) {\n const A = rects.get(e.from);\n const B = rects.get(e.to);\n if (!A || !B) continue;\n const p = ortho(A, B);\n const st = GEDGE[e.kind ?? 'solid'] ?? GEDGE['solid'] ?? {\n stroke: '#1a1a2e',\n sw: 1.4,\n dash: '',\n marker: 'gArrow',\n err: false,\n };\n s +=\n `<g><path d=\"${p.d}\" fill=\"none\" stroke=\"${st.stroke}\" stroke-width=\"${st.sw}\" stroke-dasharray=\"${st.dash}\" marker-end=\"url(#${st.marker})\"/>` +\n edgePill(p, e.label, st.err) +\n `</g>`;\n }\n\n // services\n for (const sv of services) {\n const r = rects.get(sv.id);\n if (r === undefined) continue;\n const st = blockStyle(sv.kind);\n const gl = nodeGlyph(sv.kind, r.x + 14, r.y + 14, st.accent);\n const nx = gl.length > 0 ? r.x + 38 : r.x + 14;\n const reps = sv.replicas ?? 0;\n const techLine =\n sv.tech !== undefined\n ? `<text x=\"${nx}\" y=\"${r.y + 42}\" class=\"blk-tech\" fill=\"${st.accent}\">${escapeHtml(sv.tech)}</text>`\n : '';\n const repIndicator =\n reps > 0\n ? (() => {\n const shown = Math.min(reps, 5);\n let bars = '';\n for (let j = 0; j < shown; j++) {\n bars += `<rect x=\"${r.x + 12 + j * 8}\" y=\"${r.y + r.h - 14}\" width=\"5\" height=\"8\" rx=\"1\" fill=\"${st.accent}\" opacity=\"0.7\"/>`;\n }\n return (\n `<g>` +\n bars +\n `<text x=\"${r.x + 12 + shown * 8 + 4}\" y=\"${r.y + r.h - 7}\" class=\"blk-tech\" fill=\"${st.accent}\">×${reps}</text>` +\n `</g>`\n );\n })()\n : '';\n s +=\n `<g filter=\"url(#gshadow)\">` +\n `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"${r.w}\" height=\"${r.h}\" rx=\"8\" fill=\"${st.fill}\" stroke=\"${st.accent}\" stroke-width=\"1.2\"/>` +\n `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"5\" height=\"${r.h}\" rx=\"2\" fill=\"${st.accent}\"/>` +\n gl +\n `<text x=\"${nx}\" y=\"${r.y + (sv.tech !== undefined ? 26 : 30)}\" class=\"blk-name\" fill=\"${st.text}\" style=\"font-size:12px\">${escapeHtml(sv.label)}</text>` +\n techLine +\n repIndicator +\n `</g>`;\n }\n\n s += `</svg>`;\n return diagramFrame(\n {\n tag: 'CLUSTER',\n tagBg: '#0e54a1',\n ...(data.title !== undefined ? { title: data.title } : {}),\n ...(data.description !== undefined ? { desc: data.description } : {}),\n },\n s,\n );\n}\n","/**\n * Block-graph rendering — backs `block`, `infra`, `event`, `ddd`, and\n * `network`. Two layout modes share the same data shape:\n *\n * - **Layered:** if `spec.layers` is present, nodes are placed in horizontal\n * bands by their `layer` index.\n * - **Grid:** otherwise nodes use `(col, row, w?)` placements, optionally\n * wrapped in dashed group boxes.\n *\n * Ported from doc-studio.jsx `GridBlock` + `LayeredBlock` + `BlockDiagram`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { ortho } from '../svg/ortho.js';\nimport { edgePill } from '../svg/edgePill.js';\nimport { blockStyle, nodeGlyph, GEDGE } from '../svg/blockStyle.js';\nimport { safeColor } from '../sanitize.js';\nimport { diagramFrame } from './frame.js';\n\ntype Data = BlockDataMap['block'];\ntype Group = NonNullable<Data['groups']>[number];\ntype Node = NonNullable<Data['nodes']>[number];\n\ninterface FrameOpts {\n readonly tag: string;\n readonly tagBg?: string;\n readonly tagClass?: string;\n}\n\nconst FALLBACK_EDGE = {\n stroke: '#1a1a2e',\n sw: 1.4,\n dash: '',\n marker: 'gArrow',\n err: false,\n} as const;\n\nfunction renderGrid(data: Data): string {\n const groups = data.groups ?? [];\n const nodes = data.nodes ?? [];\n const edges = data.edges ?? [];\n const cellW = 184;\n const cellH = 82;\n const gapX = 56;\n const gapY = 58;\n const padX = 26;\n const padTop = 30;\n const padBot = 20;\n const cols = Math.max(\n 1,\n ...nodes.map((n) => (n.col ?? 1) + ((n.w ?? 1) - 1)),\n ...groups.map((g) => g.col + (g.cols ?? 1) - 1),\n );\n const rows = Math.max(\n 1,\n ...nodes.map((n) => n.row ?? 1),\n ...groups.map((g) => g.row + (g.rows ?? 1) - 1),\n );\n const xOf = (c: number): number => padX + (c - 1) * (cellW + gapX);\n const yOf = (r: number): number => padTop + (r - 1) * (cellH + gapY);\n const rectFor = (n: Node): { x: number; y: number; w: number; h: number } => ({\n x: xOf(n.col ?? 1),\n y: yOf(n.row ?? 1),\n w: (n.w ?? 1) * cellW + ((n.w ?? 1) - 1) * gapX,\n h: cellH,\n });\n const groupRect = (g: Group): { x: number; y: number; w: number; h: number } => ({\n x: xOf(g.col) - 16,\n y: yOf(g.row) - 22,\n w: (g.cols ?? 1) * cellW + ((g.cols ?? 1) - 1) * gapX + 32,\n h: (g.rows ?? 1) * cellH + ((g.rows ?? 1) - 1) * gapY + 38,\n });\n const byId = new Map(nodes.map((n) => [n.id, n]));\n const width = padX * 2 + cols * cellW + (cols - 1) * gapX;\n const height = padTop + rows * cellH + (rows - 1) * gapY + padBot;\n\n // Largest groups first so smaller ones layer on top.\n const sortedGroups = [...groups].sort(\n (a, b) => (b.cols ?? 1) * (b.rows ?? 1) - (a.cols ?? 1) * (a.rows ?? 1),\n );\n\n let s = `<svg viewBox=\"0 0 ${width} ${height}\" role=\"img\"><title>Block diagram</title>`;\n\n for (const g of sortedGroups) {\n const r = groupRect(g);\n const col = safeColor(g.color, '#0e54a1');\n // AWS-console-style zone: dashed tinted boundary + a solid label badge.\n // 2D containers (e.g. a VPC) get a centered title pill on the top border;\n // band-shaped zones (e.g. subnets) get a top-left tab — so a VPC and the\n // subnet sharing its corner never collide.\n const badgeW = 16 + g.label.length * 6.4;\n const isContainer = (g.cols ?? 1) >= 2 && (g.rows ?? 1) >= 2;\n const zone = `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"${r.w}\" height=\"${r.h}\" rx=\"10\" fill=\"${col}\" fill-opacity=\"0.06\" stroke=\"${col}\" stroke-opacity=\"0.55\" stroke-width=\"1.3\" stroke-dasharray=\"7 5\"/>`;\n const label = isContainer\n ? `<rect x=\"${r.x + (r.w - badgeW) / 2}\" y=\"${r.y - 1}\" width=\"${badgeW}\" height=\"20\" rx=\"10\" fill=\"${col}\"/>` +\n `<text x=\"${r.x + r.w / 2}\" y=\"${r.y + 13}\" class=\"grp-label\" fill=\"#fff\" text-anchor=\"middle\">${escapeHtml(g.label)}</text>`\n : `<path d=\"M${r.x} ${r.y + 20} L${r.x} ${r.y + 10} a10 10 0 0 1 10 -10 h${badgeW - 10} v20 z\" fill=\"${col}\"/>` +\n `<text x=\"${r.x + badgeW / 2}\" y=\"${r.y + 14}\" class=\"grp-label\" fill=\"#fff\" text-anchor=\"middle\">${escapeHtml(g.label)}</text>`;\n s += `<g>${zone}${label}</g>`;\n }\n\n for (const e of edges) {\n const A = byId.get(e.from);\n const B = byId.get(e.to);\n if (!A || !B) continue;\n const p = ortho(rectFor(A), rectFor(B));\n const st = GEDGE[e.kind ?? 'solid'] ?? GEDGE['solid'] ?? FALLBACK_EDGE;\n s +=\n `<g><path d=\"${p.d}\" fill=\"none\" stroke=\"${st.stroke}\" stroke-width=\"${st.sw}\" stroke-dasharray=\"${st.dash}\" marker-end=\"url(#${st.marker})\"/>` +\n edgePill(p, e.label, st.err) +\n `</g>`;\n }\n\n for (const n of nodes) {\n const r = rectFor(n);\n const st = blockStyle(n.kind);\n const gl = nodeGlyph(n.kind, r.x + 16, r.y + 16, st.accent);\n const nx = gl.length > 0 ? r.x + 42 : r.x + 16;\n const chip =\n gl.length === 0 && n.kind !== undefined\n ? `<text x=\"${r.x + 16}\" y=\"${r.y + 22}\" class=\"blk-chip\" fill=\"${st.accent}\">${escapeHtml(n.kind)}</text>`\n : '';\n const tech =\n n.tech !== undefined\n ? `<text x=\"${nx}\" y=\"${r.y + (gl.length > 0 ? 50 : 60)}\" class=\"blk-tech\" fill=\"${st.accent}\">${escapeHtml(n.tech)}</text>`\n : '';\n s +=\n `<g filter=\"url(#gshadow)\">` +\n `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"${r.w}\" height=\"${r.h}\" rx=\"9\" fill=\"${st.fill}\" stroke=\"${st.accent}\" stroke-width=\"1.2\"/>` +\n `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"5\" height=\"${r.h}\" rx=\"2\" fill=\"${st.accent}\"/>` +\n gl +\n chip +\n `<text x=\"${nx}\" y=\"${r.y + (gl.length > 0 ? 34 : 44)}\" class=\"blk-name\" fill=\"${st.text}\">${escapeHtml(n.name)}</text>` +\n tech +\n `</g>`;\n }\n\n s += `</svg>`;\n return s;\n}\n\nfunction renderLayered(data: Data): string {\n const layers = data.layers ?? [];\n const nodes = data.nodes ?? [];\n const edges = data.edges ?? [];\n const byLayer: Node[][] = layers.map((_, i) =>\n nodes.filter((n) => (n.layer ?? 0) === i),\n );\n const outerPad = 28;\n const titleH = data.systemLabel !== undefined ? 32 : 16;\n const labelW = 132;\n const bandPadX = 16;\n const bandPadY = 14;\n const bandGap = 12;\n const nodeW = 158;\n const nodeH = 56;\n const nodeGap = 22;\n const rowW = (c: number): number => c * nodeW + (c - 1) * nodeGap;\n const contentW = Math.max(220, ...byLayer.map((a) => rowW(Math.max(a.length, 1))));\n const bandInnerW = contentW + bandPadX * 2;\n const bandH = nodeH + bandPadY * 2;\n const innerX = outerPad + 14;\n const contentX = innerX + labelW;\n const width = contentX + bandInnerW + 14 + outerPad;\n const top = outerPad + titleH;\n const bandY = (i: number): number => top + i * (bandH + bandGap);\n const height = bandY(layers.length) - bandGap + outerPad;\n\n const rects = new Map<string, { x: number; y: number; w: number; h: number }>();\n byLayer.forEach((arr, i) => {\n const startX = contentX + (bandInnerW - rowW(arr.length)) / 2;\n arr.forEach((n, j) => {\n rects.set(n.id, {\n x: startX + j * (nodeW + nodeGap),\n y: bandY(i) + bandPadY,\n w: nodeW,\n h: nodeH,\n });\n });\n });\n\n let s =\n `<svg viewBox=\"0 0 ${width} ${height}\" role=\"img\"><title>Layered architecture</title>` +\n `<rect x=\"${outerPad}\" y=\"${outerPad}\" width=\"${width - outerPad * 2}\" height=\"${height - outerPad * 2}\" rx=\"12\" fill=\"none\" stroke=\"#0e54a1\" stroke-width=\"1.5\"/>`;\n if (data.systemLabel !== undefined) {\n s += `<text x=\"${outerPad + 14}\" y=\"${outerPad + 18}\" class=\"grp-label\" fill=\"#0e54a1\">${escapeHtml(data.systemLabel)}</text>`;\n }\n for (let i = 0; i < layers.length; i++) {\n const L = layers[i];\n if (L === undefined) continue;\n s +=\n `<g>` +\n `<rect x=\"${innerX}\" y=\"${bandY(i)}\" width=\"${labelW + bandInnerW}\" height=\"${bandH}\" rx=\"6\" fill=\"#f3f4f6\" stroke=\"#d1d5db\"/>` +\n `<rect x=\"${innerX}\" y=\"${bandY(i)}\" width=\"${labelW}\" height=\"${bandH}\" rx=\"6\" fill=\"#0e54a1\"/>` +\n `<rect x=\"${innerX + labelW - 8}\" y=\"${bandY(i)}\" width=\"8\" height=\"${bandH}\" fill=\"#0e54a1\"/>` +\n `<text x=\"${innerX + 14}\" y=\"${bandY(i) + bandH / 2 + 4}\" class=\"layer-label\">${escapeHtml(L.label)}</text>` +\n `</g>`;\n }\n\n for (const e of edges) {\n const A = rects.get(e.from);\n const B = rects.get(e.to);\n if (!A || !B) continue;\n const p = ortho(A, B);\n const st = GEDGE[e.kind ?? 'solid'] ?? GEDGE['solid'] ?? FALLBACK_EDGE;\n s +=\n `<g><path d=\"${p.d}\" fill=\"none\" stroke=\"${st.stroke}\" stroke-width=\"${st.sw}\" stroke-dasharray=\"${st.dash}\" marker-end=\"url(#${st.marker})\"/>` +\n edgePill(p, e.label, st.err) +\n `</g>`;\n }\n\n for (const n of nodes) {\n const r = rects.get(n.id);\n if (r === undefined) continue;\n const st = blockStyle(n.kind);\n const gl = nodeGlyph(n.kind, r.x + 12, r.y + 12, st.accent);\n const nx = gl.length > 0 ? r.x + 34 : r.x + 14;\n const tech =\n n.tech !== undefined\n ? `<text x=\"${nx}\" y=\"${r.y + 42}\" class=\"blk-tech\" fill=\"${st.accent}\">${escapeHtml(n.tech)}</text>`\n : '';\n s +=\n `<g filter=\"url(#gshadow)\">` +\n `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"${r.w}\" height=\"${r.h}\" rx=\"8\" fill=\"${st.fill}\" stroke=\"${st.accent}\" stroke-width=\"1.2\"/>` +\n `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"5\" height=\"${r.h}\" rx=\"2\" fill=\"${st.accent}\"/>` +\n gl +\n `<text x=\"${nx}\" y=\"${r.y + (n.tech !== undefined ? 26 : 33)}\" class=\"blk-name\" fill=\"${st.text}\">${escapeHtml(n.name)}</text>` +\n tech +\n `</g>`;\n }\n\n s += `</svg>`;\n return s;\n}\n\nfunction renderBlockGraph(data: Data, frame: FrameOpts): string {\n const svg = data.layers !== undefined && data.layers.length > 0 ? renderLayered(data) : renderGrid(data);\n const opts: Parameters<typeof diagramFrame>[0] = {\n tag: frame.tag,\n ...(frame.tagClass !== undefined ? { tagClass: frame.tagClass } : {}),\n ...(frame.tagBg !== undefined ? { tagBg: frame.tagBg } : {}),\n ...(data.title !== undefined ? { title: data.title } : {}),\n ...(data.description !== undefined ? { desc: data.description } : {}),\n };\n return diagramFrame(opts, svg);\n}\n\n/** `block` block — generic architecture (grid or layered). */\nexport function renderBlock(data: BlockDataMap['block']): string {\n return renderBlockGraph(data, { tag: 'ARCH', tagBg: '#0f766e' });\n}\n/** `infra` block — deployment topology. */\nexport function renderInfra(data: BlockDataMap['infra']): string {\n return renderBlockGraph(data, { tag: 'INFRA', tagBg: '#0078d4' });\n}\n/** `event` block — pub/sub choreography. */\nexport function renderEvent(data: BlockDataMap['event']): string {\n return renderBlockGraph(data, { tag: 'EVENT', tagBg: '#0f766e' });\n}\n/** `ddd` block — bounded-context map. */\nexport function renderDdd(data: BlockDataMap['ddd']): string {\n return renderBlockGraph(data, { tag: 'DDD', tagBg: '#6b21a8' });\n}\n/** `network` block — security zones / network topology. */\nexport function renderNetwork(data: BlockDataMap['network']): string {\n return renderBlockGraph(data, { tag: 'ZONES', tagBg: '#991b1b' });\n}\n","/**\n * Frontend / backend module-graph rendering — design-pattern nodes (engine,\n * interface, strategy, controller, service, repo, worker, middleware, model,\n * db, cache, queue, hook, store, external) with kind-specific styling and\n * UML stereotype banners on interface nodes.\n *\n * Backs `felogic` and `belogic` (same shape, different frame colour).\n *\n * Ported from doc-studio.jsx `FrontendLogic` + `feStyle` + `feEdge`.\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { ortho } from '../svg/ortho.js';\nimport { edgePill } from '../svg/edgePill.js';\nimport { nodeGlyph } from '../svg/blockStyle.js';\nimport { safeColor } from '../sanitize.js';\nimport { diagramFrame } from './frame.js';\n\ntype Data = BlockDataMap['felogic'];\ntype Group = NonNullable<Data['groups']>[number];\ntype Node = NonNullable<Data['nodes']>[number];\n\ninterface FeStyle {\n accent: string;\n fill: string;\n text: string;\n solid?: boolean;\n dash?: string;\n stereo?: string;\n cloud?: boolean;\n}\n\nfunction feStyle(kind: string | undefined): FeStyle {\n switch ((kind ?? 'component').toLowerCase()) {\n case 'engine':\n case 'core':\n return { accent: '#0e54a1', fill: '#0e54a1', text: '#fff', solid: true };\n case 'interface':\n return { accent: '#6b21a8', fill: '#fff', text: '#4a1772', dash: '5 4', stereo: 'interface' };\n case 'strategy':\n case 'adapter':\n case 'impl':\n return { accent: '#7c3aed', fill: '#ede9fe', text: '#4a1772' };\n case 'controller':\n case 'handler':\n case 'route':\n return { accent: '#0e54a1', fill: '#cfe0f3', text: '#0a3a6e' };\n case 'service':\n case 'usecase':\n case 'apiclient':\n case 'client':\n return { accent: '#1a6dbe', fill: '#e5eff8', text: '#0a3a6e' };\n case 'repository':\n case 'repo':\n case 'dao':\n return { accent: '#0f766e', fill: '#ccfbf1', text: '#0f4f49' };\n case 'worker':\n case 'consumer':\n return { accent: '#1f9747', fill: '#dcf1e2', text: '#0f3d22' };\n case 'middleware':\n return { accent: '#6b7280', fill: '#f3f4f6', text: '#374151' };\n case 'model':\n case 'entity':\n return { accent: '#6b21a8', fill: '#ede9fe', text: '#4a1772' };\n case 'db':\n case 'store':\n case 'database':\n return { accent: '#f7952c', fill: '#fde7cd', text: '#7a3d00' };\n case 'cache':\n return { accent: '#0891b2', fill: '#cffafe', text: '#0e4f5c' };\n case 'queue':\n case 'bus':\n case 'broker':\n return { accent: '#0f766e', fill: '#ccfbf1', text: '#0f4f49' };\n case 'state':\n case 'store_state':\n return { accent: '#f7952c', fill: '#fde7cd', text: '#7a3d00' };\n case 'hook':\n return { accent: '#7c3aed', fill: '#ede9fe', text: '#4a1772' };\n case 'external':\n case 'backend':\n case 'egress':\n case 'api':\n case 'thirdparty':\n return { accent: '#6b7280', fill: '#f3f4f6', text: '#374151', cloud: true };\n default:\n return { accent: '#1f9747', fill: '#dcf1e2', text: '#0f3d22' };\n }\n}\n\ninterface FeEdgeStyle {\n stroke: string;\n sw: number;\n dash: string;\n marker: string;\n}\n\nfunction feEdge(kind: string | undefined): FeEdgeStyle {\n switch ((kind ?? 'uses').toLowerCase()) {\n case 'implements':\n return { stroke: '#6b21a8', sw: 1.4, dash: '5 4', marker: 'gTri' };\n case 'egress':\n case 'https':\n case 'api':\n return { stroke: '#0e54a1', sw: 2, dash: '', marker: 'gArrow' };\n case 'reads':\n case 'dashed':\n case 'async':\n return { stroke: '#6b7280', sw: 1.4, dash: '5 4', marker: 'gSoft' };\n default:\n return { stroke: '#1a1a2e', sw: 1.4, dash: '', marker: 'gArrow' };\n }\n}\n\nconst GLYPH_KINDS = new Set([\n 'db',\n 'store',\n 'database',\n 'bucket',\n 'blob',\n 'object',\n 'queue',\n 'bus',\n 'broker',\n 'cache',\n 'external',\n 'backend',\n 'api',\n 'thirdparty',\n 'function',\n]);\nconst GLYPH_REMAP: Record<string, string> = {\n database: 'db',\n store: 'db',\n bus: 'queue',\n broker: 'queue',\n backend: 'external',\n api: 'external',\n thirdparty: 'external',\n};\n\ninterface FrameOpts {\n readonly tag: string;\n readonly tagBg?: string;\n}\n\nfunction renderFelogicGraph(data: Data, frame: FrameOpts): string {\n const groups = data.groups ?? [];\n const nodes = data.nodes ?? [];\n const edges = data.edges ?? [];\n const cellW = 178;\n const cellH = 80;\n const gapX = 54;\n const gapY = 60;\n const padX = 26;\n const padTop = 30;\n const padBot = 20;\n const cols = Math.max(\n 1,\n ...nodes.map((n) => n.col + ((n.w ?? 1) - 1)),\n ...groups.map((g) => g.col + (g.cols ?? 1) - 1),\n );\n const rows = Math.max(\n 1,\n ...nodes.map((n) => n.row),\n ...groups.map((g) => g.row + (g.rows ?? 1) - 1),\n );\n const xOf = (c: number): number => padX + (c - 1) * (cellW + gapX);\n const yOf = (r: number): number => padTop + (r - 1) * (cellH + gapY);\n const rectFor = (n: Node): { x: number; y: number; w: number; h: number } => ({\n x: xOf(n.col),\n y: yOf(n.row),\n w: (n.w ?? 1) * cellW + ((n.w ?? 1) - 1) * gapX,\n h: cellH,\n });\n const groupRect = (g: Group): { x: number; y: number; w: number; h: number } => ({\n x: xOf(g.col) - 16,\n y: yOf(g.row) - 22,\n w: (g.cols ?? 1) * cellW + ((g.cols ?? 1) - 1) * gapX + 32,\n h: (g.rows ?? 1) * cellH + ((g.rows ?? 1) - 1) * gapY + 38,\n });\n const byId = new Map(nodes.map((n) => [n.id, n]));\n const width = padX * 2 + cols * cellW + (cols - 1) * gapX;\n const height = padTop + rows * cellH + (rows - 1) * gapY + padBot;\n const sortedGroups = [...groups].sort(\n (a, b) => (b.cols ?? 1) * (b.rows ?? 1) - (a.cols ?? 1) * (a.rows ?? 1),\n );\n\n let s = `<svg viewBox=\"0 0 ${width} ${height}\" role=\"img\"><title>Module graph</title>`;\n\n for (const g of sortedGroups) {\n const r = groupRect(g);\n const col = safeColor(g.color, '#0e54a1');\n s +=\n `<g>` +\n `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"${r.w}\" height=\"${r.h}\" rx=\"10\" fill=\"${col}\" fill-opacity=\"0.05\" stroke=\"${col}\" stroke-opacity=\"0.5\" stroke-width=\"1.2\" stroke-dasharray=\"7 5\"/>` +\n `<text x=\"${r.x + 14}\" y=\"${r.y + 15}\" class=\"grp-label\" fill=\"${col}\">${escapeHtml(g.label)}</text>` +\n `</g>`;\n }\n\n for (const e of edges) {\n const A = byId.get(e.from);\n const B = byId.get(e.to);\n if (!A || !B) continue;\n const p = ortho(rectFor(A), rectFor(B));\n const st = feEdge(e.kind);\n s +=\n `<g><path d=\"${p.d}\" fill=\"none\" stroke=\"${st.stroke}\" stroke-width=\"${st.sw}\" stroke-dasharray=\"${st.dash}\" marker-end=\"url(#${st.marker})\"/>` +\n edgePill(p, e.label) +\n `</g>`;\n }\n\n for (const n of nodes) {\n const r = rectFor(n);\n const st = feStyle(n.kind);\n const k = (n.kind ?? '').toLowerCase();\n const gl = GLYPH_KINDS.has(k) ? nodeGlyph(GLYPH_REMAP[k] ?? k, r.x + 16, r.y + 16, st.accent) : '';\n const nx = st.solid === true ? r.x + r.w / 2 : gl.length > 0 ? r.x + 42 : r.x + 16;\n const anchor = st.solid === true ? 'middle' : 'start';\n const nameY = r.y + (st.stereo !== undefined ? 38 : n.note !== undefined ? 36 : 44);\n const noteY = r.y + (st.stereo !== undefined ? 56 : 52);\n const stroke = st.solid === true ? 'none' : st.accent;\n const dashAttr = st.dash !== undefined ? ` stroke-dasharray=\"${st.dash}\"` : '';\n const stripe =\n st.solid === true\n ? ''\n : `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"5\" height=\"${r.h}\" rx=\"2\" fill=\"${st.accent}\"/>`;\n const stereo =\n st.stereo !== undefined\n ? `<text x=\"${r.x + r.w / 2}\" y=\"${r.y + 20}\" class=\"uml-stereo\">«${escapeHtml(st.stereo)}»</text>`\n : '';\n const note =\n n.note !== undefined\n ? `<text x=\"${nx}\" y=\"${noteY}\" class=\"blk-tech\" fill=\"${st.solid === true ? '#cfe0f3' : st.accent}\" text-anchor=\"${anchor}\">${escapeHtml(n.note)}</text>`\n : '';\n s +=\n `<g filter=\"url(#gshadow)\">` +\n `<rect x=\"${r.x}\" y=\"${r.y}\" width=\"${r.w}\" height=\"${r.h}\" rx=\"9\" fill=\"${st.fill}\" stroke=\"${stroke}\" stroke-width=\"1.2\"${dashAttr}/>` +\n stripe +\n gl +\n stereo +\n `<text x=\"${nx}\" y=\"${nameY}\" class=\"blk-name\" fill=\"${st.text}\" text-anchor=\"${anchor}\">${escapeHtml(n.name)}</text>` +\n note +\n `</g>`;\n }\n\n s += `</svg>`;\n return diagramFrame(\n {\n tag: frame.tag,\n ...(frame.tagBg !== undefined ? { tagBg: frame.tagBg } : {}),\n ...(data.title !== undefined ? { title: data.title } : {}),\n ...(data.description !== undefined ? { desc: data.description } : {}),\n },\n s,\n );\n}\n\n/** `felogic` — frontend module graph (purple LOGIC tag). */\nexport function renderFelogic(data: BlockDataMap['felogic']): string {\n return renderFelogicGraph(data, { tag: 'LOGIC', tagBg: '#6b21a8' });\n}\n/** `belogic` — backend module graph (navy LOGIC tag). */\nexport function renderBelogic(data: BlockDataMap['belogic']): string {\n return renderFelogicGraph(data, { tag: 'LOGIC', tagBg: '#0e54a1' });\n}\n","/**\n * Renders UI mockups — low-fidelity wireframes inside device frames\n * (desktop window, browser, or phone). Each screen is a vertical stack of\n * UI elements (header, button, list, card, …) drawn as neutral placeholders,\n * Excalidraw-flavoured.\n *\n * Screens lay out left-to-right in a row. Element heights are fixed per type;\n * the frame grows to fit its content (phones keep a minimum height).\n */\n\nimport type { BlockDataMap } from '@avodado/core';\nimport { escapeHtml } from '../escape.js';\nimport { wrapText } from '../svg/wrapText.js';\nimport { diagramFrame } from './frame.js';\n\ntype Screen = NonNullable<BlockDataMap['wireframe']['screens']>[number];\ntype Element = NonNullable<Screen['elements']>[number];\n\n/** Inner content width per device (the drawable area inside the frame chrome). */\nfunction contentWidth(device: string): number {\n if (device === 'phone') return 200;\n return 380; // desktop / browser\n}\n\n/** Vertical space one element consumes (its drawn height + the gap below). */\nfunction elementHeight(el: Element): number {\n const rows = Math.max(1, el.rows ?? 1);\n switch (el.type) {\n case 'header':\n return 34;\n case 'subheader':\n return 26;\n case 'text':\n return 16 + (rows - 1) * 12;\n case 'button':\n return 42;\n case 'input':\n case 'search':\n return 42;\n case 'image':\n return 96;\n case 'avatar':\n return 52;\n case 'card':\n return rows * 64 + (rows - 1) * 10;\n case 'list':\n return rows * 40;\n case 'nav':\n return 34;\n case 'tabs':\n return 52;\n case 'divider':\n return 14;\n case 'badge':\n return 26;\n case 'toggle':\n return 30;\n case 'spacer':\n return 18 * rows;\n default:\n return 24;\n }\n}\n\nconst PH = 'fill=\"var(--light-gray)\" stroke=\"var(--rule)\" stroke-width=\"1\"';\n\n/** Draws one element at (x, y) within a content column of width w. Returns SVG. */\nfunction drawElement(el: Element, x: number, y: number, w: number): string {\n const rows = Math.max(1, el.rows ?? 1);\n const label = el.label ?? '';\n const accent =\n el.tone === 'danger'\n ? 'var(--negative)'\n : el.tone === 'muted'\n ? 'var(--gray)'\n : 'var(--navy)';\n const anchorX = el.align === 'c' ? x + w / 2 : el.align === 'r' ? x + w : x;\n const anchor = el.align === 'c' ? 'middle' : el.align === 'r' ? 'end' : 'start';\n\n switch (el.type) {\n case 'header':\n return `<text x=\"${anchorX}\" y=\"${y + 22}\" class=\"wf-h\" fill=\"var(--charcoal)\" text-anchor=\"${anchor}\">${escapeHtml(label || 'Heading')}</text>`;\n case 'subheader':\n return `<text x=\"${anchorX}\" y=\"${y + 17}\" class=\"wf-sub\" fill=\"var(--gray)\" text-anchor=\"${anchor}\">${escapeHtml(label || 'Subheading')}</text>`;\n case 'text': {\n let s = '';\n for (let i = 0; i < rows; i++) {\n const lw = i === rows - 1 ? w * 0.66 : w;\n s += `<rect x=\"${x}\" y=\"${y + i * 12}\" width=\"${lw}\" height=\"6\" rx=\"3\" fill=\"var(--rule)\"/>`;\n }\n return s;\n }\n case 'button':\n return (\n `<rect x=\"${x}\" y=\"${y}\" width=\"${w}\" height=\"34\" rx=\"8\" fill=\"${accent}\"/>` +\n `<text x=\"${x + w / 2}\" y=\"${y + 22}\" class=\"wf-btn\" text-anchor=\"middle\">${escapeHtml(label || 'Button')}</text>`\n );\n case 'input':\n case 'search': {\n const icon =\n el.type === 'search'\n ? `<circle cx=\"${x + 16}\" cy=\"${y + 17}\" r=\"5\" fill=\"none\" stroke=\"var(--gray)\" stroke-width=\"1.4\"/><path d=\"M${x + 20} ${y + 21} l4 4\" stroke=\"var(--gray)\" stroke-width=\"1.4\"/>`\n : '';\n const tx = el.type === 'search' ? x + 30 : x + 12;\n return (\n `<rect x=\"${x}\" y=\"${y}\" width=\"${w}\" height=\"34\" rx=\"8\" fill=\"var(--white)\" stroke=\"var(--rule)\" stroke-width=\"1.2\"/>` +\n icon +\n `<text x=\"${tx}\" y=\"${y + 21}\" class=\"wf-ph-text\">${escapeHtml(label || 'Type here…')}</text>`\n );\n }\n case 'image':\n return (\n `<rect x=\"${x}\" y=\"${y}\" width=\"${w}\" height=\"88\" rx=\"8\" ${PH}/>` +\n `<path d=\"M${x} ${y + 88} L${x + w * 0.4} ${y + 40} L${x + w * 0.62} ${y + 66} L${x + w * 0.78} ${y + 50} L${x + w} ${y + 88}\" fill=\"none\" stroke=\"var(--gray)\" stroke-width=\"1.3\"/>` +\n `<circle cx=\"${x + w * 0.74} \" cy=\"${y + 26}\" r=\"7\" fill=\"none\" stroke=\"var(--gray)\" stroke-width=\"1.3\"/>`\n );\n case 'avatar':\n return (\n `<circle cx=\"${x + 22}\" cy=\"${y + 22}\" r=\"20\" ${PH}/>` +\n `<circle cx=\"${x + 22}\" cy=\"${y + 17}\" r=\"7\" fill=\"var(--gray)\"/>` +\n `<path d=\"M${x + 9} ${y + 40} a13 11 0 0 1 26 0\" fill=\"var(--gray)\"/>` +\n (label\n ? `<text x=\"${x + 52}\" y=\"${y + 27}\" class=\"wf-sub\" fill=\"var(--charcoal)\">${escapeHtml(label)}</text>`\n : '')\n );\n case 'card': {\n let s = '';\n for (let i = 0; i < rows; i++) {\n const cy = y + i * 74;\n s +=\n `<rect x=\"${x}\" y=\"${cy}\" width=\"${w}\" height=\"64\" rx=\"10\" fill=\"var(--white)\" stroke=\"var(--rule)\" stroke-width=\"1.2\"/>` +\n `<rect x=\"${x + 12}\" y=\"${cy + 12}\" width=\"40\" height=\"40\" rx=\"8\" ${PH}/>` +\n `<rect x=\"${x + 64}\" y=\"${cy + 16}\" width=\"${w - 92}\" height=\"7\" rx=\"3.5\" fill=\"var(--rule)\"/>` +\n `<rect x=\"${x + 64}\" y=\"${cy + 34}\" width=\"${(w - 92) * 0.6}\" height=\"6\" rx=\"3\" fill=\"var(--rule)\"/>`;\n }\n const cap = label\n ? `<text x=\"${x + 64}\" y=\"${y + 30}\" class=\"wf-ph-text\"></text>`\n : '';\n return s + cap;\n }\n case 'list': {\n let s = '';\n for (let i = 0; i < rows; i++) {\n const ly = y + i * 40;\n s +=\n `<circle cx=\"${x + 16}\" cy=\"${ly + 20}\" r=\"12\" ${PH}/>` +\n `<rect x=\"${x + 38}\" y=\"${ly + 12}\" width=\"${w - 76}\" height=\"6\" rx=\"3\" fill=\"var(--rule)\"/>` +\n `<rect x=\"${x + 38}\" y=\"${ly + 24}\" width=\"${(w - 76) * 0.55}\" height=\"5\" rx=\"2.5\" fill=\"var(--rule)\"/>` +\n `<path d=\"M${x + w - 14} ${ly + 15} l5 5 l-5 5\" fill=\"none\" stroke=\"var(--gray)\" stroke-width=\"1.4\"/>` +\n (i < rows - 1\n ? `<line x1=\"${x + 38}\" y1=\"${ly + 40}\" x2=\"${x + w}\" y2=\"${ly + 40}\" stroke=\"var(--light-gray)\" stroke-width=\"1\"/>`\n : '');\n }\n return s;\n }\n case 'nav': {\n // a row of pill items; label is comma-separated item names.\n const items = (label || 'Home, Docs, Pricing, About').split(',').map((t) => t.trim());\n let s = '';\n let nx = x;\n for (const it of items) {\n const pw = 16 + it.length * 6.2;\n s +=\n `<rect x=\"${nx}\" y=\"${y + 4}\" width=\"${pw}\" height=\"22\" rx=\"11\" fill=\"var(--light-gray)\"/>` +\n `<text x=\"${nx + pw / 2}\" y=\"${y + 19}\" class=\"wf-ph-text\" text-anchor=\"middle\">${escapeHtml(it)}</text>`;\n nx += pw + 8;\n }\n return s;\n }\n case 'tabs': {\n const items = (label || 'Home, Search, Bell, Profile').split(',').map((t) => t.trim());\n const seg = w / items.length;\n let s = `<line x1=\"${x}\" y1=\"${y}\" x2=\"${x + w}\" y2=\"${y}\" stroke=\"var(--rule)\" stroke-width=\"1\"/>`;\n items.forEach((it, i) => {\n const cx = x + seg * i + seg / 2;\n s +=\n `<circle cx=\"${cx}\" cy=\"${y + 18}\" r=\"8\" fill=\"none\" stroke=\"${i === 0 ? accent : 'var(--gray)'}\" stroke-width=\"1.6\"/>` +\n `<text x=\"${cx}\" y=\"${y + 42}\" class=\"wf-tab\" text-anchor=\"middle\" fill=\"${i === 0 ? accent : 'var(--gray)'}\">${escapeHtml(it)}</text>`;\n });\n return s;\n }\n case 'divider':\n return `<line x1=\"${x}\" y1=\"${y + 7}\" x2=\"${x + w}\" y2=\"${y + 7}\" stroke=\"var(--rule)\" stroke-width=\"1\"/>`;\n case 'badge': {\n const pw = 22 + label.length * 6.4;\n return (\n `<rect x=\"${anchorX - (anchor === 'middle' ? pw / 2 : anchor === 'end' ? pw : 0)}\" y=\"${y}\" width=\"${pw}\" height=\"22\" rx=\"11\" fill=\"${accent}\"/>` +\n `<text x=\"${anchorX - (anchor === 'middle' ? 0 : anchor === 'end' ? pw / 2 : -pw / 2)}\" y=\"${y + 15}\" class=\"wf-btn\" text-anchor=\"middle\">${escapeHtml(label || 'New')}</text>`\n );\n }\n case 'toggle':\n return (\n (label\n ? `<text x=\"${x}\" y=\"${y + 19}\" class=\"wf-sub\" fill=\"var(--charcoal)\">${escapeHtml(label)}</text>`\n : '') +\n `<rect x=\"${x + w - 44}\" y=\"${y + 6}\" width=\"44\" height=\"22\" rx=\"11\" fill=\"${accent}\"/>` +\n `<circle cx=\"${x + w - 16}\" cy=\"${y + 17}\" r=\"8\" fill=\"#fff\"/>`\n );\n case 'spacer':\n return '';\n default:\n return '';\n }\n}\n\n/** Renders one device frame and its stacked content. Returns {svg, width, height}. */\nfunction drawScreen(screen: Screen, idx: number): { svg: string; width: number; height: number } {\n const device = screen.device ?? 'browser';\n const cw = contentWidth(device);\n const pad = 16;\n const els = screen.elements ?? [];\n let contentH = 0;\n for (const el of els) contentH += elementHeight(el) + 10;\n contentH = Math.max(contentH, 80);\n\n // chrome heights\n const isPhone = device === 'phone';\n const isBrowser = device === 'browser';\n const titleBarH = 30;\n const addressBarH = isBrowser ? 26 : 0;\n const chromeTop = titleBarH + addressBarH;\n const homeBarH = isPhone ? 24 : 0;\n\n const frameW = cw + pad * 2;\n const screenH = contentH + pad;\n const frameH = chromeTop + screenH + homeBarH;\n const rx = isPhone ? 30 : 14;\n const sw = isPhone ? 2.4 : 1.8;\n const clip = `wfclip${idx}`;\n\n // Inner chrome + content, drawn first and clipped to the rounded frame so\n // nothing spills the corners. The border stroke is drawn LAST, on top, so the\n // outline is always crisp and visible above the fills.\n let inner = '';\n if (isPhone) {\n inner += `<rect x=\"0\" y=\"0\" width=\"${frameW}\" height=\"${titleBarH}\" fill=\"var(--light-gray)\"/>`;\n inner += `<rect x=\"${frameW / 2 - 26}\" y=\"6\" width=\"52\" height=\"9\" rx=\"4.5\" fill=\"var(--charcoal)\"/>`;\n if (screen.title)\n inner += `<text x=\"16\" y=\"20\" class=\"wf-status\">${escapeHtml(screen.title)}</text>`;\n inner += `<text x=\"${frameW - 16}\" y=\"20\" class=\"wf-status\" text-anchor=\"end\">100%</text>`;\n } else {\n inner += `<rect x=\"0\" y=\"0\" width=\"${frameW}\" height=\"${titleBarH}\" fill=\"var(--light-gray)\"/>`;\n inner += `<line x1=\"0\" y1=\"${titleBarH}\" x2=\"${frameW}\" y2=\"${titleBarH}\" stroke=\"var(--rule)\" stroke-width=\"1\"/>`;\n inner += `<circle cx=\"18\" cy=\"15\" r=\"5\" fill=\"var(--negative)\"/><circle cx=\"34\" cy=\"15\" r=\"5\" fill=\"var(--highlight)\"/><circle cx=\"50\" cy=\"15\" r=\"5\" fill=\"var(--positive)\"/>`;\n if (screen.title && !isBrowser)\n inner += `<text x=\"${frameW / 2}\" y=\"20\" class=\"wf-status\" text-anchor=\"middle\">${escapeHtml(screen.title)}</text>`;\n if (isBrowser) {\n const url = screen.url ?? screen.title ?? 'example.com';\n inner += `<rect x=\"68\" y=\"${titleBarH + 5}\" width=\"${frameW - 84}\" height=\"16\" rx=\"8\" fill=\"var(--white)\" stroke=\"var(--rule)\" stroke-width=\"1\"/>`;\n inner += `<text x=\"78\" y=\"${titleBarH + 16}\" class=\"wf-url\">${escapeHtml(url)}</text>`;\n }\n }\n\n let cy = chromeTop + pad;\n for (const el of els) {\n inner += drawElement(el, pad, cy, cw);\n cy += elementHeight(el) + 10;\n }\n if (isPhone) {\n inner += `<rect x=\"${frameW / 2 - 30}\" y=\"${frameH - 15}\" width=\"60\" height=\"5\" rx=\"2.5\" fill=\"var(--charcoal)\" opacity=\"0.55\"/>`;\n }\n\n const s =\n `<g filter=\"url(#gshadow)\">` +\n `<defs><clipPath id=\"${clip}\"><rect x=\"0\" y=\"0\" width=\"${frameW}\" height=\"${frameH}\" rx=\"${rx}\"/></clipPath></defs>` +\n // solid backing so the drop shadow reads against any page colour\n `<rect x=\"0\" y=\"0\" width=\"${frameW}\" height=\"${frameH}\" rx=\"${rx}\" fill=\"var(--white)\"/>` +\n `<g clip-path=\"url(#${clip})\">${inner}</g>` +\n // border on top — always visible above the fills\n `<rect x=\"0\" y=\"0\" width=\"${frameW}\" height=\"${frameH}\" rx=\"${rx}\" fill=\"none\" stroke=\"var(--charcoal)\" stroke-width=\"${sw}\"/>` +\n `</g>`;\n return { svg: s, width: frameW, height: frameH };\n}\n\nexport function renderWireframe(data: BlockDataMap['wireframe']): string {\n const screens = data.screens ?? [];\n const gap = 36;\n const capH = 22;\n const padX = 8;\n const padY = 8;\n\n const drawn = screens.map((screen, i) => drawScreen(screen, i));\n const totalW = drawn.reduce((a, d) => a + d.width, 0) + gap * Math.max(0, drawn.length - 1);\n const maxH = drawn.reduce((a, d) => Math.max(a, d.height), 0);\n const width = totalW + padX * 2;\n const height = maxH + capH + padY * 2;\n\n let s = `<svg viewBox=\"0 0 ${width} ${height}\" role=\"img\"><title>${escapeHtml(data.title ?? 'UI mockup')}</title>`;\n let x = padX;\n drawn.forEach((d, i) => {\n const screen = screens[i];\n s += `<g transform=\"translate(${x}, ${padY})\">${d.svg}</g>`;\n const cap = screen?.label;\n if (cap !== undefined && cap.length > 0) {\n const lines = wrapText(cap, Math.floor(d.width / 6), 2);\n lines.forEach((ln, j) => {\n s += `<text x=\"${x + d.width / 2}\" y=\"${padY + maxH + 16 + j * 12}\" class=\"wf-caption\" text-anchor=\"middle\">${escapeHtml(ln)}</text>`;\n });\n }\n x += d.width + gap;\n });\n s += `</svg>`;\n\n return diagramFrame(\n {\n tag: 'UI',\n tagBg: '#6b21a8',\n ...(data.title !== undefined ? { title: data.title } : {}),\n ...(data.description !== undefined ? { desc: data.description } : {}),\n },\n s,\n );\n}\n","/**\n * HTML renderer registry — mirrors the core block registry's exhaustiveness.\n *\n * Each block type maps to a function that takes its typed data and returns an\n * HTML string. The mapped type `{ [K in BlockType]: ... }` ensures omitting a\n * block type is a compile error — adding a new BlockType in core fails tsc here\n * until the renderer is added.\n */\n\nimport type { BlockDataMap, BlockType } from '@avodado/core';\n\nimport { renderCallout } from './blocks/callout.js';\nimport { renderErd } from './blocks/erd.js';\nimport { renderKanban } from './blocks/kanban.js';\nimport { renderMetaBlock } from './blocks/meta.js';\nimport { renderSequence } from './blocks/sequence.js';\nimport { renderTable } from './blocks/table.js';\nimport { renderTimeline } from './blocks/timeline.js';\nimport { renderTracker } from './blocks/tracker.js';\nimport { renderUserStory } from './blocks/userstory.js';\nimport { renderProseBlock } from './blocks/prose.js';\nimport { renderGlossary } from './blocks/glossary.js';\nimport { renderProsCons } from './blocks/proscons.js';\nimport { renderCvt } from './blocks/cvt.js';\nimport { renderStats } from './blocks/stats.js';\nimport { renderCode } from './blocks/code.js';\nimport { renderAgenda } from './blocks/agenda.js';\nimport { renderTree } from './blocks/tree.js';\nimport { renderPyramid } from './blocks/pyramid.js';\nimport { renderFunnel } from './blocks/funnel.js';\nimport { renderFlow } from './blocks/flow.js';\nimport { renderState } from './blocks/state.js';\nimport { renderDfd } from './blocks/dfd.js';\nimport { renderJourney } from './blocks/journey.js';\nimport { renderGantt } from './blocks/gantt.js';\nimport { renderGraph } from './blocks/graph.js';\nimport { renderQuadrant } from './blocks/quadrant.js';\nimport { renderSwimlane } from './blocks/swimlane.js';\nimport { renderC4 } from './blocks/c4.js';\nimport { renderUml } from './blocks/uml.js';\nimport { renderMece } from './blocks/mece.js';\nimport { renderFrontend } from './blocks/frontend.js';\nimport { renderCluster } from './blocks/cluster.js';\nimport {\n renderBlock,\n renderInfra,\n renderEvent,\n renderDdd,\n renderNetwork,\n} from './blocks/blockGraph.js';\nimport { renderFelogic, renderBelogic } from './blocks/felogic.js';\nimport { renderDag } from './blocks/flow.js';\nimport { renderWireframe } from './blocks/wireframe.js';\n\n/** Per-block HTML renderer signature. */\nexport type HtmlRenderer<K extends BlockType> = (data: BlockDataMap[K]) => string;\n\n/** Mapped type — adding a {@link BlockType} without an entry fails tsc. */\nexport type HtmlRendererRegistry = { readonly [K in BlockType]: HtmlRenderer<K> };\n\n/** The HTML renderer registry. `meta` is intentionally a no-op (cover is rendered separately). */\nexport const htmlRenderers: HtmlRendererRegistry = {\n meta: renderMetaBlock,\n callout: renderCallout,\n table: renderTable,\n sequence: renderSequence,\n erd: renderErd,\n userstory: renderUserStory,\n timeline: renderTimeline,\n kanban: renderKanban,\n tracker: renderTracker,\n prose: renderProseBlock,\n glossary: renderGlossary,\n proscons: renderProsCons,\n cvt: renderCvt,\n stats: renderStats,\n code: renderCode,\n agenda: renderAgenda,\n tree: renderTree,\n pyramid: renderPyramid,\n funnel: renderFunnel,\n flow: renderFlow,\n state: renderState,\n dfd: renderDfd,\n journey: renderJourney,\n gantt: renderGantt,\n graph: renderGraph,\n quadrant: renderQuadrant,\n swimlane: renderSwimlane,\n c4: renderC4,\n uml: renderUml,\n mece: renderMece,\n frontend: renderFrontend,\n cluster: renderCluster,\n block: renderBlock,\n infra: renderInfra,\n event: renderEvent,\n ddd: renderDdd,\n network: renderNetwork,\n felogic: renderFelogic,\n belogic: renderBelogic,\n dag: renderDag,\n wireframe: renderWireframe,\n};\n","/**\n * Global SVG `<defs>` shared by multiple block renderers (markers used as edge\n * arrow heads, a drop-shadow filter for boxed nodes).\n *\n * Emitted once near the top of the rendered body so subsequent SVGs can\n * reference them by id. Ported from `resources/doc-studio.jsx` `GlobalDefs`.\n */\n\n/**\n * Returns the SVG element containing global marker + filter definitions.\n * The element is invisible (width/height = 0) but the defs are scoped to the\n * document so any subsequent `<svg>` can use `marker-end=\"url(#gArrow)\"` etc.\n */\nexport function globalDefsSvg(): string {\n return (\n `<svg width=\"0\" height=\"0\" style=\"position:absolute\" aria-hidden=\"true\">` +\n `<defs>` +\n `<marker id=\"gArrow\" viewBox=\"0 0 10 10\" refX=\"9\" refY=\"5\" markerWidth=\"7\" markerHeight=\"7\" orient=\"auto-start-reverse\">` +\n `<path d=\"M0,0 L10,5 L0,10 z\" fill=\"var(--charcoal)\"/></marker>` +\n `<marker id=\"gSoft\" viewBox=\"0 0 10 10\" refX=\"9\" refY=\"5\" markerWidth=\"7\" markerHeight=\"7\" orient=\"auto-start-reverse\">` +\n `<path d=\"M0,0 L10,5 L0,10 z\" fill=\"var(--gray)\"/></marker>` +\n `<marker id=\"gErr\" viewBox=\"0 0 10 10\" refX=\"9\" refY=\"5\" markerWidth=\"7\" markerHeight=\"7\" orient=\"auto-start-reverse\">` +\n `<path d=\"M0,0 L10,5 L0,10 z\" fill=\"#991b1b\"/></marker>` +\n `<marker id=\"gTri\" viewBox=\"0 0 14 14\" refX=\"13\" refY=\"7\" markerWidth=\"14\" markerHeight=\"14\" orient=\"auto-start-reverse\">` +\n `<path d=\"M1,1 L13,7 L1,13 z\" fill=\"#fff\" stroke=\"#6b21a8\" stroke-width=\"1.2\"/></marker>` +\n `<filter id=\"gshadow\" x=\"-20%\" y=\"-20%\" width=\"140%\" height=\"170%\">` +\n `<feDropShadow dx=\"0\" dy=\"2\" stdDeviation=\"3\" flood-color=\"#0e54a1\" flood-opacity=\"0.13\"/></filter>` +\n `</defs>` +\n `</svg>`\n );\n}\n","/**\n * Theme system. Each theme is a set of CSS variable overrides applied via\n * `style=\"--navy: …; --blue: …\"` on the `.docskin` root element. The full\n * stylesheet (see {@link houseCss}) reads those variables.\n *\n * Adding a new theme = add an entry here. No CSS changes needed.\n *\n * Ported verbatim from `resources/doc-studio.jsx` `THEMES`.\n */\n\n/** Built-in theme names. */\nexport type ThemeName = 'textbook' | 'minimal' | 'teal' | 'plum' | 'slate' | 'dark' | 'soft';\n\n/** Default theme used when none is specified. */\nexport const DEFAULT_THEME: ThemeName = 'textbook';\n\ninterface ThemeDef {\n /** Human-readable label, for UI surfaces. */\n readonly label: string;\n /** CSS variable overrides applied at the `.docskin` root. */\n readonly vars: Readonly<Record<string, string>>;\n}\n\n/** The built-in themes. */\nexport const themes: Readonly<Record<ThemeName, ThemeDef>> = {\n // Default: warm textbook look (cream paper, deep academic navy, terracotta\n // accent, serif display + body) — the base :root tokens, no overrides needed.\n textbook: {\n label: 'Textbook',\n vars: {},\n },\n // Clean, modern, white: near-black ink, a single blue accent (#0070f3),\n // geometric sans, more rounding. (The former default.)\n minimal: {\n label: 'Minimal',\n vars: {\n '--navy': '#000000',\n '--navy-tint': '#d4d4d4',\n '--blue': '#0070f3',\n '--light-blue': '#e5f0ff',\n '--charcoal': '#111111',\n '--slate': '#444444',\n '--gray': '#888888',\n '--light-gray': '#fafafa',\n '--rule': '#eaeaea',\n '--highlight': '#0070f3',\n '--highlight-soft': '#e5f0ff',\n '--white': '#ffffff',\n '--radius': '8px',\n '--font-display':\n '\"Inter\",\"SF Pro Display\",-apple-system,BlinkMacSystemFont,\"Segoe UI\",Helvetica,Arial,sans-serif',\n '--font-body':\n '\"Inter\",-apple-system,BlinkMacSystemFont,\"Segoe UI\",Helvetica,Arial,sans-serif',\n },\n },\n teal: {\n label: 'Teal',\n vars: {\n '--navy': '#0f766e',\n '--blue': '#0e7490',\n '--highlight': '#f59e0b',\n },\n },\n plum: {\n label: 'Plum',\n vars: {\n '--navy': '#6b21a8',\n '--blue': '#7c3aed',\n '--highlight': '#db2777',\n },\n },\n slate: {\n label: 'Slate sans',\n vars: {\n '--navy': '#334155',\n '--blue': '#475569',\n '--highlight': '#0d9488',\n '--font-display': '\"Helvetica Neue\", Arial, sans-serif',\n },\n },\n // Full dark mode. Surfaces (--white) and ink (--charcoal) flip; neutrals are\n // remapped so hairlines/edges read as light-on-dark. Accent hues are brightened\n // for contrast. Node \"chip\" pastels (in the SVG palette) stay light by design —\n // they read as colored cards on the dark canvas.\n dark: {\n label: 'Dark',\n vars: {\n '--white': '#161b26', // surfaces: page + cards + diagram bg\n '--charcoal': '#e6e9f2', // primary ink + structural strokes\n '--slate': '#c2c9d6', // secondary text\n '--gray': '#94a0b4', // muted text / dashed edges\n '--light-gray': '#222a39', // subtle panels / zone fills / bars\n '--rule': '#333f54', // hairlines / borders\n '--navy': '#5b9cff', // primary accent (headings, links, primary nodes)\n '--navy-tint': '#1e2a44',\n '--blue': '#7fb0ff',\n '--light-blue': '#16233a',\n '--highlight': '#f7a64a',\n '--highlight-soft': '#3a2c17',\n '--positive': '#3ecf7a',\n '--positive-soft': '#16301f',\n '--negative': '#ff6b6b',\n '--negative-soft': '#3a1d1d',\n '--purple': '#b78bff',\n '--purple-soft': '#271d3a',\n '--teal': '#4fd1c5',\n '--teal-soft': '#13302d',\n '--radius': '14px',\n },\n },\n // Soft modern light theme: rounded surfaces, indigo accent, warm-gray ink.\n soft: {\n label: 'Soft',\n vars: {\n '--navy': '#4f46e5',\n '--blue': '#6366f1',\n '--charcoal': '#1f2433',\n '--slate': '#4b5366',\n '--gray': '#8b93a7',\n '--rule': '#e6e8ef',\n '--light-gray': '#f5f6fa',\n '--highlight': '#f59e0b',\n '--radius': '16px',\n '--font-display': '\"Helvetica Neue\", Arial, sans-serif',\n },\n },\n};\n\n/**\n * Returns the CSS variable overrides for a theme as an inline-style string\n * (e.g. `\"--navy:#0f766e;--blue:#0e7490;\"`). Empty string for the default\n * textbook theme.\n */\nexport function themeStyle(name: ThemeName): string {\n const vars = themes[name].vars;\n const parts: string[] = [];\n for (const k of Object.keys(vars)) parts.push(`${k}:${vars[k]};`);\n return parts.join('');\n}\n","/**\n * Renders a parsed {@link Document} into its composable PARTS — the CSS, the\n * theme-variable string, the inner body HTML (for a `<div class=\"docskin\">`),\n * the title, and a section index for navigation.\n *\n * {@link renderDocument} (in `document.ts`) wraps these parts into a standalone\n * `<!doctype html>` page. Embedding consumers (e.g. a React app) inject the\n * parts directly: one `<style>` with `css`, a scoped `<style>` that sets the\n * theme vars, and the `body` inside their own `.docskin` host. This avoids\n * nesting a full HTML document inside the page and enables live theme switching\n * (swap only the theme-vars style) and section-level navigation (each section\n * carries an `id`).\n */\n\nimport type { BlockDataMap, BlockType, Document, Segment, TypedSegment } from '@avodado/core';\nimport { houseCss } from './css.js';\nimport { escapeHtml } from './escape.js';\nimport { renderCover } from './blocks/meta.js';\nimport { SECTION_LABEL } from './blocks/frame.js';\nimport { renderProse } from './markdown.js';\nimport { htmlRenderers } from './registry.js';\nimport { globalDefsSvg } from './svg/defs.js';\nimport { DEFAULT_THEME, themeStyle, type ThemeName } from './themes.js';\n\n/** Options shared by {@link renderDocumentParts} and the page renderer. */\nexport interface RenderPartsOptions {\n /** Theme name. Defaults to `textbook`. */\n readonly theme?: ThemeName;\n /**\n * Custom CSS-variable overrides applied after the named theme (they win),\n * e.g. `{ '--navy': '#123456' }`.\n */\n readonly themeVars?: Readonly<Record<string, string>>;\n}\n\n/** One navigable section of a rendered document. */\nexport interface DocumentSection {\n /** DOM id of the `<section>` (e.g. `section-01`). */\n readonly id: string;\n /** 1-based section number. */\n readonly num: number;\n /** Section label (e.g. `Roadmap`, `Sequence`). */\n readonly label: string;\n /** The block's title, if it has one. */\n readonly title?: string;\n}\n\n/** The composable pieces of a rendered document. */\nexport interface DocumentParts {\n /** Theme-independent house stylesheet. Inject once. */\n readonly css: string;\n /** Theme variable declarations (e.g. `--navy:#0f766e;`), or `''` for default. */\n readonly themeVars: string;\n /** Inner HTML for a `<div class=\"docskin\">` host: defs + cover + sections. */\n readonly body: string;\n /** Document title (from the `meta` block). */\n readonly title: string;\n /** Section index for navigation. */\n readonly sections: readonly DocumentSection[];\n}\n\ninterface RenderCtx {\n sectionNum: number;\n sections: DocumentSection[];\n}\n\nfunction pad2(n: number): string {\n return n < 10 ? `0${n}` : String(n);\n}\n\n/** Reads optional title/lede from a block's data, defensively typed. */\nfunction readTitleAndLede(data: unknown): { title?: string; lede?: string } {\n if (data === null || typeof data !== 'object') return {};\n const d = data as { title?: unknown; lede?: unknown };\n const out: { title?: string; lede?: string } = {};\n if (typeof d.title === 'string' && d.title.length > 0) out.title = d.title;\n if (typeof d.lede === 'string' && d.lede.length > 0) out.lede = d.lede;\n return out;\n}\n\nfunction renderSectionHead(num: number, kind: BlockType, title?: string, lede?: string): string {\n const label = SECTION_LABEL[kind];\n const titleHtml =\n title !== undefined ? `<h2 class=\"section-title\">${escapeHtml(title)}</h2>` : '';\n const ledeHtml = lede !== undefined ? `<p class=\"section-lede\">${escapeHtml(lede)}</p>` : '';\n return (\n `<div class=\"section-head\">` +\n `<div class=\"section-num\">SECTION ${pad2(num)} · ${escapeHtml(label)}</div>` +\n titleHtml +\n ledeHtml +\n `</div>`\n );\n}\n\n/**\n * Dispatches a typed block to its renderer. The registry is keyed by the same\n * `BlockType` discriminant as the segment, so this single contained cast asserts\n * the invariant rather than leaking casts to every call site.\n */\nfunction dispatchBlock<K extends BlockType>(kind: K, data: BlockDataMap[K]): string {\n const fn = htmlRenderers[kind] as (data: BlockDataMap[K]) => string;\n return fn(data);\n}\n\nfunction renderTypedSegment(seg: TypedSegment, ctx: RenderCtx): string {\n if (seg.kind === 'meta') return '';\n if (seg.parseError !== undefined) {\n return `<div class=\"err\">${escapeHtml(seg.kind)} block — parse error:\\n${escapeHtml(seg.parseError)}</div>`;\n }\n if (seg.data === null || seg.data === undefined) return '';\n\n const body = dispatchBlock(seg.kind, seg.data as BlockDataMap[typeof seg.kind]);\n\n ctx.sectionNum += 1;\n const num = ctx.sectionNum;\n const { title, lede } = readTitleAndLede(seg.data);\n const id = `section-${pad2(num)}`;\n ctx.sections.push({\n id,\n num,\n label: SECTION_LABEL[seg.kind],\n ...(title !== undefined ? { title } : {}),\n });\n const head = renderSectionHead(num, seg.kind, title, lede);\n\n return `<section id=\"${id}\" class=\"section-block\">${head}${body}</section>`;\n}\n\nfunction renderSegment(seg: Segment, ctx: RenderCtx): string {\n if (seg.kind === 'markdown') return renderProse(seg.text);\n return renderTypedSegment(seg, ctx);\n}\n\n/** Builds the theme-variable declaration string (named theme + overrides). */\nexport function buildThemeVars(\n theme: ThemeName,\n vars?: Readonly<Record<string, string>>,\n): string {\n let css = themeStyle(theme);\n if (vars !== undefined) {\n for (const k of Object.keys(vars)) css += `${k}:${vars[k]};`;\n }\n return css;\n}\n\n/**\n * Renders a document into its composable parts.\n *\n * @param doc - The parsed Avodado document.\n * @param opts - Optional theme + variable overrides.\n * @returns The CSS, theme vars, body HTML, title, and section index.\n */\nexport function renderDocumentParts(doc: Document, opts: RenderPartsOptions = {}): DocumentParts {\n const title = doc.meta?.title ?? 'Untitled';\n const theme = opts.theme ?? DEFAULT_THEME;\n const themeVars = buildThemeVars(theme, opts.themeVars);\n const ctx: RenderCtx = { sectionNum: 0, sections: [] };\n const body =\n globalDefsSvg() +\n renderCover(doc.meta) +\n doc.segments.map((s) => renderSegment(s, ctx)).join('');\n return { css: houseCss, themeVars, body, title, sections: ctx.sections };\n}\n","/**\n * Renders a parsed {@link Document} to a standalone HTML string.\n *\n * - Inlines the house CSS in `<style>` so the output is self-contained.\n * - Wraps the body in `<div class=\"docskin\">` so the CSS rules apply.\n * - Applies an optional theme by setting CSS variables on `:root`.\n *\n * The actual rendering is done by {@link renderDocumentParts} (in `parts.ts`);\n * this function just wraps those parts into a full HTML page. Embedding\n * consumers (e.g. a React app) should use `renderDocumentParts` directly.\n *\n * @example\n * ```ts\n * import { parseDocument } from '@avodado/core';\n * import { renderDocument } from '@avodado/render';\n *\n * const html = renderDocument(parseDocument(md, 'orders'), { theme: 'teal' });\n * ```\n */\n\nimport type { Document } from '@avodado/core';\nimport { escapeHtml } from './escape.js';\nimport { renderDocumentParts, type RenderPartsOptions } from './parts.js';\n\n/** Options for {@link renderDocument}. */\nexport type RenderOptions = RenderPartsOptions;\n\n/**\n * Renders a document to a standalone HTML page.\n *\n * @param doc - The parsed Avodado document.\n * @param opts - Optional render options (theme).\n * @returns A complete HTML string (`<!doctype html>…</html>`).\n */\nexport function renderDocument(doc: Document, opts: RenderOptions = {}): string {\n const parts = renderDocumentParts(doc, opts);\n const themeBlock =\n parts.themeVars.length > 0 ? `\\n<style>:root{${parts.themeVars}}</style>` : '';\n return (\n `<!doctype html>\\n` +\n `<html lang=\"en\">\\n` +\n `<head>\\n` +\n `<meta charset=\"utf-8\">\\n` +\n `<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">\\n` +\n `<title>${escapeHtml(parts.title)}</title>\\n` +\n `<style>${parts.css}</style>` +\n themeBlock +\n `\\n</head>\\n` +\n `<body>\\n` +\n `<div class=\"docskin\">\\n` +\n parts.body +\n `</div>\\n` +\n `</body>\\n` +\n `</html>\\n`\n );\n}\n"]}