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

/** @since 5.0 */
export interface DynamicMapLayerProperties extends Partial<Pick<DynamicMapLayer, "gdbVersion" | "mapLayerId">> {}

/**
 * A dynamic map layer refers to a layer published in a map service that has
 * dynamic layers enabled.
 * This layer type may be used to create multiple [Sublayer.sublayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#sublayers)
 * that point to the same service layer, but are assigned different definition
 * expressions, renderers, and other properties.
 *
 * @since 5.0
 * @see [Sample - MapImageLayer: create dynamic map layers](https://developers.arcgis.com/javascript/latest/sample-code/layers-dynamicmaplayer/)
 * @see [ArcGIS REST API - Dynamic map layer](https://developers.arcgis.com/rest/services-reference/enterprise/layer-source-object/#dynamic-map-layer)
 * @example
 * // Creates two sublayers that point to the same map service layer.
 * // Each layer presents different features in the data using
 * // definition expressions and renderers.
 * let mapImageLayer = new MapImageLayer({
 *   sublayers: [{
 *     id: 10,
 *     definitionExpression: "POP < 50000",
 *     renderer: {
 *       type: "class-breaks"  // autocasts as new ClassBreaksRenderer()
 *       // set renderer properties here
 *     },
 *     source: {
 *       type: "map-layer",
 *       mapLayerId: 0
 *     }
 *   }, {
 *     id: 11,
 *     definitionExpression: "GRADUATED_HS > 0.449",
 *     renderer: {
 *       type: "class-breaks"  // autocasts as new ClassBreaksRenderer()
 *       // set renderer properties here
 *     },
 *     source: {
 *       type: "map-layer",
 *       mapLayerId: 0
 *     }
 *   }]
 * });
 */
export default class DynamicMapLayer extends JSONSupport {
  constructor(properties?: DynamicMapLayerProperties);
  /**
   * An optional property for specifying the GDB version.
   *
   * @since 5.0
   */
  accessor gdbVersion: string;
  /**
   * The [Sublayer.id](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#id) of the service sublayer.
   *
   * @since 5.0
   */
  accessor mapLayerId: number;
  /**
   * This value is always `map-layer` and is inferred when
   * the `mapLayerId` property is set.
   *
   * @since 5.0
   */
  get type(): "map-layer";
}