/**
 * Returns the geodetic length of a 2D geometry.
 *
 * > [!WARNING]
 * >
 * > **Notes**
 * > Verify that `isLoaded()` returns `true` before using this module.
 * > Use `load()` to load this module's dependencies.
 *
 * @since 4.31
 */
import type { LengthUnit } from "../../core/units.js";
import type { GeometryUnion, GeodeticCurveType } from "../types.js";

export interface Options {
  /**
   * The type of geodetic curve used to determine the length.
   *
   * @default "geodesic"
   */
  curveType?: GeodeticCurveType;
  /**
   * The length unit of the return value.
   *
   * @default "meters"
   */
  unit?: LengthUnit;
}

/**
 * Indicates if all dependencies of this module have been loaded.
 *
 * @returns Returns `true` if this module's dependencies have been loaded.
 */
export function isLoaded(): boolean;

/**
 * Loads this module's dependencies. This method must be called first if `isLoaded` returns `false`.
 *
 * @returns Resolves when the dependencies have been loaded.
 * @see [isLoaded()](https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-operators-geodeticLengthOperator.html#isLoaded)
 */
export function load(): Promise<void>;

/**
 * Calculates the geodetic length of the input Geometry.
 * Unless the `unit` option is set, the default is meters.
 *
 * @param geometry - The input geometry.
 * @param options - Additional options.
 * @returns Returns the geodetic length of the input geometry.
 * @example
 * if (!geodeticLengthOperator.isLoaded()) {
 *   await geodeticLengthOperator.load();
 * }
 *
 * // Calculate the geodetic length of a polyline
 * const length = geodeticLengthOperator.execute(polyline);
 */
export function execute(geometry: GeometryUnion, options?: Options): number;

/**
 * Indicates if the operator supports input geometries that contain curves.
 * The value is `null` or `undefined` until the operator is loaded, then it will always be `true`.
 */
export const supportsCurves: boolean | null | undefined;