/**
 * Type definitions for custom hooks
 * FE-TYPE-012: Add type safety for hooks
 *
 * This file provides return types for all custom hooks
 * to ensure full type safety across the application.
 */

/**
 * Return type for useAuth hook
 */
export interface UseAuthReturn {
  isAuthenticated: boolean;
  isLoading: boolean;
}

import type { TFunction } from 'i18next';

/**
 * Return type for useTranslation hook
 */
export interface UseTranslationReturn {
  t: TFunction;
  i18n: {
    changeLanguage: (lng: string) => Promise<void>;
    isInitialized: boolean;
    [key: string]: unknown;
  };
  language: 'en' | 'fr';
  changeLanguage: (newLanguage: 'en' | 'fr') => void;
  isReady: boolean;
}

/**
 * Return type for useToast hook
 */
export interface UseToastReturn {
  success: (message: string, duration?: number) => void;
  error: (message: string, duration?: number) => void;
  warning: (message: string, duration?: number) => void;
  info: (message: string, duration?: number) => void;
  toast: (toast: {
    message: string;
    type?: 'success' | 'error' | 'warning' | 'info';
    duration?: number;
  }) => void;
}

/**
 * Return type for useChat hook
 */
export interface UseChatReturn {
  wsStatus: 'disconnected' | 'connecting' | 'connected' | 'error';
  connect: () => void;
  disconnect: () => void;
  sendMessage: (
    content: string,
    attachments?: import('@/features/chat/types').MessageAttachment[],
  ) => void;
  fetchHistory: (conversationId: string) => Promise<void>;
  addReaction: (messageId: string, emoji: string) => void;
  removeReaction: (messageId: string) => void;
  setTyping: (isTyping: boolean) => void;
}

/**
 * Return type for usePWA hook
 */
export interface UsePWAReturn {
  // Status from PWAStatus
  isInstallable: boolean;
  isInstalled: boolean;
  isOnline: boolean;
  updateAvailable: boolean;
  hasServiceWorker: boolean;

  // Loading states
  isInstalling: boolean;
  isUpdating: boolean;

  // Actions
  install: () => Promise<boolean>;
  update: () => Promise<void>;
  requestNotifications: () => Promise<NotificationPermission>;
  showNotification: (
    title: string,
    options?: NotificationOptions,
  ) => Promise<void>;
  clearCaches: () => Promise<void>;
  getVersion: () => Promise<string>;

  // Computed properties
  canInstall: boolean;
  canUpdate: boolean;
  isOffline: boolean;
}

/**
 * Return type for usePWAInstallBanner hook
 */
export interface UsePWAInstallBannerReturn {
  showBanner: boolean;
  isInstalling: boolean;
  handleInstall: () => Promise<void>;
  handleDismiss: () => void;
}

/**
 * Return type for useOfflineDetection hook
 */
export interface UseOfflineDetectionReturn {
  isOnline: boolean;
  isOffline: boolean;
  showOfflineBanner: boolean;
  dismissOfflineBanner: () => void;
}
