import type DirectLineMeasurementAnalysis from "../../../analysis/DirectLineMeasurementAnalysis.js";
import type AnalysisView3D from "./AnalysisView3D.js";
import type { AbortOptions } from "../../../core/promiseUtils.js";
import type { DirectLineMeasurementAnalysisResult, DirectLineMeasurementPlacementResult } from "./DirectLineMeasurement/types.js";

/**
 * Represents the analysis view of a [DirectLineMeasurementAnalysis](https://developers.arcgis.com/javascript/latest/api-reference/esri-analysis-DirectLineMeasurementAnalysis.html)
 * after it has been added to [SceneView#analyses](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#analyses).
 *
 * The DirectLineMeasurementAnalysisView3D is responsible for rendering a [DirectLineMeasurementAnalysis](https://developers.arcgis.com/javascript/latest/api-reference/esri-analysis-DirectLineMeasurementAnalysis.html)
 * using custom visualizations.
 *
 * It allows to create a new analysis interactively using the [place()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-analysis-DirectLineMeasurementAnalysisView3D.html#place) method, query the measured [result](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-analysis-DirectLineMeasurementAnalysisView3D.html#result),
 * or make an existing analysis editable by enabling the [interactive](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-analysis-DirectLineMeasurementAnalysisView3D.html#interactive) property.
 *
 * The view for an analysis can be retrieved using [SceneView#whenAnalysisView()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#whenAnalysisView)
 * similar to how layer views are retrieved for layers using [SceneView#whenLayerView()](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html#whenLayerView).
 *
 * ```js
 * // retrieve analysis view for analysis
 * const analysis = new DirectLineMeasurementAnalysis();
 * view.analyses.add(analysis); // add to the scene view
 * const analysisView = await view.whenAnalysisView(analysis);
 * ```
 *
 * > [!WARNING]
 * >
 * > **Things to consider:**
 * > Snapping is enabled by default. This can be temporarily disabled by holding the `CTRL` key.
 * > Layer types currently supported for snapping are: [FeatureLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-FeatureLayer.html), [GraphicsLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GraphicsLayer.html) (except Mesh geometries),
 * > [GeoJSONLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-GeoJSONLayer.html), [WFSLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-WFSLayer.html), [CSVLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-CSVLayer.html),
 * > [3D Object SceneLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-SceneLayer.html), and [BuildingSceneLayer](https://developers.arcgis.com/javascript/latest/api-reference/esri-layers-BuildingSceneLayer.html).
 *
 * @see [DirectLineMeasurementAnalysis](https://developers.arcgis.com/javascript/latest/api-reference/esri-analysis-DirectLineMeasurementAnalysis.html)
 * @see [Direct Line Measurement 3D component](https://developers.arcgis.com/javascript/latest/references/map-components/arcgis-direct-line-measurement-3d/)
 * @see [Sample - Analysis objects](https://developers.arcgis.com/javascript/latest/sample-code/analysis-objects/)
 */
export default abstract class DirectLineMeasurementAnalysisView3D extends AnalysisView3D {
  /**
   * The direct line measurement analysis object associated with the analysis view.
   *
   * @since 4.24
   */
  get analysis(): DirectLineMeasurementAnalysis;
  /**
   * Enables interactivity for the associated [analysis](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-analysis-DirectLineMeasurementAnalysisView3D.html#analysis). When set to `true`, manipulators will be displayed,
   * allowing users to click and drag to edit the analysis if it has a valid
   * [DirectLineMeasurementAnalysis#startPoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-analysis-DirectLineMeasurementAnalysis.html#startPoint) and
   * [DirectLineMeasurementAnalysis#endPoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-analysis-DirectLineMeasurementAnalysis.html#endPoint).
   *
   * This property is automatically set to `true` when the analysis is assigned to a
   * [Direct Line Measurement 3D component](https://developers.arcgis.com/javascript/latest/references/map-components/arcgis-direct-line-measurement-3d/).
   *
   * @default false
   * @since 4.33
   */
  accessor interactive: boolean;
  /**
   * Result of the direct line measurement. Results are calculated asynchronously and should be
   * watched for changes.
   */
  accessor result: DirectLineMeasurementAnalysisResult | null | undefined;
  /**
   * The analysis view type.
   *
   * @since 4.24
   */
  get type(): "direct-line-measurement-view-3d";
  /**
   * When `true`, the analysis is visualized in the view.
   *
   * @since 4.24
   */
  get visible(): boolean;
  set visible(value: boolean | null | undefined);
  /**
   * Starts the interactive placement of a direct line measurement.
   *
   * If the analysis does not have a [DirectLineMeasurementAnalysis#startPoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-analysis-DirectLineMeasurementAnalysis.html#startPoint)
   * and [DirectLineMeasurementAnalysis#endPoint](https://developers.arcgis.com/javascript/latest/api-reference/esri-analysis-DirectLineMeasurementAnalysis.html#endPoint) yet, the method allows placing
   * the start and end points interactively in the view. If the analysis already has a measurement, clicking in the view will remove it and
   * start the placement of new start and end points.
   *
   * The placement operation will finish when the user presses the escape key.
   * To stop the placing programmatically, pass an abort signal as an argument when calling the method.
   *
   * Calling this method sets [interactive](https://developers.arcgis.com/javascript/latest/api-reference/esri-views-3d-analysis-DirectLineMeasurementAnalysisView3D.html#interactive) to `true`.
   *
   * @param options - An object specifying additional options.
   * @returns A promise which resolves when the operation is completed successfully or rejected if it is canceled.
   * @since 4.33
   * @example
   * const abortController = new AbortController();
   *
   * try {
   *   await analysisView.place({ signal: abortController.signal });
   * } catch (error) {
   *   if (error.name === "AbortError") {
   *     console.log("Placement operation was cancelled.");
   *   }
   * }
   *
   * // cancel the placement operation at some later point
   * abortController.abort();
   */
  place(options?: AbortOptions | null | undefined): Promise<DirectLineMeasurementPlacementResult>;
}