schematex 0.6.1 → 0.6.2
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/ai/ai-sdk.cjs +11 -11
- package/dist/ai/ai-sdk.d.cts +3 -3
- package/dist/ai/ai-sdk.d.ts +3 -3
- package/dist/ai/ai-sdk.js +6 -6
- package/dist/ai/index.cjs +17 -17
- package/dist/ai/index.d.cts +3 -3
- package/dist/ai/index.d.ts +3 -3
- package/dist/ai/index.js +6 -6
- package/dist/{api-DFrSR3lw.d.ts → api-XWHHAhQI.d.ts} +1 -1
- package/dist/{api-BEJTXyBA.d.cts → api-qVDutqXH.d.cts} +1 -1
- package/dist/browser.cjs +12 -12
- package/dist/browser.d.cts +3 -3
- package/dist/browser.d.ts +3 -3
- package/dist/browser.js +6 -6
- package/dist/{chunk-ST5YRTTV.cjs → chunk-2F45Y2ON.cjs} +44 -5
- package/dist/chunk-2F45Y2ON.cjs.map +1 -0
- package/dist/{chunk-V4RO5KYY.cjs → chunk-3JAI3OVG.cjs} +81 -47
- package/dist/chunk-3JAI3OVG.cjs.map +1 -0
- package/dist/{chunk-R6VX5YTJ.cjs → chunk-ECD5XHBM.cjs} +2 -2
- package/dist/{chunk-R6VX5YTJ.cjs.map → chunk-ECD5XHBM.cjs.map} +1 -1
- package/dist/{chunk-MFAMNFPA.js → chunk-EPKIJEH7.js} +6 -63
- package/dist/chunk-EPKIJEH7.js.map +1 -0
- package/dist/{chunk-OTSVMKII.js → chunk-ITUPR7G5.js} +150 -48
- package/dist/chunk-ITUPR7G5.js.map +1 -0
- package/dist/{chunk-I2GQYOZ5.js → chunk-IZWKJVIC.js} +147 -107
- package/dist/chunk-IZWKJVIC.js.map +1 -0
- package/dist/{chunk-UWA5MWCI.js → chunk-JVAJ6ZLO.js} +81 -47
- package/dist/chunk-JVAJ6ZLO.js.map +1 -0
- package/dist/{chunk-4XR7X7XW.cjs → chunk-KSNUMQGS.cjs} +151 -111
- package/dist/chunk-KSNUMQGS.cjs.map +1 -0
- package/dist/{chunk-522WB2EH.js → chunk-LGABFD3L.js} +2 -2
- package/dist/{chunk-522WB2EH.js.map → chunk-LGABFD3L.js.map} +1 -1
- package/dist/{chunk-6URNSB6G.js → chunk-P26FCZP3.js} +44 -5
- package/dist/chunk-P26FCZP3.js.map +1 -0
- package/dist/{chunk-SSLNPHCL.cjs → chunk-SD6VDTQR.cjs} +152 -50
- package/dist/chunk-SD6VDTQR.cjs.map +1 -0
- package/dist/{chunk-XNCOSVNG.cjs → chunk-SUIDD2C5.cjs} +6 -63
- package/dist/chunk-SUIDD2C5.cjs.map +1 -0
- package/dist/{diagnostics-B-ffSEhl.d.ts → diagnostics-DRxhodP6.d.cts} +0 -8
- package/dist/{diagnostics-B-ffSEhl.d.cts → diagnostics-DRxhodP6.d.ts} +0 -8
- package/dist/diagrams/blockdiagram/index.cjs +5 -5
- package/dist/diagrams/blockdiagram/index.d.cts +1 -1
- package/dist/diagrams/blockdiagram/index.d.ts +1 -1
- package/dist/diagrams/blockdiagram/index.js +1 -1
- package/dist/diagrams/circuit/index.cjs +7 -7
- package/dist/diagrams/circuit/index.d.cts +1 -1
- package/dist/diagrams/circuit/index.d.ts +1 -1
- package/dist/diagrams/circuit/index.js +1 -1
- package/dist/diagrams/ecomap/index.d.cts +1 -1
- package/dist/diagrams/ecomap/index.d.ts +1 -1
- package/dist/diagrams/entity/index.d.cts +1 -1
- package/dist/diagrams/entity/index.d.ts +1 -1
- package/dist/diagrams/fishbone/index.d.cts +1 -1
- package/dist/diagrams/fishbone/index.d.ts +1 -1
- package/dist/diagrams/flowchart/index.d.cts +2 -2
- package/dist/diagrams/flowchart/index.d.ts +2 -2
- package/dist/diagrams/genogram/index.d.cts +1 -1
- package/dist/diagrams/genogram/index.d.ts +1 -1
- package/dist/diagrams/ladder/index.d.cts +1 -1
- package/dist/diagrams/ladder/index.d.ts +1 -1
- package/dist/diagrams/logic/index.d.cts +1 -1
- package/dist/diagrams/logic/index.d.ts +1 -1
- package/dist/diagrams/orgchart/index.d.cts +1 -1
- package/dist/diagrams/orgchart/index.d.ts +1 -1
- package/dist/diagrams/pedigree/index.d.cts +1 -1
- package/dist/diagrams/pedigree/index.d.ts +1 -1
- package/dist/diagrams/phylo/index.d.cts +1 -1
- package/dist/diagrams/phylo/index.d.ts +1 -1
- package/dist/diagrams/sld/index.cjs +7 -7
- package/dist/diagrams/sld/index.d.cts +1 -1
- package/dist/diagrams/sld/index.d.ts +1 -1
- package/dist/diagrams/sld/index.js +1 -1
- package/dist/diagrams/sociogram/index.d.cts +1 -1
- package/dist/diagrams/sociogram/index.d.ts +1 -1
- package/dist/diagrams/timing/index.cjs +4 -4
- package/dist/diagrams/timing/index.d.cts +1 -1
- package/dist/diagrams/timing/index.d.ts +1 -1
- package/dist/diagrams/timing/index.js +1 -1
- package/dist/diagrams/venn/index.d.cts +1 -1
- package/dist/diagrams/venn/index.d.ts +1 -1
- package/dist/{index-S0njakQ2.d.cts → index-BRIkOPnd.d.cts} +1 -1
- package/dist/{index-DPWdYfNx.d.ts → index-C7SN-FB3.d.ts} +1 -1
- package/dist/index.cjs +32 -32
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +8 -8
- package/dist/react.cjs +6 -6
- package/dist/react.d.cts +2 -2
- package/dist/react.d.ts +2 -2
- package/dist/react.js +5 -5
- package/dist/{tools-kK_enDwb.d.ts → tools-BVeUNdsU.d.ts} +2 -2
- package/dist/{tools-CeGGMCs7.d.cts → tools-DdhP1kWY.d.cts} +2 -2
- package/package.json +1 -1
- package/dist/chunk-4XR7X7XW.cjs.map +0 -1
- package/dist/chunk-6URNSB6G.js.map +0 -1
- package/dist/chunk-I2GQYOZ5.js.map +0 -1
- package/dist/chunk-MFAMNFPA.js.map +0 -1
- package/dist/chunk-OTSVMKII.js.map +0 -1
- package/dist/chunk-SSLNPHCL.cjs.map +0 -1
- package/dist/chunk-ST5YRTTV.cjs.map +0 -1
- package/dist/chunk-UWA5MWCI.js.map +0 -1
- package/dist/chunk-V4RO5KYY.cjs.map +0 -1
- package/dist/chunk-XNCOSVNG.cjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/diagrams/sld/parser.ts","../src/core/types.ts","../src/diagrams/sld/symbols.ts","../src/diagrams/sld/layout.ts","../src/diagrams/sld/renderer.ts","../src/diagrams/sld/lint.ts","../src/diagrams/sld/index.ts"],"names":["line","text","title","matchQuotedTitle","didYouMean","group","el","path","maxX","lines","resolveIndustrialTheme","desc","defs","svgRoot","firstContentLine"],"mappings":";;;;;;;;;AAUO,IAAM,aAAA,GAAN,cAA4B,KAAA,CAAM;AAAA,EAChC,IAAA;AAAA,EACA,MAAA;AAAA,EACP,WAAA,CAAY,OAAA,EAAiBA,KAAAA,EAAe,MAAA,EAAiB;AAC3D,IAAA,KAAA,CAAMA,UAAS,MAAA,GAAY,CAAA,KAAA,EAAQA,KAAI,CAAA,EAAA,EAAK,OAAO,KAAK,OAAO,CAAA;AAC/D,IAAA,IAAA,CAAK,IAAA,GAAO,eAAA;AACZ,IAAA,IAAA,CAAK,IAAA,GAAOA,KAAAA;AACZ,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AAAA,EAChB;AACF,CAAA;AAEA,IAAM,UAAA,uBAAiB,GAAA,CAAiB;AAAA,EACtC,SAAA;AAAA,EAAW,WAAA;AAAA,EAAa,OAAA;AAAA,EAAS,MAAA;AAAA,EAAQ,KAAA;AAAA,EACzC,aAAA;AAAA,EAAe,gBAAA;AAAA,EAAkB,gBAAA;AAAA,EAAkB,gBAAA;AAAA,EACnD,gBAAA;AAAA,EAAkB,iBAAA;AAAA,EAAmB,sBAAA;AAAA,EACrC,KAAA;AAAA,EAAO,SAAA;AAAA,EAAW,KAAA;AAAA,EAClB,SAAA;AAAA,EAAW,gBAAA;AAAA,EAAkB,QAAA;AAAA,EAAU,aAAA;AAAA,EAAe,eAAA;AAAA,EACtD,KAAA;AAAA,EAAO,U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AU,KAAK,MAAM,CAAA;AAAA,EAC9B;AACF","file":"chunk-R6VX5YTJ.cjs","sourcesContent":["import type {\n SLDAST,\n SLDNode,\n SLDNodeType,\n SLDConnection,\n SLDStandard,\n} from \"../../core/types\";\nimport { matchQuotedTitle } from \"../../core/quotes\";\nimport { didYouMean } from \"../../core/dsl-suggest\";\n\nexport class SLDParseError extends Error {\n public line?: number;\n public source?: string;\n constructor(message: string, line?: number, source?: string) {\n super(line !== undefined ? `Line ${line}: ${message}` : message);\n this.name = \"SLDParseError\";\n this.line = line;\n this.source = source;\n }\n}\n\nconst NODE_TYPES = new Set<SLDNodeType>([\n \"utility\", \"generator\", \"solar\", \"wind\", \"ups\",\n \"transformer\", \"transformer_dy\", \"transformer_yd\", \"transformer_yy\",\n \"transformer_dd\", \"autotransformer\", \"transformer_3winding\",\n \"bus\", \"bus_tie\", \"hub\",\n \"breaker\", \"breaker_vacuum\", \"switch\", \"switch_load\", \"ground_switch\",\n \"ats\", \"recloser\", \"sectionalizer\", \"fuse\", \"fuse_cl\",\n \"ct\", \"pt\", \"relay\", \"surge_arrester\", \"ground_fault\",\n \"motor\", \"load\", \"capacitor_bank\", \"harmonic_filter\", \"vfd\",\n \"watthour_meter\", \"demand_meter\",\n]);\n\n// IEC 60364 / BS 7671 / REBT residential vocabulary. These map onto existing\n// IEEE-315 visual primitives until issue 02 Fix C ships a typed `rcd` node\n// and per-curve breaker glyph. The mapping is conservative: every alias\n// renders as a recognisable breaker/RCD variant, no information loss beyond\n// the label-string fidelity LLMs already rely on.\nconst TYPE_ALIASES: Record<string, SLDNodeType> = {\n mcb: \"breaker\",\n mccb: \"breaker\",\n miniature_circuit_breaker: \"breaker\",\n rcd: \"ground_fault\",\n rcbo: \"ground_fault\",\n rccb: \"ground_fault\",\n differential: \"ground_fault\",\n diferencial: \"ground_fault\",\n pia: \"breaker\",\n iga: \"breaker\",\n main_switch: \"switch_load\",\n isolator: \"switch_load\",\n disconnector: \"switch_load\",\n consumer_unit: \"bus\",\n distribution_board: \"bus\",\n panel: \"bus\",\n panelboard: \"bus\",\n};\n\nfunction stripComment(s: string): string {\n // Strip `#`, `//`, or Mermaid `%%` comments. Quoted regions are respected\n // so `\"#fff\"` (a CSS color) and `\"https://…\"` survive.\n let out = \"\";\n let inQuote = false;\n for (let i = 0; i < s.length; i++) {\n const ch = s[i]!;\n if (ch === '\"') inQuote = !inQuote;\n if (!inQuote) {\n if (ch === \"#\") break;\n if (ch === \"/\" && s[i + 1] === \"/\") break;\n if (ch === \"%\" && s[i + 1] === \"%\") break;\n }\n out += ch;\n }\n return out;\n}\n\nfunction stripQuotes(v: string): string {\n const t = v.trim();\n if (t.length >= 2 && t.startsWith('\"') && t.endsWith('\"')) {\n return t.slice(1, -1);\n }\n return t;\n}\n\nfunction splitAttrs(inside: string): Array<[string, string]> {\n // split by commas (respecting quotes) → \"key: value\" pairs\n const parts: string[] = [];\n let cur = \"\";\n let inQuote = false;\n for (const ch of inside) {\n if (ch === '\"') inQuote = !inQuote;\n if (ch === \",\" && !inQuote) {\n parts.push(cur);\n cur = \"\";\n } else {\n cur += ch;\n }\n }\n if (cur.trim()) parts.push(cur);\n\n const out: Array<[string, string]> = [];\n for (const p of parts) {\n const s = p.trim();\n if (!s) continue;\n const colon = s.indexOf(\":\");\n if (colon < 0) {\n throw new SLDParseError(`Invalid attribute \"${s}\" (missing \":\")`);\n }\n const k = s.slice(0, colon).trim();\n const v = stripQuotes(s.slice(colon + 1));\n out.push([k, v]);\n }\n return out;\n}\n\nfunction applyAttrs(node: SLDNode, attrs: Array<[string, string]>): void {\n for (const [k, v] of attrs) {\n const key = k.toLowerCase();\n if (key === \"label\") node.label = v;\n else if (key === \"voltage\") node.voltage = v;\n else if (key === \"rating\") node.rating = v;\n else if (key === \"device\") node.deviceNumber = v;\n else {\n // stash everything else as nameplate\n if (!node.nameplate) node.nameplate = {};\n node.nameplate[k] = v;\n }\n }\n}\n\n/** Join lines so that a bracketed attribute block spans a single logical line. */\nfunction joinBrackets(lines: string[]): string[] {\n const out: string[] = [];\n let buf = \"\";\n let depth = 0;\n for (const raw of lines) {\n const line = stripComment(raw);\n if (!line.trim() && depth === 0) {\n if (buf) {\n out.push(buf);\n buf = \"\";\n }\n out.push(\"\");\n continue;\n }\n for (const ch of line) {\n if (ch === \"[\") depth++;\n else if (ch === \"]\") depth = Math.max(0, depth - 1);\n }\n buf = buf ? buf + \" \" + line.trim() : line;\n if (depth === 0) {\n out.push(buf);\n buf = \"\";\n }\n }\n if (buf) out.push(buf);\n return out;\n}\n\nexport function parseSLDDSL(text: string): SLDAST {\n const rawLines = text.split(\"\\n\").map((l) => l.replace(/\\r$/, \"\"));\n const lines = joinBrackets(rawLines);\n\n let title: string | undefined;\n let standard: SLDStandard | undefined;\n const nodes: SLDNode[] = [];\n const nodeMap = new Map<string, SLDNode>();\n const connections: SLDConnection[] = [];\n\n for (let i = 0; i < lines.length; i++) {\n const raw = lines[i];\n const line = raw.trim();\n if (!line) continue;\n\n // Header: sld \"title\" [standard: iec]\n if (/^sld\\b/i.test(line)) {\n const t = matchQuotedTitle(line);\n if (t !== undefined) title = t;\n const bracket = line.match(/\\[([^\\]]*)\\]/);\n if (bracket) {\n for (const [k, v] of splitAttrs(bracket[1])) {\n if (k.toLowerCase() === \"standard\") {\n const s = v.trim().toLowerCase();\n if (s === \"ansi\" || s === \"iec\" || s === \"abnt\" || s === \"as-nzs\") {\n standard = s;\n } else {\n throw new SLDParseError(\n `Unknown standard \"${v}\". Valid: ansi, iec, abnt, as-nzs`,\n i + 1,\n line\n );\n }\n }\n }\n }\n continue;\n }\n\n // Connection: A -> B [cable: \"...\", label: \"...\"]\n const connMatch = line.match(\n /^([A-Za-z][A-Za-z0-9_-]*)\\s*->\\s*([A-Za-z][A-Za-z0-9_-]*)(?:\\s*\\[([^\\]]*)\\])?\\s*$/\n );\n if (connMatch) {\n const from = connMatch[1];\n const to = connMatch[2];\n const c: SLDConnection = { from, to };\n if (connMatch[3]) {\n for (const [k, v] of splitAttrs(connMatch[3])) {\n const key = k.toLowerCase();\n if (key === \"cable\") c.cable = v;\n else if (key === \"label\") c.label = v;\n }\n }\n connections.push(c);\n continue;\n }\n\n // Node definition: ID = type [attrs]\n const nodeMatch = line.match(\n /^([A-Za-z][A-Za-z0-9_-]*)\\s*=\\s*([a-zA-Z_][a-zA-Z0-9_]*)(?:\\s*\\[([^\\]]*)\\])?\\s*$/\n );\n if (nodeMatch) {\n const id = nodeMatch[1];\n const rawType = nodeMatch[2].toLowerCase();\n // Resolve REBT/IEC residential aliases (mcb → breaker, rcbo → ground_fault…)\n // before the canonical-type check.\n const canonical = (TYPE_ALIASES[rawType] ?? rawType) as SLDNodeType;\n if (!NODE_TYPES.has(canonical)) {\n const candidates = [\n ...NODE_TYPES,\n ...Object.keys(TYPE_ALIASES),\n ];\n throw new SLDParseError(\n `Unknown node type \"${nodeMatch[2]}\" for \"${id}\"${didYouMean(rawType, candidates)}`,\n i + 1,\n line\n );\n }\n if (nodeMap.has(id)) {\n throw new SLDParseError(`Duplicate node id \"${id}\"`, i + 1, line);\n }\n const node: SLDNode = { id, nodeType: canonical };\n // If the user wrote an alias (mcb/rcbo/iga…), preserve the original word\n // as the visible label unless an explicit `label:` attribute overrides\n // it below. This keeps \"MCB\" / \"IGA\" markings on the rendered SVG.\n if (TYPE_ALIASES[rawType]) {\n node.label = rawType.toUpperCase();\n }\n if (nodeMatch[3]) {\n applyAttrs(node, splitAttrs(nodeMatch[3]));\n }\n nodes.push(node);\n nodeMap.set(id, node);\n continue;\n }\n\n throw new SLDParseError(`Cannot parse line`, i + 1, line);\n }\n\n // Validate connections\n for (const c of connections) {\n if (!nodeMap.has(c.from)) {\n throw new SLDParseError(`Connection references unknown node \"${c.from}\"`);\n }\n if (!nodeMap.has(c.to)) {\n throw new SLDParseError(`Connection references unknown node \"${c.to}\"`);\n }\n }\n\n if (nodes.length === 0) {\n throw new SLDParseError(\"SLD diagram has no nodes\");\n }\n\n return { type: \"sld\", title, standard, nodes, connections };\n}\n","/**\n * Core type definitions for Schematex.\n *\n * The pipeline is: Text → Parser → AST → Layout → LayoutResult → Renderer → SVG\n *\n * Each diagram type (genogram, ecomap, pedigree) implements its own:\n * - Parser: text → DiagramAST\n * - Layout: DiagramAST → LayoutResult\n * - Renderer: LayoutResult → SVG string\n */\n\n// Type-only import (erased at runtime — no dependency cycle) for the plugin\n// lint hook's return type.\nimport type { SchematexDiagnostic } from \"./diagnostics\";\n\n// ─── AST Types ───────────────────────────────────────────────\n\nexport type DiagramType =\n // Relationship diagrams\n | \"genogram\"\n | \"ecomap\"\n | \"pedigree\"\n | \"phylo\"\n | \"sociogram\"\n // Electrical engineering diagrams\n | \"timing\" // Digital timing / waveform (06-TIMING-STANDARD)\n | \"logic\" // Logic gate netlist (07-LOGIC-GATE-STANDARD)\n | \"circuit\" // Circuit schematic positional DSL (08-CIRCUIT-SCHEMATIC-STANDARD)\n | \"blockdiagram\" // Control systems block diagram (09-BLOCK-DIAGRAM-STANDARD)\n | \"ladder\" // PLC ladder logic IEC 61131-3 (10-LADDER-LOGIC-STANDARD)\n | \"sld\" // Single-line diagram / power distribution (11-SINGLE-LINE-STANDARD)\n // Corporate / legal structure diagrams\n | \"entity\" // Entity structure / corporate ownership (12-ENTITY-STRUCTURE-STANDARD)\n // Causality / analysis diagrams\n | \"fishbone\" // Ishikawa cause-and-effect (14-FISHBONE-STANDARD)\n // Set-theory / logic diagrams\n | \"venn\" // Venn / Euler diagram (15-VENN-STANDARD)\n // Generic process / decision flowchart\n | \"flowchart\" // Flowchart (14-FLOWCHART-STANDARD)\n // Knowledge / brainstorming diagrams\n | \"mindmap\" // Mindmap — radial Buzan + markmap-compat tree (20-MINDMAP-STANDARD)\n // Strategy / prioritization / analysis diagrams\n | \"matrix\" // Matrix / 2x2 quadrant / 3x3 / N×M heatmap (18-MATRIX-STANDARD)\n // Organizational hierarchy diagrams\n | \"orgchart\" // Organizational / reporting structure chart (16-ORGCHART-STANDARD)\n // Decision-analysis / ML / taxonomy trees\n | \"decisiontree\" // Decision tree — Howard-Raiffa + CART + taxonomy (17-DECISION-TREE-STANDARD)\n // Time axis\n | \"timeline\" // Timeline — events / eras / lifespans on a time axis (19-TIMELINE-STANDARD)\n // Behavior modeling\n | \"state\" // UML 2.5 / Harel statechart (21-STATE-DIAGRAM-STANDARD)\n // Process & instrumentation\n | \"pid\" // ISA-5.1 / ISO 10628 P&ID (22-PID-STANDARD)\n // Data modeling\n | \"erd\" // Entity-Relationship Diagram (Chen / crow's foot, 27-ERD-STANDARD)\n // Physical wiring / hardware prototyping\n | \"breadboard\" // Fritzing-style breadboard view (26-BREADBOARD-STANDARD)\n // Business process modelling\n | \"bpmn\" // OMG BPMN 2.0 business process diagram (25-BPMN-STANDARD)\n // IEC 61131-3 visual PLC languages (sister to ladder §10)\n | \"fbd\" // Function Block Diagram — IEC 61131-3 §6.4 (23-FBD-STANDARD)\n | \"sfc\" // Sequential Function Chart — IEC 61131-3 §6.5 (24-SFC-STANDARD)\n // Evidence-synthesis / research reporting\n | \"prisma\" // PRISMA 2020 flow diagram (28-PRISMA-STANDARD)\n // Structural UML (sister to behavioral §21 state)\n | \"usecase\" // UML 2.5.1 use case diagram (29-USECASE-STANDARD)\n // Project scheduling networks\n | \"pert\" // PERT / CPM activity-on-node network (32-PERT-STANDARD)\n // Behavioral UML (sister to §21 state, §29 usecase)\n | \"sequence\" // UML 2.5.1 §17 sequence / interaction diagram (33-SEQUENCE-STANDARD)\n // Concurrency / discrete-event formalism\n | \"petri\" // Petri net (place/transition net) — Murata 1989 / ISO-IEC 15909 (34-PETRINET-STANDARD)\n // Network / infrastructure topology\n | \"network\"; // Network topology — Cisco-convention icons + hierarchical/spine-leaf layout (35-NETWORK-STANDARD)\n\nexport type GenogramMode = \"medical\" | \"heritage\";\n\n/**\n * Standard legend positions:\n * - \"bottom-inline\" (default) — horizontal strip below the diagram, no box/border\n * - \"bottom-right\" — overlay anchored at bottom-right corner\n * - \"none\" — disabled\n *\n * All other values are legacy aliases (pedigree DSL, older docs) that the renderer\n * silently maps to one of the standard positions: \"outside-*\", \"right\",\n * \"top-*\", \"bottom-left\", \"bottom-center\" → bottom-inline (or bottom-right where\n * a corner is closer in spirit).\n */\nexport type LegendPosition =\n | \"bottom-inline\"\n | \"bottom-right\"\n | \"none\"\n // Legacy aliases (kept for backwards compat; mapped at render time)\n | \"top-left\"\n | \"top-right\"\n | \"bottom-left\"\n | \"bottom-center\"\n | \"outside-right\"\n | \"outside-bottom\"\n | \"right\";\n\nexport type LegendItemKind =\n | \"shape\"\n | \"fill\"\n | \"fill-pattern\"\n | \"line\"\n | \"marker\"\n | \"edge\";\n\nexport type LegendLinePattern =\n | \"solid\"\n | \"dashed\"\n | \"dotted\"\n | \"double\"\n | \"wavy\"\n | \"zigzag\"\n | \"broken\";\n\nexport interface LegendItem {\n /** Stable identifier addressable from DSL `legend.label <key>: ...` */\n key: string;\n /** Display text (user-overridable). */\n label: string;\n kind: LegendItemKind;\n /** Primary color. For \"shape\": stroke. For \"line\"/\"edge\": stroke. For \"fill\"/\"fill-pattern\"/\"marker\": fill. */\n color?: string;\n /** For kind: \"shape\" — fill color (separate from stroke). Used for WYSIWYG matching of node fills. */\n fill?: string;\n /** Secondary color for two-tone swatches (half-fill, etc.). */\n color2?: string;\n pattern?: LegendLinePattern;\n strokeWidth?: number;\n /** For kind: \"shape\" — \"square\" | \"circle\" | \"diamond\" | \"triangle\" | \"concentric-square\" | \"concentric-circle\". */\n shape?: string;\n /** For kind: \"marker\" / \"edge\" — \"arrow\" | \"X\" | \"dot\" | \"P\" | \"C\" | \"E\" | \"star\" | \"slash\". */\n marker?: string;\n /** Section group id (e.g. \"symbols\", \"structural\", \"relationships\", \"conditions\"). */\n section?: string;\n}\n\nexport interface LegendSection {\n id: string;\n title: string;\n hidden?: boolean;\n}\n\nexport interface LegendSpec {\n /** \"auto\" resolves to \"on\" if items remain after override, else \"off\". */\n mode: \"on\" | \"off\" | \"auto\";\n title: string;\n position: LegendPosition;\n columns: number;\n sections: LegendSection[];\n items: LegendItem[];\n}\n\n/** User edits parsed from DSL; merged onto each diagram's auto-derived spec. */\nexport interface LegendOverrides {\n mode?: \"on\" | \"off\" | \"auto\";\n title?: string;\n position?: LegendPosition;\n columns?: number;\n /** Rename items by key. */\n labels?: Record<string, string>;\n /** Hide items by key. */\n hide?: string[];\n /** Rename / hide sections by id. */\n sections?: Record<string, { title?: string; hidden?: boolean }>;\n /** Manually authored items appended after auto-derived ones. */\n added?: LegendItem[];\n}\n\nexport interface DiagramAST {\n type: DiagramType;\n individuals: Individual[];\n relationships: Relationship[];\n metadata?: Record<string, string>;\n /** Legacy: pedigree-style trait legend. To be migrated into LegendOverrides.added. */\n legend?: LegendEntry[];\n /** Genogram display mode: medical conditions or cultural heritage */\n mode?: GenogramMode;\n /** Legacy: pre-unified-legend position field. New code uses legendOverrides.position. */\n legendPosition?: LegendPosition;\n /** Unified legend system — user DSL edits merged onto auto-derived spec at render time. */\n legendOverrides?: LegendOverrides;\n}\n\nexport interface LegendEntry {\n id: string;\n label: string;\n /** Fill position (for pedigree trait legend) */\n fill?: ConditionFill;\n /** Color (for heritage legend or pedigree trait legend) */\n color?: string;\n}\n\nexport interface Individual {\n id: string;\n label: string;\n sex: Sex;\n status: IndividualStatus;\n birthYear?: number;\n deathYear?: number;\n /**\n * Full ISO birth date (`\"1940-03-12\"`) for genealogy / legal family trees.\n * Backward-compatible with `birthYear`: when present it takes precedence in\n * the vital-records caption (`* 1940-03-12`). A bare 4-digit year still fills\n * `birthYear`.\n */\n dob?: string;\n /** Full ISO death date (`\"2018-11-04\"`), rendered as `† 2018-11-04`. */\n dod?: string;\n /** One-line free-text annotation rendered as a small caption under the symbol. */\n note?: string;\n /**\n * Legal/genealogy birth status (German Ahnentafel convention). Modifies the\n * born glyph in the vital-records caption: `out-of-wedlock` → `(*)`,\n * `adopted` → `[*]`. Default (legitimate) keeps the plain `*` born glyph.\n */\n birthStatus?: \"legitimate\" | \"out-of-wedlock\" | \"adopted\";\n /** Medical/psychological conditions (genogram) or affected traits (pedigree) */\n conditions?: Condition[];\n /** Genetic status for pedigree charts */\n geneticStatus?: GeneticStatus;\n /** Child relationship modifier */\n childType?: ChildType;\n /** Special markers */\n markers?: IndividualMarker[];\n /** Gender identity annotation (Bennett 2022: when gender ≠ assigned sex) */\n genderIdentity?: string;\n /** Cultural/ethnic heritage identifiers (heritage genogram mode) */\n heritage?: string[];\n /** Age to display inside shape (auto-calculated from birthYear if omitted) */\n age?: number;\n /** Rich annotations: occupation, traits, notes, etc. */\n annotations?: Record<string, string>;\n /** Whether this individual is external/non-family (dashed border) */\n external?: boolean;\n /**\n * Optional shape override. By default the shape is derived from `sex`\n * (male=square, female=circle, other=diamond). Some kinship/anthropology\n * conventions use triangles for males, etc. This field lets the DSL request\n * a specific shape regardless of sex.\n */\n shape?: \"square\" | \"circle\" | \"diamond\" | \"triangle\" | \"triangle-down\";\n /**\n * Pedigree convention for \"known relative, unknown ancestry\":\n * id of another individual whose generation this person shares as a sibling.\n * No phantom parents are synthesized — layout pins generation, renderer\n * draws a dashed bracket between the two.\n */\n siblingOf?: string;\n /** Custom properties for extensibility */\n properties?: Record<string, string>;\n}\n\nexport type Sex =\n | \"male\"\n | \"female\"\n | \"unknown\"\n | \"other\"\n // Bennett 2022 additions\n | \"nonbinary\"\n | \"intersex\";\n\nexport type IndividualStatus =\n | \"alive\"\n | \"deceased\"\n | \"stillborn\"\n | \"miscarriage\"\n | \"abortion\"\n // Expanded statuses\n | \"pregnancy\"\n | \"sab\" // spontaneous abortion (pedigree terminology)\n | \"tab\" // therapeutic/induced abortion\n | \"ectopic\";\n\nexport type GeneticStatus =\n | \"unaffected\"\n | \"affected\"\n | \"carrier\"\n | \"carrier-x\" // X-linked carrier (dot in center)\n | \"obligate-carrier\"\n | \"presymptomatic\";\n\nexport type ChildType =\n | \"biological\"\n | \"adopted\"\n | \"adopted-in\" // pedigree: adopted into family\n | \"adopted-out\" // pedigree: adopted out of family\n | \"foster\"\n | \"step\"\n | \"surrogate\"\n | \"donor\"\n | \"donor-egg\"\n | \"donor-sperm\"\n | \"donor-embryo\";\n\nexport type IndividualMarker =\n | \"proband\" // pedigree: index case (arrow + P)\n | \"consultand\" // pedigree: person who sought counseling (arrow + C)\n | \"evaluated\" // pedigree: clinically evaluated (E)\n | \"index-person\" // genogram: identified patient (concentric shape)\n | \"transgender\" // Bennett 2022: gender ≠ assigned sex\n | \"no-children\" // by choice\n | \"infertile\"\n // Pedigree convention: ≥1 sibling(s) of unknown count — single diamond with \"?\"\n | \"unknown-siblings\";\n\nexport type TwinType =\n | \"twin-identical\" // monozygotic\n | \"twin-fraternal\" // dizygotic\n | \"twin-unknown\" // unknown zygosity\n | \"triplet-identical\"\n | \"triplet-fraternal\";\n\nexport interface Condition {\n label: string;\n /** Fill pattern for condition display */\n fill: ConditionFill;\n /** Color for the fill (hex or named). Falls back to category default. */\n color?: string;\n /** Medical category for automatic color assignment */\n category?: MedicalCategory;\n}\n\nexport type ConditionFill =\n | \"full\"\n | \"half-left\"\n | \"half-right\"\n | \"half-top\"\n | \"half-bottom\"\n | \"quad-tl\"\n | \"quad-tr\"\n | \"quad-bl\"\n | \"quad-br\"\n | \"striped\" // carrier/asymptomatic\n | \"dotted\"\n | \"carrier\"; // alias for striped\n\n/** Standard 22-category medical condition system (genogram) */\nexport type MedicalCategory =\n | \"cardiovascular\"\n | \"cancer\"\n | \"diabetes\"\n | \"mental-health\"\n | \"depression\"\n | \"anxiety\"\n | \"bipolar\"\n | \"ptsd\"\n | \"substance-alcohol\"\n | \"substance-drugs\"\n | \"substance-tobacco\"\n | \"neurological\"\n | \"respiratory\"\n | \"autoimmune\"\n | \"genetic\"\n | \"reproductive\"\n | \"eating-disorder\"\n | \"learning-developmental\"\n | \"kidney\"\n | \"liver-gi\"\n | \"obesity\"\n | \"other\";\n\n// ─── Fishbone (Ishikawa) Types ──────────────────────────────\n\nexport type FishboneOrientation = \"ltr\" | \"rtl\";\n\n/** Which halves of the spine host ribs. */\nexport type FishboneSides = \"both\" | \"top\" | \"bottom\";\n\n/** Density preset — controls spine length, slot spacing, header size. */\nexport type FishboneDensity = \"compact\" | \"normal\" | \"spacious\";\n\n/** Where cause branches stick out of a rib. */\nexport type FishboneCauseSide = \"head\" | \"tail\" | \"both\";\n\nexport interface FishboneNode {\n /** Display text on the bone. */\n label: string;\n /** Optional explicit hex color (conventionally set only on majors). */\n color?: string;\n /** Nested sub-causes (unbounded depth, recommended ≤ 3). */\n children: FishboneNode[];\n /** Per-rib placement override (only honored on majors). */\n side?: \"top\" | \"bottom\";\n /** Per-rib explicit ordering within its half (lower = closer to tail). */\n order?: number;\n}\n\nexport interface FishboneLegendEntry {\n label: string;\n color: string;\n}\n\nexport interface FishboneAST {\n type: \"fishbone\";\n title?: string;\n /** Problem / outcome displayed in the head box. */\n effect: string;\n /** Top-level cause categories (major bones). */\n majors: FishboneNode[];\n /** Effect position: `ltr` → head on right, `rtl` → head on left. */\n orientation: FishboneOrientation;\n /** Optional explicit canvas dimensions (otherwise auto-computed). */\n width?: number;\n height?: number;\n /** Optional legend entries rendered in a corner box. */\n legend?: FishboneLegendEntry[];\n metadata?: Record<string, string>;\n /** Which sides of the spine host ribs. Default: \"both\". */\n sides?: FishboneSides;\n /** Rib slope dx/dy. Default: 0.6. Accepts number or preset name. */\n ribSlope?: number;\n /** Density preset. Default: \"normal\". */\n density?: FishboneDensity;\n /** Which side of the rib cause branches stick out on. Default: \"head\". */\n causeSide?: FishboneCauseSide;\n}\n\n// ─── Phylogenetic Tree Types ────────────────────────────────\n\n/** Layout algorithm for phylogenetic tree */\nexport type PhyloLayout = \"rectangular\" | \"slanted\" | \"circular\" | \"unrooted\";\n\n/** Tree representation mode — determines how branch lengths are interpreted */\nexport type PhyloMode = \"phylogram\" | \"cladogram\" | \"chronogram\";\n\n/** Clade highlight display mode */\nexport type CladeHighlightMode = \"branch\" | \"background\" | \"both\";\n\n/** A phylogenetic tree node (distinct from family-tree Individual) */\nexport interface PhyloNode {\n /** Unique id (auto-generated for unnamed internal nodes) */\n id: string;\n /** Display label (species name, gene id, etc.) */\n label?: string;\n /** Branch length to parent (substitutions/site or time units) */\n branchLength?: number;\n /** Bootstrap support or Bayesian posterior probability (0-100 or 0-1) */\n support?: number;\n /** Children nodes (empty = leaf/tip) */\n children: PhyloNode[];\n /** Is this a leaf/tip node? */\n isLeaf: boolean;\n /** NHX metadata key-value pairs */\n nhx?: Record<string, string>;\n}\n\n/** Clade definition for visual highlighting */\nexport interface CladeDef {\n id: string;\n /** Label to display next to clade bracket/background */\n label?: string;\n /** Leaf ids that define this clade (MRCA computed automatically) */\n members: string[];\n /** Branch/background color */\n color?: string;\n /** Highlight mode */\n highlight?: CladeHighlightMode;\n}\n\n/** Phylogenetic tree AST — separate from DiagramAST because structure is fundamentally different */\nexport interface PhyloTreeAST {\n type: \"phylo\";\n /** Tree title */\n title?: string;\n /** Root node of the tree */\n root: PhyloNode;\n /** Is this explicitly unrooted? */\n unrooted: boolean;\n /** Layout algorithm */\n layout: PhyloLayout;\n /** Branch length interpretation */\n mode: PhyloMode;\n /** Clade definitions for visual highlighting */\n clades: CladeDef[];\n /** Scale bar label (e.g. \"substitutions/site\", \"Million years ago\") */\n scaleLabel?: string;\n /** Most recent sampling date (for chronogram mode) */\n mrsd?: string;\n /** Outgroup taxon id (for rooting) */\n outgroup?: string;\n /** Custom metadata */\n metadata?: Record<string, string>;\n}\n\n/** Layout result for phylogenetic tree */\nexport interface PhyloLayoutNode {\n node: PhyloNode;\n x: number;\n y: number;\n /** Angle in radians (for circular/unrooted layouts) */\n angle?: number;\n /** Radius from center (for circular/unrooted layouts) */\n radius?: number;\n}\n\n/** Phylogenetic tree render config (extends base RenderConfig) */\nexport interface PhyloRenderConfig {\n fontFamily: string;\n fontSize: number;\n theme: string;\n padding: number;\n /** Branch line width in px */\n branchWidth: number;\n /** Show tip dots */\n showTipDots: boolean;\n /** Show bootstrap/support values as text */\n showSupportValues: boolean;\n /** Show bootstrap/support values as colored dots */\n showSupportDots: boolean;\n /** Minimum support value to display (default: 50) */\n supportThreshold: number;\n /** Show scale bar */\n showScaleBar: boolean;\n /** Tip spacing in px */\n tipSpacing: number;\n /** Fan opening angle in degrees (circular layout, default: 0 = full circle) */\n openAngle: number;\n /** Italicize species binomials automatically */\n italicizeSpecies: boolean;\n}\n\n// ─── Relationship Types ─────────────────────────────────────\n\nexport type RelationshipType =\n // Structural couple relationships (genogram + pedigree)\n | \"married\"\n | \"divorced\"\n | \"separated\"\n | \"engaged\"\n | \"cohabiting\"\n | \"cohabiting-ended\" // unmarried cohabitation that has ended (LATAM \"quiebre\")\n | \"domestic-partnership\"\n | \"consanguineous\"\n // Structural parent-child\n | \"parent-child\"\n | \"adopted\"\n | \"foster\"\n | \"twin-identical\"\n | \"twin-fraternal\"\n // Emotional relationships — Positive/Close (genogram)\n | \"harmony\"\n | \"close\"\n | \"bestfriends\"\n | \"love\"\n | \"inlove\"\n | \"friendship\"\n // Emotional — Negative/Hostile\n | \"hostile\"\n | \"conflict\"\n | \"enmity\"\n | \"distant-hostile\"\n | \"cutoff\"\n // Emotional — Ambivalent/Complex\n | \"close-hostile\"\n | \"fused\"\n | \"fused-hostile\"\n // Emotional — Distance\n | \"distant\"\n | \"normal\"\n | \"nevermet\"\n // Emotional — Abuse (directional)\n | \"abuse\"\n | \"physical-abuse\"\n | \"emotional-abuse\"\n | \"sexual-abuse\"\n | \"neglect\"\n // Emotional — Control/Power (directional)\n | \"manipulative\"\n | \"controlling\"\n | \"jealous\"\n // Emotional — Special\n | \"focused\"\n | \"focused-neg\"\n | \"distrust\"\n | \"admirer\"\n | \"limerence\"\n // Ecomap-specific\n | \"strong\"\n | \"moderate\"\n | \"weak\"\n | \"stressful\"\n | \"stressful-strong\"\n | \"conflictual\"\n | \"broken\"\n | \"reciprocal\";\n\nexport interface Relationship {\n type: RelationshipType;\n from: string; // Individual id\n to: string; // Individual id\n label?: string;\n /** Is this relationship directional? (abuse, control, focused, ecomap energy flow) */\n directional?: boolean;\n /** For ecomap: line weight 1-5 */\n weight?: number;\n /** For ecomap: energy flow direction */\n energyFlow?: \"from\" | \"to\" | \"mutual\" | \"none\";\n /**\n * Genogram parent-child only. When true, this link is data-true but\n * does NOT dominate layout — used for foster/adopted/guardian \"current\n * caregiver\" relationships when biological parents already claim the\n * child structurally. Renderer draws it as a dotted line.\n */\n secondary?: boolean;\n}\n\n// ─── Layout Types ────────────────────────────────────────────\n\nexport interface LayoutResult {\n width: number;\n height: number;\n nodes: LayoutNode[];\n edges: LayoutEdge[];\n}\n\nexport interface LayoutNode {\n id: string;\n x: number;\n y: number;\n width: number;\n height: number;\n /** Generation/layer index (0 = oldest generation) */\n generation: number;\n individual: Individual;\n}\n\nexport interface LayoutEdge {\n from: string;\n to: string;\n relationship: Relationship;\n /** SVG path data (d attribute) */\n path: string;\n}\n\n// ─── Diagram Plugin Interface ────────────────────────────────\n\nexport interface DiagramPlugin {\n type: DiagramType;\n detect: (text: string) => boolean;\n render: (text: string, config?: RenderConfig) => string;\n /** Parse DSL text to the diagram's AST (for JSON export / programmatic access). */\n parse?: (text: string) => unknown;\n /**\n * Optional non-fatal validation pass. Runs after a successful parse and\n * returns domain-level warnings (e.g. an incomplete instrument loop) without\n * blocking rendering. Surfaced through `parseResult` / `renderResult`\n * diagnostics. Must not throw — return `[]` when there's nothing to flag.\n */\n lint?: (text: string) => SchematexDiagnostic[];\n}\n\nexport interface LayoutConfig {\n /** Horizontal spacing between nodes */\n nodeSpacingX: number;\n /** Vertical spacing between generations */\n nodeSpacingY: number;\n /** Node dimensions */\n nodeWidth: number;\n nodeHeight: number;\n}\n\nexport interface RenderConfig {\n fontFamily: string;\n fontSize: number;\n theme: string;\n padding: number;\n /** Show age number inside shapes */\n showAge?: boolean;\n /** Show rich annotations below names */\n showAnnotations?: boolean;\n /** Show relationship labels on lines */\n showEdgeLabels?: boolean;\n /** Show in-law relationship labels */\n showInLawLabels?: boolean;\n /** Legend position override */\n legendPosition?: LegendPosition;\n}\n\n// ─── Electrical Engineering AST Types ───────────────────────\n\n// ── Timing Diagram ──────────────────────────────────────────\n\n/** A single waveform signal or group */\nexport type TimingSignalState =\n | \"0\" | \"1\" | \"x\" | \"z\" | \"=\" | \".\" | \"u\" | \"d\"\n | \"p\" | \"P\" | \"n\" | \"N\" | \"h\" | \"H\" | \"l\" | \"L\"\n | \"2\" | \"3\" | \"4\" | \"5\" | \"6\" | \"7\" | \"8\" | \"9\";\n\nexport interface TimingSignal {\n /** Signal name (display label) */\n name: string;\n /** WaveDrom wave string: sequence of state chars */\n wave: string;\n /** Data labels for bus states (= or 2-9) */\n data?: string[];\n /** Phase offset in half-periods */\n phase?: number;\n /** Period multiplier */\n period?: number;\n /** Node markers for annotation arrows */\n node?: string;\n}\n\nexport interface TimingGroup {\n label: string;\n signals: Array<TimingSignal | TimingGroup>;\n}\n\nexport interface TimingAnnotation {\n /** Source node marker id */\n from: string;\n /** Target node marker id */\n to: string;\n label?: string;\n}\n\nexport interface TimingAST {\n type: \"timing\";\n title?: string;\n /** Time scale multiplier (1–4) */\n hscale?: number;\n signals: Array<TimingSignal | TimingGroup>;\n annotations?: TimingAnnotation[];\n metadata?: Record<string, string>;\n}\n\n// ── Logic Gate ───────────────────────────────────────────────\n\nexport type LogicGateType =\n // ── Combinational Gates ──────────────────────────────────────\n | \"AND\" | \"OR\" | \"NOT\" | \"NAND\" | \"NOR\" | \"XOR\" | \"XNOR\" | \"BUF\"\n // ── Buffers with special output types ────────────────────────\n | \"TRISTATE_BUF\" // Buffer + enable pin; Z-state when disabled\n | \"TRISTATE_INV\" // Inverting buffer + enable pin\n | \"OPEN_DRAIN\" // Open-drain/open-collector output (pull-up required)\n | \"SCHMITT\" // Schmitt trigger; hysteresis symbol inside body\n // ── Edge-triggered flip-flops ─────────────────────────────────\n | \"DFF\" // D flip-flop (clock triangle)\n | \"JKFF\" // JK flip-flop\n | \"SRFF\" // SR flip-flop\n | \"TFF\" // T (toggle) flip-flop\n // ── Level-sensitive latches ────────────────────────────────────\n | \"LATCH_SR\" // SR latch (NOR/NAND cross-coupled, no clock)\n | \"LATCH_D\" // D latch (transparent when enable=1)\n // ── Combinational complex ──────────────────────────────────────\n | \"MUX\" | \"DEMUX\" | \"DECODER\" | \"ENCODER\"\n // ── Sequential complex ─────────────────────────────────────────\n | \"COUNTER\" // Generic binary counter (CTR label, CLK/RESET/Q0–Q3)\n | \"SHIFT_REG\"; // Generic shift register (SRG label, CLK/SER/Q0–Q7)\n\nexport type LogicGateStyle = \"ansi\" | \"iec\";\n\nexport interface LogicGateNode {\n id: string;\n gateType: LogicGateType;\n inputs: string[]; // References to signal ids or gate ids (with ~ for active-low)\n label?: string;\n style?: LogicGateStyle;\n /** Optional module/sub-circuit this gate belongs to */\n moduleId?: string;\n}\n\nexport interface LogicGateModule {\n id: string;\n label: string;\n}\n\nexport interface LogicGateInput {\n id: string;\n label: string;\n isActiveLow?: boolean;\n /** True when the parser inferred this input from a gate reference rather than an explicit declaration. */\n autoDeclared?: boolean;\n}\n\nexport interface LogicGateOutput {\n id: string;\n /** Signal source id (gate output or input port) */\n from: string;\n label: string;\n isActiveLow?: boolean;\n}\n\nexport interface LogicGateAST {\n type: \"logic\";\n title?: string;\n style?: LogicGateStyle;\n inputs: LogicGateInput[];\n outputs: LogicGateOutput[];\n gates: LogicGateNode[];\n modules?: LogicGateModule[];\n metadata?: Record<string, string>;\n /** Non-fatal parser warnings (e.g. signals auto-declared as inputs). */\n warnings?: string[];\n}\n\n// ── Circuit Schematic ────────────────────────────────────────\n\nexport type CircuitComponentType =\n // ── Resistors & Passive Variants ────────────────────────────\n | \"resistor\" // Zigzag (ANSI) / rectangle (IEC)\n | \"potentiometer\" // Resistor + diagonal arrow, 3-pin (A/wiper/B)\n | \"rheostat\" // Resistor + diagonal arrow, 2-pin variable\n | \"thermistor_ntc\" // Resistor + diagonal arrow + \"-t°\" label\n | \"thermistor_ptc\" // Resistor + diagonal arrow + \"+t°\" label\n | \"ldr\" // Resistor + two inward arrows (light dependent)\n | \"varistor\" // Resistor + \"V\" label inside box\n | \"fuse\" // Small rectangle/oval on wire (sacrificial)\n | \"fuse_slow\" // Fuse + \"T\" designation\n\n // ── Capacitors ───────────────────────────────────────────────\n | \"capacitor\" // Two parallel lines (nonpolar)\n | \"electrolytic_cap\" // Curved plate + polarity markers (polar)\n | \"variable_cap\" // Capacitor + diagonal arrow\n\n // ── Inductors ────────────────────────────────────────────────\n | \"inductor\" // Arc humps (air core)\n | \"inductor_iron\" // Arc humps + two parallel core lines\n | \"inductor_ferrite\" // Arc humps + one filled core line\n | \"variable_inductor\" // Inductor + diagonal arrow\n | \"ferrite_bead\" // Small filled rectangle on wire (EMI bead)\n | \"crystal\" // Rect body + two external lines (quartz oscillator)\n | \"transformer\" // Two coil groups + core lines\n\n // ── Diodes ───────────────────────────────────────────────────\n | \"diode\" // Triangle + bar\n | \"zener\" // Triangle + bent bar (Z)\n | \"schottky\" // Triangle + S-bar\n | \"led\" // Diode + two outward arrows\n | \"photodiode\" // Diode + two inward arrows\n | \"varactor\" // Diode + variable capacitor symbol\n | \"tvs_diode\" // Bidirectional zener (two bent bars)\n | \"bridge_rectifier\" // Diamond of 4 diodes, 4-pin (AC1/AC2/DC+/DC−)\n\n // ── Bipolar Transistors ───────────────────────────────────────\n | \"npn\" // NPN BJT (arrow outward on emitter)\n | \"pnp\" // PNP BJT (arrow inward on emitter)\n | \"darlington_npn\" // NPN + NPN Darlington pair\n | \"darlington_pnp\" // PNP + PNP Darlington pair\n\n // ── Field Effect Transistors ──────────────────────────────────\n | \"nmos\" // N-channel MOSFET enhancement (gate insulated, dashed channel)\n | \"pmos\" // P-channel MOSFET enhancement\n | \"nmos_depletion\" // N-channel MOSFET depletion (solid channel)\n | \"jfet_n\" // N-channel JFET (gate arrow pointing in)\n | \"jfet_p\" // P-channel JFET (gate arrow pointing out)\n\n // ── Power Semiconductors ─────────────────────────────────────\n | \"igbt\" // IGBT: MOSFET gate + BJT body + diode body\n | \"scr\" // SCR/Thyristor: diode + gate lead (PNPN)\n | \"triac\" // TRIAC: two back-to-back SCRs + gate\n | \"diac\" // DIAC: two back-to-back diodes, 2-pin\n\n // ── Optoelectronics ───────────────────────────────────────────\n | \"phototransistor\" // NPN shape + two inward arrows on base\n | \"optocoupler\" // LED + phototransistor in dashed isolation box\n\n // ── Op-Amp / Analog ICs ───────────────────────────────────────\n | \"opamp\" // Triangle: +/− inputs, output, ±Vcc\n | \"comparator\" // Triangle (same shape, open-collector output)\n | \"schmitt_buffer\" // Buffer triangle + hysteresis symbol inside\n | \"tri_state_buffer\" // Buffer triangle + enable pin\n | \"instrumentation_amp\" // Three op-amp INA block\n\n // ── Generic IC & Special Blocks ──────────────────────────────\n | \"generic_ic\" // Rect with configurable labeled pins (attrs: pins_left, pins_right)\n | \"voltage_regulator\" // 3-terminal rect block (IN/GND/OUT), e.g. LM7805\n | \"dc_dc_converter\" // 2-port rect block with \"DC/DC\" label\n | \"555_timer\" // 8-pin rect with standard 555 pinout\n | \"terminal_block\" // Labeled enclosure with N named terminals (junction box, terminal strip)\n\n // ── Sources & Power ───────────────────────────────────────────\n | \"voltage_source\" // Circle + V or ± polarity\n | \"current_source\" // Circle + arrow\n | \"ac_source\" // Circle + ~ (sine symbol)\n | \"battery\" // Alternating long/short lines\n | \"vcc\" // Power rail arrow pointing up\n | \"ground\" // Earth ground (3 horizontal lines)\n | \"gnd_signal\" // Signal ground (solid triangle)\n | \"gnd_chassis\" // Chassis ground (hash-like)\n | \"gnd_digital\" // Digital ground (square)\n\n // ── Switches ──────────────────────────────────────────────────\n | \"switch_spst\" // Single-pole single-throw (angled arm + gap)\n | \"switch_spdt\" // Single-pole double-throw (3-pin)\n | \"switch_dpdt\" // Double-pole double-throw (6-pin)\n | \"push_no\" // Push button normally-open (circle + contact gap)\n | \"push_nc\" // Push button normally-closed (circle + line + slash)\n\n // ── Relays (coil and contacts placed separately) ───────────────\n | \"relay_coil\" // Rectangle with coil symbol, 2-pin\n | \"relay_no\" // Relay contact normally-open (like switch_spst)\n | \"relay_nc\" // Relay contact normally-closed (with slash)\n\n // ── Industrial control / Power electrical (IEC 60617 §07/§14) ──\n | \"contactor\" // Heavy-load switching (KM*) — bold contact + dash actuator\n | \"solenoid_valve\" // Pneumatic / hydraulic control (EV*) — coil + valve symbol\n | \"thermal_overload\" // Motor protection (F2*) — hashed rectangle + heat marks\n | \"disconnect_switch\" // Service disconnect / isolator (Q1*) — switch with disconnect bracket\n\n // ── Electromechanical ─────────────────────────────────────────\n | \"motor\" // Circle + M + shaft line\n | \"speaker\" // Triangle + box + radiating lines\n | \"microphone\" // Circle + vertical lines (capsule)\n | \"buzzer\" // Piezo symbol or speaker variant\n\n // ── Measurement ───────────────────────────────────────────────\n | \"ammeter\" // Circle + \"A\"\n | \"voltmeter\" // Circle + \"V\"\n | \"wattmeter\" // Circle + \"W\"\n | \"oscilloscope\" // Circle + waveform symbol\n\n // ── Connectors & Annotations ──────────────────────────────────\n | \"wire\" // Plain wire segment\n | \"dot\" // Junction dot\n | \"label\" // Net label (flag or text-only)\n | \"port\" // Named port (hollow circle + label)\n | \"test_point\" // TP marker (small circle + \"TP\" label)\n | \"no_connect\" // X marker — no electrical connection\n | \"antenna\"; // Antenna (vertical line + radiating stubs)\n\nexport type CircuitDirection = \"right\" | \"left\" | \"up\" | \"down\";\n\nexport interface CircuitComponent {\n id: string;\n componentType: CircuitComponentType;\n direction: CircuitDirection;\n /** Reference to anchor point of previous/named element: e.g. \"R1.end\", \"origin\" */\n at?: string;\n /** Display label (R1, C2, etc.) */\n label?: string;\n /** Value annotation (1kΩ, 100nF, etc.) */\n value?: string;\n /** Extra attributes (length for wires, gain for opamp, etc.) */\n attrs?: Record<string, string>;\n}\n\n/** Multi-terminal electrical node — connects multiple anchor refs to the same node */\nexport interface CircuitNet {\n /** Net name (e.g. \"VOUT\") */\n id: string;\n /** Anchor refs sharing the same node (e.g. [\"R2.end\", \"U1.out\", \"OUT.start\"]) */\n anchors: string[];\n}\n\nexport interface CircuitAST {\n type: \"circuit\";\n title?: string;\n components: CircuitComponent[];\n /** Explicit net declarations for multi-terminal connections */\n nets: CircuitNet[];\n metadata?: Record<string, string>;\n /** Layout mode: \"positional\" (Schemdraw-style direction chain) or \"netlist\" (SPICE-style, auto-layout). */\n mode?: \"positional\" | \"netlist\";\n /**\n * Netlist-only. Maps componentId → { pinName → netId }.\n * Populated by the netlist parser; consumed by the auto-layout engine.\n */\n pinMap?: Record<string, Record<string, string>>;\n}\n\n// ── Block Diagram ────────────────────────────────────────────\n\nexport type BlockRole = \"plant\" | \"controller\" | \"sensor\" | \"actuator\" | \"reference\" | \"disturbance\" | \"generic\";\n\nexport interface BlockNode {\n id: string;\n /** Display label / transfer function e.g. \"G(s)\" */\n label: string;\n role?: BlockRole;\n /** Routing hint for feedback/feedforward blocks: \"above\" = route over forward path */\n route?: \"above\" | \"below\";\n}\n\nexport interface SummingJunction {\n id: string;\n /** Signed inputs: \"+r\" means add signal r, \"-ym\" means subtract signal ym */\n inputs: string[];\n /** Output signal id */\n output?: string;\n}\n\nexport interface BlockSignal {\n id: string;\n /** Display label for an input/output signal port, e.g. \"y (output)\" */\n label: string;\n /** Dashed line for discrete-time signals */\n discrete?: boolean;\n}\n\nexport interface BlockEdge {\n from: string;\n to: string;\n /** Signal label e.g. \"E(s)\", \"U(s)\" */\n label?: string;\n /** Dashed line for discrete-time signals */\n discrete?: boolean;\n}\n\nexport interface BlockAST {\n type: \"blockdiagram\";\n title?: string;\n blocks: BlockNode[];\n sums: SummingJunction[];\n signals?: BlockSignal[];\n connections: BlockEdge[];\n metadata?: Record<string, string>;\n}\n\n// ── Ladder Logic ─────────────────────────────────────────────\n\nexport type LadderContactType = \"XIC\" | \"XIO\" | \"ONS\" | \"OSF\";\nexport type LadderCoilType = \"OTE\" | \"OTL\" | \"OTU\" | \"OTN\" | \"RES\";\nexport type LadderFBType =\n | \"TON\" | \"TOFF\" | \"TP\" // Timers\n | \"CTU\" | \"CTD\" | \"CTUD\" // Counters\n | \"ADD\" | \"SUB\" | \"MUL\" | \"DIV\" // Math\n | \"MOV\" // Move\n | \"EQU\" | \"NEQ\" | \"GRT\" | \"LES\" | \"GEQ\" | \"LEQ\"; // Compare (Allen-Bradley convention)\n\nexport interface LadderContact {\n elementType: \"contact\";\n contactType: LadderContactType;\n tag: string;\n address?: string;\n /** Human-readable description (rendered above the tag as 1–3 wrapped lines) */\n name?: string;\n}\n\nexport interface LadderCoil {\n elementType: \"coil\";\n coilType: LadderCoilType;\n tag: string;\n address?: string;\n /** Human-readable description (rendered above the tag as 1–3 wrapped lines) */\n name?: string;\n}\n\nexport interface LadderFunctionBlock {\n elementType: \"function_block\";\n fbType: LadderFBType;\n tag: string;\n params: Record<string, string | number>;\n}\n\nexport type LadderElement = LadderContact | LadderCoil | LadderFunctionBlock;\n\nexport interface LadderBranch {\n elements: LadderElement[];\n}\n\nexport interface LadderRung {\n number: number;\n comment?: string;\n /** Sequential elements and parallel groups */\n elements: Array<LadderElement | { parallel: LadderBranch[] }>;\n}\n\nexport interface LadderAST {\n type: \"ladder\";\n title?: string;\n rungs: LadderRung[];\n metadata?: Record<string, string>;\n}\n\n// ── Single-Line Diagram ──────────────────────────────────────\n\nexport type SLDNodeType =\n // ── Generation & Sources ─────────────────────────────────────\n | \"utility\" // Infinite bus / utility feed (circle + ~)\n | \"generator\" // Synchronous generator (circle + G)\n | \"solar\" // PV array (panel symbol)\n | \"wind\" // Wind turbine\n | \"ups\" // Uninterruptible power supply block\n\n // ── Transformers (winding configuration variants) ──────────────\n | \"transformer\" // Generic (two coil groups, no winding spec)\n | \"transformer_dy\" // Delta primary → Wye grounded secondary (Δ-Yg)\n | \"transformer_yd\" // Wye grounded primary → Delta secondary (Yg-Δ)\n | \"transformer_yy\" // Wye-Wye (both grounded)\n | \"transformer_dd\" // Delta-Delta\n | \"autotransformer\" // Single winding with tap (zigzag coil symbol)\n | \"transformer_3winding\" // Three-winding power transformer\n\n // ── Buses & Nodes ─────────────────────────────────────────────\n | \"bus\" // Horizontal thick line (6px stroke)\n | \"bus_tie\" // Bus-tie breaker between two parallel same-level buses\n | \"hub\" // Multi-port synchronization / combining hub (wide rectangle)\n\n // ── Switching Equipment ───────────────────────────────────────\n | \"breaker\" // Circuit breaker (diagonal + arc at top)\n | \"breaker_vacuum\" // Vacuum CB (diagonal + \"V\" inside oval)\n | \"switch\" // Disconnect switch (diagonal, no arc, open tip)\n | \"switch_load\" // Load interrupter switch\n | \"ground_switch\" // Grounding disconnect (diagonal + ground symbol)\n | \"ats\" // Automatic transfer switch (two breakers + tie)\n | \"recloser\" // Auto-reclosing breaker (diagonal + arc + circling arrow)\n | \"sectionalizer\" // Sectionalizer (diagonal + \"S\" designation)\n | \"fuse\" // Expulsion fuse cutout (diagonal in oval)\n | \"fuse_cl\" // Current-limiting fuse (diagonal in rect)\n\n // ── Protection & Monitoring ───────────────────────────────────\n | \"ct\" // Current transformer (small circle + CT + line through)\n | \"pt\" // Potential/voltage transformer (small circle + PT)\n | \"relay\" // Protection relay (small circle + ANSI device number)\n | \"surge_arrester\" // Surge arrester / lightning arrester (downward arrow + ground)\n | \"ground_fault\" // Ground fault detector (GFI)\n\n // ── Loads & Equipment ─────────────────────────────────────────\n | \"motor\" // Motor (circle + M + 3-phase dots)\n | \"load\" // Generic load (rectangle)\n | \"capacitor_bank\" // Capacitor bank (two plates + switch)\n | \"harmonic_filter\" // Passive harmonic filter (LC symbol)\n | \"vfd\" // Variable frequency drive (rect + \"VFD\")\n\n // ── Metering ──────────────────────────────────────────────────\n | \"watthour_meter\" // Energy meter (circle + Wh)\n | \"demand_meter\" // Demand meter (circle + D);\n\nexport interface SLDNode {\n id: string;\n nodeType: SLDNodeType;\n label?: string;\n /** Voltage level e.g. \"13.8kV\", \"480V\" */\n voltage?: string;\n /** Equipment rating e.g. \"1000A\", \"500kVA\" */\n rating?: string;\n /** ANSI device number (relays: 51, 87, 27, etc.) */\n deviceNumber?: string;\n /** Additional nameplate data (transformer: kVA, ratio, %Z) */\n nameplate?: Record<string, string>;\n}\n\nexport interface SLDConnection {\n from: string;\n to: string;\n /** Cable specification e.g. \"3#2/0 AWG\" */\n cable?: string;\n label?: string;\n}\n\n/**\n * Symbol standard for SLD / circuit glyphs. `ansi` (IEEE 315 / ANSI Y32.2) is\n * the default and preserves historical rendering. `iec` (IEC 60617) switches to\n * IEC symbol forms. `abnt` (Brazil, NBR 5410) and `as-nzs` (Australia/NZ,\n * AS/NZS 3000) are IEC 60364-family presets: they reuse the IEC glyphs and add\n * their own jurisdiction labelling.\n */\nexport type SLDStandard = \"ansi\" | \"iec\" | \"abnt\" | \"as-nzs\";\n\n/** True for standards that render with the IEC 60617 glyph set. */\nexport function isIecFamily(standard: SLDStandard | undefined): boolean {\n return standard === \"iec\" || standard === \"abnt\" || standard === \"as-nzs\";\n}\n\nexport interface SLDAST {\n type: \"sld\";\n title?: string;\n /** Symbol standard (default `ansi`). */\n standard?: SLDStandard;\n nodes: SLDNode[];\n connections: SLDConnection[];\n metadata?: Record<string, string>;\n}\n\n// ─── Entity Structure Types ─────────────────────────────────\n\nexport type EntityType =\n | \"corp\"\n | \"llc\"\n | \"lp\"\n | \"trust\"\n | \"individual\"\n | \"foundation\"\n | \"disregarded\"\n | \"pool\"\n | \"placeholder\";\n\nexport type EntityStatus = \"normal\" | \"new\" | \"eliminated\" | \"modified\";\n\nexport interface EntityNode {\n id: string;\n name: string;\n entityType: EntityType;\n /** ISO 3166-1 alpha-2 or 2-3 letter state code (DE, IE, KY, BVI, ...) */\n jurisdiction?: string;\n status?: EntityStatus;\n taxClass?: string;\n role?: string;\n note?: string;\n formationDate?: string;\n properties?: Record<string, string>;\n}\n\nexport type EntityEdgeOp =\n | \"ownership\" // -> solid black arrow (default)\n | \"voting\" // ==> double line (voting-only control)\n | \"pool\" // -.-> dashed grey (option pool)\n | \"license\" // -~-> purple dashed (IP license / management)\n | \"distribution\"; // --> green dashed (trust distribution)\n\nexport interface EntityEdge {\n from: string;\n to: string;\n op: EntityEdgeOp;\n /** Raw percentage text, e.g. \"100%\" or \"V 75% / E 50%\" or \"was 40% → 100%\" */\n percentage?: string;\n /** Share class label (Series A Pref, Common, Option Pool) */\n shareClass?: string;\n label?: string;\n}\n\nexport interface JurisdictionDef {\n code: string;\n name: string;\n color?: string;\n}\n\nexport interface ClusterDef {\n id: string;\n label: string;\n /** Entity ids (explicit members) */\n members: string[];\n color?: string;\n}\n\nexport interface EntityAST {\n type: \"entity\";\n title?: string;\n entities: EntityNode[];\n edges: EntityEdge[];\n jurisdictions: JurisdictionDef[];\n clusters: ClusterDef[];\n metadata?: Record<string, string>;\n}\n\n// ─── ERD (Entity-Relationship Diagram) Types ─────────────────\n// 27-ERD-STANDARD — crow's foot first. Chen / Barker deferred.\n\nexport type ErdNotation = \"crowsfoot\" | \"chen\" | \"barker\";\n\n/** Min..Max cardinality for one end of a relationship. */\nexport type ErdCardinality =\n | \"one-mandatory\" // 1..1 ─┃\n | \"one-optional\" // 0..1 ─○\n | \"many-mandatory\" // 1..N ─┃<\n | \"many-optional\"; // 0..N ─○<\n\n/** Attribute / column row within a tabular entity (crow's foot mode). */\nexport interface ErdAttribute {\n name: string;\n /** Free-form type token, e.g. \"int\", \"varchar(255)\", \"timestamp\" — rendered verbatim. */\n type?: string;\n pk?: boolean;\n fk?: boolean;\n uk?: boolean;\n /** NOT NULL marker. */\n notNull?: boolean;\n /** FK target as \"TableName.columnName\" (parser canonicalizes inline `FK -> X.y` here). */\n fkTarget?: string;\n /** Optional in-line comment / description. */\n comment?: string;\n}\n\nexport interface ErdEntity {\n id: string;\n /** Display name (defaults to id when not separately quoted). */\n name: string;\n attributes: ErdAttribute[];\n /** Reserved for Chen mode (weak entity). Ignored in crow's foot rendering. */\n weak?: boolean;\n}\n\nexport interface ErdRef {\n /** \"TableName\" or \"TableName.columnName\". */\n from: string;\n to: string;\n fromCard: ErdCardinality;\n toCard: ErdCardinality;\n /** \"--\" identifying (solid). \"..\": non-identifying (dashed). */\n identifying: boolean;\n label?: string;\n}\n\nexport interface ErdAst {\n type: \"erd\";\n notation: ErdNotation;\n direction: \"LR\" | \"TB\";\n title?: string;\n entities: ErdEntity[];\n refs: ErdRef[];\n}\n\n/** Per-attribute-row geometry inside a laid-out entity. */\nexport interface ErdLayoutRow {\n attribute: ErdAttribute;\n /** y offset relative to entity top, where the row's vertical center sits. */\n yCenter: number;\n}\n\nexport interface ErdLayoutEntity {\n entity: ErdEntity;\n x: number;\n y: number;\n width: number;\n height: number;\n /** y coordinate of the header bar baseline (relative to entity top). */\n headerHeight: number;\n rows: ErdLayoutRow[];\n}\n\nexport interface ErdLayoutEdge {\n ref: ErdRef;\n /** Orthogonal SVG path data (\"M ... L ... L ...\"). */\n path: string;\n /** Center coords of the source-end glyph anchor (just outside the entity edge). */\n fromAnchor: { x: number; y: number; side: \"left\" | \"right\" | \"top\" | \"bottom\" };\n toAnchor: { x: number; y: number; side: \"left\" | \"right\" | \"top\" | \"bottom\" };\n /** Optional label position (mid-segment). */\n labelAt?: { x: number; y: number };\n}\n\nexport interface ErdLayoutResult {\n ast: ErdAst;\n entities: ErdLayoutEntity[];\n edges: ErdLayoutEdge[];\n width: number;\n height: number;\n}\n\n// ── EE Plugin union type (for type-narrowing in plugins) ──────\n\nexport type EEDiagramAST =\n | TimingAST\n | LogicGateAST\n | CircuitAST\n | BlockAST\n | LadderAST\n | SLDAST;\n\n// ─── Venn / Euler Diagram Types ──────────────────────────────\n\nexport type VennDiagramMode = \"auto\" | \"venn\" | \"euler\";\nexport type VennPalette = \"default\" | \"brand\" | \"monochrome\";\nexport type VennBlendMode = \"multiply\" | \"screen\" | \"none\";\nexport type VennEulerRelationType = \"subset\" | \"disjoint\" | \"overlap\";\n\n/** Raw value attached to a region. */\nexport type VennRegionValue =\n | { kind: \"integer\"; value: number }\n | { kind: \"percent\"; value: number }\n | { kind: \"text\"; value: string }\n | { kind: \"list\"; value: string[] }\n | { kind: \"none\" };\n\n/** One set (a circle or ellipse in the diagram). */\nexport interface VennSet {\n id: string;\n label: string;\n /** Optional explicit elements (enumeration DSL). */\n elements?: string[];\n /** Override color (hex). */\n color?: string;\n}\n\n/** A named region. `sets` is the subset of set ids that define it (at least one). */\nexport interface VennRegion {\n /** Sorted list of set ids that belong to the intersection (e.g. [\"A\",\"B\"]). */\n sets: string[];\n /** Does this region mean \"only\" these sets (exclude any other set)? */\n only: boolean;\n /** Value payload attached to the region. */\n value: VennRegionValue;\n}\n\nexport interface VennEulerRelation {\n from: string;\n to: string;\n type: VennEulerRelationType;\n}\n\nexport interface VennConfig {\n mode: VennDiagramMode;\n proportional: boolean;\n palette: VennPalette;\n blendMode: VennBlendMode;\n showCounts: boolean | \"auto\";\n showPercent: boolean;\n}\n\nexport interface VennAST {\n type: \"venn\";\n title?: string;\n sets: VennSet[];\n regions: VennRegion[];\n relations: VennEulerRelation[];\n config: VennConfig;\n metadata?: Record<string, string>;\n}\n\n/** Circle geometry (n=2, n=3 and Euler). */\nexport interface VennCircle {\n id: string;\n cx: number;\n cy: number;\n r: number;\n}\n\n/** Ellipse geometry (n=4). */\nexport interface VennEllipse {\n id: string;\n cx: number;\n cy: number;\n rx: number;\n ry: number;\n /** Rotation in degrees around (cx,cy). */\n rotation: number;\n}\n\nexport type VennShape =\n | ({ kind: \"circle\" } & VennCircle)\n | ({ kind: \"ellipse\" } & VennEllipse);\n\nexport interface VennLabelPosition {\n /** Region this label describes (sorted set ids). */\n sets: string[];\n /** Canonical label text (e.g. \"A ∩ B\", \"42\", \"[a,b,c]\"). */\n label: string;\n /** Centroid x / y (inside or external). */\n x: number;\n y: number;\n /** If true, label is placed outside the region and `leader` is populated. */\n external: boolean;\n /** Optional leader line endpoints (from region-interior → label). */\n leader?: { x1: number; y1: number; x2: number; y2: number };\n /** Text anchor for external labels. */\n anchor?: \"start\" | \"middle\" | \"end\";\n}\n\nexport interface VennLayoutResult {\n width: number;\n height: number;\n /** Rendering mode chosen (venn or euler; upset deferred). */\n mode: \"venn\" | \"euler\";\n /** Shape per set id (circles for n=2/3/euler, ellipses for n=4). */\n shapes: VennShape[];\n /** Region labels + placements. */\n labels: VennLabelPosition[];\n /** Set-title positions (one per set). */\n setLabels: Array<{ id: string; label: string; x: number; y: number; anchor: \"start\" | \"middle\" | \"end\" }>;\n /** Title placement (optional). */\n title?: { text: string; x: number; y: number };\n /** Proportional-solve residual (0 if not proportional). */\n proportionalResidual?: number;\n}\n// ─── Flowchart Types ─────────────────────────────────────────\n\nexport type FlowchartDirection = \"TB\" | \"BT\" | \"LR\" | \"RL\";\n\n/**\n * Shape keyword catalog. M1 implements only the first 5; the rest are reserved\n * for M2 so AST/types don't have to be rewritten later.\n */\nexport type FlowchartShape =\n // M1 core shapes\n | \"rect\"\n | \"round\"\n | \"stadium\"\n | \"diamond\"\n | \"parallelogram\"\n // M2 (declared for forward-compat; parser accepts them but may fall back to \"rect\")\n | \"parallelogram-alt\"\n | \"trapezoid\"\n | \"trapezoid-alt\"\n | \"subroutine\"\n | \"cylinder\"\n | \"circle\"\n | \"double-circle\"\n | \"hexagon\"\n | \"asymmetric\";\n\nexport type FlowchartEdgeKind =\n | \"solid\" // -->\n | \"none\" // ---\n | \"dotted\" // -.->\n | \"thick\" // ==>\n | \"bidirectional\" // <-->\n | \"crossed\" // --x\n | \"round-end\"; // --o\n\nexport type FlowchartArrowEnd = \"none\" | \"arrow\" | \"circle\" | \"cross\";\n\nexport interface FlowchartNode {\n id: string;\n label: string;\n shape: FlowchartShape;\n icon?: string;\n classes?: string[];\n /** Inline CSS overrides from `style nodeId fill:#f9f,...` */\n style?: Record<string, string>;\n /** Containing subgraph id (undefined = root) */\n parent?: string;\n}\n\nexport interface FlowchartEdge {\n id?: string;\n from: string;\n to: string;\n kind: FlowchartEdgeKind;\n label?: string;\n arrowStart?: FlowchartArrowEnd;\n arrowEnd?: FlowchartArrowEnd;\n classes?: string[];\n /** Reversed during cycle-removal (renderer must flip visual arrow) */\n isReversed?: boolean;\n}\n\nexport interface FlowchartSubgraph {\n id: string;\n label: string;\n direction?: FlowchartDirection;\n children: string[];\n subgraphs: string[];\n classes?: string[];\n}\n\nexport interface FlowchartClassDef {\n id: string;\n props: Record<string, string>;\n}\n\nexport interface FlowchartAST {\n type: \"flowchart\";\n title?: string;\n direction: FlowchartDirection;\n nodes: FlowchartNode[];\n edges: FlowchartEdge[];\n subgraphs: FlowchartSubgraph[];\n classDefs: FlowchartClassDef[];\n /** linkStyle index → css-ish props. Parsed in M1, applied in M2. */\n linkStyles: Map<number, Record<string, string>>;\n metadata?: Record<string, string>;\n}\n\nexport interface FlowchartLayoutNode {\n node: FlowchartNode;\n x: number;\n y: number;\n width: number;\n height: number;\n /** 0-based layer index (top for TB, left for LR) */\n layer: number;\n /** Position within the layer (0-based) */\n order: number;\n /** Dummy routing node inserted for long edges */\n isDummy?: boolean;\n}\n\nexport interface FlowchartLayoutEdge {\n edge: FlowchartEdge;\n /** SVG path d attribute */\n path: string;\n /** Label anchor with optional text-anchor hint for proper line clearance */\n labelAnchor?: { x: number; y: number; textAnchor?: \"start\" | \"middle\" | \"end\" };\n /** Position in `ast.edges` (declaration order) — used by linkStyle index targeting */\n index?: number;\n}\n\nexport interface FlowchartLayoutCluster {\n subgraph: FlowchartSubgraph;\n x: number;\n y: number;\n width: number;\n height: number;\n depth: number;\n}\n\nexport interface FlowchartLayoutResult {\n width: number;\n height: number;\n direction: FlowchartDirection;\n nodes: FlowchartLayoutNode[];\n edges: FlowchartLayoutEdge[];\n clusters: FlowchartLayoutCluster[];\n}\n\n// ─── Mindmap Types ──────────────────────────────────────────\n\nexport type MindmapStyle = \"map\" | \"logic-right\";\n\n/**\n * Inline markdown token for mindmap labels. Parsed once at parse-time by\n * `inline.ts`, consumed by layout (width measurement) and renderer (tspan\n * emission). See `docs/reference/00-OVERVIEW.md` for the DSL contract.\n */\nexport type InlineToken =\n | { kind: \"text\"; value: string; bold?: boolean; italic?: boolean }\n | { kind: \"code\"; value: string }\n | { kind: \"link\"; href: string; value: InlineToken[] }\n | { kind: \"checkbox\"; checked: boolean };\n\nexport interface MindmapNode {\n id: string;\n /** Raw label text (post-bullet-marker, pre-tokenize) — kept for title/tooltip. */\n label: string;\n /** Tokenized label. Layout & renderer consume this. */\n tokens: InlineToken[];\n depth: number;\n children: MindmapNode[];\n}\n\nexport interface MindmapAST {\n type: \"mindmap\";\n title?: string;\n style: MindmapStyle;\n root: MindmapNode;\n /** Theme override from DSL `%% theme:` directive. */\n themeOverride?: string;\n /** Max wrap width for labels (px). Default 240. From `%% maxLabelWidth:`. */\n maxLabelWidth: number;\n}\n\nexport interface MindmapLayoutNode {\n node: MindmapNode;\n x: number;\n y: number;\n /** \"center\" for root; \"left\"/\"right\" for map style; \"right\" for logic-right. */\n side: \"left\" | \"right\" | \"center\";\n /** Main-branch index (0..N-1); -1 for root. Drives palette. */\n branchIndex: number;\n labelWidth: number;\n labelHeight: number;\n /** Font size chosen for this node — used by renderer + for per-line measurement. */\n fontSize: number;\n /** Wrapped token lines. Always at least one entry. */\n lines: MindmapLabelLine[];\n}\n\nexport interface MindmapLabelLine {\n tokens: InlineToken[];\n width: number;\n}\n\nexport interface MindmapLayoutEdge {\n from: string;\n to: string;\n path: string;\n color: string;\n width: number;\n}\n\nexport interface MindmapLayoutResult {\n width: number;\n height: number;\n style: MindmapStyle;\n nodes: MindmapLayoutNode[];\n edges: MindmapLayoutEdge[];\n title?: string;\n}\n\n// ─── Breadboard / Physical Wiring Types ─────────────────────\n\n/**\n * Breadboard form factor:\n * - \"mini\" 170 tie-points, 17 cols × 5+5 rows, no power rails\n * - \"half\" 400 tie-points, 30 cols, 2 rail pairs (continuous)\n * - \"full\" 830 tie-points, 63 cols, 2 rail pairs (broken at col 30/31)\n */\nexport type BreadboardForm = \"mini\" | \"half\" | \"full\";\n\n/** Power-rail half: top vs bottom edge of board, positive vs negative stripe. */\nexport type BreadboardRail = \"+t\" | \"-t\" | \"+b\" | \"-b\";\n\n/** Breadboard hole address — main grid (col + row) or rail (col + rail). */\nexport type BreadboardCoord =\n | { kind: \"hole\"; col: number; row: \"a\" | \"b\" | \"c\" | \"d\" | \"e\" | \"f\" | \"g\" | \"h\" | \"i\" | \"j\" }\n | { kind: \"rail\"; rail: BreadboardRail; col: number };\n\n/** Off-board MCU placement (relative to breadboard substrate). */\nexport type BreadboardSidePlacement = \"beside-left\" | \"beside-right\" | \"above\" | \"below\";\n\n/** Where a part lives. Either a span across the grid (resistor, led, dip) or a side placement (uno). */\nexport type BreadboardPlacement =\n | { kind: \"point\"; at: BreadboardCoord }\n | { kind: \"span\"; from: BreadboardCoord; to: BreadboardCoord }\n | { kind: \"side\"; side: BreadboardSidePlacement };\n\n/** Catalog of v0.1 part kinds. */\nexport type BreadboardPartKind =\n | \"resistor\"\n | \"led\"\n | \"cap-elec\"\n | \"cap-ceramic\"\n | \"diode\"\n | \"button\"\n | \"dip\"\n | \"header\"\n | \"mcu-uno\"\n | \"mcu-nano\"\n | \"mcu-esp32\"\n | \"mcu-pico\"\n | \"sensor-hcsr04\"\n | \"sensor-dht11\"\n | \"sensor-dht22\"\n | \"display-oled-ssd1306\"\n | \"display-lcd-1602-i2c\"\n | \"module-rotary-ky040\"\n | \"actuator-servo-sg90\";\n\nexport interface BreadboardPart {\n /** User-assigned id (e.g. \"uno\", \"r1\"). */\n id: string;\n kind: BreadboardPartKind;\n /** Optional kind-specific args. e.g. resistor.value=\"220\", dip.pins=8, led.color=\"red\". */\n args: Record<string, string | number>;\n placement: BreadboardPlacement;\n /** Optional inline label drawn near the part body. */\n label?: string;\n}\n\nexport type BreadboardWireColor =\n | \"red\"\n | \"black\"\n | \"blue\"\n | \"yellow\"\n | \"orange\"\n | \"green\"\n | \"white\"\n | \"purple\"\n | \"brown\"\n | \"grey\";\n\n/** Wire endpoint — either a part pin or a board hole/rail. */\nexport type BreadboardEndpoint =\n | { kind: \"pin\"; partId: string; pin: string }\n | { kind: \"coord\"; at: BreadboardCoord };\n\nexport interface BreadboardWire {\n from: BreadboardEndpoint;\n to: BreadboardEndpoint;\n color: BreadboardWireColor;\n /** Optional intermediate hole that biases the Bézier control points. */\n via?: BreadboardCoord;\n}\n\nexport interface BreadboardAst {\n type: \"breadboard\";\n board: BreadboardForm;\n title?: string;\n parts: BreadboardPart[];\n wires: BreadboardWire[];\n}\n\n/** Resolved part box on (or beside) the substrate. */\nexport interface BreadboardLayoutPart {\n part: BreadboardPart;\n /** Top-left x of bounding box in canvas px. */\n x: number;\n y: number;\n width: number;\n height: number;\n /** For span/point parts: rotation angle in degrees (currently 0 or 90). */\n rotation: number;\n /** Resolved pin centers in canvas px, keyed by pin name. */\n pins: Record<string, { x: number; y: number }>;\n}\n\nexport interface BreadboardLayoutWire {\n wire: BreadboardWire;\n /** Cubic Bézier path \"M x1 y1 C cx1 cy1 cx2 cy2 x2 y2\". */\n path: string;\n /** Endpoint dots (rendered as small filled circles). */\n fromXY: { x: number; y: number };\n toXY: { x: number; y: number };\n color: BreadboardWireColor;\n}\n\nexport interface BreadboardLayoutSubstrate {\n /** Top-left of board substrate. */\n x: number;\n y: number;\n width: number;\n height: number;\n /** Hole pitch in px (default 14). */\n pitch: number;\n /** Number of columns (17 / 30 / 63). */\n cols: number;\n /** Whether rails exist on this form. */\n hasRails: boolean;\n /** Whether rails break at col 30/31 (full board only). */\n railsBreak: boolean;\n /** Vertical center of the trough channel. */\n troughY: number;\n /** Width of trough channel (≈ pitch). */\n troughHeight: number;\n}\n\nexport interface BreadboardLayoutResult {\n ast: BreadboardAst;\n substrate: BreadboardLayoutSubstrate;\n parts: BreadboardLayoutPart[];\n wires: BreadboardLayoutWire[];\n width: number;\n height: number;\n}\n\n// ─── BPMN AST Types (25-BPMN-STANDARD) ─────────────────────\n\n/** Direction the process flows. LR is conventional. */\nexport type BpmnDirection = \"LR\" | \"TB\";\n\n/** BPMN event lifecycle role — encoded in stroke weight. */\nexport type BpmnEventKind = \"start\" | \"intermediate\" | \"end\";\n\n/** Trigger types (inner glyph). v0.1 supports the common subset. */\nexport type BpmnEventTrigger = \"none\" | \"message\" | \"timer\";\n\n/** Filled glyph = throw, unfilled = catch. v0.1 derives this from kind+context. */\nexport type BpmnEventThrowCatch = \"throw\" | \"catch\";\n\nexport interface BpmnEvent {\n id: string;\n kind: BpmnEventKind;\n trigger: BpmnEventTrigger;\n /** Filled (throw) vs unfilled (catch). End events with a trigger throw; intermediate without context catch. */\n throwCatch: BpmnEventThrowCatch;\n label?: string;\n /** Owning lane id, set by parser. */\n laneId: string;\n /** Owning pool id. */\n poolId: string;\n}\n\n/** Activity (rounded rectangle) — v0.1 covers task and collapsed subprocess. */\nexport type BpmnActivityKind = \"task\" | \"subprocess-collapsed\";\n\n/** Task type marker (top-left small icon). */\nexport type BpmnTaskMarker =\n | \"abstract\"\n | \"user\"\n | \"service\"\n | \"send\"\n | \"receive\"\n | \"manual\"\n | \"script\";\n\nexport interface BpmnActivity {\n id: string;\n kind: BpmnActivityKind;\n marker: BpmnTaskMarker;\n label: string;\n laneId: string;\n poolId: string;\n}\n\n/** Gateway types — diamond inner glyph. */\nexport type BpmnGatewayKind = \"xor\" | \"or\" | \"and\" | \"event\";\n\nexport interface BpmnGateway {\n id: string;\n gatewayKind: BpmnGatewayKind;\n label?: string;\n laneId: string;\n poolId: string;\n}\n\nexport type BpmnFlowObject = BpmnEvent | BpmnActivity | BpmnGateway;\n\n/** Connector kinds — sequence/conditional/default within a pool, message across pools. */\nexport type BpmnFlowKind = \"sequence\" | \"conditional\" | \"default\" | \"message\";\n\nexport interface BpmnFlow {\n /** Source flow-object id, OR a pool name (for message flows from a black-box pool). */\n from: string;\n /** Target flow-object id, OR a pool name. */\n to: string;\n kind: BpmnFlowKind;\n label?: string;\n}\n\nexport interface BpmnLane {\n id: string;\n label: string;\n poolId: string;\n /** Ordered child object ids (events / activities / gateways). */\n children: string[];\n}\n\nexport interface BpmnPool {\n id: string;\n label: string;\n /** Black-box pools must contain no flow objects. */\n blackbox: boolean;\n /** Lane ids in display order. Empty for blackbox. */\n lanes: string[];\n}\n\nexport interface BpmnAst {\n type: \"bpmn\";\n direction: BpmnDirection;\n title?: string;\n pools: BpmnPool[];\n lanes: BpmnLane[];\n events: BpmnEvent[];\n activities: BpmnActivity[];\n gateways: BpmnGateway[];\n flows: BpmnFlow[];\n}\n\n// ─── BPMN Layout Types ─────────────────────────────────────\n\nexport interface BpmnLayoutObject {\n obj: BpmnFlowObject;\n /** Top-left corner of the object's bounding box. */\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport interface BpmnLayoutLane {\n lane: BpmnLane;\n /** Lane band geometry (interior, label band excluded). */\n x: number;\n y: number;\n width: number;\n height: number;\n /** X position of the lane label band (rotated text). */\n labelX: number;\n labelY: number;\n labelHeight: number;\n}\n\nexport interface BpmnLayoutPool {\n pool: BpmnPool;\n /** Pool outer geometry (includes pool label band on the left). */\n x: number;\n y: number;\n width: number;\n height: number;\n /** Pool label band geometry (rotated text on the left). */\n labelX: number;\n labelY: number;\n labelWidth: number;\n}\n\nexport interface BpmnLayoutFlow {\n flow: BpmnFlow;\n /** Manhattan polyline path data. */\n path: string;\n /** Anchor for label rendering. */\n labelAnchor?: { x: number; y: number };\n}\n\nexport interface BpmnLayoutResult {\n ast: BpmnAst;\n pools: BpmnLayoutPool[];\n lanes: BpmnLayoutLane[];\n objects: BpmnLayoutObject[];\n flows: BpmnLayoutFlow[];\n width: number;\n height: number;\n}\n\n// ─── FBD (Function Block Diagram) Types ─────────────────────\n// IEC 61131-3 §6.4 — function blocks wired through named ports.\n// See docs/reference/23-FBD-STANDARD.md.\n\n/** IEC 61131-3 standard data types (subset used for wire coloring + display). */\nexport type FbdDataType =\n | \"bool\"\n | \"int\" | \"dint\" | \"uint\" | \"udint\"\n | \"real\" | \"lreal\"\n | \"time\" | \"date\" | \"tod\"\n | \"string\" | \"wstring\"\n | \"byte\" | \"word\" | \"dword\"\n | \"timer\" | \"counter\"\n | \"any\";\n\n/** Variable scope (IEC 61131-3 §2.4.3). */\nexport type FbdVarScope =\n | \"local\"\n | \"input\"\n | \"output\"\n | \"in_out\"\n | \"global\"\n | \"external\";\n\nexport interface FbdVarDecl {\n name: string;\n scope: FbdVarScope;\n dataType: FbdDataType | string; // user-defined FB type as opaque string\n initValue?: string;\n /** True if the type is a user-defined function block (not a primitive type). */\n isUserFb?: boolean;\n}\n\n/** Standard function block / function names (uppercase). The renderer knows how to draw each. */\nexport type FbdStdBlockName =\n | \"AND\" | \"OR\" | \"NOT\" | \"NAND\" | \"NOR\" | \"XOR\" | \"XNOR\" | \"BUF\"\n | \"R_TRIG\" | \"F_TRIG\" | \"SR\" | \"RS\"\n | \"TON\" | \"TOF\" | \"TP\"\n | \"CTU\" | \"CTD\"\n | \"ADD\" | \"SUB\" | \"MUL\" | \"DIV\" | \"MOD\"\n | \"ABS\" | \"NEG\" | \"MOVE\"\n | \"EQ\" | \"NE\" | \"GT\" | \"GE\" | \"LT\" | \"LE\"\n | \"SEL\" | \"MUX\" | \"MAX\" | \"MIN\" | \"LIMIT\";\n\nexport type FbdPortSide = \"in\" | \"out\";\n\nexport interface FbdPort {\n name: string;\n side: FbdPortSide;\n dataType: FbdDataType;\n /** Inline constant on input ports (e.g. `T#5s`, `5`, `TRUE`). When set, no incoming wire. */\n constant?: string;\n /** Negation bubble on this port. */\n negated?: boolean;\n}\n\nexport interface FbdBlock {\n /** Optional user-given instance tag (italic above header). */\n instance?: string;\n /** Type — standard name or user-defined FB type. */\n blockType: string;\n /** True if blockType is one of FbdStdBlockName. */\n isStd: boolean;\n /** Ports in declaration order (top-to-bottom on each side). */\n ports: FbdPort[];\n /** Network this block belongs to. */\n networkIndex: number;\n /** Synthetic id for wire references (`block-N` or instance). */\n id: string;\n}\n\nexport interface FbdWire {\n /** Source: either `{block: id, port: name}` or `{var: name}` (declared variable). */\n from: { kind: \"port\"; blockId: string; portName: string } | { kind: \"var\"; name: string };\n /** Sink. */\n to: { kind: \"port\"; blockId: string; portName: string } | { kind: \"var\"; name: string };\n /** Inferred from source port. */\n dataType: FbdDataType;\n /** Negation bubble at sink end (for `~`). */\n negatedAtSink?: boolean;\n}\n\nexport interface FbdNetwork {\n index: number;\n title?: string;\n blocks: FbdBlock[];\n wires: FbdWire[];\n}\n\nexport interface FbdAst {\n type: \"fbd\";\n title?: string;\n variables: FbdVarDecl[];\n networks: FbdNetwork[];\n}\n\n// ─── FBD Layout Types ────────────────────────────────────────\n\nexport interface FbdLayoutPort {\n name: string;\n side: FbdPortSide;\n /** Absolute x of the port end (port_stub_length out from block edge). */\n x: number;\n y: number;\n /** Block-edge x (port stub start). */\n edgeX: number;\n dataType: FbdDataType;\n constant?: string;\n negated?: boolean;\n}\n\nexport interface FbdLayoutBlock {\n block: FbdBlock;\n x: number;\n y: number;\n width: number;\n height: number;\n ports: FbdLayoutPort[];\n}\n\nexport interface FbdLayoutWire {\n wire: FbdWire;\n /** SVG path \"d\" attribute (Manhattan polyline). */\n path: string;\n}\n\n/** Variable terminal: a small labeled box on the left (input vars) or right (output vars) of each network. */\nexport interface FbdLayoutVarTerm {\n name: string;\n x: number;\n y: number;\n width: number;\n height: number;\n side: \"left\" | \"right\";\n dataType: FbdDataType;\n}\n\nexport interface FbdLayoutNetwork {\n network: FbdNetwork;\n x: number;\n y: number;\n width: number;\n height: number;\n blocks: FbdLayoutBlock[];\n wires: FbdLayoutWire[];\n varTerms: FbdLayoutVarTerm[];\n /** Junction points (filled circles where one wire branches to multiple sinks). */\n junctions: { x: number; y: number }[];\n}\n\nexport interface FbdLayoutResult {\n ast: FbdAst;\n networks: FbdLayoutNetwork[];\n width: number;\n height: number;\n}\n\n// ─── SFC (Sequential Function Chart) Types ──────────────────\n// IEC 61131-3 §6.5 — steps + transitions with bars.\n// See docs/reference/24-SFC-STANDARD.md.\n\nexport type SfcStepKind = \"initial\" | \"normal\" | \"final\";\n\nexport type SfcActionQualifier =\n | \"N\" | \"S\" | \"R\" | \"L\" | \"D\" | \"P\" | \"P0\" | \"P1\" | \"SD\" | \"DS\" | \"SL\";\n\nexport interface SfcAction {\n qualifier: SfcActionQualifier;\n /** Action body — name reference or inline ST text. */\n body: string;\n /** Optional duration literal (T#5s) for L/D/SD/SL/DS qualifiers. */\n time?: string;\n}\n\nexport interface SfcStep {\n id: string;\n kind: SfcStepKind;\n /** Display label override; defaults to id. */\n label?: string;\n actions: SfcAction[];\n}\n\nexport interface SfcTransition {\n /** Optional explicit transition id (e.g. T_Reset). */\n id?: string;\n from: string;\n to: string;\n /** Boolean expression as raw text. */\n condition: string;\n}\n\nexport type SfcVarType =\n | \"bool\" | \"int\" | \"real\" | \"time\" | \"timer\" | \"counter\" | string;\n\nexport interface SfcVarDecl {\n name: string;\n dataType: SfcVarType;\n initValue?: string;\n}\n\n/** Branch group nodes — recursive AST for alt/sim regions. */\nexport type SfcNode =\n | { kind: \"step\"; stepId: string }\n | { kind: \"alt\"; branches: SfcAltBranch[]; mergeTo: string }\n | { kind: \"sim\"; condition: string; branches: SfcSimBranch[]; mergeTo: string; mergeCondition: string };\n\nexport interface SfcAltBranch {\n /** Optional priority (default = declaration order). */\n priority?: number;\n /** Entry transition condition (rendered between divergence bar and first step). */\n entryCondition: string;\n /** Inner steps in linear order. */\n body: SfcNode[];\n /** Exit transition condition (rendered between last step and convergence bar). */\n exitCondition: string;\n}\n\nexport interface SfcSimBranch {\n body: SfcNode[];\n}\n\nexport interface SfcAst {\n type: \"sfc\";\n title?: string;\n variables: SfcVarDecl[];\n steps: Map<string, SfcStep>;\n /** Top-level node sequence (linear chain with possibly branch nodes). */\n body: SfcNode[];\n /** All transitions — explicit ones from `transition` directives.\n * Branch entry/exit conditions live inside SfcAltBranch / SfcSimBranch. */\n transitions: SfcTransition[];\n}\n\n// ─── SFC Layout Types ──────────────────────────────────────\n\nexport interface SfcLayoutStep {\n step: SfcStep;\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport interface SfcLayoutAction {\n action: SfcAction;\n stepId: string;\n /** Index in step's action list. */\n index: number;\n x: number;\n y: number;\n width: number;\n height: number;\n qualifierWidth: number;\n}\n\nexport interface SfcLayoutTransition {\n transition: SfcTransition;\n /** Center of the transition bar. */\n cx: number;\n cy: number;\n /** Bar half-width — bar spans [cx-w, cx+w]. */\n w: number;\n /** Optional explicit id label (e.g. T_Reset). */\n id?: string;\n}\n\nexport type SfcBarKind = \"alt-div\" | \"alt-conv\" | \"sim-div\" | \"sim-conv\";\n\nexport interface SfcLayoutBar {\n kind: SfcBarKind;\n /** Horizontal extent. */\n x1: number;\n x2: number;\n y: number;\n}\n\nexport interface SfcLayoutWire {\n /** SVG path \"d\" — typically a vertical or L-shape. */\n path: string;\n /** Optional class hint (e.g. \"wire\", \"jump\"). */\n cls: \"wire\" | \"jump\";\n}\n\nexport interface SfcLayoutJump {\n fromStepId: string;\n toStepId: string;\n /** Polyline path including arrowhead. */\n path: string;\n /** Margin label position. */\n labelX: number;\n labelY: number;\n labelText: string;\n /** Condition text (rendered near the source). */\n condition?: string;\n}\n\nexport interface SfcLayoutResult {\n ast: SfcAst;\n steps: SfcLayoutStep[];\n actions: SfcLayoutAction[];\n transitions: SfcLayoutTransition[];\n bars: SfcLayoutBar[];\n wires: SfcLayoutWire[];\n jumps: SfcLayoutJump[];\n width: number;\n height: number;\n}\n","import type { SLDNodeType, SLDStandard } from \"../../core/types\";\nimport { isIecFamily } from \"../../core/types\";\nimport { el, group, line, path as pathEl, text as textEl } from \"../../core/svg\";\n\n/**\n * Symbol renderers — each returns SVG markup centered at (0,0)\n * Used by the renderer after applying transform=\"translate(cx,cy)\".\n *\n * Every symbol exposes a conceptual top/bottom terminal on the vertical axis,\n * so the layout only needs to draw vertical wires between them.\n */\n\nexport interface SymbolGeometry {\n /** Bounding half-width for layout */\n halfWidth: number;\n /** Y-offset of the top terminal (negative = above center) */\n topY: number;\n /** Y-offset of the bottom terminal (positive = below center) */\n bottomY: number;\n}\n\nexport const DEFAULT_GEOMETRY: SymbolGeometry = {\n halfWidth: 20,\n topY: -20,\n bottomY: 20,\n};\n\nexport function geometryFor(type: SLDNodeType): SymbolGeometry {\n switch (type) {\n case \"utility\":\n case \"generator\":\n case \"solar\":\n case \"wind\":\n return { halfWidth: 18, topY: -24, bottomY: 18 };\n case \"transformer\":\n case \"transformer_dy\":\n case \"transformer_yd\":\n case \"transformer_yy\":\n case \"transformer_dd\":\n case \"autotransformer\":\n case \"transformer_3winding\":\n return { halfWidth: 22, topY: -24, bottomY: 24 };\n case \"breaker\":\n case \"breaker_vacuum\":\n case \"recloser\":\n case \"switch\":\n case \"switch_load\":\n case \"ground_switch\":\n case \"sectionalizer\":\n return { halfWidth: 18, topY: -18, bottomY: 18 };\n case \"fuse\":\n case \"fuse_cl\":\n return { halfWidth: 14, topY: -18, bottomY: 18 };\n case \"motor\":\n return { halfWidth: 16, topY: -16, bottomY: 22 };\n case \"load\":\n case \"capacitor_bank\":\n case \"harmonic_filter\":\n return { halfWidth: 20, topY: -14, bottomY: 14 };\n case \"vfd\":\n case \"ups\":\n return { halfWidth: 24, topY: -18, bottomY: 18 };\n case \"ats\":\n return { halfWidth: 22, topY: -18, bottomY: 18 };\n case \"ct\":\n case \"pt\":\n return { halfWidth: 10, topY: -16, bottomY: 16 };\n case \"relay\":\n return { halfWidth: 12, topY: -12, bottomY: 12 };\n case \"surge_arrester\":\n return { halfWidth: 12, topY: -16, bottomY: 26 };\n case \"watthour_meter\":\n case \"demand_meter\":\n case \"ground_fault\":\n return { halfWidth: 14, topY: -14, bottomY: 14 };\n case \"bus\":\n return DEFAULT_GEOMETRY;\n case \"hub\":\n return { halfWidth: 52, topY: -20, bottomY: 20 };\n case \"bus_tie\":\n return { halfWidth: 16, topY: -10, bottomY: 10 };\n default:\n return DEFAULT_GEOMETRY;\n }\n}\n\nfunction lineEl(x1: number, y1: number, x2: number, y2: number, cls = \"lt-sld-stroke\"): string {\n return line({ x1, y1, x2, y2, class: cls });\n}\n\nfunction utilitySymbol(): string {\n return group({}, [\n el(\"circle\", { cx: 0, cy: 0, r: 16, class: \"lt-sld-fill\" }),\n pathEl({ d: \"M -8 0 Q -4 -8 0 0 Q 4 8 8 0\", class: \"lt-sld-stroke\", fill: \"none\" }),\n // lead wires in/out\n lineEl(0, -24, 0, -16),\n lineEl(0, 16, 0, 18),\n ]);\n}\n\nfunction generatorSymbol(): string {\n return group({}, [\n el(\"circle\", { cx: 0, cy: 0, r: 16, class: \"lt-sld-fill\" }),\n textEl({ x: 0, y: -2, class: \"lt-sld-symbol-text\", \"text-anchor\": \"middle\", \"font-weight\": \"bold\", \"font-size\": \"14\" }, \"G\"),\n pathEl({ d: \"M -6 6 Q -3 1 0 6 Q 3 11 6 6\", class: \"lt-sld-stroke\", fill: \"none\" }),\n lineEl(0, -24, 0, -16),\n lineEl(0, 16, 0, 18),\n ]);\n}\n\nfunction solarSymbol(): string {\n return group({}, [\n el(\"rect\", { x: -18, y: -12, width: 36, height: 24, class: \"lt-sld-fill\" }),\n lineEl(-18, -4, 18, -4),\n lineEl(-18, 4, 18, 4),\n lineEl(-6, -12, -6, 12),\n lineEl(6, -12, 6, 12),\n lineEl(0, 12, 0, 18),\n ]);\n}\n\nfunction windSymbol(): string {\n return group({}, [\n el(\"circle\", { cx: 0, cy: 0, r: 6, class: \"lt-sld-fill\" }),\n lineEl(0, -6, 0, -22),\n pathEl({ d: \"M 0 -6 L 14 -2 L 0 0 Z\", class: \"lt-sld-fill-dark\" }),\n pathEl({ d: \"M 0 -6 L -10 8 L 0 2 Z\", class: \"lt-sld-fill-dark\" }),\n pathEl({ d: \"M 0 -6 L -6 -18 L 2 -6 Z\", class: \"lt-sld-fill-dark\" }),\n lineEl(0, 6, 0, 18),\n ]);\n}\n\nfunction upsSymbol(): string {\n return group({}, [\n el(\"rect\", { x: -22, y: -16, width: 44, height: 32, class: \"lt-sld-fill\" }),\n textEl({ x: 0, y: 4, class: \"lt-sld-symbol-text\", \"text-anchor\": \"middle\", \"font-weight\": \"bold\", \"font-size\": \"11\" }, \"UPS\"),\n ]);\n}\n\n/**\n * Transformer: two coil groups (three humps each) + polarity dots.\n * Optional winding labels (Δ or Y) are overlaid as compact glyphs.\n */\nfunction transformerSymbol(type: SLDNodeType): string {\n const pieces: string[] = [];\n // primary coil (top)\n pieces.push(\n pathEl({\n d: \"M -12 -18 A 4 4 0 0 1 -4 -18 A 4 4 0 0 1 4 -18 A 4 4 0 0 1 12 -18\",\n class: \"lt-sld-stroke\",\n fill: \"none\",\n })\n );\n // core lines\n pieces.push(lineEl(-14, -8, 14, -8));\n pieces.push(lineEl(-14, -4, 14, -4));\n // secondary coil (bottom, mirrored)\n pieces.push(\n pathEl({\n d: \"M -12 18 A 4 4 0 0 0 -4 18 A 4 4 0 0 0 4 18 A 4 4 0 0 0 12 18\",\n class: \"lt-sld-stroke\",\n fill: \"none\",\n })\n );\n // polarity dots\n pieces.push(el(\"circle\", { cx: -10, cy: -14, r: 2, class: \"lt-sld-dot\" }));\n pieces.push(el(\"circle\", { cx: 10, cy: 14, r: 2, class: \"lt-sld-dot\" }));\n // leads\n pieces.push(lineEl(0, -24, 0, -22));\n pieces.push(lineEl(0, 22, 0, 24));\n\n // Winding designators (Δ / Y / Yg)\n const { primary, secondary } = windingGlyphs(type);\n if (primary) pieces.push(textEl({ x: 20, y: -14, class: \"lt-sld-wdg\", \"text-anchor\": \"start\" }, primary));\n if (secondary) pieces.push(textEl({ x: 20, y: 18, class: \"lt-sld-wdg\", \"text-anchor\": \"start\" }, secondary));\n return group({}, pieces);\n}\n\nfunction windingGlyphs(type: SLDNodeType): { primary?: string; secondary?: string } {\n switch (type) {\n case \"transformer_dy\": return { primary: \"Δ\", secondary: \"Y\" };\n case \"transformer_yd\": return { primary: \"Y\", secondary: \"Δ\" };\n case \"transformer_yy\": return { primary: \"Y\", secondary: \"Y\" };\n case \"transformer_dd\": return { primary: \"Δ\", secondary: \"Δ\" };\n default: return {};\n }\n}\n\nfunction autotransformerSymbol(): string {\n return group({}, [\n pathEl({\n d: \"M 0 -20 A 6 6 0 0 1 0 -10 A 6 6 0 0 1 0 0 A 6 6 0 0 1 0 10 A 6 6 0 0 1 0 20\",\n class: \"lt-sld-stroke\",\n fill: \"none\",\n }),\n lineEl(6, 0, 14, 0),\n lineEl(0, -24, 0, -20),\n lineEl(0, 20, 0, 24),\n ]);\n}\n\nfunction threeWindingSymbol(): string {\n return group({}, [\n // top coil\n pathEl({ d: \"M -10 -18 A 3 3 0 0 1 -4 -18 A 3 3 0 0 1 2 -18 A 3 3 0 0 1 8 -18\", class: \"lt-sld-stroke\", fill: \"none\" }),\n // left-bottom coil\n pathEl({ d: \"M -18 6 A 3 3 0 0 1 -12 6 A 3 3 0 0 1 -6 6 A 3 3 0 0 1 0 6\", class: \"lt-sld-stroke\", fill: \"none\" }),\n // right-bottom coil\n pathEl({ d: \"M 0 6 A 3 3 0 0 1 6 6 A 3 3 0 0 1 12 6 A 3 3 0 0 1 18 6\", class: \"lt-sld-stroke\", fill: \"none\" }),\n lineEl(-14, -8, 14, -8),\n lineEl(0, -24, 0, -18),\n lineEl(-9, 10, -9, 24),\n lineEl(9, 10, 9, 24),\n ]);\n}\n\n/** Circuit breaker: diagonal line + top arc. */\nfunction breakerSymbol(): string {\n return group({}, [\n lineEl(0, -14, 0, -10, \"lt-sld-stroke\"),\n lineEl(0, 10, 0, 14, \"lt-sld-stroke\"),\n line({ x1: -6, y1: 10, x2: 8, y2: -10, class: \"lt-sld-stroke-thick\" }),\n pathEl({ d: \"M 8 -10 Q 14 -12 12 -18\", class: \"lt-sld-stroke\", fill: \"none\" }),\n lineEl(0, -18, 0, -14),\n lineEl(0, 14, 0, 18),\n ]);\n}\n\nfunction vacuumBreakerSymbol(): string {\n return group({}, [\n el(\"ellipse\", { cx: 0, cy: 0, rx: 10, ry: 14, class: \"lt-sld-fill\" }),\n line({ x1: -6, y1: 10, x2: 8, y2: -10, class: \"lt-sld-stroke-thick\" }),\n textEl({ x: -2, y: -4, class: \"lt-sld-symbol-text\", \"text-anchor\": \"middle\", \"font-size\": \"8\" }, \"V\"),\n lineEl(0, -18, 0, -14),\n lineEl(0, 14, 0, 18),\n ]);\n}\n\nfunction recloserSymbol(): string {\n return group({}, [\n line({ x1: -6, y1: 10, x2: 8, y2: -10, class: \"lt-sld-stroke-thick\" }),\n pathEl({ d: \"M 8 -10 Q 14 -12 12 -18\", class: \"lt-sld-stroke\", fill: \"none\" }),\n pathEl({ d: \"M 14 -6 A 5 5 0 1 1 18 -4\", class: \"lt-sld-stroke\", fill: \"none\" }),\n el(\"polygon\", { points: \"18,-4 20,-8 15,-7\", class: \"lt-sld-dot\" }),\n lineEl(0, -18, 0, -14),\n lineEl(0, 14, 0, 18),\n ]);\n}\n\nfunction switchSymbol(open = false): string {\n const pieces: string[] = [];\n if (open) {\n pieces.push(line({ x1: -6, y1: 10, x2: 10, y2: -8, class: \"lt-sld-stroke-thick\" }));\n pieces.push(el(\"circle\", { cx: 10, cy: -8, r: 2, class: \"lt-sld-fill\" }));\n } else {\n pieces.push(line({ x1: -6, y1: 10, x2: 8, y2: -10, class: \"lt-sld-stroke-thick\" }));\n }\n pieces.push(lineEl(0, -18, 0, -10));\n pieces.push(lineEl(0, 10, 0, 18));\n return group({}, pieces);\n}\n\nfunction loadSwitchSymbol(): string {\n return group({}, [\n line({ x1: -6, y1: 10, x2: 8, y2: -10, class: \"lt-sld-stroke-thick\" }),\n el(\"rect\", { x: 6, y: -14, width: 6, height: 6, class: \"lt-sld-fill\" }),\n lineEl(0, -18, 0, -10),\n lineEl(0, 10, 0, 18),\n ]);\n}\n\nfunction groundSwitchSymbol(): string {\n return group({}, [\n line({ x1: -6, y1: 0, x2: 8, y2: -14, class: \"lt-sld-stroke-thick\" }),\n lineEl(0, -18, 0, -4),\n // ground symbol\n lineEl(-8, 6, 8, 6),\n lineEl(-5, 10, 5, 10),\n lineEl(-2, 14, 2, 14),\n lineEl(0, 0, 0, 6),\n ]);\n}\n\nfunction sectionalizerSymbol(): string {\n return group({}, [\n line({ x1: -6, y1: 10, x2: 10, y2: -8, class: \"lt-sld-stroke-thick\" }),\n el(\"circle\", { cx: 10, cy: -8, r: 2, class: \"lt-sld-fill\" }),\n textEl({ x: 14, y: -4, class: \"lt-sld-wdg\", \"text-anchor\": \"start\" }, \"S\"),\n lineEl(0, -18, 0, -10),\n lineEl(0, 10, 0, 18),\n ]);\n}\n\nfunction fuseSymbol(): string {\n return group({}, [\n el(\"rect\", { x: -5, y: -10, width: 10, height: 20, class: \"lt-sld-fill\" }),\n lineEl(0, -18, 0, -10),\n lineEl(0, 10, 0, 18),\n ]);\n}\n\nfunction fuseCLSymbol(): string {\n return group({}, [\n el(\"rect\", { x: -6, y: -12, width: 12, height: 24, class: \"lt-sld-fill\" }),\n lineEl(-6, 0, 6, 0),\n lineEl(0, -18, 0, -12),\n lineEl(0, 12, 0, 18),\n ]);\n}\n\nfunction motorSymbol(): string {\n return group({}, [\n el(\"circle\", { cx: 0, cy: 0, r: 14, class: \"lt-sld-fill\" }),\n textEl({ x: 0, y: 5, class: \"lt-sld-symbol-text\", \"text-anchor\": \"middle\", \"font-weight\": \"bold\", \"font-size\": \"13\" }, \"M\"),\n lineEl(0, -16, 0, -14),\n // 3-phase dots at bottom\n el(\"circle\", { cx: -6, cy: 12, r: 1.5, class: \"lt-sld-dot\" }),\n el(\"circle\", { cx: 0, cy: 14, r: 1.5, class: \"lt-sld-dot\" }),\n el(\"circle\", { cx: 6, cy: 12, r: 1.5, class: \"lt-sld-dot\" }),\n ]);\n}\n\nfunction loadSymbol(): string {\n return group({}, [\n el(\"rect\", { x: -16, y: -12, width: 32, height: 24, class: \"lt-sld-fill\" }),\n ]);\n}\n\nfunction capacitorBankSymbol(): string {\n return group({}, [\n lineEl(-10, -6, 10, -6, \"lt-sld-stroke-thick\"),\n lineEl(-10, -2, 10, -2, \"lt-sld-stroke-thick\"),\n lineEl(-10, 4, 10, 4, \"lt-sld-stroke-thick\"),\n lineEl(-10, 8, 10, 8, \"lt-sld-stroke-thick\"),\n lineEl(0, -14, 0, -6),\n lineEl(0, 8, 0, 14),\n ]);\n}\n\nfunction harmonicFilterSymbol(): string {\n return group({}, [\n // L + C chained\n pathEl({ d: \"M -14 -4 A 3 3 0 0 1 -8 -4 A 3 3 0 0 1 -2 -4 A 3 3 0 0 1 4 -4\", class: \"lt-sld-stroke\", fill: \"none\" }),\n lineEl(4, -8, 14, -8),\n lineEl(4, 0, 14, 0),\n lineEl(0, -14, 0, -4),\n lineEl(0, 4, 0, 14),\n ]);\n}\n\nfunction vfdSymbol(): string {\n return group({}, [\n el(\"rect\", { x: -22, y: -16, width: 44, height: 32, class: \"lt-sld-fill\" }),\n textEl({ x: 0, y: -2, class: \"lt-sld-symbol-text\", \"text-anchor\": \"middle\", \"font-weight\": \"bold\", \"font-size\": \"11\" }, \"VFD\"),\n pathEl({ d: \"M -10 8 Q -5 2 0 8 Q 5 14 10 8\", class: \"lt-sld-stroke\", fill: \"none\" }),\n lineEl(0, -18, 0, -16),\n lineEl(0, 16, 0, 18),\n ]);\n}\n\nfunction atsSymbol(): string {\n return group({}, [\n el(\"rect\", { x: -22, y: -16, width: 44, height: 32, class: \"lt-sld-fill\" }),\n line({ x1: -14, y1: -8, x2: -2, y2: 6, class: \"lt-sld-stroke-thick\" }),\n line({ x1: 14, y1: -8, x2: 2, y2: 6, class: \"lt-sld-stroke-thick\" }),\n textEl({ x: 0, y: 14, class: \"lt-sld-symbol-text\", \"text-anchor\": \"middle\", \"font-weight\": \"bold\", \"font-size\": \"9\" }, \"ATS\"),\n lineEl(-12, -18, -12, -16),\n lineEl(12, -18, 12, -16),\n lineEl(0, 16, 0, 18),\n ]);\n}\n\nfunction ctSymbol(): string {\n return group({}, [\n el(\"circle\", { cx: 0, cy: 0, r: 7, class: \"lt-sld-fill\" }),\n textEl({ x: 0, y: 3, class: \"lt-sld-wdg\", \"text-anchor\": \"middle\", \"font-size\": \"7\" }, \"CT\"),\n lineEl(0, -16, 0, -7),\n lineEl(0, 7, 0, 16),\n ]);\n}\n\nfunction ptSymbol(): string {\n return group({}, [\n el(\"circle\", { cx: 0, cy: 0, r: 7, class: \"lt-sld-fill\" }),\n textEl({ x: 0, y: 3, class: \"lt-sld-wdg\", \"text-anchor\": \"middle\", \"font-size\": \"7\" }, \"PT\"),\n lineEl(0, -16, 0, -7),\n lineEl(0, 7, 0, 16),\n ]);\n}\n\nfunction relaySymbol(deviceNumber?: string): string {\n return group({}, [\n el(\"circle\", { cx: 0, cy: 0, r: 11, class: \"lt-sld-fill\" }),\n textEl({ x: 0, y: 4, class: \"lt-sld-wdg\", \"text-anchor\": \"middle\", \"font-size\": \"10\" }, deviceNumber ?? \"R\"),\n ]);\n}\n\nfunction surgeArresterSymbol(): string {\n return group({}, [\n el(\"rect\", { x: -7, y: -6, width: 14, height: 14, class: \"lt-sld-fill\" }),\n pathEl({ d: \"M -4 2 Q 0 -4 4 2\", class: \"lt-sld-stroke\", fill: \"none\" }),\n lineEl(0, -16, 0, -6),\n lineEl(0, 8, 0, 14),\n lineEl(-8, 14, 8, 14),\n lineEl(-5, 18, 5, 18),\n lineEl(-2, 22, 2, 22),\n ]);\n}\n\nfunction groundFaultSymbol(): string {\n return group({}, [\n el(\"circle\", { cx: 0, cy: 0, r: 12, class: \"lt-sld-fill\" }),\n textEl({ x: 0, y: 4, class: \"lt-sld-wdg\", \"text-anchor\": \"middle\", \"font-size\": \"9\" }, \"GFI\"),\n lineEl(0, -14, 0, -12),\n lineEl(0, 12, 0, 14),\n ]);\n}\n\nfunction hubSymbol(label?: string): string {\n return group({}, [\n el(\"rect\", {\n x: -50, y: -18, width: 100, height: 36,\n rx: 4, ry: 4,\n class: \"lt-sld-fill\",\n \"stroke-width\": 2,\n }),\n textEl(\n { x: 0, y: 4, class: \"lt-sld-wdg\", \"text-anchor\": \"middle\", \"font-size\": \"11\" },\n label ?? \"HUB\"\n ),\n lineEl(0, -20, 0, -18),\n lineEl(0, 18, 0, 20),\n // left/right lead stubs for lateral ports\n lineEl(-50, 0, -54, 0),\n lineEl(50, 0, 54, 0),\n ]);\n}\n\nfunction busTieSymbol(): string {\n // Horizontal breaker: two stubs + diagonal switch bar + arc above\n return group({}, [\n lineEl(-16, 0, -4, 0),\n lineEl(4, 0, 16, 0),\n pathEl({ d: \"M -4 0 L 4 -6\", class: \"lt-sld-stroke-thick\" }),\n pathEl({ d: \"M -4 -6 Q 0 -10 4 -6\", class: \"lt-sld-stroke\", fill: \"none\" }),\n ]);\n}\n\nfunction meterSymbol(label: string): string {\n return group({}, [\n el(\"circle\", { cx: 0, cy: 0, r: 12, class: \"lt-sld-fill\" }),\n textEl({ x: 0, y: 4, class: \"lt-sld-wdg\", \"text-anchor\": \"middle\", \"font-size\": \"9\" }, label),\n lineEl(0, -14, 0, -12),\n lineEl(0, 12, 0, 14),\n ]);\n}\n\n// ─── IEC 60617 symbol variants ──────────────────────────────\n// Only the devices whose IEC glyph differs recognisably from the IEEE-315\n// (ANSI) form are overridden here. Earth, knife-switch disconnectors, motors,\n// meters, etc. share the same primitive across both standards, so they fall\n// through to the shared renderers below.\n\n/** IEC two-winding transformer: two interlinked circles (vs ANSI coil humps). */\nfunction transformerSymbolIEC(type: SLDNodeType): string {\n const pieces: string[] = [\n el(\"circle\", { cx: 0, cy: -7, r: 11, class: \"lt-sld-stroke\" }),\n el(\"circle\", { cx: 0, cy: 7, r: 11, class: \"lt-sld-stroke\" }),\n lineEl(0, -24, 0, -18),\n lineEl(0, 18, 0, 24),\n ];\n const { primary, secondary } = windingGlyphs(type);\n if (primary) pieces.push(textEl({ x: 20, y: -10, class: \"lt-sld-wdg\", \"text-anchor\": \"start\" }, primary));\n if (secondary) pieces.push(textEl({ x: 20, y: 14, class: \"lt-sld-wdg\", \"text-anchor\": \"start\" }, secondary));\n return group({}, pieces);\n}\n\n/**\n * IEC circuit breaker: a contact arm whose fixed contact carries the `×`\n * breaking-function mark (vs the ANSI contact + quarter-arc).\n */\nfunction breakerSymbolIEC(): string {\n return group({}, [\n lineEl(0, -18, 0, -10),\n lineEl(0, 10, 0, 18),\n // open contact arm pivoting from the bottom terminal\n line({ x1: -6, y1: 10, x2: 6, y2: -8, class: \"lt-sld-stroke-thick\" }),\n // × at the fixed contact\n line({ x1: -4, y1: -13, x2: 4, y2: -7, class: \"lt-sld-stroke\" }),\n line({ x1: 4, y1: -13, x2: -4, y2: -7, class: \"lt-sld-stroke\" }),\n ]);\n}\n\n/** IEC fuse: rectangle with a conductor line through the long axis (vs ANSI plain box). */\nfunction fuseSymbolIEC(): string {\n return group({}, [\n el(\"rect\", { x: -5, y: -11, width: 10, height: 22, class: \"lt-sld-fill\" }),\n lineEl(0, -11, 0, 11),\n lineEl(0, -18, 0, -11),\n lineEl(0, 11, 0, 18),\n ]);\n}\n\n/** Main entry — render a node symbol at origin. */\nexport function renderSymbol(\n type: SLDNodeType,\n detail?: string,\n standard?: SLDStandard\n): string {\n if (isIecFamily(standard)) {\n switch (type) {\n case \"transformer\":\n case \"transformer_dy\":\n case \"transformer_yd\":\n case \"transformer_yy\":\n case \"transformer_dd\":\n return transformerSymbolIEC(type);\n case \"breaker\":\n return breakerSymbolIEC();\n case \"fuse\":\n return fuseSymbolIEC();\n }\n }\n switch (type) {\n case \"utility\": return utilitySymbol();\n case \"generator\": return generatorSymbol();\n case \"solar\": return solarSymbol();\n case \"wind\": return windSymbol();\n case \"ups\": return upsSymbol();\n case \"transformer\":\n case \"transformer_dy\":\n case \"transformer_yd\":\n case \"transformer_yy\":\n case \"transformer_dd\":\n return transformerSymbol(type);\n case \"autotransformer\": return autotransformerSymbol();\n case \"transformer_3winding\": return threeWindingSymbol();\n case \"breaker\": return breakerSymbol();\n case \"breaker_vacuum\": return vacuumBreakerSymbol();\n case \"recloser\": return recloserSymbol();\n case \"switch\": return switchSymbol(true);\n case \"switch_load\": return loadSwitchSymbol();\n case \"ground_switch\": return groundSwitchSymbol();\n case \"sectionalizer\": return sectionalizerSymbol();\n case \"fuse\": return fuseSymbol();\n case \"fuse_cl\": return fuseCLSymbol();\n case \"motor\": return motorSymbol();\n case \"load\": return loadSymbol();\n case \"capacitor_bank\": return capacitorBankSymbol();\n case \"harmonic_filter\": return harmonicFilterSymbol();\n case \"vfd\": return vfdSymbol();\n case \"ats\": return atsSymbol();\n case \"ct\": return ctSymbol();\n case \"pt\": return ptSymbol();\n case \"relay\": return relaySymbol(detail);\n case \"surge_arrester\": return surgeArresterSymbol();\n case \"ground_fault\": return groundFaultSymbol();\n case \"watthour_meter\": return meterSymbol(\"Wh\");\n case \"demand_meter\": return meterSymbol(\"D\");\n case \"bus\": return \"\";\n case \"hub\": return hubSymbol(detail);\n case \"bus_tie\": return busTieSymbol();\n default: return loadSymbol();\n }\n}\n","import type { SLDAST, SLDConnection, SLDNode, SLDNodeType } from \"../../core/types\";\nimport { geometryFor } from \"./symbols\";\n\n/**\n * Top-down hierarchical layout:\n * level 0 = sources (top)\n * each edge forces child.level >= parent.level + 1\n * Bus nodes expand horizontally to span their children.\n * Other nodes are positioned in a tidy tree-like layout.\n */\n\nexport interface SLDLayoutNode {\n node: SLDNode;\n nodeType: SLDNodeType;\n /** center x */\n x: number;\n /** center y */\n y: number;\n /** Terminal y (top and bottom) after symbol geometry */\n topY: number;\n bottomY: number;\n level: number;\n /** Half width for spacing */\n halfWidth: number;\n /** For bus nodes: left and right extent (x min/max) */\n busLeft?: number;\n busRight?: number;\n}\n\nexport interface SLDLayoutEdge {\n from: string;\n to: string;\n path: string;\n cable?: string;\n label?: string;\n midX: number;\n midY: number;\n}\n\nexport interface SLDLayoutBand {\n level: number;\n voltage?: string;\n y: number;\n height: number;\n}\n\nexport interface SLDLayoutResult {\n width: number;\n height: number;\n nodes: SLDLayoutNode[];\n edges: SLDLayoutEdge[];\n bands: SLDLayoutBand[];\n nodeById: Map<string, SLDLayoutNode>;\n}\n\nconst LEVEL_SPACING = 100;\nconst H_SPACING = 90;\nconst LEFT_PADDING = 80;\nconst TOP_PADDING = 40;\nconst BUS_OVERHANG = 20;\n\nfunction computeLevels(ast: SLDAST): Map<string, number> {\n const levels = new Map<string, number>();\n const inEdges = new Map<string, SLDConnection[]>();\n const outEdges = new Map<string, SLDConnection[]>();\n for (const n of ast.nodes) {\n inEdges.set(n.id, []);\n outEdges.set(n.id, []);\n }\n for (const c of ast.connections) {\n inEdges.get(c.to)?.push(c);\n outEdges.get(c.from)?.push(c);\n }\n\n // Sources: no incoming edges\n const roots = ast.nodes.filter((n) => (inEdges.get(n.id) ?? []).length === 0);\n for (const r of roots) levels.set(r.id, 0);\n\n // Identify bus_tie nodes — they are lateral at the same level as their source.\n const typeById = new Map<string, SLDNodeType>();\n for (const n of ast.nodes) typeById.set(n.id, n.nodeType);\n const isTieEdge = (c: SLDConnection): boolean =>\n typeById.get(c.from) === \"bus_tie\" || typeById.get(c.to) === \"bus_tie\";\n\n // Relaxation: level(to) = max(level(from)+1); iterate until stable.\n // Skip edges touching bus_tie (those are lateral).\n const maxIter = ast.nodes.length + 2;\n for (let iter = 0; iter < maxIter; iter++) {\n let changed = false;\n for (const c of ast.connections) {\n if (isTieEdge(c)) continue;\n const fromLvl = levels.get(c.from);\n if (fromLvl === undefined) continue;\n const want = fromLvl + 1;\n const curr = levels.get(c.to);\n if (curr === undefined || want > curr) {\n levels.set(c.to, want);\n changed = true;\n }\n }\n if (!changed) break;\n }\n\n // Tie edges: force both endpoints and the tie node itself to share level\n // with any already-leveled participant.\n for (let iter = 0; iter < maxIter; iter++) {\n let changed = false;\n for (const c of ast.connections) {\n if (!isTieEdge(c)) continue;\n const fromLvl = levels.get(c.from);\n const toLvl = levels.get(c.to);\n const shared = fromLvl ?? toLvl;\n if (shared === undefined) continue;\n if (fromLvl === undefined || fromLvl !== shared) {\n levels.set(c.from, shared);\n changed = true;\n }\n if (toLvl === undefined || toLvl !== shared) {\n levels.set(c.to, shared);\n changed = true;\n }\n }\n if (!changed) break;\n }\n\n // Any orphaned nodes: put at level 0\n for (const n of ast.nodes) {\n if (!levels.has(n.id)) levels.set(n.id, 0);\n }\n return levels;\n}\n\nfunction orderWithinLevel(\n ast: SLDAST,\n levels: Map<string, number>\n): Map<number, string[]> {\n const byLevel = new Map<number, string[]>();\n for (const n of ast.nodes) {\n const lvl = levels.get(n.id) ?? 0;\n if (!byLevel.has(lvl)) byLevel.set(lvl, []);\n byLevel.get(lvl)!.push(n.id);\n }\n\n // Order: DFS from sources preserving declaration order.\n const visited = new Set<string>();\n const order = new Map<string, number>();\n let idx = 0;\n\n const adj = new Map<string, string[]>();\n for (const n of ast.nodes) adj.set(n.id, []);\n for (const c of ast.connections) adj.get(c.from)?.push(c.to);\n\n function dfs(id: string): void {\n if (visited.has(id)) return;\n visited.add(id);\n order.set(id, idx++);\n for (const child of adj.get(id) ?? []) dfs(child);\n }\n\n // Start from sources in declaration order\n const inEdgeCount = new Map<string, number>();\n for (const n of ast.nodes) inEdgeCount.set(n.id, 0);\n for (const c of ast.connections) {\n inEdgeCount.set(c.to, (inEdgeCount.get(c.to) ?? 0) + 1);\n }\n for (const n of ast.nodes) {\n if ((inEdgeCount.get(n.id) ?? 0) === 0) dfs(n.id);\n }\n // Fallback for any remaining nodes\n for (const n of ast.nodes) dfs(n.id);\n\n // Sort each level by the DFS order\n for (const [lvl, ids] of byLevel.entries()) {\n ids.sort((a, b) => (order.get(a) ?? 0) - (order.get(b) ?? 0));\n byLevel.set(lvl, ids);\n }\n return byLevel;\n}\n\nexport function layoutSLD(ast: SLDAST): SLDLayoutResult {\n const levels = computeLevels(ast);\n const byLevel = orderWithinLevel(ast, levels);\n const nodeMap = new Map<string, SLDNode>();\n for (const n of ast.nodes) nodeMap.set(n.id, n);\n\n // First pass: x position for all non-bus nodes.\n // Buses get x later after their children are placed.\n const layoutNodes: SLDLayoutNode[] = [];\n const byIdLayout = new Map<string, SLDLayoutNode>();\n\n const parents = new Map<string, string[]>();\n const children = new Map<string, string[]>();\n for (const n of ast.nodes) {\n parents.set(n.id, []);\n children.set(n.id, []);\n }\n for (const c of ast.connections) {\n parents.get(c.to)?.push(c.from);\n children.get(c.from)?.push(c.to);\n }\n\n const sortedLevels = Array.from(byLevel.keys()).sort((a, b) => a - b);\n const maxLevel = sortedLevels.length ? sortedLevels[sortedLevels.length - 1] : 0;\n\n // Assign sequential X for non-bus leaf-like nodes within each level.\n // Then propagate bus positions by averaging their children.\n let nextX = LEFT_PADDING;\n // x assignment helper: if children already placed, center above them; else nextX\n function placeNode(id: string): SLDLayoutNode {\n const existing = byIdLayout.get(id);\n if (existing) return existing;\n const node = nodeMap.get(id)!;\n const lvl = levels.get(id) ?? 0;\n const geom = geometryFor(node.nodeType);\n const y = TOP_PADDING + lvl * LEVEL_SPACING;\n const ln: SLDLayoutNode = {\n node,\n nodeType: node.nodeType,\n x: 0,\n y,\n topY: y + geom.topY,\n bottomY: y + geom.bottomY,\n level: lvl,\n halfWidth: geom.halfWidth,\n };\n byIdLayout.set(id, ln);\n layoutNodes.push(ln);\n return ln;\n }\n\n // Walk levels top-to-bottom placing non-bus nodes sequentially; buses get centered on children\n // We do this in two passes: first place everything sequentially, then re-center buses.\n for (const lvl of sortedLevels) {\n for (const id of byLevel.get(lvl)!) {\n const ln = placeNode(id);\n if (ln.nodeType === \"bus\") {\n // defer\n ln.x = nextX; // placeholder\n } else {\n ln.x = nextX;\n nextX += H_SPACING;\n }\n }\n }\n\n // Center buses over their children (or parents if no children)\n // Iterate multiple times to stabilize.\n for (let iter = 0; iter < 4; iter++) {\n for (const lvl of sortedLevels) {\n for (const id of byLevel.get(lvl)!) {\n const ln = byIdLayout.get(id)!;\n if (ln.nodeType !== \"bus\") continue;\n const childrenIds = children.get(id) ?? [];\n const parentIds = parents.get(id) ?? [];\n const relatedXs: number[] = [];\n for (const cid of childrenIds) {\n const c = byIdLayout.get(cid);\n if (c && c.nodeType !== \"bus_tie\") relatedXs.push(c.x);\n }\n if (relatedXs.length === 0) {\n for (const pid of parentIds) {\n const p = byIdLayout.get(pid);\n if (p && p.nodeType !== \"bus_tie\") relatedXs.push(p.x);\n }\n }\n if (relatedXs.length > 0) {\n const minX = Math.min(...relatedXs);\n const maxX = Math.max(...relatedXs);\n ln.x = (minX + maxX) / 2;\n ln.busLeft = minX - BUS_OVERHANG;\n ln.busRight = maxX + BUS_OVERHANG;\n } else {\n ln.busLeft = ln.x - 40;\n ln.busRight = ln.x + 40;\n }\n }\n }\n }\n\n // Center non-bus nodes over their child(ren), bottom-up.\n // For convergence (child has multiple parents at same level), spread\n // parents horizontally around the child instead of collapsing them to one x.\n const CONVERGENCE_SPREAD = Math.max(H_SPACING, 110);\n for (let iter = 0; iter < 4; iter++) {\n for (const lvl of [...sortedLevels].reverse()) {\n for (const id of byLevel.get(lvl)!) {\n const ln = byIdLayout.get(id)!;\n if (ln.nodeType === \"bus\" || ln.nodeType === \"bus_tie\") continue;\n const childIds = children.get(id) ?? [];\n if (childIds.length === 1) {\n const child = byIdLayout.get(childIds[0]);\n if (!child) continue;\n // Only the convergence child's parents are spread\n const siblingParents = (parents.get(child.node.id) ?? [])\n .map((pid) => byIdLayout.get(pid))\n .filter((p): p is SLDLayoutNode => !!p && p.level === lvl && p.nodeType !== \"bus\");\n if (siblingParents.length > 1) {\n // Sort by original sequential x to preserve declared order\n siblingParents.sort((a, b) => a.x - b.x);\n const n = siblingParents.length;\n const spread = Math.max(\n CONVERGENCE_SPREAD,\n (child.halfWidth * 2 + 40) / Math.max(1, n - 1)\n );\n const idx = siblingParents.indexOf(ln);\n ln.x = child.x + (idx - (n - 1) / 2) * spread;\n } else {\n ln.x = child.x;\n }\n } else if (childIds.length > 1) {\n const xs = childIds\n .map((c) => byIdLayout.get(c)?.x)\n .filter((v): v is number => v !== undefined);\n if (xs.length > 0) {\n ln.x = (Math.min(...xs) + Math.max(...xs)) / 2;\n }\n }\n }\n }\n }\n\n // Bus-tie lateral placement: place tie and its \"second bus\" to the right\n // of the \"first bus\" at the same level. Shift the entire busB cluster\n // (all nodes reachable from busB excluding busA/tie) so the whole\n // right-side subtree moves together.\n for (const ln of layoutNodes) {\n if (ln.nodeType !== \"bus_tie\") continue;\n const inIds = parents.get(ln.node.id) ?? [];\n const outIds = children.get(ln.node.id) ?? [];\n const busA = inIds.map((id) => byIdLayout.get(id)).find((n) => n?.nodeType === \"bus\");\n const busB = outIds.map((id) => byIdLayout.get(id)).find((n) => n?.nodeType === \"bus\");\n if (!busA || !busB) continue;\n\n const busAChildren = (children.get(busA.node.id) ?? [])\n .map((id) => byIdLayout.get(id))\n .filter((c): c is SLDLayoutNode => !!c && c.nodeType !== \"bus_tie\");\n const busAMaxX = busAChildren.length\n ? Math.max(...busAChildren.map((c) => c.x))\n : busA.x;\n ln.y = busA.y;\n ln.x = busAMaxX + 60;\n\n // Cluster of busB: BFS in both directions excluding busA and tie itself\n const cluster = new Set<string>([busB.node.id]);\n const queue = [busB.node.id];\n const excluded = new Set<string>([busA.node.id, ln.node.id]);\n while (queue.length) {\n const cur = queue.shift()!;\n const neighbors = [...(children.get(cur) ?? []), ...(parents.get(cur) ?? [])];\n for (const nb of neighbors) {\n if (cluster.has(nb) || excluded.has(nb)) continue;\n cluster.add(nb);\n queue.push(nb);\n }\n }\n\n // Shift whole cluster so its leftmost member sits just right of the tie\n let minClusterX = Infinity;\n for (const id of cluster) {\n const n = byIdLayout.get(id);\n if (!n) continue;\n const left = n.nodeType === \"bus\" ? (n.busLeft ?? n.x) : n.x - n.halfWidth;\n if (left < minClusterX) minClusterX = left;\n }\n const desiredLeft = ln.x + 30;\n const shift = desiredLeft - minClusterX;\n if (shift > 0) {\n for (const id of cluster) {\n const n = byIdLayout.get(id);\n if (!n) continue;\n n.x += shift;\n if (n.busLeft !== undefined) n.busLeft += shift;\n if (n.busRight !== undefined) n.busRight += shift;\n }\n }\n }\n\n // Label-aware collision resolution within each level.\n // For each non-bus node, estimate displayed label width so sibling\n // placement respects text, not just symbol geometry.\n const labelHalfWidth = (ln: SLDLayoutNode): number => {\n if (ln.nodeType === \"bus\" || ln.nodeType === \"bus_tie\") return 0;\n const node = ln.node;\n const txtParts: string[] = [node.label ?? node.id];\n if (node.rating) txtParts.push(node.rating);\n const longest = txtParts.reduce((m, s) => Math.max(m, s.length), 0);\n // Bold 11px sans-serif id is ~6.2px per char at widest; pad a bit.\n return (longest * 6.2) / 2 + 4;\n };\n\n for (const lvl of sortedLevels) {\n const ids = byLevel.get(lvl)!;\n const sorted = ids.map((id) => byIdLayout.get(id)!).sort((a, b) => a.x - b.x);\n for (let i = 1; i < sorted.length; i++) {\n const prev = sorted[i - 1];\n const cur = sorted[i];\n if (prev.nodeType === \"bus\" && cur.nodeType !== \"bus\") continue;\n if (cur.nodeType === \"bus\" && prev.nodeType !== \"bus\") continue;\n const symGap =\n (prev.nodeType === \"bus\" ? 0 : prev.halfWidth) +\n (cur.nodeType === \"bus\" ? 0 : cur.halfWidth) +\n 16;\n const labelGap = labelHalfWidth(prev) + labelHalfWidth(cur) + 8;\n const minGap = Math.max(symGap, labelGap);\n if (cur.x - prev.x < minGap) {\n cur.x = prev.x + minGap;\n }\n }\n }\n\n // Bus nodes: re-update extent after collision resolution\n for (const ln of layoutNodes) {\n if (ln.nodeType !== \"bus\") continue;\n const childrenIds = children.get(ln.node.id) ?? [];\n const parentIds = parents.get(ln.node.id) ?? [];\n const xs: number[] = [];\n for (const cid of [...childrenIds, ...parentIds]) {\n const rel = byIdLayout.get(cid);\n if (rel && rel.nodeType !== \"bus_tie\") xs.push(rel.x);\n }\n // Include tie x so bus stretches up to the tie (but doesn't center on it)\n const tieXs: number[] = [];\n for (const cid of [...childrenIds, ...parentIds]) {\n const rel = byIdLayout.get(cid);\n if (rel && rel.nodeType === \"bus_tie\") tieXs.push(rel.x);\n }\n if (xs.length > 0) {\n let left = Math.min(...xs) - BUS_OVERHANG;\n let right = Math.max(...xs) + BUS_OVERHANG;\n for (const tx of tieXs) {\n if (tx < left) left = tx;\n if (tx > right) right = tx;\n }\n ln.busLeft = left;\n ln.busRight = right;\n ln.x = (Math.min(...xs) + Math.max(...xs)) / 2;\n }\n }\n\n // Update terminal Ys\n for (const ln of layoutNodes) {\n const geom = geometryFor(ln.nodeType);\n ln.topY = ln.y + geom.topY;\n ln.bottomY = ln.y + geom.bottomY;\n }\n\n // Build edges\n const edges: SLDLayoutEdge[] = [];\n for (const c of ast.connections) {\n const from = byIdLayout.get(c.from);\n const to = byIdLayout.get(c.to);\n if (!from || !to) continue;\n\n const fx = from.x;\n const tx = to.x;\n const lateralTie =\n from.nodeType === \"bus_tie\" ||\n to.nodeType === \"bus_tie\" ||\n (from.level === to.level && (from.nodeType === \"bus\" || to.nodeType === \"bus\"));\n\n let startY: number;\n let endY: number;\n if (lateralTie) {\n startY = from.y;\n endY = to.y;\n } else {\n startY = from.nodeType === \"bus\" ? from.y : from.bottomY;\n endY = to.nodeType === \"bus\" ? to.y : to.topY;\n }\n\n let pathD: string;\n if (lateralTie) {\n // Horizontal segment at common y; small stubs if tie sits on bus y\n pathD = `M ${fx} ${startY} L ${tx} ${endY}`;\n } else if (Math.abs(fx - tx) < 0.5) {\n pathD = `M ${fx} ${startY} L ${tx} ${endY}`;\n } else {\n // L-path: go down halfway, then horizontal, then vertical\n const midY = (startY + endY) / 2;\n pathD = `M ${fx} ${startY} L ${fx} ${midY} L ${tx} ${midY} L ${tx} ${endY}`;\n }\n\n edges.push({\n from: c.from,\n to: c.to,\n path: pathD,\n cable: c.cable,\n label: c.label,\n midX: (fx + tx) / 2,\n midY: (startY + endY) / 2,\n });\n }\n\n // Compute bands (voltage regions)\n const bands: SLDLayoutBand[] = [];\n for (const lvl of sortedLevels) {\n // Find a representative voltage label for this band\n let voltage: string | undefined;\n for (const id of byLevel.get(lvl)!) {\n const n = nodeMap.get(id)!;\n if (n.voltage) {\n voltage = n.voltage;\n break;\n }\n }\n bands.push({\n level: lvl,\n voltage,\n y: TOP_PADDING + lvl * LEVEL_SPACING - LEVEL_SPACING / 2 + 10,\n height: LEVEL_SPACING,\n });\n }\n\n // Normalize X so the leftmost content sits at LEFT_PADDING (no empty left gutter).\n let contentMinX = Infinity;\n for (const ln of layoutNodes) {\n const left = ln.nodeType === \"bus\"\n ? (ln.busLeft ?? ln.x)\n : ln.x - ln.halfWidth;\n if (left < contentMinX) contentMinX = left;\n }\n if (!Number.isFinite(contentMinX)) contentMinX = 0;\n const xShift = LEFT_PADDING - contentMinX;\n if (Math.abs(xShift) > 0.5) {\n for (const ln of layoutNodes) {\n ln.x += xShift;\n if (ln.busLeft !== undefined) ln.busLeft += xShift;\n if (ln.busRight !== undefined) ln.busRight += xShift;\n }\n for (const e of edges) {\n e.midX += xShift;\n // Shift every \"x\" coord in the path string (M / L tokens are \"x y\" pairs).\n e.path = e.path.replace(\n /([ML])\\s+(-?[\\d.]+)\\s+(-?[\\d.]+)/g,\n (_m, cmd, x, y) => `${cmd} ${Number(x) + xShift} ${y}`\n );\n }\n }\n\n // Compute canvas size\n let maxX = 0;\n for (const ln of layoutNodes) {\n const right = (ln.busRight ?? (ln.x + ln.halfWidth)) + 60;\n if (right > maxX) maxX = right;\n }\n const width = Math.max(400, maxX + 40);\n const height = TOP_PADDING + maxLevel * LEVEL_SPACING + 120;\n\n return {\n width,\n height,\n nodes: layoutNodes,\n edges,\n bands,\n nodeById: byIdLayout,\n };\n}\n","import type { SLDAST, SLDNode, RenderConfig } from \"../../core/types\";\nimport {\n svgRoot,\n group,\n el,\n path as pathEl,\n text as textEl,\n title as titleEl,\n desc,\n defs,\n} from \"../../core/svg\";\nimport { resolveIndustrialTheme, type IndustrialTokens, type ResolvedTheme } from \"../../core/theme\";\nimport { layoutSLD, type SLDLayoutNode } from \"./layout\";\nimport { renderSymbol } from \"./symbols\";\n\ntype IT = ResolvedTheme<IndustrialTokens>;\n\n// Zebra-band fills for grouped rows. Local to SLD — no other diagram uses\n// alternating row backgrounds, so they don't need to live in IndustrialTokens.\nconst BAND_ODD_LIGHT = \"#f7f7f7\";\nconst BAND_EVEN_LIGHT = \"#fbfbfb\";\nconst BAND_ODD_DARK = \"#2a2b3c\";\nconst BAND_EVEN_DARK = \"#313244\";\n\nfunction buildCss(t: IT): string {\n const isDark = t.bg !== \"#ffffff\";\n const bandOdd = isDark ? BAND_ODD_DARK : BAND_ODD_LIGHT;\n const bandEven = isDark ? BAND_EVEN_DARK : BAND_EVEN_LIGHT;\n return `\n.lt-sld { font-family: system-ui, -apple-system, sans-serif; }\n.lt-sld-stroke { stroke: ${t.stroke}; stroke-width: 1.8; fill: none; }\n.lt-sld-stroke-thick { stroke: ${t.stroke}; stroke-width: 2.4; fill: none; stroke-linecap: round; }\n.lt-sld-fill { fill: ${t.bg}; stroke: ${t.stroke}; stroke-width: 2; }\n.lt-sld-fill-dark { fill: ${t.stroke}; stroke: ${t.stroke}; stroke-width: 1; }\n.lt-sld-dot { fill: ${t.stroke}; stroke: none; }\n.lt-sld-wire { stroke: ${t.stroke}; stroke-width: 2; fill: none; }\n.lt-sld-bus { stroke: ${t.strokeHeavy}; stroke-width: 6; stroke-linecap: square; }\n.lt-sld-band-odd { fill: ${bandOdd}; stroke: none; }\n.lt-sld-band-even { fill: ${bandEven}; stroke: none; }\n.lt-sld-band-label { font: bold 11px sans-serif; fill: ${t.textMuted}; }\n.lt-sld-title { font: bold 16px sans-serif; fill: ${t.text}; }\n.lt-sld-id { font: bold 11px sans-serif; fill: ${t.text}; text-anchor: middle; }\n.lt-sld-rating { font: 9px sans-serif; fill: ${t.textMuted}; text-anchor: middle; }\n.lt-sld-voltage { font: bold 10px sans-serif; fill: ${t.textMuted}; }\n.lt-sld-nameplate { font: 9px sans-serif; fill: ${t.textMuted}; }\n.lt-sld-cable { font: 9px ui-monospace, SFMono-Regular, Menlo, monospace; fill: ${t.textMuted}; }\n.lt-sld-symbol-text { font: 11px sans-serif; fill: ${t.text}; dominant-baseline: middle; }\n.lt-sld-wdg { font: bold 10px sans-serif; fill: ${t.stroke}; dominant-baseline: middle; }\n.lt-sld-bus-label { font: bold 11px sans-serif; fill: ${t.accent}; }\n.lt-sld-standard-badge { font: bold 10px sans-serif; fill: ${t.textMuted}; letter-spacing: 0.3px; }\n`.trim();\n}\n\n/**\n * Jurisdiction-localised standard badge. ABNT (Brazil) reads in Portuguese;\n * AS/NZS and IEC use their published designations. ANSI (the default) shows no\n * badge to keep historical output unchanged.\n */\nfunction standardBadge(standard: SLDAST[\"standard\"]): string | undefined {\n switch (standard) {\n case \"iec\":\n return \"Standard: IEC 60617\";\n case \"abnt\":\n return \"Norma: ABNT NBR 5410 (IEC 60364)\";\n case \"as-nzs\":\n return \"Standard: AS/NZS 3000 (IEC 60364)\";\n default:\n return undefined;\n }\n}\n\nfunction renderLabels(ln: SLDLayoutNode): string[] {\n const pieces: string[] = [];\n const { node } = ln;\n if (ln.nodeType === \"bus\") {\n // Bus label + voltage sits above the bus bar\n const label = node.label ?? node.id;\n pieces.push(\n textEl(\n { x: (ln.busLeft ?? ln.x - 40) + 4, y: ln.y - 8, class: \"lt-sld-bus-label\" },\n node.voltage ? `${node.voltage} · ${label}` : label\n )\n );\n return pieces;\n }\n\n if (ln.nodeType === \"hub\") {\n // Label rendered inside the hub rect; skip external ID.\n if (node.rating || node.voltage) {\n const lines: string[] = [];\n if (node.rating) lines.push(node.rating);\n if (node.voltage) lines.push(node.voltage);\n lines.forEach((l, i) => {\n pieces.push(\n textEl(\n { x: ln.x, y: ln.bottomY + 14 + i * 11, class: \"lt-sld-rating\" },\n l\n )\n );\n });\n }\n return pieces;\n }\n\n if (ln.nodeType === \"bus_tie\") {\n // Tie breaker label to the side\n pieces.push(\n textEl(\n { x: ln.x, y: ln.topY - 6, class: \"lt-sld-rating\" },\n node.label ?? node.id\n )\n );\n return pieces;\n }\n\n // ID above\n const idY = ln.topY - 22;\n pieces.push(\n textEl({ x: ln.x, y: idY, class: \"lt-sld-id\" }, node.label ?? node.id)\n );\n\n // Rating below\n const lines: string[] = [];\n if (node.rating) lines.push(node.rating);\n if (node.voltage) lines.push(node.voltage);\n if (node.deviceNumber && ln.nodeType === \"relay\") {\n // deviceNumber is shown inside the relay glyph; skip here\n }\n lines.forEach((l, i) => {\n pieces.push(\n textEl(\n { x: ln.x, y: ln.bottomY + 14 + i * 11, class: \"lt-sld-rating\" },\n l\n )\n );\n });\n\n // Transformer nameplate\n if (\n (ln.nodeType === \"transformer\" ||\n ln.nodeType === \"transformer_dy\" ||\n ln.nodeType === \"transformer_yd\" ||\n ln.nodeType === \"transformer_yy\" ||\n ln.nodeType === \"transformer_dd\" ||\n ln.nodeType === \"autotransformer\" ||\n ln.nodeType === \"transformer_3winding\") &&\n node.nameplate\n ) {\n const np = node.nameplate;\n const keys = Object.keys(np);\n let offset = -12;\n const x = ln.x + ln.halfWidth + 28;\n for (const k of keys) {\n pieces.push(\n textEl(\n { x, y: ln.y + offset, class: \"lt-sld-nameplate\" },\n `${k}: ${np[k]}`\n )\n );\n offset += 11;\n }\n }\n\n return pieces;\n}\n\nexport function renderSLD(ast: SLDAST, config?: RenderConfig): string {\n const layout = layoutSLD(ast);\n const t = resolveIndustrialTheme(config?.theme ?? \"default\");\n const titleOffset = ast.title ? 34 : 12;\n const width = Math.ceil(layout.width);\n const height = Math.ceil(layout.height + titleOffset);\n\n const children: string[] = [];\n children.push(titleEl(ast.title ?? \"Single-Line Diagram\"));\n children.push(\n desc(\n `Single-line diagram with ${ast.nodes.length} nodes and ${ast.connections.length} connections`\n )\n );\n children.push(el(\"style\", {}, buildCss(t)));\n\n // Arrow marker\n children.push(\n defs([\n el(\n \"marker\",\n {\n id: \"lt-sld-arrow\",\n markerWidth: 8,\n markerHeight: 8,\n refX: 6,\n refY: 3,\n orient: \"auto\",\n markerUnits: \"strokeWidth\",\n },\n [el(\"path\", { d: \"M 0 0 L 6 3 L 0 6 z\", fill: t.textMuted })]\n ),\n ])\n );\n\n if (ast.title) {\n children.push(\n textEl({ x: 20, y: 22, class: \"lt-sld-title\" }, ast.title)\n );\n }\n\n // Standard-compliance badge (top-right), localised for the jurisdiction.\n const badge = standardBadge(ast.standard);\n if (badge) {\n children.push(\n textEl(\n { x: width - 14, y: 22, class: \"lt-sld-standard-badge\", \"text-anchor\": \"end\" },\n badge\n )\n );\n }\n\n const inner: string[] = [];\n\n // Voltage bands (alternating background)\n layout.bands.forEach((b, i) => {\n inner.push(\n el(\"rect\", {\n x: 0,\n y: b.y,\n width: layout.width,\n height: b.height,\n class: i % 2 === 0 ? \"lt-sld-band-odd\" : \"lt-sld-band-even\",\n })\n );\n if (b.voltage) {\n inner.push(\n textEl(\n { x: 14, y: b.y + 18, class: \"lt-sld-band-label\" },\n b.voltage\n )\n );\n }\n });\n\n // Connection wires (draw before symbols so symbols sit on top)\n for (const e of layout.edges) {\n inner.push(pathEl({ d: e.path, class: \"lt-sld-wire\" }));\n if (e.cable) {\n // Position cable label near midpoint, slightly offset\n inner.push(\n textEl(\n { x: e.midX + 6, y: e.midY - 2, class: \"lt-sld-cable\" },\n e.cable\n )\n );\n }\n if (e.label) {\n inner.push(\n textEl(\n { x: e.midX + 6, y: e.midY + 10, class: \"lt-sld-cable\" },\n e.label\n )\n );\n }\n }\n\n // Nodes\n for (const ln of layout.nodes) {\n if (ln.nodeType === \"bus\") {\n const left = ln.busLeft ?? ln.x - 40;\n const right = ln.busRight ?? ln.x + 40;\n inner.push(\n el(\"line\", {\n x1: left,\n y1: ln.y,\n x2: right,\n y2: ln.y,\n class: \"lt-sld-bus\",\n \"data-id\": ln.node.id,\n })\n );\n for (const piece of renderLabels(ln)) inner.push(piece);\n continue;\n }\n const attrs = {\n transform: `translate(${ln.x}, ${ln.y})`,\n \"data-type\": ln.nodeType,\n \"data-id\": ln.node.id,\n };\n inner.push(\n group(attrs, [\n renderSymbol(\n ln.nodeType,\n ln.nodeType === \"hub\"\n ? ln.node.label ?? ln.node.id\n : (ln.node as SLDNode).deviceNumber,\n ast.standard\n ),\n ])\n );\n for (const piece of renderLabels(ln)) inner.push(piece);\n }\n\n const wrap = group({ transform: `translate(0, ${titleOffset})` }, inner);\n children.push(wrap);\n\n return svgRoot(\n {\n class: \"lt-sld\",\n role: \"img\",\n \"aria-labelledby\": \"lt-sld-title lt-sld-desc\",\n width,\n height,\n viewBox: `0 0 ${width} ${height}`,\n },\n children\n );\n}\n","import type { SchematexDiagnostic } from \"../../core/diagnostics\";\nimport type { SLDAST, SLDNodeType } from \"../../core/types\";\nimport { isIecFamily } from \"../../core/types\";\nimport { parseSLDDSL } from \"./parser\";\n\n/**\n * SLD standard-compatibility lint.\n *\n * When an explicit `[standard: …]` is selected, flag devices that have no\n * symbol in that standard's published catalog so an engineer doesn't\n * unknowingly submit a glyph their jurisdiction won't accept. The engine does\n * not silently substitute a foreign symbol — it renders the closest available\n * form and warns.\n */\nexport function lintSLD(text: string): SchematexDiagnostic[] {\n let ast: SLDAST;\n try {\n ast = parseSLDDSL(text);\n } catch {\n return [];\n }\n return lintSLDAst(ast);\n}\n\n// North-American utility devices with no direct IEC 60617 glyph in our catalog.\n// Under an IEC-family standard they fall back to the ANSI form, which may not be\n// accepted in IEC submittals.\nconst ANSI_ONLY: Partial<Record<SLDNodeType, string>> = {\n recloser: \"recloser\",\n sectionalizer: \"sectionalizer\",\n watthour_meter: \"watt-hour meter\",\n demand_meter: \"demand meter\",\n};\n\nexport function lintSLDAst(ast: SLDAST): SchematexDiagnostic[] {\n const out: SchematexDiagnostic[] = [];\n if (!isIecFamily(ast.standard)) return out;\n\n const stdName = ast.standard === \"abnt\" ? \"ABNT NBR 5410\" : ast.standard === \"as-nzs\" ? \"AS/NZS 3000\" : \"IEC 60617\";\n const seen = new Set<SLDNodeType>();\n for (const node of ast.nodes) {\n const friendly = ANSI_ONLY[node.nodeType];\n if (!friendly || seen.has(node.nodeType)) continue;\n seen.add(node.nodeType);\n out.push({\n severity: \"warning\",\n code: \"SLD_SYMBOL_NOT_IN_STANDARD\",\n message: `device \"${node.nodeType}\" (${friendly}) has no symbol in ${stdName}; rendered with the ANSI/IEEE form`,\n hint: `${friendly} is a North-American utility convention. Confirm an equivalent device exists in ${stdName}, or model it with an IEC-native device.`,\n fatal: false,\n });\n }\n return out;\n}\n","import type { DiagramPlugin } from \"../../core/types\";\nimport { firstContentLine } from \"../../core/dsl-preprocess\";\nimport { parseSLDDSL } from \"./parser\";\nimport { renderSLD } from \"./renderer\";\nimport { lintSLD } from \"./lint\";\n\nexport const sld: DiagramPlugin = {\n type: \"sld\",\n detect(text: string): boolean {\n const first = firstContentLine(text)?.toLowerCase() ?? \"\";\n return first.startsWith(\"sld\");\n },\n parse: parseSLDDSL,\n lint: lintSLD,\n\n render(text: string, config): string {\n const ast = parseSLDDSL(text);\n return renderSLD(ast, config);\n },\n};\n\nexport { lintSLD, lintSLDAst } from \"./lint\";\nexport { parseSLDDSL } from \"./parser\";\nexport { renderSLD } from \"./renderer\";\nexport { layoutSLD } from \"./layout\";\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/diagrams/sld/parser.ts","../src/core/types.ts","../src/diagrams/sld/symbols.ts","../src/diagrams/sld/layout.ts","../src/diagrams/sld/renderer.ts","../src/diagrams/sld/lint.ts","../src/diagrams/sld/index.ts"],"names":["line","text","title","matchQuotedTitle","didYouMean","group","el","path","maxX","lines","resolveIndustrialTheme","desc","defs","svgRoot","firstContentLine"],"mappings":";;;;;;;;;AAUO,IAAM,aAAA,GAAN,cAA4B,KAAA,CAAM;AAAA,EAChC,IAAA;AAAA,EACA,MAAA;AAAA,EACP,WAAA,CAAY,OAAA,EAAiBA,KAAAA,EAAe,MAAA,EAAiB;AAC3D,IAAA,KAAA,CAAMA,UAAS,MAAA,GAAY,CAAA,KAAA,EAAQA,KAAI,CAAA,EAAA,EAAK,OAAO,KAAK,OAAO,CAAA;AAC/D,IAAA,IAAA,CAAK,IAAA,GAAO,eAAA;AACZ,IAAA,IAAA,CAAK,IAAA,GAAOA,KAAAA;AACZ,IAAA,IAAA,CAAK,MAAA,GAAS,MAAA;AAAA,EAChB;AACF,CAAA;AAEA,IAAM,UAAA,uBAAiB,GAAA,CAAiB;AAAA,EACtC,SAAA;AAAA,EAAW,WAAA;AAAA,EAAa,OAAA;AAAA,EAAS,MAAA;AAAA,EAAQ,KAAA;AAAA,EACzC,aAAA;AAAA,EAAe,gBAAA;AAAA,EAAkB,gBAAA;AAAA,EAAkB,gBAAA;AAAA,EACnD,gBAAA;AAAA,EAAkB,iBAAA;AAAA,EAAmB,sBAAA;AAAA,EACrC,KAAA;AAAA,EAAO,SAAA;AAAA,EAAW,KAAA;AAAA,EAClB,SAAA;A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A,CAAOA,OAAc,MAAA,EAAgB;AACnC,IAAA,MAAM,GAAA,GAAM,YAAYA,KAAI,CAAA;AAC5B,IAAA,OAAO,SAAA,CAAU,KAAK,MAAM,CAAA;AAAA,EAC9B;AACF","file":"chunk-ECD5XHBM.cjs","sourcesContent":["import type {\n SLDAST,\n SLDNode,\n SLDNodeType,\n SLDConnection,\n SLDStandard,\n} from \"../../core/types\";\nimport { matchQuotedTitle } from \"../../core/quotes\";\nimport { didYouMean } from \"../../core/dsl-suggest\";\n\nexport class SLDParseError extends Error {\n public line?: number;\n public source?: string;\n constructor(message: string, line?: number, source?: string) {\n super(line !== undefined ? `Line ${line}: ${message}` : message);\n this.name = \"SLDParseError\";\n this.line = line;\n this.source = source;\n }\n}\n\nconst NODE_TYPES = new Set<SLDNodeType>([\n \"utility\", \"generator\", \"solar\", \"wind\", \"ups\",\n \"transformer\", \"transformer_dy\", \"transformer_yd\", \"transformer_yy\",\n \"transformer_dd\", \"autotransformer\", \"transformer_3winding\",\n \"bus\", \"bus_tie\", \"hub\",\n \"breaker\", \"breaker_vacuum\", \"switch\", \"switch_load\", \"ground_switch\",\n \"ats\", \"recloser\", \"sectionalizer\", \"fuse\", \"fuse_cl\",\n \"ct\", \"pt\", \"relay\", \"surge_arrester\", \"ground_fault\",\n \"motor\", \"load\", \"capacitor_bank\", \"harmonic_filter\", \"vfd\",\n \"watthour_meter\", \"demand_meter\",\n]);\n\n// IEC 60364 / BS 7671 / REBT residential vocabulary. These map onto existing\n// IEEE-315 visual primitives until issue 02 Fix C ships a typed `rcd` node\n// and per-curve breaker glyph. The mapping is conservative: every alias\n// renders as a recognisable breaker/RCD variant, no information loss beyond\n// the label-string fidelity LLMs already rely on.\nconst TYPE_ALIASES: Record<string, SLDNodeType> = {\n mcb: \"breaker\",\n mccb: \"breaker\",\n miniature_circuit_breaker: \"breaker\",\n rcd: \"ground_fault\",\n rcbo: \"ground_fault\",\n rccb: \"ground_fault\",\n differential: \"ground_fault\",\n diferencial: \"ground_fault\",\n pia: \"breaker\",\n iga: \"breaker\",\n main_switch: \"switch_load\",\n isolator: \"switch_load\",\n disconnector: \"switch_load\",\n consumer_unit: \"bus\",\n distribution_board: \"bus\",\n panel: \"bus\",\n panelboard: \"bus\",\n};\n\nfunction stripComment(s: string): string {\n // Strip `#`, `//`, or Mermaid `%%` comments. Quoted regions are respected\n // so `\"#fff\"` (a CSS color) and `\"https://…\"` survive.\n let out = \"\";\n let inQuote = false;\n for (let i = 0; i < s.length; i++) {\n const ch = s[i]!;\n if (ch === '\"') inQuote = !inQuote;\n if (!inQuote) {\n if (ch === \"#\") break;\n if (ch === \"/\" && s[i + 1] === \"/\") break;\n if (ch === \"%\" && s[i + 1] === \"%\") break;\n }\n out += ch;\n }\n return out;\n}\n\nfunction stripQuotes(v: string): string {\n const t = v.trim();\n if (t.length >= 2 && t.startsWith('\"') && t.endsWith('\"')) {\n return t.slice(1, -1);\n }\n return t;\n}\n\nfunction splitAttrs(inside: string): Array<[string, string]> {\n // split by commas (respecting quotes) → \"key: value\" pairs\n const parts: string[] = [];\n let cur = \"\";\n let inQuote = false;\n for (const ch of inside) {\n if (ch === '\"') inQuote = !inQuote;\n if (ch === \",\" && !inQuote) {\n parts.push(cur);\n cur = \"\";\n } else {\n cur += ch;\n }\n }\n if (cur.trim()) parts.push(cur);\n\n const out: Array<[string, string]> = [];\n for (const p of parts) {\n const s = p.trim();\n if (!s) continue;\n const colon = s.indexOf(\":\");\n if (colon < 0) {\n throw new SLDParseError(`Invalid attribute \"${s}\" (missing \":\")`);\n }\n const k = s.slice(0, colon).trim();\n const v = stripQuotes(s.slice(colon + 1));\n out.push([k, v]);\n }\n return out;\n}\n\nfunction applyAttrs(node: SLDNode, attrs: Array<[string, string]>): void {\n for (const [k, v] of attrs) {\n const key = k.toLowerCase();\n if (key === \"label\") node.label = v;\n else if (key === \"voltage\") node.voltage = v;\n else if (key === \"rating\") node.rating = v;\n else if (key === \"device\") node.deviceNumber = v;\n else {\n // stash everything else as nameplate\n if (!node.nameplate) node.nameplate = {};\n node.nameplate[k] = v;\n }\n }\n}\n\n/** Join lines so that a bracketed attribute block spans a single logical line. */\nfunction joinBrackets(lines: string[]): string[] {\n const out: string[] = [];\n let buf = \"\";\n let depth = 0;\n for (const raw of lines) {\n const line = stripComment(raw);\n if (!line.trim() && depth === 0) {\n if (buf) {\n out.push(buf);\n buf = \"\";\n }\n out.push(\"\");\n continue;\n }\n for (const ch of line) {\n if (ch === \"[\") depth++;\n else if (ch === \"]\") depth = Math.max(0, depth - 1);\n }\n buf = buf ? buf + \" \" + line.trim() : line;\n if (depth === 0) {\n out.push(buf);\n buf = \"\";\n }\n }\n if (buf) out.push(buf);\n return out;\n}\n\nexport function parseSLDDSL(text: string): SLDAST {\n const rawLines = text.split(\"\\n\").map((l) => l.replace(/\\r$/, \"\"));\n const lines = joinBrackets(rawLines);\n\n let title: string | undefined;\n let standard: SLDStandard | undefined;\n const nodes: SLDNode[] = [];\n const nodeMap = new Map<string, SLDNode>();\n const connections: SLDConnection[] = [];\n\n for (let i = 0; i < lines.length; i++) {\n const raw = lines[i];\n const line = raw.trim();\n if (!line) continue;\n\n // Header: sld \"title\" [standard: iec]\n if (/^sld\\b/i.test(line)) {\n const t = matchQuotedTitle(line);\n if (t !== undefined) title = t;\n const bracket = line.match(/\\[([^\\]]*)\\]/);\n if (bracket) {\n for (const [k, v] of splitAttrs(bracket[1])) {\n if (k.toLowerCase() === \"standard\") {\n const s = v.trim().toLowerCase();\n if (s === \"ansi\" || s === \"iec\" || s === \"abnt\" || s === \"as-nzs\") {\n standard = s;\n } else {\n throw new SLDParseError(\n `Unknown standard \"${v}\". Valid: ansi, iec, abnt, as-nzs`,\n i + 1,\n line\n );\n }\n }\n }\n }\n continue;\n }\n\n // Connection: A -> B [cable: \"...\", label: \"...\"]\n const connMatch = line.match(\n /^([A-Za-z][A-Za-z0-9_-]*)\\s*->\\s*([A-Za-z][A-Za-z0-9_-]*)(?:\\s*\\[([^\\]]*)\\])?\\s*$/\n );\n if (connMatch) {\n const from = connMatch[1];\n const to = connMatch[2];\n const c: SLDConnection = { from, to };\n if (connMatch[3]) {\n for (const [k, v] of splitAttrs(connMatch[3])) {\n const key = k.toLowerCase();\n if (key === \"cable\") c.cable = v;\n else if (key === \"label\") c.label = v;\n }\n }\n connections.push(c);\n continue;\n }\n\n // Node definition: ID = type [attrs]\n const nodeMatch = line.match(\n /^([A-Za-z][A-Za-z0-9_-]*)\\s*=\\s*([a-zA-Z_][a-zA-Z0-9_]*)(?:\\s*\\[([^\\]]*)\\])?\\s*$/\n );\n if (nodeMatch) {\n const id = nodeMatch[1];\n const rawType = nodeMatch[2].toLowerCase();\n // Resolve REBT/IEC residential aliases (mcb → breaker, rcbo → ground_fault…)\n // before the canonical-type check.\n const canonical = (TYPE_ALIASES[rawType] ?? rawType) as SLDNodeType;\n if (!NODE_TYPES.has(canonical)) {\n const candidates = [\n ...NODE_TYPES,\n ...Object.keys(TYPE_ALIASES),\n ];\n throw new SLDParseError(\n `Unknown node type \"${nodeMatch[2]}\" for \"${id}\"${didYouMean(rawType, candidates)}`,\n i + 1,\n line\n );\n }\n if (nodeMap.has(id)) {\n throw new SLDParseError(`Duplicate node id \"${id}\"`, i + 1, line);\n }\n const node: SLDNode = { id, nodeType: canonical };\n // If the user wrote an alias (mcb/rcbo/iga…), preserve the original word\n // as the visible label unless an explicit `label:` attribute overrides\n // it below. This keeps \"MCB\" / \"IGA\" markings on the rendered SVG.\n if (TYPE_ALIASES[rawType]) {\n node.label = rawType.toUpperCase();\n }\n if (nodeMatch[3]) {\n applyAttrs(node, splitAttrs(nodeMatch[3]));\n }\n nodes.push(node);\n nodeMap.set(id, node);\n continue;\n }\n\n throw new SLDParseError(`Cannot parse line`, i + 1, line);\n }\n\n // Validate connections\n for (const c of connections) {\n if (!nodeMap.has(c.from)) {\n throw new SLDParseError(`Connection references unknown node \"${c.from}\"`);\n }\n if (!nodeMap.has(c.to)) {\n throw new SLDParseError(`Connection references unknown node \"${c.to}\"`);\n }\n }\n\n if (nodes.length === 0) {\n throw new SLDParseError(\"SLD diagram has no nodes\");\n }\n\n return { type: \"sld\", title, standard, nodes, connections };\n}\n","/**\n * Core type definitions for Schematex.\n *\n * The pipeline is: Text → Parser → AST → Layout → LayoutResult → Renderer → SVG\n *\n * Each diagram type (genogram, ecomap, pedigree) implements its own:\n * - Parser: text → DiagramAST\n * - Layout: DiagramAST → LayoutResult\n * - Renderer: LayoutResult → SVG string\n */\n\n// Type-only import (erased at runtime — no dependency cycle) for the plugin\n// lint hook's return type.\nimport type { SchematexDiagnostic } from \"./diagnostics\";\n\n// ─── AST Types ───────────────────────────────────────────────\n\nexport type DiagramType =\n // Relationship diagrams\n | \"genogram\"\n | \"ecomap\"\n | \"pedigree\"\n | \"phylo\"\n | \"sociogram\"\n // Electrical engineering diagrams\n | \"timing\" // Digital timing / waveform (06-TIMING-STANDARD)\n | \"logic\" // Logic gate netlist (07-LOGIC-GATE-STANDARD)\n | \"circuit\" // Circuit schematic positional DSL (08-CIRCUIT-SCHEMATIC-STANDARD)\n | \"blockdiagram\" // Control systems block diagram (09-BLOCK-DIAGRAM-STANDARD)\n | \"ladder\" // PLC ladder logic IEC 61131-3 (10-LADDER-LOGIC-STANDARD)\n | \"sld\" // Single-line diagram / power distribution (11-SINGLE-LINE-STANDARD)\n // Corporate / legal structure diagrams\n | \"entity\" // Entity structure / corporate ownership (12-ENTITY-STRUCTURE-STANDARD)\n // Causality / analysis diagrams\n | \"fishbone\" // Ishikawa cause-and-effect (14-FISHBONE-STANDARD)\n // Set-theory / logic diagrams\n | \"venn\" // Venn / Euler diagram (15-VENN-STANDARD)\n // Generic process / decision flowchart\n | \"flowchart\" // Flowchart (14-FLOWCHART-STANDARD)\n // Knowledge / brainstorming diagrams\n | \"mindmap\" // Mindmap — radial Buzan + markmap-compat tree (20-MINDMAP-STANDARD)\n // Strategy / prioritization / analysis diagrams\n | \"matrix\" // Matrix / 2x2 quadrant / 3x3 / N×M heatmap (18-MATRIX-STANDARD)\n // Organizational hierarchy diagrams\n | \"orgchart\" // Organizational / reporting structure chart (16-ORGCHART-STANDARD)\n // Decision-analysis / ML / taxonomy trees\n | \"decisiontree\" // Decision tree — Howard-Raiffa + CART + taxonomy (17-DECISION-TREE-STANDARD)\n // Time axis\n | \"timeline\" // Timeline — events / eras / lifespans on a time axis (19-TIMELINE-STANDARD)\n // Behavior modeling\n | \"state\" // UML 2.5 / Harel statechart (21-STATE-DIAGRAM-STANDARD)\n // Process & instrumentation\n | \"pid\" // ISA-5.1 / ISO 10628 P&ID (22-PID-STANDARD)\n // Data modeling\n | \"erd\" // Entity-Relationship Diagram (Chen / crow's foot, 27-ERD-STANDARD)\n // Physical wiring / hardware prototyping\n | \"breadboard\" // Fritzing-style breadboard view (26-BREADBOARD-STANDARD)\n // Business process modelling\n | \"bpmn\" // OMG BPMN 2.0 business process diagram (25-BPMN-STANDARD)\n // IEC 61131-3 visual PLC languages (sister to ladder §10)\n | \"fbd\" // Function Block Diagram — IEC 61131-3 §6.4 (23-FBD-STANDARD)\n | \"sfc\" // Sequential Function Chart — IEC 61131-3 §6.5 (24-SFC-STANDARD)\n // Evidence-synthesis / research reporting\n | \"prisma\" // PRISMA 2020 flow diagram (28-PRISMA-STANDARD)\n // Structural UML (sister to behavioral §21 state)\n | \"usecase\" // UML 2.5.1 use case diagram (29-USECASE-STANDARD)\n // Project scheduling networks\n | \"pert\" // PERT / CPM activity-on-node network (32-PERT-STANDARD)\n // Behavioral UML (sister to §21 state, §29 usecase)\n | \"sequence\" // UML 2.5.1 §17 sequence / interaction diagram (33-SEQUENCE-STANDARD)\n // Concurrency / discrete-event formalism\n | \"petri\" // Petri net (place/transition net) — Murata 1989 / ISO-IEC 15909 (34-PETRINET-STANDARD)\n // Network / infrastructure topology\n | \"network\"; // Network topology — Cisco-convention icons + hierarchical/spine-leaf layout (35-NETWORK-STANDARD)\n\nexport type GenogramMode = \"medical\" | \"heritage\";\n\n/**\n * Standard legend positions:\n * - \"bottom-inline\" (default) — horizontal strip below the diagram, no box/border\n * - \"bottom-right\" — overlay anchored at bottom-right corner\n * - \"none\" — disabled\n *\n * All other values are legacy aliases (pedigree DSL, older docs) that the renderer\n * silently maps to one of the standard positions: \"outside-*\", \"right\",\n * \"top-*\", \"bottom-left\", \"bottom-center\" → bottom-inline (or bottom-right where\n * a corner is closer in spirit).\n */\nexport type LegendPosition =\n | \"bottom-inline\"\n | \"bottom-right\"\n | \"none\"\n // Legacy aliases (kept for backwards compat; mapped at render time)\n | \"top-left\"\n | \"top-right\"\n | \"bottom-left\"\n | \"bottom-center\"\n | \"outside-right\"\n | \"outside-bottom\"\n | \"right\";\n\nexport type LegendItemKind =\n | \"shape\"\n | \"fill\"\n | \"fill-pattern\"\n | \"line\"\n | \"marker\"\n | \"edge\";\n\nexport type LegendLinePattern =\n | \"solid\"\n | \"dashed\"\n | \"dotted\"\n | \"double\"\n | \"wavy\"\n | \"zigzag\"\n | \"broken\";\n\nexport interface LegendItem {\n /** Stable identifier addressable from DSL `legend.label <key>: ...` */\n key: string;\n /** Display text (user-overridable). */\n label: string;\n kind: LegendItemKind;\n /** Primary color. For \"shape\": stroke. For \"line\"/\"edge\": stroke. For \"fill\"/\"fill-pattern\"/\"marker\": fill. */\n color?: string;\n /** For kind: \"shape\" — fill color (separate from stroke). Used for WYSIWYG matching of node fills. */\n fill?: string;\n /** Secondary color for two-tone swatches (half-fill, etc.). */\n color2?: string;\n pattern?: LegendLinePattern;\n strokeWidth?: number;\n /** For kind: \"shape\" — \"square\" | \"circle\" | \"diamond\" | \"triangle\" | \"concentric-square\" | \"concentric-circle\". */\n shape?: string;\n /** For kind: \"marker\" / \"edge\" — \"arrow\" | \"X\" | \"dot\" | \"P\" | \"C\" | \"E\" | \"star\" | \"slash\". */\n marker?: string;\n /** Section group id (e.g. \"symbols\", \"structural\", \"relationships\", \"conditions\"). */\n section?: string;\n}\n\nexport interface LegendSection {\n id: string;\n title: string;\n hidden?: boolean;\n}\n\nexport interface LegendSpec {\n /** \"auto\" resolves to \"on\" if items remain after override, else \"off\". */\n mode: \"on\" | \"off\" | \"auto\";\n title: string;\n position: LegendPosition;\n columns: number;\n sections: LegendSection[];\n items: LegendItem[];\n}\n\n/** User edits parsed from DSL; merged onto each diagram's auto-derived spec. */\nexport interface LegendOverrides {\n mode?: \"on\" | \"off\" | \"auto\";\n title?: string;\n position?: LegendPosition;\n columns?: number;\n /** Rename items by key. */\n labels?: Record<string, string>;\n /** Hide items by key. */\n hide?: string[];\n /** Rename / hide sections by id. */\n sections?: Record<string, { title?: string; hidden?: boolean }>;\n /** Manually authored items appended after auto-derived ones. */\n added?: LegendItem[];\n}\n\nexport interface DiagramAST {\n type: DiagramType;\n individuals: Individual[];\n relationships: Relationship[];\n metadata?: Record<string, string>;\n /** Legacy: pedigree-style trait legend. To be migrated into LegendOverrides.added. */\n legend?: LegendEntry[];\n /** Genogram display mode: medical conditions or cultural heritage */\n mode?: GenogramMode;\n /** Legacy: pre-unified-legend position field. New code uses legendOverrides.position. */\n legendPosition?: LegendPosition;\n /** Unified legend system — user DSL edits merged onto auto-derived spec at render time. */\n legendOverrides?: LegendOverrides;\n}\n\nexport interface LegendEntry {\n id: string;\n label: string;\n /** Fill position (for pedigree trait legend) */\n fill?: ConditionFill;\n /** Color (for heritage legend or pedigree trait legend) */\n color?: string;\n}\n\nexport interface Individual {\n id: string;\n label: string;\n sex: Sex;\n status: IndividualStatus;\n birthYear?: number;\n deathYear?: number;\n /**\n * Full ISO birth date (`\"1940-03-12\"`) for genealogy / legal family trees.\n * Backward-compatible with `birthYear`: when present it takes precedence in\n * the vital-records caption (`* 1940-03-12`). A bare 4-digit year still fills\n * `birthYear`.\n */\n dob?: string;\n /** Full ISO death date (`\"2018-11-04\"`), rendered as `† 2018-11-04`. */\n dod?: string;\n /** One-line free-text annotation rendered as a small caption under the symbol. */\n note?: string;\n /**\n * Legal/genealogy birth status (German Ahnentafel convention). Modifies the\n * born glyph in the vital-records caption: `out-of-wedlock` → `(*)`,\n * `adopted` → `[*]`. Default (legitimate) keeps the plain `*` born glyph.\n */\n birthStatus?: \"legitimate\" | \"out-of-wedlock\" | \"adopted\";\n /** Medical/psychological conditions (genogram) or affected traits (pedigree) */\n conditions?: Condition[];\n /** Genetic status for pedigree charts */\n geneticStatus?: GeneticStatus;\n /** Child relationship modifier */\n childType?: ChildType;\n /** Special markers */\n markers?: IndividualMarker[];\n /** Gender identity annotation (Bennett 2022: when gender ≠ assigned sex) */\n genderIdentity?: string;\n /** Cultural/ethnic heritage identifiers (heritage genogram mode) */\n heritage?: string[];\n /** Age to display inside shape (auto-calculated from birthYear if omitted) */\n age?: number;\n /** Rich annotations: occupation, traits, notes, etc. */\n annotations?: Record<string, string>;\n /** Whether this individual is external/non-family (dashed border) */\n external?: boolean;\n /**\n * Optional shape override. By default the shape is derived from `sex`\n * (male=square, female=circle, other=diamond). Some kinship/anthropology\n * conventions use triangles for males, etc. This field lets the DSL request\n * a specific shape regardless of sex.\n */\n shape?: \"square\" | \"circle\" | \"diamond\" | \"triangle\" | \"triangle-down\";\n /**\n * Pedigree convention for \"known relative, unknown ancestry\":\n * id of another individual whose generation this person shares as a sibling.\n * No phantom parents are synthesized — layout pins generation, renderer\n * draws a dashed bracket between the two.\n */\n siblingOf?: string;\n /** Custom properties for extensibility */\n properties?: Record<string, string>;\n}\n\nexport type Sex =\n | \"male\"\n | \"female\"\n | \"unknown\"\n | \"other\"\n // Bennett 2022 additions\n | \"nonbinary\"\n | \"intersex\";\n\nexport type IndividualStatus =\n | \"alive\"\n | \"deceased\"\n | \"stillborn\"\n | \"miscarriage\"\n | \"abortion\"\n // Expanded statuses\n | \"pregnancy\"\n | \"sab\" // spontaneous abortion (pedigree terminology)\n | \"tab\" // therapeutic/induced abortion\n | \"ectopic\";\n\nexport type GeneticStatus =\n | \"unaffected\"\n | \"affected\"\n | \"carrier\"\n | \"carrier-x\" // X-linked carrier (dot in center)\n | \"obligate-carrier\"\n | \"presymptomatic\";\n\nexport type ChildType =\n | \"biological\"\n | \"adopted\"\n | \"adopted-in\" // pedigree: adopted into family\n | \"adopted-out\" // pedigree: adopted out of family\n | \"foster\"\n | \"step\"\n | \"surrogate\"\n | \"donor\"\n | \"donor-egg\"\n | \"donor-sperm\"\n | \"donor-embryo\";\n\nexport type IndividualMarker =\n | \"proband\" // pedigree: index case (arrow + P)\n | \"consultand\" // pedigree: person who sought counseling (arrow + C)\n | \"evaluated\" // pedigree: clinically evaluated (E)\n | \"index-person\" // genogram: identified patient (concentric shape)\n | \"transgender\" // Bennett 2022: gender ≠ assigned sex\n | \"no-children\" // by choice\n | \"infertile\"\n // Pedigree convention: ≥1 sibling(s) of unknown count — single diamond with \"?\"\n | \"unknown-siblings\";\n\nexport type TwinType =\n | \"twin-identical\" // monozygotic\n | \"twin-fraternal\" // dizygotic\n | \"twin-unknown\" // unknown zygosity\n | \"triplet-identical\"\n | \"triplet-fraternal\";\n\nexport interface Condition {\n label: string;\n /** Fill pattern for condition display */\n fill: ConditionFill;\n /** Color for the fill (hex or named). Falls back to category default. */\n color?: string;\n /** Medical category for automatic color assignment */\n category?: MedicalCategory;\n}\n\nexport type ConditionFill =\n | \"full\"\n | \"half-left\"\n | \"half-right\"\n | \"half-top\"\n | \"half-bottom\"\n | \"quad-tl\"\n | \"quad-tr\"\n | \"quad-bl\"\n | \"quad-br\"\n | \"striped\" // carrier/asymptomatic\n | \"dotted\"\n | \"carrier\"; // alias for striped\n\n/** Standard 22-category medical condition system (genogram) */\nexport type MedicalCategory =\n | \"cardiovascular\"\n | \"cancer\"\n | \"diabetes\"\n | \"mental-health\"\n | \"depression\"\n | \"anxiety\"\n | \"bipolar\"\n | \"ptsd\"\n | \"substance-alcohol\"\n | \"substance-drugs\"\n | \"substance-tobacco\"\n | \"neurological\"\n | \"respiratory\"\n | \"autoimmune\"\n | \"genetic\"\n | \"reproductive\"\n | \"eating-disorder\"\n | \"learning-developmental\"\n | \"kidney\"\n | \"liver-gi\"\n | \"obesity\"\n | \"other\";\n\n// ─── Fishbone (Ishikawa) Types ──────────────────────────────\n\nexport type FishboneOrientation = \"ltr\" | \"rtl\";\n\n/** Which halves of the spine host ribs. */\nexport type FishboneSides = \"both\" | \"top\" | \"bottom\";\n\n/** Density preset — controls spine length, slot spacing, header size. */\nexport type FishboneDensity = \"compact\" | \"normal\" | \"spacious\";\n\n/** Where cause branches stick out of a rib. */\nexport type FishboneCauseSide = \"head\" | \"tail\" | \"both\";\n\nexport interface FishboneNode {\n /** Display text on the bone. */\n label: string;\n /** Optional explicit hex color (conventionally set only on majors). */\n color?: string;\n /** Nested sub-causes (unbounded depth, recommended ≤ 3). */\n children: FishboneNode[];\n /** Per-rib placement override (only honored on majors). */\n side?: \"top\" | \"bottom\";\n /** Per-rib explicit ordering within its half (lower = closer to tail). */\n order?: number;\n}\n\nexport interface FishboneLegendEntry {\n label: string;\n color: string;\n}\n\nexport interface FishboneAST {\n type: \"fishbone\";\n title?: string;\n /** Problem / outcome displayed in the head box. */\n effect: string;\n /** Top-level cause categories (major bones). */\n majors: FishboneNode[];\n /** Effect position: `ltr` → head on right, `rtl` → head on left. */\n orientation: FishboneOrientation;\n /** Optional explicit canvas dimensions (otherwise auto-computed). */\n width?: number;\n height?: number;\n /** Optional legend entries rendered in a corner box. */\n legend?: FishboneLegendEntry[];\n metadata?: Record<string, string>;\n /** Which sides of the spine host ribs. Default: \"both\". */\n sides?: FishboneSides;\n /** Rib slope dx/dy. Default: 0.6. Accepts number or preset name. */\n ribSlope?: number;\n /** Density preset. Default: \"normal\". */\n density?: FishboneDensity;\n /** Which side of the rib cause branches stick out on. Default: \"head\". */\n causeSide?: FishboneCauseSide;\n}\n\n// ─── Phylogenetic Tree Types ────────────────────────────────\n\n/** Layout algorithm for phylogenetic tree */\nexport type PhyloLayout = \"rectangular\" | \"slanted\" | \"circular\" | \"unrooted\";\n\n/** Tree representation mode — determines how branch lengths are interpreted */\nexport type PhyloMode = \"phylogram\" | \"cladogram\" | \"chronogram\";\n\n/** Clade highlight display mode */\nexport type CladeHighlightMode = \"branch\" | \"background\" | \"both\";\n\n/** A phylogenetic tree node (distinct from family-tree Individual) */\nexport interface PhyloNode {\n /** Unique id (auto-generated for unnamed internal nodes) */\n id: string;\n /** Display label (species name, gene id, etc.) */\n label?: string;\n /** Branch length to parent (substitutions/site or time units) */\n branchLength?: number;\n /** Bootstrap support or Bayesian posterior probability (0-100 or 0-1) */\n support?: number;\n /** Children nodes (empty = leaf/tip) */\n children: PhyloNode[];\n /** Is this a leaf/tip node? */\n isLeaf: boolean;\n /** NHX metadata key-value pairs */\n nhx?: Record<string, string>;\n}\n\n/** Clade definition for visual highlighting */\nexport interface CladeDef {\n id: string;\n /** Label to display next to clade bracket/background */\n label?: string;\n /** Leaf ids that define this clade (MRCA computed automatically) */\n members: string[];\n /** Branch/background color */\n color?: string;\n /** Highlight mode */\n highlight?: CladeHighlightMode;\n}\n\n/** Phylogenetic tree AST — separate from DiagramAST because structure is fundamentally different */\nexport interface PhyloTreeAST {\n type: \"phylo\";\n /** Tree title */\n title?: string;\n /** Root node of the tree */\n root: PhyloNode;\n /** Is this explicitly unrooted? */\n unrooted: boolean;\n /** Layout algorithm */\n layout: PhyloLayout;\n /** Branch length interpretation */\n mode: PhyloMode;\n /** Clade definitions for visual highlighting */\n clades: CladeDef[];\n /** Scale bar label (e.g. \"substitutions/site\", \"Million years ago\") */\n scaleLabel?: string;\n /** Most recent sampling date (for chronogram mode) */\n mrsd?: string;\n /** Outgroup taxon id (for rooting) */\n outgroup?: string;\n /** Custom metadata */\n metadata?: Record<string, string>;\n}\n\n/** Layout result for phylogenetic tree */\nexport interface PhyloLayoutNode {\n node: PhyloNode;\n x: number;\n y: number;\n /** Angle in radians (for circular/unrooted layouts) */\n angle?: number;\n /** Radius from center (for circular/unrooted layouts) */\n radius?: number;\n}\n\n/** Phylogenetic tree render config (extends base RenderConfig) */\nexport interface PhyloRenderConfig {\n fontFamily: string;\n fontSize: number;\n theme: string;\n padding: number;\n /** Branch line width in px */\n branchWidth: number;\n /** Show tip dots */\n showTipDots: boolean;\n /** Show bootstrap/support values as text */\n showSupportValues: boolean;\n /** Show bootstrap/support values as colored dots */\n showSupportDots: boolean;\n /** Minimum support value to display (default: 50) */\n supportThreshold: number;\n /** Show scale bar */\n showScaleBar: boolean;\n /** Tip spacing in px */\n tipSpacing: number;\n /** Fan opening angle in degrees (circular layout, default: 0 = full circle) */\n openAngle: number;\n /** Italicize species binomials automatically */\n italicizeSpecies: boolean;\n}\n\n// ─── Relationship Types ─────────────────────────────────────\n\nexport type RelationshipType =\n // Structural couple relationships (genogram + pedigree)\n | \"married\"\n | \"divorced\"\n | \"separated\"\n | \"engaged\"\n | \"cohabiting\"\n | \"cohabiting-ended\" // unmarried cohabitation that has ended (LATAM \"quiebre\")\n | \"domestic-partnership\"\n | \"consanguineous\"\n // Structural parent-child\n | \"parent-child\"\n | \"adopted\"\n | \"foster\"\n | \"twin-identical\"\n | \"twin-fraternal\"\n // Emotional relationships — Positive/Close (genogram)\n | \"harmony\"\n | \"close\"\n | \"bestfriends\"\n | \"love\"\n | \"inlove\"\n | \"friendship\"\n // Emotional — Negative/Hostile\n | \"hostile\"\n | \"conflict\"\n | \"enmity\"\n | \"distant-hostile\"\n | \"cutoff\"\n // Emotional — Ambivalent/Complex\n | \"close-hostile\"\n | \"fused\"\n | \"fused-hostile\"\n // Emotional — Distance\n | \"distant\"\n | \"normal\"\n | \"nevermet\"\n // Emotional — Abuse (directional)\n | \"abuse\"\n | \"physical-abuse\"\n | \"emotional-abuse\"\n | \"sexual-abuse\"\n | \"neglect\"\n // Emotional — Control/Power (directional)\n | \"manipulative\"\n | \"controlling\"\n | \"jealous\"\n // Emotional — Special\n | \"focused\"\n | \"focused-neg\"\n | \"distrust\"\n | \"admirer\"\n | \"limerence\"\n // Ecomap-specific\n | \"strong\"\n | \"moderate\"\n | \"weak\"\n | \"stressful\"\n | \"stressful-strong\"\n | \"conflictual\"\n | \"broken\"\n | \"reciprocal\";\n\nexport interface Relationship {\n type: RelationshipType;\n from: string; // Individual id\n to: string; // Individual id\n label?: string;\n /** Is this relationship directional? (abuse, control, focused, ecomap energy flow) */\n directional?: boolean;\n /** For ecomap: line weight 1-5 */\n weight?: number;\n /** For ecomap: energy flow direction */\n energyFlow?: \"from\" | \"to\" | \"mutual\" | \"none\";\n /**\n * Genogram parent-child only. When true, this link is data-true but\n * does NOT dominate layout — used for foster/adopted/guardian \"current\n * caregiver\" relationships when biological parents already claim the\n * child structurally. Renderer draws it as a dotted line.\n */\n secondary?: boolean;\n}\n\n// ─── Layout Types ────────────────────────────────────────────\n\nexport interface LayoutResult {\n width: number;\n height: number;\n nodes: LayoutNode[];\n edges: LayoutEdge[];\n}\n\nexport interface LayoutNode {\n id: string;\n x: number;\n y: number;\n width: number;\n height: number;\n /** Generation/layer index (0 = oldest generation) */\n generation: number;\n individual: Individual;\n}\n\nexport interface LayoutEdge {\n from: string;\n to: string;\n relationship: Relationship;\n /** SVG path data (d attribute) */\n path: string;\n}\n\n// ─── Diagram Plugin Interface ────────────────────────────────\n\nexport interface DiagramPlugin {\n type: DiagramType;\n detect: (text: string) => boolean;\n render: (text: string, config?: RenderConfig) => string;\n /** Parse DSL text to the diagram's AST (for JSON export / programmatic access). */\n parse?: (text: string) => unknown;\n /**\n * Optional non-fatal validation pass. Runs after a successful parse and\n * returns domain-level warnings (e.g. an incomplete instrument loop) without\n * blocking rendering. Surfaced through `parseResult` / `renderResult`\n * diagnostics. Must not throw — return `[]` when there's nothing to flag.\n */\n lint?: (text: string) => SchematexDiagnostic[];\n}\n\nexport interface LayoutConfig {\n /** Horizontal spacing between nodes */\n nodeSpacingX: number;\n /** Vertical spacing between generations */\n nodeSpacingY: number;\n /** Node dimensions */\n nodeWidth: number;\n nodeHeight: number;\n}\n\nexport interface RenderConfig {\n fontFamily: string;\n fontSize: number;\n theme: string;\n padding: number;\n /** Show age number inside shapes */\n showAge?: boolean;\n /** Show rich annotations below names */\n showAnnotations?: boolean;\n /** Show relationship labels on lines */\n showEdgeLabels?: boolean;\n /** Show in-law relationship labels */\n showInLawLabels?: boolean;\n /** Legend position override */\n legendPosition?: LegendPosition;\n}\n\n// ─── Electrical Engineering AST Types ───────────────────────\n\n// ── Timing Diagram ──────────────────────────────────────────\n\n/** A single waveform signal or group */\nexport type TimingSignalState =\n | \"0\" | \"1\" | \"x\" | \"z\" | \"=\" | \".\" | \"u\" | \"d\"\n | \"p\" | \"P\" | \"n\" | \"N\" | \"h\" | \"H\" | \"l\" | \"L\"\n | \"2\" | \"3\" | \"4\" | \"5\" | \"6\" | \"7\" | \"8\" | \"9\";\n\nexport interface TimingSignal {\n /** Signal name (display label) */\n name: string;\n /** WaveDrom wave string: sequence of state chars */\n wave: string;\n /** Data labels for bus states (= or 2-9) */\n data?: string[];\n /** Phase offset in half-periods */\n phase?: number;\n /** Period multiplier */\n period?: number;\n /** Node markers for annotation arrows */\n node?: string;\n}\n\nexport interface TimingGroup {\n label: string;\n signals: Array<TimingSignal | TimingGroup>;\n}\n\nexport interface TimingAnnotation {\n /** Source node marker id */\n from: string;\n /** Target node marker id */\n to: string;\n label?: string;\n}\n\nexport interface TimingAST {\n type: \"timing\";\n title?: string;\n /** Time scale multiplier (1–4) */\n hscale?: number;\n signals: Array<TimingSignal | TimingGroup>;\n annotations?: TimingAnnotation[];\n metadata?: Record<string, string>;\n}\n\n// ── Logic Gate ───────────────────────────────────────────────\n\nexport type LogicGateType =\n // ── Combinational Gates ──────────────────────────────────────\n | \"AND\" | \"OR\" | \"NOT\" | \"NAND\" | \"NOR\" | \"XOR\" | \"XNOR\" | \"BUF\"\n // ── Buffers with special output types ────────────────────────\n | \"TRISTATE_BUF\" // Buffer + enable pin; Z-state when disabled\n | \"TRISTATE_INV\" // Inverting buffer + enable pin\n | \"OPEN_DRAIN\" // Open-drain/open-collector output (pull-up required)\n | \"SCHMITT\" // Schmitt trigger; hysteresis symbol inside body\n // ── Edge-triggered flip-flops ─────────────────────────────────\n | \"DFF\" // D flip-flop (clock triangle)\n | \"JKFF\" // JK flip-flop\n | \"SRFF\" // SR flip-flop\n | \"TFF\" // T (toggle) flip-flop\n // ── Level-sensitive latches ────────────────────────────────────\n | \"LATCH_SR\" // SR latch (NOR/NAND cross-coupled, no clock)\n | \"LATCH_D\" // D latch (transparent when enable=1)\n // ── Combinational complex ──────────────────────────────────────\n | \"MUX\" | \"DEMUX\" | \"DECODER\" | \"ENCODER\"\n // ── Sequential complex ─────────────────────────────────────────\n | \"COUNTER\" // Generic binary counter (CTR label, CLK/RESET/Q0–Q3)\n | \"SHIFT_REG\"; // Generic shift register (SRG label, CLK/SER/Q0–Q7)\n\nexport type LogicGateStyle = \"ansi\" | \"iec\";\n\nexport interface LogicGateNode {\n id: string;\n gateType: LogicGateType;\n inputs: string[]; // References to signal ids or gate ids (with ~ for active-low)\n label?: string;\n style?: LogicGateStyle;\n /** Optional module/sub-circuit this gate belongs to */\n moduleId?: string;\n}\n\nexport interface LogicGateModule {\n id: string;\n label: string;\n}\n\nexport interface LogicGateInput {\n id: string;\n label: string;\n isActiveLow?: boolean;\n /** True when the parser inferred this input from a gate reference rather than an explicit declaration. */\n autoDeclared?: boolean;\n}\n\nexport interface LogicGateOutput {\n id: string;\n /** Signal source id (gate output or input port) */\n from: string;\n label: string;\n isActiveLow?: boolean;\n}\n\nexport interface LogicGateAST {\n type: \"logic\";\n title?: string;\n style?: LogicGateStyle;\n inputs: LogicGateInput[];\n outputs: LogicGateOutput[];\n gates: LogicGateNode[];\n modules?: LogicGateModule[];\n metadata?: Record<string, string>;\n /** Non-fatal parser warnings (e.g. signals auto-declared as inputs). */\n warnings?: string[];\n}\n\n// ── Circuit Schematic ────────────────────────────────────────\n\nexport type CircuitComponentType =\n // ── Resistors & Passive Variants ────────────────────────────\n | \"resistor\" // Zigzag (ANSI) / rectangle (IEC)\n | \"potentiometer\" // Resistor + diagonal arrow, 3-pin (A/wiper/B)\n | \"rheostat\" // Resistor + diagonal arrow, 2-pin variable\n | \"thermistor_ntc\" // Resistor + diagonal arrow + \"-t°\" label\n | \"thermistor_ptc\" // Resistor + diagonal arrow + \"+t°\" label\n | \"ldr\" // Resistor + two inward arrows (light dependent)\n | \"varistor\" // Resistor + \"V\" label inside box\n | \"fuse\" // Small rectangle/oval on wire (sacrificial)\n | \"fuse_slow\" // Fuse + \"T\" designation\n\n // ── Capacitors ───────────────────────────────────────────────\n | \"capacitor\" // Two parallel lines (nonpolar)\n | \"electrolytic_cap\" // Curved plate + polarity markers (polar)\n | \"variable_cap\" // Capacitor + diagonal arrow\n\n // ── Inductors ────────────────────────────────────────────────\n | \"inductor\" // Arc humps (air core)\n | \"inductor_iron\" // Arc humps + two parallel core lines\n | \"inductor_ferrite\" // Arc humps + one filled core line\n | \"variable_inductor\" // Inductor + diagonal arrow\n | \"ferrite_bead\" // Small filled rectangle on wire (EMI bead)\n | \"crystal\" // Rect body + two external lines (quartz oscillator)\n | \"transformer\" // Two coil groups + core lines\n\n // ── Diodes ───────────────────────────────────────────────────\n | \"diode\" // Triangle + bar\n | \"zener\" // Triangle + bent bar (Z)\n | \"schottky\" // Triangle + S-bar\n | \"led\" // Diode + two outward arrows\n | \"photodiode\" // Diode + two inward arrows\n | \"varactor\" // Diode + variable capacitor symbol\n | \"tvs_diode\" // Bidirectional zener (two bent bars)\n | \"bridge_rectifier\" // Diamond of 4 diodes, 4-pin (AC1/AC2/DC+/DC−)\n\n // ── Bipolar Transistors ───────────────────────────────────────\n | \"npn\" // NPN BJT (arrow outward on emitter)\n | \"pnp\" // PNP BJT (arrow inward on emitter)\n | \"darlington_npn\" // NPN + NPN Darlington pair\n | \"darlington_pnp\" // PNP + PNP Darlington pair\n\n // ── Field Effect Transistors ──────────────────────────────────\n | \"nmos\" // N-channel MOSFET enhancement (gate insulated, dashed channel)\n | \"pmos\" // P-channel MOSFET enhancement\n | \"nmos_depletion\" // N-channel MOSFET depletion (solid channel)\n | \"jfet_n\" // N-channel JFET (gate arrow pointing in)\n | \"jfet_p\" // P-channel JFET (gate arrow pointing out)\n\n // ── Power Semiconductors ─────────────────────────────────────\n | \"igbt\" // IGBT: MOSFET gate + BJT body + diode body\n | \"scr\" // SCR/Thyristor: diode + gate lead (PNPN)\n | \"triac\" // TRIAC: two back-to-back SCRs + gate\n | \"diac\" // DIAC: two back-to-back diodes, 2-pin\n\n // ── Optoelectronics ───────────────────────────────────────────\n | \"phototransistor\" // NPN shape + two inward arrows on base\n | \"optocoupler\" // LED + phototransistor in dashed isolation box\n\n // ── Op-Amp / Analog ICs ───────────────────────────────────────\n | \"opamp\" // Triangle: +/− inputs, output, ±Vcc\n | \"comparator\" // Triangle (same shape, open-collector output)\n | \"schmitt_buffer\" // Buffer triangle + hysteresis symbol inside\n | \"tri_state_buffer\" // Buffer triangle + enable pin\n | \"instrumentation_amp\" // Three op-amp INA block\n\n // ── Generic IC & Special Blocks ──────────────────────────────\n | \"generic_ic\" // Rect with configurable labeled pins (attrs: pins_left, pins_right)\n | \"voltage_regulator\" // 3-terminal rect block (IN/GND/OUT), e.g. LM7805\n | \"dc_dc_converter\" // 2-port rect block with \"DC/DC\" label\n | \"555_timer\" // 8-pin rect with standard 555 pinout\n | \"terminal_block\" // Labeled enclosure with N named terminals (junction box, terminal strip)\n\n // ── Sources & Power ───────────────────────────────────────────\n | \"voltage_source\" // Circle + V or ± polarity\n | \"current_source\" // Circle + arrow\n | \"ac_source\" // Circle + ~ (sine symbol)\n | \"battery\" // Alternating long/short lines\n | \"vcc\" // Power rail arrow pointing up\n | \"ground\" // Earth ground (3 horizontal lines)\n | \"gnd_signal\" // Signal ground (solid triangle)\n | \"gnd_chassis\" // Chassis ground (hash-like)\n | \"gnd_digital\" // Digital ground (square)\n\n // ── Switches ──────────────────────────────────────────────────\n | \"switch_spst\" // Single-pole single-throw (angled arm + gap)\n | \"switch_spdt\" // Single-pole double-throw (3-pin)\n | \"switch_dpdt\" // Double-pole double-throw (6-pin)\n | \"push_no\" // Push button normally-open (circle + contact gap)\n | \"push_nc\" // Push button normally-closed (circle + line + slash)\n\n // ── Relays (coil and contacts placed separately) ───────────────\n | \"relay_coil\" // Rectangle with coil symbol, 2-pin\n | \"relay_no\" // Relay contact normally-open (like switch_spst)\n | \"relay_nc\" // Relay contact normally-closed (with slash)\n\n // ── Industrial control / Power electrical (IEC 60617 §07/§14) ──\n | \"contactor\" // Heavy-load switching (KM*) — bold contact + dash actuator\n | \"solenoid_valve\" // Pneumatic / hydraulic control (EV*) — coil + valve symbol\n | \"thermal_overload\" // Motor protection (F2*) — hashed rectangle + heat marks\n | \"disconnect_switch\" // Service disconnect / isolator (Q1*) — switch with disconnect bracket\n\n // ── Electromechanical ─────────────────────────────────────────\n | \"motor\" // Circle + M + shaft line\n | \"speaker\" // Triangle + box + radiating lines\n | \"microphone\" // Circle + vertical lines (capsule)\n | \"buzzer\" // Piezo symbol or speaker variant\n\n // ── Measurement ───────────────────────────────────────────────\n | \"ammeter\" // Circle + \"A\"\n | \"voltmeter\" // Circle + \"V\"\n | \"wattmeter\" // Circle + \"W\"\n | \"oscilloscope\" // Circle + waveform symbol\n\n // ── Connectors & Annotations ──────────────────────────────────\n | \"wire\" // Plain wire segment\n | \"dot\" // Junction dot\n | \"label\" // Net label (flag or text-only)\n | \"port\" // Named port (hollow circle + label)\n | \"test_point\" // TP marker (small circle + \"TP\" label)\n | \"no_connect\" // X marker — no electrical connection\n | \"antenna\"; // Antenna (vertical line + radiating stubs)\n\nexport type CircuitDirection = \"right\" | \"left\" | \"up\" | \"down\";\n\nexport interface CircuitComponent {\n id: string;\n componentType: CircuitComponentType;\n direction: CircuitDirection;\n /** Reference to anchor point of previous/named element: e.g. \"R1.end\", \"origin\" */\n at?: string;\n /** Display label (R1, C2, etc.) */\n label?: string;\n /** Value annotation (1kΩ, 100nF, etc.) */\n value?: string;\n /** Extra attributes (length for wires, gain for opamp, etc.) */\n attrs?: Record<string, string>;\n}\n\n/** Multi-terminal electrical node — connects multiple anchor refs to the same node */\nexport interface CircuitNet {\n /** Net name (e.g. \"VOUT\") */\n id: string;\n /** Anchor refs sharing the same node (e.g. [\"R2.end\", \"U1.out\", \"OUT.start\"]) */\n anchors: string[];\n}\n\nexport interface CircuitAST {\n type: \"circuit\";\n title?: string;\n components: CircuitComponent[];\n /** Explicit net declarations for multi-terminal connections */\n nets: CircuitNet[];\n metadata?: Record<string, string>;\n /** Layout mode: \"positional\" (Schemdraw-style direction chain) or \"netlist\" (SPICE-style, auto-layout). */\n mode?: \"positional\" | \"netlist\";\n /**\n * Netlist-only. Maps componentId → { pinName → netId }.\n * Populated by the netlist parser; consumed by the auto-layout engine.\n */\n pinMap?: Record<string, Record<string, string>>;\n}\n\n// ── Block Diagram ────────────────────────────────────────────\n\nexport type BlockRole = \"plant\" | \"controller\" | \"sensor\" | \"actuator\" | \"reference\" | \"disturbance\" | \"generic\";\n\nexport interface BlockNode {\n id: string;\n /** Display label / transfer function e.g. \"G(s)\" */\n label: string;\n role?: BlockRole;\n /** Routing hint for feedback/feedforward blocks: \"above\" = route over forward path */\n route?: \"above\" | \"below\";\n}\n\nexport interface SummingJunction {\n id: string;\n /** Signed inputs: \"+r\" means add signal r, \"-ym\" means subtract signal ym */\n inputs: string[];\n /** Output signal id */\n output?: string;\n}\n\nexport interface BlockEdge {\n from: string;\n to: string;\n /** Signal label e.g. \"E(s)\", \"U(s)\" */\n label?: string;\n /** Dashed line for discrete-time signals */\n discrete?: boolean;\n}\n\nexport interface BlockAST {\n type: \"blockdiagram\";\n title?: string;\n blocks: BlockNode[];\n sums: SummingJunction[];\n connections: BlockEdge[];\n metadata?: Record<string, string>;\n}\n\n// ── Ladder Logic ─────────────────────────────────────────────\n\nexport type LadderContactType = \"XIC\" | \"XIO\" | \"ONS\" | \"OSF\";\nexport type LadderCoilType = \"OTE\" | \"OTL\" | \"OTU\" | \"OTN\" | \"RES\";\nexport type LadderFBType =\n | \"TON\" | \"TOFF\" | \"TP\" // Timers\n | \"CTU\" | \"CTD\" | \"CTUD\" // Counters\n | \"ADD\" | \"SUB\" | \"MUL\" | \"DIV\" // Math\n | \"MOV\" // Move\n | \"EQU\" | \"NEQ\" | \"GRT\" | \"LES\" | \"GEQ\" | \"LEQ\"; // Compare (Allen-Bradley convention)\n\nexport interface LadderContact {\n elementType: \"contact\";\n contactType: LadderContactType;\n tag: string;\n address?: string;\n /** Human-readable description (rendered above the tag as 1–3 wrapped lines) */\n name?: string;\n}\n\nexport interface LadderCoil {\n elementType: \"coil\";\n coilType: LadderCoilType;\n tag: string;\n address?: string;\n /** Human-readable description (rendered above the tag as 1–3 wrapped lines) */\n name?: string;\n}\n\nexport interface LadderFunctionBlock {\n elementType: \"function_block\";\n fbType: LadderFBType;\n tag: string;\n params: Record<string, string | number>;\n}\n\nexport type LadderElement = LadderContact | LadderCoil | LadderFunctionBlock;\n\nexport interface LadderBranch {\n elements: LadderElement[];\n}\n\nexport interface LadderRung {\n number: number;\n comment?: string;\n /** Sequential elements and parallel groups */\n elements: Array<LadderElement | { parallel: LadderBranch[] }>;\n}\n\nexport interface LadderAST {\n type: \"ladder\";\n title?: string;\n rungs: LadderRung[];\n metadata?: Record<string, string>;\n}\n\n// ── Single-Line Diagram ──────────────────────────────────────\n\nexport type SLDNodeType =\n // ── Generation & Sources ─────────────────────────────────────\n | \"utility\" // Infinite bus / utility feed (circle + ~)\n | \"generator\" // Synchronous generator (circle + G)\n | \"solar\" // PV array (panel symbol)\n | \"wind\" // Wind turbine\n | \"ups\" // Uninterruptible power supply block\n\n // ── Transformers (winding configuration variants) ──────────────\n | \"transformer\" // Generic (two coil groups, no winding spec)\n | \"transformer_dy\" // Delta primary → Wye grounded secondary (Δ-Yg)\n | \"transformer_yd\" // Wye grounded primary → Delta secondary (Yg-Δ)\n | \"transformer_yy\" // Wye-Wye (both grounded)\n | \"transformer_dd\" // Delta-Delta\n | \"autotransformer\" // Single winding with tap (zigzag coil symbol)\n | \"transformer_3winding\" // Three-winding power transformer\n\n // ── Buses & Nodes ─────────────────────────────────────────────\n | \"bus\" // Horizontal thick line (6px stroke)\n | \"bus_tie\" // Bus-tie breaker between two parallel same-level buses\n | \"hub\" // Multi-port synchronization / combining hub (wide rectangle)\n\n // ── Switching Equipment ───────────────────────────────────────\n | \"breaker\" // Circuit breaker (diagonal + arc at top)\n | \"breaker_vacuum\" // Vacuum CB (diagonal + \"V\" inside oval)\n | \"switch\" // Disconnect switch (diagonal, no arc, open tip)\n | \"switch_load\" // Load interrupter switch\n | \"ground_switch\" // Grounding disconnect (diagonal + ground symbol)\n | \"ats\" // Automatic transfer switch (two breakers + tie)\n | \"recloser\" // Auto-reclosing breaker (diagonal + arc + circling arrow)\n | \"sectionalizer\" // Sectionalizer (diagonal + \"S\" designation)\n | \"fuse\" // Expulsion fuse cutout (diagonal in oval)\n | \"fuse_cl\" // Current-limiting fuse (diagonal in rect)\n\n // ── Protection & Monitoring ───────────────────────────────────\n | \"ct\" // Current transformer (small circle + CT + line through)\n | \"pt\" // Potential/voltage transformer (small circle + PT)\n | \"relay\" // Protection relay (small circle + ANSI device number)\n | \"surge_arrester\" // Surge arrester / lightning arrester (downward arrow + ground)\n | \"ground_fault\" // Ground fault detector (GFI)\n\n // ── Loads & Equipment ─────────────────────────────────────────\n | \"motor\" // Motor (circle + M + 3-phase dots)\n | \"load\" // Generic load (rectangle)\n | \"capacitor_bank\" // Capacitor bank (two plates + switch)\n | \"harmonic_filter\" // Passive harmonic filter (LC symbol)\n | \"vfd\" // Variable frequency drive (rect + \"VFD\")\n\n // ── Metering ──────────────────────────────────────────────────\n | \"watthour_meter\" // Energy meter (circle + Wh)\n | \"demand_meter\" // Demand meter (circle + D);\n\nexport interface SLDNode {\n id: string;\n nodeType: SLDNodeType;\n label?: string;\n /** Voltage level e.g. \"13.8kV\", \"480V\" */\n voltage?: string;\n /** Equipment rating e.g. \"1000A\", \"500kVA\" */\n rating?: string;\n /** ANSI device number (relays: 51, 87, 27, etc.) */\n deviceNumber?: string;\n /** Additional nameplate data (transformer: kVA, ratio, %Z) */\n nameplate?: Record<string, string>;\n}\n\nexport interface SLDConnection {\n from: string;\n to: string;\n /** Cable specification e.g. \"3#2/0 AWG\" */\n cable?: string;\n label?: string;\n}\n\n/**\n * Symbol standard for SLD / circuit glyphs. `ansi` (IEEE 315 / ANSI Y32.2) is\n * the default and preserves historical rendering. `iec` (IEC 60617) switches to\n * IEC symbol forms. `abnt` (Brazil, NBR 5410) and `as-nzs` (Australia/NZ,\n * AS/NZS 3000) are IEC 60364-family presets: they reuse the IEC glyphs and add\n * their own jurisdiction labelling.\n */\nexport type SLDStandard = \"ansi\" | \"iec\" | \"abnt\" | \"as-nzs\";\n\n/** True for standards that render with the IEC 60617 glyph set. */\nexport function isIecFamily(standard: SLDStandard | undefined): boolean {\n return standard === \"iec\" || standard === \"abnt\" || standard === \"as-nzs\";\n}\n\nexport interface SLDAST {\n type: \"sld\";\n title?: string;\n /** Symbol standard (default `ansi`). */\n standard?: SLDStandard;\n nodes: SLDNode[];\n connections: SLDConnection[];\n metadata?: Record<string, string>;\n}\n\n// ─── Entity Structure Types ─────────────────────────────────\n\nexport type EntityType =\n | \"corp\"\n | \"llc\"\n | \"lp\"\n | \"trust\"\n | \"individual\"\n | \"foundation\"\n | \"disregarded\"\n | \"pool\"\n | \"placeholder\";\n\nexport type EntityStatus = \"normal\" | \"new\" | \"eliminated\" | \"modified\";\n\nexport interface EntityNode {\n id: string;\n name: string;\n entityType: EntityType;\n /** ISO 3166-1 alpha-2 or 2-3 letter state code (DE, IE, KY, BVI, ...) */\n jurisdiction?: string;\n status?: EntityStatus;\n taxClass?: string;\n role?: string;\n note?: string;\n formationDate?: string;\n properties?: Record<string, string>;\n}\n\nexport type EntityEdgeOp =\n | \"ownership\" // -> solid black arrow (default)\n | \"voting\" // ==> double line (voting-only control)\n | \"pool\" // -.-> dashed grey (option pool)\n | \"license\" // -~-> purple dashed (IP license / management)\n | \"distribution\"; // --> green dashed (trust distribution)\n\nexport interface EntityEdge {\n from: string;\n to: string;\n op: EntityEdgeOp;\n /** Raw percentage text, e.g. \"100%\" or \"V 75% / E 50%\" or \"was 40% → 100%\" */\n percentage?: string;\n /** Share class label (Series A Pref, Common, Option Pool) */\n shareClass?: string;\n label?: string;\n}\n\nexport interface JurisdictionDef {\n code: string;\n name: string;\n color?: string;\n}\n\nexport interface ClusterDef {\n id: string;\n label: string;\n /** Entity ids (explicit members) */\n members: string[];\n color?: string;\n}\n\nexport interface EntityAST {\n type: \"entity\";\n title?: string;\n entities: EntityNode[];\n edges: EntityEdge[];\n jurisdictions: JurisdictionDef[];\n clusters: ClusterDef[];\n metadata?: Record<string, string>;\n}\n\n// ─── ERD (Entity-Relationship Diagram) Types ─────────────────\n// 27-ERD-STANDARD — crow's foot first. Chen / Barker deferred.\n\nexport type ErdNotation = \"crowsfoot\" | \"chen\" | \"barker\";\n\n/** Min..Max cardinality for one end of a relationship. */\nexport type ErdCardinality =\n | \"one-mandatory\" // 1..1 ─┃\n | \"one-optional\" // 0..1 ─○\n | \"many-mandatory\" // 1..N ─┃<\n | \"many-optional\"; // 0..N ─○<\n\n/** Attribute / column row within a tabular entity (crow's foot mode). */\nexport interface ErdAttribute {\n name: string;\n /** Free-form type token, e.g. \"int\", \"varchar(255)\", \"timestamp\" — rendered verbatim. */\n type?: string;\n pk?: boolean;\n fk?: boolean;\n uk?: boolean;\n /** NOT NULL marker. */\n notNull?: boolean;\n /** FK target as \"TableName.columnName\" (parser canonicalizes inline `FK -> X.y` here). */\n fkTarget?: string;\n /** Optional in-line comment / description. */\n comment?: string;\n}\n\nexport interface ErdEntity {\n id: string;\n /** Display name (defaults to id when not separately quoted). */\n name: string;\n attributes: ErdAttribute[];\n /** Reserved for Chen mode (weak entity). Ignored in crow's foot rendering. */\n weak?: boolean;\n}\n\nexport interface ErdRef {\n /** \"TableName\" or \"TableName.columnName\". */\n from: string;\n to: string;\n fromCard: ErdCardinality;\n toCard: ErdCardinality;\n /** \"--\" identifying (solid). \"..\": non-identifying (dashed). */\n identifying: boolean;\n label?: string;\n}\n\nexport interface ErdAst {\n type: \"erd\";\n notation: ErdNotation;\n direction: \"LR\" | \"TB\";\n title?: string;\n entities: ErdEntity[];\n refs: ErdRef[];\n}\n\n/** Per-attribute-row geometry inside a laid-out entity. */\nexport interface ErdLayoutRow {\n attribute: ErdAttribute;\n /** y offset relative to entity top, where the row's vertical center sits. */\n yCenter: number;\n}\n\nexport interface ErdLayoutEntity {\n entity: ErdEntity;\n x: number;\n y: number;\n width: number;\n height: number;\n /** y coordinate of the header bar baseline (relative to entity top). */\n headerHeight: number;\n rows: ErdLayoutRow[];\n}\n\nexport interface ErdLayoutEdge {\n ref: ErdRef;\n /** Orthogonal SVG path data (\"M ... L ... L ...\"). */\n path: string;\n /** Center coords of the source-end glyph anchor (just outside the entity edge). */\n fromAnchor: { x: number; y: number; side: \"left\" | \"right\" | \"top\" | \"bottom\" };\n toAnchor: { x: number; y: number; side: \"left\" | \"right\" | \"top\" | \"bottom\" };\n /** Optional label position (mid-segment). */\n labelAt?: { x: number; y: number };\n}\n\nexport interface ErdLayoutResult {\n ast: ErdAst;\n entities: ErdLayoutEntity[];\n edges: ErdLayoutEdge[];\n width: number;\n height: number;\n}\n\n// ── EE Plugin union type (for type-narrowing in plugins) ──────\n\nexport type EEDiagramAST =\n | TimingAST\n | LogicGateAST\n | CircuitAST\n | BlockAST\n | LadderAST\n | SLDAST;\n\n// ─── Venn / Euler Diagram Types ──────────────────────────────\n\nexport type VennDiagramMode = \"auto\" | \"venn\" | \"euler\";\nexport type VennPalette = \"default\" | \"brand\" | \"monochrome\";\nexport type VennBlendMode = \"multiply\" | \"screen\" | \"none\";\nexport type VennEulerRelationType = \"subset\" | \"disjoint\" | \"overlap\";\n\n/** Raw value attached to a region. */\nexport type VennRegionValue =\n | { kind: \"integer\"; value: number }\n | { kind: \"percent\"; value: number }\n | { kind: \"text\"; value: string }\n | { kind: \"list\"; value: string[] }\n | { kind: \"none\" };\n\n/** One set (a circle or ellipse in the diagram). */\nexport interface VennSet {\n id: string;\n label: string;\n /** Optional explicit elements (enumeration DSL). */\n elements?: string[];\n /** Override color (hex). */\n color?: string;\n}\n\n/** A named region. `sets` is the subset of set ids that define it (at least one). */\nexport interface VennRegion {\n /** Sorted list of set ids that belong to the intersection (e.g. [\"A\",\"B\"]). */\n sets: string[];\n /** Does this region mean \"only\" these sets (exclude any other set)? */\n only: boolean;\n /** Value payload attached to the region. */\n value: VennRegionValue;\n}\n\nexport interface VennEulerRelation {\n from: string;\n to: string;\n type: VennEulerRelationType;\n}\n\nexport interface VennConfig {\n mode: VennDiagramMode;\n proportional: boolean;\n palette: VennPalette;\n blendMode: VennBlendMode;\n showCounts: boolean | \"auto\";\n showPercent: boolean;\n}\n\nexport interface VennAST {\n type: \"venn\";\n title?: string;\n sets: VennSet[];\n regions: VennRegion[];\n relations: VennEulerRelation[];\n config: VennConfig;\n metadata?: Record<string, string>;\n}\n\n/** Circle geometry (n=2, n=3 and Euler). */\nexport interface VennCircle {\n id: string;\n cx: number;\n cy: number;\n r: number;\n}\n\n/** Ellipse geometry (n=4). */\nexport interface VennEllipse {\n id: string;\n cx: number;\n cy: number;\n rx: number;\n ry: number;\n /** Rotation in degrees around (cx,cy). */\n rotation: number;\n}\n\nexport type VennShape =\n | ({ kind: \"circle\" } & VennCircle)\n | ({ kind: \"ellipse\" } & VennEllipse);\n\nexport interface VennLabelPosition {\n /** Region this label describes (sorted set ids). */\n sets: string[];\n /** Canonical label text (e.g. \"A ∩ B\", \"42\", \"[a,b,c]\"). */\n label: string;\n /** Centroid x / y (inside or external). */\n x: number;\n y: number;\n /** If true, label is placed outside the region and `leader` is populated. */\n external: boolean;\n /** Optional leader line endpoints (from region-interior → label). */\n leader?: { x1: number; y1: number; x2: number; y2: number };\n /** Text anchor for external labels. */\n anchor?: \"start\" | \"middle\" | \"end\";\n}\n\nexport interface VennLayoutResult {\n width: number;\n height: number;\n /** Rendering mode chosen (venn or euler; upset deferred). */\n mode: \"venn\" | \"euler\";\n /** Shape per set id (circles for n=2/3/euler, ellipses for n=4). */\n shapes: VennShape[];\n /** Region labels + placements. */\n labels: VennLabelPosition[];\n /** Set-title positions (one per set). */\n setLabels: Array<{ id: string; label: string; x: number; y: number; anchor: \"start\" | \"middle\" | \"end\" }>;\n /** Title placement (optional). */\n title?: { text: string; x: number; y: number };\n /** Proportional-solve residual (0 if not proportional). */\n proportionalResidual?: number;\n}\n// ─── Flowchart Types ─────────────────────────────────────────\n\nexport type FlowchartDirection = \"TB\" | \"BT\" | \"LR\" | \"RL\";\n\n/**\n * Shape keyword catalog. M1 implements only the first 5; the rest are reserved\n * for M2 so AST/types don't have to be rewritten later.\n */\nexport type FlowchartShape =\n // M1 core shapes\n | \"rect\"\n | \"round\"\n | \"stadium\"\n | \"diamond\"\n | \"parallelogram\"\n // M2 (declared for forward-compat; parser accepts them but may fall back to \"rect\")\n | \"parallelogram-alt\"\n | \"trapezoid\"\n | \"trapezoid-alt\"\n | \"subroutine\"\n | \"cylinder\"\n | \"circle\"\n | \"double-circle\"\n | \"hexagon\"\n | \"asymmetric\";\n\nexport type FlowchartEdgeKind =\n | \"solid\" // -->\n | \"none\" // ---\n | \"dotted\" // -.->\n | \"thick\" // ==>\n | \"bidirectional\" // <-->\n | \"crossed\" // --x\n | \"round-end\"; // --o\n\nexport type FlowchartArrowEnd = \"none\" | \"arrow\" | \"circle\" | \"cross\";\n\nexport interface FlowchartNode {\n id: string;\n label: string;\n shape: FlowchartShape;\n icon?: string;\n classes?: string[];\n /** Inline CSS overrides from `style nodeId fill:#f9f,...` */\n style?: Record<string, string>;\n /** Containing subgraph id (undefined = root) */\n parent?: string;\n}\n\nexport interface FlowchartEdge {\n id?: string;\n from: string;\n to: string;\n kind: FlowchartEdgeKind;\n label?: string;\n arrowStart?: FlowchartArrowEnd;\n arrowEnd?: FlowchartArrowEnd;\n classes?: string[];\n /** Reversed during cycle-removal (renderer must flip visual arrow) */\n isReversed?: boolean;\n}\n\nexport interface FlowchartSubgraph {\n id: string;\n label: string;\n direction?: FlowchartDirection;\n children: string[];\n subgraphs: string[];\n classes?: string[];\n}\n\nexport interface FlowchartClassDef {\n id: string;\n props: Record<string, string>;\n}\n\nexport interface FlowchartAST {\n type: \"flowchart\";\n title?: string;\n direction: FlowchartDirection;\n nodes: FlowchartNode[];\n edges: FlowchartEdge[];\n subgraphs: FlowchartSubgraph[];\n classDefs: FlowchartClassDef[];\n /** linkStyle index → css-ish props. Parsed in M1, applied in M2. */\n linkStyles: Map<number, Record<string, string>>;\n metadata?: Record<string, string>;\n}\n\nexport interface FlowchartLayoutNode {\n node: FlowchartNode;\n x: number;\n y: number;\n width: number;\n height: number;\n /** 0-based layer index (top for TB, left for LR) */\n layer: number;\n /** Position within the layer (0-based) */\n order: number;\n /** Dummy routing node inserted for long edges */\n isDummy?: boolean;\n}\n\nexport interface FlowchartLayoutEdge {\n edge: FlowchartEdge;\n /** SVG path d attribute */\n path: string;\n /** Label anchor with optional text-anchor hint for proper line clearance */\n labelAnchor?: { x: number; y: number; textAnchor?: \"start\" | \"middle\" | \"end\" };\n /** Position in `ast.edges` (declaration order) — used by linkStyle index targeting */\n index?: number;\n}\n\nexport interface FlowchartLayoutCluster {\n subgraph: FlowchartSubgraph;\n x: number;\n y: number;\n width: number;\n height: number;\n depth: number;\n}\n\nexport interface FlowchartLayoutResult {\n width: number;\n height: number;\n direction: FlowchartDirection;\n nodes: FlowchartLayoutNode[];\n edges: FlowchartLayoutEdge[];\n clusters: FlowchartLayoutCluster[];\n}\n\n// ─── Mindmap Types ──────────────────────────────────────────\n\nexport type MindmapStyle = \"map\" | \"logic-right\";\n\n/**\n * Inline markdown token for mindmap labels. Parsed once at parse-time by\n * `inline.ts`, consumed by layout (width measurement) and renderer (tspan\n * emission). See `docs/reference/00-OVERVIEW.md` for the DSL contract.\n */\nexport type InlineToken =\n | { kind: \"text\"; value: string; bold?: boolean; italic?: boolean }\n | { kind: \"code\"; value: string }\n | { kind: \"link\"; href: string; value: InlineToken[] }\n | { kind: \"checkbox\"; checked: boolean };\n\nexport interface MindmapNode {\n id: string;\n /** Raw label text (post-bullet-marker, pre-tokenize) — kept for title/tooltip. */\n label: string;\n /** Tokenized label. Layout & renderer consume this. */\n tokens: InlineToken[];\n depth: number;\n children: MindmapNode[];\n}\n\nexport interface MindmapAST {\n type: \"mindmap\";\n title?: string;\n style: MindmapStyle;\n root: MindmapNode;\n /** Theme override from DSL `%% theme:` directive. */\n themeOverride?: string;\n /** Max wrap width for labels (px). Default 240. From `%% maxLabelWidth:`. */\n maxLabelWidth: number;\n}\n\nexport interface MindmapLayoutNode {\n node: MindmapNode;\n x: number;\n y: number;\n /** \"center\" for root; \"left\"/\"right\" for map style; \"right\" for logic-right. */\n side: \"left\" | \"right\" | \"center\";\n /** Main-branch index (0..N-1); -1 for root. Drives palette. */\n branchIndex: number;\n labelWidth: number;\n labelHeight: number;\n /** Font size chosen for this node — used by renderer + for per-line measurement. */\n fontSize: number;\n /** Wrapped token lines. Always at least one entry. */\n lines: MindmapLabelLine[];\n}\n\nexport interface MindmapLabelLine {\n tokens: InlineToken[];\n width: number;\n}\n\nexport interface MindmapLayoutEdge {\n from: string;\n to: string;\n path: string;\n color: string;\n width: number;\n}\n\nexport interface MindmapLayoutResult {\n width: number;\n height: number;\n style: MindmapStyle;\n nodes: MindmapLayoutNode[];\n edges: MindmapLayoutEdge[];\n title?: string;\n}\n\n// ─── Breadboard / Physical Wiring Types ─────────────────────\n\n/**\n * Breadboard form factor:\n * - \"mini\" 170 tie-points, 17 cols × 5+5 rows, no power rails\n * - \"half\" 400 tie-points, 30 cols, 2 rail pairs (continuous)\n * - \"full\" 830 tie-points, 63 cols, 2 rail pairs (broken at col 30/31)\n */\nexport type BreadboardForm = \"mini\" | \"half\" | \"full\";\n\n/** Power-rail half: top vs bottom edge of board, positive vs negative stripe. */\nexport type BreadboardRail = \"+t\" | \"-t\" | \"+b\" | \"-b\";\n\n/** Breadboard hole address — main grid (col + row) or rail (col + rail). */\nexport type BreadboardCoord =\n | { kind: \"hole\"; col: number; row: \"a\" | \"b\" | \"c\" | \"d\" | \"e\" | \"f\" | \"g\" | \"h\" | \"i\" | \"j\" }\n | { kind: \"rail\"; rail: BreadboardRail; col: number };\n\n/** Off-board MCU placement (relative to breadboard substrate). */\nexport type BreadboardSidePlacement = \"beside-left\" | \"beside-right\" | \"above\" | \"below\";\n\n/** Where a part lives. Either a span across the grid (resistor, led, dip) or a side placement (uno). */\nexport type BreadboardPlacement =\n | { kind: \"point\"; at: BreadboardCoord }\n | { kind: \"span\"; from: BreadboardCoord; to: BreadboardCoord }\n | { kind: \"side\"; side: BreadboardSidePlacement };\n\n/** Catalog of v0.1 part kinds. */\nexport type BreadboardPartKind =\n | \"resistor\"\n | \"led\"\n | \"cap-elec\"\n | \"cap-ceramic\"\n | \"diode\"\n | \"button\"\n | \"dip\"\n | \"header\"\n | \"mcu-uno\"\n | \"mcu-nano\"\n | \"mcu-esp32\"\n | \"mcu-pico\"\n | \"sensor-hcsr04\"\n | \"sensor-dht11\"\n | \"sensor-dht22\"\n | \"display-oled-ssd1306\"\n | \"display-lcd-1602-i2c\"\n | \"module-rotary-ky040\"\n | \"actuator-servo-sg90\";\n\nexport interface BreadboardPart {\n /** User-assigned id (e.g. \"uno\", \"r1\"). */\n id: string;\n kind: BreadboardPartKind;\n /** Optional kind-specific args. e.g. resistor.value=\"220\", dip.pins=8, led.color=\"red\". */\n args: Record<string, string | number>;\n placement: BreadboardPlacement;\n /** Optional inline label drawn near the part body. */\n label?: string;\n}\n\nexport type BreadboardWireColor =\n | \"red\"\n | \"black\"\n | \"blue\"\n | \"yellow\"\n | \"orange\"\n | \"green\"\n | \"white\"\n | \"purple\"\n | \"brown\"\n | \"grey\";\n\n/** Wire endpoint — either a part pin or a board hole/rail. */\nexport type BreadboardEndpoint =\n | { kind: \"pin\"; partId: string; pin: string }\n | { kind: \"coord\"; at: BreadboardCoord };\n\nexport interface BreadboardWire {\n from: BreadboardEndpoint;\n to: BreadboardEndpoint;\n color: BreadboardWireColor;\n /** Optional intermediate hole that biases the Bézier control points. */\n via?: BreadboardCoord;\n}\n\nexport interface BreadboardAst {\n type: \"breadboard\";\n board: BreadboardForm;\n title?: string;\n parts: BreadboardPart[];\n wires: BreadboardWire[];\n}\n\n/** Resolved part box on (or beside) the substrate. */\nexport interface BreadboardLayoutPart {\n part: BreadboardPart;\n /** Top-left x of bounding box in canvas px. */\n x: number;\n y: number;\n width: number;\n height: number;\n /** For span/point parts: rotation angle in degrees (currently 0 or 90). */\n rotation: number;\n /** Resolved pin centers in canvas px, keyed by pin name. */\n pins: Record<string, { x: number; y: number }>;\n}\n\nexport interface BreadboardLayoutWire {\n wire: BreadboardWire;\n /** Cubic Bézier path \"M x1 y1 C cx1 cy1 cx2 cy2 x2 y2\". */\n path: string;\n /** Endpoint dots (rendered as small filled circles). */\n fromXY: { x: number; y: number };\n toXY: { x: number; y: number };\n color: BreadboardWireColor;\n}\n\nexport interface BreadboardLayoutSubstrate {\n /** Top-left of board substrate. */\n x: number;\n y: number;\n width: number;\n height: number;\n /** Hole pitch in px (default 14). */\n pitch: number;\n /** Number of columns (17 / 30 / 63). */\n cols: number;\n /** Whether rails exist on this form. */\n hasRails: boolean;\n /** Whether rails break at col 30/31 (full board only). */\n railsBreak: boolean;\n /** Vertical center of the trough channel. */\n troughY: number;\n /** Width of trough channel (≈ pitch). */\n troughHeight: number;\n}\n\nexport interface BreadboardLayoutResult {\n ast: BreadboardAst;\n substrate: BreadboardLayoutSubstrate;\n parts: BreadboardLayoutPart[];\n wires: BreadboardLayoutWire[];\n width: number;\n height: number;\n}\n\n// ─── BPMN AST Types (25-BPMN-STANDARD) ─────────────────────\n\n/** Direction the process flows. LR is conventional. */\nexport type BpmnDirection = \"LR\" | \"TB\";\n\n/** BPMN event lifecycle role — encoded in stroke weight. */\nexport type BpmnEventKind = \"start\" | \"intermediate\" | \"end\";\n\n/** Trigger types (inner glyph). v0.1 supports the common subset. */\nexport type BpmnEventTrigger = \"none\" | \"message\" | \"timer\";\n\n/** Filled glyph = throw, unfilled = catch. v0.1 derives this from kind+context. */\nexport type BpmnEventThrowCatch = \"throw\" | \"catch\";\n\nexport interface BpmnEvent {\n id: string;\n kind: BpmnEventKind;\n trigger: BpmnEventTrigger;\n /** Filled (throw) vs unfilled (catch). End events with a trigger throw; intermediate without context catch. */\n throwCatch: BpmnEventThrowCatch;\n label?: string;\n /** Owning lane id, set by parser. */\n laneId: string;\n /** Owning pool id. */\n poolId: string;\n}\n\n/** Activity (rounded rectangle) — v0.1 covers task and collapsed subprocess. */\nexport type BpmnActivityKind = \"task\" | \"subprocess-collapsed\";\n\n/** Task type marker (top-left small icon). */\nexport type BpmnTaskMarker =\n | \"abstract\"\n | \"user\"\n | \"service\"\n | \"send\"\n | \"receive\"\n | \"manual\"\n | \"script\";\n\nexport interface BpmnActivity {\n id: string;\n kind: BpmnActivityKind;\n marker: BpmnTaskMarker;\n label: string;\n laneId: string;\n poolId: string;\n}\n\n/** Gateway types — diamond inner glyph. */\nexport type BpmnGatewayKind = \"xor\" | \"or\" | \"and\" | \"event\";\n\nexport interface BpmnGateway {\n id: string;\n gatewayKind: BpmnGatewayKind;\n label?: string;\n laneId: string;\n poolId: string;\n}\n\nexport type BpmnFlowObject = BpmnEvent | BpmnActivity | BpmnGateway;\n\n/** Connector kinds — sequence/conditional/default within a pool, message across pools. */\nexport type BpmnFlowKind = \"sequence\" | \"conditional\" | \"default\" | \"message\";\n\nexport interface BpmnFlow {\n /** Source flow-object id, OR a pool name (for message flows from a black-box pool). */\n from: string;\n /** Target flow-object id, OR a pool name. */\n to: string;\n kind: BpmnFlowKind;\n label?: string;\n}\n\nexport interface BpmnLane {\n id: string;\n label: string;\n poolId: string;\n /** Ordered child object ids (events / activities / gateways). */\n children: string[];\n}\n\nexport interface BpmnPool {\n id: string;\n label: string;\n /** Black-box pools must contain no flow objects. */\n blackbox: boolean;\n /** Lane ids in display order. Empty for blackbox. */\n lanes: string[];\n}\n\nexport interface BpmnAst {\n type: \"bpmn\";\n direction: BpmnDirection;\n title?: string;\n pools: BpmnPool[];\n lanes: BpmnLane[];\n events: BpmnEvent[];\n activities: BpmnActivity[];\n gateways: BpmnGateway[];\n flows: BpmnFlow[];\n}\n\n// ─── BPMN Layout Types ─────────────────────────────────────\n\nexport interface BpmnLayoutObject {\n obj: BpmnFlowObject;\n /** Top-left corner of the object's bounding box. */\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport interface BpmnLayoutLane {\n lane: BpmnLane;\n /** Lane band geometry (interior, label band excluded). */\n x: number;\n y: number;\n width: number;\n height: number;\n /** X position of the lane label band (rotated text). */\n labelX: number;\n labelY: number;\n labelHeight: number;\n}\n\nexport interface BpmnLayoutPool {\n pool: BpmnPool;\n /** Pool outer geometry (includes pool label band on the left). */\n x: number;\n y: number;\n width: number;\n height: number;\n /** Pool label band geometry (rotated text on the left). */\n labelX: number;\n labelY: number;\n labelWidth: number;\n}\n\nexport interface BpmnLayoutFlow {\n flow: BpmnFlow;\n /** Manhattan polyline path data. */\n path: string;\n /** Anchor for label rendering. */\n labelAnchor?: { x: number; y: number };\n}\n\nexport interface BpmnLayoutResult {\n ast: BpmnAst;\n pools: BpmnLayoutPool[];\n lanes: BpmnLayoutLane[];\n objects: BpmnLayoutObject[];\n flows: BpmnLayoutFlow[];\n width: number;\n height: number;\n}\n\n// ─── FBD (Function Block Diagram) Types ─────────────────────\n// IEC 61131-3 §6.4 — function blocks wired through named ports.\n// See docs/reference/23-FBD-STANDARD.md.\n\n/** IEC 61131-3 standard data types (subset used for wire coloring + display). */\nexport type FbdDataType =\n | \"bool\"\n | \"int\" | \"dint\" | \"uint\" | \"udint\"\n | \"real\" | \"lreal\"\n | \"time\" | \"date\" | \"tod\"\n | \"string\" | \"wstring\"\n | \"byte\" | \"word\" | \"dword\"\n | \"timer\" | \"counter\"\n | \"any\";\n\n/** Variable scope (IEC 61131-3 §2.4.3). */\nexport type FbdVarScope =\n | \"local\"\n | \"input\"\n | \"output\"\n | \"in_out\"\n | \"global\"\n | \"external\";\n\nexport interface FbdVarDecl {\n name: string;\n scope: FbdVarScope;\n dataType: FbdDataType | string; // user-defined FB type as opaque string\n initValue?: string;\n /** True if the type is a user-defined function block (not a primitive type). */\n isUserFb?: boolean;\n}\n\n/** Standard function block / function names (uppercase). The renderer knows how to draw each. */\nexport type FbdStdBlockName =\n | \"AND\" | \"OR\" | \"NOT\" | \"NAND\" | \"NOR\" | \"XOR\" | \"XNOR\" | \"BUF\"\n | \"R_TRIG\" | \"F_TRIG\" | \"SR\" | \"RS\"\n | \"TON\" | \"TOF\" | \"TP\"\n | \"CTU\" | \"CTD\"\n | \"ADD\" | \"SUB\" | \"MUL\" | \"DIV\" | \"MOD\"\n | \"ABS\" | \"NEG\" | \"MOVE\"\n | \"EQ\" | \"NE\" | \"GT\" | \"GE\" | \"LT\" | \"LE\"\n | \"SEL\" | \"MUX\" | \"MAX\" | \"MIN\" | \"LIMIT\";\n\nexport type FbdPortSide = \"in\" | \"out\";\n\nexport interface FbdPort {\n name: string;\n side: FbdPortSide;\n dataType: FbdDataType;\n /** Inline constant on input ports (e.g. `T#5s`, `5`, `TRUE`). When set, no incoming wire. */\n constant?: string;\n /** Negation bubble on this port. */\n negated?: boolean;\n}\n\nexport interface FbdBlock {\n /** Optional user-given instance tag (italic above header). */\n instance?: string;\n /** Type — standard name or user-defined FB type. */\n blockType: string;\n /** True if blockType is one of FbdStdBlockName. */\n isStd: boolean;\n /** Ports in declaration order (top-to-bottom on each side). */\n ports: FbdPort[];\n /** Network this block belongs to. */\n networkIndex: number;\n /** Synthetic id for wire references (`block-N` or instance). */\n id: string;\n}\n\nexport interface FbdWire {\n /** Source: either `{block: id, port: name}` or `{var: name}` (declared variable). */\n from: { kind: \"port\"; blockId: string; portName: string } | { kind: \"var\"; name: string };\n /** Sink. */\n to: { kind: \"port\"; blockId: string; portName: string } | { kind: \"var\"; name: string };\n /** Inferred from source port. */\n dataType: FbdDataType;\n /** Negation bubble at sink end (for `~`). */\n negatedAtSink?: boolean;\n}\n\nexport interface FbdNetwork {\n index: number;\n title?: string;\n blocks: FbdBlock[];\n wires: FbdWire[];\n}\n\nexport interface FbdAst {\n type: \"fbd\";\n title?: string;\n variables: FbdVarDecl[];\n networks: FbdNetwork[];\n}\n\n// ─── FBD Layout Types ────────────────────────────────────────\n\nexport interface FbdLayoutPort {\n name: string;\n side: FbdPortSide;\n /** Absolute x of the port end (port_stub_length out from block edge). */\n x: number;\n y: number;\n /** Block-edge x (port stub start). */\n edgeX: number;\n dataType: FbdDataType;\n constant?: string;\n negated?: boolean;\n}\n\nexport interface FbdLayoutBlock {\n block: FbdBlock;\n x: number;\n y: number;\n width: number;\n height: number;\n ports: FbdLayoutPort[];\n}\n\nexport interface FbdLayoutWire {\n wire: FbdWire;\n /** SVG path \"d\" attribute (Manhattan polyline). */\n path: string;\n}\n\n/** Variable terminal: a small labeled box on the left (input vars) or right (output vars) of each network. */\nexport interface FbdLayoutVarTerm {\n name: string;\n x: number;\n y: number;\n width: number;\n height: number;\n side: \"left\" | \"right\";\n dataType: FbdDataType;\n}\n\nexport interface FbdLayoutNetwork {\n network: FbdNetwork;\n x: number;\n y: number;\n width: number;\n height: number;\n blocks: FbdLayoutBlock[];\n wires: FbdLayoutWire[];\n varTerms: FbdLayoutVarTerm[];\n /** Junction points (filled circles where one wire branches to multiple sinks). */\n junctions: { x: number; y: number }[];\n}\n\nexport interface FbdLayoutResult {\n ast: FbdAst;\n networks: FbdLayoutNetwork[];\n width: number;\n height: number;\n}\n\n// ─── SFC (Sequential Function Chart) Types ──────────────────\n// IEC 61131-3 §6.5 — steps + transitions with bars.\n// See docs/reference/24-SFC-STANDARD.md.\n\nexport type SfcStepKind = \"initial\" | \"normal\" | \"final\";\n\nexport type SfcActionQualifier =\n | \"N\" | \"S\" | \"R\" | \"L\" | \"D\" | \"P\" | \"P0\" | \"P1\" | \"SD\" | \"DS\" | \"SL\";\n\nexport interface SfcAction {\n qualifier: SfcActionQualifier;\n /** Action body — name reference or inline ST text. */\n body: string;\n /** Optional duration literal (T#5s) for L/D/SD/SL/DS qualifiers. */\n time?: string;\n}\n\nexport interface SfcStep {\n id: string;\n kind: SfcStepKind;\n /** Display label override; defaults to id. */\n label?: string;\n actions: SfcAction[];\n}\n\nexport interface SfcTransition {\n /** Optional explicit transition id (e.g. T_Reset). */\n id?: string;\n from: string;\n to: string;\n /** Boolean expression as raw text. */\n condition: string;\n}\n\nexport type SfcVarType =\n | \"bool\" | \"int\" | \"real\" | \"time\" | \"timer\" | \"counter\" | string;\n\nexport interface SfcVarDecl {\n name: string;\n dataType: SfcVarType;\n initValue?: string;\n}\n\n/** Branch group nodes — recursive AST for alt/sim regions. */\nexport type SfcNode =\n | { kind: \"step\"; stepId: string }\n | { kind: \"alt\"; branches: SfcAltBranch[]; mergeTo: string }\n | { kind: \"sim\"; condition: string; branches: SfcSimBranch[]; mergeTo: string; mergeCondition: string };\n\nexport interface SfcAltBranch {\n /** Optional priority (default = declaration order). */\n priority?: number;\n /** Entry transition condition (rendered between divergence bar and first step). */\n entryCondition: string;\n /** Inner steps in linear order. */\n body: SfcNode[];\n /** Exit transition condition (rendered between last step and convergence bar). */\n exitCondition: string;\n}\n\nexport interface SfcSimBranch {\n body: SfcNode[];\n}\n\nexport interface SfcAst {\n type: \"sfc\";\n title?: string;\n variables: SfcVarDecl[];\n steps: Map<string, SfcStep>;\n /** Top-level node sequence (linear chain with possibly branch nodes). */\n body: SfcNode[];\n /** All transitions — explicit ones from `transition` directives.\n * Branch entry/exit conditions live inside SfcAltBranch / SfcSimBranch. */\n transitions: SfcTransition[];\n}\n\n// ─── SFC Layout Types ──────────────────────────────────────\n\nexport interface SfcLayoutStep {\n step: SfcStep;\n x: number;\n y: number;\n width: number;\n height: number;\n}\n\nexport interface SfcLayoutAction {\n action: SfcAction;\n stepId: string;\n /** Index in step's action list. */\n index: number;\n x: number;\n y: number;\n width: number;\n height: number;\n qualifierWidth: number;\n}\n\nexport interface SfcLayoutTransition {\n transition: SfcTransition;\n /** Center of the transition bar. */\n cx: number;\n cy: number;\n /** Bar half-width — bar spans [cx-w, cx+w]. */\n w: number;\n /** Optional explicit id label (e.g. T_Reset). */\n id?: string;\n}\n\nexport type SfcBarKind = \"alt-div\" | \"alt-conv\" | \"sim-div\" | \"sim-conv\";\n\nexport interface SfcLayoutBar {\n kind: SfcBarKind;\n /** Horizontal extent. */\n x1: number;\n x2: number;\n y: number;\n}\n\nexport interface SfcLayoutWire {\n /** SVG path \"d\" — typically a vertical or L-shape. */\n path: string;\n /** Optional class hint (e.g. \"wire\", \"jump\"). */\n cls: \"wire\" | \"jump\";\n}\n\nexport interface SfcLayoutJump {\n fromStepId: string;\n toStepId: string;\n /** Polyline path including arrowhead. */\n path: string;\n /** Margin label position. */\n labelX: number;\n labelY: number;\n labelText: string;\n /** Condition text (rendered near the source). */\n condition?: string;\n}\n\nexport interface SfcLayoutResult {\n ast: SfcAst;\n steps: SfcLayoutStep[];\n actions: SfcLayoutAction[];\n transitions: SfcLayoutTransition[];\n bars: SfcLayoutBar[];\n wires: SfcLayoutWire[];\n jumps: SfcLayoutJump[];\n width: number;\n height: number;\n}\n","import type { SLDNodeType, SLDStandard } from \"../../core/types\";\nimport { isIecFamily } from \"../../core/types\";\nimport { el, group, line, path as pathEl, text as textEl } from \"../../core/svg\";\n\n/**\n * Symbol renderers — each returns SVG markup centered at (0,0)\n * Used by the renderer after applying transform=\"translate(cx,cy)\".\n *\n * Every symbol exposes a conceptual top/bottom terminal on the vertical axis,\n * so the layout only needs to draw vertical wires between them.\n */\n\nexport interface SymbolGeometry {\n /** Bounding half-width for layout */\n halfWidth: number;\n /** Y-offset of the top terminal (negative = above center) */\n topY: number;\n /** Y-offset of the bottom terminal (positive = below center) */\n bottomY: number;\n}\n\nexport const DEFAULT_GEOMETRY: SymbolGeometry = {\n halfWidth: 20,\n topY: -20,\n bottomY: 20,\n};\n\nexport function geometryFor(type: SLDNodeType): SymbolGeometry {\n switch (type) {\n case \"utility\":\n case \"generator\":\n case \"solar\":\n case \"wind\":\n return { halfWidth: 18, topY: -24, bottomY: 18 };\n case \"transformer\":\n case \"transformer_dy\":\n case \"transformer_yd\":\n case \"transformer_yy\":\n case \"transformer_dd\":\n case \"autotransformer\":\n case \"transformer_3winding\":\n return { halfWidth: 22, topY: -24, bottomY: 24 };\n case \"breaker\":\n case \"breaker_vacuum\":\n case \"recloser\":\n case \"switch\":\n case \"switch_load\":\n case \"ground_switch\":\n case \"sectionalizer\":\n return { halfWidth: 18, topY: -18, bottomY: 18 };\n case \"fuse\":\n case \"fuse_cl\":\n return { halfWidth: 14, topY: -18, bottomY: 18 };\n case \"motor\":\n return { halfWidth: 16, topY: -16, bottomY: 22 };\n case \"load\":\n case \"capacitor_bank\":\n case \"harmonic_filter\":\n return { halfWidth: 20, topY: -14, bottomY: 14 };\n case \"vfd\":\n case \"ups\":\n return { halfWidth: 24, topY: -18, bottomY: 18 };\n case \"ats\":\n return { halfWidth: 22, topY: -18, bottomY: 18 };\n case \"ct\":\n case \"pt\":\n return { halfWidth: 10, topY: -16, bottomY: 16 };\n case \"relay\":\n return { halfWidth: 12, topY: -12, bottomY: 12 };\n case \"surge_arrester\":\n return { halfWidth: 12, topY: -16, bottomY: 26 };\n case \"watthour_meter\":\n case \"demand_meter\":\n case \"ground_fault\":\n return { halfWidth: 14, topY: -14, bottomY: 14 };\n case \"bus\":\n return DEFAULT_GEOMETRY;\n case \"hub\":\n return { halfWidth: 52, topY: -20, bottomY: 20 };\n case \"bus_tie\":\n return { halfWidth: 16, topY: -10, bottomY: 10 };\n default:\n return DEFAULT_GEOMETRY;\n }\n}\n\nfunction lineEl(x1: number, y1: number, x2: number, y2: number, cls = \"lt-sld-stroke\"): string {\n return line({ x1, y1, x2, y2, class: cls });\n}\n\nfunction utilitySymbol(): string {\n return group({}, [\n el(\"circle\", { cx: 0, cy: 0, r: 16, class: \"lt-sld-fill\" }),\n pathEl({ d: \"M -8 0 Q -4 -8 0 0 Q 4 8 8 0\", class: \"lt-sld-stroke\", fill: \"none\" }),\n // lead wires in/out\n lineEl(0, -24, 0, -16),\n lineEl(0, 16, 0, 18),\n ]);\n}\n\nfunction generatorSymbol(): string {\n return group({}, [\n el(\"circle\", { cx: 0, cy: 0, r: 16, class: \"lt-sld-fill\" }),\n textEl({ x: 0, y: -2, class: \"lt-sld-symbol-text\", \"text-anchor\": \"middle\", \"font-weight\": \"bold\", \"font-size\": \"14\" }, \"G\"),\n pathEl({ d: \"M -6 6 Q -3 1 0 6 Q 3 11 6 6\", class: \"lt-sld-stroke\", fill: \"none\" }),\n lineEl(0, -24, 0, -16),\n lineEl(0, 16, 0, 18),\n ]);\n}\n\nfunction solarSymbol(): string {\n return group({}, [\n el(\"rect\", { x: -18, y: -12, width: 36, height: 24, class: \"lt-sld-fill\" }),\n lineEl(-18, -4, 18, -4),\n lineEl(-18, 4, 18, 4),\n lineEl(-6, -12, -6, 12),\n lineEl(6, -12, 6, 12),\n lineEl(0, 12, 0, 18),\n ]);\n}\n\nfunction windSymbol(): string {\n return group({}, [\n el(\"circle\", { cx: 0, cy: 0, r: 6, class: \"lt-sld-fill\" }),\n lineEl(0, -6, 0, -22),\n pathEl({ d: \"M 0 -6 L 14 -2 L 0 0 Z\", class: \"lt-sld-fill-dark\" }),\n pathEl({ d: \"M 0 -6 L -10 8 L 0 2 Z\", class: \"lt-sld-fill-dark\" }),\n pathEl({ d: \"M 0 -6 L -6 -18 L 2 -6 Z\", class: \"lt-sld-fill-dark\" }),\n lineEl(0, 6, 0, 18),\n ]);\n}\n\nfunction upsSymbol(): string {\n return group({}, [\n el(\"rect\", { x: -22, y: -16, width: 44, height: 32, class: \"lt-sld-fill\" }),\n textEl({ x: 0, y: 4, class: \"lt-sld-symbol-text\", \"text-anchor\": \"middle\", \"font-weight\": \"bold\", \"font-size\": \"11\" }, \"UPS\"),\n ]);\n}\n\n/**\n * Transformer: two coil groups (three humps each) + polarity dots.\n * Optional winding labels (Δ or Y) are overlaid as compact glyphs.\n */\nfunction transformerSymbol(type: SLDNodeType): string {\n const pieces: string[] = [];\n // primary coil (top)\n pieces.push(\n pathEl({\n d: \"M -12 -18 A 4 4 0 0 1 -4 -18 A 4 4 0 0 1 4 -18 A 4 4 0 0 1 12 -18\",\n class: \"lt-sld-stroke\",\n fill: \"none\",\n })\n );\n // core lines\n pieces.push(lineEl(-14, -8, 14, -8));\n pieces.push(lineEl(-14, -4, 14, -4));\n // secondary coil (bottom, mirrored)\n pieces.push(\n pathEl({\n d: \"M -12 18 A 4 4 0 0 0 -4 18 A 4 4 0 0 0 4 18 A 4 4 0 0 0 12 18\",\n class: \"lt-sld-stroke\",\n fill: \"none\",\n })\n );\n // polarity dots\n pieces.push(el(\"circle\", { cx: -10, cy: -14, r: 2, class: \"lt-sld-dot\" }));\n pieces.push(el(\"circle\", { cx: 10, cy: 14, r: 2, class: \"lt-sld-dot\" }));\n // leads\n pieces.push(lineEl(0, -24, 0, -22));\n pieces.push(lineEl(0, 22, 0, 24));\n\n // Winding designators (Δ / Y / Yg)\n const { primary, secondary } = windingGlyphs(type);\n if (primary) pieces.push(textEl({ x: 20, y: -14, class: \"lt-sld-wdg\", \"text-anchor\": \"start\" }, primary));\n if (secondary) pieces.push(textEl({ x: 20, y: 18, class: \"lt-sld-wdg\", \"text-anchor\": \"start\" }, secondary));\n return group({}, pieces);\n}\n\nfunction windingGlyphs(type: SLDNodeType): { primary?: string; secondary?: string } {\n switch (type) {\n case \"transformer_dy\": return { primary: \"Δ\", secondary: \"Y\" };\n case \"transformer_yd\": return { primary: \"Y\", secondary: \"Δ\" };\n case \"transformer_yy\": return { primary: \"Y\", secondary: \"Y\" };\n case \"transformer_dd\": return { primary: \"Δ\", secondary: \"Δ\" };\n default: return {};\n }\n}\n\nfunction autotransformerSymbol(): string {\n return group({}, [\n pathEl({\n d: \"M 0 -20 A 6 6 0 0 1 0 -10 A 6 6 0 0 1 0 0 A 6 6 0 0 1 0 10 A 6 6 0 0 1 0 20\",\n class: \"lt-sld-stroke\",\n fill: \"none\",\n }),\n lineEl(6, 0, 14, 0),\n lineEl(0, -24, 0, -20),\n lineEl(0, 20, 0, 24),\n ]);\n}\n\nfunction threeWindingSymbol(): string {\n return group({}, [\n // top coil\n pathEl({ d: \"M -10 -18 A 3 3 0 0 1 -4 -18 A 3 3 0 0 1 2 -18 A 3 3 0 0 1 8 -18\", class: \"lt-sld-stroke\", fill: \"none\" }),\n // left-bottom coil\n pathEl({ d: \"M -18 6 A 3 3 0 0 1 -12 6 A 3 3 0 0 1 -6 6 A 3 3 0 0 1 0 6\", class: \"lt-sld-stroke\", fill: \"none\" }),\n // right-bottom coil\n pathEl({ d: \"M 0 6 A 3 3 0 0 1 6 6 A 3 3 0 0 1 12 6 A 3 3 0 0 1 18 6\", class: \"lt-sld-stroke\", fill: \"none\" }),\n lineEl(-14, -8, 14, -8),\n lineEl(0, -24, 0, -18),\n lineEl(-9, 10, -9, 24),\n lineEl(9, 10, 9, 24),\n ]);\n}\n\n/** Circuit breaker: diagonal line + top arc. */\nfunction breakerSymbol(): string {\n return group({}, [\n lineEl(0, -14, 0, -10, \"lt-sld-stroke\"),\n lineEl(0, 10, 0, 14, \"lt-sld-stroke\"),\n line({ x1: -6, y1: 10, x2: 8, y2: -10, class: \"lt-sld-stroke-thick\" }),\n pathEl({ d: \"M 8 -10 Q 14 -12 12 -18\", class: \"lt-sld-stroke\", fill: \"none\" }),\n lineEl(0, -18, 0, -14),\n lineEl(0, 14, 0, 18),\n ]);\n}\n\nfunction vacuumBreakerSymbol(): string {\n return group({}, [\n el(\"ellipse\", { cx: 0, cy: 0, rx: 10, ry: 14, class: \"lt-sld-fill\" }),\n line({ x1: -6, y1: 10, x2: 8, y2: -10, class: \"lt-sld-stroke-thick\" }),\n textEl({ x: -2, y: -4, class: \"lt-sld-symbol-text\", \"text-anchor\": \"middle\", \"font-size\": \"8\" }, \"V\"),\n lineEl(0, -18, 0, -14),\n lineEl(0, 14, 0, 18),\n ]);\n}\n\nfunction recloserSymbol(): string {\n return group({}, [\n line({ x1: -6, y1: 10, x2: 8, y2: -10, class: \"lt-sld-stroke-thick\" }),\n pathEl({ d: \"M 8 -10 Q 14 -12 12 -18\", class: \"lt-sld-stroke\", fill: \"none\" }),\n pathEl({ d: \"M 14 -6 A 5 5 0 1 1 18 -4\", class: \"lt-sld-stroke\", fill: \"none\" }),\n el(\"polygon\", { points: \"18,-4 20,-8 15,-7\", class: \"lt-sld-dot\" }),\n lineEl(0, -18, 0, -14),\n lineEl(0, 14, 0, 18),\n ]);\n}\n\nfunction switchSymbol(open = false): string {\n const pieces: string[] = [];\n if (open) {\n pieces.push(line({ x1: -6, y1: 10, x2: 10, y2: -8, class: \"lt-sld-stroke-thick\" }));\n pieces.push(el(\"circle\", { cx: 10, cy: -8, r: 2, class: \"lt-sld-fill\" }));\n } else {\n pieces.push(line({ x1: -6, y1: 10, x2: 8, y2: -10, class: \"lt-sld-stroke-thick\" }));\n }\n pieces.push(lineEl(0, -18, 0, -10));\n pieces.push(lineEl(0, 10, 0, 18));\n return group({}, pieces);\n}\n\nfunction loadSwitchSymbol(): string {\n return group({}, [\n line({ x1: -6, y1: 10, x2: 8, y2: -10, class: \"lt-sld-stroke-thick\" }),\n el(\"rect\", { x: 6, y: -14, width: 6, height: 6, class: \"lt-sld-fill\" }),\n lineEl(0, -18, 0, -10),\n lineEl(0, 10, 0, 18),\n ]);\n}\n\nfunction groundSwitchSymbol(): string {\n return group({}, [\n line({ x1: -6, y1: 0, x2: 8, y2: -14, class: \"lt-sld-stroke-thick\" }),\n lineEl(0, -18, 0, -4),\n // ground symbol\n lineEl(-8, 6, 8, 6),\n lineEl(-5, 10, 5, 10),\n lineEl(-2, 14, 2, 14),\n lineEl(0, 0, 0, 6),\n ]);\n}\n\nfunction sectionalizerSymbol(): string {\n return group({}, [\n line({ x1: -6, y1: 10, x2: 10, y2: -8, class: \"lt-sld-stroke-thick\" }),\n el(\"circle\", { cx: 10, cy: -8, r: 2, class: \"lt-sld-fill\" }),\n textEl({ x: 14, y: -4, class: \"lt-sld-wdg\", \"text-anchor\": \"start\" }, \"S\"),\n lineEl(0, -18, 0, -10),\n lineEl(0, 10, 0, 18),\n ]);\n}\n\nfunction fuseSymbol(): string {\n return group({}, [\n el(\"rect\", { x: -5, y: -10, width: 10, height: 20, class: \"lt-sld-fill\" }),\n lineEl(0, -18, 0, -10),\n lineEl(0, 10, 0, 18),\n ]);\n}\n\nfunction fuseCLSymbol(): string {\n return group({}, [\n el(\"rect\", { x: -6, y: -12, width: 12, height: 24, class: \"lt-sld-fill\" }),\n lineEl(-6, 0, 6, 0),\n lineEl(0, -18, 0, -12),\n lineEl(0, 12, 0, 18),\n ]);\n}\n\nfunction motorSymbol(): string {\n return group({}, [\n el(\"circle\", { cx: 0, cy: 0, r: 14, class: \"lt-sld-fill\" }),\n textEl({ x: 0, y: 5, class: \"lt-sld-symbol-text\", \"text-anchor\": \"middle\", \"font-weight\": \"bold\", \"font-size\": \"13\" }, \"M\"),\n lineEl(0, -16, 0, -14),\n // 3-phase dots at bottom\n el(\"circle\", { cx: -6, cy: 12, r: 1.5, class: \"lt-sld-dot\" }),\n el(\"circle\", { cx: 0, cy: 14, r: 1.5, class: \"lt-sld-dot\" }),\n el(\"circle\", { cx: 6, cy: 12, r: 1.5, class: \"lt-sld-dot\" }),\n ]);\n}\n\nfunction loadSymbol(): string {\n return group({}, [\n el(\"rect\", { x: -16, y: -12, width: 32, height: 24, class: \"lt-sld-fill\" }),\n ]);\n}\n\nfunction capacitorBankSymbol(): string {\n return group({}, [\n lineEl(-10, -6, 10, -6, \"lt-sld-stroke-thick\"),\n lineEl(-10, -2, 10, -2, \"lt-sld-stroke-thick\"),\n lineEl(-10, 4, 10, 4, \"lt-sld-stroke-thick\"),\n lineEl(-10, 8, 10, 8, \"lt-sld-stroke-thick\"),\n lineEl(0, -14, 0, -6),\n lineEl(0, 8, 0, 14),\n ]);\n}\n\nfunction harmonicFilterSymbol(): string {\n return group({}, [\n // L + C chained\n pathEl({ d: \"M -14 -4 A 3 3 0 0 1 -8 -4 A 3 3 0 0 1 -2 -4 A 3 3 0 0 1 4 -4\", class: \"lt-sld-stroke\", fill: \"none\" }),\n lineEl(4, -8, 14, -8),\n lineEl(4, 0, 14, 0),\n lineEl(0, -14, 0, -4),\n lineEl(0, 4, 0, 14),\n ]);\n}\n\nfunction vfdSymbol(): string {\n return group({}, [\n el(\"rect\", { x: -22, y: -16, width: 44, height: 32, class: \"lt-sld-fill\" }),\n textEl({ x: 0, y: -2, class: \"lt-sld-symbol-text\", \"text-anchor\": \"middle\", \"font-weight\": \"bold\", \"font-size\": \"11\" }, \"VFD\"),\n pathEl({ d: \"M -10 8 Q -5 2 0 8 Q 5 14 10 8\", class: \"lt-sld-stroke\", fill: \"none\" }),\n lineEl(0, -18, 0, -16),\n lineEl(0, 16, 0, 18),\n ]);\n}\n\nfunction atsSymbol(): string {\n return group({}, [\n el(\"rect\", { x: -22, y: -16, width: 44, height: 32, class: \"lt-sld-fill\" }),\n line({ x1: -14, y1: -8, x2: -2, y2: 6, class: \"lt-sld-stroke-thick\" }),\n line({ x1: 14, y1: -8, x2: 2, y2: 6, class: \"lt-sld-stroke-thick\" }),\n textEl({ x: 0, y: 14, class: \"lt-sld-symbol-text\", \"text-anchor\": \"middle\", \"font-weight\": \"bold\", \"font-size\": \"9\" }, \"ATS\"),\n lineEl(-12, -18, -12, -16),\n lineEl(12, -18, 12, -16),\n lineEl(0, 16, 0, 18),\n ]);\n}\n\nfunction ctSymbol(): string {\n return group({}, [\n el(\"circle\", { cx: 0, cy: 0, r: 7, class: \"lt-sld-fill\" }),\n textEl({ x: 0, y: 3, class: \"lt-sld-wdg\", \"text-anchor\": \"middle\", \"font-size\": \"7\" }, \"CT\"),\n lineEl(0, -16, 0, -7),\n lineEl(0, 7, 0, 16),\n ]);\n}\n\nfunction ptSymbol(): string {\n return group({}, [\n el(\"circle\", { cx: 0, cy: 0, r: 7, class: \"lt-sld-fill\" }),\n textEl({ x: 0, y: 3, class: \"lt-sld-wdg\", \"text-anchor\": \"middle\", \"font-size\": \"7\" }, \"PT\"),\n lineEl(0, -16, 0, -7),\n lineEl(0, 7, 0, 16),\n ]);\n}\n\nfunction relaySymbol(deviceNumber?: string): string {\n return group({}, [\n el(\"circle\", { cx: 0, cy: 0, r: 11, class: \"lt-sld-fill\" }),\n textEl({ x: 0, y: 4, class: \"lt-sld-wdg\", \"text-anchor\": \"middle\", \"font-size\": \"10\" }, deviceNumber ?? \"R\"),\n ]);\n}\n\nfunction surgeArresterSymbol(): string {\n return group({}, [\n el(\"rect\", { x: -7, y: -6, width: 14, height: 14, class: \"lt-sld-fill\" }),\n pathEl({ d: \"M -4 2 Q 0 -4 4 2\", class: \"lt-sld-stroke\", fill: \"none\" }),\n lineEl(0, -16, 0, -6),\n lineEl(0, 8, 0, 14),\n lineEl(-8, 14, 8, 14),\n lineEl(-5, 18, 5, 18),\n lineEl(-2, 22, 2, 22),\n ]);\n}\n\nfunction groundFaultSymbol(): string {\n return group({}, [\n el(\"circle\", { cx: 0, cy: 0, r: 12, class: \"lt-sld-fill\" }),\n textEl({ x: 0, y: 4, class: \"lt-sld-wdg\", \"text-anchor\": \"middle\", \"font-size\": \"9\" }, \"GFI\"),\n lineEl(0, -14, 0, -12),\n lineEl(0, 12, 0, 14),\n ]);\n}\n\nfunction hubSymbol(label?: string): string {\n return group({}, [\n el(\"rect\", {\n x: -50, y: -18, width: 100, height: 36,\n rx: 4, ry: 4,\n class: \"lt-sld-fill\",\n \"stroke-width\": 2,\n }),\n textEl(\n { x: 0, y: 4, class: \"lt-sld-wdg\", \"text-anchor\": \"middle\", \"font-size\": \"11\" },\n label ?? \"HUB\"\n ),\n lineEl(0, -20, 0, -18),\n lineEl(0, 18, 0, 20),\n // left/right lead stubs for lateral ports\n lineEl(-50, 0, -54, 0),\n lineEl(50, 0, 54, 0),\n ]);\n}\n\nfunction busTieSymbol(): string {\n // Horizontal breaker: two stubs + diagonal switch bar + arc above\n return group({}, [\n lineEl(-16, 0, -4, 0),\n lineEl(4, 0, 16, 0),\n pathEl({ d: \"M -4 0 L 4 -6\", class: \"lt-sld-stroke-thick\" }),\n pathEl({ d: \"M -4 -6 Q 0 -10 4 -6\", class: \"lt-sld-stroke\", fill: \"none\" }),\n ]);\n}\n\nfunction meterSymbol(label: string): string {\n return group({}, [\n el(\"circle\", { cx: 0, cy: 0, r: 12, class: \"lt-sld-fill\" }),\n textEl({ x: 0, y: 4, class: \"lt-sld-wdg\", \"text-anchor\": \"middle\", \"font-size\": \"9\" }, label),\n lineEl(0, -14, 0, -12),\n lineEl(0, 12, 0, 14),\n ]);\n}\n\n// ─── IEC 60617 symbol variants ──────────────────────────────\n// Only the devices whose IEC glyph differs recognisably from the IEEE-315\n// (ANSI) form are overridden here. Earth, knife-switch disconnectors, motors,\n// meters, etc. share the same primitive across both standards, so they fall\n// through to the shared renderers below.\n\n/** IEC two-winding transformer: two interlinked circles (vs ANSI coil humps). */\nfunction transformerSymbolIEC(type: SLDNodeType): string {\n const pieces: string[] = [\n el(\"circle\", { cx: 0, cy: -7, r: 11, class: \"lt-sld-stroke\" }),\n el(\"circle\", { cx: 0, cy: 7, r: 11, class: \"lt-sld-stroke\" }),\n lineEl(0, -24, 0, -18),\n lineEl(0, 18, 0, 24),\n ];\n const { primary, secondary } = windingGlyphs(type);\n if (primary) pieces.push(textEl({ x: 20, y: -10, class: \"lt-sld-wdg\", \"text-anchor\": \"start\" }, primary));\n if (secondary) pieces.push(textEl({ x: 20, y: 14, class: \"lt-sld-wdg\", \"text-anchor\": \"start\" }, secondary));\n return group({}, pieces);\n}\n\n/**\n * IEC circuit breaker: a contact arm whose fixed contact carries the `×`\n * breaking-function mark (vs the ANSI contact + quarter-arc).\n */\nfunction breakerSymbolIEC(): string {\n return group({}, [\n lineEl(0, -18, 0, -10),\n lineEl(0, 10, 0, 18),\n // open contact arm pivoting from the bottom terminal\n line({ x1: -6, y1: 10, x2: 6, y2: -8, class: \"lt-sld-stroke-thick\" }),\n // × at the fixed contact\n line({ x1: -4, y1: -13, x2: 4, y2: -7, class: \"lt-sld-stroke\" }),\n line({ x1: 4, y1: -13, x2: -4, y2: -7, class: \"lt-sld-stroke\" }),\n ]);\n}\n\n/** IEC fuse: rectangle with a conductor line through the long axis (vs ANSI plain box). */\nfunction fuseSymbolIEC(): string {\n return group({}, [\n el(\"rect\", { x: -5, y: -11, width: 10, height: 22, class: \"lt-sld-fill\" }),\n lineEl(0, -11, 0, 11),\n lineEl(0, -18, 0, -11),\n lineEl(0, 11, 0, 18),\n ]);\n}\n\n/** Main entry — render a node symbol at origin. */\nexport function renderSymbol(\n type: SLDNodeType,\n detail?: string,\n standard?: SLDStandard\n): string {\n if (isIecFamily(standard)) {\n switch (type) {\n case \"transformer\":\n case \"transformer_dy\":\n case \"transformer_yd\":\n case \"transformer_yy\":\n case \"transformer_dd\":\n return transformerSymbolIEC(type);\n case \"breaker\":\n return breakerSymbolIEC();\n case \"fuse\":\n return fuseSymbolIEC();\n }\n }\n switch (type) {\n case \"utility\": return utilitySymbol();\n case \"generator\": return generatorSymbol();\n case \"solar\": return solarSymbol();\n case \"wind\": return windSymbol();\n case \"ups\": return upsSymbol();\n case \"transformer\":\n case \"transformer_dy\":\n case \"transformer_yd\":\n case \"transformer_yy\":\n case \"transformer_dd\":\n return transformerSymbol(type);\n case \"autotransformer\": return autotransformerSymbol();\n case \"transformer_3winding\": return threeWindingSymbol();\n case \"breaker\": return breakerSymbol();\n case \"breaker_vacuum\": return vacuumBreakerSymbol();\n case \"recloser\": return recloserSymbol();\n case \"switch\": return switchSymbol(true);\n case \"switch_load\": return loadSwitchSymbol();\n case \"ground_switch\": return groundSwitchSymbol();\n case \"sectionalizer\": return sectionalizerSymbol();\n case \"fuse\": return fuseSymbol();\n case \"fuse_cl\": return fuseCLSymbol();\n case \"motor\": return motorSymbol();\n case \"load\": return loadSymbol();\n case \"capacitor_bank\": return capacitorBankSymbol();\n case \"harmonic_filter\": return harmonicFilterSymbol();\n case \"vfd\": return vfdSymbol();\n case \"ats\": return atsSymbol();\n case \"ct\": return ctSymbol();\n case \"pt\": return ptSymbol();\n case \"relay\": return relaySymbol(detail);\n case \"surge_arrester\": return surgeArresterSymbol();\n case \"ground_fault\": return groundFaultSymbol();\n case \"watthour_meter\": return meterSymbol(\"Wh\");\n case \"demand_meter\": return meterSymbol(\"D\");\n case \"bus\": return \"\";\n case \"hub\": return hubSymbol(detail);\n case \"bus_tie\": return busTieSymbol();\n default: return loadSymbol();\n }\n}\n","import type { SLDAST, SLDConnection, SLDNode, SLDNodeType } from \"../../core/types\";\nimport { geometryFor } from \"./symbols\";\n\n/**\n * Top-down hierarchical layout:\n * level 0 = sources (top)\n * each edge forces child.level >= parent.level + 1\n * Bus nodes expand horizontally to span their children.\n * Other nodes are positioned in a tidy tree-like layout.\n */\n\nexport interface SLDLayoutNode {\n node: SLDNode;\n nodeType: SLDNodeType;\n /** center x */\n x: number;\n /** center y */\n y: number;\n /** Terminal y (top and bottom) after symbol geometry */\n topY: number;\n bottomY: number;\n level: number;\n /** Half width for spacing */\n halfWidth: number;\n /** For bus nodes: left and right extent (x min/max) */\n busLeft?: number;\n busRight?: number;\n}\n\nexport interface SLDLayoutEdge {\n from: string;\n to: string;\n path: string;\n cable?: string;\n label?: string;\n midX: number;\n midY: number;\n}\n\nexport interface SLDLayoutBand {\n level: number;\n voltage?: string;\n y: number;\n height: number;\n}\n\nexport interface SLDLayoutResult {\n width: number;\n height: number;\n nodes: SLDLayoutNode[];\n edges: SLDLayoutEdge[];\n bands: SLDLayoutBand[];\n nodeById: Map<string, SLDLayoutNode>;\n}\n\nconst LEVEL_SPACING = 100;\nconst H_SPACING = 90;\nconst LEFT_PADDING = 80;\nconst TOP_PADDING = 40;\nconst BUS_OVERHANG = 20;\n\nfunction computeLevels(ast: SLDAST): Map<string, number> {\n const levels = new Map<string, number>();\n const inEdges = new Map<string, SLDConnection[]>();\n const outEdges = new Map<string, SLDConnection[]>();\n for (const n of ast.nodes) {\n inEdges.set(n.id, []);\n outEdges.set(n.id, []);\n }\n for (const c of ast.connections) {\n inEdges.get(c.to)?.push(c);\n outEdges.get(c.from)?.push(c);\n }\n\n // Sources: no incoming edges\n const roots = ast.nodes.filter((n) => (inEdges.get(n.id) ?? []).length === 0);\n for (const r of roots) levels.set(r.id, 0);\n\n // Identify bus_tie nodes — they are lateral at the same level as their source.\n const typeById = new Map<string, SLDNodeType>();\n for (const n of ast.nodes) typeById.set(n.id, n.nodeType);\n const isTieEdge = (c: SLDConnection): boolean =>\n typeById.get(c.from) === \"bus_tie\" || typeById.get(c.to) === \"bus_tie\";\n\n // Relaxation: level(to) = max(level(from)+1); iterate until stable.\n // Skip edges touching bus_tie (those are lateral).\n const maxIter = ast.nodes.length + 2;\n for (let iter = 0; iter < maxIter; iter++) {\n let changed = false;\n for (const c of ast.connections) {\n if (isTieEdge(c)) continue;\n const fromLvl = levels.get(c.from);\n if (fromLvl === undefined) continue;\n const want = fromLvl + 1;\n const curr = levels.get(c.to);\n if (curr === undefined || want > curr) {\n levels.set(c.to, want);\n changed = true;\n }\n }\n if (!changed) break;\n }\n\n // Tie edges: force both endpoints and the tie node itself to share level\n // with any already-leveled participant.\n for (let iter = 0; iter < maxIter; iter++) {\n let changed = false;\n for (const c of ast.connections) {\n if (!isTieEdge(c)) continue;\n const fromLvl = levels.get(c.from);\n const toLvl = levels.get(c.to);\n const shared = fromLvl ?? toLvl;\n if (shared === undefined) continue;\n if (fromLvl === undefined || fromLvl !== shared) {\n levels.set(c.from, shared);\n changed = true;\n }\n if (toLvl === undefined || toLvl !== shared) {\n levels.set(c.to, shared);\n changed = true;\n }\n }\n if (!changed) break;\n }\n\n // Any orphaned nodes: put at level 0\n for (const n of ast.nodes) {\n if (!levels.has(n.id)) levels.set(n.id, 0);\n }\n return levels;\n}\n\nfunction orderWithinLevel(\n ast: SLDAST,\n levels: Map<string, number>\n): Map<number, string[]> {\n const byLevel = new Map<number, string[]>();\n for (const n of ast.nodes) {\n const lvl = levels.get(n.id) ?? 0;\n if (!byLevel.has(lvl)) byLevel.set(lvl, []);\n byLevel.get(lvl)!.push(n.id);\n }\n\n // Order: DFS from sources preserving declaration order.\n const visited = new Set<string>();\n const order = new Map<string, number>();\n let idx = 0;\n\n const adj = new Map<string, string[]>();\n for (const n of ast.nodes) adj.set(n.id, []);\n for (const c of ast.connections) adj.get(c.from)?.push(c.to);\n\n function dfs(id: string): void {\n if (visited.has(id)) return;\n visited.add(id);\n order.set(id, idx++);\n for (const child of adj.get(id) ?? []) dfs(child);\n }\n\n // Start from sources in declaration order\n const inEdgeCount = new Map<string, number>();\n for (const n of ast.nodes) inEdgeCount.set(n.id, 0);\n for (const c of ast.connections) {\n inEdgeCount.set(c.to, (inEdgeCount.get(c.to) ?? 0) + 1);\n }\n for (const n of ast.nodes) {\n if ((inEdgeCount.get(n.id) ?? 0) === 0) dfs(n.id);\n }\n // Fallback for any remaining nodes\n for (const n of ast.nodes) dfs(n.id);\n\n // Sort each level by the DFS order\n for (const [lvl, ids] of byLevel.entries()) {\n ids.sort((a, b) => (order.get(a) ?? 0) - (order.get(b) ?? 0));\n byLevel.set(lvl, ids);\n }\n return byLevel;\n}\n\nexport function layoutSLD(ast: SLDAST): SLDLayoutResult {\n const levels = computeLevels(ast);\n const byLevel = orderWithinLevel(ast, levels);\n const nodeMap = new Map<string, SLDNode>();\n for (const n of ast.nodes) nodeMap.set(n.id, n);\n\n // First pass: x position for all non-bus nodes.\n // Buses get x later after their children are placed.\n const layoutNodes: SLDLayoutNode[] = [];\n const byIdLayout = new Map<string, SLDLayoutNode>();\n\n const parents = new Map<string, string[]>();\n const children = new Map<string, string[]>();\n for (const n of ast.nodes) {\n parents.set(n.id, []);\n children.set(n.id, []);\n }\n for (const c of ast.connections) {\n parents.get(c.to)?.push(c.from);\n children.get(c.from)?.push(c.to);\n }\n\n const sortedLevels = Array.from(byLevel.keys()).sort((a, b) => a - b);\n const maxLevel = sortedLevels.length ? sortedLevels[sortedLevels.length - 1] : 0;\n\n // Assign sequential X for non-bus leaf-like nodes within each level.\n // Then propagate bus positions by averaging their children.\n let nextX = LEFT_PADDING;\n // x assignment helper: if children already placed, center above them; else nextX\n function placeNode(id: string): SLDLayoutNode {\n const existing = byIdLayout.get(id);\n if (existing) return existing;\n const node = nodeMap.get(id)!;\n const lvl = levels.get(id) ?? 0;\n const geom = geometryFor(node.nodeType);\n const y = TOP_PADDING + lvl * LEVEL_SPACING;\n const ln: SLDLayoutNode = {\n node,\n nodeType: node.nodeType,\n x: 0,\n y,\n topY: y + geom.topY,\n bottomY: y + geom.bottomY,\n level: lvl,\n halfWidth: geom.halfWidth,\n };\n byIdLayout.set(id, ln);\n layoutNodes.push(ln);\n return ln;\n }\n\n // Walk levels top-to-bottom placing non-bus nodes sequentially; buses get centered on children\n // We do this in two passes: first place everything sequentially, then re-center buses.\n for (const lvl of sortedLevels) {\n for (const id of byLevel.get(lvl)!) {\n const ln = placeNode(id);\n if (ln.nodeType === \"bus\") {\n // defer\n ln.x = nextX; // placeholder\n } else {\n ln.x = nextX;\n nextX += H_SPACING;\n }\n }\n }\n\n // Center buses over their children (or parents if no children)\n // Iterate multiple times to stabilize.\n for (let iter = 0; iter < 4; iter++) {\n for (const lvl of sortedLevels) {\n for (const id of byLevel.get(lvl)!) {\n const ln = byIdLayout.get(id)!;\n if (ln.nodeType !== \"bus\") continue;\n const childrenIds = children.get(id) ?? [];\n const parentIds = parents.get(id) ?? [];\n const relatedXs: number[] = [];\n for (const cid of childrenIds) {\n const c = byIdLayout.get(cid);\n if (c && c.nodeType !== \"bus_tie\") relatedXs.push(c.x);\n }\n if (relatedXs.length === 0) {\n for (const pid of parentIds) {\n const p = byIdLayout.get(pid);\n if (p && p.nodeType !== \"bus_tie\") relatedXs.push(p.x);\n }\n }\n if (relatedXs.length > 0) {\n const minX = Math.min(...relatedXs);\n const maxX = Math.max(...relatedXs);\n ln.x = (minX + maxX) / 2;\n ln.busLeft = minX - BUS_OVERHANG;\n ln.busRight = maxX + BUS_OVERHANG;\n } else {\n ln.busLeft = ln.x - 40;\n ln.busRight = ln.x + 40;\n }\n }\n }\n }\n\n // Center non-bus nodes over their child(ren), bottom-up.\n // For convergence (child has multiple parents at same level), spread\n // parents horizontally around the child instead of collapsing them to one x.\n const CONVERGENCE_SPREAD = Math.max(H_SPACING, 110);\n for (let iter = 0; iter < 4; iter++) {\n for (const lvl of [...sortedLevels].reverse()) {\n for (const id of byLevel.get(lvl)!) {\n const ln = byIdLayout.get(id)!;\n if (ln.nodeType === \"bus\" || ln.nodeType === \"bus_tie\") continue;\n const childIds = children.get(id) ?? [];\n if (childIds.length === 1) {\n const child = byIdLayout.get(childIds[0]);\n if (!child) continue;\n // Only the convergence child's parents are spread\n const siblingParents = (parents.get(child.node.id) ?? [])\n .map((pid) => byIdLayout.get(pid))\n .filter((p): p is SLDLayoutNode => !!p && p.level === lvl && p.nodeType !== \"bus\");\n if (siblingParents.length > 1) {\n // Sort by original sequential x to preserve declared order\n siblingParents.sort((a, b) => a.x - b.x);\n const n = siblingParents.length;\n const spread = Math.max(\n CONVERGENCE_SPREAD,\n (child.halfWidth * 2 + 40) / Math.max(1, n - 1)\n );\n const idx = siblingParents.indexOf(ln);\n ln.x = child.x + (idx - (n - 1) / 2) * spread;\n } else {\n ln.x = child.x;\n }\n } else if (childIds.length > 1) {\n const xs = childIds\n .map((c) => byIdLayout.get(c)?.x)\n .filter((v): v is number => v !== undefined);\n if (xs.length > 0) {\n ln.x = (Math.min(...xs) + Math.max(...xs)) / 2;\n }\n }\n }\n }\n }\n\n // Bus-tie lateral placement: place tie and its \"second bus\" to the right\n // of the \"first bus\" at the same level. Shift the entire busB cluster\n // (all nodes reachable from busB excluding busA/tie) so the whole\n // right-side subtree moves together.\n for (const ln of layoutNodes) {\n if (ln.nodeType !== \"bus_tie\") continue;\n const inIds = parents.get(ln.node.id) ?? [];\n const outIds = children.get(ln.node.id) ?? [];\n const busA = inIds.map((id) => byIdLayout.get(id)).find((n) => n?.nodeType === \"bus\");\n const busB = outIds.map((id) => byIdLayout.get(id)).find((n) => n?.nodeType === \"bus\");\n if (!busA || !busB) continue;\n\n const busAChildren = (children.get(busA.node.id) ?? [])\n .map((id) => byIdLayout.get(id))\n .filter((c): c is SLDLayoutNode => !!c && c.nodeType !== \"bus_tie\");\n const busAMaxX = busAChildren.length\n ? Math.max(...busAChildren.map((c) => c.x))\n : busA.x;\n ln.y = busA.y;\n ln.x = busAMaxX + 60;\n\n // Cluster of busB: BFS in both directions excluding busA and tie itself\n const cluster = new Set<string>([busB.node.id]);\n const queue = [busB.node.id];\n const excluded = new Set<string>([busA.node.id, ln.node.id]);\n while (queue.length) {\n const cur = queue.shift()!;\n const neighbors = [...(children.get(cur) ?? []), ...(parents.get(cur) ?? [])];\n for (const nb of neighbors) {\n if (cluster.has(nb) || excluded.has(nb)) continue;\n cluster.add(nb);\n queue.push(nb);\n }\n }\n\n // Shift whole cluster so its leftmost member sits just right of the tie\n let minClusterX = Infinity;\n for (const id of cluster) {\n const n = byIdLayout.get(id);\n if (!n) continue;\n const left = n.nodeType === \"bus\" ? (n.busLeft ?? n.x) : n.x - n.halfWidth;\n if (left < minClusterX) minClusterX = left;\n }\n const desiredLeft = ln.x + 30;\n const shift = desiredLeft - minClusterX;\n if (shift > 0) {\n for (const id of cluster) {\n const n = byIdLayout.get(id);\n if (!n) continue;\n n.x += shift;\n if (n.busLeft !== undefined) n.busLeft += shift;\n if (n.busRight !== undefined) n.busRight += shift;\n }\n }\n }\n\n // Label-aware collision resolution within each level.\n // For each non-bus node, estimate displayed label width so sibling\n // placement respects text, not just symbol geometry.\n const labelHalfWidth = (ln: SLDLayoutNode): number => {\n if (ln.nodeType === \"bus\" || ln.nodeType === \"bus_tie\") return 0;\n const node = ln.node;\n const txtParts: string[] = [node.label ?? node.id];\n if (node.rating) txtParts.push(node.rating);\n const longest = txtParts.reduce((m, s) => Math.max(m, s.length), 0);\n // Bold 11px sans-serif id is ~6.2px per char at widest; pad a bit.\n return (longest * 6.2) / 2 + 4;\n };\n\n for (const lvl of sortedLevels) {\n const ids = byLevel.get(lvl)!;\n const sorted = ids.map((id) => byIdLayout.get(id)!).sort((a, b) => a.x - b.x);\n for (let i = 1; i < sorted.length; i++) {\n const prev = sorted[i - 1];\n const cur = sorted[i];\n if (prev.nodeType === \"bus\" && cur.nodeType !== \"bus\") continue;\n if (cur.nodeType === \"bus\" && prev.nodeType !== \"bus\") continue;\n const symGap =\n (prev.nodeType === \"bus\" ? 0 : prev.halfWidth) +\n (cur.nodeType === \"bus\" ? 0 : cur.halfWidth) +\n 16;\n const labelGap = labelHalfWidth(prev) + labelHalfWidth(cur) + 8;\n const minGap = Math.max(symGap, labelGap);\n if (cur.x - prev.x < minGap) {\n cur.x = prev.x + minGap;\n }\n }\n }\n\n // Bus nodes: re-update extent after collision resolution\n for (const ln of layoutNodes) {\n if (ln.nodeType !== \"bus\") continue;\n const childrenIds = children.get(ln.node.id) ?? [];\n const parentIds = parents.get(ln.node.id) ?? [];\n const xs: number[] = [];\n for (const cid of [...childrenIds, ...parentIds]) {\n const rel = byIdLayout.get(cid);\n if (rel && rel.nodeType !== \"bus_tie\") xs.push(rel.x);\n }\n // Include tie x so bus stretches up to the tie (but doesn't center on it)\n const tieXs: number[] = [];\n for (const cid of [...childrenIds, ...parentIds]) {\n const rel = byIdLayout.get(cid);\n if (rel && rel.nodeType === \"bus_tie\") tieXs.push(rel.x);\n }\n if (xs.length > 0) {\n let left = Math.min(...xs) - BUS_OVERHANG;\n let right = Math.max(...xs) + BUS_OVERHANG;\n for (const tx of tieXs) {\n if (tx < left) left = tx;\n if (tx > right) right = tx;\n }\n ln.busLeft = left;\n ln.busRight = right;\n ln.x = (Math.min(...xs) + Math.max(...xs)) / 2;\n }\n }\n\n // Update terminal Ys\n for (const ln of layoutNodes) {\n const geom = geometryFor(ln.nodeType);\n ln.topY = ln.y + geom.topY;\n ln.bottomY = ln.y + geom.bottomY;\n }\n\n // Build edges\n const edges: SLDLayoutEdge[] = [];\n for (const c of ast.connections) {\n const from = byIdLayout.get(c.from);\n const to = byIdLayout.get(c.to);\n if (!from || !to) continue;\n\n const fx = from.x;\n const tx = to.x;\n const lateralTie =\n from.nodeType === \"bus_tie\" ||\n to.nodeType === \"bus_tie\" ||\n (from.level === to.level && (from.nodeType === \"bus\" || to.nodeType === \"bus\"));\n\n let startY: number;\n let endY: number;\n if (lateralTie) {\n startY = from.y;\n endY = to.y;\n } else {\n startY = from.nodeType === \"bus\" ? from.y : from.bottomY;\n endY = to.nodeType === \"bus\" ? to.y : to.topY;\n }\n\n let pathD: string;\n if (lateralTie) {\n // Horizontal segment at common y; small stubs if tie sits on bus y\n pathD = `M ${fx} ${startY} L ${tx} ${endY}`;\n } else if (Math.abs(fx - tx) < 0.5) {\n pathD = `M ${fx} ${startY} L ${tx} ${endY}`;\n } else {\n // L-path: go down halfway, then horizontal, then vertical\n const midY = (startY + endY) / 2;\n pathD = `M ${fx} ${startY} L ${fx} ${midY} L ${tx} ${midY} L ${tx} ${endY}`;\n }\n\n edges.push({\n from: c.from,\n to: c.to,\n path: pathD,\n cable: c.cable,\n label: c.label,\n midX: (fx + tx) / 2,\n midY: (startY + endY) / 2,\n });\n }\n\n // Compute bands (voltage regions)\n const bands: SLDLayoutBand[] = [];\n for (const lvl of sortedLevels) {\n // Find a representative voltage label for this band\n let voltage: string | undefined;\n for (const id of byLevel.get(lvl)!) {\n const n = nodeMap.get(id)!;\n if (n.voltage) {\n voltage = n.voltage;\n break;\n }\n }\n bands.push({\n level: lvl,\n voltage,\n y: TOP_PADDING + lvl * LEVEL_SPACING - LEVEL_SPACING / 2 + 10,\n height: LEVEL_SPACING,\n });\n }\n\n // Normalize X so the leftmost content sits at LEFT_PADDING (no empty left gutter).\n let contentMinX = Infinity;\n for (const ln of layoutNodes) {\n const left = ln.nodeType === \"bus\"\n ? (ln.busLeft ?? ln.x)\n : ln.x - ln.halfWidth;\n if (left < contentMinX) contentMinX = left;\n }\n if (!Number.isFinite(contentMinX)) contentMinX = 0;\n const xShift = LEFT_PADDING - contentMinX;\n if (Math.abs(xShift) > 0.5) {\n for (const ln of layoutNodes) {\n ln.x += xShift;\n if (ln.busLeft !== undefined) ln.busLeft += xShift;\n if (ln.busRight !== undefined) ln.busRight += xShift;\n }\n for (const e of edges) {\n e.midX += xShift;\n // Shift every \"x\" coord in the path string (M / L tokens are \"x y\" pairs).\n e.path = e.path.replace(\n /([ML])\\s+(-?[\\d.]+)\\s+(-?[\\d.]+)/g,\n (_m, cmd, x, y) => `${cmd} ${Number(x) + xShift} ${y}`\n );\n }\n }\n\n // Compute canvas size\n let maxX = 0;\n for (const ln of layoutNodes) {\n const right = (ln.busRight ?? (ln.x + ln.halfWidth)) + 60;\n if (right > maxX) maxX = right;\n }\n const width = Math.max(400, maxX + 40);\n const height = TOP_PADDING + maxLevel * LEVEL_SPACING + 120;\n\n return {\n width,\n height,\n nodes: layoutNodes,\n edges,\n bands,\n nodeById: byIdLayout,\n };\n}\n","import type { SLDAST, SLDNode, RenderConfig } from \"../../core/types\";\nimport {\n svgRoot,\n group,\n el,\n path as pathEl,\n text as textEl,\n title as titleEl,\n desc,\n defs,\n} from \"../../core/svg\";\nimport { resolveIndustrialTheme, type IndustrialTokens, type ResolvedTheme } from \"../../core/theme\";\nimport { layoutSLD, type SLDLayoutNode } from \"./layout\";\nimport { renderSymbol } from \"./symbols\";\n\ntype IT = ResolvedTheme<IndustrialTokens>;\n\n// Zebra-band fills for grouped rows. Local to SLD — no other diagram uses\n// alternating row backgrounds, so they don't need to live in IndustrialTokens.\nconst BAND_ODD_LIGHT = \"#f7f7f7\";\nconst BAND_EVEN_LIGHT = \"#fbfbfb\";\nconst BAND_ODD_DARK = \"#2a2b3c\";\nconst BAND_EVEN_DARK = \"#313244\";\n\nfunction buildCss(t: IT): string {\n const isDark = t.bg !== \"#ffffff\";\n const bandOdd = isDark ? BAND_ODD_DARK : BAND_ODD_LIGHT;\n const bandEven = isDark ? BAND_EVEN_DARK : BAND_EVEN_LIGHT;\n return `\n.lt-sld { font-family: system-ui, -apple-system, sans-serif; }\n.lt-sld-stroke { stroke: ${t.stroke}; stroke-width: 1.8; fill: none; }\n.lt-sld-stroke-thick { stroke: ${t.stroke}; stroke-width: 2.4; fill: none; stroke-linecap: round; }\n.lt-sld-fill { fill: ${t.bg}; stroke: ${t.stroke}; stroke-width: 2; }\n.lt-sld-fill-dark { fill: ${t.stroke}; stroke: ${t.stroke}; stroke-width: 1; }\n.lt-sld-dot { fill: ${t.stroke}; stroke: none; }\n.lt-sld-wire { stroke: ${t.stroke}; stroke-width: 2; fill: none; }\n.lt-sld-bus { stroke: ${t.strokeHeavy}; stroke-width: 6; stroke-linecap: square; }\n.lt-sld-band-odd { fill: ${bandOdd}; stroke: none; }\n.lt-sld-band-even { fill: ${bandEven}; stroke: none; }\n.lt-sld-band-label { font: bold 11px sans-serif; fill: ${t.textMuted}; }\n.lt-sld-title { font: bold 16px sans-serif; fill: ${t.text}; }\n.lt-sld-id { font: bold 11px sans-serif; fill: ${t.text}; text-anchor: middle; }\n.lt-sld-rating { font: 9px sans-serif; fill: ${t.textMuted}; text-anchor: middle; }\n.lt-sld-voltage { font: bold 10px sans-serif; fill: ${t.textMuted}; }\n.lt-sld-nameplate { font: 9px sans-serif; fill: ${t.textMuted}; }\n.lt-sld-cable { font: 9px ui-monospace, SFMono-Regular, Menlo, monospace; fill: ${t.textMuted}; }\n.lt-sld-symbol-text { font: 11px sans-serif; fill: ${t.text}; dominant-baseline: middle; }\n.lt-sld-wdg { font: bold 10px sans-serif; fill: ${t.stroke}; dominant-baseline: middle; }\n.lt-sld-bus-label { font: bold 11px sans-serif; fill: ${t.accent}; }\n.lt-sld-standard-badge { font: bold 10px sans-serif; fill: ${t.textMuted}; letter-spacing: 0.3px; }\n`.trim();\n}\n\n/**\n * Jurisdiction-localised standard badge. ABNT (Brazil) reads in Portuguese;\n * AS/NZS and IEC use their published designations. ANSI (the default) shows no\n * badge to keep historical output unchanged.\n */\nfunction standardBadge(standard: SLDAST[\"standard\"]): string | undefined {\n switch (standard) {\n case \"iec\":\n return \"Standard: IEC 60617\";\n case \"abnt\":\n return \"Norma: ABNT NBR 5410 (IEC 60364)\";\n case \"as-nzs\":\n return \"Standard: AS/NZS 3000 (IEC 60364)\";\n default:\n return undefined;\n }\n}\n\nfunction renderLabels(ln: SLDLayoutNode): string[] {\n const pieces: string[] = [];\n const { node } = ln;\n if (ln.nodeType === \"bus\") {\n // Bus label + voltage sits above the bus bar\n const label = node.label ?? node.id;\n pieces.push(\n textEl(\n { x: (ln.busLeft ?? ln.x - 40) + 4, y: ln.y - 8, class: \"lt-sld-bus-label\" },\n node.voltage ? `${node.voltage} · ${label}` : label\n )\n );\n return pieces;\n }\n\n if (ln.nodeType === \"hub\") {\n // Label rendered inside the hub rect; skip external ID.\n if (node.rating || node.voltage) {\n const lines: string[] = [];\n if (node.rating) lines.push(node.rating);\n if (node.voltage) lines.push(node.voltage);\n lines.forEach((l, i) => {\n pieces.push(\n textEl(\n { x: ln.x, y: ln.bottomY + 14 + i * 11, class: \"lt-sld-rating\" },\n l\n )\n );\n });\n }\n return pieces;\n }\n\n if (ln.nodeType === \"bus_tie\") {\n // Tie breaker label to the side\n pieces.push(\n textEl(\n { x: ln.x, y: ln.topY - 6, class: \"lt-sld-rating\" },\n node.label ?? node.id\n )\n );\n return pieces;\n }\n\n // ID above\n const idY = ln.topY - 22;\n pieces.push(\n textEl({ x: ln.x, y: idY, class: \"lt-sld-id\" }, node.label ?? node.id)\n );\n\n // Rating below\n const lines: string[] = [];\n if (node.rating) lines.push(node.rating);\n if (node.voltage) lines.push(node.voltage);\n if (node.deviceNumber && ln.nodeType === \"relay\") {\n // deviceNumber is shown inside the relay glyph; skip here\n }\n lines.forEach((l, i) => {\n pieces.push(\n textEl(\n { x: ln.x, y: ln.bottomY + 14 + i * 11, class: \"lt-sld-rating\" },\n l\n )\n );\n });\n\n // Transformer nameplate\n if (\n (ln.nodeType === \"transformer\" ||\n ln.nodeType === \"transformer_dy\" ||\n ln.nodeType === \"transformer_yd\" ||\n ln.nodeType === \"transformer_yy\" ||\n ln.nodeType === \"transformer_dd\" ||\n ln.nodeType === \"autotransformer\" ||\n ln.nodeType === \"transformer_3winding\") &&\n node.nameplate\n ) {\n const np = node.nameplate;\n const keys = Object.keys(np);\n let offset = -12;\n const x = ln.x + ln.halfWidth + 28;\n for (const k of keys) {\n pieces.push(\n textEl(\n { x, y: ln.y + offset, class: \"lt-sld-nameplate\" },\n `${k}: ${np[k]}`\n )\n );\n offset += 11;\n }\n }\n\n return pieces;\n}\n\nexport function renderSLD(ast: SLDAST, config?: RenderConfig): string {\n const layout = layoutSLD(ast);\n const t = resolveIndustrialTheme(config?.theme ?? \"default\");\n const titleOffset = ast.title ? 34 : 12;\n const width = Math.ceil(layout.width);\n const height = Math.ceil(layout.height + titleOffset);\n\n const children: string[] = [];\n children.push(titleEl(ast.title ?? \"Single-Line Diagram\"));\n children.push(\n desc(\n `Single-line diagram with ${ast.nodes.length} nodes and ${ast.connections.length} connections`\n )\n );\n children.push(el(\"style\", {}, buildCss(t)));\n\n // Arrow marker\n children.push(\n defs([\n el(\n \"marker\",\n {\n id: \"lt-sld-arrow\",\n markerWidth: 8,\n markerHeight: 8,\n refX: 6,\n refY: 3,\n orient: \"auto\",\n markerUnits: \"strokeWidth\",\n },\n [el(\"path\", { d: \"M 0 0 L 6 3 L 0 6 z\", fill: t.textMuted })]\n ),\n ])\n );\n\n if (ast.title) {\n children.push(\n textEl({ x: 20, y: 22, class: \"lt-sld-title\" }, ast.title)\n );\n }\n\n // Standard-compliance badge (top-right), localised for the jurisdiction.\n const badge = standardBadge(ast.standard);\n if (badge) {\n children.push(\n textEl(\n { x: width - 14, y: 22, class: \"lt-sld-standard-badge\", \"text-anchor\": \"end\" },\n badge\n )\n );\n }\n\n const inner: string[] = [];\n\n // Voltage bands (alternating background)\n layout.bands.forEach((b, i) => {\n inner.push(\n el(\"rect\", {\n x: 0,\n y: b.y,\n width: layout.width,\n height: b.height,\n class: i % 2 === 0 ? \"lt-sld-band-odd\" : \"lt-sld-band-even\",\n })\n );\n if (b.voltage) {\n inner.push(\n textEl(\n { x: 14, y: b.y + 18, class: \"lt-sld-band-label\" },\n b.voltage\n )\n );\n }\n });\n\n // Connection wires (draw before symbols so symbols sit on top)\n for (const e of layout.edges) {\n inner.push(pathEl({ d: e.path, class: \"lt-sld-wire\" }));\n if (e.cable) {\n // Position cable label near midpoint, slightly offset\n inner.push(\n textEl(\n { x: e.midX + 6, y: e.midY - 2, class: \"lt-sld-cable\" },\n e.cable\n )\n );\n }\n if (e.label) {\n inner.push(\n textEl(\n { x: e.midX + 6, y: e.midY + 10, class: \"lt-sld-cable\" },\n e.label\n )\n );\n }\n }\n\n // Nodes\n for (const ln of layout.nodes) {\n if (ln.nodeType === \"bus\") {\n const left = ln.busLeft ?? ln.x - 40;\n const right = ln.busRight ?? ln.x + 40;\n inner.push(\n el(\"line\", {\n x1: left,\n y1: ln.y,\n x2: right,\n y2: ln.y,\n class: \"lt-sld-bus\",\n \"data-id\": ln.node.id,\n })\n );\n for (const piece of renderLabels(ln)) inner.push(piece);\n continue;\n }\n const attrs = {\n transform: `translate(${ln.x}, ${ln.y})`,\n \"data-type\": ln.nodeType,\n \"data-id\": ln.node.id,\n };\n inner.push(\n group(attrs, [\n renderSymbol(\n ln.nodeType,\n ln.nodeType === \"hub\"\n ? ln.node.label ?? ln.node.id\n : (ln.node as SLDNode).deviceNumber,\n ast.standard\n ),\n ])\n );\n for (const piece of renderLabels(ln)) inner.push(piece);\n }\n\n const wrap = group({ transform: `translate(0, ${titleOffset})` }, inner);\n children.push(wrap);\n\n return svgRoot(\n {\n class: \"lt-sld\",\n role: \"img\",\n \"aria-labelledby\": \"lt-sld-title lt-sld-desc\",\n width,\n height,\n viewBox: `0 0 ${width} ${height}`,\n },\n children\n );\n}\n","import type { SchematexDiagnostic } from \"../../core/diagnostics\";\nimport type { SLDAST, SLDNodeType } from \"../../core/types\";\nimport { isIecFamily } from \"../../core/types\";\nimport { parseSLDDSL } from \"./parser\";\n\n/**\n * SLD standard-compatibility lint.\n *\n * When an explicit `[standard: …]` is selected, flag devices that have no\n * symbol in that standard's published catalog so an engineer doesn't\n * unknowingly submit a glyph their jurisdiction won't accept. The engine does\n * not silently substitute a foreign symbol — it renders the closest available\n * form and warns.\n */\nexport function lintSLD(text: string): SchematexDiagnostic[] {\n let ast: SLDAST;\n try {\n ast = parseSLDDSL(text);\n } catch {\n return [];\n }\n return lintSLDAst(ast);\n}\n\n// North-American utility devices with no direct IEC 60617 glyph in our catalog.\n// Under an IEC-family standard they fall back to the ANSI form, which may not be\n// accepted in IEC submittals.\nconst ANSI_ONLY: Partial<Record<SLDNodeType, string>> = {\n recloser: \"recloser\",\n sectionalizer: \"sectionalizer\",\n watthour_meter: \"watt-hour meter\",\n demand_meter: \"demand meter\",\n};\n\nexport function lintSLDAst(ast: SLDAST): SchematexDiagnostic[] {\n const out: SchematexDiagnostic[] = [];\n if (!isIecFamily(ast.standard)) return out;\n\n const stdName = ast.standard === \"abnt\" ? \"ABNT NBR 5410\" : ast.standard === \"as-nzs\" ? \"AS/NZS 3000\" : \"IEC 60617\";\n const seen = new Set<SLDNodeType>();\n for (const node of ast.nodes) {\n const friendly = ANSI_ONLY[node.nodeType];\n if (!friendly || seen.has(node.nodeType)) continue;\n seen.add(node.nodeType);\n out.push({\n severity: \"warning\",\n code: \"SLD_SYMBOL_NOT_IN_STANDARD\",\n message: `device \"${node.nodeType}\" (${friendly}) has no symbol in ${stdName}; rendered with the ANSI/IEEE form`,\n hint: `${friendly} is a North-American utility convention. Confirm an equivalent device exists in ${stdName}, or model it with an IEC-native device.`,\n fatal: false,\n });\n }\n return out;\n}\n","import type { DiagramPlugin } from \"../../core/types\";\nimport { firstContentLine } from \"../../core/dsl-preprocess\";\nimport { parseSLDDSL } from \"./parser\";\nimport { renderSLD } from \"./renderer\";\nimport { lintSLD } from \"./lint\";\n\nexport const sld: DiagramPlugin = {\n type: \"sld\",\n detect(text: string): boolean {\n const first = firstContentLine(text)?.toLowerCase() ?? \"\";\n return first.startsWith(\"sld\");\n },\n parse: parseSLDDSL,\n lint: lintSLD,\n\n render(text: string, config): string {\n const ast = parseSLDDSL(text);\n return renderSLD(ast, config);\n },\n};\n\nexport { lintSLD, lintSLDAst } from \"./lint\";\nexport { parseSLDDSL } from \"./parser\";\nexport { renderSLD } from \"./renderer\";\nexport { layoutSLD } from \"./layout\";\n"]}
|