import { SearchResponseProductAttributes } from 'src/application/models/api/response';

export enum ProductSorting {
  FEATURED = 'featured',
  PRICE_ASC = 'price_asc',
  PRICE_DESC = 'price_desc',
}

export const ProductSortingNames = {
  [ProductSorting.FEATURED]: 'Featured',
  [ProductSorting.PRICE_ASC]: 'Price Low to High',
  [ProductSorting.PRICE_DESC]: 'Price High to Low',
};

export type ChatSearchStateType = 'entrypoint' | 'initializing-search' | 'product-page';

export type ChatSearchFilter = {
  filterId: string;
  displayName: string;
  items: ChatSearchFilterItem[];
};

export type ChatSearchFilterItem = {
  filterItemId: string;
  displayName: string;
  productCount: number;
  isSelected: boolean;
};

export interface ChatSearchSortProps {
  options: ProductSorting[];
}

export interface ChatSearchSortModalProps extends ChatSearchSortProps {
  open: boolean;
  handlePopupState: (state: boolean) => void;
}

export interface SortOption {
  value: ProductSorting;
  isSelected: boolean;
  onSelect: (option: ProductSorting) => void;
}

export enum ChatSearchSortOverrides {
  DESKTOP_FILTER_CONTAINER = 'spiffy-chat-search-filter-container',
  DESKTOP_FILTER_SELECT_COMPONENT = 'spiffy-chat-search-filter-select-component',
  DESKTOP_FILTER_SELECT_ICON = 'spiffy-chat-search-filter-select-icon',
  MOBILE_FILTER_BUTTON = 'spiffy-chat-search-filter-button',
  MOBILE_FILTER_MODAL_CONTAINER = 'spiffy-chat-search-filter-modal-container',
  MOBILE_FILTER_MODAL_HEADER = 'spiffy-chat-search-filter-modal-header',
  MOBILE_FILTER_MODAL_SELECTION = 'spiffy-chat-search-filter-modal-selection',
  MOBILE_FILTER_MODAL_OPTION = 'spiffy-chat-search-filter-modal-option',
  MOBILE_FILTER_MODAL_OPTION_PILL = 'spiffy-chat-search-filter-modal-option-pill',
  MOBILE_FILTER_MODAL_OPTION_DESCRIPTION = 'spiffy-chat-search-filter-modal-option-desc',
  MOBILE_FILTER_MODAL_APPLY_BUTTON = 'spiffy-chat-search-filter-modal-apply-button',
}

// Custom product retrieval result interface
export interface ProductRetrievalResult {
  products: SearchResponseProductAttributes['attributes'][];
  totalProductCount: number;
}

// Product retrieval parameters interface
export interface ProductRetrievalParams {
  productIds: string[];
}
