import type ColormapInfo from "./support/ColormapInfo.js";
import type { JSONSupport } from "../core/JSONSupport.js";
import type { ColormapInfoProperties } from "./support/ColormapInfo.js";

export interface RasterColormapRendererProperties {
  /**
   * A colormap info array containing mappings for pixel and RGB color values.
   * Colormaps contain a set of values that are associated with colors and pixel values, and are used to display a single-band raster
   * consistently with the same colors.
   */
  colormapInfos?: ColormapInfoProperties[];
}

/**
 * The RasterColormapRenderer defines the symbology to display raster data based on specific colors,
 * aiding in visual analysis of the data. For example, a forestry commission may want to quickly visualize areas
 * above and below the treeline occurring at a known elevation on a raster containing elevation values.
 * They could overlay a transparent colormap set to color those areas below the treeline elevation green, and those above white.
 *
 * The RasterColormapRenderer is only available if a [color map](https://developers.arcgis.com/rest/services-reference/colormap.htm)
 * is present in an [ImageryLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html) or [ImageryTileLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryTileLayer.html).
 * Otherwise, you can use the [UniqueValueRenderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-UniqueValueRenderer.html) to apply colors to your layer.
 *
 * @since 4.16
 */
export default class RasterColormapRenderer extends JSONSupport {
  /**
   * Creates a new instance [RasterColormapRenderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-RasterColormapRenderer.html) from an array of color maps
   * where pixel values with its corresponding RGB color values specified.
   *
   * @param colormap - RGB color representation of pixel values. Each item in the colormap array has an array of the pixel value and red, green, and blue values.
   * @returns Returns a new instance [RasterColormapRenderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-RasterColormapRenderer.html) based on provided colormap.
   * @example
   * // create a color map where values 0-199 are pink and 200-250 are light blue.
   * let colors = [];
   * for (let i = 0; i <= 250; i++) {
   *   if (i < 200) {
   *     colors.push([i, 250, 0, 128]);
   *   } else {
   *     colors.push([i, 0, 128, 250]);
   *   }
   * }
   *
   * // create a RasterColormapRenderer from the colors array
   * const renderer = RasterColormapRenderer.createFromColormap(colors);
   */
  static createFromColormap(colormap: number[][] | null | undefined): RasterColormapRenderer | null;
  /**
   * @example
   * // create a new RasterColormapRenderer from provided the colormap array
   * const renderer = RasterColormapRenderer.createFromColormap(colors);
   * @example
   * // create a new RasterColormapRenderer
   * const renderer = new RasterColormapRenderer({
   *  colormapInfos: colormapInfos
   * });
   */
  constructor(properties?: RasterColormapRendererProperties);
  /**
   * A colormap info array containing mappings for pixel and RGB color values.
   * Colormaps contain a set of values that are associated with colors and pixel values, and are used to display a single-band raster
   * consistently with the same colors.
   */
  get colormapInfos(): ColormapInfo[];
  set colormapInfos(value: ColormapInfoProperties[]);
  /** The type of Renderer. */
  get type(): "raster-colormap";
  /**
   * Creates a deep clone of the renderer.
   *
   * @returns A deep clone of the object that
   *                                                      invoked this method.
   * @example
   * // Creates a deep clone of the first layer's renderer
   * let renderer = view.map.layers.at(0).renderer.clone();
   */
  clone(): RasterColormapRenderer;
}