import type AttributeTableTemplate from "../AttributeTableTemplate.js";
import type AttributeTableAttachmentElement from "../elements/AttributeTableAttachmentElement.js";
import type AttributeTableFieldElement from "../elements/AttributeTableFieldElement.js";
import type AttributeTableGroupElement from "../elements/AttributeTableGroupElement.js";
import type AttributeTableRelationshipElement from "../elements/AttributeTableRelationshipElement.js";
import type { FieldType } from "../../layers/support/types.js";

/**
 * A union of all [attribute table elements](https://developers.arcgis.com/javascript/latest/references/core/tables/elements/AttributeTableElement/).
 *
 * @since 5.1
 */
export type AttributeTableElementUnion = AttributeTableAttachmentElement | AttributeTableFieldElement | AttributeTableGroupElement | AttributeTableRelationshipElement;

/**
 * A union of all [attribute table elements](https://developers.arcgis.com/javascript/latest/references/core/tables/elements/AttributeTableElement/) that are nestable in a group element.
 *
 * @since 5.1
 */
export type NestedAttributeTableElementUnion = Exclude<AttributeTableElementUnion, AttributeTableGroupElement>;

/**
 * Parameters for creating a [table template](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/TableTemplate/) or [attribute table template](https://developers.arcgis.com/javascript/latest/references/core/tables/AttributeTableTemplate/).
 *
 * @since 5.1
 */
export interface CreateTemplateParameters {
  /**
   * Layer from which to generate a default template.
   *
   * @since 5.1
   */
  layer: unknown;
  /**
   * Set of field names used to generate columns. If this parameter is not specified, columns are generated for all fields that are visible by default.
   *
   * @since 5.1
   */
  visibleFieldNames?: string[];
  /**
   * Indicates whether `attachments` columns should be excluded.
   *
   * @since 5.1
   */
  excludeAttachments?: boolean;
  /**
   * Indicates whether `relationship` columns should be excluded.
   *
   * @since 5.1
   */
  excludeRelationships?: boolean;
  /**
   * An array of field types that specify which types to exclude. The default value is ["geometry", "blob", "raster", "guid", "xml"].
   *
   * @since 5.1
   */
  excludedFieldTypesOverride?: FieldType[];
}

/**
 * Parameters for creating a [table template](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/TableTemplate/) from a provided [attribute table template](https://developers.arcgis.com/javascript/latest/references/core/tables/AttributeTableTemplate/).
 *
 * @since 5.1
 */
export interface CreateTableTemplateFromAttributeTableTemplateParameters {
  /**
   * Layer used to generate the default template.
   *
   * @since 5.1
   */
  layer: unknown;
  /**
   * Instance of an [AttributeTableTemplate](https://developers.arcgis.com/javascript/latest/references/core/tables/AttributeTableTemplate/) used to configure a new [TableTemplate](https://developers.arcgis.com/javascript/latest/references/core/widgets/FeatureTable/support/TableTemplate/).
   *
   * @since 5.1
   */
  template: AttributeTableTemplate;
  /**
   * Indicates whether columns should be generated for fields without associated [attribute table elements](https://developers.arcgis.com/javascript/latest/references/core/tables/elements/AttributeTableElement/).
   *
   * @since 5.1
   */
  includeHiddenFields?: boolean;
  /**
   * Indicates field types that should be excluded. Defaults to: ["geometry", "blob", "raster", "guid", "xml"].
   *
   * @since 5.1
   */
  excludedFieldTypesOverride?: FieldType[];
}