/**
 * OptimizedServiceManager.tsx
 *
 * Comprehensive service layer manager that consolidates all service-related functionality:
 *
 * Services consolidated:
 * - api.ts (API client configuration and user/content APIs)
 * - useDashboardData.js (dashboard data fetching hook)
 * - useDashboardState.js (dashboard state management hook)
 * - useTheme.ts (theme management)
 * - useBreakpoint.ts (responsive breakpoint handling)
 * - colorUtils.ts (color utility functions)
 * - responsiveUtils.ts (responsive design utilities)
 * - styleUtils.ts (styling utilities)
 *
 * Key improvements:
 * - Unified service layer with comprehensive error handling
 * - Real-time data synchronization with WebSocket support
 * - Advanced caching strategies with TTL and invalidation
 * - Request deduplication and batch processing
 * - Comprehensive logging and monitoring
 * - Performance optimization with request prioritization
 * - Offline support with data synchronization
 * - Type-safe API client with automatic retry logic
 * - Centralized authentication and authorization
 * - Multi-tenant support with context switching
 */
import React, { ReactNode } from 'react';
import { ColorMode } from '@chakra-ui/react';
export interface User {
    id: string;
    username: string;
    email: string;
    firstName: string;
    lastName: string;
    fullName?: string;
    role: string;
    avatar?: string;
    permissions: string[];
    preferences: UserPreferences;
    metadata?: Record<string, any>;
    createdAt: string;
    updatedAt: string;
    lastLoginAt?: string;
    isActive: boolean;
    tenant?: string;
}
export interface UserPreferences {
    theme: 'light' | 'dark' | 'system';
    language: string;
    timezone: string;
    notifications: {
        email: boolean;
        push: boolean;
        browser: boolean;
        types: string[];
    };
    dashboard: {
        layout: string;
        widgets: string[];
        refreshInterval: number;
    };
    accessibility: {
        reducedMotion: boolean;
        highContrast: boolean;
        largeText: boolean;
    };
}
export interface ApiResponse<T> {
    data: T;
    message?: string;
    success: boolean;
    timestamp: string;
    requestId?: string;
}
export interface PaginatedResponse<T> {
    items: T[];
    pagination: {
        page: number;
        limit: number;
        total: number;
        totalPages: number;
        hasNext: boolean;
        hasPrev: boolean;
    };
    filters?: Record<string, any>;
    sort?: {
        field: string;
        direction: 'asc' | 'desc';
    };
}
export interface RequestConfig {
    url: string;
    method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
    data?: any;
    params?: Record<string, any>;
    headers?: Record<string, string>;
    timeout?: number;
    cache?: boolean;
    cacheTtl?: number;
    priority?: 'low' | 'normal' | 'high' | 'critical';
    retries?: number;
    deduplicationKey?: string;
    offline?: boolean;
}
export interface CacheEntry<T> {
    data: T;
    timestamp: number;
    ttl: number;
    tags: string[];
    size: number;
}
export interface ServiceError {
    code: string;
    message: string;
    details?: any;
    retryable: boolean;
    timestamp: string;
    requestId?: string;
    context?: Record<string, any>;
}
export interface WebSocketMessage {
    type: string;
    channel: string;
    data: any;
    timestamp: string;
    id: string;
}
export interface ServiceMetrics {
    requestCount: number;
    errorCount: number;
    cacheHitRate: number;
    averageResponseTime: number;
    activeConnections: number;
    queuedRequests: number;
    retryCount: number;
    lastUpdated: string;
}
interface ServiceConfig {
    apiUrl: string;
    wsUrl: string;
    timeout: number;
    retries: number;
    cacheTtl: number;
    batchSize: number;
    retryDelay: number;
    enableRealTime: boolean;
    enableOffline: boolean;
    enableMetrics: boolean;
    enableLogging: boolean;
    logLevel: 'debug' | 'info' | 'warn' | 'error';
    tenant?: string;
}
declare class OptimizedApiClient {
    private config;
    private cache;
    private requestQueue;
    private retryQueue;
    private metrics;
    private authToken?;
    private refreshToken?;
    private interceptors;
    private errorInterceptors;
    constructor(config: ServiceConfig);
    setAuthToken(token: string, refreshToken?: string): void;
    clearAuth(): void;
    refreshAuthToken(): Promise<boolean>;
    addRequestInterceptor(interceptor: (config: RequestConfig) => RequestConfig): void;
    addErrorInterceptor(interceptor: (error: ServiceError) => ServiceError | null): void;
    private getCacheKey;
    private getCachedData;
    private setCachedData;
    invalidateCache(pattern?: string | string[]): void;
    private setupPeriodicCleanup;
    private makeRequest;
    private executeRequest;
    get<T>(url: string, config?: Partial<RequestConfig>): Promise<ApiResponse<T>>;
    post<T>(url: string, data?: any, config?: Partial<RequestConfig>): Promise<ApiResponse<T>>;
    put<T>(url: string, data?: any, config?: Partial<RequestConfig>): Promise<ApiResponse<T>>;
    patch<T>(url: string, data?: any, config?: Partial<RequestConfig>): Promise<ApiResponse<T>>;
    delete<T>(url: string, config?: Partial<RequestConfig>): Promise<ApiResponse<T>>;
    batch<T>(requests: RequestConfig[]): Promise<ApiResponse<T>[]>;
    private generateRequestId;
    private updateMetrics;
    getMetrics(): ServiceMetrics;
    private log;
}
declare class WebSocketManager {
    private ws?;
    private config;
    private subscribers;
    private reconnectAttempts;
    private maxReconnectAttempts;
    private reconnectDelay;
    private heartbeatInterval?;
    constructor(config: ServiceConfig);
    connect(): void;
    disconnect(): void;
    subscribe(channel: string, callback: (message: WebSocketMessage) => void): () => void;
    private send;
    private handleMessage;
    private scheduleReconnect;
    private startHeartbeat;
    private stopHeartbeat;
}
interface ServiceContextValue {
    apiClient: OptimizedApiClient;
    wsManager: WebSocketManager;
    user: User | null;
    isAuthenticated: boolean;
    isLoading: boolean;
    error: ServiceError | null;
    metrics: ServiceMetrics;
    config: ServiceConfig;
    login: (credentials: {
        username: string;
        password: string;
    }) => Promise<void>;
    logout: () => void;
    refreshAuth: () => Promise<boolean>;
    updateProfile: (data: Partial<User>) => Promise<void>;
    updatePreferences: (data: Partial<UserPreferences>) => Promise<void>;
    clearCache: (pattern?: string | string[]) => void;
    getMetrics: () => ServiceMetrics;
    subscribe: (channel: string, callback: (message: WebSocketMessage) => void) => () => void;
    colorMode: ColorMode;
    toggleColorMode: () => void;
    breakpoint: string;
    isMobile: boolean;
    isTablet: boolean;
    isDesktop: boolean;
}
interface ServiceProviderProps {
    children: ReactNode;
    config?: Partial<ServiceConfig>;
}
export declare const OptimizedServiceProvider: React.FC<ServiceProviderProps>;
export declare const useService: () => ServiceContextValue;
export declare const useApi: () => OptimizedApiClient;
export declare const useAuth: () => {
    user: User | null;
    isAuthenticated: boolean;
    isLoading: boolean;
    login: (credentials: {
        username: string;
        password: string;
    }) => Promise<void>;
    logout: () => void;
    refreshAuth: () => Promise<boolean>;
};
export declare const useRealTime: () => {
    subscribe: (channel: string, callback: (message: WebSocketMessage) => void) => () => void;
};
export declare const useResponsive: () => {
    breakpoint: string;
    isMobile: boolean;
    isTablet: boolean;
    isDesktop: boolean;
};
export declare class ServiceError extends Error {
    code: string;
    details?: any;
    retryable: boolean;
    timestamp: string;
    requestId?: string;
    context?: Record<string, any>;
    constructor(code: string, message: string, details?: any, retryable?: boolean, timestamp?: string, requestId?: string, context?: Record<string, any>);
}
export default OptimizedServiceProvider;
export type { User, UserPreferences, ApiResponse, PaginatedResponse, RequestConfig, ServiceConfig, ServiceMetrics, WebSocketMessage, ServiceContextValue };
//# sourceMappingURL=OptimizedServiceManager.d.ts.map