import type Point from "../../geometry/Point.js";
import type QuantizationParameters from "./QuantizationParameters.js";
import type StatisticDefinition from "./StatisticDefinition.js";
import type { JSONSupport, JSONSupportMixinProperties } from "../../core/JSONSupport.js";
import type { DatumTransformation, SQLFormat } from "../../portal/jsonTypes.js";
import type { QueryMixin, QueryMixinProperties } from "./QueryMixin.js";
import type { ObjectId } from "../../views/types.js";
import type { StatisticDefinitionProperties } from "./StatisticDefinition.js";
import type { PointProperties } from "../../geometry/Point.js";
import type { QuantizationParametersProperties } from "./QuantizationParameters.js";

export interface QueryProperties extends JSONSupportMixinProperties, QueryMixinProperties, Partial<Pick<Query, "aggregateIds" | "datumTransformation" | "gdbVersion" | "geometryPrecision" | "groupByFieldsForStatistics" | "having" | "maxAllowableOffset" | "maxRecordCountFactor" | "multipatchOption" | "num" | "objectIds" | "orderByFields" | "outFields" | "parameterValues" | "rangeValues" | "relationParameter" | "returnCentroid" | "returnDistinctValues" | "returnExceededLimitFeatures" | "returnGeometry" | "returnM" | "returnQueryGeometry" | "returnZ" | "sqlFormat" | "start" | "text">> {
  /**
   * The historic moment to query. This parameter applies only if the `supportsQueryWithHistoricMoment`
   * capability of the service being queried is `true`. This setting is provided in the layer resource.
   */
  historicMoment?: (Date | number | string) | null;
  /**
   * The definitions for one or more field-based statistics to be calculated. If `outStatistics` is specified the only other query parameters
   * that should be used are [groupByFieldsForStatistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#groupByFieldsForStatistics), [orderByFields](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#orderByFields), [returnDistinctValues](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#returnDistinctValues),
   * [geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#geometry), [text](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#text), [timeExtent](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#timeExtent) and [where](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#where).
   *
   * > [!WARNING]
   * >
   * > **Known Limitations**
   * >
   * > For service-based queries, `outStatistics` is only supported on layers where `supportsStatistics = true`.
   *
   * @example
   * let query = new Query();
   * let statisticDefinition = new StatisticDefinition({
   *   statisticType: "sum",
   *   onStatisticField: "POP2000",
   *   outStatisticFieldName: "TotalPop"
   * });
   *
   * query.outStatistics = [ statisticDefinition ];
   */
  outStatistics?: StatisticDefinitionProperties[] | null;
  /**
   * Specifies the pixel level to be identified on the X and Y axis. Defaults to the base resolution of the
   * dataset if not specified. Applicable only to Image Service layers.
   */
  pixelSize?: PointProperties | null;
  /**
   * Used to project the geometry onto a virtual grid, likely representing
   * pixels on the screen. Geometry coordinates are converted to integers
   * by building a grid with a resolution matching the `quantizationParameters.tolerance`.
   * Each coordinate is then snapped to one pixel on the grid.
   *
   * > [!WARNING]
   * >
   * > **Known Limitations**
   * >
   * > Only supported with ArcGIS Online hosted services or ArcGIS Enterprise 10.6.1 services.
   *
   * @example
   * let query = new Query();
   * query.quantizationParameters = {
   *   mode: "view",
   *   originPosition: "upper-left",
   *   tolerance: 4820,
   *   extent: layer.fullExtent
   * };
   */
  quantizationParameters?: QuantizationParametersProperties | null;
}

export interface RangeValue {
  /** The range id. */
  name: string;
  /** Single value or value range. */
  value: number | [
      number,
      number
  ];
}

