import type { WebChartStackedKinds, WebChartTypes } from "../../spec/chart-object-literals.js";
import type { Color, IFont, ISimpleFillSymbol, ISimpleLineSymbol, ISimpleMarkerSymbol } from "../../spec/rest-js-types.js";
import type { CategoryFormatOptions, DateTimeFormatOptions, HistogramOverlays, NumberFormatOptions, ScatterplotOverlays, SizePolicy, WebBoxPlot, WebChart, WebChartAxis, WebChartBarChartSeries, WebChartBoxPlotSeries, WebChartCursorCrosshair, WebChartGaugeAxis, WebChartGaugeSeries, WebChartHeatChartSeries, WebChartHistogramSeries, WebChartLegend, WebChartLineChartSeries, WebChartNeedle, WebChartOverlay, WebChartPieChartSeries, WebChartPieChartTick, WebChartRadarChartSeries, WebChartScatterplotSeries, WebChartText, WebChartTextSymbol, WebGaugeChart, WebHeatChart } from "../../spec/web-chart.js";
import type { CommonStrings } from "../localization/interfaces.js";
import type { ChartElementLimit, ChartElementTechnicalLimit, ChartTextProps, QueryDefaults, TextElements } from "./interfaces.js";

/** @internal */
export const histogramBinCount: 32;

/** @internal */
export const featuresExtentField: "arcgis_charts_features_extent";

/** @internal */
export const queryDefaults: QueryDefaults;

/** @internal */
export const queryCalculatedExpr: (string | string | string | string)[];

/** @internal */
export const fullOpacity: 1;

/** @internal */
export const reducedOpacity: 0.7;

/** @internal */
export const defaultGridLineOpacity: 25;

/** @internal */
export const defaultAxisLineColor: Color;

/** @internal */
export const defaultPieTickColor: Color;

/** @internal */
export const defaultLineSymbolStyle: "esriSLSSolid";

/** @internal */
export const defaultLineSymbolWidth: 2;

/** @internal */
export const pieChartSpecialSlicesId: {
    defaultGroupOfSlicesId: string;
    sliceIdPrefix: string;
    undefinedSliceId: string;
    nullSliceId: string;
    emptySliceId: string;
};

/** @internal */
export const defaultBoxPlotCategory: "arcgis_charts_box_plot_category";

/** @internal */
export const defaultHeatChartFields: {
    valueField: string;
    xField: string;
    yField: string;
};

/** @internal */
export const defaultHeatChartNumberOfBreaks: {
    min: number;
    max: number;
};

/**
 * default color set from Pro
 *
 * @internal
 */
export const ramp: Color[];

/** @internal */
export const darkModeRamp: Color[];

/** @internal */
export const darkModeOverlayRamp: Color[];

/** @internal */
export const loaderBackgroundLight: Color;

/**
 * Same as --calcite-color-foreground-1 in dark mode
 *
 * @internal
 */
export const loaderBackgroundDark: Color;

/** @internal */
export const loaderSpinnerColor: Color;

/** @internal */
export const lightTextColor: Color;

/** @internal */
export const darkTextColor: Color;

/**
 * Returns a specific color from the default ramp, given an index. If the index is > than the ramp length,
 * we use modulo to get the corresponding color.
 *
 * @param props - The index to fetch the color from the `ramp` or `overlayRamp` array
 * @internal
 */
export function getOneRampColor(props: {
    colorIndex?: number;
    opacity?: number;
    histogramOverlays?: boolean;
}): Color;

/**
 * @param opacity
 * @internal
 */
export function getDefaultColor(opacity?: number): Color;

/**
 * Gets default cursor crosshair
 *
 * @returns default cursor crosshair
 * @internal
 */
export function getDefaultCursorCrosshair(): WebChartCursorCrosshair;

/**
 * random color with alpha 70% for authoring page.
 *
 * @param opacityPercentage - default is 1
 * @internal
 */
export function generateRandomRestColor(opacityPercentage?: number): Color;

/**
 * @param type
 * @internal
 */
export function getDefaultFont(type?: TextElements): IFont;

/**
 * @param text
 * @param font
 * @param type
 * @internal
 */
export function getDefaultTextSymbol(text?: string, font?: IFont, type?: TextElements): WebChartTextSymbol;

/**
 * @param props
 * @internal
 */
export function getDefaultChartText(props?: ChartTextProps): WebChartText;

/**
 * @param props
 * @internal
 */
export function getDefaultLineSymbol(props?: {
    color?: Color;
    useRandomColor?: boolean;
    useRampColor?: { colorIndex?: number; };
    width?: number;
    opacity?: number;
    isHistogramOverlay?: boolean;
}): ISimpleLineSymbol;

/** @internal */
export function getDefaultCategoryFormat(): CategoryFormatOptions;

