import type AlgorithmicColorRamp from "../../rest/support/AlgorithmicColorRamp.js";
import type MultipartColorRamp from "../../rest/support/MultipartColorRamp.js";

/**
 * @internal
 * @internal
 */
export type Colormap = number[][];

/**
 * @internal
 * @internal
 */
export type Color = [
    number,
    number,
    number,
    number
] | [
    number,
    number,
    number
];

/**
 * @internal
 * @internal
 */
export type AlgorithmType = "esriCIELabAlgorithm" | "esriHSVAlgorithm" | "esriLabLChAlgorithm";

/**
 * @internal
 * @internal
 */
export interface AlgorithmicColorRampJSON {
  /**
   * The algorithm of the color ramp.
   *
   * @internal
   */
  algorithm: AlgorithmType;
  /**
   * From color.
   *
   * @internal
   */
  fromColor: Color;
  /**
   * To color.
   *
   * @internal
   */
  toColor: Color;
  /**
   * The type.
   *
   * @internal
   */
  type: "algorithmic";
}

/**
 * @internal
 * @internal
 */
export interface AlgorithmicColorRampPart extends AlgorithmicColorRampJSON {
  /**
   * Start value.
   *
   * @internal
   */
  start?: number;
  /**
   * Stop value.
   *
   * @internal
   */
  stop?: number;
}

/**
 * @internal
 * @internal
 */
export interface MultipartColorRampJSON {
  /**
   * The multipart color ramps.
   *
   * @internal
   */
  colorRamps: AlgorithmicColorRampPart[];
  /**
   * The type.
   *
   * @internal
   */
  type: "multipart";
}

/**
 * @internal
 * @internal
 */
export interface ColorRampOptions {
  /**
   * The number of colors in the color ramp.
   *
   * @internal
   */
  numColors?: number;
  /**
   * The distance offset.
   *
   * @internal
   */
  distanceOffset?: number;
  /**
   * The distance interval.
   *
   * @internal
   */
  distanceInterval?: number;
  /**
   * The interpolate alpha flag.
   *
   * @internal
   */
  interpolateAlpha?: boolean;
  /**
   * The weights array.
   *
   * @internal
   */
  weights?: number[];
  /**
   * Whether it is custom interval.
   *
   * @internal
   */
  isCustomInterval?: boolean;
}

/**
 * @internal
 * @internal
 */
export interface HsvColor {
  /**
   * The type.
   *
   * @internal
   */
  type: "HsvColor";
  /**
   * The Hue.
   *
   * @internal
   */
  Hue: number;
  /**
   * The Saturation.
   *
   * @internal
   */
  Saturation: number;
  /**
   * The value.
   *
   * @internal
   */
  Value: number;
  /**
   * The Alpha value.
   *
   * @internal
   */
  AlphaValue: number;
}

/**
 * @internal
 * @internal
 */
export interface AlgorithmColorRampArgValue {
  /**
   * The algorithm of the color ramp.
   *
   * @internal
   */
  Algorithm: AlgorithmType;
  /**
   * From color.
   *
   * @internal
   */
  FromColor: HsvColor;
  /**
   * To color.
   *
   * @internal
   */
  ToColor: HsvColor;
  /**
   * The type.
   *
   * @internal
   */
  readonly type: "AlgorithmicColorRamp";
  /**
   * The name.
   *
   * @internal
   */
  Name?: string;
}

/**
 * @internal
 * @internal
 */
export interface MultipartColorRampArgValue {
  /**
   * The number of color ramps.
   *
   * @internal
   */
  NumColorRamps: number;
  /**
   * The array of multipart color ramps.
   *
   * @internal
   */
  ArrayOfColorRamp: AlgorithmColorRampArgValue[];
  /**
   * The name.
   *
   * @internal
   */
  Name: string;
  /**
   * The type.
   *
   * @internal
   */
  readonly type: "MultiPartColorRamp";
}

/**
 * Convert a ColorRamp object/json to a raster colormap. Default number of colors is 256.
 *
 * @param colorRamp
 * @param options
 * @internal
 * @internal
 */
export function convertColorRampToColormap(colorRamp: AlgorithmicColorRamp | MultipartColorRamp | AlgorithmicColorRampJSON | MultipartColorRampJSON, options?: ColorRampOptions): Colormap;

/**
 * Converts a ColorRamp object to color ramp format readable as part of RFTs.
 *
 * @param colorRamp
 * @internal
 * @internal
 */
export function getRFxArgColorRampValue(colorRamp: AlgorithmicColorRamp | MultipartColorRamp): AlgorithmColorRampArgValue | MultipartColorRampArgValue | null | undefined;