/**
 * * [Attribute queries](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#attribute)
 *   * [Numbers and strings](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#number-string-query)
 *   * [Date and times](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#date-query)
 * * [Spatial queries](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#spatial)
 * * [Temporal queries](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#temporal)
 * * [Statistic queries](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#statistic)
 *
 * This class defines parameters for executing queries for features from a layer or layer view.
 * Once a Query object's properties are defined, it can then be passed into an executable function, which will
 * return the features in a [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-FeatureSet.html).
 *
 * There are three types of queries: attribute, spatial, and statistic queries. You can query for features
 * in one of these categories or use elements of each in a single query.
 *
 * <span id="attribute"></span>
 * ## Attribute queries
 *
 * <span id="number-string-query"></span>
 * #### Number and strings
 * To query features based on attribute values, specify a SQL where clause in the [where](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#where) property.
 * You can optionally use the [text](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#text) property for a `LIKE` statement. Setting the [outFields](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#outFields)
 * of the query will limit the attributes returned from the query. This can improve the speed of the query
 * if your app doesn't require all the attributes for each feature.
 *
 * For example, you can use [where](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#where) to query all counties in the state of Washington
 * from a layer representing U.S. Counties:
 *
 * ```js
 * const query = featureLayer.createQuery();
 * query.where = "STATE_NAME = 'Washington'";
 * query.outFields = [ "STATE_NAME", "COUNTY_NAME", "POPULATION", "(POPULATION / AREA) as 'POP_DENSITY'" ];
 *
 * // To return a feature set containing the attributes: STATE_NAME, COUNTY_NAME, POPULATION, and POP_DENSITY.
 * const featureSet = await featureLayer.queryFeatures(query)
 * ```
 * <span id="date-query"></span>
 * #### Date and times
 *
 * When querying features based on `date`, `date-only`, `time-only` and `timestamp-offset` field types
 * the `DATE`, `TIMESTAMP` or `TIME` SQL functions should be used to make sure the query returns correct results.
 * The following snippets demonstrate how the date functions can be constructed with the functions mentioned above.
 *
 * ```js
 * <DateField> = DATE 'YYYY-MM-DD'
 * <DateField> = TIMESTAMP 'YYYY-MM-DD HH:MI:SS'
 * <DateOnlyField> = DATE 'YYYY-MM-DD'
 * <TimeOnlyField> = TIME 'HH:MM:SS'
 * <TimestampOffsetField> = TIMESTAMP 'YYYY-MM-DD HH:MI:SS +/-UTC offset'
 * ```
 *
 * Date values are stored as epoch values in `date` field. Epoch time describes a point in time as the number
 * of seconds since `00:00:00 Thursday, 1 January 1970 (UTC)`.
 * A `date` field can be associated with a specific time zone. When querying values from a date field, you may need to convert dates to match the time zone of the field.
 * Use the [FieldsIndex#getTimeZone()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-support-FieldsIndex.html#getTimeZone) method to identify the time zone of a date field.
 * For example, if your service has two date fields, one in `America/Los_Angeles` and the other in `America/New_York`, then date queries need to be crafted specifically for each field.
 * If the desired query date is `01/01/2012 11:20:00 PM GMT` then the resulting query could be:
 *
 * `query.where = "DateTime_PST = TIMESTAMP '2012-01-01 15:20:00"`, or
 *
 * `query.where = "DateTime_EST = TIMESTAMP '2012-01-01 18:20:00"`.
 *
 * ```js
 * // Query for features that recorded on January 1, 2012 9:00:00 AM GMT
 * // DateTime_PST date field values are in PST. Must adjust the epoch values to PST
 *
 * const queryDate = new Date(1325408400000); // 01/01/2012 9:00:00 AM GMT
 * let queryFields = ["DateTime_PST"];
 *
 * // get the timezone of the DateTime_PST date field
 * const fieldTimeZone = layer.fieldsIndex.getTimeZone("DateTime_PST") ;
 *
 * // we need to adjust the date value to match the time zone of the field.
 * const where = `DateTime_PST < DATE '${getDateForTimeZone(queryDate, fieldTimeZone)}'`
 * layerView.filter = new FeatureFilter({
 *   where
 * });
 * runQueries(where, queryFields);
 *
 * // This function conveniently formats a dates in terms of the parsed time zone.
 * function getDateForTimeZone(queryDate, timezone) {
 *
 *   // adjust the given date field to the timezone of the date field
 *   const zonedDate = new Date(
 *     queryDate.toLocaleString("en-US", {
 *       timeZone: timezone
 *     })
 *   );
 *   const pad = (value) => String(value).padStart(2, "0");
 *   const month = pad(zonedDate.getMonth() + 1);
 *   const day = pad(zonedDate.getDate())
 *   const year = zonedDate.getFullYear();
 *   const hour = pad(zonedDate.getHours());
 *   const minutes = pad(zonedDate.getMinutes());
 *   const seconds = pad(zonedDate.getSeconds());
 *
 *   return `${year}-${month}-${day} ${hour}:${minutes}:${seconds}`;
 * }
 * ```
 *
 * Please refer to [Querying Feature Services: Date-Time Queries](https://www.esri.com/arcgis-blog/products/api-rest/data-management/querying-feature-services-date-time-queries/) and
 * [REST API - Date-time queries](https://developers.arcgis.com/rest/services-reference/enterprise/query-feature-service-layer/#date-time-queries) documents
 * to learn more about how to query date-time values.
 *
 * <span id="spatial"></span>
 * ## Spatial queries
 *
 * You can query features by geometry/location. While [where](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#where) is not required in this
 * workflow, you can use `where` as part of the query to get more refined results.
 *
 * To execute a spatial query, you must set the [geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#geometry) parameter to a
 * [Geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Geometry.html) object and specify a valid [spatialRelationship](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#spatialRelationship).
 * You can optionally provide a query [distance](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#distance) and [units](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#units) to query features against a buffer
 * around the given geometry.
 *
 * For example, to query for all features within 2 miles of a mouse move, you would do the following:
 *
 * ```js
 * view.on("pointer-move", async (event) => {
 *   const query = featureLayer.createQuery();
 *   query.geometry = view.toMap(event);  // the point location of the pointer
 *   query.distance = 2;
 *   query.units = "miles";
 *   query.spatialRelationship = "intersects";  // this is the default
 *   query.returnGeometry = true;
 *   query.outFields = ["POPULATION"];
 *
 *   // The following line returns features within two miles of the pointer's location
 *   const { features } = await featureLayer.queryFeatures(query);
 * });
 * ```
 *
 * You could also use `where`, for example, to return all features with a population greater than 10,000 within
 * the 2-mile buffer.
 *
 * > [!WARNING]
 * >
 * > **Known Limitations**
 * >
 * > For client side spatial queries on 3D Object SceneLayerView the [Extent](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Extent.html) of the feature
 * > is used when evaluating the spatial relationship with the [geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#geometry). This means that a feature might be
 * > returned from the query, even though its footprint is not in a spatial relationship with the [geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#geometry).
 *
 * <span id="temporal"></span>
 * ## Temporal queries
 *
 * You can query features based on a given time range by specifying the [timeExtent](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#timeExtent) property. The temporal query will return
 * results only if the feature service is published with [FeatureLayer#timeInfo](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#timeInfo) information. The temporal
 * query can also be combined with attribute and geometry queries.
 *
 * For example, you can use [timeExtent](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#timeExtent) and [where](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#where) parameters to query specified hurricane tracks
 * within a given time extent.
 *
 * ```js
 * // query katrina tracks that took place in Aug 30 - Aug 31, 2005
 * const query = new Query({
 *   outFields: ["Name, WindSpeed"],
 *   where: "Name = 'Katrina'",
 *   timeExtent: {
 *     start: new Date(2005, 7, 30),
 *     end: new Date(2005, 7, 31)
 *   }
 * });
 * const { features } = await featureLayer.queryFeatures(query);
 * ```
 *
 * <span id="statistic"></span>
 * ## Statistic queries
 *
 * Rather than return individual features from a query, you can return statistics
 * for field attributes and expressions. Statistic queries are defined by the [outStatistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#outStatistics)
 * parameter, which requires an array of [StatisticDefinition](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-StatisticDefinition.html) objects.
 *
 * For example, you can query for the average and total population of counties in the layer mentioned above
 * in the following manner:
 *
 * ```js
 *
 * // query for the sum of the population in all features
 * const sumPopulation = {
 *   onStatisticField: "POP_2015",  // service field for 2015 population
 *   outStatisticFieldName: "Pop_2015_sum",
 *   statisticType: "sum"
 * };
 *
 * // query for the average population in all features
 * const avgPopulation = {
 *   onStatisticField: "POP_2015",  // service field for 2015 population
 *   outStatisticFieldName: "Pop_2015_avg",
 *   statisticType: "avg"
 * };
 *
 * // Notice that you can pass a SQL expression as a field name to calculate statistics
 * const populationChangeDefinition = {
 *   onStatisticField: "POP_2015 - POP_2010",  // service field for 2015 population
 *   outStatisticFieldName: "avg_pop_change_2015_2010",
 *   statisticType: "avg"
 * };
 *
 * const query = layer.createQuery();
 * query.where = "STATE_NAME = 'Washington'";
 * query.outStatistics = [sumPopulation, avgPopulation, populationChangeDefinition];
 *
 * const { feature } = await featureLayer.queryFeatures(query);
 * const { attributes } = features[0];
 *
 * console.log(`The total population in WA is ${attributes.Pop_2015_sum}`);
 * console.log(`The average population in WA counties is ${attributes.Pop_2015_avg}`);
 * console.log(`The average population change in WA counties is ${attributes.avg_pop_change_2015_2010}`);
 * ```
 *
 * <span id="working-with-results"></span>
 * ## Working with results
 *
 * Query results can be used in a number of ways depending on the use case. Consider the following
 * parameters which impact the format of the resulting feature set.
 *
 * * [returnGeometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#returnGeometry) - Returning a geometry is useful for displaying results back
 *   in the view as graphics, or for conducting further spatial analysis. If the geometry isn't necessary
 *   in your workflow, then don't request it to improve app performance.
 * * [outStatistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#outStatistics) - Querying for statistics will never return features from the layer,
 *   only an object with number properties for the requested statistics.
 * * [returnDistinctValues](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#returnDistinctValues) - Returns the unique values that exist in a field as an
 *   array of strings, so no features are returned when this parameter is true.
 *
 * > [!WARNING]
 * >
 * > The fields in the query needs to be available and listed in the [FeatureLayerView#availableFields](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-FeatureLayerView.html#availableFields) or [SceneLayerView#availableFields](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-SceneLayerView.html#availableFields).
 * > Define them either in [FeatureLayer#outFields](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#outFields) or [SceneLayer#outFields](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#outFields).
 *
 * @since 4.20
 * @see [FeatureLayer#createQuery()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#createQuery)
 * @see [FeatureLayer#queryFeatures()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#queryFeatures)
 * @see [FeatureLayerView#queryFeatures()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-FeatureLayerView.html#queryFeatures)
 * @see [CSVLayer#queryFeatures()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html#queryFeatures)
 * @see [SceneLayer#queryFeatures()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html#queryFeatures)
 * @see [SceneLayerView#queryFeatures()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-SceneLayerView.html#queryFeatures)
 * @see [Query and filter guide](https://developers.arcgis.com/javascript/latest/query-filter/)
 * @see [Sample - Query statistics client-side by distance](https://developers.arcgis.com/javascript/latest/sample-code/featurelayerview-query-distance/)
 * @see [Sample - Query statistics by geometry](https://developers.arcgis.com/javascript/latest/sample-code/featurelayerview-query-geometry/)
 * @see [Sample - Query statistics client-side](https://developers.arcgis.com/javascript/latest/sample-code/featurelayerview-query-stats/)
 * @see [query](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-query.html)
 */
