import type CursorUpdateEvent from "./CursorUpdateEvent.js";
import type DrawAction from "./DrawAction.js";
import type DrawCompleteEvent from "./DrawCompleteEvent.js";
import type VertexAddEvent from "./VertexAddEvent.js";
import type VertexRemoveEvent from "./VertexRemoveEvent.js";
import type { DrawActionProperties } from "./DrawAction.js";

export interface MultipointDrawActionProperties extends DrawActionProperties {}

export interface MultipointDrawActionEvents {
  /**
   * Fires after the pointer moves on the view.
   *
   * @example
   * // fires when the pointer moves on the view.
   * action.on("cursor-update", function (evt) {
   *   view.graphics.removeAll();
   *   let multipoint = new Multipoint({
   *     points: evt.vertices,
   *     spatialReference: view.spatialReference
   *   });
   *   let graphic = createGraphic(multipoint);
   *   view.graphics.add(graphic);
   * });
   */
  "cursor-update": CursorUpdateEvent;
  /**
   * Fires after the user has completed drawing a [Multipoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Multipoint.html).
   *
   * @example
   * // fires when completed drawing the multipoint.
   * action.on("draw-complete", function (evt) {
   *   view.graphics.removeAll();
   *   let multipoint = new Multipoint({
   *     points: evt.vertices,
   *     spatialReference: view.spatialReference
   *   });
   *   let graphic = createGraphic(multipoint);
   *   view.graphics.add(graphic);
   * });
   */
  "draw-complete": DrawCompleteEvent;
  /**
   * Fires in response to redo action or when [redo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-draw-MultipointDrawAction.html#redo) is called.
   *
   * @since 4.7
   * @example
   * // Update the graphic on the view as the last action was redone
   * action.on("redo", function (evt) {
   *   view.graphics.removeAll();
   *   let multipoint = new Multipoint({
   *     points: evt.vertices,
   *     spatialReference: view.spatialReference
   *   });
   *   let graphic = createGraphic(multipoint);
   *   view.graphics.add(graphic);
   * });
   */
  redo: VertexAddEvent | VertexRemoveEvent;
  /**
   * Fires in response to undo action or when [undo()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-draw-MultipointDrawAction.html#undo) is called.
   *
   * @since 4.7
   * @example
   * // Update the graphic on the view as the last action was undone
   * action.on("undo", function (evt) {
   *   view.graphics.removeAll();
   *   let multipoint = new Multipoint({
   *     points: evt.vertices,
   *     spatialReference: view.spatialReference
   *   });
   *   let graphic = createGraphic(multipoint);
   *   view.graphics.add(graphic);
   * });
   */
  undo: VertexAddEvent | VertexRemoveEvent;
  /**
   * Fires when a point is added to the multipoint.
   *
   * @example
   * // fires when a point is added to the multipoint.
   * action.on("vertex-add", function (evt) {
   *   view.graphics.removeAll();
   *   let multipoint = new Multipoint({
   *     points: evt.vertices,
   *     spatialReference: view.spatialReference
   *   });
   *   let graphic = createGraphic(multipoint);
   *   view.graphics.add(graphic);
   * });
   */
  "vertex-add": VertexAddEvent;
  /**
   * Fires when a point is removed from the multipoint.
   *
   * @example
   * // fires when a point is removed from multipoint.
   * action.on("vertex-remove", function (evt) {
   *   view.graphics.removeAll();
   *   let multipoint = new Multipoint({
   *     points: evt.vertices,
   *     spatialReference: view.spatialReference
   *   });
   *   let graphic = createGraphic(multipoint);
   *   view.graphics.add(graphic);
   * });
   */
  "vertex-remove": VertexRemoveEvent;
}

/**
 * This class uses the view events to generate a set of coordinates to create a new [Multipoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Multipoint.html)
 * geometry using [Draw](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-draw-Draw.html). When the [draw.create("multipoint")](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-draw-Draw.html#create)
 * method is called, a reference to MultipointDrawAction is returned. You can listen to [events](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-draw-MultipointDrawAction.html#MultipointDrawActionEvents)
 * on the MultipointDrawAction instance, which allows users to create a multipoint that meets criteria specified by the application.
 *
 * > [!WARNING]
 * >
 * > **Known Limitations**
 * >
 * > Currently the MultipointDrawAction is only supported in a [MapView](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html).
 *
 * @since 4.6
 * @see [Sample - Prevent drawing a self-intersecting line](https://developers.arcgis.com/javascript/latest/sample-code/draw-line/)
 * @example
 * function enableCreateMultipoint(draw, view) {
 *   let action = draw.create("multipoint");
 *
 *   // Give a visual feedback to users as they move the pointer over the view
 *   action.on("cursor-update", function (evt) {
 *     createMultipointGraphic(evt.vertices);
 *   });
 *
 *   // Fires when the user clicks, or presses the "F" key on the view
 *   // Can also fire when the "R" key is pressed to redo.
 *   action.on("vertex-add", function (evt) {
 *     createMultipointGraphic(evt.vertices);
 *   });
 *
 *   // Fires when the "Z" key is pressed to undo the last added point
 *   action.on("vertex-remove", function (evt) {
 *     createMultipointGraphic(evt.vertices);
 *   });
 *
 *   // Create a point when user clicks on the view or presses the "Enter" key.
 *   action.on("draw-complete", function (evt) {
 *     createMultipointGraphic(evt.vertices);
 *   });
 * }
 *
 * function createMultipointGraphic(vertices) {
 *   view.graphics.removeAll();
 *
 *   let multipoint = new Multipoint({
 *     points: vertices,
 *     spatialReference: view.spatialReference
 *   });
 *
 *   graphic = new Graphic({
 *     geometry: multipoint,
 *     symbol: {
 *       type: "simple-marker",
 *       style: "square",
 *       color: "red",
 *       size: "16px",
 *       outline: {
 *         color: [255, 255, 0],
 *         width: 3
 *       }
 *     }
 *   });
 *   view.graphics.add(graphic);
 * }
 */
export default class MultipointDrawAction extends DrawAction {
  /**
   * @deprecated
   * Do not directly reference this property.
   * Use EventNames and EventTypes helpers from \@arcgis/core/Evented
   */
  "@eventTypes": MultipointDrawActionEvents;
  constructor(properties?: MultipointDrawActionProperties);
  /**
   * Completes drawing the [Multipoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-Multipoint.html) geometry and fires the [@draw-complete](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-draw-MultipointDrawAction.html#event-draw-complete) event.
   * Call this method if the drawing logic needs to be completed other than by double-clicking or pressing the "Enter" key.
   */
  complete(): void;
}