import type Color from "../../Color.js";
import type HeatmapColorStop from "../../renderers/support/HeatmapColorStop.js";
import type ColorSizeStop from "../../renderers/visualVariables/support/ColorSizeStop.js";
import type ColorStop from "../../renderers/visualVariables/support/ColorStop.js";
import type OpacityStop from "../../renderers/visualVariables/support/OpacityStop.js";
import type SizeStop from "../../renderers/visualVariables/support/SizeStop.js";
import type { HistogramBin } from "../../smartMapping/statistics/types.js";
import type { BarCreatedFunction, DataLineInfos, DataLineCreatedFunction } from "../Histogram/types.js";

export type VisualVariableStop = ColorSizeStop | ColorStop | SizeStop | OpacityStop;

export type SmartMappingSupportedStop = VisualVariableStop | HeatmapColorStop;

export type SupportedBreaks = ColorBreak | SizeBreak;

export type ViewModelState = "disabled" | "ready";

export interface ZoomOptions {
  /** The upper bound of the zoom. */
  max?: number | null;
  /** The lower bound of the zoom. */
  min?: number | null;
}

/** Configuration options for defining the slider's [Histogram](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Histogram.html). */
export interface HistogramConfig {
  /**
   * Indicates the average value of the dataset. When set,
   *   a solid line on the histogram will render at the location of the average value along
   *   with a label defaulting to the value set here.
   */
  average?: number;
  /**
   * Function for styling bars representing histogram bins.
   *   This can be used to style bins or add custom interaction to them. For
   *   example, you can use this function to color bins that match the colors on the slider's track.
   */
  barCreatedFunction?: BarCreatedFunction;
  /**
   * The bins of the histogram. This is
   *   an array of objects indicating the range and count of data in each bin. This value is
   *   typically retrieved from the [histogram](https://developers.arcgis.com/javascript/latest/api-reference/esri-smartMapping-statistics-histogram.html)
   *   function.
   */
  bins?: HistogramBin[];
  /**
   * Function
   *   that fires each time a data line is created.
   *   You can use this to style individual dataLines on the data axis.
   */
  dataLineCreatedFunction?: DataLineCreatedFunction;
  /**
   * When set, renders lines on the histogram that indicate important or
   *   meaningful values to the end user.
   */
  dataLines?: DataLineInfos[];
  /**
   * Indicates the standard deviation of the dataset.
   *   When set, data lines are on the histogram at the locations of the standard deviations
   *   above and below the `average`.
   */
  standardDeviation?: number;
  /**
   * Indicates the standard deviation of the dataset.
   *   When set, data lines are on the histogram at the locations of the standard deviations
   *   above and below the `average`.
   */
  standardDeviationCount?: number;
}

/** The return object of the `getStopInfo()` and `getColorStopInfo()` methods. */
export interface GradientStopInfo {
  /** The color of the stop. */
  color: Color;
  /** The offset of the stop. */
  offset: number;
}

export interface ColorBreak {
  /**
   * Features with values within the provided `min`
   *   and `max` will be rendered with this color.
   */
  color: Color;
  /**
   * The max value of the break. The `max` of each break should match the `min`
   *   value of the break directly above it.
   */
  max: number;
  /**
   * The min value of the break. The `min` of each break should match the `max`
   *   value of the break directly below it.
   */
  min: number;
}

export interface SizeBreak {
  /**
   * The max value of the break. The `max` of each break should match the `min`
   *   value of the break directly above it.
   */
  max: number;
  /**
   * The min value of the break. The `min` of each break should match the `max`
   *   value of the break directly below it.
   */
  min: number;
  /**
   * The size in points of the symbol representing features with values within
   *   the given `min` and `max`.
   */
  size: number;
}