/** @internal */
export function getDefaultDateFormat(): DateTimeFormatOptions;

/** @internal */
export function getDefaultNumberFormat(): NumberFormatOptions;

/** @internal */
export function getDefaultStatNumberFormat(): NumberFormatOptions;

/** @internal */
export function getDefaultPercentNumberFormat(): NumberFormatOptions;

/**
 * @param text
 * @internal
 */
export function getDefaultValueAxis(text?: string): WebChartAxis;

/** @internal */
export function getDefaultLegend(): WebChartLegend;

/**
 * @param overlayIndex
 * @internal
 */
export function getDefaultOverlay(overlayIndex: number): WebChartOverlay;

/** @internal */
export function getDefaultBackground(): Color;

/**
 * @param commonStrings
 * @internal
 */
export function getDefaultTitle(commonStrings: CommonStrings): string;

/**
 * @param seriesIndex
 * @param useRandomColor
 * @internal
 */
export function getDefaultBoxPlotElementSymbol(seriesIndex: number | undefined, useRandomColor?: boolean): ISimpleFillSymbol;

/**
 * Returns a default marker symbol for a line chart
 *
 * @param seriesIndex - The series index to pick a symbol color
 * @internal
 */
export function getDefaultLineChartMarkerSymbol(seriesIndex?: number): ISimpleMarkerSymbol;

/**
 * Returns a default line symbol for a line chart
 *
 * @param seriesIndex - The series index to pick a symbol color
 * @internal
 */
export function getDefaultLineChartLineSymbol(seriesIndex?: number): ISimpleLineSymbol;

/**
 * @param useRandomColor
 * @internal
 */
export function getDefaultScatterplotMarkerSymbol(useRandomColor?: boolean): ISimpleMarkerSymbol;

/** @internal */
export function getDefaultScatterplotSizePolicy(): Required<SizePolicy>;

/**
 * @param useRandomColor
 * @internal
 */
export function getDefaultTrendLine(useRandomColor?: boolean): Required<ScatterplotOverlays>;

/**
 * @param commonStrings
 * @param objectIDField
 * @internal
 */
export function getHeatChartSeries(commonStrings: CommonStrings, objectIDField?: string): WebChartHeatChartSeries;

/** @internal */
export function getScatterplotSeries(): WebChartScatterplotSeries;

/**
 * Returns default axes based on chart type as per the WebChart Specification
 *
 * @param commonStrings - The common strings used in the chart
 * @param chartType - The type of WebChart which is of type WebChartTypes
 * @internal
 */
export function getDefaultAxes(commonStrings: CommonStrings, chartType: WebChartTypes): WebChartAxis[];

/**
 * Returns the default gauge needle
 *
 * @internal
 */
export function getDefaultGaugeNeedle(): WebChartNeedle;

/**
 * Returns the gauge axes
 *
 * @param commonStrings
 * @internal
 */
export function getGaugeAxes(commonStrings: CommonStrings): WebChartGaugeAxis[];

/**
 * Returns a default LineChartSeries object as per the WebChart Specification
 *
 * @param props
 * @internal
 */
export function getDefaultLineChartSeries(props: {
    commonStrings: CommonStrings;
    objectIDField?: string;
    seriesIndex?: number;
}): Required<Pick<WebChartLineChartSeries, "dataLabels" | "lineSymbol" | "markerSymbol" | "query">> & WebChartLineChartSeries;

/**
 * Returns a default RadarChartSeries object as per the WebChart Specification
 *
 * @param props
 * @internal
 */
export function getDefaultRadarChartSeries(props: {
    commonStrings: CommonStrings;
    objectIDField?: string;
    seriesIndex?: number;
}): Required<Pick<WebChartRadarChartSeries, "dataLabels" | "lineSymbol" | "markerSymbol" | "query">> & WebChartRadarChartSeries;

/**
 * Returns a default symbol for a bar chart series
 *
 * @param seriesIndex - The series index to pick a symbol color
 * @internal
 */
export function getDefaultBarChartSeriesSymbol(seriesIndex?: number): ISimpleFillSymbol;

/**
 * Returns a default BarChartSeries object as per the WebChart Specification
 *
 * @param props
 * @internal
 */
export function getDefaultBarChartSeries(props: {
    objectIDField?: string;
    seriesIndex?: number;
    commonStrings: CommonStrings;
}): Required<Pick<WebChartBarChartSeries, "dataLabels" | "fillSymbol" | "query">> & WebChartBarChartSeries;

/**
 * Returns a default BoxPlotSeries object as per the WebBoxPlot Specification
 *
 * @param commonStrings
 * @param seriesIndex
 * @internal
 */
export function getDefaultBoxPlotSeries(commonStrings: CommonStrings, seriesIndex?: number): WebChartBoxPlotSeries;