export default class Query extends QuerySuperclass {
  constructor(properties?: QueryProperties);
  /**
   * An array of Object IDs representing [aggregate](https://developers.arcgis.com/javascript/latest/api-reference/esri-Graphic.html#isAggregate) (i.e. cluster) graphics. This property should be used to query features represented
   * by one or more cluster graphics with the given Object IDs.
   *
   * This is useful in the following scenarios:
   *
   * - To display features included in the cluster as a collection of graphics.
   * - To push clustered features to the view's popup for browsing.
   * - To display statistics of features included in the cluster in the popup.
   *
   * > [!WARNING]
   * >
   * > **Known Limitations**
   * >
   * > This property only applies to [LayerView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html) query methods. Support for server-side
   * > queries is being considered for a future release.
   *
   * @example
   * // Will execute query for features represented by the clusterGraphic
   * if (clusterGraphic.isAggregate) {
   *   query.aggregateIds = [clusterGraphic.getObjectId()];
   * }
   */
  accessor aggregateIds: ObjectId[] | null | undefined;
  /**
   * Datum transformation used for projecting geometries in the query results when
   * [outSpatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#outSpatialReference) is different than the layer's spatial reference.
   * Requires ArcGIS Server service 10.5 or greater.
   */
  accessor datumTransformation: DatumTransformation | null | undefined;
  /** Specifies the geodatabase version to display for feature service queries. */
  accessor gdbVersion: string | null | undefined;
  /** Specifies the number of decimal places for geometries returned by the [JSON query operation](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-query.html#executeQueryJSON). */
  accessor geometryPrecision: number | null | undefined;
  /**
   * Used only in [statistical queries](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#statistic). When one or more field names are provided in this property, the output
   * statistics will be grouped based on unique values from those fields. This is only valid when
   * [outStatistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#outStatistics) has been defined.
   *
   * @example
   * query.outStatistics = [{
   *   onStatisticField: "CUSTOMERS",
   *   outStatisticFieldName: "avg_customers",
   *   statisticType: "avg"
   * }, {
   *   onStatisticField: "RATING",
   *   outStatisticFieldName: "min_rating",
   *   statisticType: "min"
   * }, {
   *   onStatisticField: "1=1",
   *   outStatisticFieldName: "total_businesses",
   *   statisticType: "count"
   * }];
   * query.groupByFieldsForStatistics = [ "region" ];
   *
   * // query the above stats for each region in the layer
   * layer.queryFeatures(query).then(displayResults);
   */
  accessor groupByFieldsForStatistics: string[] | null | undefined;
  /**
   * A condition used with [outStatistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#outStatistics) and [groupByFieldsForStatistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#groupByFieldsForStatistics)
   * to limit query results to groups that
   * satisfy the aggregation function(s).
   *
   * The following aggregation functions are supported in this clause: `MIN` | `MAX` | `AVG` | `SUM` | `STDDEV` | `COUNT` | `VAR`
   *
   * Aggregation functions used in `having` must be included in the `outStatistics` as well. See the snippet below for an example
   * of how this works.
   *
   * For service-based layer queries, this parameter applies only if the [supportsHavingClause](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities) property of the layer is `true`.
   * This property is supported on all [LayerView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html) queries.
   *
   * @see [ArcGIS Blog - Querying Feature Services: Having Clause](https://www.esri.com/arcgis-blog/products/api-rest/data-management/querying-feature-services-having-clause/)
   * @see [ArcGIS REST API documentation](https://developers.arcgis.com/rest/services-reference/query-feature-service-layer-.htm)
   * @example
   * query.outStatistics = [{
   *   onStatisticField: "CUSTOMERS",
   *   outStatisticFieldName: "avg_customers",
   *   statisticType: "avg"
   * }, {
   *   onStatisticField: "RATING",
   *   outStatisticFieldName: "min_rating",
   *   statisticType: "min"
   * }, {
   *   onStatisticField: "1=1",
   *   outStatisticFieldName: "total_businesses",
   *   statisticType: "count"
   * }];
   * query.groupByFieldsForStatistics = [ "region" ];
   * query.having = "AVG(CUSTOMERS) >= 1,000 AND MIN(RATING) >= 3";
   *
   * // query the above stats for all regions where
   * // the average number of daily customers per business is
   * // greater than 1,000 and the minimum customer rating
   * // for a business within the region is 3
   * layer.queryFeatures(query).then(displayResults);
   */
  accessor having: string | null | undefined;
  /**
   * The historic moment to query. This parameter applies only if the `supportsQueryWithHistoricMoment`
   * capability of the service being queried is `true`. This setting is provided in the layer resource.
   */
  get historicMoment(): Date | null | undefined;
  set historicMoment(value: (Date | number | string) | null | undefined);
  /**
   * The maximum distance in units of [outSpatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#outSpatialReference) used for
   * generalizing geometries returned by the query operation. It limits how far any part of the
   * generalized geometry can be from the original geometry. If `outSpatialReference` is not defined,
   * the spatialReference of the data is used.
   *
   * > [!WARNING]
   * >
   * > **Known Limitations**
   * >
   * > This property does not apply to [LayerView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-LayerView.html) or [CSVLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html) queries.
   */
  accessor maxAllowableOffset: number | null | undefined;
  /**
   * When set, the maximum number of features returned by the query will equal the
   * `maxRecordCount` of the service multiplied by this factor. The value of this
   * property may not exceed `5`.
   *
   * For example, if the `maxRecordCount` of your feature service is `2000`, and you set
   * the `maxRecordCountFactor` to `5`, then the maximum number of features that could be
   * returned by the query is `10000`.
   *
   * > [!WARNING]
   * >
   * > **Known Limitations**
   * >
   * > Only supported with ArcGIS Online hosted services or ArcGIS Enterprise 10.6 services and higher.
   *
   * @default 1
   */
  accessor maxRecordCountFactor: number;
  /**
   * Parameter dictates how the geometry of a multipatch feature will be returned.
   * Currently, the only supported value is `xyFootprint`. If indicated, the xy footprint of each multipatch geometry will be
   * returned in the result.
   *
   * @example
   * // url to the layer of interest to query
   * const queryUrl = "https://sampleserver6.arcgisonline.com/arcgis/rest/services/Notes/FeatureServer/0";
   *
   * const queryObject = new Query({
   *   objectIds: [22],
   *   multipatchOption: "xyFootprint",
   *   outFields: ["*"],
   *   returnGeometry: true
   * });
   *
   * // call the executeQueryJSON() method
   * query.executeQueryJSON(queryUrl, queryObject).then(function(results){
   *   // results.graphics contains the graphics returned from query
   * });
   */
  accessor multipatchOption: "xyFootprint" | null | undefined;
  /**
   * The number of features to retrieve. This option should be used in conjunction with the [start property](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#start). Use this to
   * implement paging (i.e. to retrieve "pages" of results when querying).
   *
   * If not provided, but an instance of Query has a `start` property, then the default value of `num` is 10.
   * If neither `num` nor `start` properties are provided, then the default value of `num` is equal to the
   * `maxRecordCount` of the service, which can be found at the REST endpoint of the FeatureLayer.
   */
  accessor num: number | null | undefined;
  /** An array of ObjectIDs to be used to query for features in a layer. */
  accessor objectIds: ObjectId[] | null | undefined;
  /**
   * One or more field names used to order the query results. Specify `ASC` (ascending) or `DESC`
   * (descending) after the field name to control the order. The default order is `ASC`.
   *
   * > [!WARNING]
   * >
   * > **Known Limitations**
   * >
   * > If querying a [MapImageLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html), then `supportsAdvancedQueries` must be `true` on the service.
   * > For [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html), `FeatureLayer.capabilities.queryRelated.supportsOrderBy` must be `true`.
   *
   * @see [FeatureLayer#capabilities](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities)
   * @example query.orderByFields = ["STATE_NAME DESC"];
   */
  accessor orderByFields: string[] | null | undefined;
  /**
   * Attribute fields to include in the [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-FeatureSet.html). Fields must exist in the service layer. You must list actual
   * field names rather than field aliases. You may, however, use field aliases when you display
   * the results of the query.
   *
   * When specifying the output fields, you should limit the fields to only those you expect to use in the
   * query or the results. The fewer fields you include, the smaller the payload size, and therefore the faster the response of the query.
   *
   * You can also specify SQL expressions as `outFields` to calculate new values server side for the query results. See the
   * example snippets below for an example of this.
   *
   * Each query must have access to the `Shape` and `ObjectId` fields for a layer. However, the list of outFields does
   * not need to include these two fields.
   *
   * > [!WARNING]
   * >
   * > **Known Limitations**
   * >
   * > If specifying outFields as expressions on a feature service-based [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html), the service capabilities
   * > `advancedQueryCapabilities.supportsOutFieldSQLExpression` and `useStandardizedQueries` must both be true.
   *
   * @example
   * // query for field attributes
   * query.outFields = [ "NAME", "STATE_ABBR", "POP04" ];
   * @example
   * // query for data returned from an expressions and other fields as the following field names
   * // POP_CHANGE_2020, NAME, POP2020
   * // where POP_CHANGE_2020 represents the population change from 2010 - 2020
   * query.outFields = [ "( (POP2020 - POP2010) / POP2010 ) * 100 as POP_CHANGE_2020", "NAME", "POP2020" ]
   */
  accessor outFields: string[] | null | undefined;
  /**
   * The definitions for one or more field-based statistics to be calculated. If `outStatistics` is specified the only other query parameters
   * that should be used are [groupByFieldsForStatistics](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#groupByFieldsForStatistics), [orderByFields](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#orderByFields), [returnDistinctValues](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#returnDistinctValues),
   * [geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#geometry), [text](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#text), [timeExtent](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#timeExtent) and [where](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#where).
   *
   * > [!WARNING]
   * >
   * > **Known Limitations**
   * >
   * > For service-based queries, `outStatistics` is only supported on layers where `supportsStatistics = true`.
   *
   * @example
   * let query = new Query();
   * let statisticDefinition = new StatisticDefinition({
   *   statisticType: "sum",
   *   onStatisticField: "POP2000",
   *   outStatisticFieldName: "TotalPop"
   * });
   *
   * query.outStatistics = [ statisticDefinition ];
   */
  get outStatistics(): StatisticDefinition[] | null | undefined;
  set outStatistics(value: StatisticDefinitionProperties[] | null | undefined);
  /**
   * Filters features from the layer based on pre-authored parameterized filters.
   * When value is not specified for any parameter in a request, the default value,
   * that is assigned during authoring time, gets used.
   * Requires an ArcGIS Enterprise service 10.5 or greater. This parameter is only supported with
   * [MapImageLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html) pointing to a [map service](https://enterprise.arcgis.com/en/server/latest/publish-services/windows/what-is-a-map-service.htm).
   *
   * @see [ArcGIS Pro - creating a query layer](https://pro.arcgis.com/en/pro-app/latest/help/mapping/layer-properties/creating-a-query-layer.htm)
   * @see [ArcGIS REST API - query a map service layer](https://developers.arcgis.com/rest/services-reference/enterprise/query-map-service-layer-.htm)
   */
  accessor parameterValues: Record<string, ParameterValueType> | null | undefined;
  /**
   * Specifies the pixel level to be identified on the X and Y axis. Defaults to the base resolution of the
   * dataset if not specified. Applicable only to Image Service layers.
   */
  get pixelSize(): Point | null | undefined;
  set pixelSize(value: PointProperties | null | undefined);
  /**
   * Used to project the geometry onto a virtual grid, likely representing
   * pixels on the screen. Geometry coordinates are converted to integers
   * by building a grid with a resolution matching the `quantizationParameters.tolerance`.
   * Each coordinate is then snapped to one pixel on the grid.
   *
   * > [!WARNING]
   * >
   * > **Known Limitations**
   * >
   * > Only supported with ArcGIS Online hosted services or ArcGIS Enterprise 10.6.1 services.
   *
   * @example
   * let query = new Query();
   * query.quantizationParameters = {
   *   mode: "view",
   *   originPosition: "upper-left",
   *   tolerance: 4820,
   *   extent: layer.fullExtent
   * };
   */
  get quantizationParameters(): QuantizationParameters | null | undefined;
  set quantizationParameters(value: QuantizationParametersProperties | null | undefined);
  /**
   * Filters features from the layer that are within the specified range values.
   * Requires ArcGIS Enterprise services 10.5 or greater.This parameter is only supported with
   * [MapImageLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-MapImageLayer.html) pointing to a [map service](https://enterprise.arcgis.com/en/server/latest/publish-services/windows/what-is-a-map-service.htm).
   *
   * @see [ArcGIS Pro - creating a query layer](https://pro.arcgis.com/en/pro-app/latest/help/mapping/layer-properties/creating-a-query-layer.htm)
   * @see [ArcGIS REST API - query a map service layer](https://developers.arcgis.com/rest/services-reference/enterprise/query-map-service-layer-.htm)
   */
  accessor rangeValues: RangeValue[] | null | undefined;
  /**
   * The Dimensionally Extended 9 Intersection Model (DE-9IM) matrix relation (encoded as a string) to query
   * the spatial relationship of the input [geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#geometry) to the layer's features. This
   * string contains the test result of each intersection represented in the DE-9IM matrix. Each result is
   * one character of the string and may be represented as either a number (maximum dimension returned: 0,1,2),
   * a Boolean value (T or F), or a mask character (for ignoring results: '*').
   *
   * Set this parameter when the [spatialRelationship](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#spatialRelationship) is `relation`.
   * The [Relational functions for ST_Geometry](https://pro.arcgis.com/en/pro-app/latest/help/data/databases/pdf/stgeometry_reference.pdf) topic has additional details
   * on how to construct these strings.
   *
   * > [!WARNING]
   * >
   * > **Known Limitations**
   * >
   * > This property does not apply to layer view or [CSVLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html) queries.
   *
   * @example
   * let query = new Query({
   *   relationParameter: "FFFTTT***"
   * });
   */
  accessor relationParameter: string | null | undefined;
  /**
   * If `true`, each feature in the returned [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-FeatureSet.html) will be returned with a centroid.
   * This property only applies to queries against polygon [FeatureLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html).
   *
   * > [!WARNING]
   * >
   * > **Known Limitations**
   * >
   * > Only supported with ArcGIS Online hosted services or ArcGIS Enterprise 10.6.1 services.
   *
   * @default false
   */
  accessor returnCentroid: boolean;
  /**
   * If `true` then the query returns distinct values based on the field(s) specified in [outFields](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#outFields).
   *
   * > [!WARNING]
   * >
   * > **Known Limitations**
   * >
   * > For service-based queries, this parameter applies only if the `supportsAdvancedQueries` capability of the layer is `true`.
   * > Make sure to set [returnGeometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#returnGeometry) to `false` when `returnDistinctValues` is true. Otherwise, reliable results will not be returned.
   *
   * @default false
   */
  accessor returnDistinctValues: boolean;
  /**
   * If `true`, then all features are returned for each tile request, even if they exceed the
   * maximum record limit per query indicated on the service by `maxRecordCount`. If `false`, the
   * tile request will not return any features if the `maxRecordCount` limit is exceeded.
   *
   * > [!WARNING]
   * >
   * > **Known Limitations**
   * >
   * > Only supported with ArcGIS Online hosted services or ArcGIS Enterprise 10.6 services and higher.
   *
   * @default true
   */
  accessor returnExceededLimitFeatures: boolean;
  /**
   * If `true`, each feature in the returned [FeatureSet](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-FeatureSet.html) includes the geometry.
   *
   * > [!WARNING]
   * >
   * > **Known Limitations**
   * >
   * > For [FeatureLayerView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-FeatureLayerView.html) queries, the precision of the returned geometries will only be
   * >   as high as the view's scale resolution since geometries are quantized for improved performance on the view.
   * >   The smaller the scale, the lower the resolution of the geometries.
   * >
   * >   This limitation does not apply to [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html), [CSVLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html),
   * >   and [CSVLayerView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-CSVLayerView.html) queries.
   *
   * @default false
   */
  accessor returnGeometry: boolean;
  /** If `true`, and [returnGeometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#returnGeometry) is `true`, then m-values are included in the geometry. */
  accessor returnM: boolean | null | undefined;
  /**
   * If `true`, the [query geometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-FeatureSet.html#queryGeometry) will be returned with the query results.
   * It is useful for getting the buffer geometry generated when querying features by [distance](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#distance)
   * or getting the query geometry projected in the [outSpatialReference](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#outSpatialReference) of the query.
   * The query geometry is returned only for [client-side queries](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-FeatureLayerView.html#queryFeatures)
   * and [hosted feature services](https://doc.arcgis.com/en/arcgis-online/share-maps/hosted-web-layers.htm)
   * and if the layer's [capabilities.query.supportsQueryGeometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#capabilities)
   * is `true`.
   *
   * @default false
   */
  accessor returnQueryGeometry: boolean;
  /**
   * If `true`, and [returnGeometry](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#returnGeometry) is `true`, then z-values are included in the geometry.
   *
   * > [!WARNING]
   * >
   * > **Known Limitations**
   * >
   * > [FeatureLayerView#queryFeatures()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-layers-FeatureLayerView.html#queryFeatures),
   * > {@link views/layers/GeoJSONLayerView#queryFeatures}, and
   * > {@link views/layers/OGCFeatureLayerView#queryFeatures} results do not
   * > include the z-values when called in [2D MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html) even if `returnZ` is set to `true`.
   */
  accessor returnZ: boolean | null | undefined;
  /**
   * This parameter can be either standard SQL92 `standard` or it can use the native SQL of the underlying datastore `native`.
   * See the [ArcGIS REST API documentation](https://developers.arcgis.com/rest/services-reference/query-feature-service-.htm)
   * for more information.
   *
   * > [!WARNING]
   * >
   * > **Known Limitations**
   * >
   * > This property does not apply to layer view or [CSVLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html) queries.
   *
   * @default "none"
   */
  accessor sqlFormat: SQLFormat | null | undefined;
  /**
   * The zero-based index indicating where to begin retrieving features. This property should be used in conjunction with [num](https://developers.arcgis.com/javascript/latest/api-reference/esri-rest-support-Query.html#num).
   * Use this to implement paging and retrieve "pages" of results when querying. Features are sorted ascending by
   * object ID by default.
   */
  accessor start: number | null | undefined;
  /** Shorthand for a where clause using "like". The field used is the display field defined in the services directory. */
  accessor text: string | null | undefined;
  /**
   * Creates a deep clone of Query object.
   *
   * @returns A new instance of a Query object equal to the object used to call `.clone()`.
   */
  clone(): Query;
}
declare const QuerySuperclass: typeof JSONSupport & typeof QueryMixin

export type ParameterValueType = number | number[] | string | string[] | Date | Date[];