import { GlobalMessage } from '@/components/common/GlobalMessage';
import { toast } from 'sonner';

declare global {
  interface Window {
    msg: GlobalMessage;
    $message: {
      success: (message: string, duration?: number) => void;
      error: (message: string, duration?: number) => void;
      warning: (message: string, duration?: number) => void;
      info: (message: string, duration?: number) => void;
      loading: (message: string) => ReturnType<typeof toast.promise>;
      dismiss: () => void;
    };
    // Google Analytics 类型声明
    gtag: (...args: any[]) => void;
    dataLayer: any[];
    
    // Google GSI API类型声明
    google?: {
      accounts: {
        id: {
          initialize: (config: {
            client_id: string;
            callback: (response: { credential: string }) => void;
            auto_select?: boolean;
            cancel_on_tap_outside?: boolean;
          }) => void;
          prompt: (callback?: (notification: {
            isNotDisplayed: () => boolean;
            isSkippedMoment: () => boolean;
          }) => void) => void;
          renderButton: (
            element: HTMLElement,
            options: {
              theme?: 'outline' | 'filled_blue' | 'filled_black';
              size?: 'large' | 'medium' | 'small';
              text?: 'signin_with' | 'signup_with' | 'continue_with' | 'signin';
              shape?: 'rectangular' | 'pill' | 'circle' | 'square';
              logo_alignment?: 'left' | 'center';
              width?: string | number;
              locale?: string;
            }
          ) => void;
        };
      };
    };
  }
}