libpetri 2.13.0 → 3.0.1
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/README.md +89 -130
- package/dist/chunk-6NH64RCU.js +1016 -0
- package/dist/chunk-6NH64RCU.js.map +1 -0
- package/dist/{chunk-7VJ5CYUU.js → chunk-JZIEWVAV.js} +905 -62
- package/dist/chunk-JZIEWVAV.js.map +1 -0
- package/dist/{chunk-JVI5HFRX.js → chunk-VCDOKWVU.js} +2 -2
- package/dist/{chunk-E3ZWB645.js → chunk-YVIPJ6KM.js} +1 -1
- package/dist/chunk-YVIPJ6KM.js.map +1 -0
- package/dist/debug/index.d.ts +2 -2
- package/dist/debug/index.js +2 -2
- package/dist/doclet/index.d.ts +12 -3
- package/dist/doclet/index.js +8 -4
- package/dist/doclet/index.js.map +1 -1
- package/dist/doclet/resources/petrinet-diagrams.css +21 -0
- package/dist/doclet/resources/petrinet-diagrams.js +3575 -3573
- package/dist/dot-exporter-3STXYK74.js +9 -0
- package/dist/{render-ZGZEZ5RK.js → elk-place-YVNQFGXI.js} +3 -258
- package/dist/elk-place-YVNQFGXI.js.map +1 -0
- package/dist/{event-store-DKTenPbC.d.ts → event-store-BFX_yJ8I.d.ts} +1 -1
- package/dist/export/index.d.ts +1 -1
- package/dist/export/index.js +2 -2
- package/dist/index.d.ts +91 -38
- package/dist/index.js +368 -294
- package/dist/index.js.map +1 -1
- package/dist/pan-zoom-Cp51IkDl.d.ts +33 -0
- package/dist/{petri-net-C3LSY-vm.d.ts → petri-net-WSScMyDL.d.ts} +43 -29
- package/dist/preprocess-FN3F75JR.js +193 -0
- package/dist/preprocess-FN3F75JR.js.map +1 -0
- package/dist/render-QOHGDWNE.js +78 -0
- package/dist/render-QOHGDWNE.js.map +1 -0
- package/dist/render-dom/index.d.ts +28 -29
- package/dist/render-dom/index.js +14 -21
- package/dist/render-dom/index.js.map +1 -1
- package/dist/verification/index.d.ts +273 -7
- package/dist/verification/index.js +7 -1
- package/dist/verification/index.js.map +1 -1
- package/dist/viewer/index.d.ts +24 -32
- package/dist/viewer/index.js +9 -1003
- package/dist/viewer/index.js.map +1 -1
- package/dist/viewer/viewer.css +21 -0
- package/dist/viewer/viewer.iife.js +3575 -3573
- package/package.json +2 -2
- package/dist/chunk-7VJ5CYUU.js.map +0 -1
- package/dist/chunk-E3ZWB645.js.map +0 -1
- package/dist/dot-exporter-SHBYMMJ3.js +0 -9
- package/dist/render-ZGZEZ5RK.js.map +0 -1
- /package/dist/{chunk-JVI5HFRX.js.map → chunk-VCDOKWVU.js.map} +0 -0
- /package/dist/{dot-exporter-SHBYMMJ3.js.map → dot-exporter-3STXYK74.js.map} +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/core/match-spec.ts"],"sourcesContent":["/**\n * ν-net join correlation ([[MatchSpec]]).\n *\n * A {@link MatchSpec} declares that a subset of a transition's **input** places\n * must be correlated by **name equality**: the transition is enabled only when\n * there exists a single {@link NameId} `n` such that every correlated input\n * supplies (at least) its required token count whose projected name equals `n`.\n * On firing, exactly those name-matched tokens are consumed (spec NU-020).\n *\n * This is the single *decidable* predicate — equality of opaque names — and is\n * deliberately NOT a general guard: it correlates the name dimension *across*\n * places (composition-structural, like cardinality) rather than evaluating an\n * arbitrary boolean per token. When both a unary input `guard` and a match are\n * present the guard filters first, then the name correlation runs over the\n * survivors (NU-021).\n */\nimport type { Place } from './place.js';\nimport type { NameId } from './name.js';\n\n/**\n * A name projection: maps a token's value to its {@link NameId}. A projection\n * that yields no name (returns `null`/`undefined` at runtime) is treated as\n * \"no name\" — that token never correlates — mirroring the Java/Rust `KeyFn`\n * contract; the binding selector handles a nullish result defensively.\n */\nexport type KeyFn<T = any> = (value: T) => NameId;\n\n/** One correlated input: the place plus its name projection. */\nexport interface MatchKey<T = any> {\n readonly place: Place<T>;\n readonly key: KeyFn<T>;\n}\n\n/** Correlated fork/join match specification (ν-net join side). */\nexport interface MatchSpec {\n readonly keys: readonly MatchKey[];\n}\n\n/** Builds one correlated input for a {@link MatchSpec}. */\nexport function matchKey<T>(place: Place<T>, key: KeyFn<T>): MatchKey<T> {\n return { place, key };\n}\n\n/**\n * Builds a {@link MatchSpec} from two or more correlated inputs.\n *\n * @example\n * Transition.builder('join')\n * .inputs(one(branchA), one(branchB))\n * .match(matchSpec(\n * matchKey(branchA, (m: Msg) => nameId(m.correlationId)),\n * matchKey(branchB, (m: Msg) => nameId(m.correlationId)),\n * ))\n *\n * @throws if fewer than two inputs are correlated (a match over a single place\n * is just a guard).\n */\nexport function matchSpec(...keys: MatchKey[]): MatchSpec {\n if (keys.length < 2) {\n throw new Error(`MatchSpec must correlate at least 2 input places, got ${keys.length}`);\n }\n return { keys };\n}\n\n/** Returns the name projection for `placeName`, or `undefined` if not correlated. */\nexport function keyForPlace(spec: MatchSpec, placeName: string): KeyFn | undefined {\n for (const k of spec.keys) {\n if (k.place.name === placeName) return k.key;\n }\n return undefined;\n}\n\n/** True when `placeName` is one of the correlated inputs. */\nexport function matchCorrelates(spec: MatchSpec, placeName: string): boolean {\n return spec.keys.some(k => k.place.name === placeName);\n}\n"],"mappings":";AAuCO,SAAS,SAAY,OAAiB,KAA4B;AACvE,SAAO,EAAE,OAAO,IAAI;AACtB;AAgBO,SAAS,aAAa,MAA6B;AACxD,MAAI,KAAK,SAAS,GAAG;AACnB,UAAM,IAAI,MAAM,yDAAyD,KAAK,MAAM,EAAE;AAAA,EACxF;AACA,SAAO,EAAE,KAAK;AAChB;AAGO,SAAS,YAAY,MAAiB,WAAsC;AACjF,aAAW,KAAK,KAAK,MAAM;AACzB,QAAI,EAAE,MAAM,SAAS,UAAW,QAAO,EAAE;AAAA,EAC3C;AACA,SAAO;AACT;AAGO,SAAS,gBAAgB,MAAiB,WAA4B;AAC3E,SAAO,KAAK,KAAK,KAAK,OAAK,EAAE,MAAM,SAAS,SAAS;AACvD;","names":[]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/viewer/render.ts","../src/viewer/layout/preprocess.ts","../src/viewer/layout/elk-place.ts"],"sourcesContent":["/**\n * DOT → SVG rendering for the canonical libpetri viewer.\n *\n * Two render paths:\n *\n * renderDotToSvg(dot) — plain Graphviz `dot` engine.\n * renderDotToSvgWithElkLayout(dot) — C0 pipeline: parse → fold →\n * replicate → ELK → writeBack →\n * Graphviz `nop2` (pinned nodes AND\n * edge routes). Cached by DOT hash.\n *\n * The ELK path is the default for {@link mount}; the plain-Graphviz path\n * remains as a fallback for callers that want stock layout (or for\n * environments where elkjs isn't installed).\n *\n * @module viewer/render\n */\n\nimport { instance as vizInstance } from '@viz-js/viz';\nimport {\n foldOrphans,\n parseLibpetriDot,\n replicateShared,\n} from './layout/preprocess.js';\nimport { elkLayout, writeBack } from './layout/elk-place.js';\nimport type { ElkLayoutConfig } from './layout/elk-place.js';\n\ntype Viz = Awaited<ReturnType<typeof vizInstance>>;\n\nlet vizPromise: Promise<Viz> | null = null;\n\n/** Memoize the viz.js instance so the wasm loads only once per page. */\nexport function getViz(): Promise<Viz> {\n if (!vizPromise) vizPromise = vizInstance();\n return vizPromise;\n}\n\n/**\n * Render a DOT source string to an SVGSVGElement using the plain `dot`\n * engine. Deterministic across runs; libpetri exporters emit byte-stable\n * DOT per spec EXP-014 so the same DOT yields the same SVG.\n */\nexport async function renderDotToSvg(dotSource: string): Promise<SVGSVGElement> {\n const viz = await getViz();\n return viz.renderSVGElement(dotSource, { engine: 'dot' });\n}\n\n// ---- C0 / ELK pin-mode cache ---------------------------------------------\n\n/** FNV-1a 32-bit hash. Fast enough that a SHA isn't worth the import. */\nfunction fnv1a(input: string): string {\n let h = 0x811c9dc5;\n for (let i = 0; i < input.length; i++) {\n h ^= input.charCodeAt(i);\n h = Math.imul(h, 0x01000193);\n }\n return (h >>> 0).toString(16);\n}\n\nconst PINNED_DOT_CACHE_CAP = 16;\nconst pinnedDotCache = new Map<string, string>();\n\nfunction getCachedPinnedDot(key: string): string | undefined {\n const hit = pinnedDotCache.get(key);\n if (hit !== undefined) {\n // LRU touch: re-insert moves to most-recent position in Map ordering.\n pinnedDotCache.delete(key);\n pinnedDotCache.set(key, hit);\n }\n return hit;\n}\n\nfunction setCachedPinnedDot(key: string, value: string): void {\n pinnedDotCache.set(key, value);\n while (pinnedDotCache.size > PINNED_DOT_CACHE_CAP) {\n const oldest = pinnedDotCache.keys().next().value;\n if (oldest === undefined) break;\n pinnedDotCache.delete(oldest);\n }\n}\n\n/** Test helper — clears the pinned-DOT LRU cache between mounts. */\nexport function _clearElkLayoutCache(): void {\n pinnedDotCache.clear();\n}\n\n/**\n * Run the C0 layout pipeline against a libpetri DOT source and return the\n * rendered SVG. The expensive steps (preprocess + ELK layout + DOT rewrite)\n * are cached keyed on the input DOT's hash plus the layout config, so\n * re-mounts on the same net structure and config skip everything except the\n * Graphviz pin-mode draw.\n *\n * Per-tick marking updates do NOT call this — they toggle classes on the\n * already-mounted SVG. ELK only runs when the net structure changes.\n *\n * `cfg` tunes the ELK stage — see {@link ElkLayoutConfig}.\n */\nexport async function renderDotToSvgWithElkLayout(\n dotSource: string,\n cfg?: ElkLayoutConfig,\n): Promise<SVGSVGElement> {\n const key = fnv1a(dotSource + '\\0' + JSON.stringify(cfg ?? {}));\n let pinnedDot = getCachedPinnedDot(key);\n if (pinnedDot === undefined) {\n const graph = replicateShared(\n foldOrphans(parseLibpetriDot(dotSource), 0.7),\n { max: Infinity },\n );\n const layout = await elkLayout(graph, cfg);\n pinnedDot = writeBack(graph, layout);\n setCachedPinnedDot(key, pinnedDot);\n }\n const viz = await getViz();\n return viz.renderSVGElement(pinnedDot, {\n // nop2 draws the pinned node positions AND our ELK-computed orthogonal\n // edge routes verbatim. See writeBack/edgePosSpline: we route edges\n // ourselves rather than let Graphviz's ortho router run, which crashes\n // the wasm on large nets.\n engine: 'nop2',\n yInvert: true,\n });\n}\n","/**\n * Graph pre-processing for the C0-replicate-default layout pipeline.\n *\n * Three pure-ish transforms operate on a {@link GraphModel} parsed from a\n * libpetri-exported DOT string:\n *\n * parseLibpetriDot(dot) → GraphModel\n * foldOrphans(graph, threshold) → GraphModel (REASSIGN_ORPHANS)\n * replicateShared(graph, opts) → GraphModel (REPLICATE_SHARED)\n *\n * The pipeline turns a flat cluster soup into a cluster-internal one by\n * (a) folding orphan nodes whose edges concentrate in one cluster into that\n * cluster, and (b) cloning shared places into every foreign cluster they\n * touch so cross-cluster spaghetti disappears. The resulting GraphModel is\n * what ELK lays out (Stage 2) and Graphviz then renders in pin-mode.\n *\n * Algorithm lineage: ported from\n * `/home/db/otto-repos/nucleus_marvin/.scratch/javadoc-layout-exp/CHECKPOINTS/run16_GOOD_v3_skip-junctions.mjs`\n * lines 14–220. The arc-type detection, replica naming\n * (`${placeId}__rep__${clusterShortName}`), and the `__replica` /\n * `replicaOf` markers are load-bearing — downstream stages key off them.\n *\n * @module viewer/layout/preprocess\n */\n\nexport type ArcType = 'normal' | 'reset' | 'inhibitor' | 'read';\nexport type NodeKind = 'place' | 'transition' | 'junction';\n\nexport interface ParsedNode {\n readonly id: string;\n readonly kind: NodeKind;\n readonly attrs: Record<string, string>;\n /** True iff this node was emitted by replicateShared. */\n readonly replica?: boolean;\n /** For a replica, the id of the original logical place. */\n readonly replicaOf?: string;\n}\n\nexport interface ParsedEdge {\n readonly src: string;\n readonly dst: string;\n readonly arc: ArcType;\n /**\n * Raw attribute body from the libpetri DOT (between the `[…]` brackets,\n * brackets stripped). Carries style/penwidth/label that we want to\n * round-trip verbatim so the rendered output matches `DotExporter`'s\n * native look.\n */\n readonly rawAttrs: string;\n}\n\nexport interface ParsedCluster {\n readonly id: string; // \"cluster_productSearch\"\n readonly shortName: string; // \"productSearch\"\n readonly nodes: readonly string[];\n}\n\nexport interface GraphModel {\n readonly nodes: ReadonlyMap<string, ParsedNode>;\n readonly clusters: ReadonlyMap<string, ParsedCluster>;\n readonly nodeToCluster: ReadonlyMap<string, string>;\n /** Node ids not in any cluster (rendered at the orchestrator root). */\n readonly orphans: readonly string[];\n readonly edges: readonly ParsedEdge[];\n}\n\nfunction classifyKind(id: string): NodeKind {\n if (id.startsWith('p_')) return 'place';\n if (id.startsWith('t_')) return 'transition';\n return 'junction';\n}\n\n/**\n * Recover key=value attributes from inside a DOT `[...]` block.\n *\n * Mirrors v3 line 29. The regex is intentionally permissive about quoted\n * values containing escaped quotes; it does not validate DOT syntax.\n */\nfunction parseAttrs(body: string): Record<string, string> {\n const attrs: Record<string, string> = {};\n for (const m of body.matchAll(/(\\w+)=(\"(?:[^\"]|\\\\.)*\"|\\S+?)(?=[\\s,]|$)/g)) {\n const [, key, raw] = m as unknown as [string, string, string];\n const v = raw.startsWith('\"') && raw.endsWith('\"') ? raw.slice(1, -1) : raw;\n attrs[key] = v;\n }\n return attrs;\n}\n\n/**\n * Parse a libpetri-exported DOT string into a {@link GraphModel}.\n *\n * Tolerates the current exporter shape (see\n * `java/src/main/java/org/libpetri/export/StyleConstants.java`):\n * - inhibitor arcs use `arrowhead=\"odot\"` + color `#dc3545`\n * - reset arcs use `label=\"reset\"` + color `#fd7e14`\n * - read arcs use `label=\"read\"` + color `#6c757d`\n *\n * Mirrors v3 lines 24–103.\n */\nexport function parseLibpetriDot(dot: string): GraphModel {\n const nodes = new Map<string, ParsedNode>();\n // Greedy `.*` (no /s flag) consumes the full attrs body up to the line's\n // trailing `];`. The v3 reference used `[^\\]]*` which silently dropped\n // transitions whose label contained `[…]` text (e.g., `\"[0, ∞]ms\"`); we\n // can't tolerate that here because the typed model wants every cluster\n // member to have a Node entry.\n for (const m of dot.matchAll(/^\\s*([pjt]_[A-Za-z0-9_]+)\\s*\\[(.*)\\];\\s*$/gm)) {\n const [, id, body] = m as unknown as [string, string, string];\n nodes.set(id, { id, kind: classifyKind(id), attrs: parseAttrs(body) });\n }\n\n const clusters = new Map<string, ParsedCluster>();\n const nodeToCluster = new Map<string, string>();\n for (const cm of dot.matchAll(/subgraph (cluster_\\w+)\\s*\\{([^]*?)^\\s*\\}/gm)) {\n const [, clusterId, body] = cm as unknown as [string, string, string];\n const memberIds = [...body.matchAll(/^\\s*([pjt]_[A-Za-z0-9_]+)\\s*\\[/gm)]\n .map(m => (m as unknown as [string, string])[1]);\n clusters.set(clusterId, {\n id: clusterId,\n shortName: clusterId.replace(/^cluster_/, ''),\n nodes: memberIds,\n });\n for (const n of memberIds) nodeToCluster.set(n, clusterId);\n }\n\n // Catch nodes declared at root (orphans) — strip cluster bodies, then scan\n const stripped = dot.replace(/subgraph cluster_\\w+\\s*\\{[^]*?^\\s*\\}/gm, '');\n for (const m of stripped.matchAll(/^\\s*([pjt]_[A-Za-z0-9_]+)\\s*\\[/gm)) {\n const id = (m as unknown as [string, string])[1];\n if (!nodes.has(id)) {\n // Root-declared node without full attrs (rare); seed with empty attrs.\n nodes.set(id, { id, kind: classifyKind(id), attrs: {} });\n }\n }\n\n const orphans = [...nodes.keys()].filter(n => !nodeToCluster.has(n));\n\n const edges: ParsedEdge[] = [];\n for (const m of dot.matchAll(/([pjt]_[A-Za-z0-9_]+)\\s*->\\s*([pjt]_[A-Za-z0-9_]+)\\s*(\\[[^\\]]*\\])?/g)) {\n const [, src, dst, rawAttrs] = m as unknown as [string, string, string, string | undefined];\n const attrs = rawAttrs ?? '';\n // Cluster-anchor edges (lhead/ltail) are exporter-internal routing hints,\n // not real arcs in the Petri net — skip per v3 line 97.\n if (attrs.includes('lhead=') || attrs.includes('ltail=')) continue;\n let arc: ArcType = 'normal';\n if (attrs.includes('label=\"reset\"') || attrs.includes('#fd7e14')) arc = 'reset';\n else if (attrs.includes('arrowhead=\"odot\"') || attrs.includes('#dc3545')) arc = 'inhibitor';\n else if (attrs.includes('label=\"read\"')) arc = 'read';\n // Strip the `[…]` brackets so writeBack can splice the body into a new\n // attr list. Empty if libpetri emitted a bare `src -> dst;`.\n const stripped = attrs.startsWith('[') && attrs.endsWith(']')\n ? attrs.slice(1, -1)\n : '';\n edges.push({ src, dst, arc, rawAttrs: stripped });\n }\n\n return { nodes, clusters, nodeToCluster, orphans, edges };\n}\n\n/**\n * Adopt orphan nodes into the cluster their edges most prefer.\n *\n * For each orphan, tally how many of its edges touch each cluster. If the\n * dominant cluster gets at least `threshold` of the orphan's cluster-touching\n * edges, the orphan is reassigned to that cluster.\n *\n * Mirrors v3 lines 105–136. Default threshold 0.7 matches REASSIGN_ORPHANS.\n */\nexport function foldOrphans(graph: GraphModel, threshold = 0.7): GraphModel {\n if (threshold <= 0) return graph;\n\n const nodeToCluster = new Map(graph.nodeToCluster);\n const clusterMembers = new Map<string, string[]>();\n for (const [id, c] of graph.clusters) clusterMembers.set(id, [...c.nodes]);\n\n const tally = new Map<string, Map<string, number>>();\n const bump = (orphan: string, other: string): void => {\n const oc = nodeToCluster.get(other);\n if (!oc) return;\n let t = tally.get(orphan);\n if (!t) { t = new Map(); tally.set(orphan, t); }\n t.set(oc, (t.get(oc) ?? 0) + 1);\n };\n\n for (const e of graph.edges) {\n const sIsOrphan = !nodeToCluster.has(e.src);\n const dIsOrphan = !nodeToCluster.has(e.dst);\n if (sIsOrphan && !dIsOrphan) bump(e.src, e.dst);\n if (dIsOrphan && !sIsOrphan) bump(e.dst, e.src);\n }\n\n for (const id of graph.orphans) {\n const t = tally.get(id);\n if (!t) continue;\n let total = 0;\n let bestCluster: string | null = null;\n let bestCount = 0;\n for (const [c, n] of t) {\n total += n;\n if (n > bestCount) { bestCount = n; bestCluster = c; }\n }\n if (bestCluster && total > 0 && bestCount / total >= threshold) {\n clusterMembers.get(bestCluster)!.push(id);\n nodeToCluster.set(id, bestCluster);\n }\n }\n\n const clusters = new Map<string, ParsedCluster>();\n for (const [id, c] of graph.clusters) {\n clusters.set(id, { ...c, nodes: clusterMembers.get(id)! });\n }\n const orphans = [...graph.nodes.keys()].filter(n => !nodeToCluster.has(n));\n return { ...graph, clusters, nodeToCluster, orphans };\n}\n\nexport interface ReplicateOptions {\n /**\n * Skip places that touch more than this many foreign clusters. Per the\n * plan's \"no cap\" decision, default is `Infinity`. Set to a finite value\n * to suppress replication of hub places that would otherwise produce many\n * copies.\n */\n readonly max?: number;\n /** If true, replicate transitions as well as places. Default false. */\n readonly replicateTransitions?: boolean;\n}\n\nexport interface ReplicateStats {\n readonly replicatedPlaces: number;\n readonly totalCopies: number;\n}\n\n/**\n * For each place P, replicate it into every foreign cluster touched by its\n * edges, and redirect those cross-cluster edges to the local copy.\n *\n * Replica id convention is load-bearing: `${placeId}__rep__${shortClusterName}`.\n * Downstream stages (mount-time tagging, overlay highlight, click-all-copies)\n * key off this naming and the `replica: true` / `replicaOf` markers.\n *\n * If P has a home cluster (folded earlier), the original stays as the primary\n * copy and is also marked as a replica so the ⇄ glyph renders consistently.\n * If P is an orphan with all its edges redirected, the original is dropped.\n *\n * Mirrors v3 lines 138–221.\n */\nexport function replicateShared(\n graph: GraphModel,\n opts: ReplicateOptions = {},\n): GraphModel & { readonly replicateStats: ReplicateStats } {\n const max = opts.max ?? Infinity;\n const replicateTransitions = opts.replicateTransitions ?? false;\n\n const nodes = new Map(graph.nodes);\n const nodeToCluster = new Map(graph.nodeToCluster);\n const clusterMembers = new Map<string, string[]>();\n for (const [id, c] of graph.clusters) clusterMembers.set(id, [...c.nodes]);\n const edges = graph.edges.map(e => ({ ...e }));\n\n // 1. Compute foreign-cluster set per replicable node.\n const foreignByNode = new Map<string, Set<string>>();\n const noteForeign = (nodeId: string, otherId: string): void => {\n if (!nodeId.startsWith('p_') && !(replicateTransitions && nodeId.startsWith('t_'))) return;\n const home = nodeToCluster.get(nodeId);\n const otherCluster = nodeToCluster.get(otherId);\n if (!otherCluster) return;\n if (otherCluster === home) return;\n let s = foreignByNode.get(nodeId);\n if (!s) { s = new Set(); foreignByNode.set(nodeId, s); }\n s.add(otherCluster);\n };\n for (const e of edges) {\n noteForeign(e.src, e.dst);\n noteForeign(e.dst, e.src);\n }\n\n // 2. Emit replicas for nodes within the cap.\n const replicaMap = new Map<string, Map<string, string>>(); // orig → cluster → replicaId\n let replicatedPlaces = 0;\n let totalCopies = 0;\n for (const [placeId, foreigns] of foreignByNode) {\n if (foreigns.size === 0) continue;\n if (foreigns.size > max) continue;\n const perCluster = new Map<string, string>();\n const orig = nodes.get(placeId);\n if (!orig) continue;\n for (const clusterId of foreigns) {\n const shortName = clusterId.replace(/^cluster_/, '');\n const repId = `${placeId}__rep__${shortName}`;\n perCluster.set(clusterId, repId);\n clusterMembers.get(clusterId)!.push(repId);\n nodeToCluster.set(repId, clusterId);\n nodes.set(repId, {\n id: repId,\n kind: orig.kind,\n attrs: { ...orig.attrs },\n replica: true,\n replicaOf: placeId,\n });\n totalCopies++;\n }\n replicaMap.set(placeId, perCluster);\n replicatedPlaces++;\n // Mark the original as a shared place so the ⇄ glyph renders uniformly.\n nodes.set(placeId, { ...orig, replica: true, replicaOf: placeId });\n }\n\n // 3. Redirect cross-cluster edges to the local replica on each end.\n for (const e of edges) {\n const sMap = replicaMap.get(e.src);\n const dMap = replicaMap.get(e.dst);\n if (sMap) {\n const dCl = nodeToCluster.get(e.dst);\n if (dCl && sMap.has(dCl)) e.src = sMap.get(dCl)!;\n }\n if (dMap) {\n const sCl = nodeToCluster.get(e.src);\n if (sCl && dMap.has(sCl)) e.dst = dMap.get(sCl)!;\n }\n }\n\n // 4. Drop orphan originals whose edges all got redirected away.\n for (const [origId] of replicaMap) {\n if (nodeToCluster.has(origId)) continue; // folded — keep as primary\n const stillHasEdge = edges.some(e => e.src === origId || e.dst === origId);\n if (!stillHasEdge) nodes.delete(origId);\n }\n\n const clusters = new Map<string, ParsedCluster>();\n for (const [id, c] of graph.clusters) {\n clusters.set(id, { ...c, nodes: clusterMembers.get(id)! });\n }\n const orphans = [...nodes.keys()].filter(n => !nodeToCluster.has(n));\n\n return {\n nodes,\n clusters,\n nodeToCluster,\n orphans,\n edges,\n replicateStats: { replicatedPlaces, totalCopies },\n };\n}\n","/**\n * ELK placement + DOT pin-mode rewrite.\n *\n * Stage 2 of the C0 pipeline. Takes the {@link GraphModel} produced by\n * {@link parseLibpetriDot} → {@link foldOrphans} → {@link replicateShared},\n * runs ELKjs to compute absolute `(x, y)` per node, bounding boxes per\n * cluster, and orthogonal `(x, y)` routes per edge, then emits a fresh DOT\n * string with node positions pinned via `pos=\"x,y!\"`, cluster boxes via\n * `bb=\"…\"`, and each edge's route as a `pos=\"e,…\"` spline. Downstream callers\n * render the result through `@viz-js/viz` with `engine: 'nop2'` — Graphviz\n * draws the pinned node positions AND edge routes verbatim, doing no layout or\n * routing of its own (see {@link writeBack} / {@link edgePosSpline} for why we\n * route edges ourselves rather than let Graphviz's ortho router run).\n *\n * `elkLayout` takes (graph, cfg?); `writeBack` takes (graph, layout).\n * Neither touches the original DOT text — the model after replication has\n * nodes the original DOT doesn't, so patching the original would be\n * incorrect.\n *\n * Layout is configurable via {@link ElkLayoutConfig}: the per-subnet\n * algorithm (`clusterLayout`) and whether clusters dominated by side-effect\n * leaf places pack those leaves into a grid sub-block (`leafPacking`).\n *\n * @module viewer/layout/elk-place\n */\n\nimport ELK from 'elkjs/lib/elk.bundled.js';\nimport type {\n ElkExtendedEdge,\n ElkNode,\n} from 'elkjs/lib/elk-api.js';\nimport type { ArcType, GraphModel, ParsedCluster, ParsedNode } from './preprocess.js';\n\nconst ORCHESTRATOR_CLUSTER_ID = 'cluster_orchestrator';\n\n// Visual sizing — kept proportional to the v3 reference renderer so the\n// resulting bounding box is comparable to C0-GOOD_v3.svg.\nconst PLACE_RADIUS = 22;\nconst PLACE_CHARW = 7.4;\nconst PLACE_PAD_BELOW = 16;\nconst FONT_PLACE = 13;\nconst TRANSITION_MIN_W = 180;\nconst TRANSITION_H = 40;\nconst TRANSITION_CHARW = 8.5;\nconst JUNCTION_SIZE = 28;\nconst FONT_CLUSTER = 17;\nconst ROOT_SPACING = 90;\nconst CLUSTER_SPACING = 16;\n\n/**\n * Width/height in points that ELK should reserve for a node. Mirrors\n * `nodeDims` in v3 lines 66–78 — places get extra height to leave room for\n * the xlabel underneath the circle.\n */\nfunction nodeDims(node: ParsedNode): { width: number; height: number } {\n if (node.kind === 'place') {\n const label = (node.attrs.xlabel ?? node.attrs.label ?? node.id).replace(/\\\\n/g, ' ');\n const labelWidth = label.length * PLACE_CHARW;\n const circleD = PLACE_RADIUS * 2 + 4;\n return {\n width: Math.max(circleD, labelWidth),\n height: circleD + PLACE_PAD_BELOW + FONT_PLACE,\n };\n }\n if (node.kind === 'junction') {\n return { width: JUNCTION_SIZE, height: JUNCTION_SIZE };\n }\n const label = (node.attrs.label ?? node.id).replace(/\\\\n/g, ' ');\n return {\n width: Math.max(TRANSITION_MIN_W, label.length * TRANSITION_CHARW),\n height: TRANSITION_H,\n };\n}\n\nexport interface NodePosition {\n readonly x: number;\n readonly y: number;\n readonly width: number;\n readonly height: number;\n}\n\nexport interface ClusterBox {\n readonly x: number;\n readonly y: number;\n readonly width: number;\n readonly height: number;\n}\n\nexport interface EdgePath {\n readonly start: { x: number; y: number };\n readonly end: { x: number; y: number };\n readonly bends: ReadonlyArray<{ x: number; y: number }>;\n}\n\nexport interface LayoutResult {\n readonly nodePositions: ReadonlyMap<string, NodePosition>;\n readonly clusterBoxes: ReadonlyMap<string, ClusterBox>;\n /** Keyed on `${src}->${dst}` — ELK-computed edge routes for Graphviz `nop2`. */\n readonly edgePaths: ReadonlyMap<string, EdgePath>;\n readonly totalWidth: number;\n readonly totalHeight: number;\n}\n\n// Shared edge-routing options for the layered layouts. Spacing gives parallel\n// edges their own channels (ELK's ~10pt default lets dense fan-in/out at\n// junctions and shared places collapse into one thick line) and keeps edges\n// off the nodes/labels they pass. `mergeEdges` bundles arcs that share an\n// endpoint into a common orthogonal trunk that branches at each end — so e.g.\n// a transition's many reset arcs read as one labelled bus with a tidy branch\n// up to each place, instead of a stack of nested right-angle brackets.\n// Trade-off (accepted, EXP-004): arcs sharing an endpoint run collinearly along\n// the shared trunk, so over that stretch their strokes over-paint — only the\n// endpoints (arrowheads/labels) stay per-type distinct. Kept intentionally for\n// legibility on dense fan-in/out; any added ELK layout cost is paid once per\n// unique net and amortized by the pinned-DOT cache in render.ts.\nconst LAYERED_EDGE_OPTS: Record<string, string> = {\n 'elk.spacing.edgeEdge': '18',\n 'elk.spacing.edgeNode': '18',\n 'elk.layered.spacing.edgeEdgeBetweenLayers': '16',\n 'elk.layered.spacing.edgeNodeBetweenLayers': '16',\n 'elk.layered.mergeEdges': 'true',\n};\n\nconst CLUSTER_OPTIONS: Record<string, string> = {\n 'elk.padding': `[top=${FONT_CLUSTER + 16},left=16,bottom=16,right=16]`,\n 'elk.algorithm': 'layered',\n 'elk.direction': 'DOWN',\n 'elk.spacing.nodeNode': String(CLUSTER_SPACING),\n 'elk.layered.spacing.nodeNodeBetweenLayers': String(CLUSTER_SPACING + 6),\n 'elk.edgeRouting': 'ORTHOGONAL',\n ...LAYERED_EDGE_OPTS,\n};\n\nconst ROOT_OPTIONS: Record<string, string> = {\n 'elk.algorithm': 'org.eclipse.elk.rectpacking',\n 'elk.aspectRatio': '1.4',\n 'elk.padding': '[top=24,left=24,bottom=24,right=24]',\n 'elk.spacing.nodeNode': String(ROOT_SPACING),\n};\n\nconst ORCHESTRATOR_OPTIONS: Record<string, string> = {\n ...CLUSTER_OPTIONS,\n 'elk.aspectRatio': '2.4',\n 'elk.spacing.nodeNode': '10',\n};\n\n/**\n * Layout options for the synthetic orchestrator when it IS the whole\n * diagram — the flat \"one-net\" view (no real subnet clusters).\n *\n * `ORCHESTRATOR_OPTIONS` deliberately packs the orphan block tight\n * (`nodeNode: 10`, `aspectRatio: 2.4`) so it stays compact next to the\n * real subnet blocks the `rectpacking` root arranges. When the graph is\n * flat there are no other blocks: that compaction just bunches the whole\n * net up. Flat mode instead gets a generous layered layout — a clean\n * place→transition rank flow — with no forced aspect ratio.\n */\nconst FLAT_OPTIONS: Record<string, string> = {\n 'elk.padding': `[top=24,left=24,bottom=24,right=24]`,\n 'elk.algorithm': 'layered',\n 'elk.direction': 'DOWN',\n 'elk.spacing.nodeNode': '45',\n 'elk.layered.spacing.nodeNodeBetweenLayers': '60',\n 'elk.edgeRouting': 'ORTHOGONAL',\n ...LAYERED_EDGE_OPTS,\n};\n\n/**\n * Per-subnet ELK algorithm used when {@link ElkLayoutConfig.clusterLayout}\n * is `'rectpacking'` — packs a cluster's nodes as a 2-D grid, ignoring\n * intra-cluster edges. Maximally compact, but the place→transition flow\n * reading order is lost.\n */\nconst RECTPACK_CLUSTER_OPTIONS: Record<string, string> = {\n 'elk.padding': `[top=${FONT_CLUSTER + 16},left=16,bottom=16,right=16]`,\n 'elk.algorithm': 'org.eclipse.elk.rectpacking',\n 'elk.aspectRatio': '1.3',\n 'elk.spacing.nodeNode': String(CLUSTER_SPACING),\n};\n\n// Sub-layout options for a leaf-packed cluster: the flow part keeps the\n// layered place→transition rank flow; the leaf part is a compact grid.\nconst FLOW_SUB_OPTIONS: Record<string, string> = {\n 'elk.algorithm': 'layered',\n 'elk.direction': 'DOWN',\n 'elk.spacing.nodeNode': String(CLUSTER_SPACING),\n 'elk.layered.spacing.nodeNodeBetweenLayers': String(CLUSTER_SPACING + 6),\n 'elk.edgeRouting': 'ORTHOGONAL',\n ...LAYERED_EDGE_OPTS,\n};\nconst LEAF_SUB_OPTIONS: Record<string, string> = {\n 'elk.algorithm': 'org.eclipse.elk.rectpacking',\n 'elk.aspectRatio': '1.4',\n 'elk.spacing.nodeNode': String(CLUSTER_SPACING),\n};\n/** Gap between the layered flow and the packed leaf block, in points. */\nconst LEAF_BLOCK_GAP = 40;\n/** Padding inside a leaf-packed cluster box (left/right/bottom). */\nconst SUB_PAD = 16;\n/** Top padding inside a cluster box — room for the cluster label. */\nconst SUB_PAD_TOP = FONT_CLUSTER + 16;\n\n// ======================== Layout configuration ========================\n\n/** Per-subnet ELK algorithm. */\nexport type ClusterLayout = 'layered' | 'rectpacking';\n\n/** Tuning for side-effect-leaf packing — see {@link ElkLayoutConfig}. */\nexport interface LeafPackingOptions {\n /**\n * A cluster is \"dominated\" — and its side-effect leaf places get packed\n * into a grid sub-block — when it has at least this many of them.\n * Default 10.\n */\n readonly minLeaves?: number;\n /**\n * Arc types that mark a place as a side-effect leaf (a place whose every\n * intra-cluster arc is one of these carries no data-flow ordering).\n * Default `['reset', 'read']`.\n */\n readonly arcs?: readonly ArcType[];\n}\n\n/**\n * Layout configuration for {@link elkLayout}, surfaced to viewer callers\n * via `MountOptions`.\n */\nexport interface ElkLayoutConfig {\n /** Per-subnet ELK algorithm. Default `'layered'`. */\n readonly clusterLayout?: ClusterLayout;\n /**\n * Pack side-effect leaf places into a rectpacking sub-block, in clusters\n * where they dominate. `true` (default) enables it with defaults; `false`\n * disables it; an object tunes the threshold / arc types. Only takes\n * effect when `clusterLayout` is `'layered'`.\n */\n readonly leafPacking?: boolean | LeafPackingOptions;\n}\n\ninterface ResolvedConfig {\n readonly clusterLayout: ClusterLayout;\n readonly leafPacking: {\n readonly enabled: boolean;\n readonly minLeaves: number;\n readonly arcs: ReadonlySet<ArcType>;\n };\n}\n\nconst DEFAULT_MIN_LEAVES = 10;\n\nfunction resolveConfig(cfg?: ElkLayoutConfig): ResolvedConfig {\n const lp = cfg?.leafPacking ?? true;\n const lpObj: LeafPackingOptions = typeof lp === 'object' ? lp : {};\n return {\n clusterLayout: cfg?.clusterLayout ?? 'layered',\n leafPacking: {\n enabled: lp !== false,\n minLeaves: lpObj.minLeaves ?? DEFAULT_MIN_LEAVES,\n arcs: new Set(lpObj.arcs ?? ['reset', 'read']),\n },\n };\n}\n\n/** A cluster pre-laid-out as [layered flow] stacked over [packed leaves]. */\ninterface PrebuiltCluster {\n readonly width: number;\n readonly height: number;\n /** member node id → position relative to the cluster's top-left. */\n readonly rel: ReadonlyMap<string, NodePosition>;\n}\n\n/**\n * Split a cluster's members into flow nodes and \"side-effect leaf places\".\n *\n * A side-effect leaf is a place whose every intra-cluster arc is a\n * side-effect arc (per `arcs` — reset/read). Such a place is not on any\n * data-flow path, so packing it as a grid cell loses no reading order.\n */\nfunction classifyLeaves(\n graph: GraphModel,\n cluster: ParsedCluster,\n arcs: ReadonlySet<ArcType>,\n): { flow: string[]; leaves: string[] } {\n const members = new Set(cluster.nodes);\n const intraDegree = new Map<string, number>();\n const intraSideEffect = new Map<string, number>();\n for (const e of graph.edges) {\n if (!members.has(e.src) || !members.has(e.dst)) continue;\n const sideEffect = arcs.has(e.arc) ? 1 : 0;\n for (const id of [e.src, e.dst]) {\n intraDegree.set(id, (intraDegree.get(id) ?? 0) + 1);\n intraSideEffect.set(id, (intraSideEffect.get(id) ?? 0) + sideEffect);\n }\n }\n const flow: string[] = [];\n const leaves: string[] = [];\n for (const id of cluster.nodes) {\n const node = graph.nodes.get(id);\n if (!node) continue;\n const deg = intraDegree.get(id) ?? 0;\n const isLeaf =\n node.kind === 'place' &&\n deg >= 1 &&\n (intraSideEffect.get(id) ?? 0) === deg;\n (isLeaf ? leaves : flow).push(id);\n }\n return { flow, leaves };\n}\n\n/**\n * Lay a dominated cluster out as two stacked blocks: the flow nodes via\n * `layered` (place→transition rank flow), the side-effect leaves via\n * `rectpacking` (a compact grid). Returns the cluster's overall size and\n * every member node's position relative to the cluster's top-left.\n */\nasync function layoutDominatedCluster(\n elk: InstanceType<typeof ELK>,\n graph: GraphModel,\n flow: string[],\n leaves: string[],\n): Promise<PrebuiltCluster> {\n const dimsOf = (id: string): { width: number; height: number } =>\n nodeDims(graph.nodes.get(id)!);\n\n const flowSet = new Set(flow);\n const flowEdges: ElkExtendedEdge[] = [];\n graph.edges.forEach((e, i) => {\n if (flowSet.has(e.src) && flowSet.has(e.dst)) {\n flowEdges.push({ id: `fe${i}`, sources: [e.src], targets: [e.dst] });\n }\n });\n\n const flowLayout: ElkNode = await elk.layout({\n id: '__flow',\n layoutOptions: FLOW_SUB_OPTIONS,\n children: flow.map(id => ({ id, ...dimsOf(id) })),\n edges: flowEdges,\n });\n const leafLayout: ElkNode = await elk.layout({\n id: '__leaves',\n layoutOptions: LEAF_SUB_OPTIONS,\n children: leaves.map(id => ({ id, ...dimsOf(id) })),\n edges: [],\n });\n\n const flowW = flowLayout.width ?? 0;\n const flowH = flowLayout.height ?? 0;\n const leafW = leafLayout.width ?? 0;\n const leafH = leafLayout.height ?? 0;\n const contentW = Math.max(flowW, leafW);\n const contentH = flowH + (leaves.length > 0 ? LEAF_BLOCK_GAP + leafH : 0);\n\n const rel = new Map<string, NodePosition>();\n const flowOffX = SUB_PAD + (contentW - flowW) / 2;\n for (const ch of flowLayout.children ?? []) {\n rel.set(ch.id, {\n x: flowOffX + (ch.x ?? 0),\n y: SUB_PAD_TOP + (ch.y ?? 0),\n width: ch.width ?? 0,\n height: ch.height ?? 0,\n });\n }\n const leafOffX = SUB_PAD + (contentW - leafW) / 2;\n const leafOffY = SUB_PAD_TOP + flowH + LEAF_BLOCK_GAP;\n for (const ch of leafLayout.children ?? []) {\n rel.set(ch.id, {\n x: leafOffX + (ch.x ?? 0),\n y: leafOffY + (ch.y ?? 0),\n width: ch.width ?? 0,\n height: ch.height ?? 0,\n });\n }\n\n return {\n width: contentW + 2 * SUB_PAD,\n height: contentH + SUB_PAD_TOP + SUB_PAD,\n rel,\n };\n}\n\n/**\n * Group edges by the cluster that contains both endpoints (or 'root' if\n * the edge crosses cluster boundaries).\n *\n * Orphans count as living in `cluster_orchestrator` for routing purposes,\n * matching v3's `ownerOf` (line 223).\n */\nfunction partitionEdges(graph: GraphModel): {\n byCluster: Map<string, ElkExtendedEdge[]>;\n cross: ElkExtendedEdge[];\n /** edgeId → \"src->dst\" so the layout walk can recover the original key. */\n edgeIdToKey: Map<string, string>;\n} {\n const byCluster = new Map<string, ElkExtendedEdge[]>();\n const cross: ElkExtendedEdge[] = [];\n const edgeIdToKey = new Map<string, string>();\n const ownerOf = (id: string): string =>\n graph.nodeToCluster.get(id) ?? ORCHESTRATOR_CLUSTER_ID;\n\n graph.edges.forEach((e, i) => {\n const so = ownerOf(e.src);\n const dt = ownerOf(e.dst);\n const id = `e${i}`;\n edgeIdToKey.set(id, `${e.src}->${e.dst}`);\n const elkEdge: ElkExtendedEdge = {\n id,\n sources: [e.src],\n targets: [e.dst],\n };\n if (so === dt) {\n let list = byCluster.get(so);\n if (!list) { list = []; byCluster.set(so, list); }\n list.push(elkEdge);\n } else {\n cross.push(elkEdge);\n }\n });\n return { byCluster, cross, edgeIdToKey };\n}\n\n/**\n * Run ELK layout against the C0 graph and return absolute positions.\n *\n * Orphan nodes are wrapped in a synthetic `cluster_orchestrator` so ELK\n * lays them out as a single block alongside the real subnets, which the\n * `rectpacking` root algorithm then packs.\n *\n * With the default config a cluster dominated by side-effect leaf places\n * (≥ `leafPacking.minLeaves` of them) is pre-laid-out as a layered flow\n * stacked over a packed grid of those leaves — so a transition with many\n * reset arcs no longer strings its leaves into one wide row. See\n * {@link ElkLayoutConfig}.\n */\nexport async function elkLayout(\n graph: GraphModel,\n cfg?: ElkLayoutConfig,\n): Promise<LayoutResult> {\n const config = resolveConfig(cfg);\n const { byCluster, cross, edgeIdToKey } = partitionEdges(graph);\n const elk = new ELK();\n const clusterOptions =\n config.clusterLayout === 'rectpacking' ? RECTPACK_CLUSTER_OPTIONS : CLUSTER_OPTIONS;\n\n // Pre-lay-out clusters dominated by side-effect leaf places. Only in\n // 'layered' mode — 'rectpacking' already packs every cluster's nodes.\n const prebuilt = new Map<string, PrebuiltCluster>();\n if (config.clusterLayout === 'layered' && config.leafPacking.enabled) {\n for (const [clusterId, cluster] of graph.clusters) {\n const { flow, leaves } = classifyLeaves(graph, cluster, config.leafPacking.arcs);\n if (leaves.length >= config.leafPacking.minLeaves && flow.length > 0) {\n prebuilt.set(clusterId, await layoutDominatedCluster(elk, graph, flow, leaves));\n }\n }\n }\n\n const elkChildren: ElkNode[] = [];\n for (const [clusterId, cluster] of graph.clusters) {\n const pre = prebuilt.get(clusterId);\n if (pre) {\n // Childless fixed-size box — ELK's root packer places it; the member\n // node positions are spliced back in during the walk.\n elkChildren.push({ id: clusterId, width: pre.width, height: pre.height });\n continue;\n }\n elkChildren.push({\n id: clusterId,\n layoutOptions: clusterOptions,\n children: cluster.nodes\n .map(id => graph.nodes.get(id))\n .filter((n): n is ParsedNode => n !== undefined)\n .map(n => ({ id: n.id, ...nodeDims(n) })),\n edges: byCluster.get(clusterId) ?? [],\n });\n }\n // Synthetic orchestrator cluster holds the remaining orphans. When there\n // are no real clusters the orchestrator IS the whole diagram (flat view),\n // so it gets a generous full layered layout instead of the compact block\n // packing tuned for sitting beside real subnets.\n const orchestratorOptions =\n graph.clusters.size === 0\n ? FLAT_OPTIONS\n : config.clusterLayout === 'rectpacking'\n ? RECTPACK_CLUSTER_OPTIONS\n : ORCHESTRATOR_OPTIONS;\n elkChildren.push({\n id: ORCHESTRATOR_CLUSTER_ID,\n layoutOptions: orchestratorOptions,\n children: graph.orphans\n .map(id => graph.nodes.get(id))\n .filter((n): n is ParsedNode => n !== undefined)\n .map(n => ({ id: n.id, ...nodeDims(n) })),\n edges: byCluster.get(ORCHESTRATOR_CLUSTER_ID) ?? [],\n });\n\n const rootGraph: ElkNode = {\n id: 'root',\n layoutOptions: ROOT_OPTIONS,\n children: elkChildren,\n // Cross-cluster edges feed `edgePaths` (the routes nop2 draws), but\n // `rectpacking` never routes them, so they fall back to the L-corner in\n // `edgePosSpline`. Drop them when any cluster is a childless prebuilt box —\n // the edges reference member nodes ELK can no longer resolve in the hierarchy.\n edges: prebuilt.size > 0 ? [] : cross,\n };\n const layout: ElkNode = await elk.layout(rootGraph);\n\n const nodePositions = new Map<string, NodePosition>();\n const clusterBoxes = new Map<string, ClusterBox>();\n const edgePaths = new Map<string, EdgePath>();\n\n const walk = (node: ElkNode, parentX: number, parentY: number): void => {\n const ax = parentX + (node.x ?? 0);\n const ay = parentY + (node.y ?? 0);\n const pre = node.id !== 'root' ? prebuilt.get(node.id) : undefined;\n const isCluster =\n node.id !== 'root' && ((node.children?.length ?? 0) > 0 || pre !== undefined);\n if (isCluster) {\n clusterBoxes.set(node.id, {\n x: ax, y: ay,\n width: node.width ?? 0,\n height: node.height ?? 0,\n });\n // Prebuilt cluster: splice in the pre-computed member positions,\n // offset by the cluster's ELK-assigned absolute origin.\n if (pre) {\n for (const [memberId, r] of pre.rel) {\n nodePositions.set(memberId, {\n x: ax + r.x, y: ay + r.y, width: r.width, height: r.height,\n });\n }\n }\n }\n if (node.id !== 'root' && !isCluster) {\n nodePositions.set(node.id, {\n x: ax, y: ay,\n width: node.width ?? 0,\n height: node.height ?? 0,\n });\n }\n // Edges inside this node — their section coords are in the parent's\n // coordinate frame, so the offset to absolutize is (parentX, parentY)\n // for root edges, or (ax, ay) for cluster-internal edges.\n const edgeOffsetX = node.id === 'root' ? parentX : ax;\n const edgeOffsetY = node.id === 'root' ? parentY : ay;\n for (const edge of node.edges ?? []) {\n const key = edge.id ? edgeIdToKey.get(edge.id) : undefined;\n const section = edge.sections?.[0];\n if (!key || !section) continue;\n edgePaths.set(key, {\n start: {\n x: edgeOffsetX + section.startPoint.x,\n y: edgeOffsetY + section.startPoint.y,\n },\n end: {\n x: edgeOffsetX + section.endPoint.x,\n y: edgeOffsetY + section.endPoint.y,\n },\n bends: (section.bendPoints ?? []).map(p => ({\n x: edgeOffsetX + p.x,\n y: edgeOffsetY + p.y,\n })),\n });\n }\n for (const child of node.children ?? []) walk(child, ax, ay);\n };\n walk(layout, 0, 0);\n\n return {\n nodePositions,\n clusterBoxes,\n edgePaths,\n totalWidth: layout.width ?? 0,\n totalHeight: layout.height ?? 0,\n };\n}\n\n/**\n * Escape an attribute value for inclusion in a DOT string literal.\n *\n * Quotes are doubled (per the DOT escape convention `\\\"`).\n */\nfunction quote(value: string): string {\n return `\"${value.replace(/\\\\/g, '\\\\\\\\').replace(/\"/g, '\\\\\"')}\"`;\n}\n\n// ======================== Orthogonal edge routing ========================\n//\n// We render the pinned graph with Graphviz engine `nop2`, which draws edges\n// from the `pos=` spline we supply verbatim (no routing). We supply ELK's own\n// orthogonal route for each edge. This deliberately avoids Graphviz's `ortho`\n// spline router, which is unusable here: its maze/trapezoid allocator (see\n// `mkMaze`, `trapezoid.c`) requests a large block that the @viz-js/viz wasm\n// heap denies past ~220 node obstacles, and Graphviz does not check the failed\n// allocation, so the next write traps the wasm (\"memory access out of\n// bounds\"). Native Graphviz has the heap headroom and never trips it, but the\n// wasm build does — so on the big Marvin nets `splines=ortho` hard-crashes.\n// Drawing ELK's routes ourselves sidesteps that router entirely and cannot\n// crash, on a net of any size.\n\n/** Length of the drawn arrowhead, in points (Graphviz default ≈ 10). */\nconst ARROW_LEN = 10;\n\n/**\n * Inches → drawn *half*-extent in points (72 dpi ÷ 2). Libpetri's `width`/\n * `height` attrs are inches; a node's drawn radius / box half-side is\n * `inches * HALF_PT_PER_IN`.\n */\nconst HALF_PT_PER_IN = 36;\n\ninterface Pt {\n readonly x: number;\n readonly y: number;\n}\n\n/** Visual node center — Graphviz draws the shape centered on the pinned pos. */\nfunction drawnCenter(pos: NodePosition): Pt {\n return { x: pos.x + pos.width / 2, y: pos.y + pos.height / 2 };\n}\n\ninterface Extent {\n readonly shape: 'circle' | 'diamond' | 'box';\n readonly rx: number;\n readonly ry: number;\n}\n\n/**\n * Half-extents of a node's *drawn* shape (not ELK's layout-reserved box).\n * The drawn shape comes from libpetri's own `width`/`height` attrs\n * (inches → points): circles/diamonds are fixed-size, while a transition box\n * grows to its label, so its half-width is estimated from the label length.\n */\nfunction visualExtent(node: ParsedNode): Extent {\n const wIn = parseFloat(node.attrs.width ?? '');\n const hIn = parseFloat(node.attrs.height ?? '');\n const shape = node.attrs.shape ?? '';\n // Fallbacks are the libpetri StyleConstants defaults in drawn half-points:\n // place/end 0.35in, junction 0.3in, transition box 0.8×0.4in.\n if (shape === 'circle' || shape === 'doublecircle') {\n const r =\n (Number.isFinite(wIn) ? wIn * HALF_PT_PER_IN : 0.35 * HALF_PT_PER_IN) +\n (shape === 'doublecircle' ? 4 : 0); // +4pt for the outer end-place ring\n return { shape: 'circle', rx: r, ry: r };\n }\n if (shape === 'diamond') {\n // Junctions are squares-on-point; approachEndpoint clips to the diamond's\n // bounding box, so an arrowhead entering near a tip can float a few points\n // off the slanted face — cosmetic on 0.3in junctions.\n return {\n shape: 'diamond',\n rx: Number.isFinite(wIn) ? wIn * HALF_PT_PER_IN : 0.3 * HALF_PT_PER_IN,\n ry: Number.isFinite(hIn) ? hIn * HALF_PT_PER_IN : 0.3 * HALF_PT_PER_IN,\n };\n }\n // Box (transition): height is reliable; width grows to the label, so estimate\n // from the label length (~6pt/char + 16pt pad) and floor by the attr width.\n const label = (node.attrs.label ?? '').replace(/\\\\n/g, ' ');\n const estHalfW = (label.length * 6 + 16) / 2;\n return {\n shape: 'box',\n rx: Math.max(Number.isFinite(wIn) ? wIn * HALF_PT_PER_IN : 0.8 * HALF_PT_PER_IN, estHalfW),\n ry: Number.isFinite(hIn) ? hIn * HALF_PT_PER_IN : 0.4 * HALF_PT_PER_IN,\n };\n}\n\ninterface Approach {\n /** Point ON the visual node boundary where the edge meets the shape. */\n readonly entry: Pt;\n /** Optional pre-entry corner that keeps the connector a right angle. */\n readonly jog?: Pt;\n}\n\n/**\n * Where an edge should meet a node's *visual* boundary, given ELK's route\n * point on the node's layout box (`boxEnd`, larger than the drawn shape) and\n * the adjacent route point (`neighbor`). Keeps the approach axis-aligned.\n *\n * When the approach would land within the shape's span it clips straight onto\n * the boundary (preserving ELK's fan-out across a wide box). When it would\n * MISS the shape — e.g. fan-in to a place whose label-padded box is far wider\n * than its little circle, so ELK enters at an x beyond the circle radius — it\n * funnels to the near-side centre of the shape and returns a `jog` so the\n * connector turns at a right angle instead of leaving the arrowhead floating\n * beside the node.\n */\nfunction approachEndpoint(center: Pt, ext: Extent, boxEnd: Pt, neighbor: Pt): Approach {\n const vertical = Math.abs(neighbor.x - boxEnd.x) <= Math.abs(neighbor.y - boxEnd.y);\n if (vertical) {\n const sgn = neighbor.y < center.y ? -1 : 1; // meet the top (−) or bottom (+)\n const off = Math.abs(boxEnd.x - center.x);\n const reach = ext.shape === 'circle' ? ext.rx - 1 : ext.rx;\n if (off < reach) {\n const dy = ext.shape === 'circle' ? Math.sqrt(ext.rx * ext.rx - off * off) : ext.ry;\n return { entry: { x: boxEnd.x, y: center.y + sgn * dy } };\n }\n return { entry: { x: center.x, y: center.y + sgn * ext.ry }, jog: { x: center.x, y: neighbor.y } };\n }\n const sgn = neighbor.x < center.x ? -1 : 1; // meet the left (−) or right (+)\n const off = Math.abs(boxEnd.y - center.y);\n const reach = ext.shape === 'circle' ? ext.rx - 1 : ext.ry;\n if (off < reach) {\n const dx = ext.shape === 'circle' ? Math.sqrt(ext.rx * ext.rx - off * off) : ext.rx;\n return { entry: { x: center.x + sgn * dx, y: boxEnd.y } };\n }\n return { entry: { x: center.x + sgn * ext.rx, y: center.y }, jog: { x: neighbor.x, y: center.y } };\n}\n\n/** Format a point as Graphviz `x,y` with 2-decimal precision. */\nconst fmtPt = (p: Pt): string => `${p.x.toFixed(2)},${p.y.toFixed(2)}`;\nconst lerp = (a: Pt, b: Pt, t: number): Pt => ({ x: a.x + (b.x - a.x) * t, y: a.y + (b.y - a.y) * t });\n\n/**\n * Build a Graphviz edge `pos` spline that draws ELK's orthogonal route as\n * straight segments, clipped to the visual node boundaries so arrowheads land\n * on the shape edge. Format: `e,<tip> <start> <c1> <c2> <anchor> …` where the\n * control-point triples are collinear (so each cubic renders as a line).\n *\n * Cross-cluster and leaf-packed edges have no ELK route (rectpacking and\n * prebuilt boxes don't route them), so they fall back to a straight L-corner\n * between node centers — which may cross intervening nodes. That is the\n * accepted price of right-angle edges at any net size.\n *\n * Returns null when either endpoint has no laid-out position.\n */\nfunction edgePosSpline(\n graph: GraphModel,\n layout: LayoutResult,\n src: string,\n dst: string,\n): string | null {\n const srcPos = layout.nodePositions.get(src);\n const dstPos = layout.nodePositions.get(dst);\n const srcNode = graph.nodes.get(src);\n const dstNode = graph.nodes.get(dst);\n if (!srcPos || !dstPos || !srcNode || !dstNode) return null;\n\n const sc = drawnCenter(srcPos);\n const tc = drawnCenter(dstPos);\n const route = layout.edgePaths.get(`${src}->${dst}`);\n // Full orthogonal polyline. ELK's own route when available (its right-angle\n // bends AND its box-border anchor points); otherwise an L-corner between the\n // drawn centers (vertical-then-horizontal) so the edge still turns square.\n let raw: Pt[];\n if (route) {\n raw = [route.start, ...route.bends, route.end];\n } else if (sc.x === tc.x || sc.y === tc.y) {\n raw = [sc, tc];\n } else {\n raw = [sc, { x: sc.x, y: tc.y }, tc];\n }\n if (raw.length < 2) return null;\n\n const extS = visualExtent(srcNode);\n const extT = visualExtent(dstNode);\n // Land both ends on the visual shape boundary (with a right-angle jog when\n // ELK's approach would otherwise miss a small shape — see approachEndpoint).\n const startA = approachEndpoint(sc, extS, raw[0]!, raw[1]!);\n const endA = approachEndpoint(tc, extT, raw[raw.length - 1]!, raw[raw.length - 2]!);\n\n // Drawn polyline: source boundary → (jog) → ELK bends → (jog) → target\n // boundary, dropping any zero-length steps so segments stay clean.\n const poly: Pt[] = [];\n const push = (p: Pt): void => {\n const last = poly[poly.length - 1];\n if (!last || last.x !== p.x || last.y !== p.y) poly.push(p);\n };\n push(startA.entry);\n if (startA.jog) push(startA.jog);\n for (const p of raw.slice(1, -1)) push(p);\n if (endA.jog) push(endA.jog);\n push(endA.entry);\n if (poly.length < 2) return null;\n\n // Safety net: force every segment axis-aligned. A few ELK routes come back\n // as a single diagonal 2-point segment; insert a corner where needed,\n // oriented so the segment entering the target keeps its approach axis.\n const ortho: Pt[] = [poly[0]!];\n for (let i = 1; i < poly.length; i++) {\n const a = ortho[ortho.length - 1]!;\n const b = poly[i]!;\n if (Math.abs(b.x - a.x) > 1 && Math.abs(b.y - a.y) > 1) {\n ortho.push(i === poly.length - 1 ? { x: b.x, y: a.y } : { x: a.x, y: b.y });\n }\n ortho.push(b);\n }\n\n const tip = ortho[ortho.length - 1]!;\n const prev = ortho[ortho.length - 2]!;\n // Pull the drawn line back from the tip by one arrowhead length, along the\n // (axis-aligned) approach, so Graphviz draws the arrow in that gap.\n const ax = prev.x - tip.x;\n const ay = prev.y - tip.y;\n const al = Math.hypot(ax, ay) || 1;\n // Clamp the pull-back to the final segment so the arrow base never overshoots\n // past `prev` and doubles the drawn line back on itself. Short final stubs\n // (< ARROW_LEN) are realistic here — a mergeEdges branch stub or the corner an\n // approachEndpoint jog lands next to the last ELK bend can both be tiny.\n const pull = Math.min(ARROW_LEN, al);\n const arrowBase: Pt = { x: tip.x + (ax / al) * pull, y: tip.y + (ay / al) * pull };\n\n const anchors: Pt[] = [...ortho.slice(0, -1), arrowBase];\n let spline = fmtPt(anchors[0]!);\n for (let i = 1; i < anchors.length; i++) {\n const a = anchors[i - 1]!;\n const b = anchors[i]!;\n spline += ` ${fmtPt(lerp(a, b, 1 / 3))} ${fmtPt(lerp(a, b, 2 / 3))} ${fmtPt(b)}`;\n }\n return `e,${fmtPt(tip)} ${spline}`;\n}\n\n/**\n * Render a node's attribute list — preserving the parsed attrs (including\n * libpetri's `width`/`height`, which are the *visual* shape dimensions)\n * and adding the ELK-computed `pos` so Graphviz `nop2` can pin it.\n *\n * The `pos=\"x,y!\"` form (with trailing `!`) is the neato pin-mode marker.\n * Do NOT emit ELK's layout-reserved width/height to Graphviz — those are\n * the bounding boxes needed for ELK packing (which account for xlabel\n * spillover), not the visible shape sizes. libpetri's standard styles use\n * `width=0.35` for places (25pt circles); overriding with ELK's\n * ~3 inch label-padded box made Graphviz render 114pt-radius circles.\n */\nfunction nodeAttrLine(node: ParsedNode, pos: NodePosition): string {\n const attrs: string[] = [];\n // Center the pinned position on the node's bbox (ELK gives the top-left).\n const c = drawnCenter(pos);\n attrs.push(`pos=${quote(`${c.x.toFixed(2)},${c.y.toFixed(2)}!`)}`);\n for (const [k, v] of Object.entries(node.attrs)) {\n if (k === 'pos') continue;\n attrs.push(`${k}=${quote(v)}`);\n }\n return `${node.id} [${attrs.join(', ')}];`;\n}\n\nfunction edgeAttrLine(\n graph: GraphModel,\n layout: LayoutResult,\n src: string,\n dst: string,\n rawAttrs: string,\n): string {\n // Splice libpetri's original attrs verbatim so style/penwidth/label/color/\n // arrowhead match `DotExporter` 1:1, then add ELK's orthogonal route as a\n // `pos=` spline for Graphviz `nop2` to draw. See `edgePosSpline` for why we\n // route ourselves rather than use Graphviz's (wasm-crashing) ortho router.\n const pos = edgePosSpline(graph, layout, src, dst);\n const parts = [rawAttrs.trim(), pos ? `pos=\"${pos}\"` : ''].filter(Boolean);\n const body = parts.join(', ');\n return `${src} -> ${dst}` + (body ? ` [${body}];` : ';');\n}\n\n/**\n * Emit a Graphviz DOT string with node positions AND edge routes pinned.\n * Render the result with `@viz-js/viz` using:\n *\n * ```ts\n * viz.renderSVGElement(dot, {\n * engine: 'nop2',\n * yInvert: true,\n * });\n * ```\n *\n * `engine: 'nop2'` honours the pinned `pos=` on every node AND the `pos=`\n * spline on every edge, drawing both verbatim with no layout or routing. We\n * supply ELK's own orthogonal edge routes (clipped to the visual node\n * boundary for correct arrowheads — see {@link edgePosSpline}). This replaces\n * the former `nop`/`nop1` mode, where Graphviz routed edges itself: that gave\n * curved (not right-angle) edges, and switching it to `splines=ortho` crashed\n * the wasm on large nets (Graphviz's ortho maze allocator overruns the wasm\n * heap). Routing ourselves gives right angles on a net of any size, no crash.\n *\n * `yInvert: true` matches ELK's Y-down convention to Graphviz's Y-up.\n */\nexport function writeBack(graph: GraphModel, layout: LayoutResult): string {\n const lines: string[] = [];\n lines.push('digraph LibpetriPinned {');\n lines.push(' rankdir=TB;');\n lines.push(' overlap=\"false\";');\n lines.push(' compound=\"true\";');\n lines.push(' fontname=\"Helvetica,Arial,sans-serif\";');\n lines.push(' outputorder=\"edgesfirst\";');\n lines.push(' node [fontname=\"Helvetica,Arial,sans-serif\", fontsize=10];');\n lines.push(' edge [fontname=\"Helvetica,Arial,sans-serif\", fontsize=9];');\n\n // Clusters with their pinned bounding boxes\n for (const [clusterId, cluster] of graph.clusters) {\n const box = layout.clusterBoxes.get(clusterId);\n lines.push(` subgraph ${clusterId} {`);\n lines.push(` label=${quote(cluster.shortName)};`);\n lines.push(` style=\"rounded,dashed\";`);\n lines.push(` bgcolor=\"#FAFAFA\";`);\n lines.push(` penwidth=1.5;`);\n if (box) {\n const x1 = box.x.toFixed(2);\n const y1 = box.y.toFixed(2);\n const x2 = (box.x + box.width).toFixed(2);\n const y2 = (box.y + box.height).toFixed(2);\n lines.push(` bb=${quote(`${x1},${y1},${x2},${y2}`)};`);\n }\n for (const nodeId of cluster.nodes) {\n const node = graph.nodes.get(nodeId);\n const pos = layout.nodePositions.get(nodeId);\n if (!node || !pos) continue;\n lines.push(' ' + nodeAttrLine(node, pos));\n }\n lines.push(' }');\n }\n\n // Orphans (root-level nodes) — laid out inside the synthetic\n // orchestrator cluster but emitted at root so they sit alongside the\n // real subnets without their own labelled box.\n for (const orphanId of graph.orphans) {\n const node = graph.nodes.get(orphanId);\n const pos = layout.nodePositions.get(orphanId);\n if (!node || !pos) continue;\n lines.push(' ' + nodeAttrLine(node, pos));\n }\n\n // Edges — libpetri's original styling attrs plus ELK's orthogonal route as\n // a `pos=` spline, drawn verbatim by Graphviz `nop2`.\n for (const edge of graph.edges) {\n lines.push(' ' + edgeAttrLine(graph, layout, edge.src, edge.dst, edge.rawAttrs));\n }\n\n lines.push('}');\n return lines.join('\\n');\n}\n"],"mappings":";AAkBA,SAAS,YAAY,mBAAmB;;;ACgDxC,SAAS,aAAa,IAAsB;AAC1C,MAAI,GAAG,WAAW,IAAI,EAAG,QAAO;AAChC,MAAI,GAAG,WAAW,IAAI,EAAG,QAAO;AAChC,SAAO;AACT;AAQA,SAAS,WAAW,MAAsC;AACxD,QAAM,QAAgC,CAAC;AACvC,aAAW,KAAK,KAAK,SAAS,0CAA0C,GAAG;AACzE,UAAM,CAAC,EAAE,KAAK,GAAG,IAAI;AACrB,UAAM,IAAI,IAAI,WAAW,GAAG,KAAK,IAAI,SAAS,GAAG,IAAI,IAAI,MAAM,GAAG,EAAE,IAAI;AACxE,UAAM,GAAG,IAAI;AAAA,EACf;AACA,SAAO;AACT;AAaO,SAAS,iBAAiB,KAAyB;AACxD,QAAM,QAAQ,oBAAI,IAAwB;AAM1C,aAAW,KAAK,IAAI,SAAS,6CAA6C,GAAG;AAC3E,UAAM,CA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