/**
 * Represents a single IPv6 address, providing methods for validation,
 * classification, and manipulation.
 *
 * @example
 * const ip = new IPv6('2001:db8::1');
 * console.log(ip.address); // "2001:db8::1"
 * console.log(ip.isLinkLocal()); // false
 */
declare class IPv6 {
    #private;
    /**
     * @param address An IPv6 address string (e.g., "2001:db8::1").
     * @throws {InvalidIPAddressError} If the address is not a valid IPv6 address.
     */
    constructor(address: string);
    /**
     * Creates an IPv6 instance from a BigInt.
     * @param value The BigInt representation of an IPv6 address.
     * @returns A new IPv6 instance.
     *
     * @example
     * const ip = IPv6.fromBigInt(1n);
     * console.log(ip.address); // "::1"
     */
    static fromBigInt(value: bigint): IPv6;
    /**
     * Creates an IPv6 instance from an array of 16 bytes.
     * @param bytes An array of 16 numbers (0-255).
     * @returns A new IPv6 instance.
     * @throws {InvalidIPAddressError} If the byte array is not 16 bytes long.
     *
     * @example
     * const bytes = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1];
     * const ip = IPv6.fromBytes(bytes);
     * console.log(ip.address); // "::1"
     */
    static fromBytes(bytes: number[]): IPv6;
    /**
     * Checks if a string is a valid IPv6 address.
     * @param address The string to validate.
     * @returns True if the string is a valid IPv6 address.
     *
     * @example
     * IPv6.isValid('2001:db8::1'); // true
     * IPv6.isValid('2001:db8::g'); // false
     */
    static isValid(address: string): boolean;
    /**
     * The IP version number.
     * @returns {6}
     */
    get version(): 6;
    /**
     * The compressed, canonical IPv6 address string.
     * @returns {string}
     */
    get address(): string;
    /**
     * The fully expanded IPv6 address string.
     * @returns {string}
     */
    get expandedAddress(): string;
    /**
     * Converts the IP address to its BigInt representation.
     * @returns {bigint}
     */
    toBigInt(): bigint;
    /**
     * Converts the IP address to an array of 16 bytes.
     * @returns {number[]}
     */
    toBytes(): number[];
    /**
     * Returns the string representation of the IP address.
     * @returns {string}
     */
    toString(): string;
    /**
     * Returns the string representation for JSON serialization.
     * @returns {string}
     */
    toJSON(): string;
    /**
     * Converts an IPv4-mapped address to an IPv4 instance, otherwise returns null.
     * @returns {IPv4 | null}
     */
    toIPv4(): IPv4 | null;
    /**
     * Returns the reverse DNS (ARPA) name for the IP address.
     * @returns {string}
     *
     * @example
     * const ip = new IPv6('2001:db8::1');
     * console.log(ip.toArpa()); // "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.8.b.d.0.1.0.0.2.ip6.arpa"
     */
    toArpa(): string;
    /**
     * Checks if the address is the unspecified address (::).
     * @returns {boolean}
     */
    isUnspecified(): boolean;
    /**
     * Checks if the address is the loopback address (::1).
     * @returns {boolean}
     */
    isLoopback(): boolean;
    /**
     * Checks if the address is a multicast address (ff00::/8).
     * @returns {boolean}
     */
    isMulticast(): boolean;
    /**
     * Checks if the address is a link-local address (fe80::/10).
     * @returns {boolean}
     */
    isLinkLocal(): boolean;
    /**
     * Checks if the address is a unique local address (fc00::/7).
     * @returns {boolean}
     */
    isUniqueLocal(): boolean;
    /**
     * Checks if the address is an IPv4-mapped address (::ffff:0:0/96).
     * @returns {boolean}
     */
    isIPv4Mapped(): boolean;
    /**
     * Checks if the address is reserved by IANA. This includes ranges for
     * documentation, benchmarking, and other special purposes.
     * @returns {boolean}
     */
    isReserved(): boolean;
    /**
     * Checks if the address is a global unicast address.
     * @returns {boolean}
     */
    isGlobalUnicast(): boolean;
    /**
     * Checks for exact equality between this and another IPv6 address.
     * @param other The other IPv6 address to compare with.
     * @returns {boolean}
     */
    equals(other: IPv6 | string): boolean;
    /**
     * Compares this IP address with another.
     * @param other The other IPv6 address to compare with.
     * @returns `-1` if this address is less than the other, `0` if they are equal, `1` if it is greater.
     */
    compare(other: IPv6 | string): -1 | 0 | 1;
    /**
     * Performs a bitwise AND operation with another IPv6 address.
     * @param other The other IPv6 address.
     * @returns A new IPv6 instance with the result of the AND operation.
     */
    and(other: IPv6 | string): IPv6;
    /**
     * Performs a bitwise OR operation with another IPv6 address.
     * @param other The other IPv6 address.
     * @returns A new IPv6 instance with the result of the OR operation.
     */
    or(other: IPv6 | string): IPv6;
    /**
     * Performs a bitwise NOT operation on the address.
     * @returns A new IPv6 instance with the result of the NOT operation.
     */
    not(): IPv6;
    /**
     * Returns the next IP address.
     * @param [count=1n] The number of addresses to increment by.
     * @returns {IPv6}
     */
    next(count?: bigint): IPv6;
    /**
     * Returns the previous IP address.
     * @param [count=1n] The number of addresses to decrement by.
     * @returns {IPv6}
     */
    previous(count?: bigint): IPv6;
}

