/**
 * GitHubRateLimiter - Specialized rate limiter for GitHub API calls
 *
 * Features:
 * - Respects GitHub's authenticated (5000/hour) and unauthenticated (60/hour) limits
 * - Client-side queuing when approaching limits
 * - Request prioritization for critical operations
 * - Comprehensive logging for quota management
 * - Early termination when exact matches are found
 */
import { RateLimitStatus } from './RateLimiter.js';
import { TokenManager } from '../security/tokenManager.js';
export interface GitHubRateLimitInfo {
    limit: number;
    remaining: number;
    reset: Date;
    used: number;
}
export interface GitHubApiRequest {
    id: string;
    operation: string;
    priority: 'high' | 'normal' | 'low';
    timestamp: number;
    resolve: (value: any) => void;
    reject: (error: any) => void;
}
export interface GitHubRateStatus extends RateLimitStatus {
    queueLength: number;
    currentLimit: number;
    rateLimitInfo?: GitHubRateLimitInfo;
}
/**
 * Interface for rate limiting GitHub API requests
 * Used for dependency injection
 */
export interface IRateLimiter {
    queueRequest<T>(operation: string, apiCall: () => Promise<T>, priority?: 'high' | 'normal' | 'low'): Promise<T>;
    getStatus(): GitHubRateStatus;
    clearQueue(): void;
    reset(): void;
    cleanup(): void;
    dispose(): void;
}
export declare class GitHubRateLimiter implements IRateLimiter {
    private rateLimiter;
    private requestQueue;
    private processing;
    private lastRateLimitInfo?;
    private isAuthenticated;
    private initialized;
    private initializationPromise?;
    private tokenManager;
    constructor(tokenManager: TokenManager);
    /**
     * Ensure rate limiter is initialized with proper auth status
     */
    private ensureInitialized;
    /**
     * Update rate limits based on current authentication status
     */
    private updateLimitsForAuthStatus;
    private statusCheckInterval?;
    /**
     * Setup periodic check for rate limit status
     * FIX: Store interval reference to allow cleanup in tests
     */
    private setupPeriodicStatusCheck;
    /**
     * Cleanup method for tests
     */
    cleanup(): void;
    /**
     * Queue a GitHub API request with rate limiting
     * @param operation Description of the operation
     * @param apiCall Function that makes the actual API call
     * @param priority Request priority (high, normal, low)
     * @returns Promise that resolves with the API response
     */
    queueRequest<T>(operation: string, apiCall: () => Promise<T>, priority?: 'high' | 'normal' | 'low'): Promise<T>;
    /**
     * Add request to queue with priority ordering
     */
    private addToQueue;
    /**
     * Process the request queue
     */
    private processQueue;
    /**
     * Get current rate limit status
     */
    getStatus(): GitHubRateStatus;
    /**
     * Check if an error is a GitHub rate limit error
     */
    private isGitHubRateLimitError;
    /**
     * Handle GitHub rate limit error response
     */
    private handleGitHubRateLimit;
    /**
     * Log API usage for monitoring and diagnostics
     */
    private logApiUsage;
    /**
     * Clear the request queue (for testing or emergency situations)
     */
    clearQueue(): void;
    /**
     * Reset the rate limiter (for testing)
     */
    reset(): void;
    /**
     * Dispose of background timers and queued requests.
     */
    dispose(): void;
}
//# sourceMappingURL=GitHubRateLimiter.d.ts.map