import { HTMLAttributes } from 'react';
import { JSX } from 'react';
import { ReactElement } from 'react';
import { ReactNode } from 'react';
/**
* Move a date by a number of working days.
*
* `n` days forward means `n` calls to {@link nextBusinessDay}; a negative `n`
* walks backwards the same way. `n === 0` returns the day unchanged **even when it
* is not a working day** — snapping silently would hide the case a caller most
* needs to see.
*
* @param date - `YYYY-MM-DD` or a `Date`.
* @param days - Working days to add. May be negative.
* @param options - See {@link BusinessDayOptions}.
* @returns Local midnight of the resulting day.
* @throws {RangeError} On a malformed input, or on a calendar with no working days.
*
* @example
* addBusinessDays("2026-04-01", 2); // 2026-04-06 — skips Good Friday and the weekend
*/
export declare function addBusinessDays(date: DateInput, days: number, options?: BusinessDayOptions): Date;
/**
* Administrative regions of a federative unit.
*
* Only the Federal District has any — 35 of them, inside its single
* municipality. Every other UF answers `[]`, which is a valid result and not an
* error.
*
* @param uf - Federative unit acronym, case-insensitive.
* @returns The regions, alphabetically. Empty outside the DF.
*/
export declare function administrativeRegionsByUf(uf: string): readonly BrazilAdministrativeRegion[];
/** What the two parsers return. Narrow on `kind`. */
export declare type Boleto = BoletoBanco | BoletoArrecadacao;
/** An arrecadação/convênio slip — utilities, taxes, traffic fines. */
export declare interface BoletoArrecadacao {
kind: "arrecadacao";
/** 44 digits, always starting with `8`. */
codigoBarras: string;
/** 48 digits, in four blocks of twelve. */
linhaDigitavel: string;
/** Position 2. See {@link segmentoLabel}. */
segmento: number;
/** Human label, or `null` for a value the layout does not define. */
segmentoLabel: string | null;
/** Position 3: `6`/`8` mean real money, `7`/`9` mean a reference quantity. */
identificacaoValor: number;
/** Which modulo position 3 selects for the general check digit. */
dvModulo: 10 | 11;
/** The general check digit, position 4. */
dv: string;
/** Reais, or `null` when position 3 says the field is a reference, not money. */
valor: number | null;
/** The raw 11-digit value field, useful when {@link valor} is `null`. */
valorRaw: string;
/**
* Positions 16-19 — the 4-digit code FEBRABAN assigns the company — or, on
* segmento 6, positions 16-23, which are the first eight CNPJ digits.
*/
empresa: string;
/** `true` when {@link empresa} is a CNPJ prefix rather than a FEBRABAN code. */
empresaIsCnpj: boolean;
/** 25 digits, or 21 when the CNPJ took four of them. Issuer-defined. */
campoLivre: string;
/**
* Due date read from the first eight digits of the campo livre.
*
* The layout says a due date, **if present**, must sit there as `AAAAMMDD` —
* but the field is optional and nothing marks its presence, so a campo livre
* that merely looks like a date lands here too. Treat it as a hint for a UI,
* never as the date a payment settles against.
*/
vencimentoCampoLivre: Date | null;
}
/** A cobrança boleto — the kind a bank issues against an invoice. */
export declare interface BoletoBanco {
kind: "banco";
/** 44 digits. */
codigoBarras: string;
/** 47 digits. */
linhaDigitavel: string;
/** 3-digit bank code in the clearing house, e.g. `"341"`. */
banco: string;
/** 1 digit. `"9"` is BRL; nothing else is in use. */
moeda: string;
/** `"Real"` for `"9"`, `null` for anything else. */
moedaLabel: string | null;
/** The general check digit, position 5 of the barcode. */
dv: string;
/** Raw 4-digit field. `0` means the boleto carries no due date. */
fatorVencimento: number;
/** Due date, or `null` when the fator is `0`. */
vencimento: Date | null;
/** Which epoch {@link vencimento} was resolved under. `null` when there is none. */
vencimentoEpoch: Exclude | null;
/** Reais. `0` when the issuer left the amount for the payer to fill in. */
valor: number;
/** 25 digits the issuing bank defines. Not interpretable without its manual. */
campoLivre: string;
}
/**
* Resolve a fator de vencimento to a calendar date.
*
* The field is four digits of days since a base date, and it has had **two** base
* dates: 1997-10-07 until the counter saturated at 9999 on 2025-02-21, then
* 2022-05-29 from 2025-02-22, when FEBRABAN restarted it at 1000.
*
* !!! danger "The two epochs are genuinely ambiguous"
* Every fator from 1000 to 9999 has a reading under each base — 1997-10-07
* gives a date in `2000-07-03 … 2025-02-21`, 2022-05-29 gives one in
* `2025-02-22 … 2049-10-14`. Nothing in the barcode says which. `"auto"`
* picks whichever lands nearer `reference`, which is right for the case that
* matters (a slip being paid now) and wrong for an archive sweep. Pass
* `"legacy"` or `"current"` when you know.
*
* @param fator - The raw 4-digit field as a number. `0` means "no due date".
* @param options - Epoch selection. Default `"auto"` against `new Date()`.
* @returns Local midnight of the due date, or `null` when `fator` is `0`.
*
* @example
* boletoDueDate(1000, { epoch: "legacy" }); // 2000-07-03
* boletoDueDate(1000, { epoch: "current" }); // 2025-02-22
*/
export declare function boletoDueDate(fator: number, options?: BoletoOptions): {
date: Date;
epoch: Exclude;
} | null;
/** Which base date the fator de vencimento counts from. See {@link boletoDueDate}. */
export declare type BoletoEpoch = "auto" | "legacy" | "current";
/**
* @tempest-limits file-lines — the FEBRABAN spec in one file: the 47-digit linha
* digitável, the 44-digit barcode, the two layouts (bank slips and arrecadação),
* modulo-10 and modulo-11 check digits, the base date the due date counts from, and
* the value scaling. Every piece cross-checks another — the conversion between the
* two forms is what proves the check digits — so splitting it hides the one property
* the file exists to guarantee.
*/
/**
* A boleto string could not be read, or failed a check digit.
*
* Its own class so a scanner screen can tell "this is not a boleto" apart from a
* bug, and so the message can be shown to the operator as-is.
*/
export declare class BoletoError extends Error {
constructor(message: string);
}
/**
* The two incompatible layouts that share the 44-digit barcode.
*
* `"banco"` is the cobrança boleto every bank issues; `"arrecadacao"` is the
* concessionária/tributo slip, which starts with `8` and lays out its 44 digits
* completely differently — same length, different meaning for every field.
*/
export declare type BoletoKind = "banco" | "arrecadacao";
/**
* Which layout a string is in, without throwing.
*
* @param value - A barcode or typed line, masked or not.
* @returns The layout, or `null` when the length is not 44, 47 or 48.
*/
export declare function boletoKind(value: string): BoletoKind | null;
/** Options shared by every parser here. */
export declare interface BoletoOptions {
/** Fator de vencimento epoch. Default `"auto"`. */
epoch?: BoletoEpoch;
/** Date `"auto"` measures proximity against. Default `new Date()`. */
reference?: Date;
}
/**
* An administrative region of the Federal District.
*
* The DF has exactly one municipality — Brasília — and 35 administrative
* regions inside it. Nobody in the DF writes "Brasília" in an address field,
* so the regions are listed and resolvable; they are not municipalities, and
* `municipalityId` is what they geocode through.
*/
export declare interface BrazilAdministrativeRegion {
/** IBGE subdistrict code, e.g. `"53001080515"` for Ceilândia. */
id: string;
/** IBGE name, e.g. `"Sudoeste/Octogonal"`. */
name: string;
/** The municipality it belongs to — Brasília (`"5300108"`) for all 35. */
municipalityId: string;
}
/**
* Clickable choropleth map of Brazil's 27 federative units. Renders the bundled
* simplified UF GeoJSON as SVG paths — **no external tiles or paid API**. Click
* a state to fire `onSelect(uf)`; pass `selected` to highlight and `values` to
* tint states by a metric.
*
* The GeoJSON (~36 KB gzip) is loaded lazily, so importing this component does
* not pull the geometry until it actually mounts.
*
* @example
* const [uf, setUf] = useState(null);
*
*
* @example
* // Choropleth by a metric per state
*
*/
export declare function BrazilMap({ selected, onSelect, values, minColor, maxColor, colorScale, colorByRegion, height, padding, showLabels, label, loadingContent, showTooltip, renderTooltip, markers, onMarkerClick, zoomable, className, style, ...rest }: BrazilMapProps): JSX.Element;
export declare interface BrazilMapProps extends Omit, "onSelect"> {
/** Currently selected UF(s) — highlighted. Accepts one or many. */
selected?: UF | readonly UF[] | null;
/** Fired when a state is clicked. */
onSelect?: (uf: UF) => void;
/**
* Optional choropleth values per UF. When set, each state is tinted between
* `minColor` and `maxColor` by its value (linear). States without a value
* use the base surface color.
*/
values?: Partial>;
/** Choropleth low-end color (2-color linear ramp). Default: a light primary tint. */
minColor?: string;
/** Choropleth high-end color (2-color linear ramp). Default: the primary token. */
maxColor?: string;
/**
* Custom value→color scale (e.g. from `sequentialScale`/`quantizeScale`).
* Takes precedence over `minColor`/`maxColor`. Pair with a ``.
*/
colorScale?: ColorScale;
/**
* Tint each state by its macro-region (categorical). Overrides
* `values`/`colorScale`. Pair with ``.
*/
colorByRegion?: boolean;
/** Viewport height in pixels. Default: `440`. */
height?: number;
/** Inner padding in pixels. Default: `12`. */
padding?: number;
/** Render the UF acronym at each state centroid. Default: `true`. */
showLabels?: boolean;
/** Accessible label for the map region. Default: `"Mapa do Brasil por estado"`. */
label?: string;
/** Custom content when the geometry is still loading. */
loadingContent?: ReactNode;
/** Show a floating tooltip (name + region + city count + value) on hover. Default: `true`. */
showTooltip?: boolean;
/** Override the default tooltip content. */
renderTooltip?: (data: BrazilMapTooltipData) => ReactNode;
/** Point markers to overlay on the map (e.g. capitals, stores). */
markers?: readonly GeoMarker[];
/** Fired when a marker is clicked. */
onMarkerClick?: (marker: GeoMarker, index: number) => void;
/** Enable wheel-zoom + drag-pan (double-click resets). Default: `false`. */
zoomable?: boolean;
}
/** Data passed to a {@link BrazilMapProps.renderTooltip} callback. */
export declare interface BrazilMapTooltipData {
uf: UF;
name: string;
/** Choropleth value for this UF, if `values` was provided. */
value?: number;
}
/** A municipality, identified by the code that survives its renames. */
export declare interface BrazilMunicipality {
/** 7-digit IBGE code, e.g. `"3550308"`. Stable across a rename. */
id: string;
/** Current IBGE name, e.g. `"São Paulo"`. */
name: string;
}
/** A federative unit with its display name and city list. */
export declare interface BrazilState {
/** Two-letter acronym, e.g. `"SP"`. */
uf: UF;
/** Full name, e.g. `"São Paulo"`. */
name: string;
/** Macro-region the state belongs to. */
region: BrRegion;
/** Municipality names within the state, alphabetically. */
cities: string[];
/** The same municipalities carrying their IBGE codes, same order. */
municipalities: readonly BrazilMunicipality[];
/** Administrative regions — 35 for `"DF"`, empty everywhere else. */
administrativeRegions: readonly BrazilAdministrativeRegion[];
}
export declare function BrazilStateCitySelect({ defaultUf, defaultCity, onChange, stateLabel, cityLabel, statePlaceholder, cityPlaceholder, disabled, layout, }: BrazilStateCitySelectProps): ReactElement;
/** Current selection emitted by {@link BrazilStateCitySelect}. */
export declare interface BrazilStateCitySelection {
/** Selected federative unit, or `null` when none. */
uf: UF | null;
/** Selected city, or `null` when none. */
city: string | null;
/**
* IBGE code of the selected municipality, or `null` when none is selected.
*
* This is the value to store. It survives the renames `city` does not, and
* it is what `geocodeMunicipality` and every other dataset here join on. A
* DF administrative region carries Brasília's code, because that is the
* municipality it is part of.
*/
municipalityId: string | null;
}
export declare interface BrazilStateCitySelectProps {
/** Pre-selected UF (uncontrolled initial value). */
defaultUf?: UF;
/** Pre-selected city (uncontrolled initial value). */
defaultCity?: string;
/** Fired whenever the state or city changes. */
onChange?: (selection: BrazilStateCitySelection) => void;
/** Label for the state select. Default: `"Estado"`. */
stateLabel?: string;
/** Label for the city select. Default: `"Cidade"`. */
cityLabel?: string;
/** Placeholder for the state select. Default: `"Selecione o estado"`. */
statePlaceholder?: string;
/** Placeholder for the city select. Default: `"Selecione a cidade"`. */
cityPlaceholder?: string;
/** Disable both selects. */
disabled?: boolean;
/** Layout of the two selects. Default: `"row"`. */
layout?: "row" | "column";
}
/**
* Clickable submap of a single Brazilian state showing **all its
* municipalities** as SVG paths — no external tiles or paid API. The state's
* geometry (~40-70 KB gzip) is loaded lazily per UF, so switching states fetches
* only what is shown.
*
* @example
* const [city, setCity] = useState(null);
* setCity(m.name)} />
*
* @example
* // Choropleth of a metric by municipality name
*
*/
export declare function BrazilStateMap({ uf, selected, onSelect, values, minColor, maxColor, colorScale, height, padding, showLabels, label, loadingContent, showTooltip, renderTooltip, markers, onMarkerClick, zoomable, className, style, ...rest }: BrazilStateMapProps): JSX.Element;
export declare interface BrazilStateMapProps extends Omit, "onSelect"> {
/** Federative unit to draw (required). */
uf: UF;
/** Selected municipality — matched by IBGE `id` or by `name`. Accepts many. */
selected?: string | readonly string[] | null;
/** Fired when a municipality is clicked. */
onSelect?: (municipality: Municipality) => void;
/**
* Choropleth values keyed by municipality `id` **or** `name`. When set, each
* municipality is tinted between `minColor` and `maxColor`.
*/
values?: Record;
/** Choropleth low-end color (2-color linear ramp). Default: a light primary tint. */
minColor?: string;
/** Choropleth high-end color (2-color linear ramp). Default: the primary token. */
maxColor?: string;
/**
* Custom value→color scale (from `sequentialScale`/`quantizeScale`). Takes
* precedence over `minColor`/`maxColor`. Pair with a ``.
*/
colorScale?: ColorScale;
/** Viewport height in pixels. Default: `440`. */
height?: number;
/** Inner padding in pixels. Default: `12`. */
padding?: number;
/**
* Render each municipality name at its centroid. Off by default — a state
* can have hundreds of municipalities and labels overlap badly.
*/
showLabels?: boolean;
/** Accessible label. Default: derived from the state name. */
label?: string;
/** Content while the state geometry is loading. */
loadingContent?: ReactNode;
/** Show a floating tooltip (name + IBGE code + value) on hover. Default: `true`. */
showTooltip?: boolean;
/** Override the default tooltip content. */
renderTooltip?: (data: BrazilStateMapTooltipData) => ReactNode;
/** Point markers to overlay on the state (e.g. addresses, POIs). */
markers?: readonly GeoMarker[];
/** Fired when a marker is clicked. */
onMarkerClick?: (marker: GeoMarker, index: number) => void;
/** Enable wheel-zoom + drag-pan (double-click resets). Default: `false`. */
zoomable?: boolean;
}
/** Data passed to a {@link BrazilStateMapProps.renderTooltip} callback. */
export declare interface BrazilStateMapTooltipData extends Municipality {
/** Choropleth value for this municipality, if `values` was provided. */
value?: number;
}
/** The five Brazilian macro-regions (IBGE). */
export declare type BrRegion = "Norte" | "Nordeste" | "Centro-Oeste" | "Sudeste" | "Sul";
/** One federative unit feature. */
export declare interface BrUfFeature {
type: "Feature";
properties: {
uf: UF;
name: string;
region: BrRegion;
/** Representative point `[longitude, latitude]` (area-weighted centroid). */
centroid: [number, number];
};
geometry: BrUfGeometry;
}
/** The bundled, simplified GeoJSON of all 27 UF boundaries. */
export declare interface BrUfFeatureCollection {
type: "FeatureCollection";
features: BrUfFeature[];
}
/** GeoJSON geometry for a federative unit — always a (multi)polygon. */
export declare interface BrUfGeometry {
type: "Polygon" | "MultiPolygon";
/** `Polygon` → `Ring[]`; `MultiPolygon` → `Ring[][]`. */
coordinates: Ring[] | Ring[][];
}
/** Options shared by the calendar helpers. */
export declare interface BusinessDayOptions {
/**
* Which kinds count as non-working. Default `["national", "banking"]`, i.e.
* the Bacen calendar — the right default for anything money moves through.
* Pass `["national"]` for a labour-law calendar.
*/
kinds?: readonly HolidayKind[];
/**
* Extra non-working days, as `YYYY-MM-DD` or `Date`. This is where state and
* municipal holidays go: they are **not** in the built-in table and never will
* be — there are 5 570 municipalities, each free to declare its own.
*/
extra?: readonly DateInput[];
/**
* Days of the week that are not worked, `0` = Sunday. Default `[0, 6]`.
*/
weekend?: readonly number[];
}
/** A fiscal access key taken apart. */
export declare interface ChaveNFe {
/** Federative unit of the issuer, resolved from {@link cUF}. */
uf: UF;
/** The raw 2-digit IBGE code, positions 1-2. */
cUF: string;
/** Positions 3-6, `AAMM` — the two-digit year and the month of issue. */
anoMes: string;
/** Four-digit year derived from {@link anoMes}. */
ano: number;
/** Month of issue, 1-12. */
mes: number;
/** Positions 7-20, the issuer's CNPJ. */
cnpj: string;
/** Positions 21-22, `mod`. `"55"` is an NF-e, `"65"` an NFC-e. */
modelo: string;
/** Human label for {@link modelo}, or `null` for a model outside the table. */
modeloLabel: string | null;
/** Positions 23-25. */
serie: string;
/** Positions 26-34, `nNF`. */
numero: string;
/** Position 35, `tpEmis`. */
tipoEmissao: string;
/** Human label for {@link tipoEmissao}, or `null` for a value outside the table. */
tipoEmissaoLabel: string | null;
/** Positions 36-43, `cNF` — the issuer's random code. */
codigoNumerico: string;
/** Position 44, `cDV`. */
dv: string;
}
/**
* The check digit a 43-digit key body requires.
*
* Módulo 11: each digit is multiplied by weights cycling `2…9` from right to
* left, the products are summed, and the digit is `11 - (sum mod 11)` — except
* that a remainder of `0` or `1` yields `0`, since `11` and `10` do not fit one
* position.
*
* Note this is the **fiscal** flavour of módulo 11. The cobrança boleto resolves
* those same remainders to `1`; see `mod11DacCobranca` in `./boleto`.
*
* @param body - The first 43 digits of the key.
* @returns The check digit, 0-9.
* @throws {ChaveNFeError} When `body` is not exactly 43 digits.
*/
export declare function chaveNFeCheckDigit(body: string): number;
/**
* A 44-digit fiscal access key could not be read.
*
* Its own class so a scanner screen can tell a bad key apart from a bug and show
* the message to the operator unchanged.
*/
export declare class ChaveNFeError extends Error {
constructor(message: string);
}
/** A `{ value, label }` option, handy for `