import type Collection from "../../core/Collection.js";
import type Sublayer from "../support/Sublayer.js";
import type { SublayerProperties } from "../support/Sublayer.js";
import type { ReadonlyArrayOrCollection } from "../../core/Collection.js";

export interface SublayersOwnerProperties {
  /**
   * A flat [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html) of all the tables
   * in the layer including the tables of its sublayers.
   * Apps can add them to a map as standalone tables.
   *
   * @since 4.30
   * @example
   * // Apps can add tables to a map as standalone tables
   * layer.subtables.forEach((subtable) => {
   *   const featureLayer = await subtable.createFeatureLayer();
   *   map.tables.add(featureLayer);
   * });
   */
  subtables?: ReadonlyArrayOrCollection<SublayerProperties> | null;
}

/** Mixin for [MapImageLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html) and [TileLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-TileLayer.html). */
export abstract class SublayersOwner {
  constructor(...args: any[]);
  /**
   * A flat [Collection](https://developers.arcgis.com/javascript/latest/api-reference/esri-core-Collection.html) of all the tables
   * in the layer including the tables of its sublayers.
   * Apps can add them to a map as standalone tables.
   *
   * @since 4.30
   * @example
   * // Apps can add tables to a map as standalone tables
   * layer.subtables.forEach((subtable) => {
   *   const featureLayer = await subtable.createFeatureLayer();
   *   map.tables.add(featureLayer);
   * });
   */
  get subtables(): Collection<Sublayer> | null | undefined;
  set subtables(value: ReadonlyArrayOrCollection<SublayerProperties> | null | undefined);
  /**
   * Returns a deep clone of a map service's
   * [sublayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html) as defined by the service.
   * This is useful for scenarios when the developer is unfamiliar with the
   * service sublayers and needs to "reset" the layer's sublayers to match
   * those defined by the service.
   *
   * @returns A collection of
   * [sublayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html) as defined by the map
   * service.
   * @example
   * Layer.fromPortalItem({
   *   portalItem: {
   *     portalId: "dbb9b48477444015912061b182f196b9"
   *   }
   * }).then(function(layer){
   *   let serviceSublayers = layer.createServiceSublayers();
   *   layer.sublayers = serviceSublayers;
   * });
   */
  createServiceSublayers(): Collection<Sublayer>;
  /**
   * Returns the sublayer with the given layerId.
   *
   * @param id - The [Sublayer.id](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-Sublayer.html#id)
   * of the sublayer.
   * @returns Returns the sublayer
   * at the given layer ID.
   * @example
   * // returns the sublayer with a layerId of 0
   * let sublayer0 = layer.findSublayerById(0);
   */
  findSublayerById(id: number): Sublayer | null | undefined;
}