/**
 * Utils for knowledge studio supporting access to utilities shared between Studio and the SDK
 *
 * NOTE TO DEVS
 * MINIMIZE USE OF INTERNAL SDK ACCESS!
 * To the maximum extent possible, ArcGIS Knowledge Studio should use the same public interface as
 * PS/3rd party developers.
 *
 * @internal
 * @internal
 */
import type Graphic from "../../Graphic.js";
import type FeatureLayer from "../../layers/FeatureLayer.js";
import type KnowledgeGraphLayer from "../../layers/KnowledgeGraphLayer.js";
import type LinkChartLayer from "../../layers/LinkChartLayer.js";
import type LinkChartView from "../../views/LinkChartView.js";
import type MapView from "../../views/MapView.js";
import type { Evented } from "../../core/Evented.js";

/**
 * @internal
 * @since 5.0
 * @internal
 */
export interface TypedSelectionToolbarViewModel extends Evented {
  /**
   * @internal
   * @since 5.0
   */
  "@eventTypes": TypedSelectionToolbarViewModelEvents;
  /**
   * @internal
   * @since 5.0
   */
  activate: TypedSelectionToolbarViewModelActivate;
  /**
   * @internal
   * @since 5.0
   */
  cancel: () => void;
  /**
   * @internal
   * @since 5.0
   */
  destroy: () => void;
  /**
   * @internal
   * @since 5.0
   */
  sources?: Array<FeatureLayer | KnowledgeGraphLayer | LinkChartLayer> | null;
}

/**
 * @param parameters - The selection operation parameters.
 * @internal
 * @since 5.0
 * @internal
 */
export type TypedSelectionToolbarViewModelActivate = (parameters: SelectionOperationParameters) => void;

/**
 * @internal
 * @since 5.0
 * @internal
 */
export interface SelectionOperationParameters {
  /**
   * @internal
   * @since 5.0
   */
  createTool: "point" | "polygon" | "circle" | "rectangle";
  /**
   * @internal
   * @since 5.0
   */
  mode: "freehand" | "click";
  /**
   * @internal
   * @since 5.0
   */
  selectOnComplete?: boolean;
  /**
   * @internal
   * @since 5.0
   */
  type?: "add" | "remove" | "replace";
}

/**
 * @internal
 * @since 5.0
 * @internal
 */
export interface TypedSelectionToolbarViewModelEvents {
  /**
   * @internal
   * @since 5.0
   */
  complete: TypedSelectionToolbarViewModelSelectionResultType;
}

/**
 * @internal
 * @since 5.0
 * @internal
 */
export interface TypedSelectionToolbarViewModelSelectionResultType {
  /**
   * @internal
   * @since 5.0
   */
  aborted: boolean;
  /**
   * @internal
   * @since 5.0
   */
  operationType: "add" | "remove" | "replace";
  /**
   * @internal
   * @since 5.0
   */
  selection: Graphic[];
}

/**
 * @param view - The MapView instance.
 * @param sources - An array of layers to be used as sources for selection.
 * @returns A new instance of SelectionToolbarViewModel.
 * @internal
 * @since 5.0
 * @internal
 */
export function getNewTypedSelectionToolbarViewModel(view: MapView | LinkChartView, sources?: Array<FeatureLayer | KnowledgeGraphLayer | LinkChartLayer>): TypedSelectionToolbarViewModel;

/**
 * @param domains - An array of domain strings to be registered as no-CORS domains.
 * @internal
 * @since 5.0
 * @internal
 */
export function typedRegisterNoCorsDomain(domains: string[]): void;