/**
 * Represents a single IPv4 address, providing methods for validation,
 * classification, and manipulation.
 *
 * @example
 * const ip = new IPv4('192.168.1.1');
 * console.log(ip.address); // "192.168.1.1"
 * console.log(ip.isPrivate()); // true
 */
declare class IPv4 {
    #private;
    /**
     * @param address An IPv4 address string (e.g., "192.168.1.1").
     * @throws {InvalidIPAddressError} If the address is not a valid IPv4 address.
     */
    constructor(address: string);
    /**
     * Creates an IPv4 instance from a BigInt.
     * @param value The BigInt representation of an IPv4 address.
     * @returns A new IPv4 instance.
     *
     * @example
     * const ip = IPv4.fromBigInt(3232235777n);
     * console.log(ip.address); // "192.168.1.1"
     */
    static fromBigInt(value: bigint): IPv4;
    /**
     * Creates an IPv4 instance from an array of 4 bytes.
     * @param bytes An array of 4 numbers (0-255).
     * @returns A new IPv4 instance.
     *
     * @example
     * const ip = IPv4.fromBytes([192, 168, 1, 1]);
     * console.log(ip.address); // "192.168.1.1"
     */
    static fromBytes(bytes: [number, number, number, number]): IPv4;
    /**
     * Checks if a string is a valid IPv4 address.
     * @param address The string to validate.
     * @returns True if the string is a valid IPv4 address.
     *
     * @example
     * IPv4.isValid('1.2.3.4'); // true
     * IPv4.isValid('1.2.3.256'); // false
     */
    static isValid(address: string): boolean;
    /**
     * The IP version number.
     * @returns {4}
     */
    get version(): 4;
    /**
     * The IP address as a string.
     * @returns {string}
     */
    get address(): string;
    /**
     * Converts the IP address to its BigInt representation.
     * @returns {bigint}
     */
    toBigInt(): bigint;
    /**
     * Converts the IP address to an array of 4 bytes.
     * @returns {[number, number, number, number]}
     */
    toBytes(): [number, number, number, number];
    /**
     * Returns the string representation of the IP address.
     * @returns {string}
     */
    toString(): string;
    /**
     * Returns the string representation for JSON serialization.
     * @returns {string}
     */
    toJSON(): string;
    /**
     * Converts the IPv4 address to an IPv4-mapped IPv6 address.
     * @returns {IPv6} An IPv6 instance representing the mapped address.
     *
     * @example
     * const ipv4 = new IPv4('192.0.2.1');
     * const ipv6 = ipv4.toIPv4Mapped();
     * console.log(ipv6.address); // "::ffff:192.0.2.1"
     */
    toIPv4Mapped(): IPv6;
    /**
     * Returns the reverse DNS (ARPA) name for the IP address.
     * @returns {string}
     *
     * @example
     * const ip = new IPv4('192.168.1.1');
     * console.log(ip.toArpa()); // "1.1.168.192.in-addr.arpa"
     */
    toArpa(): string;
    /**
     * Checks if the address is in a private range (RFC 1918).
     * @returns {boolean}
     */
    isPrivate(): boolean;
    /**
     * Checks if the address is a loopback address (127.0.0.0/8).
     * @returns {boolean}
     */
    isLoopback(): boolean;
    /**
     * Checks if the address is a multicast address (224.0.0.0/4).
     * @returns {boolean}
     */
    isMulticast(): boolean;
    /**
     * Checks if the address is a link-local address (169.254.0.0/16).
     * @returns {boolean}
     */
    isLinkLocal(): boolean;
    /**
     * Checks if the address is the unspecified address (0.0.0.0).
     * @returns {boolean}
     */
    isUnspecified(): boolean;
    /**
     * Checks if the address is the limited broadcast address (255.255.255.255).
     * Note: This does not check for subnet-directed broadcasts.
     * @returns {boolean}
     */
    isBroadcast(): boolean;
    /**
     * Checks if the address is reserved by IANA. This includes ranges for
     * private use, loopback, multicast, and other special purposes.
     * @returns {boolean}
     */
    isReserved(): boolean;
    /**
     * Checks if the address is a global unicast address (i.e., a public IP).
     * @returns {boolean}
     */
    isGlobalUnicast(): boolean;
    /**
     * Checks for exact equality between this and another IPv4 address.
     * @param other The other IPv4 address to compare with.
     * @returns {boolean}
     */
    equals(other: IPv4 | string): boolean;
    /**
     * Compares this IP address with another.
     * @param other The other IPv4 address to compare with.
     * @returns `-1` if this address is less than the other, `0` if they are equal, `1` if it is greater.
     */
    compare(other: IPv4 | string): -1 | 0 | 1;
    /**
     * Performs a bitwise AND operation with another IPv4 address.
     * @param other The other IPv4 address.
     * @returns A new IPv4 instance with the result of the AND operation.
     */
    and(other: IPv4 | string): IPv4;
    /**
     * Performs a bitwise OR operation with another IPv4 address.
     * @param other The other IPv4 address.
     * @returns A new IPv4 instance with the result of the OR operation.
     */
    or(other: IPv4 | string): IPv4;
    /**
     * Performs a bitwise NOT operation on the address.
     * @returns A new IPv4 instance with the result of the NOT operation.
     */
    not(): IPv4;
    /**
     * Returns the next IP address.
     * @param [count=1n] The number of addresses to increment by.
     * @returns {IPv4}
     */
    next(count?: bigint): IPv4;
    /**
     * Returns the previous IP address.
     * @param [count=1n] The number of addresses to decrement by.
     * @returns {IPv4}
     */
    previous(count?: bigint): IPv4;
}

