import { a as Direction, c as Grid, d as Puzzle, f as RebusId, h as asRebusId, i as Clues, l as GridCoordinate, m as asGridCoordinate, n as Clue, o as ErrorCode, p as asClueNumber, r as ClueNumber, s as ErrorContext, t as Cell, u as ParseOptions } from "./types-BHvD0ULE.js"; //#region src/ipuz.d.ts declare enum CellType { NORMAL = "normal", BLOCK = "block", NULL = "null" } interface CellStyle { shapebg?: string; highlight?: boolean; named?: boolean; border?: number; divided?: string; label?: string; mark?: Record; imagebg?: string; color?: string; colortext?: string; colorborder?: string; colorbar?: string; barred?: string; dotted?: string; dashed?: string; lessthan?: string; greaterthan?: string; equal?: string; handler?: string; handlerdata?: unknown; } interface IpuzCell { type: CellType; number?: number | string; value?: string; solution?: string; style?: CellStyle; continued?: Record; directions?: string[]; given?: boolean; } interface IpuzClue { number: number | string; text: string; cells?: Array<[number, number]>; references?: Array; continued?: Record; highlight?: boolean; image?: string; } interface IpuzPuzzle { version: string; kind: string[]; dimensions: { width: number; height: number; }; puzzle: IpuzCell[][]; title?: string; author?: string; copyright?: string; publisher?: string; publication?: string; url?: string; uniqueId?: string; intro?: string; explanation?: string; annotation?: string; notes?: string; difficulty?: string; origin?: string; date?: string; empty?: string; charset?: string; clues: Record; solution?: Array>; zones?: Array>; styles?: Record; extensions: Record; volatile?: Record; checksum?: string[]; saved?: Array>; enumeration?: boolean; enumerations?: string[]; misses?: Record; block?: string; showEnumerations?: boolean; cluePlacement?: string; answer?: string; answers?: string[]; } /** * Parse an iPUZ format crossword puzzle. * * @param content - The iPUZ data as JSON string or Buffer * @param options - Optional parsing options * @param options.maxGridSize - Maximum allowed grid dimensions * @returns An IpuzPuzzle object containing all puzzle data * @throws {IpuzParseError} When the content is not valid iPUZ format * @throws {UnsupportedPuzzleTypeError} When the puzzle is not a crossword * * @example * ```typescript * import { parseIpuz } from 'xword-parser'; * const ipuzData = '{"version":"http://ipuz.org/v2","kind":["http://ipuz.org/crossword#1"]...}'; * const puzzle = parseIpuz(ipuzData); * ``` */ declare function parseIpuz(content: string | Buffer, options?: ParseOptions): IpuzPuzzle; /** * Convert an iPUZ puzzle to the unified Puzzle format. * * @param puzzle - The IpuzPuzzle object to convert * @returns A unified Puzzle object * * @example * ```typescript * import { parseIpuz, convertIpuzToUnified } from 'xword-parser'; * const ipuzPuzzle = parseIpuz(ipuzData); * const unifiedPuzzle = convertIpuzToUnified(ipuzPuzzle); * ``` */ declare function convertIpuzToUnified(puzzle: IpuzPuzzle): Puzzle; //#endregion //#region src/xd.d.ts interface XdMetadata { title?: string; author?: string; editor?: string; copyright?: string; date?: string; rebus?: string; [key: string]: string | undefined; } interface XdClue { number: string; clue: string; answer: string; metadata?: Record; } interface XdPuzzle { metadata: XdMetadata; grid: string[][]; across: XdClue[]; down: XdClue[]; notes?: string; } /** * Parse an XD format crossword puzzle. * * @param content - The XD text data as string * @param options - Optional parsing options * @param options.maxGridSize - Maximum allowed grid dimensions * @returns An XdPuzzle object containing all puzzle data * @throws {XdParseError} When the content is not valid XD format * * @example * ```typescript * import { parseXd } from 'xword-parser'; * const xdData = 'Title: Example\\nAuthor: John Doe\\n\\n## Grid\\n...'; * const puzzle = parseXd(xdData); * ``` */ declare function parseXd(content: string, options?: ParseOptions): XdPuzzle; /** * Convert an XD puzzle to the unified Puzzle format. * * @param puzzle - The XdPuzzle object to convert * @returns A unified Puzzle object * * @example * ```typescript * import { parseXd, convertXdToUnified } from 'xword-parser'; * const xdPuzzle = parseXd(xdData); * const unifiedPuzzle = convertXdToUnified(xdPuzzle); * ``` */ declare function convertXdToUnified(puzzle: XdPuzzle): Puzzle; //#endregion //#region src/puz.d.ts interface PuzMetadata { title?: string; author?: string; copyright?: string; notes?: string; } interface PuzClue { number: number; text: string; } interface PuzCell { solution?: string; playerState?: string; isBlack: boolean; isCircled?: boolean; hasRebus?: boolean; rebusKey?: number; } interface PuzPuzzle { width: number; height: number; metadata: PuzMetadata; grid: PuzCell[][]; across: PuzClue[]; down: PuzClue[]; rebusTable?: Map; isScrambled?: boolean; timer?: { elapsed: number; running: boolean; }; } /** * Parse a PUZ format crossword puzzle. * * @param data - The PUZ binary data as Buffer, ArrayBuffer, Uint8Array, or string * @param options - Optional parsing options * @param options.maxGridSize - Maximum allowed grid dimensions * @returns A PuzPuzzle object containing all puzzle data * @throws {PuzParseError} When the content is not valid PUZ format * @throws {InvalidFileError} When the file is corrupted or has invalid checksums * * @example * ```typescript * import { parsePuz } from 'xword-parser'; * import { readFileSync } from 'fs'; * * const puzData = readFileSync('puzzle.puz'); * const puzzle = parsePuz(puzData); * ``` */ declare function parsePuz(data: Buffer | ArrayBuffer | Uint8Array | string, options?: ParseOptions): PuzPuzzle; /** * Convert a PUZ puzzle to the unified Puzzle format. * * @param puzzle - The PuzPuzzle object to convert * @returns A unified Puzzle object * * @example * ```typescript * import { parsePuz, convertPuzToUnified } from 'xword-parser'; * const puzPuzzle = parsePuz(puzData); * const unifiedPuzzle = convertPuzToUnified(puzPuzzle); * ``` */ declare function convertPuzToUnified(puzzle: PuzPuzzle): Puzzle; //#endregion //#region src/jpz.d.ts interface JpzMetadata { title?: string; creator?: string; copyright?: string; description?: string; publisher?: string; identifier?: string; } interface JpzCell { x: number; y: number; solution?: string; number?: number; type?: "block" | "cell"; isCircled?: boolean; backgroundColor?: string; barTop?: boolean; barBottom?: boolean; barLeft?: boolean; barRight?: boolean; } interface JpzClue { number: string | number; text: string; format?: string; } interface JpzWord { id: string; cells: Array<{ x: number; y: number; }>; } interface JpzPuzzle { width: number; height: number; metadata: JpzMetadata; grid: JpzCell[][]; across: JpzClue[]; down: JpzClue[]; words?: JpzWord[]; } /** * Parse a JPZ format crossword puzzle. * * @param content - The JPZ XML data as string * @param options - Optional parsing options * @param options.maxGridSize - Maximum allowed grid dimensions * @returns A JpzPuzzle object containing all puzzle data * @throws {JpzParseError} When the content is not valid JPZ format * @throws {UnsupportedPuzzleTypeError} When the puzzle is not a crossword * * @example * ```typescript * import { parseJpz } from 'xword-parser'; * const jpzData = '...'; * const puzzle = parseJpz(jpzData); * ``` */ declare function parseJpz(content: string, options?: ParseOptions): JpzPuzzle; /** * Convert a JPZ puzzle to the unified Puzzle format. * * @param puzzle - The JpzPuzzle object to convert * @returns A unified Puzzle object * * @example * ```typescript * import { parseJpz, convertJpzToUnified } from 'xword-parser'; * const jpzPuzzle = parseJpz(jpzData); * const unifiedPuzzle = convertJpzToUnified(jpzPuzzle); * ``` */ declare function convertJpzToUnified(puzzle: JpzPuzzle): Puzzle; //#endregion //#region src/errors.d.ts /** * Base error class for all parsing errors */ declare class ParseError extends Error { readonly code: ErrorCode; readonly context?: ErrorContext; constructor(message: string, code?: ErrorCode, context?: ErrorContext, cause?: unknown); /** * Determines if this error indicates a format mismatch (file is valid but wrong format) * vs a real parsing error (file is corrupted or has other issues) */ isFormatMismatch(): boolean; } /** * Error thrown when the input format cannot be detected */ declare class FormatDetectionError extends ParseError { constructor(message?: string, context?: ErrorContext, cause?: unknown); } /** * Error thrown when a file is corrupted or invalid */ declare class InvalidFileError extends ParseError { constructor(format: string, message: string, context?: ErrorContext, cause?: unknown); } /** * Error thrown when a puzzle type is not supported */ declare class UnsupportedPuzzleTypeError extends ParseError { constructor(puzzleType: string, context?: ErrorContext, cause?: unknown); } /** * Format-specific error classes */ declare class IpuzParseError extends ParseError { constructor(message: string, code?: ErrorCode, context?: ErrorContext, cause?: unknown); isFormatMismatch(): boolean; } declare class PuzParseError extends ParseError { constructor(message: string, code?: ErrorCode, context?: ErrorContext, cause?: unknown); isFormatMismatch(): boolean; } declare class JpzParseError extends ParseError { constructor(message: string, code?: ErrorCode, context?: ErrorContext, cause?: unknown); isFormatMismatch(): boolean; } declare class XdParseError extends ParseError { constructor(message: string, code?: ErrorCode, context?: ErrorContext, cause?: unknown); isFormatMismatch(): boolean; } /** * Error thrown when binary data cannot be read or parsed correctly. * This is used by the BinaryReader class for low-level binary parsing errors. */ declare class BinaryParseError extends ParseError { constructor(message: string, context?: ErrorContext); } //#endregion //#region src/validate.d.ts /** * Validate a unified Puzzle structure for type correctness and structural integrity. * Throws InvalidFileError if the puzzle is malformed. * * :param puzzle: The puzzle to validate * :returns: The validated puzzle (for chaining) * :raises InvalidFileError: When the puzzle structure is invalid */ declare function validatePuzzle(puzzle: Puzzle): Puzzle; //#endregion //#region src/index.d.ts /** * Parse a crossword puzzle from various formats (iPUZ, PUZ, JPZ, XD). * Automatically detects the format and returns a unified puzzle structure. * * @param data - The puzzle data as string, Buffer, or ArrayBuffer * @param options - Optional parsing options * @param options.filename - Filename hint to improve format detection * @param options.encoding - Character encoding for text formats (default: 'utf-8') * @param options.maxGridSize - Maximum allowed grid dimensions * @returns A unified Puzzle object * @throws {FormatDetectionError} When the format cannot be detected * @throws {ParseError} When parsing fails for the detected format * * @example * ```typescript * import { parse } from 'xword-parser'; * import { readFileSync } from 'fs'; * * const content = readFileSync('puzzle.puz'); * const puzzle = parse(content, { filename: 'puzzle.puz' }); * console.log(puzzle.title, puzzle.grid.width + 'x' + puzzle.grid.height); * ``` */ declare function parse(data: string | Buffer | ArrayBuffer, options?: ParseOptions): Puzzle; //#endregion export { BinaryParseError, Cell, CellStyle, CellType, Clue, ClueNumber, Clues, Direction, ErrorCode, ErrorContext, FormatDetectionError, Grid, GridCoordinate, InvalidFileError, IpuzCell, IpuzClue, IpuzParseError, IpuzPuzzle, JpzCell, JpzClue, JpzMetadata, JpzParseError, JpzPuzzle, JpzWord, ParseError, ParseOptions, PuzCell, PuzClue, PuzMetadata, PuzParseError, PuzPuzzle, Puzzle, RebusId, UnsupportedPuzzleTypeError, XdClue, XdMetadata, XdParseError, XdPuzzle, asClueNumber, asGridCoordinate, asRebusId, convertIpuzToUnified, convertJpzToUnified, convertPuzToUnified, convertXdToUnified, parse, parseIpuz, parseJpz, parsePuz, parseXd, validatePuzzle }; //# sourceMappingURL=index.d.ts.map