import type FeatureLayer from "@arcgis/core/layers/FeatureLayer.js";
import type SubtypeSublayer from "@arcgis/core/layers/support/SubtypeSublayer.js";
import type { EventEmitter } from "@arcgis/lumina";
import type { SupportedLocale } from "@arcgis/toolkit/intl";
import type { WebChartTemporalBinningUnits } from "./spec/chart-object-literals.js";
import type { List as List } from "@esri/calcite-components/components/calcite-list";

/** Supported layer types for charts. */
export type SupportedLayer = FeatureLayer | SubtypeSublayer;

export interface IntervalPopoverProps {
  size: number;
  unit: WebChartTemporalBinningUnits;
}

/** @internal */
export const ChartAuthoringPages: {
    readonly Data: "data";
    readonly Series: "series";
    readonly Slices: "slices";
    readonly Axes: "axes";
    readonly Guides: "guides";
    readonly Format: "format";
    readonly General: "general";
};

/** @internal */
export type ChartAuthoringPages = (typeof ChartAuthoringPages)[keyof typeof ChartAuthoringPages];

/** @internal */
export const FormatIcons: {
    readonly Title: "title";
    readonly Text: "text";
    readonly Label: "label";
    readonly Palette: "palette";
};

/** @internal */
export type FormatIcons = (typeof FormatIcons)[keyof typeof FormatIcons];

/** @internal */
export const LineChartDataPopoverKinds: {
    readonly xAxisField: "xAxisField";
    readonly aggregation: "aggregation";
    readonly numericFields: "numericField";
    readonly splitByField: "splitByField";
    readonly interval: "interval";
    readonly intervalAlignment: "intervalAlignment";
};

/** @internal */
export type LineChartDataPopoverKinds = (typeof LineChartDataPopoverKinds)[keyof typeof LineChartDataPopoverKinds];

/** @internal */
export const BarChartDataPopoverKinds: {
    readonly category: "category";
    readonly aggregation: "aggregation";
    readonly numericFields: "numericField";
    readonly splitByField: "splitByField";
    readonly sortOrder: "sortOrder";
    readonly interval: "interval";
    readonly intervalAlignment: "intervalAlignment";
};

/** @internal */
export type BarChartDataPopoverKinds = (typeof BarChartDataPopoverKinds)[keyof typeof BarChartDataPopoverKinds];

/** @internal */
export const PieChartDataPopoverKinds: {
    readonly category: "category";
    readonly aggregation: "aggregation";
    readonly numericFields: "numericFields";
    readonly sortOrder: "sortOrder";
};

/** @internal */
export type PieChartDataPopoverKinds = (typeof PieChartDataPopoverKinds)[keyof typeof PieChartDataPopoverKinds];

/** @internal */
export const HistogramDataPopoverKinds: {
    readonly numericFields: "numericField";
    readonly transformation: "transformation";
    readonly fillSymbol: "fillSymbol";
    readonly lineSymbol: "lineSymbol";
};

/** @internal */
export type HistogramDataPopoverKinds = (typeof HistogramDataPopoverKinds)[keyof typeof HistogramDataPopoverKinds];

/** @internal */
export const ScatterplotDataPopoverKinds: {
    readonly xAxisField: "xAxis";
    readonly yAxisField: "yAxis";
    readonly sizeVariable: "sizeVariable";
    readonly symbol: "symbol";
    readonly trendLine: "trendLine";
    readonly additionalTooltipFields: "additionalTooltipFields";
    readonly none: "none";
};

/** @internal */
export type ScatterplotDataPopoverKinds = (typeof ScatterplotDataPopoverKinds)[keyof typeof ScatterplotDataPopoverKinds];

/** @internal */
export interface NumericFieldsChangeProps {
  pickListElement?: List;
  eventEmitter: EventEmitter<unknown>;
  contentKind: BarChartDataPopoverKinds | LineChartDataPopoverKinds | PieChartDataPopoverKinds;
}

/** @internal */
export const BoxPlotDataPopoverKinds: {
    readonly category: "category";
    readonly numericFields: "numericField";
    readonly splitByField: "splitByField";
    readonly sortOrder: "sortOrder";
};

/** @internal */
export type BoxPlotDataPopoverKinds = (typeof BoxPlotDataPopoverKinds)[keyof typeof BoxPlotDataPopoverKinds];

/** @internal */
export const HeatChartDataPopoverKinds: {
    readonly xAxisField: "xAxisField";
    readonly aggregation: "aggregation";
    readonly numericFields: "numericField";
    readonly calendarType: "calendarType";
    readonly calendarViewType: "calendarViewType";
    readonly classBreakMethod: "classBreakMethod";
    readonly colorScheme: "colorScheme";
    readonly null: "null";
};

/** @internal */
export type HeatChartDataPopoverKinds = (typeof HeatChartDataPopoverKinds)[keyof typeof HeatChartDataPopoverKinds];

/**
 * Represents the different types of calendar-based temporal binning that can be applied to a chart.
 *
 * @internal
 */
export const WebChartCalendarTypes: {
    readonly WeekByDayOfWeekAndHourOfDay: "weekByDayOfWeekAndHourOfDay";
    readonly YearByMonthAndDayOfMonth: "yearByMonthAndDayOfMonth";
};

/** @internal */
export const ScatterplotSymbolSizeTypes: {
    readonly Fixed: "fixed";
    readonly Proportional: "proportional";
};

/** @internal */
export type ScatterplotSymbolSizeTypes = (typeof ScatterplotSymbolSizeTypes)[keyof typeof ScatterplotSymbolSizeTypes];

/** @internal */
export const ButtonDirections: {
    readonly Up: "up";
    readonly Down: "down";
};

/** @internal */
export type ButtonDirections = (typeof ButtonDirections)[keyof typeof ButtonDirections];

/**
 * Options for exporting chart data to CSV.
 *
 * @template T - The type of the data being exported.
 */
export interface CSVOptions {
  /**
   * Explicit list of columns to export.
   * If not provided, all columns will be exported.
   */
  columns?: string[];
  /** Field delimiter. */
  delimiter?: string;
  /** Whether to include the header row in the CSV. */
  includeHeader?: boolean;
  /** Whether to quote all fields. */
  quoteAll?: boolean;
  /**
   * Locale used for formatting numbers in the CSV. This affects how numbers are formatted, such as decimal and thousands separators.
   * If not provided, the default locale will be used.
   *
   * Supported locales include:
   * `"ar"`, `"ar-u-nu-latn"`, `"bs"`, `"bg"`, `"ca"`, `"cs"`, `"da"`, `"de"`, `"el"`, `"en"`, `"en-US"`, `"es"`, `"et"`, `"fi"`, `"fr"`, `"he"`, `"hr"`, `"hu"`, `"id"`, `"it"`, `"ja"`, `"ko"`, `"lt"`, `"lv"`, `"no"`, `"nl"`, `"pl"`, `"pt-BR"`, `"pt-PT"`, `"ro"`, `"ru"`, `"sr"`, `"sl"`, `"sk"`, `"sv"`, `"th"`, `"tr"`, `"uk"`, `"vi"`, `"zh-CN"`, `"zh-HK"`, `"zh-TW"`
   */
  locale?: SupportedLocale;
}