import type Graphic from "../Graphic.js";
import type EsriMap from "../Map.js";
import type Collection from "../core/Collection.js";
import type Widget from "./Widget.js";
import type BatchAttributeFormViewModel from "./BatchAttributeForm/BatchAttributeFormViewModel.js";
import type VisibleElements from "./BatchAttributeForm/VisibleElements.js";
import type { Icon } from "@esri/calcite-components/components/calcite-icon";
import type { WidgetProperties } from "./Widget.js";
import type { BatchAttributeFormViewModelEvents, BatchAttributeFormViewModelProperties } from "./BatchAttributeForm/BatchAttributeFormViewModel.js";
import type { AttributeFormSupportedLayerInfo } from "./BatchAttributeForm/types.js";
import type { HeadingLevel } from "./support/types.js";
import type { VisibleElementsProperties } from "./BatchAttributeForm/VisibleElements.js";

export interface BatchAttributeFormProperties extends WidgetProperties, Partial<Pick<BatchAttributeForm, "activeFeatureIndex" | "disabled" | "features" | "groupDisplay" | "headingLevel" | "layerInfos" | "map" | "readOnly" | "timeZone">> {
  /**
   * Icon displayed in the widget's button.
   *
   * @default "edit-attributes"
   * @see [Calcite Icon Search](https://developers.arcgis.com/calcite-design-system/icons/)
   * @since 4.27
   * @see [Calcite Icon Search](https://developers.arcgis.com/calcite-design-system/icons/)
   */
  icon?: Icon["icon"] | null;
  /**
   * The view model for this widget. This is a class that contains all the logic
   * (properties and methods) that controls this widget's behavior. See the
   * [BatchAttributeFormViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BatchAttributeForm-BatchAttributeFormViewModel.html) class to access
   * all properties and methods on the widget.
   */
  viewModel?: BatchAttributeFormViewModelProperties;
  /** Defines which elements are visible in the widget. */
  visibleElements?: VisibleElementsProperties;
}

export interface BatchAttributeFormEvents extends BatchAttributeFormViewModelEvents {}

/**
 * The `BatchAttributeForm` widget enables users to edit the attributes of multiple features at once. Designed for batch editing workflows, it provides a dynamic form that adapts to the fields of the selected features. The `BatchAttributeForm` is ideal for scenarios where attribute consistency across multiple features is required, streamlining data management and reducing repetitive editing tasks.
 *
 * > [!WARNING]
 * >
 * > **Known Limitations**
 * >
 * > Currently, editing [relationship elements](https://developers.arcgis.com/javascript/latest/api-reference/esri-form-elements-RelationshipElement.html) and [Attachments](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Attachments.html) and are not supported within this widget. Users can edit related records and attachments individually using the [FeatureForm](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureForm.html) widget.
 * > Editing utility network associations is not supported within this widget. Users can edit association fields individually using the [FeatureForm](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-FeatureForm.html) widget.
 * > [Text elements](https://developers.arcgis.com/javascript/latest/api-reference/esri-form-elements-TextElement.html) are not supported within this widget.
 * > The widget does not support editing features from layers with contingent values.
 *
 * @since 4.33
 * @see [BatchAttributeFormViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BatchAttributeForm-BatchAttributeFormViewModel.html)
 * @see [DefaultUI](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-ui-DefaultUI.html)
 * @see [Editor](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Editor.html)
 * @example
 * const batchAttributeForm = new BatchAttributeForm({
 *   container: batchAttributeFormDiv, //HTML div
 *   features: featureCollection,
 *   map: map, // Required if using Arcade expressions that use the global $map variable
 * });
 */
