/**
 * Performs an overlay operation on a set of 2D polygons in the XY plane.
 * This operation produces similar results to the Union tool in Geoprocessing.
 *
 * @since 4.31
 */
import type Polygon from "../Polygon.js";

export interface Options {
  /**
   * Output overlapping areas of polygons.
   *
   * @default true
   */
  overlaps?: boolean;
  /**
   * Output non-overlapping areas of polygons.
   *
   * @default true
   */
  noOverlaps?: boolean;
  /**
   * Create polygons to fill gaps.
   * Gaps are empty areas between different polygons, that have a closed boundary.
   */
  gaps?: boolean;
  /**
   * Create polygons to fill holes.
   * Holes are empty areas completely enclosed by a single polygon.
   * In addition to regular holes formed by the interior rings, the operator considers any empty area that has a closed boundary formed by the segments of same polygon to be a hole.
   * For example, a gap between two or more exterior rings of same polygon is also considered a hole.
   */
  holes?: boolean;
  /**
   * Output multipart polygons.
   * Multipart output requires more processing.
   * If the option is not set, the output will contain single part polygons (one exterior ring and zero or more holes).
   */
  multiPart?: boolean;
}

/** Object returned by the [executeMany()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-operators-polygonOverlayOperator.html#executeMany) method. */
export interface ExecuteManyResult {
  /** The array of polygons returned by the operator. */
  results: Polygon[];
  /** The corresponding set of ids for each result. Each id is the index of the polygon in the input array. result[0] corresponds to ids[0], result[1] to ids[1], etc. */
  ids: number[][];
}

/**
 * Performs the topological overlay of the geometry set in the XY plane.
 *
 * @param polygons - The set of polygons to overlay.
 * All the polygons must have the same spatial reference.
 * @param options - Additional options.
 * @returns Returns the result polygons and ids.
 * Overlaps have two or more ids, no-overlaps have one id, and gaps have no ids.
 * @example
 * // Overlay a set of polygons
 * const result = polygonOverlayOperator.executeMany(polygons);
 */
export function executeMany(polygons: Polygon[], options?: Options): ExecuteManyResult;

/**
 * Indicates if the operator supports input polygons that contain curves.
 * The value will always be `true`.
 */
export const supportsCurves: boolean;