import type CreateFeaturesWorkflowData from "./CreateFeaturesWorkflowData.js";
import type MergeFeaturesWorkflowData from "./MergeFeaturesWorkflowData.js";
import type SplitFeatureWorkflowData from "./SplitFeatureWorkflowData.js";
import type UpdateFeaturesWorkflowData from "./UpdateFeaturesWorkflowData.js";
import type UpdateWorkflowData from "./UpdateWorkflowData.js";
import type { EventedAccessor } from "../../core/Evented.js";
import type { CancelWorkflowOptions } from "./types.js";

export interface WorkflowProperties<D extends CreateFeaturesWorkflowData | MergeFeaturesWorkflowData | SplitFeatureWorkflowData | UpdateWorkflowData | UpdateFeaturesWorkflowData = CreateFeaturesWorkflowData | MergeFeaturesWorkflowData | SplitFeatureWorkflowData | UpdateWorkflowData | UpdateFeaturesWorkflowData, S extends string = string> {}

export interface WorkflowEvents {}

/**
 * The read-only `Workflow` class helps manage different stages of an [editing](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/) workflow.
 * A workflow can be thought of as one of two types: [CreateFeaturesWorkflow](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/CreateFeaturesWorkflow/) and [UpdateWorkflow](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/UpdateWorkflow/).
 * If adding an individual or multiple features, the [CreateFeaturesWorkflow](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/CreateFeaturesWorkflow/) is used. Whereas if editing an existing feature, the [UpdateWorkflow](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/UpdateWorkflow/) is used.
 * Updating workflows include both editing geometry and attribute data and deleting features.
 *
 * An instance of either a [CreateFeaturesWorkflow](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/CreateFeaturesWorkflow/) or [UpdateWorkflow](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/UpdateWorkflow/)
 * is accessed via the `activeWorkflow` property in either the [Editor.activeWorkflow](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/#activeWorkflow) or [EditorViewModel.activeWorkflow](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/EditorViewModel/#activeWorkflow) classes.
 *
 * > [!WARNING]
 * >
 * > These workflows are only enabled if the feature service allows these operations. For example, if a feature service is only enabled to allow updates, it is not possible to override this using the API.
 *
 * @since 4.11
 * @see [Editor](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/)
 * @see [EditorViewModel](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/EditorViewModel/)
 * @see [CreateFeaturesWorkflow](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/CreateFeaturesWorkflow/)
 * @see [CreateFeaturesWorkflowData](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/CreateFeaturesWorkflowData/)
 * @see [UpdateWorkflow](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/UpdateWorkflow/)
 * @see [UpdateWorkflowData](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/UpdateWorkflowData/)
 * @see [Sample - Popup with edit action](https://developers.arcgis.com/javascript/latest/sample-code/popup-editaction/)
 */
export default class Workflow<D extends CreateFeaturesWorkflowData | MergeFeaturesWorkflowData | SplitFeatureWorkflowData | UpdateWorkflowData | UpdateFeaturesWorkflowData = CreateFeaturesWorkflowData | MergeFeaturesWorkflowData | SplitFeatureWorkflowData | UpdateWorkflowData | UpdateFeaturesWorkflowData, S extends string = string> extends EventedAccessor {
  constructor(properties?: WorkflowProperties<D, S>);
  /**
   * The shared workflow data. This can be either
   * [CreateFeaturesWorkflowData](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/CreateFeaturesWorkflowData/), [UpdateWorkflowData](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/UpdateWorkflowData/), [UpdateFeaturesWorkflowData](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/UpdateFeaturesWorkflowData/), [MergeFeaturesWorkflowData](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/MergeFeaturesWorkflowData/), or
   * [SplitFeatureWorkflowData](https://developers.arcgis.com/javascript/latest/references/core/widgets/Editor/SplitFeatureWorkflowData/).
   */
  get data(): D;
  /** This property indicates whether there is a next step in the workflow. */
  get hasNextStep(): boolean;
  /** This property indicates if there is a previous step in the workflow. */
  get hasPreviousStep(): boolean;
  /**
   * Indicates whether the workflow is considered active.
   *
   * @default false
   */
  get started(): boolean;
  /** The name of the current step in the workflow. */
  get stepId(): S;
  /**
   * Value indicating the workflow type.
   *
   * | Possible Value | Description |
   * | -------------- | ----------- |
   * | create-features |  This allows the end user to create either individual or continuous features in the feature service. (Since 4.23) |
   * | update | This allows the end user to update and/or delete features in the feature service. |
   *
   * > [!WARNING]
   * >
   * > These workflows are only enabled if the feature service allows these operations.
   */
  get type(): "add-association" | "create-features" | "merge-features" | "split-feature" | "update" | "update-feature" | "update-features" | "update-table-record";
  /**
   * Cancels the active workflow.
   *
   * @param options - An object with the following properties.
   * @returns Resolves when the active workflow is canceled.
   */
  cancel(options?: CancelWorkflowOptions): Promise<void>;
  /**
   * Call this method when the workflow is considered finished. This is used to help process the editing results.
   *
   * @returns Resolves when the active workflow commits and processes the edited results.
   * @since 4.15
   */
  commit(): Promise<void>;
  /**
   * Moves to the next step in the workflow.
   *
   * @returns Resolves when moved to the next step within the active workflow.
   */
  next(): Promise<void>;
  /**
   * Moves to the previous step in the workflow.
   *
   * @param options - Options when calling this method.
   * @returns Resolves when moved to the previous step within the active workflow.
   */
  previous(options?: WorkflowPreviousOptions): Promise<void>;
  /**
   * Resets the workflow.
   *
   * @returns Resolves when the active workflow is reset.
   */
  reset(): Promise<void>;
  /**
   * Starts the workflow.
   *
   * @returns Resolves when the active workflow starts.
   */
  start(): Promise<any>;
}

export interface WorkflowPreviousOptions {
  /** Cancels the current workflow when calling this method. Default value is `false`. */
  cancelCurrentStep: boolean;
}