import { FC } from 'react';

export interface ChatWidgetProps {
  /** Enable dark mode */
  darkMode?: boolean;
  /** Primary brand color (hex or rgba) */
  primaryColor?: string;
  /** Widget position on screen */
  position?: 'bottom-right' | 'bottom-left' | 'top-right' | 'top-left';
  /** Company/team name */
  companyName?: string;
  /** Company logo URL */
  companyLogo?: string | null;
  /** Welcome message shown before conversation starts */
  welcomeMessage?: string;
  /** API base URL used for streaming responses */
  apiBaseUrl?: string;
  /** Organization ID header for backend */
  organizationId?: string;
  /** Provide quick questions for users to click */
  quickQuestions?: string[];
  /** Layout for quick questions */
  quickQuestionsLayout?: 'vertical' | 'horizontal';
  /** Theme text color */
  textColor?: string;
  /** Assistant message bubble color */
  agentMessageBubbleColor?: string;
  /** User message bubble color */
  userMessageBoxColor?: string;
  /** Assistant message text color */
  assistantTextColor?: string;
  /** User message text color */
  userTextColor?: string;
  /** Custom font family */
  fontFamily?: string;
  /** Base font size */
  fontSize?: string;
  /** Default language code for RTL support */
  defaultLanguage?: string;
  /** Auto-open widget on load */
  autoOpen?: boolean;
  /** Delay before auto-opening (ms) */
  openDelay?: number;
  /** Locale for internationalization */
  locale?: string;
  /** Make header text bold */
  headerTextBold?: boolean;
  /** Make header text italic */
  headerTextItalic?: boolean;
  /** Enable voice interaction (bidi) */
  enableVoiceInteraction?: boolean;
  /** Disclaimer text to display */
  disclaimerText?: string;
  /** Position of disclaimer: 'top' or 'footer' */
  disclaimerPosition?: 'top' | 'footer';
  /** Show "Powered by ESHAL" in the footer*/
  showPoweredBy?: boolean;
  /** Concierge/agent name */
  conciergeName?: string;
  /** Additional CSS classes */
  className?: string;
  /** Onboarding questions array */
  onboardingQuestions?: Array<{
    askToType: string;
    fieldType: 'phone' | 'fullName' | 'email';
    required: boolean;
  }>;
  /** Collection prompt text */
  collectionPrompt?: string;
  /** Allowed domains where widget can appear (empty array = all domains) */
  allowedDomains?: string[];
  /** Enable onboarding */
  onboardingEnabled?: boolean;
  /** Inactivity timeout value */
  inactivityTimeoutValue?: number;
  /** Inactivity timeout unit */
  inactivityTimeoutUnit?: 'MINUTES' | 'HOURS' | 'DAYS';
}

declare const ChatWidget: FC<ChatWidgetProps>;

export default ChatWidget;

// Vanilla JS API types
export interface VanillaConfig extends ChatWidgetProps {
  /** Legacy REST API endpoint URL */
  apiUrl?: string;
  /** API authentication key */
  apiKey?: string;
  /** Session initialization URL */
  sessionUrl?: string;
  /** User ID */
  userId?: string;
  /** User name */
  userName?: string;
  /** User email */
  userEmail?: string;
  /** Callback when widget opens */
  onOpen?: () => void;
  /** Callback when widget closes */
  onClose?: () => void;
}

export interface VanillaAPI {
  /** Initialize the widget */
  init(config?: VanillaConfig): Promise<VanillaAPI>;
  /** Update configuration */
  updateConfig(config: Partial<VanillaConfig>): VanillaAPI;
  /** Open the widget */
  open(): VanillaAPI;
  /** Close the widget */
  close(): VanillaAPI;
  /** Toggle dark/light theme */
  toggleTheme(): VanillaAPI;
  /** Destroy the widget */
  destroy(): VanillaAPI;
  /** Get current configuration */
  getConfig(): VanillaConfig;
}

declare global {
  interface Window {
    ChatWidget: VanillaAPI;
    ChatWidgetConfig?: VanillaConfig;
  }
}
