/** * Public color parser. Accepts the relaxed forms an LLM or hand-authored JSON * is likely to emit (hex strings, `rgb(...)` strings, named colors, RGB or * CMYK objects with mixed 0–1 vs 0–255 components) and returns the canonical * `PdfColor` shape with all components in the strict 0..1 PDF range. * * Addresses `docs/0428-claude-test-based-directive2.md` §"@paperjsx/json-to-pdf" * items (1) and (2): hex must be accepted at the API boundary, and a single * helper must produce the canonical shape used everywhere downstream. */ import type { PdfColor } from "./phase4-types.js"; export type PdfColorInput = string | { space: "rgb"; r: number; g: number; b: number; } | { space: "cmyk"; c: number; m: number; y: number; k: number; } | { r: number; g: number; b: number; } | { c: number; m: number; y: number; k: number; }; export declare class PdfColorParseError extends Error { readonly input: unknown; readonly path: string | undefined; constructor(message: string, input: unknown, path?: string); } /** * Parse a relaxed color input into the canonical `PdfColor` shape. * * Accepted inputs: * - Hex strings: "#RGB", "#RRGGBB", "RGB", "RRGGBB" * - rgb()/rgba() strings: "rgb(229, 231, 235)" / "rgba(0, 0, 0, 0.5)" (alpha is ignored) * - Named colors: black, white, red, green, blue, gray * - RGB object: { r, g, b } or { space: "rgb", r, g, b } (components in 0..1) * - CMYK object: { c, m, y, k } or { space: "cmyk", c, m, y, k } (components in 0..1) * * @throws PdfColorParseError with a path-prefixed message */ export declare function parseColor(input: PdfColorInput, path?: string): PdfColor; export declare function tryParseColor(input: unknown, path?: string): PdfColor | undefined; //# sourceMappingURL=parse-color.d.ts.map