import type Extent from "../../geometry/Extent.js";
import type Polygon from "../../geometry/Polygon.js";
import type DimensionalDefinition from "./DimensionalDefinition.js";
import type { JSONSupport } from "../../core/JSONSupport.js";
import type { PolygonProperties } from "../../geometry/Polygon.js";
import type { ExtentProperties } from "../../geometry/Extent.js";
import type { DimensionalDefinitionProperties } from "./DimensionalDefinition.js";

/** @since 5.0 */
export interface MultidimensionalSubsetProperties {
  /**
   * The spatial area of interest. The area of interest can only be set on an [ImageryLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html).
   * Only the imagery within the area of interest will be available when set.
   *
   * > [!WARNING]
   * >
   * > **Note:**
   * >
   * > This property will not be honored on an [ImageryTileLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryTileLayer.html).
   */
  areaOfInterest?: (ExtentProperties & { type: "extent" }) | (PolygonProperties & { type: "polygon" }) | null;
  /**
   * The variable and dimension subset definitions to set the layer.
   * Only the dimensional definitions defined here will be available on the layer.
   */
  subsetDefinitions?: DimensionalDefinitionProperties[] | null;
}

/**
 * A subset of multidimensional raster data created by slicing the data along defined variables and dimensions.
 * Only dimensional slices that meet the multidimensionalSubset requirements will be available on a multidimensional [ImageryLayer.multidimensionalSubset](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html#multidimensionalSubset)
 * or [ImageryTileLayer.multidimensionalSubset](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryTileLayer.html#multidimensionalSubset) when the `multiDimensionalSubset` property is set on the layer.
 * For example, if you have an [ImageryLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html) that contains 30 years of monthly precipitation data,
 * and you only want to expose data for each January to see how precipitation has changed for that month, you can set the `multiDimensionalSubset` on the imagery layer.
 *
 * When the `multiDimensionalSubset` is defined on a layer, the [ImageryTileLayer.multidimensionalDefinition](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryTileLayer.html#multidimensionalDefinition)
 * property of the [ImageryTileLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryTileLayer.html#multidimensionaldata) or the [mosaicRule.multidimensionalDefinition](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html#mosaicRule)
 * of the [ImageryLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html#multidimensionaldata) must be within the defined `multidimensionalSubset`, otherwise nothing will be displayed on the map or available for analysis.
 *
 * @since 4.25
 * @see [ImageryLayer - working with multidimensional raster data](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html#multidimensionaldata)
 * @see [ImageryTileLayer - working with multidimensional raster data](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryTileLayer.html#multidimensionaldata)
 * @see [Sample - Multidimensional ImageryTileLayer](https://developers.arcgis.com/javascript/latest/sample-code/layers-imagery-multidimensional/)
 */
export default class MultidimensionalSubset extends JSONSupport {
  constructor(properties?: MultidimensionalSubsetProperties);
  /**
   * The spatial area of interest. The area of interest can only be set on an [ImageryLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryLayer.html).
   * Only the imagery within the area of interest will be available when set.
   *
   * > [!WARNING]
   * >
   * > **Note:**
   * >
   * > This property will not be honored on an [ImageryTileLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-ImageryTileLayer.html).
   */
  get areaOfInterest(): Extent | Polygon | null | undefined;
  set areaOfInterest(value: (ExtentProperties & { type: "extent" }) | (PolygonProperties & { type: "polygon" }) | null | undefined);
  /** The aggregated dimension names and their extents or ranges computed from the [subsetDefinitions](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MultidimensionalSubset.html#subsetDefinitions). */
  get dimensions(): SubsetDimension[];
  /**
   * The variable and dimension subset definitions to set the layer.
   * Only the dimensional definitions defined here will be available on the layer.
   */
  get subsetDefinitions(): DimensionalDefinition[] | null | undefined;
  set subsetDefinitions(value: DimensionalDefinitionProperties[] | null | undefined);
  /** The aggregated variables list computed from the [subsetDefinitions](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MultidimensionalSubset.html#subsetDefinitions). */
  get variables(): string[];
  /**
   * Creates a deep clone of the MultidimensionalSubset object.
   *
   * @returns A clone of the object that invoked this method.
   */
  clone(): MultidimensionalSubset;
}

/**
 * Dimension name and its extent or range computed from the [subsetDefinitions](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MultidimensionalSubset.html#subsetDefinitions) and it is added to [dimensions](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-MultidimensionalSubset.html#dimensions).
 *
 * @since 4.25
 */
export interface SubsetDimension {
  /**
   * The dimension name.
   *
   * @since 4.25
   */
  name: string;
  /**
   * The computed extent or ranges for the given dimension.
   *
   * @since 4.25
   */
  extent: [
      number,
      number
  ];
}