/**
 * Global WordPress types for B3 Swatches.
 */

interface B3WvsData {
  ajax_url: string;
  nonce: string;
  rest_url: string;
  admin_color: string;
  admin_urls?: {
    getting_started?: string;
    settings?: string;
    attributes?: string;
    products?: string;
  };
  /** Raw settings (for admin form state). */
  settings: {
    shape?: "square";
    enable_tooltips?: boolean;
    layout?: "wrap";
    swatch_style?: "underline";
    layout_padding_top?: number;
    layout_padding_right?: number;
    layout_padding_bottom?: number;
    layout_padding_left?: number;
    external_padding_top?: number;
    external_padding_right?: number;
    external_padding_bottom?: number;
    external_padding_left?: number;
    padding_top?: number;
    padding_right?: number;
    padding_bottom?: number;
    padding_left?: number;
    swatch_gap?: number;
    swatch_width?: number;
    swatch_height?: number;
    show_labels?: boolean;
    show_labels_colors?: boolean;
    selected_color?: string;
    heading_font_color?: string;
    heading_font_size?: number;
    label_text_color?: string;
    label_font_size?: number;
    auto_convert_dropdowns?: boolean;
    remove_on_uninstall?: boolean;
    [key: string]: any;
  };
  // Optional supplemental payloads stay intentionally loose here.
  [key: string]: any;
}

declare global {
  interface Window {
    b3WvsData: B3WvsData;
    wp: {
      media: (options: any) => any;
      element: any;
    };
  }

  const b3WvsData: B3WvsData;

  // Minimal jQuery surface used by WooCommerce integrations in legacy/admin code.
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  interface JQueryObject {
    trigger: (event: string, data?: any[]) => JQueryObject;
    on: (
      events: string,
      selectorOrHandler: string | ((...args: any[]) => void),
      handler?: (...args: any[]) => void,
    ) => JQueryObject;
    off: (event: string, selector?: string) => JQueryObject;
    each: (callback: (this: HTMLElement) => void) => JQueryObject;
    get: (index: number) => any;
  }

  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  const jQuery:
    | (((selector?: any) => JQueryObject) & {
        fn: { [key: string]: any };
      })
    | undefined;

  // Provided by WooCommerce when cart fragments are enabled.
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
  const wc_cart_fragments_params: any;
}

export {};
