import type {
  ContentListPage, ContentListPageBody, ProductFilter, ProductGroup, ProductParams, SearchParams
} from './common/mod.ts';


export interface AutocompleteParams extends ProductParams, SearchParams {}

export interface AutocompleteBody extends ContentListPageBody {
  /** @deprecated Use productRules instead */
  productFilter?: ProductFilter;
  /**
   * Product rules to apply for autocomplete in accordance with the Elevate product rules syntax
   * @see https://docs.elevate.voyado.cloud/elevate/4/integration/api/common/page-configuration/
   */
  productRules?: string;
}

export interface Autocomplete extends ContentListPage {
  /** Collection of PhraseSuggestion, that matched query */
  phraseSuggestions: PhraseSuggestion[];
  /** Collection of ProductGroup, that matched query */
  productSuggestions: ProductGroup[];
  /** Collection of Content Suggestions, that matched query */
  contentSuggestions: ContentSuggestion[];
  /** Collection of recent searches by the current `customerKey` in the form of RecentSearch, when query is empty */
  recentSearches: RecentSearch[];
  /** Collection of ProductGroup, the recently viewed products */
  recentlyViewed: ProductGroup[];
  /** Total number of ProductGroup that matched query */
  totalHits: number;
  /** Redirect direct to product page */
  redirectLink?: string;
}

export interface PhraseSuggestion {
  /** Matching phrase with highlight, e.g. {{jea}}ns */
  highlighted: string;
  /** Matching phrase */
  q: string;
}

export interface ContentSuggestion {
  /** Matching title */
  title: string;
  /** Matching title with highlight, e.g. {{Return}}s */
  highlightedTitle: string;
  /** Link to content page */
  link: string;
  /** Use with click notification to identify interaction */
  ticket: string;
}

export interface RecentSearch {
  /** Recent search phrase */
  q: string;
}
