/**
 * Variation Type Definitions
 */

export interface Variation {
  id: number;
  parent_id: number;
  parent_name: string;
  sku: string;
  image_url: string | null;
  attributes: Record<string, string>;
  regular_price: string;
  sale_price: string;
  price: string;
  date_on_sale_from?: string | null;
  date_on_sale_to?: string | null;
  stock_quantity: number | null;
  stock_status: StockStatus;
  manage_stock: boolean;
  weight?: string;
  dimensions?: {
    length: string;
    width: string;
    height: string;
  };
  permalink: string;
}

export type StockStatus = 'instock' | 'outofstock' | 'onbackorder';

export interface ParentProduct {
  id: number;
  name: string;
  image_url: string;
  variation_count: number;
  has_matches: boolean;
  matched_variation_ids: number[];
  variations: Variation[];
}

export interface WCSettings {
  currency_symbol: string;
  currency_position: 'left' | 'right' | 'left_space' | 'right_space';
  price_decimals: number;
  price_decimal_separator: string;
  price_thousand_separator: string;
  weight_unit: string;
  dimension_unit: string;
}

export interface VariationsResponse {
  success: boolean;
  data: {
    variations?: Variation[];
    total?: number;
    offset?: number;
    limit?: number;
    parents?: ParentProduct[];
    total_parents?: number;
    mode?: 'flat' | 'grouped';
    tax_class_options?: string[]; // 🎯 Dynamic tax classes from WooCommerce
    wc_settings?: WCSettings; // 🎯 WooCommerce formatting settings
  };
}

export interface VariationsQueryParams {
  offset?: number;
  limit?: number;
  search?: string;
  parentId?: number;
  stockStatus?: StockStatus;
  attributes?: string;
  priceMin?: number | null;
  priceMax?: number | null;
  filterSalePrice?: boolean;
  saleDateFrom?: string | null;
  saleDateTo?: string | null;
  onlyActiveSales?: boolean;
  groupBy?: 'parent';
}