/**
 * Represents the version of an IP address.
 * - `4` for IPv4
 * - `6` for IPv6
 */
type IPVersion = 4 | 6;
/**
 * Represents an IP address, which can be either an IPv4 or an IPv6 address.
 */
type IP = IPv4 | IPv6;

/**
 * Represents a CIDR block, which includes an IP address and a prefix length.
 *
 * @example
 * const cidr = new CIDR('192.168.1.0/24');
 * console.log(cidr.network.address); // "192.168.1.0"
 * console.log(cidr.broadcast.address); // "192.168.1.255"
 * console.log(cidr.contains('192.168.1.50')); // true
 */
declare class CIDR<T extends IP> {
    #private;
    /**
     * @param cidr A CIDR string (e.g., "192.168.1.0/24" or "2001:db8::/32").
     * @throws {InvalidIPAddressError} If the CIDR string is invalid.
     */
    constructor(cidr: string);
    /**
     * The IP address portion of the CIDR.
     * @returns {T}
     */
    get address(): T;
    /**
     * The prefix length of the CIDR.
     * @returns {number}
     */
    get prefix(): number;
    /**
     * The IP version.
     * @returns {IPVersion}
     */
    get version(): IPVersion;
    /**
     * The netmask for the CIDR block.
     * @returns {T}
     */
    get netmask(): T;
    /**
     * The network address of the CIDR block.
     * @returns {T}
     */
    get network(): T;
    /**
     * The broadcast address for the CIDR block.
     * @returns {T}
     */
    get broadcast(): T;
    /**
     * The first usable IP address in the CIDR block.
     * For IPv4 /31 and /32, this is the network address.
     * For IPv6, this is the network address (Subnet-Router anycast).
     * @returns {T}
     */
    get first(): T;
    /**
     * The last usable IP address in the CIDR block.
     * For IPv4 /31 and /32, this is the broadcast address.
     * For IPv6, this is the highest address in the range.
     * @returns {T}
     */
    get last(): T;
    /**
     * Checks if a given IP address is contained within this CIDR block.
     * @param ip The IP address to check.
     * @returns {boolean}
     */
    contains(ip: T | string): boolean;
    /**
     * Returns the string representation of the CIDR.
     * @returns {string}
     */
    toString(): string;
    /**
     * Returns the string representation for JSON serialization.
     * @returns {string}
     */
    toJSON(): string;
}

