/** Offline parsing, validation and formatting. Pure: no I/O, no mutation. */ export declare const LENGTH = 11; /** The five segments of a postcode, `AA-99-H77-BB-55`, widest first. */ export declare const SEGMENTS: readonly ["state", "lga", "district", "area", "unit"]; export type Segment = (typeof SEGMENTS)[number]; /** The input did not hold exactly 11 letters and digits. */ export declare class WrongLength { readonly found: number; constructor(found: number); toString(): string; } /** The input did not end where a segment does: after 2, 4, 7, 9 or 11 letters and digits. */ export declare class WrongPrefixLength { readonly found: number; constructor(found: number); toString(): string; } /** The input held something other than letters, digits, spaces and hyphens. */ export declare class InvalidCharacter { readonly char: string; readonly index: number; constructor(char: string, index: number); toString(): string; } /** A segment has the wrong shape, such as digits in the state or `00` as a unit. */ export declare class InvalidSegment { readonly segment: Segment; constructor(segment: Segment); toString(): string; } export type ParseError = WrongLength | WrongPrefixLength | InvalidCharacter | InvalidSegment; /** Held only here, so nothing outside this module can build a `Postcode` unchecked. */ declare const CHECKED: unique symbol; /** * A well-formed postcode, held in its compact upper-case form. * * Well formed is not the same as assigned: only the NIPOST API knows whether a * code belongs to a real building. Build one with `parse`. */ export declare class Postcode { #private; /** @internal Callers use `parse`: only this module holds the key. */ constructor(key: typeof CHECKED, compact: string); /** Whether `value` came from `parse`. A look-alike object does not pass, as it does `instanceof`. */ static is(value: unknown): value is Postcode; /** The form to store and compare, `EK01A03FK01`. */ get compact(): string; /** The canonical hyphenated form, `EK-01-A03-FK-01`. */ toString(): string; toJSON(): string; /** The form shown to people, `EK 01 A03 FK 01`. */ get spaced(): string; get state(): string; get lga(): string; get district(): string; get area(): string; get unit(): string; segment(segment: Segment): string; /** The hyphenated code down to `through`: `prefix("area")` is `EK-01-A03-FK`. */ prefix(through: Segment): string; /** The code cut off after `through`, as a value: `truncate("area")` is the area this building is in. */ truncate(through: Segment): Prefix; } /** * A postcode cut off after one of its segments, such as the district `EK-01-A03`. * * It names every code that starts with it, so it serves to group or select codes by * state, LGA, district or area. A whole code is the narrowest prefix. Build one with * `parsePrefix` or `Postcode.truncate`. */ export declare class Prefix { #private; /** @internal Callers use `parsePrefix`: only this module holds the key. */ constructor(key: typeof CHECKED, compact: string); /** Whether `value` came from `parsePrefix` or `truncate`. */ static is(value: unknown): value is Prefix; /** The form to store and compare, `EK01A03`. */ get compact(): string; /** The last segment the prefix holds. */ get through(): Segment; /** The prefix one segment shorter, or null for a state. */ get parent(): Prefix | null; /** Whether `code` starts with this prefix. */ contains(code: Postcode): boolean; /** The hyphenated form, `EK-01-A03`. */ toString(): string; toJSON(): string; } /** The result of `parseLenient`. */ export interface Corrected { readonly postcode: Postcode; /** How many characters were swapped for their look-alike. */ readonly corrections: number; } /** Parse a hyphenated, spaced or compact code in either case. */ export declare function parse(text: string): Postcode | ParseError; /** * Parse after swapping look-alikes that cannot occur where they stand: `0 1 5 8` * become `O I S B` where a letter is required, and `O I L S B` become `0 1 1 5 8` * where a digit is. The district allows both, so it is never rewritten. * * The result is well formed but may not be the code the user meant, so confirm * it with them when `corrections` is not zero. */ export declare function parseLenient(text: string): Corrected | ParseError; /** Parse a hyphenated, spaced or compact prefix in either case. */ export declare function parsePrefix(text: string): Prefix | ParseError; /** Build a code from its segments, zero-filling the LGA and unit. */ export declare function fromSegments(state: string, lga: string, district: string, area: string, unit: string): Postcode | ParseError; /** Whether `text` is a well-formed postcode. */ export declare function isValid(text: string): boolean; /** * Trim Unicode White_Space, which every implementation trims. `trim()` alone skips * U+0085 and removes U+FEFF, which the others keep. */ export declare function trimWhiteSpace(text: string): string; export {};