import type LayerView from "./LayerView.js";
import type HighlightOptions from "../support/HighlightOptions.js";
import type { ResourceHandle } from "../../core/Handles.js";
import type { PixelData } from "../../layers/raster/types.js";
import type { PixelHighlightTarget, HighlightTarget } from "../types.js";
import type { LayerViewHighlightOptions } from "./types.js";
import type { HighlightOptionsProperties } from "../support/HighlightOptions.js";
import type { LayerViewProperties } from "./LayerView.js";

export interface ImageryLayerViewProperties extends LayerViewProperties {
  /**
   * Options for configuring the highlight. Use the [FeatureLikeLayerView.highlight()](https://developers.arcgis.com/javascript/latest/references/core/views/layers/FeatureLikeLayerView/#highlight) method on the layer view to highlight a feature
   *
   * > [!WARNING]
   * >
   * > **Known Limitations**
   * >
   * > The `highlightOptions` on layer views are only supported in [2D MapViews](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/). To
   * > configure highlights for a [3D SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/), use
   * > [SceneView.highlights](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/#highlights) instead.
   *
   * @deprecated since version 4.34. Use the [View.highlights](https://developers.arcgis.com/javascript/latest/references/core/views/View/#highlights) property instead.
   * @since 4.26
   * @see [highlight()](https://developers.arcgis.com/javascript/latest/references/core/views/layers/FeatureLikeLayerView/#highlight)
   * @see [Sample: Highlight SceneLayer](https://developers.arcgis.com/javascript/latest/sample-code/highlight-scenelayer/)
   * @example
   * // Features in the layerview will be highlighted with bright
   * // yellow colors in the map.
   * const layerView = await view.whenLayerView(layer);
   * layerView.highlightOptions = {
   *   color: [255, 255, 0, 1],
   *   haloOpacity: 0.9,
   *   fillOpacity: 0.2
   * };
   */
  highlightOptions?: HighlightOptionsProperties | null;
}

/**
 * Represents the [LayerView](https://developers.arcgis.com/javascript/latest/references/core/views/layers/LayerView/) of an [ImageryLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/ImageryLayer/)
 * after it has been added to a [Map](https://developers.arcgis.com/javascript/latest/references/core/Map/) in either a [MapView](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/), [Map component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-map/),
 * [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/) or [Scene component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-scene/).
 *
 * The ImageryLayerView is responsible for rendering [pixelData](https://developers.arcgis.com/javascript/latest/references/core/views/layers/ImageryLayerView/#pixelData) in the
 * [View](https://developers.arcgis.com/javascript/latest/references/core/views/View/). Pixel values can be manipulated to add color to an
 * [ImageryLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/ImageryLayer/).
 *
 * @since 4.0
 * @see [ImageryLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/ImageryLayer/)
 * @see [Sample - Access pixel values in an ImageryLayer](https://developers.arcgis.com/javascript/latest/sample-code/layers-imagery-pixelvalues/)
 */
export default abstract class ImageryLayerView extends LayerView {
  /**
   * Options for configuring the highlight. Use the [FeatureLikeLayerView.highlight()](https://developers.arcgis.com/javascript/latest/references/core/views/layers/FeatureLikeLayerView/#highlight) method on the layer view to highlight a feature
   *
   * > [!WARNING]
   * >
   * > **Known Limitations**
   * >
   * > The `highlightOptions` on layer views are only supported in [2D MapViews](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/). To
   * > configure highlights for a [3D SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/), use
   * > [SceneView.highlights](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/#highlights) instead.
   *
   * @deprecated since version 4.34. Use the [View.highlights](https://developers.arcgis.com/javascript/latest/references/core/views/View/#highlights) property instead.
   * @since 4.26
   * @see [highlight()](https://developers.arcgis.com/javascript/latest/references/core/views/layers/FeatureLikeLayerView/#highlight)
   * @see [Sample: Highlight SceneLayer](https://developers.arcgis.com/javascript/latest/sample-code/highlight-scenelayer/)
   * @example
   * // Features in the layerview will be highlighted with bright
   * // yellow colors in the map.
   * const layerView = await view.whenLayerView(layer);
   * layerView.highlightOptions = {
   *   color: [255, 255, 0, 1],
   *   haloOpacity: 0.9,
   *   fillOpacity: 0.2
   * };
   */
  get highlightOptions(): HighlightOptions | null | undefined;
  set highlightOptions(value: HighlightOptionsProperties | null | undefined);
  /**
   * An object that provides the user access to
   * [PixelBlock.pixels](https://developers.arcgis.com/javascript/latest/references/core/layers/support/PixelBlock/#pixels) and their values in the layer.
   * See the object specifications table below for details about each property. This object
   * is used as input in the [ImageryLayer.pixelFilter](https://developers.arcgis.com/javascript/latest/references/core/layers/ImageryLayer/#pixelFilter) function
   * for filtering and processing each pixel in the block.
   *
   * > [!WARNING]
   * >
   * > **Known Limitations**
   * >
   * > The `pixelData` is only supported in 2D [MapView](https://developers.arcgis.com/javascript/latest/references/core/views/MapView/).
   *
   * @since 5.0
   * @see [Sample - Access pixel values in an ImageryLayer](https://developers.arcgis.com/javascript/latest/sample-code/layers-imagery-pixelvalues/)
   */
  get pixelData(): PixelData | null | undefined;
  /**
   * Returns the map scale that corresponds to the source level of raster data.
   *
   * @returns Returns a promise that resolves to a number representing the map scale that corresponds to the source level of raster data.
   * @since 4.32
   */
  getSourceScale(): Promise<number>;
  /**
   * Highlights the given feature(s) in an ImageryLayerView.
   *
   * @param target - The feature(s) to highlight. When passing a graphic or array of graphics, each feature must
   *   have a valid `objectID`.
   * @param options - An object with the following properties.
   * @returns Returns a highlight handler with a `remove()` method that
   * can be called to remove the highlight.
   * @since 5.0
   * @see [View.highlights](https://developers.arcgis.com/javascript/latest/references/core/views/View/#highlights)
   * @see [Sample: Highlight SceneLayer](https://developers.arcgis.com/javascript/latest/sample-code/highlight-scenelayer/)
   * @example
   * // Highlight features based on a query result
   * // Add a new set of highlight options to the view's highlights collection
   * view.highlights.push({
   *   name: "forest",
   *   color: "#forestgreen",
   *   haloOpacity: 0.8,
   *   fillOpacity: 0.3
   * });
   *
   * // A handler can be used to remove any previous highlight when applying a new one
   * let highlight;
   *
   * view.whenLayerView(layer).then((layerView) => {
   *   let query = layer.createQuery();
   *   query.where = "Category = 'Forested'";
   *   layer.queryRasters(query).then((result) => {
   *     // Remove any previous highlight, if it exists
   *     highlight?.remove();
   *     // Apply the "forest" highlight options to the corresponding features
   *     highlight = layerView.highlight(result.features, { name: "forest" });
   *   });
   * });
   * @example
   * // highlight pixels between -50 and -40 or between 40 and 50 based on band 0 value
   * layerView.highlight({pixelRanges: [[-50,-40],[40,50]], bandId: 0});
   * @example
   * // highlight pixels - band 0 and band 3 pixel values are in the defined rectangle
   * layerView.highlight({
   *    xBandId: 0,
   *    yBandId: 3,
   *    pixelRanges: new Extent({ xmin: 20, xmax: 30, ymin: 210, ymax: 215 }),
   * });
   */
  abstract highlight(target: HighlightTarget | PixelHighlightTarget, options?: LayerViewHighlightOptions): ResourceHandle;
}