import type AutoIntervalBinParameters from "./AutoIntervalBinParameters.js";
import type DateBinParameters from "./DateBinParameters.js";
import type FixedBoundariesBinParameters from "./FixedBoundariesBinParameters.js";
import type FixedIntervalBinParameters from "./FixedIntervalBinParameters.js";
import type StatisticDefinition from "./StatisticDefinition.js";
import type { ClonableMixin, ClonableMixinProperties } from "../../core/Clonable.js";
import type { JSONSupport, JSONSupportMixinProperties } from "../../core/JSONSupport.js";
import type { DatumTransformation } from "../../portal/jsonTypes.js";
import type { QueryMixin, QueryMixinProperties } from "./QueryMixin.js";
import type { IANATimeZone } from "../../time/types.js";
import type { FixedIntervalBinParametersProperties } from "./FixedIntervalBinParameters.js";
import type { FixedBoundariesBinParametersProperties } from "./FixedBoundariesBinParameters.js";
import type { DateBinParametersProperties } from "./DateBinParameters.js";
import type { AutoIntervalBinParametersProperties } from "./AutoIntervalBinParameters.js";
import type { StatisticDefinitionProperties } from "./StatisticDefinition.js";

export interface AttributeBinsQueryProperties extends JSONSupportMixinProperties, ClonableMixinProperties, QueryMixinProperties, Partial<Pick<AttributeBinsQuery, "binOrder" | "datumTransformation" | "lowerBoundaryAlias" | "outTimeZone" | "upperBoundaryAlias">> {
  /**
   * Bin parameters describe the characteristics of the bins, including their size and starting value. Each bin's size can either be specified by a parameter
   * or calculated dynamically. Additionally, bins can be based on either date or numeric values.
   */
  binParameters?: ((AutoIntervalBinParametersProperties & { type: "auto-interval" }) | (DateBinParametersProperties & { type: "date" }) | (FixedBoundariesBinParametersProperties & { type: "fixed-boundaries" }) | (FixedIntervalBinParametersProperties & { type: "fixed-interval" }));
  /**
   * The definitions for one or more field-based statistics to be calculated. For service-based queries, check the layer's
   * [query.queryAttributeBins.supportedStatistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-types.html#FeatureLayerCapabilities) capabilities to ensure that
   * the layer supports statistics queries.
   *
   * @example
   * // get the average temperature for each bin
   * let statisticDefinition = new StatisticDefinition({
   *   statisticType: "avg",
   *   onStatisticField: "temp",
   *   outStatisticFieldName: "temp_avg"
   * });
   *
   * // Query bins with fixed interval bin parameters based on field "temp" with 5 degrees interval.
   * const binQuery = new AttributeBinsQuery({
   *   binParameters: new FixedIntervalBinParameters({
   *     interval: 5, // the interval size for each bin. In this case, 5 degrees celsius
   *     field: "temp", // the field to bin, containing the temperature data
   *     start: 0, // the lower boundary of the first bin. 0 degrees celsius
   *     end: 30 // the upper boundary of the last bin. 30 degrees celsius
   *   }),
   *  // get the average temperature for each bin
   *  outStatistics: [statisticDefinition]
   * });
   */
  outStatistics?: StatisticDefinitionProperties[] | null;
}

export type BinParameters = AutoIntervalBinParameters | DateBinParameters | FixedBoundariesBinParameters | FixedIntervalBinParameters;

/**
 * This class configures parameters for the [queryAttributeBins](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#queryAttributeBins) method, which groups features in a layer or layer view into bins
 * based on numeric or date fields. This operation is useful for summarizing and analyzing large datasets by organizing them into meaningful groups, or bins, making it easier to detect patterns,
 * trends, and anomalies across different ranges or time periods.
 *
 * The [binParameters](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-AttributeBinsQuery.html#binParameters) property defines bin characteristics like size and start value, while the [outStatistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-AttributeBinsQuery.html#outStatistics) parameter specifies the information each bin provides.
 * Features can be filtered using a [where](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-AttributeBinsQuery.html#where) condition and a [spatial filter](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-AttributeBinsQuery.html#geometry). Bins are arranged consecutively with no gaps:
 * they are left-inclusive and right-exclusive, except for the last bin, which is right-inclusive. The method supports multiple statistical aggregations per bin and defaults to
 * a histogram of value frequencies/counts if no specific aggregations are provided in `outStatistics`.
 *
 * Bins are defined using one of the bin parameters, each supporting distinct parameters for handling boundaries between bins. Understanding the purpose of each bin parameter is
 * crucial for understanding binning and boundary settings. There are four types of bin parameters:
 * | Bin parameter type | Description |
 * | ------------------- | ----------- |
 * | [AutoIntervalBinParameters](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-AutoIntervalBinParameters.html) | You specify the number of [numBins](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-AutoIntervalBinParameters.html#numBins), [start](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-AutoIntervalBinParameters.html#start) and [end](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-AutoIntervalBinParameters.html#end) values of the binning. The bin size is calculated by dividing the dataset's range by this number of bins.|
 * | [FixedBoundariesBinParameters](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-FixedBoundariesBinParameters.html) | The bins strictly follow the specified [input values](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-FixedBoundariesBinParameters.html#boundaries). The first item in the array specifies the lower boundary of the first bin, while the last item specifies the upper boundary of the last bin. Intermediate values represent the lower boundaries of each bin. |
 * | [FixedIntervalBinParameters](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-FixedIntervalBinParameters.html) | The number of bins is not important, but the [interval](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-FixedIntervalBinParameters.html#interval) size must match the input data. Each bin will cover a range that exactly fits the specified interval. |
 * | [DateBinParameters](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-DateBinParameters.html) | The [intervals](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-DateBinParameters.html#interval) are based on calendar units. For example, with monthly intervals, each bin represents an entire month. |
 *
 * @since 4.32
 * @see [FeatureLayer#queryAttributeBins()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#queryAttributeBins)
 * @see [Sample - Attribute Bins Query](https://developers.arcgis.com/javascript/latest/sample-code/query-attribute-bins/)
 */
