import type Accessor from "../../../core/Accessor.js";
import type Collection from "../../../core/Collection.js";
import type Layer from "../../../layers/Layer.js";
import type LayerView from "../../../views/layers/LayerView.js";
import type { MapViewOrSceneView } from "../../../views/MapViewOrSceneView.js";
import type { LegendElement } from "../../types.js";

export interface ActiveLayerInfoProperties extends Partial<Pick<ActiveLayerInfo, "children" | "hideLayersNotInCurrentView" | "layer" | "layerView" | "legendElements" | "parent" | "respectLayerVisibility" | "sublayerIds" | "title" | "view">> {}

/**
 * ActiveLayerInfo is added to or removed from the collection of
 * [Legend#activeLayerInfos](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend.html#activeLayerInfos) as layers become visible or
 * invisible in the view. You can use this module to make the [Legend](https://developers.arcgis.com/javascript/latest/references/map-components/arcgis-legend/) more interactive.
 *
 * @since 4.11
 */
export default abstract class ActiveLayerInfo extends Accessor {
  /**
   * A collection of child activeLayerInfos. This only applies to renderers of
   * [Sublayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html) or the children
   * of [GroupLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GroupLayer.html).
   */
  accessor children: Collection<ActiveLayerInfo>;
  /**
   * The CSS filter string for the effects of the active layer.
   *
   * @since 4.34
   */
  get cssEffectFilter(): string | null | undefined;
  /**
   * When `true`, layers will only be shown in the legend if
   * they are visible in the view's extent. When data from a layer
   * is not visible in the view, the layer's legend information
   * will be hidden.
   *
   * To hide layers completely
   * from the legend, you should set the `legendEnabled` property of
   * the layer to `false`.
   *
   * @default false
   * @since 4.21
   * @see [respectLayerVisibility](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend-support-ActiveLayerInfo.html#respectLayerVisibility)
   * @example
   * // layers not displayed in the view
   * // will not be shown in the legend
   * legend.hideLayersNotInCurrentView = true;
   */
  accessor hideLayersNotInCurrentView: boolean;
  /**
   * Indicates if the legend's display of the layer's renderer is driven by the scale of the view.
   * This is true of [Sublayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html) renderers, any renderer that uses
   * a `valueExpression` (Arcade expression), [DotDensityRenderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-DotDensityRenderer.html), and
   * layers that have [FeatureReductionLayer#featureReduction](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-FeatureReductionLayer.html#featureReduction) enabled.
   */
  get isScaleDriven(): boolean;
  /** The layer represented by the ActiveLayerInfo object. */
  accessor layer: Layer;
  /** The layerView represented by the ActiveLayerInfo object's layer. */
  accessor layerView: LayerView;
  /**
   * The legendElements is constructed using the layer [Renderer](https://developers.arcgis.com/javascript/latest/api-reference/esri-renderers-Renderer.html). It reflects the actual
   * structure of the legend.
   */
  accessor legendElements: LegendElement[];
  /**
   * The opacity of the layer or parent element.
   *
   * @since 4.17
   */
  get opacity(): number;
  /** The ActiveLayerInfo of the parent [Sublayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html) or [GroupLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GroupLayer.html). */
  accessor parent: ActiveLayerInfo | null | undefined;
  /**
   * Indicates if the activeLayerInfo is ready. It is set to `true` when all its [legendElements](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend-support-ActiveLayerInfo.html#legendElements) are computed.
   * It is set to `false` when the layer renderer changes so that the legendElements can recomputed.
   */
  get ready(): boolean;
  /**
   * Determines whether to respect the properties of the layers in the map that
   * control the legend's visibility (`minScale`, `maxScale`, `legendEnabled`).
   * By default, a layer's legend elements **will
   * not render** in the legend given the following conditions:
   *
   * - The [FeatureLayer#legendEnabled](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#legendEnabled) property
   * is set to `false`.
   * - If the view's scale is outside the visibility range
   * defined by the [ScaleRangeLayer#minScale](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ScaleRangeLayer.html#minScale) and
   * [ScaleRangeLayer#maxScale](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-mixins-ScaleRangeLayer.html#maxScale) properties.
   *
   * When the `respectLayerVisibility` property of the legend is set to `false`, the legend elements for each
   * layer in the map will always display, thus disregarding the `minScale`, `maxScale`,
   * and `legendEnabled` properties for each layer in the map.
   *
   * @default true
   * @since 4.13
   * @see [hideLayersNotInCurrentView](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend-support-ActiveLayerInfo.html#hideLayersNotInCurrentView)
   * @example
   * // Always displays legend elements for the map's layers
   * // regardless of their minScale, maxScale, and legendEnabled properties
   * legend.respectLayerVisibility = false;
   */
  accessor respectLayerVisibility: boolean;
  /** The scale of the view instance in which the Legend is rendered. */
  get scale(): number;
  /**
   * Only applies if the [layer](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend-support-ActiveLayerInfo.html#layer) is a [MapImageLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html). An array of
   * MapImageLayer [Sublayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html) IDs for which to display legend information. For example,
   * if a MapImageLayer contains 100 sublayers, but you want to display the legend for two sublayers,
   * then specifying the IDs of both sublayers will allow the Legend to only display legend information for those sublayers.
   *
   * @since 4.23
   * @example
   * // Only displays legend items for sublayers 1 and 2
   * activeLayerInfo.sublayerIds = [1, 2];
   */
  accessor sublayerIds: number[];
  /**
   * The text string that represents the legend's title. This value is read from the `layerInfo` of the
   * corresponding layer in the legend. If not provided, this value comes from the
   * [Layer#title](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-Layer.html#title).
   */
  accessor title: string | null | undefined;
  /**
   * The version of the ActiveLayerInfo. It increases by `1` whenever [ready](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Legend-support-ActiveLayerInfo.html#ready) property of ActiveLayerInfo changes.
   * This property should watched in the view for ActiveLayerInfo changes and update the DOM accordingly.
   */
  get version(): number;
  /** The view in which the Legend is rendered. */
  accessor view: MapViewOrSceneView;
}