type DgmoSeverity = 'error' | 'warning'; interface DgmoError { line: number; column?: number; message: string; severity: DgmoSeverity; /** * Optional stable diagnostic code (e.g. 'E_ARROW_SUBSTRING_IN_LABEL'). * Additive; pre-existing diagnostics omit this field and existing * substring-on-`.message` assertions keep working unchanged. */ code?: string; /** * Set only when the error was raised in a file OTHER than the one being * parsed — today, a file pulled in by an org chart's `import`. Holds that * file's path as the import directive wrote it. When present, `line` points * at the top-level `import` line that led there, NOT at the offending line, * and `fileLine` carries the line within `file`. */ file?: string; /** 1-based line within `file`. Only set alongside `file`. */ fileLine?: number; } declare function makeDgmoError(line: number, message: string, severity?: DgmoSeverity, code?: string): DgmoError; /** Runtime params passed to `emit()` and forwarded to a message builder. */ type DiagnosticParams = Record; /** * Parameter type for a `DiagnosticSpec.message` builder body. Typed loosely * (`any`) on purpose: builders are hand-authored interpolation bags keyed by * ad-hoc names, and dgmo's tsconfig enables `noPropertyAccessFromIndexSignature` * (which forbids `p.name` dot-access on a `Record`). Using * `any` here keeps builder bodies readable (`p.name`) instead of forcing * `p['name']` bracket access at every interpolation site. */ type DiagnosticMessageParams = any; interface DiagnosticSpec { /** Stable diagnostic code, e.g. `'E_MAP_UNKNOWN_PLACE'`. */ code: string; /** Severity — must agree with the `E_`/`W_`/`I_` code prefix. */ severity: DgmoSeverity; /** Owning chart type (`'map'`, `'swimlane'`, …) or `null` for universal/global codes. */ chartType: string | null; /** Short human label for the catalog UI. */ title: string; /** * Canonical message wording. A plain string for static messages, or a * builder `(params) => string` when the message interpolates runtime * values. The builder must tolerate being called with `{}` so the * catalog can show a representative message without live params. */ message: string | ((params: DiagnosticMessageParams) => string); /** Optional fix guidance shown alongside the message. */ hint?: string; /** Minimal `.dgmo` source that triggers this diagnostic (for docs/console). */ example?: string; } /** Optional extras when emitting (currently just an explicit column). */ interface EmitOptions { column?: number; } /** * Emit a diagnostic from its `DiagnosticSpec`. The code, severity, and * canonical wording all come from the spec — call sites supply only the * line and the interpolation params, so the code/severity can never drift * out of sync with the declared spec. Replaces the per-parser * `push`/`err`/`fail` wrappers that each re-declared this shape. */ declare function emit(spec: DiagnosticSpec, line: number, params?: DiagnosticParams, opts?: EmitOptions): DgmoError; declare function formatDgmoError(err: DgmoError): string; /** * Compact view state schema (ADR-6). * All fields optional. Only non-default values are encoded. * `tag: null` means "user chose none"; absent `tag` means "use DSL default" (ADR-5). */ interface CompactViewState { tag?: string | null; cs?: number[]; cg?: string[]; swim?: string | null; cl?: string[]; cc?: string[]; rm?: string; htv?: Record; ha?: string[]; sem?: boolean; cm?: boolean; c4l?: string; c4s?: string; c4c?: string; rps?: number; spd?: number; io?: Record; hd?: boolean; cbd?: boolean; rq?: string; an?: boolean; fl?: boolean; } interface DecodedDiagramUrl { dsl: string; viewState: CompactViewState; palette?: string; theme?: 'light' | 'dark'; filename?: string; } interface EncodeDiagramUrlOptions { baseUrl?: string; viewState?: CompactViewState; palette?: string; theme?: 'light' | 'dark'; filename?: string; } type EncodeDiagramUrlResult = { url: string; error?: undefined; } | { url?: undefined; error: 'too-large'; compressedSize: number; limit: number; }; /** * Encode a CompactViewState to a compressed string for URL embedding. * Returns empty string if state has no keys (ADR-4). */ declare function encodeViewState(state: CompactViewState): string; /** * Decode a compressed view state string back to CompactViewState. * Returns empty object on failure (no crash). */ declare function decodeViewState(encoded: string): CompactViewState; /** * Compress a DGMO DSL string into a shareable URL. * Returns `{ url }` on success, or `{ error: 'too-large', compressedSize, limit }` if the * compressed payload exceeds the 8 KB limit. */ declare function encodeDiagramUrl(dsl: string, options?: EncodeDiagramUrlOptions): EncodeDiagramUrlResult; /** * Decode a DGMO DSL string and view state from a URL query string or hash. * Accepts any of: * - `?dgmo=&vs=` * - `#dgmo=&vs=` (backwards compat) * - `dgmo=` * - `` * * Returns `{ dsl, viewState }`. The DSL is empty string on invalid input. */ declare function decodeDiagramUrl(hash: string): DecodedDiagramUrl; /** * Color definitions for a single mode (light or dark). * 10 semantic UI colors + 9 named accent colors = 19 total. * * `readonly` on every field (and the nested `colors` map) by design — * palettes flow from the registry into every renderer; nothing in the * pipeline should ever mutate a palette in place. */ interface PaletteColors { /** Main background (#eceff4 light / #2e3440 dark for Nord) */ readonly bg: string; /** Cards, panels (#e5e9f0 / #3b4252) */ readonly surface: string; /** Popovers, dropdowns (#e5e9f0 / #434c5e) */ readonly overlay: string; /** Borders, dividers, muted (#d8dee9 / #4c566a) */ readonly border: string; /** Primary text (#2e3440 / #eceff4) */ readonly text: string; /** Secondary/diminished text (#4c566a / #d8dee9) */ readonly textMuted: string; /** * Light-mode arg for `contrastText()` when text is rendered on a * tinted shape fill (e.g. `shapeFill()` output). Must guarantee * ≥ 4.5:1 WCAG AA against any `shapeFill()` the palette can produce. * Distinct from `colors.white` because palette-aesthetic anchors don't * always meet contrast requirements (TD-5). */ readonly textOnFillLight: string; /** Dark-mode counterpart to `textOnFillLight`. */ readonly textOnFillDark: string; /** Primary accent — buttons, links */ readonly primary: string; /** Secondary accent */ readonly secondary: string; /** Tertiary accent */ readonly accent: string; /** Error/danger */ readonly destructive: string; /** * Used for: inline annotations (red), pie charts, cScale, * series rotation, journey actors, Gantt tasks. */ readonly colors: { readonly red: string; readonly orange: string; readonly yellow: string; readonly green: string; readonly blue: string; readonly purple: string; readonly teal: string; readonly cyan: string; readonly gray: string; readonly black: string; readonly white: string; }; } /** * Complete palette definition. One object per color scheme. * This is what palette authors create — the single artifact for NFR1. * * Palettes are immutable from the consumer's perspective; the registry * hands out the same frozen-shape object on every `getPalette(id)`. */ interface PaletteConfig { /** Registry key: 'nord', 'slate', 'catppuccin' */ readonly id: string; /** Display name: 'Nord', 'Slate', 'Catppuccin' */ readonly name: string; /** Light mode color definitions */ readonly light: PaletteColors; /** Dark mode color definitions */ readonly dark: PaletteColors; } /** A single entry inside a tag group: `Value color` */ interface TagEntry { readonly value: string; readonly color: string; /** * The color NAME the author wrote (one of the recognized palette names), * when the entry declared an explicit color. Absent for bare/auto-colored * entries. `color` above is always the RESOLVED hex (auto and explicit are * indistinguishable there); this preserves the authored-vs-auto distinction * so a GUI editor can round-trip an explicit color through a reparse. */ readonly authoredColor?: string; readonly lineNumber: number; } /** * A tag group block: heading + entries. * * Parser internals build via `Writable` from `utils/brand.ts`; * once returned to a chart-type parser, consumers see the readonly view. */ interface TagGroup { readonly name: string; readonly alias?: string; readonly entries: readonly TagEntry[]; /** Default value for nodes without explicit metadata. First entry unless another is marked `default`. */ readonly defaultValue?: string; readonly lineNumber: number; } /** * DOM-safe key for a tag group — used wherever the group name becomes a * `data-tag-*` attribute suffix, an entity metadata key, or an `active-tag` * match target. For a single-identifier name (the only form the parser used to * accept) this is exactly `name.toLowerCase()`, so swapping it in for existing * diagrams is byte-identical. A quoted multi-word name (`tag "Trust Zone" as tz`) * slugs to a hyphenated identifier (`trust-zone`) so it never produces an * invalid DOM attribute name; the original `name` is kept for the legend label. */ declare function tagAttrKey(name: string): string; /** * The categorical name cycle used to auto-assign colors to bare tag values, * in deterministic order. Aliased to the shared {@link CATEGORICAL_COLOR_ORDER} * (RGB-seeded, max-contrast, neutrals excluded) so tag swatches and data-chart * series colors share one canonical rotation. If a group has more colorless * entries than free categorical names, the cycle wraps. */ declare const autoTagColorCycle: readonly string[]; export { type CompactViewState as C, type DgmoError as D, type EmitOptions as E, type PaletteConfig as P, type TagGroup as T, type PaletteColors as a, type DiagnosticSpec as b, type DgmoSeverity as c, type DiagnosticParams as d, emit as e, formatDgmoError as f, type TagEntry as g, type DecodedDiagramUrl as h, type EncodeDiagramUrlOptions as i, type EncodeDiagramUrlResult as j, autoTagColorCycle as k, decodeDiagramUrl as l, decodeViewState as m, encodeDiagramUrl as n, encodeViewState as o, makeDgmoError as p, tagAttrKey as t };