export default class AttributeBinsQuery extends AttributeBinsQuerySuperclass {
  constructor(properties?: AttributeBinsQueryProperties);
  /**
   * Bins can be returned in ascending or descending order. The default is `ascending`.
   *
   * @default "ascending"
   */
  binOrder?: "ascending" | "descending" | null;
  /**
   * Bin parameters describe the characteristics of the bins, including their size and starting value. Each bin's size can either be specified by a parameter
   * or calculated dynamically. Additionally, bins can be based on either date or numeric values.
   */
  get binParameters(): BinParameters;
  set binParameters(value: ((AutoIntervalBinParametersProperties & { type: "auto-interval" }) | (DateBinParametersProperties & { type: "date" }) | (FixedBoundariesBinParametersProperties & { type: "fixed-boundaries" }) | (FixedIntervalBinParametersProperties & { type: "fixed-interval" })));
  /**
   * Datum transformation used for projecting geometries in the query results when
   * [outSpatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-AttributeBinsQuery.html#outSpatialReference) is different than the layer's spatial reference.
   * Requires ArcGIS Server service 10.5 or greater.
   */
  accessor datumTransformation: DatumTransformation | null | undefined;
  /** Sets the name of the lower boundary property in the response. By default, the lower boundary is name `lowerBoundary` and indicates the value at the edge of each bin. */
  accessor lowerBoundaryAlias: string | null | undefined;
  /**
   * The definitions for one or more field-based statistics to be calculated. For service-based queries, check the layer's
   * [query.queryAttributeBins.supportedStatistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-types.html#FeatureLayerCapabilities) capabilities to ensure that
   * the layer supports statistics queries.
   *
   * @example
   * // get the average temperature for each bin
   * let statisticDefinition = new StatisticDefinition({
   *   statisticType: "avg",
   *   onStatisticField: "temp",
   *   outStatisticFieldName: "temp_avg"
   * });
   *
   * // Query bins with fixed interval bin parameters based on field "temp" with 5 degrees interval.
   * const binQuery = new AttributeBinsQuery({
   *   binParameters: new FixedIntervalBinParameters({
   *     interval: 5, // the interval size for each bin. In this case, 5 degrees celsius
   *     field: "temp", // the field to bin, containing the temperature data
   *     start: 0, // the lower boundary of the first bin. 0 degrees celsius
   *     end: 30 // the upper boundary of the last bin. 30 degrees celsius
   *   }),
   *  // get the average temperature for each bin
   *  outStatistics: [statisticDefinition]
   * });
   */
  get outStatistics(): StatisticDefinition[] | null | undefined;
  set outStatistics(value: StatisticDefinitionProperties[] | null | undefined);
  /**
   * Defines the [IANA time zone](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones) used for bin calculations when the bin parameter field is a date field.
   * If not specified, the UTC time zone is used for binning calculations.
   * When a time zone is specified, dates and times will be adjusted according to that IANA time zone.
   *
   * @see [wikipedia - List of tz database time zones](https://en.wikipedia.org/wiki/List_of_tz_database_time_zones)
   * @example
   * // Query bins with date interval bin parameters based on field "date" with monthly intervals.
   * const binQuery = new AttributeBinsQuery({
   *   binParameters: new DateBinParameters({
   *     interval: 3,
   *     field: "RecordedDate",
   *     start: new Date(Date.UTC(1980, 0, 2, 0, 0)),
   *     end: new Date(Date.UTC(1980, 2, 1, 0, 0)),
   *     number: "1",
   *     unit: "months"
   *   }),
   *   outTimeZone: "America/New_York" // Get the binning results in Eastern Time Zone
   * });
   */
  accessor outTimeZone: IANATimeZone | null | undefined;
  /** Sets the name of the upper boundary property in the response. By default, the upper boundary is name `upperBoundary` and indicates the value at the edge of each bin. */
  accessor upperBoundaryAlias: string | null | undefined;
}
declare const AttributeBinsQuerySuperclass: typeof JSONSupport & typeof ClonableMixin & typeof QueryMixin