import type { ChartElementLimit } from "../../defaults/interfaces.js";
import type { QueryObject } from "../../layer/interfaces.js";
import type { AbortControllerKeyType } from "../../layer/query-features/interfaces.js";
import type { WebChartQuery } from "../../../spec/web-chart.js";

/**
 * Fetches the unique values from a given field.
 * /!\ Currently the results for a same split-by field might differ from a category field to another.
 * This is due to the server not being able to make a distinction in some cases between values having for
 * only difference trailing spaces (e.g. `value` and `value ` and `value  `). It means it will aggregate the
 * stats for those similar values.
 * Given the stats for the similar values will be later aggregated, we also want the unique value list to carry
 * the same approximation.
 * To get a list of unique values that will match the chart's data, we simulate the data query and retain the unique
 * values for given the split-by field.
 *
 * @param props - The object used to query the features (layer or feature layer view)
 * @internal
 */
export function uniqueValues(props: {
    queryObject?: QueryObject;
    queryConfig: WebChartQuery;
    category: string;
    splitByField?: string;
    chartLimits?: ChartElementLimit;
    abortKey?: AbortControllerKeyType;
}): Promise<(number | string)[]>;