/** * @copyright Sister Software * @license AGPL-3.0 * @author Teffen Ellis, et al. * * Generates localized PO-box and private-mailbox rows in which the designator and number form one `po_box` span. */ import type { CanonicalRow } from "#types"; /** * The address tail for one PO-box row. */ export interface PoBoxBaseTuple { locality: string; region: string; postcode: string; country: string; } /** * One locale's PO-box designators. */ export interface LocaleTemplate { locale: string; leaders: ReadonlyArray; /** * Private-mailbox designators. * They render beside the street instead of replacing it. */ pmb?: ReadonlyArray; } /** * The PO-box designator vocabulary for each supported locale. * * Other recipes, such as the CEDEX recipe, reuse this list. */ export declare const PO_BOX_LOCALE_TEMPLATES: ReadonlyArray; /** * Returns the box number unchanged 90% of the time. * * Otherwise, the function adds a thousands comma, an inner hyphen, or spaces between the digits. */ export declare function maybeNoisifyBoxNumber(num: string, random: () => number): string; /** * Joins a designator and a number into one `po_box` phrase. */ export declare function composePoBoxPhrase(leader: string, number: string): string; /** * One synthesized row with its template. */ export interface SynthesizedPoBoxRow { raw: string; components: CanonicalRow["components"]; locale: string; template: "po-box" | "pmb-with-street" | "military-po-box"; } /** * Options for the PO-box synthesizers. */ export interface PoBoxSynthesisOpts { /** * The random source. * It defaults to `Math.random`. */ random?: () => number; /** * The box-number generator. * * By default, it chooses a number from 1 to 99,999 and weights short numbers more heavily. */ pickNumber?: (random: () => number) => string; /** * The probability of a private-mailbox row when the locale and tuple allow one. * The default is 0. */ pmbRatio?: number; } /** * Generates a localized PO-box row, or a private-mailbox row when the tuple * has a street and the locale allows it. * * The function returns `null` when the country lacks a template locale, an ISO code or a layout. */ export declare function synthesizePoBoxRow(base: PoBoxBaseTuple & { street?: string; houseNumber?: string; }, opts?: PoBoxSynthesisOpts): SynthesizedPoBoxRow | null; /** * Generates a US military or diplomatic address without a base tuple. * * The unit line is the `po_box`. * APO, FPO, or DPO is the locality. * The armed-forces code is the region. */ export declare function synthesizeMilitaryPoBoxRow(opts?: PoBoxSynthesisOpts): SynthesizedPoBoxRow; /** * Returns the locale whose PO-box vocabulary a country uses. * * Countries without their own template use `en-US` designators. * Their address order still comes from the country's layout. */ export declare function poBoxTemplateLocale(country: string): string; /** * Returns the locales that have PO-box templates. */ export declare function supportedLocales(): ReadonlyArray; /** * Locales whose standard PO-box layout omits the region. */ export declare const REGION_OPTIONAL_LOCALES: ReadonlySet; //# sourceMappingURL=po-box.d.ts.map