/**
 * Quickly determines the IP version from a string.
 * @param probablyIp The IP address string.
 * @returns The IP version (4 or 6).
 * @throws {InvalidIPAddressError} If the string is not recognizable as an IP address.
 */
declare function fastIpVersion(probablyIp: string): IPVersion;
/**
 * Converts an IP address string to its BigInt representation.
 *
 * @param ip The IP address string to convert.
 * @param version The IP version (4 or 6). If not provided, it will be detected automatically.
 * @returns The BigInt representation of the IP address.
 * @throws {InvalidIPAddressError} If the IP address is invalid.
 */
declare function ipToBigInt(ip: string, version?: IPVersion): bigint;
/**
 * Converts a BigInt to its IP address string representation.
 *
 * @param number The BigInt to convert.
 * @param version The IP version (4 or 6).
 * @param compress Whether to compress the IPv6 address (e.g., remove leading zeros and use `::`).
 * @returns The IP address string.
 */
declare function bigIntToIp(number: bigint, version: IPVersion, compress?: boolean): string;

declare class InvalidIPAddressError extends Error {
    constructor(message: string);
}

/**
 * A factory function that parses an IP address string and returns
 * an instance of the appropriate class (IPv4 or IPv6).
 *
 * @param address The IP address string.
 * @returns An instance of IPv4 or IPv6.
 * @throws {InvalidIPAddressError} if the address is not a valid v4 or v6 address.
 */
declare function parseIP(address: string): IP;
/**
 * A factory function that parses a CIDR string and returns
 * an instance of the CIDR class.
 *
 * @param cidr The CIDR string.
 * @returns An instance of CIDR.
 * @throws {InvalidIPAddressError} if the cidr is not a valid v4 or v6 cidr.
 */
declare function parseCIDR(cidr: string): CIDR<IP>;
/**
 * Safely checks if a value is a string representing a valid IPv4 or IPv6 address.
 *
 * @param maybeIP The value to check.
 * @returns {boolean} True if the value is a valid IP address string.
 *
 * @example
 * isValidIP('192.168.1.1');      // true
 * isValidIP('2001:db8::1');      // true
 * isValidIP('not an ip');        // false
 * isValidIP(null);               // false
 */
declare function isValidIP(maybeIP: unknown): boolean;

export { CIDR, type IP, type IPVersion, IPv4, IPv6, InvalidIPAddressError, bigIntToIp, fastIpVersion, ipToBigInt, isValidIP, parseCIDR, parseIP };
