import type Accessor from "../../core/Accessor.js";
import type { HistogramBin } from "../../smartMapping/statistics/types.js";
import type { HistogramLabelFormatFunction } from "../types.js";
import type { HistogramState } from "./types.js";

export interface HistogramViewModelProperties extends Partial<Pick<HistogramViewModel, "average" | "bins" | "labelFormatFunction" | "max" | "min">> {}

/**
 * Provides the logic for the [Histogram](https://developers.arcgis.com/javascript/latest/references/core/widgets/Histogram/) widget.
 *
 * @since 4.12
 * @see [Histogram](https://developers.arcgis.com/javascript/latest/references/core/widgets/Histogram/)
 * @see [Programming patterns: Widget viewModel pattern](https://developers.arcgis.com/javascript/latest/programming-patterns/#widget-viewmodel-pattern)
 */
export default class HistogramViewModel extends Accessor {
  constructor(properties?: HistogramViewModelProperties);
  /**
   * The statistical average of the data in the histogram. You would typically
   * get this value from the `avg` property of
   * [SummaryStatisticsResult](https://developers.arcgis.com/javascript/latest/references/core/smartMapping/statistics/types/#SummaryStatisticsResult),
   * which is the result of the
   * [summaryStatistics](https://developers.arcgis.com/javascript/latest/references/core/smartMapping/statistics/summaryStatistics/) function.
   *
   * When set, this value will render on the histogram with a symbol indicating it is the average.
   *
   * @example
   * // sets result returned from a smart mapping method
   * // to the histogram
   * histogramVM.average = response.statistics.avg;
   * @example histogramVM.average = 34.5;
   */
  accessor average: number | null | undefined;
  /**
   * The range of values for the histogram calculated from the bins. This is calculated by
   * subtracting the min value of the first bin from the max
   * value of the last bin.
   */
  get binRange(): number;
  /**
   * An array of objects representing each bin in the histogram. This
   * information is typically returned from the
   * [histogram](https://developers.arcgis.com/javascript/latest/references/core/smartMapping/statistics/histogram/) function.
   *
   * @example
   * // sets the bins of the histogram from the bins in the histogram() result
   * histogramVM.bins = histogramResult.bins;
   * @example
   * // Creates a histogram with 7 bins.
   * histogramVM.bins = [
   *   { minValue: 0, maxValue: 10, count: 4 },
   *   { minValue: 10.1, maxValue: 20, count: 14 },
   *   { minValue: 20.1, maxValue: 30, count: 9 },
   *   { minValue: 30.1, maxValue: 40, count: 34 },
   *   { minValue: 40.1, maxValue: 50, count: 351 },
   *   { minValue: 50.1, maxValue: 60, count: 100 },
   *   { minValue: 60.1, maxValue: 70, count: 1 }
   * ];
   */
  accessor bins: HistogramBin[] | null | undefined;
  /**
   * A function used to format labels. Overrides the default label formatter.
   *
   * @example
   * // For thumb values, rounds each label to whole numbers.
   * slider.viewModel.labelFormatFunction = function(value) {
   *   return value.toFixed(0);
   * }
   */
  accessor labelFormatFunction: HistogramLabelFormatFunction | null | undefined;
  /**
   * The maximum value or bound of the entire histogram. This
   * should match the maximum bound of the last [bin](https://developers.arcgis.com/javascript/latest/references/core/widgets/Histogram/HistogramViewModel/#bins).
   *
   * @example histogramVM.max = 100;
   * @example
   * // sets result returned from a smart mapping method
   * // to the histogram
   * histogramVM.max = response.statistics.max;
   */
  accessor max: number | null | undefined;
  /**
   * The minimum value or bound of the entire histogram. This
   * should match the minimum bound of the first [bin](https://developers.arcgis.com/javascript/latest/references/core/widgets/Histogram/HistogramViewModel/#bins).
   *
   * @example histogramVM.min = 0;
   * @example
   * // sets result returned from a smart mapping method
   * // to the histogram
   * histogramVM.min = response.statistics.min;
   */
  accessor min: number | null | undefined;
  /**
   * The range of values for the histogram. This is calculated by
   * subtracting the [min](https://developers.arcgis.com/javascript/latest/references/core/widgets/Histogram/HistogramViewModel/#min) from the [max](https://developers.arcgis.com/javascript/latest/references/core/widgets/Histogram/HistogramViewModel/#max).
   */
  get range(): number;
  /** The current state of the view model. */
  get state(): HistogramState;
}