/**
 * Returns a default pie chart tick object as per the WebChart Specification
 *
 * @internal
 */
export function getDefaultPieChartTick(): WebChartPieChartTick;

/**
 * Returns a default symbol for a pie chart
 *
 * @internal
 */
export function getDefaultPieChartSymbol(): ISimpleFillSymbol;

/**
 * Returns a default PieChartSeries object as per the WebChart Specification
 *
 * @param commonStrings
 * @param objectIDField
 * @internal
 */
export function getDefaultPieChartSeries(commonStrings: CommonStrings, objectIDField?: string): Required<Pick<WebChartPieChartSeries, "dataLabels" | "fillSymbol" | "query">> & WebChartPieChartSeries;

/**
 * Returns a default GaugeSeries object as per the WebChart Specification
 *
 * @param props
 * @internal
 */
export function getDefaultGaugeSeries(props: { objectIDField?: string; }): WebChartGaugeSeries;

/**
 * Returns the default chart rotation.
 *
 * @internal
 */
export function getDefaultChartRotation(): boolean;

/**
 * @param commonStrings
 * @param id
 * @internal
 */
export function getDefaultBarChart(commonStrings: CommonStrings, id?: string): WebChart;

/**
 * @param commonStrings
 * @param id
 * @internal
 */
export function getDefaultBoxPlot(commonStrings: CommonStrings, id?: string): WebBoxPlot;

/**
 * @param commonStrings
 * @param id
 * @internal
 */
export function getDefaultLineChart(commonStrings: CommonStrings, id?: string): WebChart;

/**
 * @param commonStrings
 * @param id
 * @internal
 */
export function getDefaultRadarChart(commonStrings: CommonStrings, id?: string): WebChart;

/**
 * @param commonStrings
 * @param id
 * @internal
 */
export function getDefaultPieChart(commonStrings: CommonStrings, id?: string): WebChart;

/**
 * @param commonStrings
 * @param id
 * @internal
 */
export function getDefaultGauge(commonStrings: CommonStrings, id?: string): WebGaugeChart;

/**
 * @param commonStrings
 * @param id
 * @internal
 */
export function getDefaultScatterplot(commonStrings: CommonStrings, id?: string): WebChart;

/**
 * Gets default heat chart
 *
 * @param commonStrings - Common strings
 * @param objectIDField - Object ID field
 * @returns WebHeatChart
 * @internal
 */
export function getDefaultHeatChart(commonStrings: CommonStrings, objectIDField: string): WebHeatChart;

/** @internal */
export function getDefaultHistogramOverlays(): Required<HistogramOverlays>;

/** @internal */
export function getDefaultHistogramSymbol(): ISimpleFillSymbol;

/** @internal */
export function getDefaultHistogramSeries(): Omit<Required<WebChartHistogramSeries>, "dataTooltipDateFormat" | "dataTooltipPercentFormat" | "dataTooltipValueFormat" | "query">;

/**
 * @param commonStrings
 * @param id
 * @internal
 */
export function getDefaultHistogram(commonStrings: CommonStrings, id?: string): WebChart;

/**
 * Returns a list of render limitations, mainly set for performance reasons. They can be overridden through the chart options,
 * or let as defaults.
 *
 * @param customizedLimits
 * @internal
 */
export function getChartLimits(customizedLimits?: ChartElementLimit): Required<ChartElementLimit>;

/**
 * Returns a list of technical limitations, mainly to the size of large queries.
 *
 * @internal
 */
export function getChartTechnicalLimits(): ChartElementTechnicalLimit;

/**
 * Returns the label for the provided aggregation type.
 *
 * @param aggregationType
 * @param commonStrings
 * @internal
 */
export function getDefaultAggregationTypeLabel(aggregationType: string | undefined, commonStrings: CommonStrings): string;

/**
 * Returns the label for the provided time aggregation type.
 *
 * @param timeAggregationType
 * @param commonStrings
 * @internal
 */
export function getDefaultTimeAggregationTypeLabel(timeAggregationType: string | undefined, commonStrings: CommonStrings): string;

/**
 * Returns the default stacked type for Bar or Line chart with multiple series.
 *
 * @internal
 */
export function getDefaultStackedType(): WebChartStackedKinds;

/**
 * Returns the default label to show when there is no R2 value computed or set for scatterplot
 *
 * @param commonStrings
 * @internal
 */
export function getDefaultNoR2Label(commonStrings: CommonStrings): string;

/** @internal */
export const pieChartInnerRadius: 0;

/** @internal */
export const boxPlotOutliersSuffix: "_arcgis_charts_outliers";

/** @internal */
export const boxPlotZScoreSuffix: "_arcgis_charts_z_score";

/** @internal */
export const defaultColorForBoxPlotWithMeanLines: Color;

/** @internal */
export const percentageSuffix: " percentage ";