@arcgis/core 5.1.0-next.106 → 5.1.0-next.107
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/arcgisGlobal.d.ts +5 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{b7a81fd4994eabba1869.js → 0c8e6ccb5a8174718d62.js} +1 -1
- package/assets/esri/core/workers/chunks/{be817be7c81fb630122f.js → 17604cbd4d24158e2c16.js} +1 -1
- package/assets/esri/core/workers/chunks/{065dd2fdc834146423c7.js → 33ec193e6d7a0cb9d8dd.js} +1 -1
- package/assets/esri/core/workers/chunks/{f9324420f2c6ac240f63.js → 37c63570c0b4981cd519.js} +1 -1
- package/assets/esri/core/workers/chunks/{15920af0c4f46773b06e.js → 502c3da8c49bf885f51d.js} +1 -1
- package/assets/esri/core/workers/chunks/518046d2b95a7590a092.js +1 -0
- package/assets/esri/core/workers/chunks/{aaad0d3e82ed917d3886.js → 547dc6ccb989bd962661.js} +1 -1
- package/assets/esri/core/workers/chunks/{bd59cb5abc67e46f1b2c.js → 55334ad3618899cdbf78.js} +2 -2
- package/assets/esri/core/workers/chunks/{d859c046a3ea42530bff.js → 56d9d3f108ff6e719dd4.js} +1 -1
- package/assets/esri/core/workers/chunks/75a7de23c05435ec7649.js +1 -0
- package/assets/esri/core/workers/chunks/7b66691d133dabd87ce6.js +1 -0
- package/assets/esri/core/workers/chunks/{dcba6c766eee8b90381a.js → 8557dd9ef336b23f768f.js} +1 -1
- package/assets/esri/core/workers/chunks/9234a293d61e134f121f.js +1 -0
- package/assets/esri/core/workers/chunks/{a8ae00e06f98e04aee8e.js → ac408c62565e2c8b5975.js} +1 -1
- package/assets/esri/core/workers/chunks/{f7fe17a22390a24d6df8.js → b69d1d528e271568cbd8.js} +2 -2
- package/assets/esri/core/workers/chunks/{0cc74bc3772be51cabc1.js → bbaf8baa3ca6195467e4.js} +1 -1
- package/assets/esri/core/workers/chunks/{b9850fe7dcdaed0c327c.js → cdb48d198145493f76f3.js} +1 -1
- package/assets/esri/core/workers/chunks/{63ea4191d441efd2f146.js → d4014213c476bf8099af.js} +1 -1
- package/assets/esri/geometry/support/pe-wasm.wasm +0 -0
- package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
- package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
- package/assets/esri/themes/base/widgets/_Sketch.scss +1 -24
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ar.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_bg.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_bs.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ca.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_cs.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_da.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_de.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_el.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_es.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_et.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_fi.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_fr.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_he.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_hr.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_hu.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_id.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_it.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ja.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ko.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_lt.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_lv.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_nl.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_no.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_pl.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_pt-BR.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_pt-PT.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ro.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ru.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sk.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sl.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sr.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sv.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_th.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_tr.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_uk.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_vi.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_zh-CN.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_zh-HK.json +1 -1
- package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_zh-TW.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable.json +1 -1
- package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_en.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_en.json +1 -1
- package/chunks/Fog.glsl.js +3 -3
- package/chunks/GlowComposition.glsl.js +38 -56
- package/chunks/OITDimOpaque.glsl.js +8 -3
- package/chunks/SimpleAtmosphere.glsl.js +3 -3
- package/chunks/lyr3DWorker.js +1 -1
- package/chunks/pe-wasm.js +1 -1
- package/config.js +1 -1
- package/geometry/support/WKIDUnitConversion.js +1 -1
- package/identity/IdentityManagerBase.js +1 -1
- package/kernel.js +1 -1
- package/layers/raster/datasets/MRFRaster.js +1 -1
- package/layers/video/VideoController.js +1 -1
- package/package.json +3 -3
- package/rest/networks/circuits/support/CircuitVerifyResult.js +1 -1
- package/rest/networks/circuits/support/VerifyCircuitsResult.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightAuthoringUtils.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightIntersectionResult.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightRayIntersector.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedConfiguration.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedPlacementController.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementShiftTool.js +1 -1
- package/views/3d/environment/FoggyWeather.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/i3s/Intersector.js +1 -1
- package/views/3d/support/ResourceController.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatIntersectionHandler.js +1 -1
- package/views/3d/webgl-engine/effects/blit/Blit.js +1 -1
- package/views/3d/webgl-engine/effects/fog/Fog.js +1 -1
- package/views/3d/webgl-engine/effects/glow/Glow.js +1 -1
- package/views/3d/webgl-engine/effects/glow/GlowCompositionTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/draw/DrawTool.d.ts +77 -0
- package/views/draw/support/editingSessionUtils.js +1 -1
- package/views/draw/support/managers/PluginLifecycleManager.d.ts +10 -0
- package/views/interactive/InteractiveToolBase.d.ts +11 -0
- package/views/interactive/editGeometry/interfaces.d.ts +8 -0
- package/views/interactive/interfaces.d.ts +20 -0
- package/views/webgl/capabilities/load.js +1 -1
- package/widgets/CoordinateConversion/CoordinateConversionViewModel.d.ts +9 -1
- package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
- package/widgets/Sketch/SketchViewModel.d.ts +67 -2
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/Sketch/VisibleElements.d.ts +19 -1
- package/widgets/Sketch/VisibleElements.js +1 -1
- package/widgets/Sketch/support/OperationHandle.js +1 -1
- package/widgets/Sketch/support/PluginManager.d.ts +12 -0
- package/widgets/Sketch/support/PluginManager.js +1 -1
- package/widgets/Sketch.js +1 -1
- package/widgets/support/SelectionToolbar/SelectionToolbarViewModel.d.ts +81 -0
- package/widgets/support/SelectionToolbar/types.d.ts +4 -0
- package/assets/esri/core/workers/chunks/2b3a8a53cd68f666676b.js +0 -1
- package/assets/esri/core/workers/chunks/2ecb21c402cdd8c82533.js +0 -1
- package/assets/esri/core/workers/chunks/7e02e5c6979090fe3ea7.js +0 -1
- package/assets/esri/core/workers/chunks/fae2c8f053927559fff0.js +0 -1
- /package/assets/esri/core/workers/chunks/{bd59cb5abc67e46f1b2c.js.LICENSE.txt → 55334ad3618899cdbf78.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{f7fe17a22390a24d6df8.js.LICENSE.txt → b69d1d528e271568cbd8.js.LICENSE.txt} +0 -0
|
@@ -14,8 +14,11 @@ import type SnappingOptions from "../../views/interactive/snapping/SnappingOptio
|
|
|
14
14
|
import type { EventedAccessor } from "../../core/Evented.js";
|
|
15
15
|
import type { TextSymbolProperties } from "../../symbols/TextSymbol.js";
|
|
16
16
|
import type { MapViewOrSceneView } from "../../views/MapViewOrSceneView.js";
|
|
17
|
+
import type { DrawTool } from "../../views/draw/DrawTool.js";
|
|
18
|
+
import type { PluginConfiguration } from "../../views/draw/support/types.js";
|
|
17
19
|
import type { SnappingOptionsProperties } from "../../views/interactive/snapping/SnappingOptions.js";
|
|
18
20
|
import type { CreateEvent, CreateOptions, CreateTool, CreationMode, DeleteEvent, RedoEvent, SketchPointSymbol, SketchPolygonSymbol, SketchPolylineSymbol, SketchTool, State, UpdateEvent, UpdateOptions, UndoEvent } from "./types.js";
|
|
21
|
+
import type { PluginManager } from "./support/PluginManager.js";
|
|
19
22
|
import type { CIMSymbolProperties } from "../../symbols/CIMSymbol.js";
|
|
20
23
|
import type { SimpleFillSymbolProperties } from "../../symbols/SimpleFillSymbol.js";
|
|
21
24
|
import type { SketchLabelOptionsProperties } from "../../views/interactive/sketch/SketchLabelOptions.js";
|
|
@@ -29,7 +32,7 @@ import type { SimpleLineSymbolProperties } from "../../symbols/SimpleLineSymbol.
|
|
|
29
32
|
import type { SketchTooltipOptionsProperties } from "../../views/interactive/sketch/SketchTooltipOptions.js";
|
|
30
33
|
import type { SketchValueOptionsProperties } from "../../views/interactive/sketch/SketchValueOptions.js";
|
|
31
34
|
|
|
32
|
-
export interface SketchViewModelProperties extends Partial<Pick<SketchViewModel, "creationMode" | "layer" | "updateOnGraphicClick" | "useLegacyCreateTools" | "view">> {
|
|
35
|
+
export interface SketchViewModelProperties extends Partial<Pick<SketchViewModel, "creationMode" | "layer" | "rootPlugins" | "updateOnGraphicClick" | "useLegacyCreateTools" | "view">> {
|
|
33
36
|
/**
|
|
34
37
|
* The [SimpleFillSymbol](https://developers.arcgis.com/javascript/latest/references/core/symbols/SimpleFillSymbol/) displayed when actively creating a new `polygon` graphic using the [polygon](https://developers.arcgis.com/javascript/latest/references/core/widgets/Sketch/SketchViewModel/#activeTool) tool.
|
|
35
38
|
*
|
|
@@ -641,10 +644,30 @@ export default class SketchViewModel extends EventedAccessor {
|
|
|
641
644
|
*/
|
|
642
645
|
get defaultUpdateOptions(): UpdateOptions;
|
|
643
646
|
set defaultUpdateOptions(value: Partial<UpdateOptions>);
|
|
647
|
+
/**
|
|
648
|
+
* The active tool instance when DrawTool is in use.
|
|
649
|
+
*
|
|
650
|
+
* @internal
|
|
651
|
+
*/
|
|
652
|
+
get drawTool(): DrawTool | null | undefined;
|
|
653
|
+
/**
|
|
654
|
+
* Gets available plugins given the active plugins.
|
|
655
|
+
* If the parent of the leaf plugin supports multiple downstream plugin options,
|
|
656
|
+
* those are returned. Otherwise, the root plugins are returned.
|
|
657
|
+
*
|
|
658
|
+
* @internal
|
|
659
|
+
*/
|
|
660
|
+
get effectiveAvailablePlugins(): PluginConfiguration[] | null | undefined;
|
|
661
|
+
/**
|
|
662
|
+
* The first plugin in the active Draw 2.0 stack whose downstream leaf can be swapped.
|
|
663
|
+
*
|
|
664
|
+
* @internal
|
|
665
|
+
*/
|
|
666
|
+
get firstPluginWithSwappableLeaf(): PluginConfiguration | null | undefined;
|
|
644
667
|
/**
|
|
645
668
|
* Indicates whether an asynchronous geometry simplification operation is in progress.
|
|
646
669
|
*
|
|
647
|
-
* Starting new operations (update, create)
|
|
670
|
+
* Starting new operations (update, create) should be blocked when this is true. Call
|
|
648
671
|
* `cancel` to cancel the long-running operation.
|
|
649
672
|
*
|
|
650
673
|
* @since 5.1
|
|
@@ -680,6 +703,24 @@ export default class SketchViewModel extends EventedAccessor {
|
|
|
680
703
|
* @since 4.6
|
|
681
704
|
*/
|
|
682
705
|
accessor layer: GraphicsLayer | MapNotesLayer | null | undefined;
|
|
706
|
+
/**
|
|
707
|
+
* True if DrawTool is using multiple plugins in a stack.
|
|
708
|
+
*
|
|
709
|
+
* This is typically true for drawing scenarios like polyline
|
|
710
|
+
* and polygon, and false if Draw 2.0 is not active or a
|
|
711
|
+
* very simple plugin like point is active.
|
|
712
|
+
*
|
|
713
|
+
* @internal
|
|
714
|
+
*/
|
|
715
|
+
get multiplePluginsActive(): boolean;
|
|
716
|
+
/**
|
|
717
|
+
* PluginManager manages the available DrawTool plugins on behalf of SketchViewModel,
|
|
718
|
+
* and provides utilities for translating from Draw 1.0/CreateTool based
|
|
719
|
+
* configuration to Draw 2.0 Plugin-based configuration.
|
|
720
|
+
*
|
|
721
|
+
* @internal
|
|
722
|
+
*/
|
|
723
|
+
get pluginManager(): PluginManager;
|
|
683
724
|
/**
|
|
684
725
|
* A [SimpleMarkerSymbol](https://developers.arcgis.com/javascript/latest/references/core/symbols/SimpleMarkerSymbol/), [PictureMarkerSymbol](https://developers.arcgis.com/javascript/latest/references/core/symbols/PictureMarkerSymbol/), [PointSymbol3D](https://developers.arcgis.com/javascript/latest/references/core/symbols/PointSymbol3D/), [TextSymbol](https://developers.arcgis.com/javascript/latest/references/core/symbols/TextSymbol/), [CIMSymbol](https://developers.arcgis.com/javascript/latest/references/core/symbols/CIMSymbol/), or [WebStyleSymbol](https://developers.arcgis.com/javascript/latest/references/core/symbols/WebStyleSymbol/) used for representing the point geometry that is being drawn. [SimpleMarkerSymbol](https://developers.arcgis.com/javascript/latest/references/core/symbols/SimpleMarkerSymbol/) may also be used to symbolize point features in a [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/). However, it is recommended you use [PointSymbol3D](https://developers.arcgis.com/javascript/latest/references/core/symbols/PointSymbol3D/) instead.
|
|
685
726
|
*
|
|
@@ -745,6 +786,13 @@ export default class SketchViewModel extends EventedAccessor {
|
|
|
745
786
|
*/
|
|
746
787
|
get polylineSymbol(): SketchPolylineSymbol;
|
|
747
788
|
set polylineSymbol(value: ((SimpleLineSymbolProperties & { type: "simple-line" }) | (LineSymbol3DProperties & { type: "line-3d" }) | (CIMSymbolProperties & { type: "cim" })));
|
|
789
|
+
/**
|
|
790
|
+
* The top-level plugins to show in Sketch.
|
|
791
|
+
* Typically point, polyline, polygon, rectangle, circle, etc.
|
|
792
|
+
*
|
|
793
|
+
* @internal
|
|
794
|
+
*/
|
|
795
|
+
accessor rootPlugins: PluginConfiguration[] | null | undefined;
|
|
748
796
|
/**
|
|
749
797
|
* The [SnappingOptions](https://developers.arcgis.com/javascript/latest/references/core/views/interactive/snapping/SnappingOptions/) for sketching. It supports [self](https://developers.arcgis.com/javascript/latest/references/core/views/interactive/snapping/SnappingOptions/#selfEnabled) and [feature](https://developers.arcgis.com/javascript/latest/references/core/views/interactive/snapping/SnappingOptions/#featureEnabled) snapping.
|
|
750
798
|
*
|
|
@@ -768,6 +816,17 @@ export default class SketchViewModel extends EventedAccessor {
|
|
|
768
816
|
*/
|
|
769
817
|
get tooltipOptions(): SketchTooltipOptions;
|
|
770
818
|
set tooltipOptions(value: SketchTooltipOptionsProperties);
|
|
819
|
+
/**
|
|
820
|
+
* Indicates whether a create or update operation transition is in progress.
|
|
821
|
+
*
|
|
822
|
+
* During this transition window, [state](https://developers.arcgis.com/javascript/latest/references/core/widgets/Sketch/SketchViewModel/#state) may briefly
|
|
823
|
+
* report `"ready"` and [activeTool](https://developers.arcgis.com/javascript/latest/references/core/widgets/Sketch/SketchViewModel/#activeTool) may briefly be `null`
|
|
824
|
+
* before the next operation becomes active.
|
|
825
|
+
*
|
|
826
|
+
* @internal
|
|
827
|
+
* @since 5.1
|
|
828
|
+
*/
|
|
829
|
+
get toolTransitionInProgress(): boolean;
|
|
771
830
|
/**
|
|
772
831
|
* An array of graphics that are being updated by the SketchViewModel.
|
|
773
832
|
*
|
|
@@ -880,6 +939,12 @@ export default class SketchViewModel extends EventedAccessor {
|
|
|
880
939
|
* sketchVM.create("circle", { preserveAspectRatio: false });
|
|
881
940
|
*/
|
|
882
941
|
create(tool: CreateTool, createOptions?: CreateOptions | null): Promise<void>;
|
|
942
|
+
/**
|
|
943
|
+
* @param tool - Name of the create tool. Specifies the geometry for the graphic to be created.
|
|
944
|
+
* @param createOptions - Options for the graphic to be created.
|
|
945
|
+
* @internal
|
|
946
|
+
*/
|
|
947
|
+
create(tool: CreateTool | PluginConfiguration[], createOptions?: CreateOptions | null): Promise<void>;
|
|
883
948
|
/**
|
|
884
949
|
* Deletes the selected graphics used in the update workflow. Calling this method will fire the
|
|
885
950
|
* [@delete](https://developers.arcgis.com/javascript/latest/references/core/widgets/Sketch/SketchViewModel/#event-delete) event.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__addDisposableResource as e,__disposeResources as t,__decorate as o}from"tslib";import i from"../../Graphic.js";import{prefersReducedMotion as a}from"../../core/a11yUtils.js";import{isSome as r}from"../../core/arrayUtils.js";import s from"../../core/Collection.js";import n from"../../core/Error.js";import{EventedAccessor as p}from"../../core/Evented.js";import{drainHandles as l,disposable as h,makeHandle as d,destroyHandle as c}from"../../core/handleUtils.js";import"../../core/has.js";import u from"../../core/Logger.js";import{destroyMaybe as m,abortMaybe as y}from"../../core/maybe.js";import{createAbortError as g,ignoreAbortErrors as v,whenOrAbort as f}from"../../core/promiseUtils.js";import{watch as _,syncAndInitial as b,on as w,when as G,whenOnce as T}from"../../core/reactiveUtils.js";import{property as O,subclass as S}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as C}from"../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as A}from"../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as E,isLoaded as M,load as k,project as H}from"../../geometry/projectionUtils.js";import{geometryToCoordinates as P}from"../../geometry/support/coordsUtils.js";import{equals as I}from"../../geometry/support/spatialReferenceUtils.js";import D from"../../layers/GraphicsLayer.js";import{isIntegratedMeshLayer as j}from"../../layers/support/layerUtils.js";import{getEffectiveElevationInfo as U}from"../../support/elevationInfoUtils.js";import R from"../../symbols/CIMSymbol.js";import x from"../../symbols/FillSymbol3DLayer.js";import L from"../../symbols/MeshSymbol3D.js";import F from"../../symbols/SimpleFillSymbol.js";import V from"../../symbols/SimpleLineSymbol.js";import W from"../../symbols/SimpleMarkerSymbol.js";import K from"../../symbols/TextSymbol.js";import{symbolTypes as Z}from"../../symbols/support/typeUtils.js";import{isSupportedObjectResultMessage as q}from"../../views/3d/interactive/editingTools/isSupportedObjectUtils.js";import{isSupportedObject as N}from"../../views/3d/interactive/editingTools/move/isSupportedObject.js";import{isSupportedObject as z}from"../../views/3d/interactive/editingTools/reshape/isSupportedObject.js";import{isSupportedGraphic as B}from"../../views/3d/interactive/editingTools/transform/isSupportedGraphic.js";import{addUniqueLayer as $}from"../../views/draw/support/layerUtils.js";import{ViewEventPriorities as Y}from"../../views/input/InputManager.js";import{sketchKeys as X}from"../../views/interactive/keybindings.js";import J from"../../views/interactive/sketch/SketchLabelOptions.js";import Q from"../../views/interactive/sketch/SketchOptions.js";import ee from"../../views/interactive/sketch/SketchTooltipOptions.js";import te from"../../views/interactive/sketch/SketchValueOptions.js";import{SnappingManager as oe}from"../../views/interactive/snapping/SnappingManager.js";import ie from"../../views/interactive/snapping/SnappingOptions.js";import{setupSnappingToggleHandles as ae}from"../../views/interactive/snapping/snappingUtils.js";import{GeometryWorkerHandle as re}from"../../views/support/GeometryWorkerHandle.js";import{defaultHighlightName as se}from"../../views/support/HighlightDefaults.js";import{findFirstGraphicHit as ne}from"../../views/support/hitTestSelectUtils.js";import{createScreenPointFromEvent as pe}from"../../views/support/screenUtils.js";import le from"./adapters/layer/GraphicsLayerAdapter.js";import he from"./adapters/layer/MapNotesLayerAdapter.js";import{CreateOperationHandle as de,DrawToolOperationHandle as ce,UpdateOperationHandle as ue}from"./support/OperationHandle.js";import{PluginManager as me}from"./support/PluginManager.js";import{SettingsManager as ye}from"./support/SettingsManager.js";import{getLegacyTool as ge,isCompletelyDegenerate as ve,graphicsHaveTooFewVerticesForBox as fe,getModeFromCreateOptions as _e,getDrawToolGeometryTypeFromCreateTool as be}from"./support/sketchUtils.js";const we={defaultZ:0},Ge={reshapeOptions:{edgeOperation:"split",shapeOperation:"move",vertexOperation:"move",enableCreateCurveFromStraightEdge:!0},enableMoveAllGraphics:!0,enableRotation:!0,enableScaling:!0,multipleSelectionEnabled:!0,preserveAspectRatio:!1,toggleToolOnClick:!0,enableZ:!0,highlightOptions:{enabled:!0,name:se},tool:"transform"},Te=Symbol(),Oe=Symbol();let Se=class extends p{constructor(e){super(e),this._defaultSnappingManager=null,this._internalGraphicsLayer=new D({listMode:"hide",internal:!0,title:"SVM Internal"}),this._pluginManager=new me({sketchViewModel:this}),this.settingsManager=new ye({availablePlugins:()=>this.pluginManager.visiblePluginsFlat}),this._operationHandle=null,this._updatingHandles=new C,this._drawToolSimplifyAbortController=null,this._geometryWorkerHandle=new re,this._viewHandlesKey="viewHandles",this.activeFillSymbol=null,this.activeLineSymbol=null,this.activeVertexSymbol=null,this.allowDeleteKey=!0,this.activeUpdateOptions=null,this.layer=null,this.pointSymbol=new W({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.polygonSymbol=new F({color:[150,150,150,.2],outline:{color:[50,50,50],width:2}}),this.polylineSymbol=new V({color:[130,130,130,1],width:2}),this.meshSymbol=new L({symbolLayers:new s([new x])}),this.updateGraphics=new s,this.updateOnGraphicClick=!0,this.creationMode="single",this.vertexSymbol=new W({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.sketchOptions=new Q,this.useLegacyCreateTools=!0,this._moduleLoaderAbortController=null,this._viewReadyAbortController=null,this._sketchContinuationFlag=!1,this._onLayerAdapterChange=async()=>{const{_layerAdapter:e}=this;if(this.removeHandles(Oe),!e)return;const t=[e.onGraphicsChange(e=>this._onLayerGraphicsChangeCallback(e)),_(()=>e.elevationInfo,e=>{e!==this._internalGraphicsLayer.elevationInfo&&(this.cancel(),this._internalGraphicsLayer&&(this._internalGraphicsLayer.elevationInfo=e))},b)].filter(r);this.addHandles(t,Oe)},this._originalPopupEnabled=null,this.defaultCreateOptions=we,this.defaultUpdateOptions=Ge,this.snappingOptions=e?.snappingManager?.options??e?.snappingOptions??new ie,this.textSymbol=new K({text:"text"})}initialize(){this._updatingHandles.addPromise(this._setupAdvancedDrawToolIntegrationMaybe()),this.addHandles([w(()=>this.view?.map?.layers,"change",e=>{this.layer&&e.removed.includes(this.layer)&&this.cancel()}),_(()=>this._layerAdapter,()=>this._onLayerAdapterChange(),b),_(()=>this.view,e=>{this._defaultSnappingManager=m(this._defaultSnappingManager),e&&(this.snappingManager||(this._defaultSnappingManager=new oe({view:e,options:this.snappingOptions})),"2d"===e.type?(import("../../views/2d/interactive/editingTools.js"),this._updatingHandles.addPromise(this._setupAdvancedDrawToolIntegrationMaybe())):"3d"===e.type&&(import("../../views/3d/interactive/editingTools.js"),import("../../views/3d/layers/GraphicsLayerView3D.js")))},b),_(()=>this.view?.spatialReference,(e,t)=>{e&&t&&!e.equals(t)&&this.cancel()})]),ae(this)}destroy(){this.cancel(),this._removeDefaultLayer(),this._defaultSnappingManager=m(this._defaultSnappingManager),this._set("snappingManager",null),this._set("view",null),this._updatingHandles.destroy(),this._drawToolSimplifyAbortController=y(this._drawToolSimplifyAbortController),this._geometryWorkerHandle.destroy(),this._pluginManager?.destroy(),this.emit("destroy")}get _layerAdapter(){const{layer:e}=this;switch(e?.type){case"graphics":return new le(e);case"map-notes":return new he(e);default:return null}}get activeTool(){return this._operationHandle?.tool??null}get geometrySimplificationInProgress(){return!!this._drawToolSimplifyAbortController}get activeCreateToolDrawMode(){const e=this._operationHandle;if("create"===e?.type&&e.activeComponent&&"mode"in e.activeComponent)return e.activeComponent.mode;if("draw-2.0"===e?.activeComponent?.type){const t=e.activeComponent.pluginStack.map(e=>e.configuration).filter(r).toArray();if(t.length>0)return this._pluginManager?.getDrawingModeEquivalentToPluginStack(t)}return null}get activeTooltip(){const{activeComponent:e,destroyed:t}=this,o=!t&&e&&"tooltip"in e?e.tooltip:null;return o?.visible?o:null}get activeComponent(){return this._operationHandle?.activeComponent??null}get createGraphic(){return null==this.activeComponent||"draw-3d"!==this.activeComponent.type&&"draw-2d"!==this.activeComponent.type?this._get("createGraphic"):this.activeComponent.graphic}get defaultCreateOptions(){return this._get("defaultCreateOptions")}set defaultCreateOptions(e){this._set("defaultCreateOptions",{...we,...e})}get defaultUpdateOptions(){return this._get("defaultUpdateOptions")}set defaultUpdateOptions(e){this._set("defaultUpdateOptions",{...Ge,...e,reshapeOptions:{...Ge.reshapeOptions,...e?.reshapeOptions},highlightOptions:{...Ge.highlightOptions,...e?.highlightOptions}})}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=e}get textSymbol(){return this._get("textSymbol")}set textSymbol(e){this._set("textSymbol",e)}get snappingOptions(){return this.snappingManager?.options??this._get("snappingOptions")}set snappingOptions(e){null!=this._defaultSnappingManager&&(this._defaultSnappingManager.options=e),this._set("snappingOptions",e)}get snappingManager(){return this._isOverridden("snappingManager")&&this._get("snappingManager"),this._defaultSnappingManager}set snappingManager(e){if(e)this._isOverridden("snappingManager")||(this._defaultSnappingManager=m(this._defaultSnappingManager)),this._override("snappingManager",e);else{const{view:e}=this;!this._defaultSnappingManager&&e&&(this._defaultSnappingManager=new oe({options:this.snappingOptions,view:e})),this._clearOverride("snappingManager")}}get state(){const e=!(!this.view?.ready||!this.layer),t=this._operationHandle;return e&&t?"active":e?"ready":"disabled"}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get updating(){return this.activeComponent&&"updating"in this.activeComponent&&this.activeComponent.updating||!!(this._updatingHandles.updating||this._drawToolSimplifyAbortController||this.snappingManager?.updating||this.drawTool?.updating)}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}get view(){return this._get("view")}set view(e){const t=this._get("view");if(t){const{container:e,map:o}=t;e&&this._clearCursor(),o?.remove(this._internalGraphicsLayer),this.removeHandles(this._viewHandlesKey),this.cancel()}const o="view-ready";this.removeHandles(o),e&&this.addHandles(G(()=>e.ready,t=>{this.removeHandles(this._viewHandlesKey),t&&this.addHandles(this._generateViewHandles(e),this._viewHandlesKey)},b),o),this._set("view",e),this._updatingHandles.addPromise(this._setupAdvancedDrawToolIntegrationMaybe())}get isUsingLegacyCreateTools(){return this.useLegacyCreateTools||"2d"!==this.view?.type}get pluginManager(){return this._pluginManager}get drawTool(){return"draw-2.0"!==this.activeComponent?.type?null:this.activeComponent}get rootPlugins(){return this._pluginManager?.availablePlugins}set rootPlugins(e){this._overrideIfSome("rootPlugins",e)}get effectiveAvailablePlugins(){if(this.isUsingLegacyCreateTools)return null;const e=this.view?.type??"2d",{firstPluginWithSwappableLeaf:t}=this;return t?t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e)):this.rootPlugins?.filter(t=>!t.excludedViews?.includes(e)).filter(r)??[]}get firstPluginWithSwappableLeaf(){const e=this.view?.type??"2d",t=this.drawTool?.pluginStack.toArray().map(e=>e.configuration).findLast(t=>null!=t&&!t.hidden&&t.availableDownstreamPlugins&&t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e))?.length>1);return t}get multiplePluginsActive(){return!!this.drawTool&&this.drawTool.pluginStack.length>1}addGraphic(e){this._layerAdapter?.add(e)}addGraphics(e){this._layerAdapter?.addMany(e)}hasGraphic(e){return!!this._layerAdapter?.has(e)}removeGraphic(e){this._layerAdapter?.remove(e)}removeGraphics(e){this._layerAdapter?.removeMany(e)}removeAllGraphics(){this._layerAdapter?.removeAll()}cancel(){this._moduleLoaderAbortController=y(this._moduleLoaderAbortController),this._viewReadyAbortController=y(this._viewReadyAbortController),this._drawToolSimplifyAbortController=y(this._drawToolSimplifyAbortController),this._sketchContinuationFlag=!0,this._operationHandle?.cancel()}complete(){this._operationHandle?.complete()}delete(){const{state:e,updateGraphics:t}=this;if("active"===e&&t.length){const{activeTool:e}=this,o=t.toArray();this.removeGraphics(o),this.cancel(),this._emitDeleteEvent({graphics:o,tool:e})}}duplicate(){if("active"===this.state&&this.updateGraphics.length){const e=this.updateGraphics.map(e=>e.clone()).toArray();return this.addGraphics(e),this.emit("duplicate",{graphics:e,type:"duplicate"}),e}return[]}async create(e,t){this.cancel(),await this._updatingHandles.addPromise(this._waitViewReady());const{view:o,layer:i}=this;if(!o||"disabled"===this.state)throw i||this._logMissingLayer(),g();if(null!=o.activeTool&&(o.activeTool=null),!e)return void this._logError("sketch:missing-parameter","Missing parameter 'tool'.");$(o,this._internalGraphicsLayer);const a=await this._updatingHandles.addPromise(this._setupCreateOperation(e,t));if(null==a||this.destroyed)return void o.map?.remove(this._internalGraphicsLayer);const r=ge(e),s=()=>{if(a===this._operationHandle){const o=this.createGraphic,i=this._operationHandle.cancelled;if(this._operationHandle.destroy(),this._operationHandle=null,this._set("createGraphic",null),this.view?.map?.remove(this._internalGraphicsLayer),a.cancelled||null==o||this.addGraphic(o),this._sketchContinuationFlag=!1,this.emit("create",{graphic:o,state:i?"cancel":"complete",tool:r??"point",toolEventInfo:null,type:"create"}),i||this._sketchContinuationFlag)return;const{creationMode:s}=this;if("continuous"===s){if(t?.geometryToPlace)return;this._updatingHandles.consumePromise(v(this.create(e,t)))}else"update"===s&&o&&this._updatingHandles.consumePromise(v(this.update([o])))}};a.on("complete",s),this._operationHandle=a,o.ready&&o.focus()}async place(e,t){return await e.load(),this.create("mesh",{mode:"click",hasZ:e.hasZ,geometryToPlace:e,...t})}async update(e,t){this.cancel(),await this._updatingHandles.addPromise(this._waitViewReady());const{layer:o,view:i,state:a}=this;if(!i||"disabled"===a)throw o||this._logMissingLayer(),g();null!=i.activeTool&&(i.activeTool=null);const r=Array.isArray(e)?e:[e];if(null==e||!r?.length)return void this._logError("sketch:missing-parameter","Missing parameter 'graphics'.");if(r.some(e=>this.hasGraphic(e)?null==e.geometry&&(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics with an unsupported geometry."),!0):(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics missing from the supplied GraphicsLayer."),!0)))return;const s=await this._updatingHandles.addPromise(this._setupUpdateOperation(r,t));this.destroyed||null==s||je(s)||($(i,this._internalGraphicsLayer),this._setUpdateOperationHandle(s,t),this.emit("update",{graphics:r,state:"start",aborted:!1,tool:s.tool,toolEventInfo:null,type:"update"}))}async _updateSpatialReference(e){const t=this.view;if(t){e=Array.isArray(e)?e:[e];for(const o of e)null==o.geometry||"mesh"===o.geometry.type||I(o.geometry.spatialReference,t.spatialReference)||(E(o.geometry.spatialReference,t.spatialReference)||M()||await k(),o.geometry=H(o.geometry,t.spatialReference))}else this._logMissingView()}undo(){this.canUndo()&&this._operationHandle?.undo()}redo(){this.canRedo()&&this._operationHandle?.redo()}canUndo(){return!!this._operationHandle?.canUndo()}canRedo(){return!!this._operationHandle?.canRedo()}toggleUpdateTool(){this._operationHandle?.toggleTool()}async _getFirstHit(e){const t=this.view;if(!t)return this._logMissingView(),null;if("2d"===t.type){const o=[];t.map.allLayers.forEach(e=>{"vector-tile"!==e.type&&"imagery"!==e.type||o.push(e)});const i=await t.hitTest(e,{exclude:o});return ne(i.results)}const o=[t.map.ground];t.map.allLayers.forEach(e=>{j(e)&&o.push(e)});const i=await t.hitTest(e,{exclude:o});if(i.results.length>0){const e=i.results[0];if(null!=e&&"graphic"===e.type&&e.graphic&&(!i.ground.mapPoint||t.map.ground.opacity<1||i.ground.distance-(e.distance??0)>-Math.min(3*i.ground.distance,"global"===t.viewingMode?A(t.renderCoordsHelper.spatialReference).radius/t.renderCoordsHelper.unitInMeters:Number.POSITIVE_INFINITY)))return e}return null}_generateViewHandles(e){return[e.on("immediate-click",async e=>{const t="active"===this.state&&"create"===this._operationHandle?.type;"disabled"!==this.state&&!t&&this.updateOnGraphicClick&&await this._updatingHandles.addPromise(this._handleImmediateClick(e))},Y.WIDGET)]}async _handleImmediateClick(e){const t=await e.defer(()=>this._getFirstHit(pe(e)));let o=null;if(null!=t){const i=t.graphic;this.updateGraphics.includes(i)||this.hasGraphic(i)?(e.stopPropagation(),o=i):"2d"!==this.view?.type||this._isComponentGraphic(i)||"active"!==this.state||this.cancel()}else"active"===this.state&&this.cancel();null==o||this.updateGraphics.includes(o)||await this.update([o],{...this.defaultUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions}})}async _setupCreateOperation(e,t){const o=this.view;if(!o)return this._logMissingView(),null;const i={hasZ:"3d"===o.type,...this.defaultCreateOptions,...t},a="string"==typeof e?this.pluginManager?.getPluginsEquivalentToCreateTool(e,i.mode):e,r=ge(e);if(a&&!this.isUsingLegacyCreateTools){const e=await this._setupDrawTool(a,i,r??"polyline");if(e)return this._setupDrawToolOperationHandle(e,r??"point")}if(!r)return null;const s=await this._setupDrawGraphicTool(r,o,i);return null==s?null:(o.tools.add(s),o.activeTool=s,this._setupCreateOperationHandle(s,r))}async _setupDrawGraphicTool(e,t,o){if("multipoint"===e&&"3d"===t.type)return this._logError("sketch:create","Multipoint geometries are not supported in SceneView."),null;if(!t)return this._logMissingView(),null;const{cursor:i,defaultZ:a,hasZ:r,geometryToPlace:s,graphicProperties:n,mode:p,preserveAspectRatio:l}=o,h=_e(p,e),d=be(e),c=o?.optionsPerTool?.has(e)?o.optionsPerTool.get(e):{},u=c?.preserveAspectRatio??l??"rectangle"!==e,m={centered:"rectangle"!==e&&!("circle"===e&&!u),cursor:i,defaultZ:a,forceUniformSize:u,graphicProperties:{...n,attributes:{...n?.attributes}},geometryToPlace:s,geometryType:d,mode:h,graphicSymbol:o.graphicSymbol??this._getGraphicSymbolFromTool(e),hasZ:r,snappingManager:this.snappingManager,snapToScene:!1,view:t,...c};return"2d"===t.type?this._makeDrawGraphicTool2D(m):this._makeDrawGraphicTool3D(m)}async _makeDrawGraphicTool2D(e){const t=await this._requireModule(import("../../views/2d/interactive/editingTools.js"));return je(t)||this.destroyed?null:new t.module.DrawGraphicTool2D({...e,activeVertexSymbol:this.activeVertexSymbol,regularVerticesSymbol:this.vertexSymbol,activeLineSymbol:this.activeLineSymbol,activeFillSymbol:Ee(e.geometryType)?this.activeFillSymbol:null,sketchOptions:this.sketchOptions})}async _makeDrawGraphicTool3D(e){const t=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));return je(t)||this.destroyed?null:new t.module.DrawGraphicTool3D({...e,elevationInfo:this._layerAdapter?.elevationInfo,snapToScene:!0,sketchOptions:this.sketchOptions})}_setupCreateOperationHandle(e,t){const o=this.view;if(!o)return this._logMissingView(),null;let i=null;const a=e.forceUniformSize,r=e.centered,s=[o.on("key-down",t=>{if(t.key===X.pan)t.stopPropagation(),t.repeat||(e.enabled=!1);else if(t.key===X.complete)t.stopPropagation(),e.completeCreateOperation();else if(t.key!==X.vertexAdd||t.repeat)t.key===X.undo?(t.stopPropagation(),n.undo()):t.key===X.redo?(t.stopPropagation(),n.redo()):t.key!==X.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType||t.repeat?t.key===X.center&&(t.repeat||(e.centered=!r,t.stopPropagation())):(e.forceUniformSize=!a,t.stopPropagation());else{const o=e.drawOperation.geometryType;"polyline"!==o&&"polygon"!==o&&"multipoint"!==o||(t.stopPropagation(),e.drawOperation.commitStagedVertex())}},Y.WIDGET),o.on("key-up",t=>{t.key===X.pan?e.enabled=!0:t.key!==X.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType?t.key===X.center&&(e.centered=r,t.stopPropagation()):(e.forceUniformSize=a,t.stopPropagation())},Y.WIDGET),e.on("vertex-add",t=>{switch(i=null==i?"start":"active",t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:i,tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[e.graphic],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[e.graphic],tool:e.geometryType})}}),e.on("cursor-update",t=>{e.drawOperation.numCommittedVertices>0&&this.emit("create",{graphic:e.graphic,state:"active",tool:this.activeTool,toolEventInfo:{coordinates:t.vertices[0].coordinates,type:"cursor-update"},type:"create"})}),e.on("vertex-remove",t=>{switch(t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:"active",tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[e.graphic],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[e.graphic],tool:e.geometryType})}}),e.on("complete",e=>{this._set("createGraphic",e.graphic),i="complete",e.aborted?n&&n.cancel():n&&n.complete()}),_(()=>this._getGraphicSymbolFromTool(t),t=>{e.graphicSymbol=t})],n=new de({activeComponent:e,type:"create",onEnd:()=>{l(s),o.tools?.remove(e)},undo:()=>{e.canUndo&&e.undo()},redo:()=>{e.canRedo&&e.redo()},canUndo:()=>e.canUndo,canRedo:()=>e.canRedo});return n}_setupDrawToolOperationHandle(o,i){const a=this.view;if(!a)return this._logMissingView(),null;let s=null;const n=[a.on("key-down",e=>{e.key===X.pan&&(e.stopPropagation(),e.repeat||(o.editable=!1))},Y.WIDGET),a.on("key-up",e=>{e.key===X.pan&&(o.editable=!0)},Y.WIDGET),o.on("before-vertex-add",e=>{const t=o.mostUpstreamPlugin?.configuration;if(t&&"legacyCreateTool"in t&&("point"===t?.legacyCreateTool||"text"===t.legacyCreateTool)){const t=e.detail.originalEvent;return void(t&&"key"in t&&t.key===X.vertexAdd&&e.preventDefault())}}),o.on("before-complete",e=>{const t=o.getGeometryIfCompleted();(!t||ve(t))&&e.preventDefault()}),o.on(["vertex-add","vertex-remove"],e=>{switch(this.createGraphic&&(this.createGraphic.geometry=o.getGeometryIfCompleted()),s=null==s&&"vertex-remove"!==e.type?"start":"active",e.operation){case"apply":this.emit("create",{graphic:this.createGraphic,state:s,tool:this.activeTool,toolEventInfo:e,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[this.createGraphic].filter(r),tool:i});break;case"redo":this._emitRedoEvent({graphics:[this.createGraphic].filter(r),tool:i})}}),o.on("cursor-update",e=>{this.createGraphic&&(this.createGraphic.geometry=o.unprocessedGeometry),(e.vertices[0]?.vertexIndex>0||e.vertices[0]?.componentIndex>0)&&this.emit("create",{graphic:this.createGraphic,state:"active",tool:this.activeTool,toolEventInfo:{coordinates:e.vertices[0].coordinates,type:"cursor-update"},type:"create"})}),o.on("complete",async({geometry:i,isSimple:a})=>{const r=this.createGraphic;if(!!i&&"mesh"!==i.type&&"extent"!==i.type&&!a&&r){const a={stack:[],error:void 0,hasError:!1};try{const t=new AbortController;this._drawToolSimplifyAbortController?.abort(),this._drawToolSimplifyAbortController=t;e(a,h(this._createDrawToolCompletionPreviewGraphic(o,i,r)),!1);await this._updatingHandles.addPromise(v(this._finalizeDrawToolCompletion({abortController:t,geometry:i,graphic:r,handle:p})))}catch(s){a.error=s,a.hasError=!0}finally{t(a)}}else r&&(r.geometry=i),p.complete()})],p=new ce({activeComponent:o,type:"create",onEnd:()=>{l(n),a.tools.remove(o)},undo:()=>o.undo(),redo:()=>o.redo(),canUndo:()=>o.canUndo,canRedo:()=>o.canRedo});return n.push(o.on("cancel",()=>{this._drawToolSimplifyAbortController=y(this._drawToolSimplifyAbortController),p.cancel()})),p}_createDrawToolCompletionPreviewGraphic(e,t,o){const a="polygon"===t?.type?this._createAnimatedPolygonPreviewSymbol():o?.symbol,r=t?e.simplifiedGeometryPreview??t:null;if(!r||!a)return d();const s=new i({geometry:r,symbol:a});return this._internalGraphicsLayer.add(s),d(()=>this._internalGraphicsLayer.remove(s))}async _finalizeDrawToolCompletion({abortController:e,geometry:t,graphic:o,handle:i}){const a=this.view?.acquireCursor("progress","high");a&&this.addHandles(a);const r=()=>!!e.signal.aborted&&(o&&this._layerAdapter?.remove(o),this._set("createGraphic",null),!0);try{const a=await this._geometryWorkerHandle.simplify(t,e.signal);if(r())return;o.geometry=a??t,i.complete()}finally{a?.remove(),this._drawToolSimplifyAbortController===e&&(this._drawToolSimplifyAbortController=null)}}_createAnimatedPolygonPreviewSymbol(){const e={type:"CIMAnimatedSymbolProperties",playAnimation:!a(),duration:1,repeatType:"Oscillate",easing:"EaseInOut"};return new R({data:{type:"CIMSymbolReference",symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[180,180,180,36],animations:[{type:"CIMSymbolAnimationTransparency",toTransparency:30,animatedSymbolProperties:e}]},{type:"CIMHatchFill",enable:!0,separation:6,rotation:-45,offsetX:0,offsetY:0,lineSymbol:{type:"CIMLineSymbol",symbolLayers:[{type:"CIMSolidStroke",enable:!0,capStyle:"Butt",joinStyle:"Round",miterLimit:10,width:.8,color:[100,100,100,110],animations:[{type:"CIMSymbolAnimationTransparency",toTransparency:30,animatedSymbolProperties:e}]}]}},{type:"CIMSolidStroke",enable:!0,capStyle:"Butt",joinStyle:"Round",miterLimit:10,width:1.8,color:[60,60,60,255],effects:[{type:"CIMGeometricEffectDashes",dashTemplate:[6,4],lineDashEnding:"FullGap",controlPointEnding:"NoConstraint"}],animations:[{type:"CIMSymbolAnimationTransparency",toTransparency:70,animatedSymbolProperties:e}]}]}}})}_getGraphicSymbolFromTool(e){switch(e){case"point":case"multipoint":return this.pointSymbol;case"polyline":case"freehandPolyline":return this.polylineSymbol;case"circle":case"rectangle":case"polygon":case"freehandPolygon":return this.polygonSymbol;case"mesh":return this.meshSymbol;case"text":return this.textSymbol}}async _setupUpdateOperation(e,t){const{view:o}=this;if(!o)return this._logMissingView(),null;const i={...this.defaultUpdateOptions,...t,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...t?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...t?.highlightOptions}};this.activeUpdateOptions=i;let a=i.tool??Ge.tool;if(this.removeGraphics(e),this.addGraphics(e),"3d"===o.type){if(0===e.length)return null;switch(a){case"move":return this._setupMove3DOperation(e,i,o,a);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupReshape3DOperation(e[0],i,o);case"transform":return this._setupGraphicTransform3DOperation(e,i,o)}}switch(a){case"move":return this._setupMove2DOperation(e,i,o);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupTransformOrReshape2DOperation(e,a,i,o);case"transform":return fe(e)&&(a="reshape"),this._setupTransformOrReshape2DOperation(e,a,i,o)}}async _setupMove3DOperation(e,t,o,i,a=!1){const r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(je(r))return r;const{ManipulatedObject3DGraphic:s,MoveTool3D:n}=r.module,p=new Map,h=()=>{p.forEach(e=>e.destroy()),p.clear()};for(const l of e){const e=new s({view:o,graphic:l}),t=N(e);if(0!==t)return h(),this._logError("sketch:move",`Move operation not supported for provided graphic(s) (${q(t)}).`),null;p.set(l,e)}const d=new n({view:o,enableZ:t.enableZ,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(d),d.objects.addMany(Array.from(p.values())),a||this.updateGraphics.addMany(e);const c=[],u=new ue({activeComponent:d,tool:i,type:"update",onEnd:()=>{l(c),De(o,d),h()},undo:()=>{Pe(this.view,d),Me(u,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{ke(u,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:e=>{this.updateGraphics.push(e);const t=new s({view:o,graphic:e});p.set(e,t),d.objects.push(t),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:e=>{const t=this.updateGraphics.indexOf(e);if(u.history.undo.forEach(e=>e.updates.splice(t,1)),u.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0===this.updateGraphics.length)return void u.complete();const o=p.get(e);o&&(d.objects.remove(o),o.destroy(),p.delete(e))},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;if("transform"!==i)return;const e=this.updateGraphics.at(0),a=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,o,!0));a&&!je(a)&&(u.onEnd(),u.destroy(),this._setUpdateOperationHandle(a,t))}});return c.push(...this._getHandlesForComponent(u,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(u,e,t),Y.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(u,e)},Y.WIDGET)),u}_setupGraphicTransform3DOperation(e,t,o,i=!1){if(1===e.length&&0===B(e[0])){const a=e[0],r=a.geometry;if(null!=r&&("point"===r.type||"mesh"===r.type))return this._setupPointTransform3DOperation(a,t,o);if(null!=r&&("polygon"===r.type||"polyline"===r.type))return this._setupPolyTransform3DOperation(a,t,o,i)}return this._setupMove3DOperation(e,t,o,"transform",i)}async _setupPointTransform3DOperation(e,t,o){const i="transform",{enableRotation:a,enableScaling:r,enableZ:s}=t,n=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(je(n))return n;const{TransformTool3D:p,ManipulatedObject3DGraphic:h}=n.module,d=new h({graphic:e,view:o}),c=new p({object:d,view:o,enableRotation:a,enableScaling:r,enableZ:s,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(c),this.updateGraphics.add(e);const u=[],m=new ue({activeComponent:c,tool:i,type:"update",onEnd:()=>{l(u),De(o,c),d.destroy()},undo:()=>{Pe(this.view,c),Me(m,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{ke(m,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),m.onEnd(),m.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));je(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),m.complete()},toggleTool:()=>{}});return u.push(...this._getHandlesForComponent(m,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(m,e,t),Y.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(m,e)},Y.WIDGET)),m}async _setupPolyTransform3DOperation(e,t,o,i=!1){const a="transform",{enableRotation:r,enableScaling:s,enableZ:n,preserveAspectRatio:p}=t,h=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(je(h))return h;const{ManipulatedObject3DGraphic:d,ExtentTransformTool:c}=h.module,u=this.view?.inputManager?.isModifierKeyDown(X.constraint),m=new d({view:o,graphic:e}),y=new c({object:m,view:o,enableRotation:r,enableScaling:s,enableZ:n,preserveAspectRatio:!!p!=!!u,sketchOptions:this.sketchOptions});o.tools.add(y),i||this.updateGraphics.add(e);const g=[],v=new ue({activeComponent:y,tool:a,type:"update",onEnd:()=>{l(g),De(o,y),m.destroy()},canUndo:()=>!y.destroyed&&y.canUndo,undo:()=>{y.destroyed||(y.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},canRedo:()=>!y.destroyed&&y.canRedo,redo:()=>{y.destroyed||(y.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),v.onEnd(),v.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));je(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),v.complete()},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;const i=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,o,!0));i&&!je(i)&&(v.onEnd(),v.destroy(),this._setUpdateOperationHandle(i,t))}});return g.push(...this._getHandlesForComponent(v,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(v,e,t),Y.WIDGET),o.on("key-down",e=>this._getCommonUpdateOperationKeyDownHandlers(v,e),Y.WIDGET),o.on("key-down",e=>{e.key!==X.constraint||e.repeat||(y.preserveAspectRatio=!y.preserveAspectRatio,e.stopPropagation())},Y.WIDGET),o.on("key-up",e=>{e.key===X.constraint&&(y.preserveAspectRatio=!y.preserveAspectRatio,e.stopPropagation())},Y.WIDGET)),v}async _setupMove2DOperation(e,t,o){const i="move";this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const a=await this._updatingHandles.addPromise(this._getGraphicMover(e,t,o));if(je(a))return a;const r=new ue({activeComponent:a,tool:i,type:"update",onEnd:()=>{this._clearCursor(),l(p),l(n),a.destroy(),this._internalGraphicsLayer?.removeMany([...this.updateGraphics.toArray()])},undo:()=>{const e=this.updateGraphics.toArray();Me(r,e),r.refreshComponent(),this._emitUndoEvent({graphics:e,tool:i})},redo:()=>{const e=this.updateGraphics.toArray();ke(r,e),r.refreshComponent(),this._emitRedoEvent({graphics:e,tool:i})},addToSelection:async e=>{await this._updatingHandles.addPromise(this._updateSpatialReference(e)),this.updateGraphics.push(e),a.graphics=this.updateGraphics.toArray(),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:e=>{const t=this.updateGraphics.indexOf(e);r.history.undo.forEach(e=>e.updates.splice(t,1)),r.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e);const o=this.updateGraphics.toArray();this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0!==this.updateGraphics.length?a.graphics=o:r.complete()}});let s=!1;const n=[o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(r,e,t),Y.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key!==X.constraint||e.repeat||(s=!0,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)},Y.WIDGET),o.on("key-up",e=>{e.key===X.constraint&&s&&(s=!1,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)},Y.WIDGET)],p=this._getHandlesForComponent(r,t);return r}async _setupReshape3DOperation(e,t,o,i=!1){const a="reshape",r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(je(r))return r;const{ManipulatedObject3DGraphic:s,ReshapeTool3D:n}=r.module,p=new s({view:o,graphic:e}),h=z(p);if(0!==h)return p.destroy(),this._logError("sketch:reshape",`Reshape operation not supported for provided graphic(s) (${q(h)}).`),null;const d=t.reshapeOptions,c=new n({view:o,object:p,enableZVertex:t.enableZ&&"move"===d?.vertexOperation,enableZShape:t.enableZ&&"move"===d?.shapeOperation,enableMoveObject:"move"===d?.shapeOperation||"move-xy"===d?.shapeOperation,enableMidpoints:"split"===d?.edgeOperation,enableEdgeOffset:"offset"===d?.edgeOperation,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(c),i||this.updateGraphics.add(p.graphic);const u=[],m=new ue({activeComponent:c,tool:a,type:"update",onEnd:()=>{l(u),De(o,c),p.destroy()},canUndo:()=>!c.destroyed&&c.canUndo,undo:()=>{c.destroyed||(c.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},canRedo:()=>!c.destroyed&&c.canRedo,redo:()=>{c.destroyed||(c.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),m.onEnd(),m.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));je(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),m.complete()},toggleTool:async()=>{if(!1===t.toggleToolOnClick)return;m.onEnd(),m.destroy();const e=await this._updatingHandles.addPromise(this._setupGraphicTransform3DOperation(this.updateGraphics.toArray(),t,o,!0));je(e)||this._setUpdateOperationHandle(e,t)}});return u.push(...this._getHandlesForComponent(m,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(m,e,t),Y.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(m,e)},Y.WIDGET)),m}async _setupTransformOrReshape2DOperation(e,t,o,i){this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const a=await this._updatingHandles.addPromise("transform"===t?this._getBox(e,o,i):this._getReshape(e,o,i));if(je(a))return a;const r=new ue({activeComponent:a,type:"update",onEnd:()=>{l(n),l(s),r.activeComponent&&!r.activeComponent.destroyed&&r.activeComponent.destroy(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray())},undo:()=>{Me(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},redo:()=>{ke(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},addToSelection:async e=>{let t=r.activeComponent;if("reshape"===t?.type){const t=[...this.updateGraphics,e];this.updateGraphics.removeAll(),r.onEnd(),r.destroy();const a=await this._updatingHandles.addPromise(this._setupTransformOrReshape2DOperation(t,"transform",o,i));if(je(a))return;this._setUpdateOperationHandle(a,o)}else this.updateGraphics.add(e),t.graphics=this.updateGraphics.toArray(),t.refresh(),r.resetHistory();this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:e=>{const t=this.updateGraphics.indexOf(e);r.history.undo.forEach(e=>e.updates.splice(t,1)),r.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e);const o=this.updateGraphics.toArray();0===o.length?r.complete():fe(o)?r.toggleTool():r.activeComponent.graphics=o,this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"})},toggleTool:async()=>{if(this.updateGraphics.length>1)return;const e=this.updateGraphics.at(0),t=e.geometry;if(null!=t&&("reshape"===r.tool&&"point"===t.type||"transform"===r.tool&&"extent"===t.type))return;let a=null;const s={...this.defaultUpdateOptions,...o,...this.activeUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...o?.reshapeOptions,...this.activeUpdateOptions?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...o?.highlightOptions,...this.activeUpdateOptions?.highlightOptions}};"transform"===r.tool?a=await this._updatingHandles.addPromise(this._getReshape([e],s,i)):"reshape"===r.tool&&(a=await this._updatingHandles.addPromise(this._getBox([e],s,i))),je(a)||(r.activeComponent?.destroy(),r.activeComponent=a,r.activeComponent&&(l(n),n=this._getHandlesForComponent(r,s)))}}),s=[i.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(r,e,o),Y.WIDGET),i.on("key-down",e=>{if(this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key===X.constraint&&!e.repeat&&r){const e=r.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},Y.WIDGET),i.on("key-up",e=>{if(e.key===X.constraint&&r){const e=r.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},Y.WIDGET)];let n=this._getHandlesForComponent(r,o);return r}async _getGraphicMover(e,t,o){const{enableMoveAllGraphics:i,highlightOptions:a}=t,r=await this._requireModule(import("../../views/draw/support/GraphicMover.js"));return je(r)?r:new r.module.default({enableMoveAllGraphics:i,highlightName:a?.name,highlightsEnabled:!!a?.enabled,indicatorsEnabled:!1,graphics:e,view:o,callbacks:{onGraphicMoveStart:({dx:e,dy:t,graphic:o})=>{this._displayCursor("grabbing"),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-start"},type:"update"})},onGraphicMove:({dx:e,dy:t,graphic:o})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move"},type:"update"}),onGraphicMoveStop:({dx:e,dy:t,graphic:o})=>{this._displayCursor("pointer"),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-stop"},type:"update"})},onGraphicPointerOver:()=>this._displayCursor("move"),onGraphicPointerOut:()=>this._clearCursor()}})}async _getBox(e,t,o){const{enableRotation:i,enableScaling:a,highlightOptions:r,preserveAspectRatio:s}=t,n=await this._requireModule(import("../../views/draw/support/Box.js"));if(je(n))return n;const p=this.view?.inputManager?.isModifierKeyDown(X.constraint),l=new n.module.default({graphics:e,enableRotation:i,enableScaling:a,highlightName:r?.name,highlightsEnabled:!!r?.enabled,preserveAspectRatio:!!s!=!!p,layer:this._internalGraphicsLayer,view:o,sketchOptions:this.sketchOptions,callbacks:{onMoveStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onMove:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onMoveStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScaleStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScale:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScaleStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotateStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotate:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotateStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"})}});return l.addHandles(_(()=>[this.activeUpdateOptions?.enableRotation,this.activeUpdateOptions?.enableScaling],([e,o])=>{l.enableRotation=e??t.enableRotation??!0,l.enableScaling=o??t.enableScaling??!0,l.refresh()},b)),l}async _getReshape(e,t,o){const{highlightOptions:i,reshapeOptions:a}=t,r="split"===a?.edgeOperation,s="move"===a?.shapeOperation,n=!!a?.enableCreateCurveFromStraightEdge,p=await this._requireModule(import("../../views/draw/support/Reshape.js"));return je(p)?p:new p.module.default({enableMidpoints:r,enableMovement:s,enableCurveOnMidpoint:n,graphic:e[0],highlightName:i?.name,highlightsEnabled:!!i?.enabled,layer:this._internalGraphicsLayer,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions,view:o,callbacks:{onReshapeStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onReshape:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onReshapeStop:({mover:e,type:t})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e,type:t},type:"update"}),onMoveStart:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onMove:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onMoveStop:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onVertexAdd:({added:e,type:t,vertices:o})=>{const i=e.map(e=>P(e.geometry));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:i,vertices:o,type:t},type:"update"})},onVertexRemove:({removed:e,type:t,vertices:o})=>{const i=e.map(e=>P(e.geometry));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{removed:i,vertices:o,type:t},type:"update"})}}})}_getHandlesForComponent(e,t){const o=e.activeComponent;if(!o)return[];switch(o.type){case"graphic-mover":return[o.on("graphic-click",({graphic:o,viewEvent:i})=>{i.native?.shiftKey&&t.multipleSelectionEnabled&&(i.stopPropagation(),e.removeFromSelection(o))}),o.on("graphic-move-start",t=>e.addToHistory(Ie(t.allGraphics)))];case"box":return[o.on("graphic-click",o=>this._onTransformOrReshape2DGraphicClick(e,t,o)),o.on("move-start",t=>e.addToHistory(Ie(t.graphics))),o.on("rotate-start",t=>e.addToHistory(Ie(t.graphics))),o.on("scale-start",t=>e.addToHistory(Ie(t.graphics)))];case"reshape":return[o.on("graphic-click",o=>this._onTransformOrReshape2DGraphicClick(e,t,o)),o.on("move-start",t=>e.addToHistory(Ie([t.mover]))),o.on("reshape-start",t=>e.addToHistory(Ie([t.graphic]))),o.on("vertex-add",t=>e.addToHistory(Ie([t.oldGraphic]))),o.on("vertex-remove",t=>e.addToHistory(Ie([t.oldGraphic])))];case"move-3d":return[o.events.on("record-undo",({updates:t})=>{e.addToHistory({updates:t})}),o.events.on("move-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move-start"},type:"update"})}),o.events.on("move",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e.dx,dy:e.dy,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move"},type:"update"})}),o.events.on("move-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move-stop"},type:"update"})}),o.events.on("immediate-click",o=>{o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool()})];case"transform-3d":return[o.events.on("record-undo",({updates:t})=>{e.addToHistory({updates:t})}),o.events.on("translate-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-start"},type:"update"})}),o.events.on("translate-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-stop"},type:"update"})}),o.events.on("rotate-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate-start"},type:"update"})}),o.events.on("rotate-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate-stop"},type:"update"})}),o.events.on("scale-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-start"},type:"update"})}),o.events.on("scale-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-stop"},type:"update"})}),o.events.on("translate",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move"},type:"update"})}),o.events.on("rotate",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate"},type:"update"})}),o.events.on("scale",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale"},type:"update"})}),o.events.on("immediate-click",o=>{o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool()})];case"reshape-3d":return[o.events.on("reshape",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e,mover:e.object.graphic},type:"update"})}),o.events.on("move",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e,mover:e.object.graphic},type:"update"})}),o.events.on("vertex-add",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})}),o.events.on("vertex-remove",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})}),o.events.on("immediate-click",o=>{o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool()})]}}_onTransformOrReshape2DGraphicClick(e,t,o){const{graphic:i,viewEvent:a}=o;return a.native?.shiftKey&&this.hasGraphic(i)?(a.stopPropagation(),e.removeFromSelection(i)):t.toggleToolOnClick?(a.stopPropagation(),e.toggleTool()):void 0}_setUpdateOperationHandle(e,t){this._operationHandle=e;const o=this.view?.map;this._disablePopup(t);const i=()=>{if(e===this._operationHandle){const i=this.updateGraphics.toArray(),a=this._operationHandle.tool;this._operationHandle.destroy(),this._operationHandle=null,this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray()),this.updateGraphics.removeAll(),o&&o.remove(this._internalGraphicsLayer),this._restorePopup(t),this.emit("update",{graphics:i,state:"complete",aborted:e.cancelled,tool:a,toolEventInfo:null,type:"update"})}};e.on("complete",i)}async _getCommonUpdateOperationClickHandlers(e,t,o){const i=pe(t),a=await t.defer(()=>this._getFirstHit(i));if(null==a)return void(this.updateOnGraphicClick&&e.complete());if(t.native.shiftKey&&this._toggleSelection([a.graphic],e,o))return void t.stopPropagation();this.updateGraphics.includes(a.graphic)?t.stopPropagation():e.complete()}_toggleSelection(e,t,o){const i=!!o.multipleSelectionEnabled;return e.some(e=>null!=e&&(!(!i||!this.hasGraphic(e))&&(this.updateGraphics.includes(e)?t.removeFromSelection(e):t.addToSelection(e),!0)))}_getCommonUpdateOperationKeyDownHandlers(e,t){if(!e)return;const o=t.key;o===X.undo&&e.canUndo()?(t.stopPropagation(),e.undo()):o===X.redo&&e.canRedo()?(t.stopPropagation(),e.redo()):o===X.cancel?(t.stopPropagation(),e.cancel()):this.allowDeleteKey&&X.delete.includes(o)&&this._onDeleteKey(t)}_onDeleteKey(e){this._operationHandle&&"update"===this._operationHandle.type&&null!=this.activeComponent&&(e.stopPropagation(),this.delete())}_removeDefaultLayer(){this._internalGraphicsLayer&&(this.view?.map?.remove(this._internalGraphicsLayer),this._internalGraphicsLayer=m(this._internalGraphicsLayer))}_isComponentGraphic(e){const{activeComponent:t}=this;return!(!e||null==t)&&(e.attributes?.esriSketchTool||"draw-2d"===t.type&&t.graphic===e||("box"===t.type||"reshape"===t.type)&&t.isUIGraphic(e))}_clearCursor(){this.removeHandles(Te)}_displayCursor(e){this.removeHandles(Te),this.view?.container&&null!=e&&this.addHandles(this.view.acquireCursor(e,"high"),Te)}_logError(e,t,o){u.getLogger(this).error(new n(e,t,o))}async _requireModule(e){const t=new AbortController;this._moduleLoaderAbortController=t;const o=await e;return this._moduleLoaderAbortController!==t||t.signal.aborted?{requireError:"aborted"}:{module:o}}_emitUndoEvent(e){this.emit("undo",{...e,type:"undo"})}_emitRedoEvent(e){this.emit("redo",{...e,type:"redo"})}_emitDeleteEvent(e){this.emit("delete",{...e,type:"delete"})}_onLayerGraphicsChangeCallback(e){if(null!=this._operationHandle){const{updateGraphics:t}=this;for(const o of e.removed)if(t.includes(o)){if(!(t.length>1)){this._operationHandle.cancel();break}this._operationHandle.removeFromSelection(o)}}}async _setupAdvancedDrawToolIntegrationMaybe(){this.isUsingLegacyCreateTools||this.pluginManager.loaded||await this.pluginManager.loadPlugins()}async _setupDrawTool(e,t,o){if(this.isUsingLegacyCreateTools||!this._pluginManager)return null;const a=this.view,r=await import("../../views/draw/DrawTool.js");await this.pluginManager.loadPlugins();const s=await this.pluginManager.makeRenderer({customSymbol:t.graphicSymbol,useTextSymbol:"text"===o}),n=new r.DrawTool({view:a,elevationInfo:this._layerAdapter?.elevationInfo??U("3d"===a.type),hasZ:!!t.hasZ,sketchOptions:this.sketchOptions,renderer:s,defaultZ:t.defaultZ??0,directionOptions:t.directionOptions,snappingManager:this.snappingManager,enableVertexVisuals:"rectangle"!==o&&"circle"!==o,readPluginSetting:(e,t)=>this.settingsManager.getValue(t)});n.addHandles(c(s));const p=new i({...t.graphicProperties,attributes:{...t.graphicProperties?.attributes},symbol:t.graphicSymbol??this._getGraphicSymbolFromTool(o)});return t.graphicSymbol||n.addHandles(_(()=>this._getGraphicSymbolFromTool(o),e=>p.symbol=e)),this._set("createGraphic",p),a.addAndActivateTool(n),n.begin(e),n}get test(){}wait(){return T(()=>!this.updating)}_disablePopupEnabled(e){return"3d"!==this.view?.type||this.updateOnGraphicClick||(e?.toggleToolOnClick??!1)}_disablePopup(e){this._disablePopupEnabled(e)&&this.view&&null==this._originalPopupEnabled&&(this._originalPopupEnabled=this.view.popupEnabled,this.view.popupEnabled=!1)}_restorePopup(e){this._disablePopupEnabled(e)&&this.view&&null!=this._originalPopupEnabled&&(this.view.popupEnabled=this._originalPopupEnabled,this._originalPopupEnabled=null)}async _waitViewReady(){const e=this.view;e?(y(this._viewReadyAbortController),this._viewReadyAbortController=new AbortController,await f(T(()=>e?.ready),this._viewReadyAbortController.signal)):this._logMissingView()}_logMissingView(){this._logError("sketch:missing-property",Ae("view"))}_logMissingLayer(){this._logError(Ce,Ae("layer"))}};o([O()],Se.prototype,"_defaultSnappingManager",void 0),o([O()],Se.prototype,"_layerAdapter",null),o([O()],Se.prototype,"_pluginManager",void 0),o([O({readOnly:!0})],Se.prototype,"settingsManager",void 0),o([O()],Se.prototype,"_operationHandle",void 0),o([O({readOnly:!0})],Se.prototype,"_updatingHandles",void 0),o([O()],Se.prototype,"_drawToolSimplifyAbortController",void 0),o([O({readOnly:!0})],Se.prototype,"activeTool",null),o([O()],Se.prototype,"geometrySimplificationInProgress",null),o([O({readOnly:!0})],Se.prototype,"activeCreateToolDrawMode",null),o([O()],Se.prototype,"activeTooltip",null),o([O({types:Z})],Se.prototype,"activeFillSymbol",void 0),o([O()],Se.prototype,"activeLineSymbol",void 0),o([O()],Se.prototype,"activeVertexSymbol",void 0),o([O()],Se.prototype,"allowDeleteKey",void 0),o([O({readOnly:!0})],Se.prototype,"createGraphic",null),o([O()],Se.prototype,"defaultCreateOptions",null),o([O()],Se.prototype,"defaultUpdateOptions",null),o([O()],Se.prototype,"activeUpdateOptions",void 0),o([O({type:J,nonNullable:!0})],Se.prototype,"labelOptions",null),o([O()],Se.prototype,"layer",void 0),o([O({types:Z})],Se.prototype,"pointSymbol",void 0),o([O({types:Z})],Se.prototype,"polygonSymbol",void 0),o([O({types:Z})],Se.prototype,"polylineSymbol",void 0),o([O()],Se.prototype,"meshSymbol",void 0),o([O({type:K})],Se.prototype,"textSymbol",null),o([O({type:ie,nonNullable:!0})],Se.prototype,"snappingOptions",null),o([O()],Se.prototype,"snappingManager",null),o([O({readOnly:!0})],Se.prototype,"state",null),o([O({type:ee,nonNullable:!0})],Se.prototype,"tooltipOptions",null),o([O({readOnly:!0})],Se.prototype,"updateGraphics",void 0),o([O()],Se.prototype,"updateOnGraphicClick",void 0),o([O()],Se.prototype,"updating",null),o([O()],Se.prototype,"creationMode",void 0),o([O({type:te,nonNullable:!0})],Se.prototype,"valueOptions",null),o([O({types:Z})],Se.prototype,"vertexSymbol",void 0),o([O({value:null})],Se.prototype,"view",null),o([O({constructOnly:!0,type:Q})],Se.prototype,"sketchOptions",void 0),o([O()],Se.prototype,"useLegacyCreateTools",void 0),o([O()],Se.prototype,"isUsingLegacyCreateTools",null),o([O()],Se.prototype,"pluginManager",null),o([O()],Se.prototype,"drawTool",null),o([O()],Se.prototype,"rootPlugins",null),o([O()],Se.prototype,"effectiveAvailablePlugins",null),o([O()],Se.prototype,"firstPluginWithSwappableLeaf",null),o([O()],Se.prototype,"multiplePluginsActive",null),Se=o([S("esri.widgets.Sketch.SketchViewModel")],Se);const Ce="sketch:missing-property",Ae=e=>`Property '${e}' is missing on SketchViewModel.`;function Ee(e){return"polygon"===e||"rectangle"===e||"circle"===e}function Me(e,t){He("undo",e.history.undo,e.history.redo,t)}function ke(e,t){He("redo",e.history.redo,e.history.undo,t)}function He(e,t,o,i){const a=t.pop();if(!a)return;const r=a.updates,s=[];i.forEach((t,o)=>{const i=r[o];null!=i&&("geometry"in i&&null!=i.geometry&&(s.push({geometry:t.geometry}),t.geometry=i.geometry),"symbol"in i&&null!=i.symbol&&(s.push({symbol:t.symbol}),t.symbol=i.symbol),"undo"in i&&(s.push(i),i[e](t)))}),o.push({updates:s})}function Pe(e,t){null!=e&&t.hasGrabbedManipulators&&(e.activeTool=null)}function Ie(e){return{updates:e.map(({geometry:e})=>"mesh"===e?.type?{geometry:e.cloneShallow()}:{geometry:e})}}function De(e,t){e.tools?.remove(t),t.destroyed||t.destroy()}function je(e){return"requireError"in e&&"aborted"===e.requireError}export{Se as default};
|
|
2
|
+
import{__addDisposableResource as e,__disposeResources as t,__decorate as o}from"tslib";import i from"../../Graphic.js";import{prefersReducedMotion as a}from"../../core/a11yUtils.js";import{isSome as r}from"../../core/arrayUtils.js";import s from"../../core/Collection.js";import n from"../../core/Error.js";import{EventedAccessor as p}from"../../core/Evented.js";import{makeHandle as l,drainHandles as h,disposable as d,destroyHandle as c}from"../../core/handleUtils.js";import"../../core/has.js";import u from"../../core/Logger.js";import{destroyMaybe as y,abortMaybe as m}from"../../core/maybe.js";import{createAbortError as g,ignoreAbortErrors as v,whenOrAbort as f}from"../../core/promiseUtils.js";import{watch as _,syncAndInitial as b,on as w,when as T,whenOnce as G}from"../../core/reactiveUtils.js";import{property as O,subclass as S}from"../../core/accessorSupport/decorators.js";import{trackAccess as C}from"../../core/accessorSupport/tracking.js";import{SimpleObservable as A}from"../../core/accessorSupport/tracking/SimpleObservable.js";import{UpdatingHandles as E}from"../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as M}from"../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as k,isLoaded as H,load as P,project as I}from"../../geometry/projectionUtils.js";import{geometryToCoordinates as D}from"../../geometry/support/coordsUtils.js";import{equals as j}from"../../geometry/support/spatialReferenceUtils.js";import U from"../../layers/GraphicsLayer.js";import{isIntegratedMeshLayer as R}from"../../layers/support/layerUtils.js";import{getEffectiveElevationInfo as x}from"../../support/elevationInfoUtils.js";import L from"../../symbols/CIMSymbol.js";import F from"../../symbols/FillSymbol3DLayer.js";import V from"../../symbols/MeshSymbol3D.js";import W from"../../symbols/SimpleFillSymbol.js";import K from"../../symbols/SimpleLineSymbol.js";import Z from"../../symbols/SimpleMarkerSymbol.js";import q from"../../symbols/TextSymbol.js";import{symbolTypes as N}from"../../symbols/support/typeUtils.js";import{isSupportedObjectResultMessage as z}from"../../views/3d/interactive/editingTools/isSupportedObjectUtils.js";import{isSupportedObject as B}from"../../views/3d/interactive/editingTools/move/isSupportedObject.js";import{isSupportedObject as $}from"../../views/3d/interactive/editingTools/reshape/isSupportedObject.js";import{isSupportedGraphic as Y}from"../../views/3d/interactive/editingTools/transform/isSupportedGraphic.js";import{addUniqueLayer as X}from"../../views/draw/support/layerUtils.js";import{ViewEventPriorities as J}from"../../views/input/InputManager.js";import{sketchKeys as Q}from"../../views/interactive/keybindings.js";import ee from"../../views/interactive/sketch/SketchLabelOptions.js";import te from"../../views/interactive/sketch/SketchOptions.js";import oe from"../../views/interactive/sketch/SketchTooltipOptions.js";import ie from"../../views/interactive/sketch/SketchValueOptions.js";import{SnappingManager as ae}from"../../views/interactive/snapping/SnappingManager.js";import re from"../../views/interactive/snapping/SnappingOptions.js";import{setupSnappingToggleHandles as se}from"../../views/interactive/snapping/snappingUtils.js";import{GeometryWorkerHandle as ne}from"../../views/support/GeometryWorkerHandle.js";import{defaultHighlightName as pe}from"../../views/support/HighlightDefaults.js";import{findFirstGraphicHit as le}from"../../views/support/hitTestSelectUtils.js";import{createScreenPointFromEvent as he}from"../../views/support/screenUtils.js";import de from"./adapters/layer/GraphicsLayerAdapter.js";import ce from"./adapters/layer/MapNotesLayerAdapter.js";import{CreateOperationHandle as ue,DrawToolOperationHandle as ye,UpdateOperationHandle as me}from"./support/OperationHandle.js";import{PluginManager as ge}from"./support/PluginManager.js";import{SettingsManager as ve}from"./support/SettingsManager.js";import{getLegacyTool as fe,isCompletelyDegenerate as _e,graphicsHaveTooFewVerticesForBox as be,getModeFromCreateOptions as we,getDrawToolGeometryTypeFromCreateTool as Te}from"./support/sketchUtils.js";const Ge={defaultZ:0},Oe={reshapeOptions:{edgeOperation:"split",shapeOperation:"move",vertexOperation:"move",enableCreateCurveFromStraightEdge:!0},enableMoveAllGraphics:!0,enableRotation:!0,enableScaling:!0,multipleSelectionEnabled:!0,preserveAspectRatio:!1,toggleToolOnClick:!0,enableZ:!0,highlightOptions:{enabled:!0,name:pe},tool:"transform"},Se=Symbol(),Ce=Symbol();let Ae=class extends p{constructor(e){super(e),this._defaultSnappingManager=null,this._internalGraphicsLayer=new U({listMode:"hide",internal:!0,title:"SVM Internal"}),this._pluginManager=new ge({sketchViewModel:this}),this.settingsManager=new ve({availablePlugins:()=>this.pluginManager.visiblePluginsFlat}),this._operationHandle=null,this._updatingHandles=new E,this._toolTransitionHandles=new E,this._drawToolSimplifyAbortController=null,this._geometryWorkerHandle=new ne,this._viewHandlesKey="viewHandles",this.activeFillSymbol=null,this.activeLineSymbol=null,this.activeVertexSymbol=null,this.allowDeleteKey=!0,this.activeUpdateOptions=null,this.layer=null,this.pointSymbol=new Z({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.polygonSymbol=new W({color:[150,150,150,.2],outline:{color:[50,50,50],width:2}}),this.polylineSymbol=new K({color:[130,130,130,1],width:2}),this.meshSymbol=new V({symbolLayers:new s([new F])}),this.updateGraphics=new s,this.updateOnGraphicClick=!0,this.creationMode="single",this.vertexSymbol=new Z({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.sketchOptions=new te,this.useLegacyCreateTools=!0,this._moduleLoaderAbortController=null,this._viewReadyAbortController=null,this._sketchContinuationFlag=!1,this._onLayerAdapterChange=async()=>{const{_layerAdapter:e}=this;if(this.removeHandles(Ce),!e)return;const t=[e.onGraphicsChange(e=>this._onLayerGraphicsChangeCallback(e)),_(()=>e.elevationInfo,e=>{e!==this._internalGraphicsLayer.elevationInfo&&(this.cancel(),this._internalGraphicsLayer&&(this._internalGraphicsLayer.elevationInfo=e))},b)].filter(r);this.addHandles(t,Ce)},this._originalPopupEnabled=null,this.defaultCreateOptions=Ge,this.defaultUpdateOptions=Oe,this.snappingOptions=e?.snappingManager?.options??e?.snappingOptions??new re,this.textSymbol=new q({text:"text"})}initialize(){this._updatingHandles.addPromise(this._setupAdvancedDrawToolIntegrationMaybe()),this.addHandles([w(()=>this.view?.map?.layers,"change",e=>{this.layer&&e.removed.includes(this.layer)&&this.cancel()}),_(()=>this._layerAdapter,()=>this._onLayerAdapterChange(),b),_(()=>this.view,e=>{this._defaultSnappingManager=y(this._defaultSnappingManager),e&&(this.snappingManager||(this._defaultSnappingManager=new ae({view:e,options:this.snappingOptions})),"2d"===e.type?(import("../../views/2d/interactive/editingTools.js"),this._updatingHandles.addPromise(this._setupAdvancedDrawToolIntegrationMaybe())):"3d"===e.type&&(import("../../views/3d/interactive/editingTools.js"),import("../../views/3d/layers/GraphicsLayerView3D.js")))},b),_(()=>this.view?.spatialReference,(e,t)=>{e&&t&&!e.equals(t)&&this.cancel()})]),se(this)}destroy(){this.cancel(),this._removeDefaultLayer(),this._defaultSnappingManager=y(this._defaultSnappingManager),this._set("snappingManager",null),this._set("view",null),this._updatingHandles.destroy(),this._toolTransitionHandles.destroy(),this._drawToolSimplifyAbortController=m(this._drawToolSimplifyAbortController),this._geometryWorkerHandle.destroy(),this._pluginManager?.destroy(),this.emit("destroy")}get _layerAdapter(){const{layer:e}=this;switch(e?.type){case"graphics":return new de(e);case"map-notes":return new ce(e);default:return null}}get activeTool(){return this._operationHandle?.tool??null}get geometrySimplificationInProgress(){return!!this._drawToolSimplifyAbortController}get activeCreateToolDrawMode(){const e=this._operationHandle;if("create"===e?.type&&e.activeComponent&&"mode"in e.activeComponent)return e.activeComponent.mode;if("draw-2.0"===e?.activeComponent?.type){const t=e.activeComponent.pluginStack.map(e=>e.configuration).filter(r).toArray();if(t.length>0)return this._pluginManager?.getDrawingModeEquivalentToPluginStack(t)}return null}get activeTooltip(){const{activeComponent:e,destroyed:t}=this,o=!t&&e&&"tooltip"in e?e.tooltip:null;return o?.visible?o:null}get activeComponent(){return this._operationHandle?.activeComponent??null}get createGraphic(){return null==this.activeComponent||"draw-3d"!==this.activeComponent.type&&"draw-2d"!==this.activeComponent.type?this._get("createGraphic"):this.activeComponent.graphic}get defaultCreateOptions(){return this._get("defaultCreateOptions")}set defaultCreateOptions(e){this._set("defaultCreateOptions",{...Ge,...e})}get defaultUpdateOptions(){return this._get("defaultUpdateOptions")}set defaultUpdateOptions(e){this._set("defaultUpdateOptions",{...Oe,...e,reshapeOptions:{...Oe.reshapeOptions,...e?.reshapeOptions},highlightOptions:{...Oe.highlightOptions,...e?.highlightOptions}})}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=e}get textSymbol(){return this._get("textSymbol")}set textSymbol(e){this._set("textSymbol",e)}get snappingOptions(){return this.snappingManager?.options??this._get("snappingOptions")}set snappingOptions(e){null!=this._defaultSnappingManager&&(this._defaultSnappingManager.options=e),this._set("snappingOptions",e)}get snappingManager(){return this._isOverridden("snappingManager")&&this._get("snappingManager"),this._defaultSnappingManager}set snappingManager(e){if(e)this._isOverridden("snappingManager")||(this._defaultSnappingManager=y(this._defaultSnappingManager)),this._override("snappingManager",e);else{const{view:e}=this;!this._defaultSnappingManager&&e&&(this._defaultSnappingManager=new ae({options:this.snappingOptions,view:e})),this._clearOverride("snappingManager")}}get state(){const e=!(!this.view?.ready||!this.layer),t=this._operationHandle;return e&&t?"active":e?"ready":"disabled"}get toolTransitionInProgress(){return this._toolTransitionHandles.updating||!!this.drawTool?.lifecycleManager.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get updating(){return this.activeComponent&&"updating"in this.activeComponent&&this.activeComponent.updating||!!(this._updatingHandles.updating||this._drawToolSimplifyAbortController||this.snappingManager?.updating||this.drawTool?.updating)}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}get view(){return this._get("view")}set view(e){const t=this._get("view");if(t){const{container:e,map:o}=t;e&&this._clearCursor(),o?.remove(this._internalGraphicsLayer),this.removeHandles(this._viewHandlesKey),this.cancel()}const o="view-ready";this.removeHandles(o),e&&this.addHandles(T(()=>e.ready,t=>{this.removeHandles(this._viewHandlesKey),t&&this.addHandles(this._generateViewHandles(e),this._viewHandlesKey)},b),o),this._set("view",e),this._updatingHandles.addPromise(this._setupAdvancedDrawToolIntegrationMaybe())}get isUsingLegacyCreateTools(){return this.useLegacyCreateTools||"2d"!==this.view?.type}get pluginManager(){return this._pluginManager}get drawTool(){return"draw-2.0"!==this.activeComponent?.type?null:this.activeComponent}get rootPlugins(){return this._pluginManager?.availablePlugins}set rootPlugins(e){this._overrideIfSome("rootPlugins",e)}get effectiveAvailablePlugins(){if(this.isUsingLegacyCreateTools)return null;const e=this.view?.type??"2d",{firstPluginWithSwappableLeaf:t}=this;return t?t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e)):this.rootPlugins?.filter(t=>!t.excludedViews?.includes(e)).filter(r)??[]}get firstPluginWithSwappableLeaf(){const e=this.view?.type??"2d",t=this.drawTool?.pluginStack.toArray().map(e=>e.configuration).findLast(t=>null!=t&&!t.hidden&&t.availableDownstreamPlugins&&t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e))?.length>1);return t}get multiplePluginsActive(){return!!this.drawTool&&this.drawTool.pluginStack.length>1}addGraphic(e){this._layerAdapter?.add(e)}addGraphics(e){this._layerAdapter?.addMany(e)}hasGraphic(e){return!!this._layerAdapter?.has(e)}removeGraphic(e){this._layerAdapter?.remove(e)}removeGraphics(e){this._layerAdapter?.removeMany(e)}removeAllGraphics(){this._layerAdapter?.removeAll()}cancel(){this._moduleLoaderAbortController=m(this._moduleLoaderAbortController),this._viewReadyAbortController=m(this._viewReadyAbortController),this._drawToolSimplifyAbortController=m(this._drawToolSimplifyAbortController),this._sketchContinuationFlag=!0,this._operationHandle?.cancel()}complete(){this._operationHandle?.complete()}delete(){const{state:e,updateGraphics:t}=this;if("active"===e&&t.length){const{activeTool:e}=this,o=t.toArray();this.removeGraphics(o),this.cancel(),this._emitDeleteEvent({graphics:o,tool:e})}}duplicate(){if("active"===this.state&&this.updateGraphics.length){const e=this.updateGraphics.map(e=>e.clone()).toArray();return this.addGraphics(e),this.emit("duplicate",{graphics:e,type:"duplicate"}),e}return[]}async create(e,t){return this._toolTransitionHandles.addPromise(this._create(e,t))}async _create(e,t){this.cancel(),await this._updatingHandles.addPromise(this._waitViewReady());const{view:o,layer:i}=this;if(!o||"disabled"===this.state)throw i||this._logMissingLayer(),g();if(null!=o.activeTool&&(o.activeTool=null),!e)return void this._logError("sketch:missing-parameter","Missing parameter 'tool'.");X(o,this._internalGraphicsLayer);const a=await this._updatingHandles.addPromise(this._setupCreateOperation(e,t));if(null==a||this.destroyed)return void o.map?.remove(this._internalGraphicsLayer);const r=fe(e),s=()=>{if(a===this._operationHandle){const o=this.createGraphic,i=this._operationHandle.cancelled;if(this._operationHandle.destroy(),this._operationHandle=null,this._set("createGraphic",null),this.view?.map?.remove(this._internalGraphicsLayer),a.cancelled||null==o||this.addGraphic(o),this._sketchContinuationFlag=!1,this.emit("create",{graphic:o,state:i?"cancel":"complete",tool:r??"point",toolEventInfo:null,type:"create"}),i||this._sketchContinuationFlag)return;const{creationMode:s}=this;if("continuous"===s){if(t?.geometryToPlace)return;this._updatingHandles.consumePromise(v(this.create(e,t)))}else"update"===s&&o&&this._updatingHandles.consumePromise(v(this.update([o])))}};a.on("complete",s),this._operationHandle=a,o.ready&&o.focus()}async place(e,t){return await e.load(),this.create("mesh",{mode:"click",hasZ:e.hasZ,geometryToPlace:e,...t})}async update(e,t){return this._toolTransitionHandles.addPromise(this._update(e,t))}async _update(e,t){this.cancel(),await this._updatingHandles.addPromise(this._waitViewReady());const{layer:o,view:i,state:a}=this;if(!i||"disabled"===a)throw o||this._logMissingLayer(),g();null!=i.activeTool&&(i.activeTool=null);const r=Array.isArray(e)?e:[e];if(null==e||!r?.length)return void this._logError("sketch:missing-parameter","Missing parameter 'graphics'.");if(r.some(e=>this.hasGraphic(e)?null==e.geometry&&(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics with an unsupported geometry."),!0):(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics missing from the supplied GraphicsLayer."),!0)))return;const s=await this._updatingHandles.addPromise(this._setupUpdateOperation(r,t));this.destroyed||null==s||Re(s)||(X(i,this._internalGraphicsLayer),this._setUpdateOperationHandle(s,t),this.emit("update",{graphics:r,state:"start",aborted:!1,tool:s.tool,toolEventInfo:null,type:"update"}))}async _updateSpatialReference(e){const t=this.view;if(t){e=Array.isArray(e)?e:[e];for(const o of e)null==o.geometry||"mesh"===o.geometry.type||j(o.geometry.spatialReference,t.spatialReference)||(k(o.geometry.spatialReference,t.spatialReference)||H()||await P(),o.geometry=I(o.geometry,t.spatialReference))}else this._logMissingView()}undo(){this.canUndo()&&this._operationHandle?.undo()}redo(){this.canRedo()&&this._operationHandle?.redo()}canUndo(){return!!this._operationHandle?.canUndo()}canRedo(){return!!this._operationHandle?.canRedo()}toggleUpdateTool(){this._operationHandle?.toggleTool()}async _getFirstHit(e){const t=this.view;if(!t)return this._logMissingView(),null;if("2d"===t.type){const o=[];t.map.allLayers.forEach(e=>{"vector-tile"!==e.type&&"imagery"!==e.type||o.push(e)});const i=await t.hitTest(e,{exclude:o});return le(i.results)}const o=[t.map.ground];t.map.allLayers.forEach(e=>{R(e)&&o.push(e)});const i=await t.hitTest(e,{exclude:o});if(i.results.length>0){const e=i.results[0];if(null!=e&&"graphic"===e.type&&e.graphic&&(!i.ground.mapPoint||t.map.ground.opacity<1||i.ground.distance-(e.distance??0)>-Math.min(3*i.ground.distance,"global"===t.viewingMode?M(t.renderCoordsHelper.spatialReference).radius/t.renderCoordsHelper.unitInMeters:Number.POSITIVE_INFINITY)))return e}return null}_generateViewHandles(e){return[e.on("immediate-click",async e=>{const t="active"===this.state&&"create"===this._operationHandle?.type;"disabled"!==this.state&&!t&&this.updateOnGraphicClick&&await this._updatingHandles.addPromise(this._handleImmediateClick(e))},J.WIDGET)]}async _handleImmediateClick(e){const t=await e.defer(()=>this._getFirstHit(he(e)));let o=null;if(null!=t){const i=t.graphic;this.updateGraphics.includes(i)||this.hasGraphic(i)?(e.stopPropagation(),o=i):"2d"!==this.view?.type||this._isComponentGraphic(i)||"active"!==this.state||this.cancel()}else"active"===this.state&&this.cancel();null==o||this.updateGraphics.includes(o)||await this.update([o],{...this.defaultUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions}})}async _setupCreateOperation(e,t){const o=this.view;if(!o)return this._logMissingView(),null;const i={hasZ:"3d"===o.type,...this.defaultCreateOptions,...t},a="string"==typeof e?this.pluginManager?.getPluginsEquivalentToCreateTool(e,i.mode):e,r=fe(e);if(a&&!this.isUsingLegacyCreateTools){const e=await this._setupDrawTool(a,i,r??"polyline");if(e)return this._setupDrawToolOperationHandle(e,r??"point")}if(!r)return null;const s=await this._setupDrawGraphicTool(r,o,i);return null==s?null:(o.tools.add(s),o.activeTool=s,this._setupCreateOperationHandle(s,r))}async _setupDrawGraphicTool(e,t,o){if("multipoint"===e&&"3d"===t.type)return this._logError("sketch:create","Multipoint geometries are not supported in SceneView."),null;if(!t)return this._logMissingView(),null;const{cursor:i,defaultZ:a,hasZ:r,geometryToPlace:s,graphicProperties:n,mode:p,preserveAspectRatio:l}=o,h=we(p,e),d=Te(e),c=o?.optionsPerTool?.has(e)?o.optionsPerTool.get(e):{},u=c?.preserveAspectRatio??l??"rectangle"!==e,y={centered:"rectangle"!==e&&!("circle"===e&&!u),cursor:i,defaultZ:a,forceUniformSize:u,graphicProperties:{...n,attributes:{...n?.attributes}},geometryToPlace:s,geometryType:d,mode:h,graphicSymbol:o.graphicSymbol??this._getGraphicSymbolFromTool(e),hasZ:r,snappingManager:this.snappingManager,snapToScene:!1,view:t,...c};return"2d"===t.type?this._makeDrawGraphicTool2D(y):this._makeDrawGraphicTool3D(y)}async _makeDrawGraphicTool2D(e){const t=await this._requireModule(import("../../views/2d/interactive/editingTools.js"));return Re(t)||this.destroyed?null:new t.module.DrawGraphicTool2D({...e,activeVertexSymbol:this.activeVertexSymbol,regularVerticesSymbol:this.vertexSymbol,activeLineSymbol:this.activeLineSymbol,activeFillSymbol:ke(e.geometryType)?this.activeFillSymbol:null,sketchOptions:this.sketchOptions})}async _makeDrawGraphicTool3D(e){const t=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));return Re(t)||this.destroyed?null:new t.module.DrawGraphicTool3D({...e,elevationInfo:this._layerAdapter?.elevationInfo,snapToScene:!0,sketchOptions:this.sketchOptions})}_setupCreateOperationHandle(e,t){const o=this.view;if(!o)return this._logMissingView(),null;let i=null;const a=e.forceUniformSize,r=e.centered,s=new A,n=[l(()=>s.destroy()),o.on("key-down",t=>{if(t.key===Q.pan)t.stopPropagation(),t.repeat||(e.enabled=!1);else if(t.key===Q.complete)t.stopPropagation(),e.completeCreateOperation();else if(t.key!==Q.vertexAdd||t.repeat)t.key===Q.undo?(t.stopPropagation(),p.undo()):t.key===Q.redo?(t.stopPropagation(),p.redo()):t.key!==Q.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType||t.repeat?t.key===Q.center&&(t.repeat||(e.centered=!r,t.stopPropagation())):(e.forceUniformSize=!a,t.stopPropagation());else{const o=e.drawOperation.geometryType;"polyline"!==o&&"polygon"!==o&&"multipoint"!==o||(t.stopPropagation(),e.drawOperation.commitStagedVertex())}},J.WIDGET),o.on("key-up",t=>{t.key===Q.pan?e.enabled=!0:t.key!==Q.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType?t.key===Q.center&&(e.centered=r,t.stopPropagation()):(e.forceUniformSize=a,t.stopPropagation())},J.WIDGET),e.on("vertex-update",()=>{s.notify()}),e.on("vertex-add",t=>{switch(s.notify(),i=null==i?"start":"active",t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:i,tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[e.graphic],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[e.graphic],tool:e.geometryType})}}),e.on("cursor-update",t=>{e.drawOperation.numCommittedVertices>0&&this.emit("create",{graphic:e.graphic,state:"active",tool:this.activeTool,toolEventInfo:{coordinates:t.vertices[0].coordinates,type:"cursor-update"},type:"create"})}),e.on("vertex-remove",t=>{switch(s.notify(),t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:"active",tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[e.graphic],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[e.graphic],tool:e.geometryType})}}),e.on("complete",e=>{this._set("createGraphic",e.graphic),i="complete",e.aborted?p&&p.cancel():p&&p.complete()}),_(()=>this._getGraphicSymbolFromTool(t),t=>{e.graphicSymbol=t})],p=new ue({activeComponent:e,type:"create",onEnd:()=>{h(n),o.tools?.remove(e)},undo:()=>{e.canUndo&&e.undo()},redo:()=>{e.canRedo&&e.redo()},canUndo:()=>(C(s),e.canUndo),canRedo:()=>(C(s),e.canRedo)});return p}_setupDrawToolOperationHandle(o,i){const a=this.view;if(!a)return this._logMissingView(),null;let s=null;const n=[a.on("key-down",e=>{e.key===Q.pan&&(e.stopPropagation(),e.repeat||(o.editable=!1))},J.WIDGET),a.on("key-up",e=>{e.key===Q.pan&&(o.editable=!0)},J.WIDGET),o.on("before-vertex-add",e=>{const t=o.mostUpstreamPlugin?.configuration;if(t&&"legacyCreateTool"in t&&("point"===t?.legacyCreateTool||"text"===t.legacyCreateTool)){const t=e.detail.originalEvent;return void(t&&"key"in t&&t.key===Q.vertexAdd&&e.preventDefault())}}),o.on("before-complete",e=>{const t=o.getGeometryIfCompleted();(!t||_e(t))&&e.preventDefault()}),o.on(["vertex-add","vertex-remove"],e=>{switch(this.createGraphic&&(this.createGraphic.geometry=o.getGeometryIfCompleted()),s=null==s&&"vertex-remove"!==e.type?"start":"active",e.operation){case"apply":this.emit("create",{graphic:this.createGraphic,state:s,tool:this.activeTool,toolEventInfo:e,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[this.createGraphic].filter(r),tool:i});break;case"redo":this._emitRedoEvent({graphics:[this.createGraphic].filter(r),tool:i})}}),o.on("cursor-update",e=>{this.createGraphic&&(this.createGraphic.geometry=o.unprocessedGeometry),(e.vertices[0]?.vertexIndex>0||e.vertices[0]?.componentIndex>0)&&this.emit("create",{graphic:this.createGraphic,state:"active",tool:this.activeTool,toolEventInfo:{coordinates:e.vertices[0].coordinates,type:"cursor-update"},type:"create"})}),o.on("complete",async({geometry:i,isSimple:a})=>{const r=this.createGraphic;if(!!i&&"mesh"!==i.type&&"extent"!==i.type&&!a&&r){const a={stack:[],error:void 0,hasError:!1};try{const t=new AbortController;this._drawToolSimplifyAbortController?.abort(),this._drawToolSimplifyAbortController=t;e(a,d(this._createDrawToolCompletionPreviewGraphic(o,i,r)),!1);await this._updatingHandles.addPromise(v(this._finalizeDrawToolCompletion({abortController:t,geometry:i,graphic:r,handle:p})))}catch(s){a.error=s,a.hasError=!0}finally{t(a)}}else r&&(r.geometry=i),p.complete()})],p=new ye({activeComponent:o,type:"create",onEnd:()=>{h(n),a.tools.remove(o)},undo:()=>o.undo(),redo:()=>o.redo(),canUndo:()=>o.canUndo,canRedo:()=>o.canRedo});return n.push(o.on("cancel",()=>{this._drawToolSimplifyAbortController=m(this._drawToolSimplifyAbortController),p.cancel()})),p}_createDrawToolCompletionPreviewGraphic(e,t,o){const a="polygon"===t?.type?this._createAnimatedPolygonPreviewSymbol():o?.symbol,r=t?e.simplifiedGeometryPreview??t:null;if(!r||!a)return l();const s=new i({geometry:r,symbol:a});return this._internalGraphicsLayer.add(s),l(()=>this._internalGraphicsLayer.remove(s))}async _finalizeDrawToolCompletion({abortController:e,geometry:t,graphic:o,handle:i}){const a=this.view?.acquireCursor("progress","high");a&&this.addHandles(a);const r=()=>!!e.signal.aborted&&(o&&this._layerAdapter?.remove(o),this._set("createGraphic",null),!0);try{const a=await this._geometryWorkerHandle.simplify(t,e.signal);if(r())return;o.geometry=a??t,i.complete()}finally{a?.remove(),this._drawToolSimplifyAbortController===e&&(this._drawToolSimplifyAbortController=null)}}_createAnimatedPolygonPreviewSymbol(){const e={type:"CIMAnimatedSymbolProperties",playAnimation:!a(),duration:1,repeatType:"Oscillate",easing:"EaseInOut"};return new L({data:{type:"CIMSymbolReference",symbol:{type:"CIMPolygonSymbol",symbolLayers:[{type:"CIMSolidFill",enable:!0,color:[180,180,180,36],animations:[{type:"CIMSymbolAnimationTransparency",toTransparency:30,animatedSymbolProperties:e}]},{type:"CIMHatchFill",enable:!0,separation:6,rotation:-45,offsetX:0,offsetY:0,lineSymbol:{type:"CIMLineSymbol",symbolLayers:[{type:"CIMSolidStroke",enable:!0,capStyle:"Butt",joinStyle:"Round",miterLimit:10,width:.8,color:[100,100,100,110],animations:[{type:"CIMSymbolAnimationTransparency",toTransparency:30,animatedSymbolProperties:e}]}]}},{type:"CIMSolidStroke",enable:!0,capStyle:"Butt",joinStyle:"Round",miterLimit:10,width:1.8,color:[60,60,60,255],effects:[{type:"CIMGeometricEffectDashes",dashTemplate:[6,4],lineDashEnding:"FullGap",controlPointEnding:"NoConstraint"}],animations:[{type:"CIMSymbolAnimationTransparency",toTransparency:70,animatedSymbolProperties:e}]}]}}})}_getGraphicSymbolFromTool(e){switch(e){case"point":case"multipoint":return this.pointSymbol;case"polyline":case"freehandPolyline":return this.polylineSymbol;case"circle":case"rectangle":case"polygon":case"freehandPolygon":return this.polygonSymbol;case"mesh":return this.meshSymbol;case"text":return this.textSymbol}}async _setupUpdateOperation(e,t){const{view:o}=this;if(!o)return this._logMissingView(),null;const i={...this.defaultUpdateOptions,...t,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...t?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...t?.highlightOptions}};this.activeUpdateOptions=i;let a=i.tool??Oe.tool;if(this.removeGraphics(e),this.addGraphics(e),"3d"===o.type){if(0===e.length)return null;switch(a){case"move":return this._setupMove3DOperation(e,i,o,a);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupReshape3DOperation(e[0],i,o);case"transform":return this._setupGraphicTransform3DOperation(e,i,o)}}switch(a){case"move":return this._setupMove2DOperation(e,i,o);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupTransformOrReshape2DOperation(e,a,i,o);case"transform":return be(e)&&(a="reshape"),this._setupTransformOrReshape2DOperation(e,a,i,o)}}async _setupMove3DOperation(e,t,o,i,a=!1){const r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Re(r))return r;const{ManipulatedObject3DGraphic:s,MoveTool3D:n}=r.module,p=new Map,l=()=>{p.forEach(e=>e.destroy()),p.clear()};for(const h of e){const e=new s({view:o,graphic:h}),t=B(e);if(0!==t)return l(),this._logError("sketch:move",`Move operation not supported for provided graphic(s) (${z(t)}).`),null;p.set(h,e)}const d=new n({view:o,enableZ:t.enableZ,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(d),d.objects.addMany(Array.from(p.values())),a||this.updateGraphics.addMany(e);const c=[],u=new me({activeComponent:d,tool:i,type:"update",onEnd:()=>{h(c),Ue(o,d),l()},undo:()=>{De(this.view,d),He(u,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{Pe(u,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:e=>{this.updateGraphics.push(e);const t=new s({view:o,graphic:e});p.set(e,t),d.objects.push(t),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:e=>{const t=this.updateGraphics.indexOf(e);if(u.history.undo.forEach(e=>e.updates.splice(t,1)),u.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0===this.updateGraphics.length)return void u.complete();const o=p.get(e);o&&(d.objects.remove(o),o.destroy(),p.delete(e))},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;if("transform"!==i)return;const e=this.updateGraphics.at(0),a=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,o,!0));a&&!Re(a)&&(u.onEnd(),u.destroy(),this._setUpdateOperationHandle(a,t))}});return c.push(...this._getHandlesForComponent(u,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(u,e,t),J.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(u,e)},J.WIDGET)),u}_setupGraphicTransform3DOperation(e,t,o,i=!1){if(1===e.length&&0===Y(e[0])){const a=e[0],r=a.geometry;if(null!=r&&("point"===r.type||"mesh"===r.type))return this._setupPointTransform3DOperation(a,t,o);if(null!=r&&("polygon"===r.type||"polyline"===r.type))return this._setupPolyTransform3DOperation(a,t,o,i)}return this._setupMove3DOperation(e,t,o,"transform",i)}async _setupPointTransform3DOperation(e,t,o){const i="transform",{enableRotation:a,enableScaling:r,enableZ:s}=t,n=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Re(n))return n;const{TransformTool3D:p,ManipulatedObject3DGraphic:l}=n.module,d=new l({graphic:e,view:o}),c=new p({object:d,view:o,enableRotation:a,enableScaling:r,enableZ:s,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(c),this.updateGraphics.add(e);const u=[],y=new me({activeComponent:c,tool:i,type:"update",onEnd:()=>{h(u),Ue(o,c),d.destroy()},undo:()=>{De(this.view,c),He(y,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{Pe(y,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),y.onEnd(),y.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Re(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),y.complete()},toggleTool:()=>{}});return u.push(...this._getHandlesForComponent(y,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(y,e,t),J.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(y,e)},J.WIDGET)),y}async _setupPolyTransform3DOperation(e,t,o,i=!1){const a="transform",{enableRotation:r,enableScaling:s,enableZ:n,preserveAspectRatio:p}=t,l=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Re(l))return l;const{ManipulatedObject3DGraphic:d,ExtentTransformTool:c}=l.module,u=this.view?.inputManager?.isModifierKeyDown(Q.constraint),y=new d({view:o,graphic:e}),m=new c({object:y,view:o,enableRotation:r,enableScaling:s,enableZ:n,preserveAspectRatio:!!p!=!!u,sketchOptions:this.sketchOptions});o.tools.add(m),i||this.updateGraphics.add(e);const g=[],v=new me({activeComponent:m,tool:a,type:"update",onEnd:()=>{h(g),Ue(o,m),y.destroy()},canUndo:()=>!m.destroyed&&m.canUndo,undo:()=>{m.destroyed||(m.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},canRedo:()=>!m.destroyed&&m.canRedo,redo:()=>{m.destroyed||(m.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),v.onEnd(),v.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Re(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),v.complete()},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;const i=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,o,!0));i&&!Re(i)&&(v.onEnd(),v.destroy(),this._setUpdateOperationHandle(i,t))}});return g.push(...this._getHandlesForComponent(v,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(v,e,t),J.WIDGET),o.on("key-down",e=>this._getCommonUpdateOperationKeyDownHandlers(v,e),J.WIDGET),o.on("key-down",e=>{e.key!==Q.constraint||e.repeat||(m.preserveAspectRatio=!m.preserveAspectRatio,e.stopPropagation())},J.WIDGET),o.on("key-up",e=>{e.key===Q.constraint&&(m.preserveAspectRatio=!m.preserveAspectRatio,e.stopPropagation())},J.WIDGET)),v}async _setupMove2DOperation(e,t,o){const i="move";this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const a=await this._updatingHandles.addPromise(this._getGraphicMover(e,t,o));if(Re(a))return a;const r=new me({activeComponent:a,tool:i,type:"update",onEnd:()=>{this._clearCursor(),h(p),h(n),a.destroy(),this._internalGraphicsLayer?.removeMany([...this.updateGraphics.toArray()])},undo:()=>{const e=this.updateGraphics.toArray();He(r,e),r.refreshComponent(),this._emitUndoEvent({graphics:e,tool:i})},redo:()=>{const e=this.updateGraphics.toArray();Pe(r,e),r.refreshComponent(),this._emitRedoEvent({graphics:e,tool:i})},addToSelection:async e=>{await this._updatingHandles.addPromise(this._updateSpatialReference(e)),this.updateGraphics.push(e),a.graphics=this.updateGraphics.toArray(),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:e=>{const t=this.updateGraphics.indexOf(e);r.history.undo.forEach(e=>e.updates.splice(t,1)),r.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e);const o=this.updateGraphics.toArray();this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0!==this.updateGraphics.length?a.graphics=o:r.complete()}});let s=!1;const n=[o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(r,e,t),J.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key!==Q.constraint||e.repeat||(s=!0,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)},J.WIDGET),o.on("key-up",e=>{e.key===Q.constraint&&s&&(s=!1,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)},J.WIDGET)],p=this._getHandlesForComponent(r,t);return r}async _setupReshape3DOperation(e,t,o,i=!1){const a="reshape",r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Re(r))return r;const{ManipulatedObject3DGraphic:s,ReshapeTool3D:n}=r.module,p=new s({view:o,graphic:e}),l=$(p);if(0!==l)return p.destroy(),this._logError("sketch:reshape",`Reshape operation not supported for provided graphic(s) (${z(l)}).`),null;const d=t.reshapeOptions,c=new n({view:o,object:p,enableZVertex:t.enableZ&&"move"===d?.vertexOperation,enableZShape:t.enableZ&&"move"===d?.shapeOperation,enableMoveObject:"move"===d?.shapeOperation||"move-xy"===d?.shapeOperation,enableMidpoints:"split"===d?.edgeOperation,enableEdgeOffset:"offset"===d?.edgeOperation,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(c),i||this.updateGraphics.add(p.graphic);const u=[],y=new me({activeComponent:c,tool:a,type:"update",onEnd:()=>{h(u),Ue(o,c),p.destroy()},canUndo:()=>!c.destroyed&&c.canUndo,undo:()=>{c.destroyed||(c.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},canRedo:()=>!c.destroyed&&c.canRedo,redo:()=>{c.destroyed||(c.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),y.onEnd(),y.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Re(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),y.complete()},toggleTool:async()=>{if(!1===t.toggleToolOnClick)return;y.onEnd(),y.destroy();const e=await this._updatingHandles.addPromise(this._setupGraphicTransform3DOperation(this.updateGraphics.toArray(),t,o,!0));Re(e)||this._setUpdateOperationHandle(e,t)}});return u.push(...this._getHandlesForComponent(y,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(y,e,t),J.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(y,e)},J.WIDGET)),y}async _setupTransformOrReshape2DOperation(e,t,o,i){this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const a=await this._updatingHandles.addPromise("transform"===t?this._getBox(e,o,i):this._getReshape(e,o,i));if(Re(a))return a;const r=new me({activeComponent:a,type:"update",onEnd:()=>{h(n),h(s),r.activeComponent&&!r.activeComponent.destroyed&&r.activeComponent.destroy(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray())},undo:()=>{He(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},redo:()=>{Pe(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},addToSelection:async e=>{let t=r.activeComponent;if("reshape"===t?.type){const t=[...this.updateGraphics,e];this.updateGraphics.removeAll(),r.onEnd(),r.destroy();const a=await this._updatingHandles.addPromise(this._setupTransformOrReshape2DOperation(t,"transform",o,i));if(Re(a))return;this._setUpdateOperationHandle(a,o)}else this.updateGraphics.add(e),t.graphics=this.updateGraphics.toArray(),t.refresh(),r.resetHistory();this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:e=>{const t=this.updateGraphics.indexOf(e);r.history.undo.forEach(e=>e.updates.splice(t,1)),r.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e);const o=this.updateGraphics.toArray();0===o.length?r.complete():be(o)?r.toggleTool():r.activeComponent.graphics=o,this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"})},toggleTool:async()=>{if(this.updateGraphics.length>1)return;const e=this.updateGraphics.at(0),t=e.geometry;if(null!=t&&("reshape"===r.tool&&"point"===t.type||"transform"===r.tool&&"extent"===t.type))return;let a=null;const s={...this.defaultUpdateOptions,...o,...this.activeUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...o?.reshapeOptions,...this.activeUpdateOptions?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...o?.highlightOptions,...this.activeUpdateOptions?.highlightOptions}};"transform"===r.tool?a=await this._updatingHandles.addPromise(this._getReshape([e],s,i)):"reshape"===r.tool&&(a=await this._updatingHandles.addPromise(this._getBox([e],s,i))),Re(a)||(r.activeComponent?.destroy(),r.activeComponent=a,r.activeComponent&&(h(n),n=this._getHandlesForComponent(r,s)))}}),s=[i.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(r,e,o),J.WIDGET),i.on("key-down",e=>{if(this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key===Q.constraint&&!e.repeat&&r){const e=r.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},J.WIDGET),i.on("key-up",e=>{if(e.key===Q.constraint&&r){const e=r.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},J.WIDGET)];let n=this._getHandlesForComponent(r,o);return r}async _getGraphicMover(e,t,o){const{enableMoveAllGraphics:i,highlightOptions:a}=t,r=await this._requireModule(import("../../views/draw/support/GraphicMover.js"));return Re(r)?r:new r.module.default({enableMoveAllGraphics:i,highlightName:a?.name,highlightsEnabled:!!a?.enabled,indicatorsEnabled:!1,graphics:e,view:o,callbacks:{onGraphicMoveStart:({dx:e,dy:t,graphic:o})=>{this._displayCursor("grabbing"),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-start"},type:"update"})},onGraphicMove:({dx:e,dy:t,graphic:o})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move"},type:"update"}),onGraphicMoveStop:({dx:e,dy:t,graphic:o})=>{this._displayCursor("pointer"),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-stop"},type:"update"})},onGraphicPointerOver:()=>this._displayCursor("move"),onGraphicPointerOut:()=>this._clearCursor()}})}async _getBox(e,t,o){const{enableRotation:i,enableScaling:a,highlightOptions:r,preserveAspectRatio:s}=t,n=await this._requireModule(import("../../views/draw/support/Box.js"));if(Re(n))return n;const p=this.view?.inputManager?.isModifierKeyDown(Q.constraint),l=new n.module.default({graphics:e,enableRotation:i,enableScaling:a,highlightName:r?.name,highlightsEnabled:!!r?.enabled,preserveAspectRatio:!!s!=!!p,layer:this._internalGraphicsLayer,view:o,sketchOptions:this.sketchOptions,callbacks:{onMoveStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onMove:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onMoveStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScaleStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScale:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScaleStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotateStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotate:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotateStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"})}});return l.addHandles(_(()=>[this.activeUpdateOptions?.enableRotation,this.activeUpdateOptions?.enableScaling],([e,o])=>{l.enableRotation=e??t.enableRotation??!0,l.enableScaling=o??t.enableScaling??!0,l.refresh()},b)),l}async _getReshape(e,t,o){const{highlightOptions:i,reshapeOptions:a}=t,r="split"===a?.edgeOperation,s="move"===a?.shapeOperation,n=!!a?.enableCreateCurveFromStraightEdge,p=await this._requireModule(import("../../views/draw/support/Reshape.js"));return Re(p)?p:new p.module.default({enableMidpoints:r,enableMovement:s,enableCurveOnMidpoint:n,graphic:e[0],highlightName:i?.name,highlightsEnabled:!!i?.enabled,layer:this._internalGraphicsLayer,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions,view:o,callbacks:{onReshapeStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onReshape:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onReshapeStop:({mover:e,type:t})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e,type:t},type:"update"}),onMoveStart:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onMove:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onMoveStop:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onVertexAdd:({added:e,type:t,vertices:o})=>{const i=e.map(e=>D(e.geometry));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:i,vertices:o,type:t},type:"update"})},onVertexRemove:({removed:e,type:t,vertices:o})=>{const i=e.map(e=>D(e.geometry));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{removed:i,vertices:o,type:t},type:"update"})}}})}_getHandlesForComponent(e,t){const o=e.activeComponent;if(!o)return[];switch(o.type){case"graphic-mover":return[o.on("graphic-click",({graphic:o,viewEvent:i})=>{i.native?.shiftKey&&t.multipleSelectionEnabled&&(i.stopPropagation(),e.removeFromSelection(o))}),o.on("graphic-move-start",t=>e.addToHistory(je(t.allGraphics)))];case"box":return[o.on("graphic-click",o=>this._onTransformOrReshape2DGraphicClick(e,t,o)),o.on("move-start",t=>e.addToHistory(je(t.graphics))),o.on("rotate-start",t=>e.addToHistory(je(t.graphics))),o.on("scale-start",t=>e.addToHistory(je(t.graphics)))];case"reshape":return[o.on("graphic-click",o=>this._onTransformOrReshape2DGraphicClick(e,t,o)),o.on("move-start",t=>e.addToHistory(je([t.mover]))),o.on("reshape-start",t=>e.addToHistory(je([t.graphic]))),o.on("vertex-add",t=>e.addToHistory(je([t.oldGraphic]))),o.on("vertex-remove",t=>e.addToHistory(je([t.oldGraphic])))];case"move-3d":return[o.events.on("record-undo",({updates:t})=>{e.addToHistory({updates:t})}),o.events.on("move-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move-start"},type:"update"})}),o.events.on("move",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e.dx,dy:e.dy,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move"},type:"update"})}),o.events.on("move-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move-stop"},type:"update"})}),o.events.on("immediate-click",o=>{o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool()})];case"transform-3d":return[o.events.on("record-undo",({updates:t})=>{e.addToHistory({updates:t})}),o.events.on("translate-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-start"},type:"update"})}),o.events.on("translate-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-stop"},type:"update"})}),o.events.on("rotate-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate-start"},type:"update"})}),o.events.on("rotate-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate-stop"},type:"update"})}),o.events.on("scale-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-start"},type:"update"})}),o.events.on("scale-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-stop"},type:"update"})}),o.events.on("translate",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move"},type:"update"})}),o.events.on("rotate",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate"},type:"update"})}),o.events.on("scale",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale"},type:"update"})}),o.events.on("immediate-click",o=>{o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool()})];case"reshape-3d":return[o.events.on("reshape",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e,mover:e.object.graphic},type:"update"})}),o.events.on("move",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e,mover:e.object.graphic},type:"update"})}),o.events.on("vertex-add",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})}),o.events.on("vertex-remove",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})}),o.events.on("immediate-click",o=>{o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool()})]}}_onTransformOrReshape2DGraphicClick(e,t,o){const{graphic:i,viewEvent:a}=o;return a.native?.shiftKey&&this.hasGraphic(i)?(a.stopPropagation(),e.removeFromSelection(i)):t.toggleToolOnClick?(a.stopPropagation(),e.toggleTool()):void 0}_setUpdateOperationHandle(e,t){this._operationHandle=e;const o=this.view?.map;this._disablePopup(t);const i=()=>{if(e===this._operationHandle){const i=this.updateGraphics.toArray(),a=this._operationHandle.tool;this._operationHandle.destroy(),this._operationHandle=null,this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray()),this.updateGraphics.removeAll(),o&&o.remove(this._internalGraphicsLayer),this._restorePopup(t),this.emit("update",{graphics:i,state:"complete",aborted:e.cancelled,tool:a,toolEventInfo:null,type:"update"})}};e.on("complete",i)}async _getCommonUpdateOperationClickHandlers(e,t,o){const i=he(t),a=await t.defer(()=>this._getFirstHit(i));if(null==a)return void(this.updateOnGraphicClick&&e.complete());if(t.native.shiftKey&&this._toggleSelection([a.graphic],e,o))return void t.stopPropagation();this.updateGraphics.includes(a.graphic)?t.stopPropagation():e.complete()}_toggleSelection(e,t,o){const i=!!o.multipleSelectionEnabled;return e.some(e=>null!=e&&(!(!i||!this.hasGraphic(e))&&(this.updateGraphics.includes(e)?t.removeFromSelection(e):t.addToSelection(e),!0)))}_getCommonUpdateOperationKeyDownHandlers(e,t){if(!e)return;const o=t.key;o===Q.undo&&e.canUndo()?(t.stopPropagation(),e.undo()):o===Q.redo&&e.canRedo()?(t.stopPropagation(),e.redo()):o===Q.cancel?(t.stopPropagation(),e.cancel()):this.allowDeleteKey&&Q.delete.includes(o)&&this._onDeleteKey(t)}_onDeleteKey(e){this._operationHandle&&"update"===this._operationHandle.type&&null!=this.activeComponent&&(e.stopPropagation(),this.delete())}_removeDefaultLayer(){this._internalGraphicsLayer&&(this.view?.map?.remove(this._internalGraphicsLayer),this._internalGraphicsLayer=y(this._internalGraphicsLayer))}_isComponentGraphic(e){const{activeComponent:t}=this;return!(!e||null==t)&&(e.attributes?.esriSketchTool||"draw-2d"===t.type&&t.graphic===e||("box"===t.type||"reshape"===t.type)&&t.isUIGraphic(e))}_clearCursor(){this.removeHandles(Se)}_displayCursor(e){this.removeHandles(Se),this.view?.container&&null!=e&&this.addHandles(this.view.acquireCursor(e,"high"),Se)}_logError(e,t,o){u.getLogger(this).error(new n(e,t,o))}async _requireModule(e){const t=new AbortController;this._moduleLoaderAbortController=t;const o=await e;return this._moduleLoaderAbortController!==t||t.signal.aborted?{requireError:"aborted"}:{module:o}}_emitUndoEvent(e){this.emit("undo",{...e,type:"undo"})}_emitRedoEvent(e){this.emit("redo",{...e,type:"redo"})}_emitDeleteEvent(e){this.emit("delete",{...e,type:"delete"})}_onLayerGraphicsChangeCallback(e){if(null!=this._operationHandle){const{updateGraphics:t}=this;for(const o of e.removed)if(t.includes(o)){if(!(t.length>1)){this._operationHandle.cancel();break}this._operationHandle.removeFromSelection(o)}}}async _setupAdvancedDrawToolIntegrationMaybe(){this.isUsingLegacyCreateTools||this.pluginManager.loaded||await this.pluginManager.loadPlugins()}async _setupDrawTool(e,t,o){if(this.isUsingLegacyCreateTools||!this._pluginManager)return null;const a=this.view,r=await import("../../views/draw/DrawTool.js");await this.pluginManager.loadPlugins();const s=await this.pluginManager.makeRenderer({customSymbol:t.graphicSymbol,useTextSymbol:"text"===o}),n=new r.DrawTool({view:a,elevationInfo:this._layerAdapter?.elevationInfo??x("3d"===a.type),hasZ:!!t.hasZ,sketchOptions:this.sketchOptions,renderer:s,defaultZ:t.defaultZ??0,directionOptions:t.directionOptions,snappingManager:this.snappingManager,enableVertexVisuals:"rectangle"!==o&&"circle"!==o,readPluginSetting:(e,t)=>this.settingsManager.getValue(t)});n.addHandles(c(s));const p=new i({...t.graphicProperties,attributes:{...t.graphicProperties?.attributes},symbol:t.graphicSymbol??this._getGraphicSymbolFromTool(o)});return t.graphicSymbol||n.addHandles(_(()=>this._getGraphicSymbolFromTool(o),e=>p.symbol=e)),this._set("createGraphic",p),a.addAndActivateTool(n),n.begin(e),n}get test(){}wait(){return G(()=>!this.updating)}_disablePopupEnabled(e){return"3d"!==this.view?.type||this.updateOnGraphicClick||(e?.toggleToolOnClick??!1)}_disablePopup(e){this._disablePopupEnabled(e)&&this.view&&null==this._originalPopupEnabled&&(this._originalPopupEnabled=this.view.popupEnabled,this.view.popupEnabled=!1)}_restorePopup(e){this._disablePopupEnabled(e)&&this.view&&null!=this._originalPopupEnabled&&(this.view.popupEnabled=this._originalPopupEnabled,this._originalPopupEnabled=null)}async _waitViewReady(){const e=this.view;e?(m(this._viewReadyAbortController),this._viewReadyAbortController=new AbortController,await f(G(()=>e?.ready),this._viewReadyAbortController.signal)):this._logMissingView()}_logMissingView(){this._logError("sketch:missing-property",Me("view"))}_logMissingLayer(){this._logError(Ee,Me("layer"))}};o([O()],Ae.prototype,"_defaultSnappingManager",void 0),o([O()],Ae.prototype,"_layerAdapter",null),o([O()],Ae.prototype,"_pluginManager",void 0),o([O({readOnly:!0})],Ae.prototype,"settingsManager",void 0),o([O()],Ae.prototype,"_operationHandle",void 0),o([O({readOnly:!0})],Ae.prototype,"_updatingHandles",void 0),o([O({readOnly:!0})],Ae.prototype,"_toolTransitionHandles",void 0),o([O()],Ae.prototype,"_drawToolSimplifyAbortController",void 0),o([O({readOnly:!0})],Ae.prototype,"activeTool",null),o([O()],Ae.prototype,"geometrySimplificationInProgress",null),o([O({readOnly:!0})],Ae.prototype,"activeCreateToolDrawMode",null),o([O()],Ae.prototype,"activeTooltip",null),o([O({types:N})],Ae.prototype,"activeFillSymbol",void 0),o([O()],Ae.prototype,"activeLineSymbol",void 0),o([O()],Ae.prototype,"activeVertexSymbol",void 0),o([O()],Ae.prototype,"allowDeleteKey",void 0),o([O({readOnly:!0})],Ae.prototype,"createGraphic",null),o([O()],Ae.prototype,"defaultCreateOptions",null),o([O()],Ae.prototype,"defaultUpdateOptions",null),o([O()],Ae.prototype,"activeUpdateOptions",void 0),o([O({type:ee,nonNullable:!0})],Ae.prototype,"labelOptions",null),o([O()],Ae.prototype,"layer",void 0),o([O({types:N})],Ae.prototype,"pointSymbol",void 0),o([O({types:N})],Ae.prototype,"polygonSymbol",void 0),o([O({types:N})],Ae.prototype,"polylineSymbol",void 0),o([O()],Ae.prototype,"meshSymbol",void 0),o([O({type:q})],Ae.prototype,"textSymbol",null),o([O({type:re,nonNullable:!0})],Ae.prototype,"snappingOptions",null),o([O()],Ae.prototype,"snappingManager",null),o([O({readOnly:!0})],Ae.prototype,"state",null),o([O()],Ae.prototype,"toolTransitionInProgress",null),o([O({type:oe,nonNullable:!0})],Ae.prototype,"tooltipOptions",null),o([O({readOnly:!0})],Ae.prototype,"updateGraphics",void 0),o([O()],Ae.prototype,"updateOnGraphicClick",void 0),o([O()],Ae.prototype,"updating",null),o([O()],Ae.prototype,"creationMode",void 0),o([O({type:ie,nonNullable:!0})],Ae.prototype,"valueOptions",null),o([O({types:N})],Ae.prototype,"vertexSymbol",void 0),o([O({value:null})],Ae.prototype,"view",null),o([O({constructOnly:!0,type:te})],Ae.prototype,"sketchOptions",void 0),o([O()],Ae.prototype,"useLegacyCreateTools",void 0),o([O()],Ae.prototype,"isUsingLegacyCreateTools",null),o([O()],Ae.prototype,"pluginManager",null),o([O()],Ae.prototype,"drawTool",null),o([O()],Ae.prototype,"rootPlugins",null),o([O()],Ae.prototype,"effectiveAvailablePlugins",null),o([O()],Ae.prototype,"firstPluginWithSwappableLeaf",null),o([O()],Ae.prototype,"multiplePluginsActive",null),Ae=o([S("esri.widgets.Sketch.SketchViewModel")],Ae);const Ee="sketch:missing-property",Me=e=>`Property '${e}' is missing on SketchViewModel.`;function ke(e){return"polygon"===e||"rectangle"===e||"circle"===e}function He(e,t){Ie("undo",e.history.undo,e.history.redo,t)}function Pe(e,t){Ie("redo",e.history.redo,e.history.undo,t)}function Ie(e,t,o,i){const a=t.pop();if(!a)return;const r=a.updates,s=[];i.forEach((t,o)=>{const i=r[o];null!=i&&("geometry"in i&&null!=i.geometry&&(s.push({geometry:t.geometry}),t.geometry=i.geometry),"symbol"in i&&null!=i.symbol&&(s.push({symbol:t.symbol}),t.symbol=i.symbol),"undo"in i&&(s.push(i),i[e](t)))}),o.push({updates:s})}function De(e,t){null!=e&&t.hasGrabbedManipulators&&(e.activeTool=null)}function je(e){return{updates:e.map(({geometry:e})=>"mesh"===e?.type?{geometry:e.cloneShallow()}:{geometry:e})}}function Ue(e,t){e.tools?.remove(t),t.destroyed||t.destroy()}function Re(e){return"requireError"in e&&"aborted"===e.requireError}export{Ae as default};
|
|
@@ -7,7 +7,7 @@ import type { SelectionToolVisibilityMapProperties } from "./SelectionToolVisibi
|
|
|
7
7
|
import type { SnappingControlsVisibleElementsProperties } from "../support/SnappingControls/VisibleElements.js";
|
|
8
8
|
|
|
9
9
|
/** @since 5.0 */
|
|
10
|
-
export interface VisibleElementsProperties extends Partial<Pick<VisibleElements, "deleteButton" | "duplicateButton" | "labelsToggle" | "selectionCountLabel" | "settingsMenu" | "snappingControls" | "tooltipsToggle" | "undoRedoMenu">> {
|
|
10
|
+
export interface VisibleElementsProperties extends Partial<Pick<VisibleElements, "deleteButton" | "duplicateButton" | "geometrySimplificationActivityIndicator" | "labelsToggle" | "selectionCountLabel" | "settingsMenu" | "snappingControls" | "tooltipsToggle" | "undoRedoMenu">> {
|
|
11
11
|
/**
|
|
12
12
|
* The available sketch tools within the widget.
|
|
13
13
|
*
|
|
@@ -82,6 +82,24 @@ export default class VisibleElements extends Accessor {
|
|
|
82
82
|
* @since 5.0
|
|
83
83
|
*/
|
|
84
84
|
accessor duplicateButton: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Indicates whether to display the geometry simplification progress indicator while geometry simplification is in progress.
|
|
87
|
+
* Default value is `true`.
|
|
88
|
+
*
|
|
89
|
+
* When set to `false`, the progress indicator is not shown. You can use
|
|
90
|
+
* [SketchViewModel.geometrySimplificationInProgress](https://developers.arcgis.com/javascript/latest/references/core/widgets/Sketch/SketchViewModel/#geometrySimplificationInProgress) to detect this state and implement
|
|
91
|
+
* alternative UI.
|
|
92
|
+
*
|
|
93
|
+
* @default true
|
|
94
|
+
* @remarks
|
|
95
|
+
* Before 5.1, simplification of geometries was done synchronously on the main thread. With the
|
|
96
|
+
* introduction of support for true curves, this simplification step can take some time (multiple seconds)
|
|
97
|
+
* in extreme cases. At 5.1, simplification is asynchronous and Sketch is disabled during simplification.
|
|
98
|
+
* If this process takes a significant amount of time, an activity indicator is shown.
|
|
99
|
+
* This property only affects rendering of that indicator.
|
|
100
|
+
* @since 5.1
|
|
101
|
+
*/
|
|
102
|
+
accessor geometrySimplificationActivityIndicator: boolean;
|
|
85
103
|
/**
|
|
86
104
|
* Indicates whether to display the sketch labels toggle. Default value is `true`.
|
|
87
105
|
*
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as o}from"tslib";import
|
|
2
|
+
import{__decorate as o}from"tslib";import t from"../../core/Accessor.js";import{property as e,subclass as l}from"../../core/accessorSupport/decorators.js";import n from"./CreateToolVisibilityMap.js";import i from"./SelectionToolVisibilityMap.js";import p from"../support/SnappingControls/VisibleElements.js";let s=class extends t{constructor(o){super(o),this.createTools=new n,this.directionModePicker=!1,this.duplicateButton=!0,this.deleteButton=!0,this.selectionCountLabel=!0,this.labelsToggle=!0,this.geometrySimplificationActivityIndicator=!0,this.selectionTools=new i,this.settingsMenu=!0,this.singlePluginBackButton=!0,this.snappingControls=!0,this.snappingControlsElements=new p,this.tooltipsToggle=!0,this.undoRedoMenu=!0}};o([e({type:n,nonNullable:!0})],s.prototype,"createTools",void 0),o([e({type:Boolean,nonNullable:!0})],s.prototype,"directionModePicker",void 0),o([e({type:Boolean,nonNullable:!0})],s.prototype,"duplicateButton",void 0),o([e({type:Boolean,nonNullable:!0})],s.prototype,"deleteButton",void 0),o([e({type:Boolean,nonNullable:!0})],s.prototype,"selectionCountLabel",void 0),o([e({type:Boolean,nonNullable:!0})],s.prototype,"labelsToggle",void 0),o([e({type:Boolean,nonNullable:!0})],s.prototype,"geometrySimplificationActivityIndicator",void 0),o([e({type:i,nonNullable:!0})],s.prototype,"selectionTools",void 0),o([e({type:Boolean,nonNullable:!0})],s.prototype,"settingsMenu",void 0),o([e()],s.prototype,"singlePluginBackButton",void 0),o([e({type:Boolean,nonNullable:!0})],s.prototype,"snappingControls",void 0),o([e({type:p,nonNullable:!0})],s.prototype,"snappingControlsElements",void 0),o([e({type:Boolean,nonNullable:!0})],s.prototype,"tooltipsToggle",void 0),o([e({type:Boolean,nonNullable:!0})],s.prototype,"undoRedoMenu",void 0),s=o([l("esri.widgets.Sketch.VisibleElements")],s);const r=s;export{r as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{isSome as t}from"../../../core/arrayUtils.js";import{EventedAccessor as
|
|
2
|
+
import{__decorate as e}from"tslib";import{isSome as t}from"../../../core/arrayUtils.js";import o from"../../../core/Collection.js";import{EventedAccessor as r}from"../../../core/Evented.js";import{property as s,subclass as n}from"../../../core/accessorSupport/decorators.js";import{getLegacyTool as i}from"./sketchUtils.js";let p=class extends r{constructor(e){super(e),this.cancelled=!1,this.history={undo:new o,redo:new o},this.type=null}get tool(){const{activeComponent:e}=this;if(!e)return null;switch(e.type){case"graphic-mover":case"move-3d":return"move";case"box":case"transform-3d":return"transform";case"reshape":case"reshape-3d":return"reshape";case"draw-2d":return"text"===e.graphicSymbol?.type?"text":e.geometryType;case"draw-3d":return e.geometryType;case"draw-2.0":return i(e.pluginStack.toArray().map(e=>e?.configuration).filter(t))??null}return null}addToHistory(e){this.history.redo.removeAll(),this.history.undo.push(e)}resetHistory(){this.history.redo.removeAll(),this.history.undo.removeAll()}canUndo(){return this.history.undo.length>0}canRedo(){return this.history.redo.length>0}complete(){const{activeComponent:e}=this;e&&"reset"in e?e.reset():e&&"complete"in e&&e.mostUpstreamPlugin&&e.complete(e.mostUpstreamPlugin),this.onEnd(),this.emit("complete")}cancel(){this.cancelled=!0;const{activeComponent:e}=this;e&&"reset"in e&&e.reset(),this.onEnd(),this.emit("complete")}refreshComponent(){const e=this.activeComponent;e&&("box"!==e.type&&"reshape"!==e.type&&"graphic-mover"!==e.type||e.refresh())}set undo(e){this._set("undo",()=>{this.canUndo()&&e()})}set redo(e){this._set("redo",()=>{this.canRedo()&&e()})}};e([s()],p.prototype,"activeComponent",void 0),e([s()],p.prototype,"cancelled",void 0),e([s()],p.prototype,"history",void 0),e([s()],p.prototype,"tool",null),e([s()],p.prototype,"type",void 0),e([s()],p.prototype,"canUndo",null),e([s()],p.prototype,"canRedo",null),e([s()],p.prototype,"onEnd",void 0),e([s()],p.prototype,"undo",null),e([s()],p.prototype,"redo",null),e([s()],p.prototype,"toggleTool",void 0),e([s()],p.prototype,"addToSelection",void 0),e([s()],p.prototype,"removeFromSelection",void 0),p=e([n("esri.widgets.Sketch.support.OperationHandle")],p);let a=class extends p{};e([s()],a.prototype,"activeComponent",void 0),a=e([n("esri.widgets.Sketch.support.OperationHandle.CreateOperationHandle")],a);let l=class extends p{};e([s()],l.prototype,"activeComponent",void 0),l=e([n("esri.widgets.Sketch.support.OperationHandle.UpdateOperationHandle")],l);let c=class extends p{};e([s()],c.prototype,"activeComponent",void 0),c=e([n("esri.widgets.Sketch.support.OperationHandle.DrawToolOperationHandle")],c);export{a as CreateOperationHandle,c as DrawToolOperationHandle,p as OperationHandle,l as UpdateOperationHandle};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type Accessor from "../../../core/Accessor.js";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Support object that manages the available plugin metadata
|
|
5
|
+
* for Sketch and SketchViewModel.
|
|
6
|
+
*
|
|
7
|
+
* Implements compatibility between legacy modes of configuring
|
|
8
|
+
* available create tools, symbology, etc.
|
|
9
|
+
*
|
|
10
|
+
* @internal
|
|
11
|
+
*/
|
|
12
|
+
export abstract class PluginManager extends Accessor {}
|