import { EventEmitter } from 'events';
import { HybridID } from './HybridID';
export interface HybridIDGeneratorOptions {
    sequenceBits?: number;
    randomBits?: number;
    entropyBits?: number;
    useCrypto?: boolean;
    maskTimestamp?: boolean;
    enableEventEmission?: boolean;
    machineIdBits?: number;
    machineId?: number | string;
    machineIdStrategy?: 'env' | 'network' | 'random';
    /** Number of bits for timestamp (default 42 = ms since Unix epoch, ~139 years). */
    timestampBits?: number;
    /** If true, use wall-clock time (Date.now()) for chronological order and expiry; if false, use process.hrtime.bigint() (monotonic, process-specific). Default true. */
    useWallClock?: boolean;
}
export interface HybridIDInfo {
    timestamp: bigint;
    machineId: number;
    randomBits: number;
    sequence: number;
    masked: boolean;
}
export declare class HybridIDGenerator extends EventEmitter {
    /**
     * The machine ID used for generating unique Hybrid IDs.
     * @private
     * @type {number}
     */
    private machineId;
    /**
     * The current sequence number for ID generation.
     * This resets to 0 when the timestamp changes.
     * @private
     * @type {number}
     * @default 0
     */
    private sequence;
    /**
     * The last generated timestamp in BigInt format.
     * This is used to determine if a new timestamp is needed
     * during ID generation.
     * @private
     * @type {bigint}
     * @default -1n
     */
    private lastTimestamp;
    /**
     * The number of bits allocated for the sequence component of the Hybrid ID.
     * @private
     * @type {number}
     */
    private sequenceBits;
    /**
     * The number of bits allocated for random bits in the Hybrid ID.
     * @private
     * @type {number}
     */
    private randomBits;
    /**
     * The number of bits allocated for entropy in the Hybrid ID.
     * @private
     * @type {number}
     */
    private entropyBits;
    /**
     * Flag indicating whether to use cryptographic functions for random number generation.
     * @private
     * @type {boolean}
     */
    private useCrypto;
    /**
     * Flag indicating whether the timestamp should be masked during ID generation.
     * @private
     * @type {boolean}
     */
    private maskTimestamp;
    /**
     * Flag indicating whether event emission is enabled for ID generation events.
     * @private
     * @type {boolean}
     */
    private enableEventEmission;
    /**
     * The maximum value for the sequence component based on the number of bits allocated.
     * @private
     * @type {number}
     */
    private maxSequence;
    /**
     * The maximum value for the machine ID based on the number of bits allocated.
     * @private
     * @type {number}
     */
    private maxMachineId;
    /**
     * The number of bits allocated for the machine ID component of the Hybrid ID.
     * @private
     * @type {number}
     */
    private machineIdBits;
    /**
     * The strategy used for generating the machine ID.
     * @private
     * @type {MachineIDStrategy}
     */
    private machineIdStrategy;
    /**
     * The number of bits allocated for the timestamp component (default 42 = ms since Unix epoch).
     * @private
     */
    private timestampBits;
    /**
     * If true, use wall-clock time (Date.now()) for chronological order and expiry.
     * @private
     */
    private useWallClock;
    /**
     * Maximum timestamp value (2^timestampBits - 1) for capping.
     * @private
     */
    private maxTimestamp;
    /**
     * Constructs a new Hybrid ID generator with the specified options.
     *
     * The constructor initializes various properties related to ID generation,
     * including bit allocation for the sequence, random bits, and entropy,
     * as well as the machine ID and options for masking and event emission.
     *
     * @param {HybridIDGeneratorOptions} [options={}] - The configuration options for the ID generator.
     * @param {number} [options.sequenceBits=12] - The number of bits for the sequence component (default: 12).
     * @param {number} [options.randomBits=10] - The number of bits for the random component (default: 10).
     * @param {number} [options.entropyBits=5] - The number of bits for the entropy component (default: 5).
     * @param {boolean} [options.useCrypto=false] - Whether to use cryptographic functions for random generation (default: false).
     * @param {boolean} [options.maskTimestamp=false] - Whether to mask the timestamp (default: false).
     * @param {boolean} [options.enableEventEmission=false] - Whether to enable event emission for ID generation (default: false).
     * @param {number} [options.machineIdBits=12] - The number of bits for the machine ID component (default: 12).
     * @param {MachineIDStrategy} [options.machineIdStrategy] - The strategy used for generating the machine ID.
     * @param {number} [options.machineId] - The initial machine ID to use (must be validated).
     * @param {number} [options.timestampBits=42] - The number of bits for the timestamp (default: 42, ms since Unix epoch).
     * @param {boolean} [options.useWallClock=true] - Use wall-clock time (Date.now()) for ordering and expiry (default: true).
     */
    constructor(options?: HybridIDGeneratorOptions);
    /**
     * Gets the current options of the Hybrid ID generator.
     *
     * This getter returns an object containing the configuration settings
     * and state variables of the Hybrid ID generator, including the number
     * of bits used for different components, the current sequence number,
     * last generated timestamp, maximum sequence, and maximum machine ID.
     *
     * @returns {HybridIDGeneratorOptions & {
    *   sequence: number;
    *   lastTimestamp: bigint;
    *   maxSequence: number;
    *   maxMachineId: number;
    * }} The current options and state of the Hybrid ID generator.
    */
    get options(): HybridIDGeneratorOptions & {
        sequence: number;
        lastTimestamp: bigint;
        maxSequence: number;
        maxMachineId: number;
        timestampBits: number;
        useWallClock: boolean;
        maxTimestamp: bigint;
    };
    /**
     * Generates the next Hybrid ID.
     *
     * This method constructs a new Hybrid ID based on the current timestamp,
     * machine ID, random bits, and sequence number. It handles timestamp
     * obfuscation if enabled, ensures unique ID generation by incrementing
     * the sequence number when necessary, and can emit an event upon ID
     * generation. The final Hybrid ID is created by combining these components.
     *
     * @returns {HybridID} The newly generated Hybrid ID.
     */
    nextId(): HybridID;
    /**
     * Generates a batch of Hybrid IDs.
     *
     * This method produces a specified number of Hybrid IDs in one call.
     * It ensures uniqueness by handling sequence numbers and timestamps.
     * The method optimizes ID generation by preallocating an array for the
     * result and managing sequence overflow correctly.
     *
     * @param {number} batchSize - The number of Hybrid IDs to generate.
     * Must be greater than 0.
     * @throws {Error} If `batchSize` is less than or equal to 0.
     * @returns {HybridID[]} An array of generated Hybrid IDs.
     */
    nextIds(batchSize: number): HybridID[];
    /**
     * Retrieves the current timestamp, capped to timestampBits.
     * Default: wall-clock time (Date.now() in ms) for real-world chronological order and expiry.
     * Optional: process.hrtime.bigint() (monotonic, process-specific) when useWallClock is false.
     *
     * @param useHighResTime - Override: if true use process.hrtime.bigint() (when available), else Date.now() ms. Default follows options.useWallClock.
     * @returns {bigint} The current timestamp (ms if wall-clock, capped to timestampBits; else hrtime ns capped).
     */
    getTimestamp(useHighResTime?: boolean): bigint;
    isIdExpired(id: bigint | HybridID, expiryDurationInMillis: number): boolean;
    toBase62(id: bigint | HybridID): string;
    fromBase62(encodedId: string | HybridID): bigint;
    /**
     * Checks whether the given ID is a valid Hybrid ID.
     *
     * This method determines if the input ID is an instance of `HybridID`,
     * a valid Base62 encoded string, or a bigint that conforms to the
     * Hybrid ID structure. It performs various checks on the ID's
     * components, including the timestamp, machine ID, random bits,
     * and sequence number.
     *
     * @param {string | bigint | HybridID} id - The ID to validate.
     * It can be a string (Base62 encoded), a bigint, or an instance of `HybridID`.
     *
     * @returns {id is HybridID} Returns true if the ID is a valid Hybrid ID,
     * false otherwise.
     */
    isHybridID(id: string | bigint | HybridID): id is HybridID;
    /**
     * Validates the given ID and checks if it is a valid Hybrid ID.
     *
     * This method uses the `isHybridID` method to validate the ID.
     * If the ID is valid, it returns an object indicating the validity
     * of the ID. If it is invalid, it provides a reason for the failure.
     *
     * @param {bigint | string} id - The ID to validate.
     * It can be a bigint or a Base62 encoded string.
     *
     * @returns {{ valid: boolean; reason?: string }} An object containing:
     * - `valid` (boolean): Indicates whether the ID is valid.
     * - `reason` (string, optional): A reason for invalidation if applicable.
     */
    validateID(id: bigint | string): {
        valid: boolean;
        reason?: string;
    };
    /**
     * Retrieves information about a given Hybrid ID.
     *
     * This method extracts various components from the Hybrid ID, including the
     * timestamp, machine ID, random bits, and sequence number. If the provided
     * ID is in Base62 format or an instance of `HybridID`, it converts it to a
     * bigint for processing. If the ID is invalid, an error is thrown.
     *
     * @param {HybridID | bigint | string} id - The Hybrid ID to extract information from.
     * It can be an instance of `HybridID`, a bigint, or a Base62 encoded string.
     *
     * @returns {HybridIDInfo} An object containing the extracted information:
     * - `timestamp` (bigint): The timestamp portion of the Hybrid ID.
     *   Returns -1 if the timestamp is masked.
     * - `machineId` (number): The machine ID extracted from the Hybrid ID.
     * - `randomBits` (number): The random bits extracted from the Hybrid ID.
     * - `sequence` (number): The sequence number extracted from the Hybrid ID.
     * - `masked` (boolean): Indicates whether the timestamp is masked.
     *
     * @throws {Error} If the provided ID is invalid.
     */
    info(id: HybridID | bigint | string): HybridIDInfo;
}
export default HybridIDGenerator;
