import type Color from "../../Color.js";
import type { JSONSupport } from "../../core/JSONSupport.js";
import type { ColorLike } from "../../Color.js";

export interface AttributeColorInfoProperties extends Partial<Pick<AttributeColorInfo, "field" | "label" | "valueExpression" | "valueExpressionTitle">> {
  /**
   * The color used to render dots representing the given [field](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AttributeColorInfo.html#field) in a [DotDensityRenderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-DotDensityRenderer.html) or
   * the color used to represent a pie chart slice in a [PieChartRenderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PieChartRenderer.html).
   */
  color?: ColorLike | null;
}

/**
 * Defines colors for dots in a [DotDensityRenderer.attributes](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-DotDensityRenderer.html#attributes),
 * or colors for pie chart slices in a [PieChartRenderer.attributes](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PieChartRenderer.html#attributes).
 *
 * @since 4.11
 * @see [DotDensityRenderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-DotDensityRenderer.html)
 * @see [PieChartRenderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PieChartRenderer.html)
 * @example
 * renderer.attributes = [{
 *   field: "POPULATION",
 *   label: "Population (2019)",
 *   color: "gray"
 * }];
 */
export default class AttributeColorInfo extends JSONSupport {
  /**
   * @example
   * // Typical usage in a dot density renderer
   * renderer.attributes = [{
   *   field: "Population",
   *   color: "black"
   * }];
   */
  constructor(properties?: AttributeColorInfoProperties);
  /**
   * The color used to render dots representing the given [field](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AttributeColorInfo.html#field) in a [DotDensityRenderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-DotDensityRenderer.html) or
   * the color used to represent a pie chart slice in a [PieChartRenderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-PieChartRenderer.html).
   */
  get color(): Color | null | undefined;
  set color(value: ColorLike | null | undefined);
  /** The name of the numeric attribute field represented by the given [color](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AttributeColorInfo.html#color). */
  accessor field: string | null | undefined;
  /**
   * The label used to describe the field or attribute in the
   * [Legend](https://developers.arcgis.com/javascript/latest/references/map-components/arcgis-legend/).
   */
  accessor label: string | null | undefined;
  /**
   * An [Arcade](https://developers.arcgis.com/javascript/latest/arcade/) expression following the specification
   * defined by the [Arcade Visualization Profile](https://developers.arcgis.com/javascript/latest/arcade/#visualization). Expressions
   * in DotDensityRenderer may reference field values using the `$feature` profile variable and must return a
   * number equal to the number of units represented by each dot. Expressions
   * in PieChartRenderer must return a number representing the size of the pie chart slice.
   *
   * This takes precedence over [field](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AttributeColorInfo.html#field).
   * Therefore, this property is typically used as an alternative to [field](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AttributeColorInfo.html#field).
   *
   * @see [Arcade Visualization Profile](https://developers.arcgis.com/javascript/latest/arcade/#visualization)
   */
  accessor valueExpression: string | null | undefined;
  /**
   * The title identifying and describing the associated
   * [Arcade](https://developers.arcgis.com/javascript/latest/arcade/) expression as defined in the [valueExpression](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AttributeColorInfo.html#valueExpression) property. This is displayed
   * as the label of the attribute in the [Legend](https://developers.arcgis.com/javascript/latest/references/map-components/arcgis-legend/) in the absence of one
   * provided in the [label](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-support-AttributeColorInfo.html#label) property.
   */
  accessor valueExpressionTitle: string | null | undefined;
  /**
   * Creates a deep clone of this object.
   *
   * @returns A deep clone of the object that
   *   invoked this method.
   * @example
   * // Creates a deep clone of the renderer's first attribute object.
   * let attributeColorInfo = renderer.attributes[0].clone();
   */
  clone(): AttributeColorInfo;
}