/**
 * Various utility methods for creating and updating templates used by
 * the [FeatureTable component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-feature-table/).
 *
 * @since 5.1
 */
import type AttributeTableTemplate from "../AttributeTableTemplate.js";
import type AttributeTableFieldOrder from "./FieldOrder.js";
import type TableTemplate from "../../widgets/FeatureTable/support/TableTemplate.js";
import type FeatureTable from "../../widgets/FeatureTable.js";
import type { AttributeTableElementUnion, CreateTableTemplateFromAttributeTableTemplateParameters, CreateTemplateParameters, NestedAttributeTableElementUnion } from "./types.js";
import type { ColumnSortOrder, FeatureTableSupportedColumn, GroupColumnSupportedTemplates, SupportedColumnTemplates } from "../../widgets/FeatureTable/support/types.js";

/**
 * Utility method which creates a basic [AttributeTableTemplate](https://developers.arcgis.com/javascript/latest/references/core/tables/AttributeTableTemplate/) based on the provided layer.
 *
 * @param params - Parameters controlling the generation of the [AttributeTableTemplate](https://developers.arcgis.com/javascript/latest/references/core/tables/AttributeTableTemplate/).
 * @returns A promise that resolves to a newly generated [AttributeTableTemplate](https://developers.arcgis.com/javascript/latest/references/core/tables/AttributeTableTemplate/).
 * @since 5.1
 */
export function createAttributeTableTemplateFromLayer(params: CreateTemplateParameters): Promise<AttributeTableTemplate>;

/**
 * Utility method which creates an array of column elements based on the provided columns.
 *
 * @param columns - An array of columns from which to generate [attribute table elements](https://developers.arcgis.com/javascript/latest/references/core/tables/elements/AttributeTableElement/).
 * @returns An array of [attribute table elements](https://developers.arcgis.com/javascript/latest/references/core/tables/elements/AttributeTableElement/) generated from the provided columns.
 * @since 5.1
 */
export function createAttributeTableElementsFromColumns(columns: FeatureTableSupportedColumn[]): AttributeTableElementUnion[];

/**
 * Method which creates a nested column element based on the provided column.
 *
 * @param column - A column from which to generate a nested [attribute table element](https://developers.arcgis.com/javascript/latest/references/core/tables/elements/AttributeTableElement/) (excludes group elements).
 * @returns An [attribute table element](https://developers.arcgis.com/javascript/latest/references/core/tables/elements/AttributeTableElement/) generated from the provided column, or undefined if the column is hidden or of an unsupported type.
 * @since 5.1
 */
export function createNestedAttributeTableElementFromColumn(column: FeatureTableSupportedColumn): NestedAttributeTableElementUnion | null | undefined;

/**
 * Method which creates a basic [TableTemplate](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/TableTemplate/) based on the provided layer.
 *
 * @param params - Parameters controlling the generation of the [TableTemplate](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/TableTemplate/).
 * @returns A promise that resolves to a newly generated [TableTemplate](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/TableTemplate/).
 * @since 5.1
 */
export function createTableTemplateFromLayer(params: CreateTemplateParameters): Promise<TableTemplate>;

/**
 * Method which creates a [TableTemplate](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/TableTemplate/) based on the provided [AttributeTableTemplate](https://developers.arcgis.com/javascript/latest/references/core/tables/AttributeTableTemplate/).
 *
 * @param params - Parameters controlling the generation of the [TableTemplate](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/TableTemplate/).
 * @returns A promise that resolves to a newly generated [TableTemplate](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/TableTemplate/).
 * @since 5.1
 */
export function createTableTemplateFromAttributeTableTemplate(params: CreateTableTemplateFromAttributeTableTemplateParameters): Promise<TableTemplate>;

/**
 * Method which creates an array of column templates based on the provided elements and orderByFields.
 *
 * @param elements - An array of [attribute table elements](https://developers.arcgis.com/javascript/latest/references/core/tables/elements/AttributeTableElement/) from which to generate column templates.
 * @param orderByFields - An array of [attribute table field order](https://developers.arcgis.com/javascript/latest/references/core/tables/support/FieldOrder/) objects which determine the sort order of columns in the table.
 * @returns An array of column templates generated from the provided elements and orderByFields.
 * @since 5.1
 */
export function createColumnTemplatesFromElements(elements: AttributeTableElementUnion[] | null | undefined, orderByFields: AttributeTableFieldOrder[]): SupportedColumnTemplates[];

