/**
 * @fileoverview Types related to diffing.
 *
 * As gr-diff is an embeddable component, many of these types are actually
 * defined in api/diff.ts. This file re-exports them and adds any
 * internal fields that Gerrit may use.
 *
 * @license
 * Copyright 2020 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */
import {WebLinkInfo} from '../api/rest-api';
import {
  ChangeType,
  DiffContent as DiffContentApi,
  DiffFileMetaInfo as DiffFileMetaInfoApi,
  DiffInfo as DiffInfoApi,
  DiffIntralineInfo,
  DiffResponsiveMode,
  DiffPreferencesInfo as DiffPreferenceInfoApi,
  IgnoreWhitespaceType,
  MarkLength,
  MoveDetails,
  SkipLength,
} from '../api/diff';

export type {
  ChangeType,
  DiffIntralineInfo,
  DiffResponsiveMode,
  IgnoreWhitespaceType,
  MarkLength,
  MoveDetails,
  SkipLength,
  WebLinkInfo,
};

export interface DiffInfo extends DiffInfoApi {
  /** Meta information about the file on side A as a DiffFileMetaInfo entity. */
  meta_a?: DiffFileMetaInfo;
  /** Meta information about the file on side B as a DiffFileMetaInfo entity. */
  meta_b?: DiffFileMetaInfo;

  /**
   * Links to the file diff in external sites as a list of DiffWebLinkInfo
   * entries.
   */
  web_links?: DiffWebLinkInfo[];

  /**
   * Links to edit the file in external sites as a list of WebLinkInfo
   * entries.
   */
  edit_web_links?: WebLinkInfo[];
}

/**
 * The DiffWebLinkInfo entity describes a link on a diff screen to an external
 * site.
 * https://gerrit-review.googlesource.com/Documentation/rest-api-changes.html#diff-web-link-info
 */
export declare interface DiffWebLinkInfo {
  /** The link name. */
  name: string;
  /** The link URL. */
  url: string;
  /** URL to the icon of the link. */
  image_url: string;
  // TODO: Are these really of type string? Not able to trigger them, but the
  // docs sound more like boolean.
  show_on_side_by_side_diff_view: string;
  show_on_unified_diff_view: string;
}

export interface DiffFileMetaInfo extends DiffFileMetaInfoApi {
  /** Links to the file in external sites as a list of WebLinkInfo entries. */
  web_links?: WebLinkInfo[];
}

export interface DiffContent extends DiffContentApi {
  // TODO: Undocumented, but used in code.
  keyLocation?: boolean;
}

export interface DiffPreferencesInfo extends DiffPreferenceInfoApi {
  expand_all_comments?: boolean;
  cursor_blink_rate?: number;
  manual_review?: boolean;
  retain_header?: boolean;
  skip_deleted?: boolean;
  hide_top_menu?: boolean;
  hide_line_numbers?: boolean;
  hide_empty_pane?: boolean;
  match_brackets?: boolean;
}

export declare type DiffPreferencesInfoKey = keyof DiffPreferencesInfo;