export default class BatchAttributeForm extends Widget<BatchAttributeFormProperties> {
  /**
   * @deprecated
   * Do not directly reference this property.
   * Use EventNames and EventTypes helpers from \@arcgis/core/Evented
   */
  "@eventTypes": BatchAttributeFormEvents;
  /**
   * @example
   * // Typical usage
   * const batchAttributeForm = new BatchAttributeForm({
   *   container: "batchAttributeFormDiv", // HTML div
   *   features: featureCollection, // Pass in the featureCollection that works with the widget
   *   map: map, // Required if using Arcade expressions that use the global $map variable
   * });
   */
  constructor(properties?: BatchAttributeFormProperties);
  /**
   * The index of the active feature that is currently being edited. This will be `-1` when {@link widgets/BatchAttributeForm#mode} is `batch`.
   * To enter `single` mode, set this property to the index in the [features](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BatchAttributeForm.html#features) array of the feature you wish to edit individually. To enter `batch` mode, set this property to `-1`.
   *
   * @default -1
   */
  accessor activeFeatureIndex: number;
  /**
   * Indicates if the widget is disabled. When `true`, the widget is not interactive and cannot be submitted.
   *
   * @default false
   */
  accessor disabled: boolean;
  /** The collection of features whose attributes are being edited. */
  accessor features: Collection<Graphic>;
  /**
   * Defines how groups will be displayed to the user.
   *
   * **Possible Values**
   *
   * Value | Description |
   * ----- | ----------- |
   * all | All groups will be expanded.
   * sequential | A single group will be expanded at a time.
   *
   * @default "all"
   */
  accessor groupDisplay: "all" | "sequential";
  /**
   * Indicates the heading level to use for the {@link widgets/BatchAttributeForm#title} of the form.
   * By default, the title is rendered as a level 2 heading (e.g. `<h2>Form title</h2>`).
   * In addition, group element labels default to a level 3 heading (e.g. `<h3>Group element label</h3>`).
   * Depending on the widget's placement
   * in your app, you may need to adjust this heading for proper semantics. This is
   * important for meeting accessibility standards.
   *
   * @default 2
   * @see [Heading Elements](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/Heading_Elements)
   * @example
   * // form title will render as an <h3>
   * // group element labels will render as an <h4>
   * featureForm.headingLevel = 3;
   */
  accessor headingLevel: HeadingLevel;
  /**
   * Icon displayed in the widget's button.
   *
   * @default "edit-attributes"
   * @see [Calcite Icon Search](https://developers.arcgis.com/calcite-design-system/icons/)
   * @since 4.27
   * @see [Calcite Icon Search](https://developers.arcgis.com/calcite-design-system/icons/)
   */
  get icon(): Icon["icon"];
  set icon(value: Icon["icon"] | null | undefined);
  /**
   * An array of objects containing a [FormTemplate](https://developers.arcgis.com/javascript/latest/api-reference/esri-form-FormTemplate.html) and its corresponding layer.
   * This provides a way to configure a `FormTemplate` with the supported field elements in `BatchAttributeForm`.
   *
   * @see [Map#editableLayers](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html#editableLayers)
   * @example
   * // Query for features
   * const { features } = await featureLayer.queryFeatures();
   *
   * // Initialize BatchAttributeForm
   * const batchAttributeForm = new BatchAttributeForm({
   *   features: features,
   *   layerInfos: [{
   *     layer: featureLayer,
   *     formTemplate:  { // autocasts to FormTemplate
   *       elements: [
   *         { // autocasts to FieldElement
   *           type: "field",
   *           fieldName: "fulladdr",
   *           label: "Full Address"
   *         }
   *       ]
   *     },
   *   }]
   * });
   */
  accessor layerInfos: AttributeFormSupportedLayerInfo[] | null | undefined;
  /**
   * A reference to the associated [Map](https://developers.arcgis.com/javascript/latest/api-reference/esri-Map.html).
   *
   * > [!WARNING]
   * >
   * > This property is required if working with [Arcade expressions](https://developers.arcgis.com/javascript/latest/arcade/) in the `BatchAttributeForm` that make use of the `$map` global variable.
   */
  accessor map: EsriMap | null | undefined;
  /**
   * Indicates whether the form is in a read-only state. If `true`, values cannot be modified.
   *
   * @default false
   */
  accessor readOnly: boolean;
  /** The time zone used to interpret date values in the form. If this property is `null` or set to `"unknown"`, date values are displayed in the time zone specified by the layer's [FeatureLayer#preferredTimeZone](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#preferredTimeZone). If none is provided there, date values are interpreted in UTC. */
  accessor timeZone: string | null | undefined;
  /** Indicates whether there are validation errors for any fields for any features. */
  get valid(): boolean;
  /**
   * The view model for this widget. This is a class that contains all the logic
   * (properties and methods) that controls this widget's behavior. See the
   * [BatchAttributeFormViewModel](https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-BatchAttributeForm-BatchAttributeFormViewModel.html) class to access
   * all properties and methods on the widget.
   */
  get viewModel(): BatchAttributeFormViewModel;
  set viewModel(value: BatchAttributeFormViewModelProperties);
  /** Defines which elements are visible in the widget. */
  get visibleElements(): VisibleElements;
  set visibleElements(value: VisibleElementsProperties);
  /**
   * This method is typically called when the user clicks a submit button or when the form is programmatically submitted and calls the [FeatureLayer#applyEdits()](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html#applyEdits) method
   * to update the features' attributes.
   */
  submit(): void;
}