/**
 * Method which creates an array of column templates based on the provided columns.
 *
 * @param columns - An array of columns from which to generate [attribute table elements](https://developers.arcgis.com/javascript/latest/references/core/tables/elements/AttributeTableElement/).
 * @returns An array of column templates generated from the provided columns.
 * @since 5.1
 */
export function createColumnTemplatesFromColumns(columns: FeatureTableSupportedColumn[]): SupportedColumnTemplates[];

/**
 * Method which creates a nested column template based on the provided column.
 *
 * @param column - A column from which to generate a nested column template (excludes group columns).
 * @returns A column template generated from the provided column, or undefined if the column is hidden or of an unsupported type.
 * @since 5.1
 */
export function createNestedColumnTemplateFromColumn(column: FeatureTableSupportedColumn): GroupColumnSupportedTemplates | null | undefined;

/**
 * Method which creates a nested column template based on the provided element and orderByFields.
 *
 * @param element - An [attribute table element](https://developers.arcgis.com/javascript/latest/references/core/tables/elements/AttributeTableElement/) from which to generate a nested column template (excludes group elements).
 * @param orderByFields - An array of [attribute table field order](https://developers.arcgis.com/javascript/latest/references/core/tables/support/FieldOrder/) objects which determine the sort order of columns in the table.
 * @returns A column template generated from the provided element and orderByFields, or undefined if the element is of an unsupported type.
 * @since 5.1
 */
export function createNestedColumnTemplateFromElement(element: AttributeTableElementUnion, orderByFields: AttributeTableFieldOrder[]): GroupColumnSupportedTemplates | null | undefined;

/**
 * Determines if a provided template is a [TableTemplate](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/TableTemplate/).
 *
 * @param template - The template to check.
 * @returns Returns true if the template is a [TableTemplate](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/TableTemplate/), otherwise returns false.
 * @since 5.1
 */
export function isTableTemplate(template: unknown): template is TableTemplate;

/**
 * Determines if a provided template is an [attribute table template](https://developers.arcgis.com/javascript/latest/references/core/tables/AttributeTableTemplate/).
 *
 * @param template - The template to check.
 * @returns Returns true if the template is an [attribute table template](https://developers.arcgis.com/javascript/latest/references/core/tables/AttributeTableTemplate/), otherwise returns false.
 * @since 5.1
 */
export function isAttributeTableTemplate(template: unknown): template is AttributeTableTemplate;

/**
 * Method which syncs an [attribute table template](https://developers.arcgis.com/javascript/latest/references/core/tables/AttributeTableTemplate/) with the provided [FeatureTable](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/).
 *
 * @param table - The FeatureTable to synchronize with the [AttributeTableTemplate](https://developers.arcgis.com/javascript/latest/references/core/tables/AttributeTableTemplate/).
 * @param template - The AttributeTableTemplate to sync with the table.
 * @param includeHiddenColumns - Indicates whether to include hidden columns in the synced template. Default is true.
 * @returns The synced [attribute table template](https://developers.arcgis.com/javascript/latest/references/core/tables/AttributeTableTemplate/).
 * @since 5.1
 */
export function syncAttributeTableTemplateWithTable(table: FeatureTable, template: AttributeTableTemplate, includeHiddenColumns?: boolean): AttributeTableTemplate;

/**
 * Method which syncs an [AttributeTableTemplate](https://developers.arcgis.com/javascript/latest/references/core/tables/AttributeTableTemplate/) with the provided columns and sort orders.
 *
 * @param template - The [AttributeTableTemplate](https://developers.arcgis.com/javascript/latest/references/core/tables/AttributeTableTemplate/) to sync with the columns.
 * @param columns - An array of columns with which to sync the [attribute table template](https://developers.arcgis.com/javascript/latest/references/core/tables/AttributeTableTemplate/).
 * @param activeSortOrders - An array of [attribute table field order](https://developers.arcgis.com/javascript/latest/references/core/tables/support/FieldOrder/) objects which determine the current sort order of table columns.
 * @param includeHiddenColumns - Indicates whether to include hidden columns in the synced template. Default is true.
 * @returns The synced [attribute table template](https://developers.arcgis.com/javascript/latest/references/core/tables/AttributeTableTemplate/).
 * @since 5.1
 */
export function syncAttributeTableTemplateWithColumns(template: AttributeTableTemplate, columns: FeatureTableSupportedColumn[], activeSortOrders: ColumnSortOrder[], includeHiddenColumns?: boolean): AttributeTableTemplate;