@arcgis/core 4.24.0-next.20220511 → 4.24.0-next.20220512

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.
Files changed (231) hide show
  1. package/assets/components/assets/icon/compactness16.json +1 -0
  2. package/assets/components/assets/icon/compactness24.json +1 -0
  3. package/assets/components/assets/icon/compactness32.json +1 -0
  4. package/assets/components/assets/icon/configure16.json +1 -0
  5. package/assets/components/assets/icon/configure24.json +1 -0
  6. package/assets/components/assets/icon/configure32.json +1 -0
  7. package/assets/components/assets/icon/debugScript16.json +1 -0
  8. package/assets/components/assets/icon/debugScript24.json +1 -0
  9. package/assets/components/assets/icon/debugScript32.json +1 -0
  10. package/assets/components/assets/icon/dissolveFeatures16.json +1 -0
  11. package/assets/components/assets/icon/dissolveFeatures24.json +1 -0
  12. package/assets/components/assets/icon/dissolveFeatures32.json +1 -0
  13. package/assets/components/assets/icon/distanceType16.json +1 -0
  14. package/assets/components/assets/icon/distanceType24.json +1 -0
  15. package/assets/components/assets/icon/distanceType32.json +1 -0
  16. package/assets/components/assets/icon/gridDiamond16.json +1 -0
  17. package/assets/components/assets/icon/gridDiamond24.json +1 -0
  18. package/assets/components/assets/icon/gridDiamond32.json +1 -0
  19. package/assets/components/assets/icon/gridHexagon16.json +1 -0
  20. package/assets/components/assets/icon/gridHexagon24.json +1 -0
  21. package/assets/components/assets/icon/gridHexagon32.json +1 -0
  22. package/assets/components/assets/icon/gridTriangle16.json +1 -0
  23. package/assets/components/assets/icon/gridTriangle24.json +1 -0
  24. package/assets/components/assets/icon/gridTriangle32.json +1 -0
  25. package/assets/components/assets/icon/insets16.json +1 -0
  26. package/assets/components/assets/icon/insets24.json +1 -0
  27. package/assets/components/assets/icon/insets32.json +1 -0
  28. package/assets/components/assets/icon/maximumTerritoryDistance16.json +1 -0
  29. package/assets/components/assets/icon/maximumTerritoryDistance24.json +1 -0
  30. package/assets/components/assets/icon/maximumTerritoryDistance32.json +1 -0
  31. package/assets/components/assets/icon/minDistanceBetweenCenters16.json +1 -0
  32. package/assets/components/assets/icon/minDistanceBetweenCenters24.json +1 -0
  33. package/assets/components/assets/icon/minDistanceBetweenCenters32.json +1 -0
  34. package/assets/components/assets/icon/numberOfTerritories16.json +1 -0
  35. package/assets/components/assets/icon/numberOfTerritories24.json +1 -0
  36. package/assets/components/assets/icon/numberOfTerritories32.json +1 -0
  37. package/assets/components/assets/icon/overlapFeatures16.json +1 -0
  38. package/assets/components/assets/icon/overlapFeatures24.json +1 -0
  39. package/assets/components/assets/icon/overlapFeatures32.json +1 -0
  40. package/assets/components/assets/icon/profileVariables16.json +1 -0
  41. package/assets/components/assets/icon/profileVariables24.json +1 -0
  42. package/assets/components/assets/icon/profileVariables32.json +1 -0
  43. package/assets/components/assets/icon/rasterAnalysis16.json +1 -0
  44. package/assets/components/assets/icon/rasterAnalysis24.json +1 -0
  45. package/assets/components/assets/icon/rasterAnalysis32.json +1 -0
  46. package/assets/components/assets/icon/recurrence16.json +1 -0
  47. package/assets/components/assets/icon/recurrence24.json +1 -0
  48. package/assets/components/assets/icon/recurrence32.json +1 -0
  49. package/assets/components/assets/icon/splitFeatures16.json +1 -0
  50. package/assets/components/assets/icon/splitFeatures24.json +1 -0
  51. package/assets/components/assets/icon/splitFeatures32.json +1 -0
  52. package/assets/components/assets/icon/territoryBufferDistance16.json +1 -0
  53. package/assets/components/assets/icon/territoryBufferDistance24.json +1 -0
  54. package/assets/components/assets/icon/territoryBufferDistance32.json +1 -0
  55. package/assets/components/assets/icon/testData16.json +1 -0
  56. package/assets/components/assets/icon/testData24.json +1 -0
  57. package/assets/components/assets/icon/testData32.json +1 -0
  58. package/assets/esri/core/workers/RemoteClient.js +1 -1
  59. package/assets/esri/core/workers/chunks/07eda3e958d29f86b37e.js +1 -0
  60. package/assets/esri/core/workers/chunks/0ecaa28b8bff1d779d66.js +1 -0
  61. package/assets/esri/core/workers/chunks/{adae54f116f311d72d97.js → 1aba8c73c62a64e0658c.js} +1 -1
  62. package/assets/esri/core/workers/chunks/1d109cd048170e2d529a.js +1 -0
  63. package/assets/esri/core/workers/chunks/366e5c1abd1ab6d3e548.js +1 -0
  64. package/assets/esri/core/workers/chunks/3e94e35f44aadbb332ff.js +1 -0
  65. package/assets/esri/core/workers/chunks/46411f32b29a0e783105.js +1 -0
  66. package/assets/esri/core/workers/chunks/4d1c87e3e0a02efcc082.js +1 -0
  67. package/assets/esri/core/workers/chunks/{b089058b64db3912478f.js → 5e46e60fab93ad034d3a.js} +1 -1
  68. package/assets/esri/core/workers/chunks/6281b15009712a5dee3c.js +1 -0
  69. package/assets/esri/core/workers/chunks/66f627d68dbb0fdb725f.js +1 -0
  70. package/assets/esri/core/workers/chunks/672da24bbf86718bf48d.js +1 -0
  71. package/assets/esri/core/workers/chunks/733625d85602127d62cd.js +1 -0
  72. package/assets/esri/core/workers/chunks/{c51c9b5da855f84b9a48.js → 7391422fc51acb96a25d.js} +1 -1
  73. package/assets/esri/core/workers/chunks/{f435dc615fdc8917f6ca.js → 7cf3cff7b28ff007dbad.js} +1 -1
  74. package/assets/esri/core/workers/chunks/7ea06c86adfc827fda08.js +1 -0
  75. package/assets/esri/core/workers/chunks/{a054a52712a118c6d505.js → 82bc24bdc9c6ebaf58c0.js} +1 -1
  76. package/assets/esri/core/workers/chunks/8965ab74e03506e3475e.js +1 -0
  77. package/assets/esri/core/workers/chunks/{5405f478af3563580926.js → 8b497d9c37a8f577a467.js} +1 -1
  78. package/assets/esri/core/workers/chunks/919d0d8b1c2176760973.js +1 -0
  79. package/assets/esri/core/workers/chunks/ab2a0480dc2b608deda3.js +1 -0
  80. package/assets/esri/core/workers/chunks/ab97a35f7a7d5cf1da19.js +2 -0
  81. package/assets/esri/core/workers/chunks/{dcd0653191cd4a1ccaae.js.LICENSE.txt → ab97a35f7a7d5cf1da19.js.LICENSE.txt} +1 -1
  82. package/assets/esri/core/workers/chunks/ae554c88e862a5761f2e.js +1 -0
  83. package/assets/esri/core/workers/chunks/ae5ce55cd1a32525f101.js +1 -0
  84. package/assets/esri/core/workers/chunks/b597c04a4abb98e29d1c.js +1 -0
  85. package/assets/esri/core/workers/chunks/{287c484fd40eee643f3a.js → b78c3e9d31c4a562cdf0.js} +1 -1
  86. package/assets/esri/core/workers/chunks/be4bf1e4cbe2a593f8b3.js +1 -0
  87. package/assets/esri/core/workers/chunks/{b7572b0921b23aef8b9d.js → c40d9caf5189be2c698e.js} +1 -1
  88. package/assets/esri/core/workers/chunks/{b28539c5a6bedb71b038.js → d63f736b3560c577a8a4.js} +1 -1
  89. package/assets/esri/core/workers/chunks/d869dabe937d3b60504e.js +1 -0
  90. package/assets/esri/core/workers/chunks/dd6c9a114ad38cf622ba.js +1 -0
  91. package/assets/esri/core/workers/chunks/e6b0f74226b9394bfa7a.js +1 -0
  92. package/assets/esri/themes/base/widgets/_Editor.scss +3 -2
  93. package/assets/esri/themes/dark/main.css +1 -1
  94. package/assets/esri/themes/light/main.css +1 -1
  95. package/assets/esri/themes/light/view.css +1 -1
  96. package/assets/esri/views/interactive/tooltip/t9n/Tooltip.json +1 -0
  97. package/assets/esri/views/interactive/tooltip/t9n/Tooltip_en.json +1 -0
  98. package/chunks/EdgeShader.glsl.js +3 -4
  99. package/interfaces.d.ts +463 -30
  100. package/layers/FeatureLayer.js +1 -1
  101. package/layers/GeoJSONLayer.js +1 -1
  102. package/layers/OGCFeatureLayer.js +1 -1
  103. package/layers/RouteLayer.js +1 -1
  104. package/layers/SceneLayer.js +1 -1
  105. package/layers/StreamLayer.js +1 -1
  106. package/layers/SubtypeGroupLayer.js +1 -1
  107. package/layers/WFSLayer.js +1 -1
  108. package/layers/buildingSublayers/BuildingComponentSublayer.js +1 -1
  109. package/layers/mixins/ArcGISImageService.js +1 -1
  110. package/layers/save/featureLayerUtils.js +1 -1
  111. package/layers/support/AggregateField.d.ts +4 -0
  112. package/layers/support/AggregateField.js +1 -1
  113. package/layers/support/FeatureReductionBinning.d.ts +4 -0
  114. package/layers/support/FeatureReductionBinning.js +1 -1
  115. package/layers/support/OutStatistic.d.ts +4 -0
  116. package/layers/support/Sublayer.js +1 -1
  117. package/layers/support/SubtypeSublayer.js +1 -1
  118. package/layers/support/rasterDatasets/ImageServerRaster.js +1 -1
  119. package/layers/support/rasterDatasets/wcsCoverageParser.js +1 -1
  120. package/layers/support/rasterFormats/TiffDecoder.js +1 -1
  121. package/package.json +3 -3
  122. package/portal/support/portalItemUtils.js +1 -1
  123. package/renderers/PieChartRenderer.d.ts +4 -0
  124. package/renderers/PieChartRenderer.js +5 -0
  125. package/renderers/Renderer.js +1 -1
  126. package/renderers/support/AuthoringInfo.js +1 -1
  127. package/renderers/support/RasterSymbolizer.js +1 -1
  128. package/renderers/support/clickToleranceUtils.js +1 -1
  129. package/renderers/support/rasterRendererHelper.js +1 -1
  130. package/renderers/support/types.js +1 -1
  131. package/renderers/support/utils.js +1 -1
  132. package/renderers.js +1 -1
  133. package/request.js +1 -1
  134. package/rest/imageService/fetchRasterInfo.js +5 -0
  135. package/rest/imageService/getCatalogItemRasterInfo.js +5 -0
  136. package/rest/print.js +1 -1
  137. package/smartMapping/renderers/color.js +1 -1
  138. package/smartMapping/renderers/dotDensity.js +1 -1
  139. package/smartMapping/renderers/heatmap.js +1 -1
  140. package/smartMapping/renderers/location.js +1 -1
  141. package/smartMapping/renderers/size.js +1 -1
  142. package/smartMapping/renderers/type.js +1 -1
  143. package/support/arcadeUtils.js +1 -1
  144. package/support/revision.js +1 -1
  145. package/symbols/cim/CIMSymbolHelper.js +1 -1
  146. package/symbols/cim/CurveHelper.js +1 -1
  147. package/symbols/cim/ExpandedCIM.js +1 -1
  148. package/symbols/cim/cimAnalyzer.js +1 -1
  149. package/symbols/cim/placements/PlacementInsidePolygon.js +1 -1
  150. package/views/2d/engine/brushes.js +1 -1
  151. package/views/2d/engine/vectorTiles/GlyphSource.js +1 -1
  152. package/views/2d/engine/vectorTiles/style/Filter.js +1 -1
  153. package/views/2d/engine/vectorTiles/style/StyleRepository.js +1 -1
  154. package/views/2d/engine/webgl/AttributeStoreView.js +1 -1
  155. package/views/2d/engine/webgl/Painter.js +1 -1
  156. package/views/2d/engine/webgl/Utils.js +1 -1
  157. package/views/2d/engine/webgl/brushes/WGLBrushPieChart.js +5 -0
  158. package/views/2d/engine/webgl/brushes/WGLGeometryBrush.js +1 -1
  159. package/views/2d/engine/webgl/brushes/WGLGeometryBrushFill.js +1 -1
  160. package/views/2d/engine/webgl/brushes/WGLGeometryBrushMarker.js +1 -1
  161. package/views/2d/engine/webgl/color.js +1 -1
  162. package/views/2d/engine/webgl/definitions.js +1 -1
  163. package/views/2d/engine/webgl/enums.js +1 -1
  164. package/views/2d/engine/webgl/mesh/templates/WGLBaseFillTemplate.js +1 -1
  165. package/views/2d/engine/webgl/mesh/templates/WGLBaseLineTemplate.js +1 -1
  166. package/views/2d/engine/webgl/mesh/templates/WGLDynamicFillTemplate.js +1 -1
  167. package/views/2d/engine/webgl/mesh/templates/WGLFillTemplate.js +1 -1
  168. package/views/2d/engine/webgl/mesh/templates/WGLMarkerTemplate.js +1 -1
  169. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  170. package/views/2d/engine/webgl/techniques/dotDensity/TechniqueDotDensity.js +1 -1
  171. package/views/2d/engine/webgl/techniques/pieChart/TechniquePieChart.js +5 -0
  172. package/views/2d/engine/webgl/techniques/utils.js +1 -1
  173. package/views/2d/engine/webgl/util/Matcher.js +1 -1
  174. package/views/2d/layers/features/schemaUtils.js +1 -1
  175. package/views/2d/layers/features/support/AttributeStore.js +1 -1
  176. package/views/2d/layers/features/tileRenderers/SymbolTileRenderer.js +1 -1
  177. package/views/2d/layers/features/tileRenderers/support/WGLFeatureView.js +1 -1
  178. package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
  179. package/views/3d/analysis/Dimensioning/DimensioningTool.js +1 -1
  180. package/views/3d/analysis/Dimensioning/LengthDimensionVisualization.js +1 -1
  181. package/views/3d/environment/SnowyWeather.d.ts +4 -0
  182. package/views/3d/layers/I3SMeshView3D.js +1 -1
  183. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  184. package/views/3d/terrain/TerrainRenderer.js +1 -1
  185. package/views/3d/terrain/TerrainSurface.js +1 -1
  186. package/views/3d/terrain/TileRenderer.js +1 -1
  187. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  188. package/views/3d/webgl-engine/collections/Component/Material/shader/ComponentData.glsl.js +5 -5
  189. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  190. package/views/3d/webgl-engine/lib/edgeRendering/EdgeRenderer.js +1 -1
  191. package/views/3d/webgl-engine/lib/edgeRendering/EdgeShaderTechniqueConfiguration.js +1 -1
  192. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  193. package/views/3d/webgl-engine/shaders/sources/edgeRenderer/EdgeUtil.glsl.js +37 -31
  194. package/views/draw/DrawOperation.js +1 -1
  195. package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
  196. package/views/interactive/snapping/SceneSnappingEngine.js +5 -0
  197. package/views/interactive/snapping/SnappingManager.js +1 -1
  198. package/views/interactive/snapping/snappingFactory.js +5 -0
  199. package/views/interactive/tooltip/content/TooltipContent.js +1 -1
  200. package/views/interactive/tooltip/content/TooltipContentDrawPoint.js +1 -1
  201. package/views/interactive/tooltip/content/TooltipContentDrawPolygon.js +1 -1
  202. package/views/interactive/tooltip/content/TooltipContentDrawPolyline.js +1 -1
  203. package/views/interactive/tooltip/content/TooltipContentTranslateVertex.js +1 -1
  204. package/widgets/Editor/workflowUtils.js +1 -1
  205. package/widgets/Editor.js +1 -1
  206. package/widgets/Popup/PopupViewModel.js +1 -1
  207. package/widgets/Popup/actionUtils.js +1 -1
  208. package/widgets/Sketch/SketchViewModel.js +1 -1
  209. package/assets/esri/core/workers/chunks/0564f1cfa3d17ff1aad3.js +0 -1
  210. package/assets/esri/core/workers/chunks/0806d5d706a864542bfb.js +0 -1
  211. package/assets/esri/core/workers/chunks/52478ee2d2a1354b6900.js +0 -1
  212. package/assets/esri/core/workers/chunks/5759af97f96f24c40105.js +0 -1
  213. package/assets/esri/core/workers/chunks/7bc828fbdd54c0b28aac.js +0 -1
  214. package/assets/esri/core/workers/chunks/875f26ee040f3d75c0db.js +0 -1
  215. package/assets/esri/core/workers/chunks/88384e7cafbfd2348598.js +0 -1
  216. package/assets/esri/core/workers/chunks/89acd5f888d6b8df4aad.js +0 -1
  217. package/assets/esri/core/workers/chunks/9d7533aaeac3b8d145c4.js +0 -1
  218. package/assets/esri/core/workers/chunks/a3bb600bfcb0282622f1.js +0 -1
  219. package/assets/esri/core/workers/chunks/b50ae3dc7e43ff452568.js +0 -1
  220. package/assets/esri/core/workers/chunks/b5b7bcbc19b3430903ee.js +0 -1
  221. package/assets/esri/core/workers/chunks/b758f3c419edc2306784.js +0 -1
  222. package/assets/esri/core/workers/chunks/cf47b605c31063e88357.js +0 -1
  223. package/assets/esri/core/workers/chunks/cfbb332d144e65a4a55d.js +0 -1
  224. package/assets/esri/core/workers/chunks/db937849b2c1af87b481.js +0 -1
  225. package/assets/esri/core/workers/chunks/dc3ed59f450283d97a19.js +0 -1
  226. package/assets/esri/core/workers/chunks/dcd0653191cd4a1ccaae.js +0 -2
  227. package/assets/esri/core/workers/chunks/dfb6a28039e5d5ce6fd4.js +0 -1
  228. package/assets/esri/core/workers/chunks/e4fdd1eaf987977d0a51.js +0 -1
  229. package/assets/esri/core/workers/chunks/f7e0bb11ba3677069c94.js +0 -1
  230. package/assets/esri/core/workers/chunks/f7f3dde4c8f9c687cc1e.js +0 -1
  231. package/assets/esri/core/workers/chunks/fc6beaf9466ea3898549.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../core/Error.js";import t from"../../core/Logger.js";import{throwIfNotAbortError as r}from"../../core/promiseUtils.js";import{zoomToFeature as i,zoomToClusteredFeatures as o,browseClusteredFeatures as a,removeSelectedFeature as n}from"./actions.js";const s="esri.widgets.Popup.PopupViewModel",c=t.getLogger(s),u=t=>{const{event:s,view:c}=t,{action:u}=s,d=c&&c.popup;if(!u)return Promise.reject(new e("trigger-action:missing-arguments","Event has no action"));if(!d)return Promise.reject(new e("trigger-action:missing-arguments","view.popup is missing"));const{disabled:g,id:p}=u;if(!p)return Promise.reject(new e("trigger-action:invalid-action","action.id is missing"));if(g)return Promise.reject(new e("trigger-action:invalid-action","Action is disabled"));if(p===i.id)return l(d.viewModel).catch(r);if(p===o.id)return w(d.viewModel);if(p===a.id)return d.featureMenuOpen=!d.featureMenuOpen,d.viewModel.browseClusterEnabled=!d.viewModel.browseClusterEnabled,Promise.resolve();if(d.viewModel.browseClusterEnabled=!1,p===n.id){d.close();const{selectedFeature:t}=d;if(!t)return Promise.reject(new e(`trigger-action:${n.id}`,"selectedFeature is required",{selectedFeature:t}));const{sourceLayer:r}=t;return r?r.remove(t):c.graphics.remove(t),Promise.resolve()}return Promise.resolve()};function d(e){const{selectedFeature:t,location:r,view:i}=e;if(!i)return null;if("3d"===i.type)return t||r;return e.get("selectedFeature.geometry")||r}function g(t,r){if("3d"!==r?.type||!t||"esri.Graphic"!==t.declaredClass)return!0;const i=r.getViewForGraphic(t);if(i&&"whenGraphicBounds"in i){let r=!1;return i.whenGraphicBounds(t,{useViewElevation:!0}).then((e=>{r=!e||!e.boundingBox||e.boundingBox[0]===e.boundingBox[3]&&e.boundingBox[1]===e.boundingBox[4]&&e.boundingBox[2]===e.boundingBox[5]})).catch((()=>{const r=new e("zoom-to:invalid-graphic","Could not zoom to the location of the graphic.",{graphic:t});c.error(r)})),r}return!0}async function l(t){const{location:r,selectedFeature:o,view:a,zoomFactor:n}=t,s=d(t);if(!s){const t=new e("zoom-to:invalid-target-or-view","Cannot zoom to location without a target and view.",{target:s,view:a});throw c.error(t),t}const u=a.scale/n,l=t.get("selectedFeature.geometry")||r,w=l&&"point"===l.type&&g(o,a);i.active=!0,i.disabled=!0;try{await t.view.goTo({target:s,scale:w?u:void 0})}finally{i.active=!1,i.disabled=!1,t.zoomToLocation=null,w&&(t.location=l)}}async function w(t){const{selectedFeature:r,view:i}=t;if("2d"!==i?.type){const t=new e("zoomToCluster:invalid-view","View must be 2d MapView.",{view:i});throw c.error(t),t}if(!r.isAggregate){const t=new e("zoomToCluster:invalid-selectedFeature","Selected feature must represent an aggregate/cluster graphic.",{selectedFeature:r});throw c.error(t),t}const a=r.sourceLayer,n=await i.whenLayerView(a),s=n.createQuery();s.aggregateIds=[r.getObjectId()],o.active=!0,o.disabled=!0;const{extent:u}=await n.queryExtent(s);await i.goTo({target:u}),o.active=!1,o.disabled=!1}async function p(t){const{selectedFeature:r,view:i}=t;if("2d"!==i?.type){const t=new e("displayClusterExtent:invalid-view","View must be 2d MapView.",{view:i});throw c.error(t),t}if(!r.isAggregate){const t=new e("zoomToCluster:invalid-selectedFeature","Selected feature must represent an aggregate/cluster graphic.",{selectedFeature:r});throw c.error(t),t}const o=r.sourceLayer,a=await i.whenLayerView(o),n=a.createQuery();n.aggregateIds=[r.getObjectId()];const{extent:s}=await a.queryExtent(n);t.selectedClusterBoundaryFeature.geometry=s,i.graphics.add(t.selectedClusterBoundaryFeature)}async function v(t){const{selectedFeature:r,view:i}=t;if("2d"!==i?.type){const t=new e("browseAggregateFeatures:invalid-view","View must be 2d MapView.",{view:i});throw c.error(t),t}if(!r.isAggregate){const t=new e("browseAggregateFeatures:invalid-selectedFeature","Selected feature must represent an aggregate/cluster graphic.",{selectedFeature:r});throw c.error(t),t}const o=r.sourceLayer,n=await i.whenLayerView(o),s=n.createQuery();s.aggregateIds=[r.getObjectId()],a.active=!0,a.disabled=!0;const{features:u}=await n.queryFeatures(s);a.active=!1,a.disabled=!1,i.popup.open({features:[r].concat(u),featureMenuOpen:!0})}function f(e){e.selectedFeature?.isAggregate&&(e.features=e.features.filter((e=>e.isAggregate)))}export{v as browseAggregateFeatures,p as displayClusterExtent,d as getSelectedTarget,g as isZoomScreenSize,f as removeClusteredFeaturesForBrowsing,u as triggerAction,w as zoomToClusterExtent,l as zoomToLocation};
5
+ import e from"../../core/Error.js";import t from"../../core/Logger.js";import{throwIfNotAbortError as r}from"../../core/promiseUtils.js";import{zoomToFeature as i,zoomToClusteredFeatures as o,browseClusteredFeatures as n,removeSelectedFeature as a}from"./actions.js";const s="esri.widgets.Popup.PopupViewModel",c=t.getLogger(s),u=t=>{const{event:s,view:c}=t,{action:u}=s,d=c&&c.popup;if(!u)return Promise.reject(new e("trigger-action:missing-arguments","Event has no action"));if(!d)return Promise.reject(new e("trigger-action:missing-arguments","view.popup is missing"));const{disabled:l,id:g}=u;if(!g)return Promise.reject(new e("trigger-action:invalid-action","action.id is missing"));if(l)return Promise.reject(new e("trigger-action:invalid-action","Action is disabled"));if(g===i.id)return w(d.viewModel).catch(r);if(g===o.id)return p(d.viewModel);if(g===n.id)return d.featureMenuOpen=!d.featureMenuOpen,d.viewModel.browseClusterEnabled=!d.viewModel.browseClusterEnabled,Promise.resolve();if(d.viewModel.browseClusterEnabled=!1,g===a.id){d.close();const{selectedFeature:t}=d;if(!t)return Promise.reject(new e(`trigger-action:${a.id}`,"selectedFeature is required",{selectedFeature:t}));const{sourceLayer:r}=t;return r?r.remove(t):c.graphics.remove(t),Promise.resolve()}return Promise.resolve()};function d(e){const{selectedFeature:t,location:r,view:i}=e;if(!i)return null;if("3d"===i.type)return t||r;return e.get("selectedFeature.geometry")||r}function l(e){return e?.isAggregate&&"cluster"===e?.sourceLayer?.featureReduction?.type}function g(t,r){if("3d"!==r?.type||!t||"esri.Graphic"!==t.declaredClass)return!0;const i=r.getViewForGraphic(t);if(i&&"whenGraphicBounds"in i){let r=!1;return i.whenGraphicBounds(t,{useViewElevation:!0}).then((e=>{r=!e||!e.boundingBox||e.boundingBox[0]===e.boundingBox[3]&&e.boundingBox[1]===e.boundingBox[4]&&e.boundingBox[2]===e.boundingBox[5]})).catch((()=>{const r=new e("zoom-to:invalid-graphic","Could not zoom to the location of the graphic.",{graphic:t});c.error(r)})),r}return!0}async function w(t){const{location:r,selectedFeature:o,view:n,zoomFactor:a}=t,s=d(t);if(!s){const t=new e("zoom-to:invalid-target-or-view","Cannot zoom to location without a target and view.",{target:s,view:n});throw c.error(t),t}const u=n.scale/a,l=t.get("selectedFeature.geometry")||r,w=l&&"point"===l.type&&g(o,n);i.active=!0,i.disabled=!0;try{await t.view.goTo({target:s,scale:w?u:void 0})}finally{i.active=!1,i.disabled=!1,t.zoomToLocation=null,w&&(t.location=l)}}async function p(t){const{selectedFeature:r,view:i}=t;if("2d"!==i?.type){const t=new e("zoomToCluster:invalid-view","View must be 2d MapView.",{view:i});throw c.error(t),t}if(!l(r)){const t=new e("zoomToCluster:invalid-selectedFeature","Selected feature must represent an aggregate/cluster graphic.",{selectedFeature:r});throw c.error(t),t}const n=r.sourceLayer,a=await i.whenLayerView(n),s=a.createQuery();s.aggregateIds=[r.getObjectId()],o.active=!0,o.disabled=!0;const{extent:u}=await a.queryExtent(s);await i.goTo({target:u}),o.active=!1,o.disabled=!1}async function v(t){const{selectedFeature:r,view:i}=t;if("2d"!==i?.type){const t=new e("displayClusterExtent:invalid-view","View must be 2d MapView.",{view:i});throw c.error(t),t}if(!l(r)){const t=new e("zoomToCluster:invalid-selectedFeature","Selected feature must represent an aggregate/cluster graphic.",{selectedFeature:r});throw c.error(t),t}const o=r.sourceLayer,n=await i.whenLayerView(o),a=n.createQuery();a.aggregateIds=[r.getObjectId()];const{extent:s}=await n.queryExtent(a);t.selectedClusterBoundaryFeature.geometry=s,i.graphics.add(t.selectedClusterBoundaryFeature)}async function f(t){const{selectedFeature:r,view:i}=t;if("2d"!==i?.type){const t=new e("browseAggregateFeatures:invalid-view","View must be 2d MapView.",{view:i});throw c.error(t),t}if(!l(r)){const t=new e("browseAggregateFeatures:invalid-selectedFeature","Selected feature must represent an aggregate/cluster graphic.",{selectedFeature:r});throw c.error(t),t}const o=r.sourceLayer,a=await i.whenLayerView(o),s=a.createQuery();s.aggregateIds=[r.getObjectId()],n.active=!0,n.disabled=!0;const{features:u}=await a.queryFeatures(s);n.active=!1,n.disabled=!1,i.popup.open({features:[r].concat(u),featureMenuOpen:!0})}function m(e){l(e.selectedFeature)&&(e.features=e.features.filter((e=>l(e))))}export{f as browseAggregateFeatures,v as displayClusterExtent,d as getSelectedTarget,l as isClusterFeature,g as isZoomScreenSize,m as removeClusteredFeaturesForBrowsing,u as triggerAction,p as zoomToClusterExtent,w as zoomToLocation};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{symbolTypes as t}from"../../symbols.js";import o from"../../core/Collection.js";import"../../core/has.js";import i from"../../core/Error.js";import a from"../../core/Evented.js";import r from"../../core/Handles.js";import s from"../../core/Logger.js";import{destroyMaybe as n,isSome as p,unwrap as l,abortMaybe as h,isNone as c,unwrapOr as d,get as u}from"../../core/maybe.js";import{createAbortError as y,whenOrAbort as m}from"../../core/promiseUtils.js";import{on as v,watch as g,when as f,whenOnce as _,syncAndInitial as w}from"../../core/reactiveUtils.js";import{property as G}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/accessorSupport/ensureType.js";import{subclass as b}from"../../core/accessorSupport/decorators/subclass.js";import{canProjectWithoutEngine as T,isLoaded as E,load as O,project as S}from"../../geometry/projection.js";import{getReferenceEllipsoid as A}from"../../geometry/projectionEllipsoid.js";import{geometryToCoordinates as k}from"../../geometry/support/coordsUtils.js";import{equals as C}from"../../geometry/support/spatialReferenceUtils.js";import H from"../../layers/GraphicsLayer.js";import{isDOMContainer as I}from"../../views/DOMContainer.js";import{SupportedGraphicResult as R,isSupportedGraphicResultMessage as D}from"../../views/3d/interactive/editingTools/isSupportedGraphicUtils.js";import{isSupportedGraphic as M}from"../../views/3d/interactive/editingTools/moveGraphic/isSupportedGraphic.js";import{isSupportedGraphic as U}from"../../views/3d/interactive/editingTools/reshapeGraphic/isSupportedGraphic.js";import{isSupportedGraphic as P}from"../../views/3d/interactive/editingTools/transformGraphic/isSupportedGraphic.js";import{addUniqueLayer as x}from"../../views/draw/support/layerUtils.js";import{ViewEventPriorities as j}from"../../views/input/InputManager.js";import{SKETCH_KEYS as L}from"../../views/interactive/keybindings.js";import{SnappingManager as F}from"../../views/interactive/snapping/SnappingManager.js";import V from"../../views/interactive/snapping/SnappingOptions.js";import{TooltipOptions as W}from"../../views/interactive/tooltip/TooltipOptions.js";import{createScreenPointFromEvent as K}from"../../views/support/screenUtils.js";import{OperationHandle as q,UpdateOperationHandle as Z}from"./support/OperationHandle.js";import z from"../../symbols/SimpleMarkerSymbol.js";import N from"../../symbols/SimpleFillSymbol.js";import B from"../../symbols/SimpleLineSymbol.js";const $="esri.widgets.Sketch.SketchViewModel",Y=s.getLogger($),J={defaultZ:0},Q={reshapeOptions:{edgeOperation:"split",shapeOperation:"move",vertexOperation:"move"},enableMoveAllGraphics:!0,enableRotation:!0,enableScaling:!0,multipleSelectionEnabled:!0,preserveAspectRatio:!1,toggleToolOnClick:!0,enableZ:!0,tool:"transform"};let X=class extends a.EventedAccessor{constructor(e){super(e),this._numUpdating=0,this._handles=new r,this._internalGraphicsLayer=new H({listMode:"hide",internal:!0,title:"SVM Internal"}),this._operationHandle=null,this._viewHandles=new r,this.activeFillSymbol=null,this.activeLineSymbol=null,this.activeVertexSymbol=null,this.allowDeleteKey=!0,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 N({color:[150,150,150,.2],outline:{color:[50,50,50],width:2}}),this.polylineSymbol=new B({color:[130,130,130,1],width:2}),this._snappingManager=null,this.tooltipOptions=new W,this.updateGraphics=new o,this.updateOnGraphicClick=!0,this.updatePointSymbol=new z({size:10,color:[0,200,255,.5],outline:{color:"black",width:1}}),this.updatePolygonSymbol=new N({color:[12,207,255,.2],outline:{join:"round",color:[12,207,255],width:2}}),this.updatePolylineSymbol=new B({color:[12,207,255],width:2}),this.vertexSymbol=new z({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this._moduleLoaderAbortController=null,this._viewReadyAbortController=null,this._originalAutoOpenEnabled=null,this.defaultCreateOptions=J,this.defaultUpdateOptions=Q,this.snappingOptions=new V}initialize(){this._handles.add([v((()=>this.view?.map?.layers),"change",(e=>{e.removed.includes(this.layer)&&this.cancel()})),v((()=>this.layer?.graphics),"change",(e=>{if(p(this._operationHandle))for(const t of e.removed)this.updateGraphics.includes(t)&&(this.updateGraphics.length>1?this._operationHandle.removeFromSelection(t):this._operationHandle.cancel())})),g((()=>this.layer?.elevationInfo??null),(e=>{e!==this._internalGraphicsLayer.elevationInfo&&(this.cancel(),this._internalGraphicsLayer.elevationInfo=e)}),w),g((()=>this.view),(e=>{n(this._snappingManager),e&&(this._snappingManager=new F({view:e,options:this.snappingOptions}),"2d"===e.type?import("../../views/2d/interactive/editingTools.js"):"3d"===e.type&&(import("../../views/3d/interactive/editingTools.js"),import("../../views/3d/layers/GraphicsLayerView3D.js")))}),w),g((()=>this.view?.spatialReference),((e,t)=>{e&&t&&!e.equals(t)&&this.cancel()}))])}destroy(){this.cancel(),this._handles=n(this._handles),this._viewHandles=n(this._viewHandles),this._removeDefaultLayer(),this._snappingManager=n(this._snappingManager),this._set("view",null),this.emit("destroy")}get _defaultUpdateTool(){return"3d"===this.view.type?"move":"transform"}get updating(){return this._numUpdating>0}get activeTool(){return this._operationHandle&&this._operationHandle.tool?this._operationHandle.tool:null}get activeComponent(){return this._operationHandle?this._operationHandle.activeComponent:null}get createGraphic(){return!p(this.activeComponent)||"draw-3d"!==this.activeComponent.type&&"draw-2d"!==this.activeComponent.type?this._get("createGraphic"):l(this.activeComponent.graphic)}set defaultCreateOptions(e){this._set("defaultCreateOptions",{...J,...e})}set defaultUpdateOptions(e){this._set("defaultUpdateOptions",{...Q,...e,reshapeOptions:{...Q.reshapeOptions,...e?.reshapeOptions}})}set snappingOptions(e){p(this._snappingManager)&&(this._snappingManager.options=e),this._set("snappingOptions",e)}get state(){const e=!(!this.view?.ready||!this.layer),t=this._operationHandle;return e&&t?"active":e?"ready":"disabled"}get view(){return this._get("view")}set view(e){const t=this._get("view");if(t){const{container:e,map:o}=t;e&&(t.cursor=null),o&&o.remove(this._internalGraphicsLayer),this._viewHandles.removeAll(),this.cancel()}const o="view-ready";this._handles.remove(o),e&&this._handles.add(f((()=>e.ready),(t=>{this._viewHandles.removeAll(),t&&this._viewHandles.add(this._generateViewHandles(e))}),w),o),this._set("view",e)}cancel(){this._moduleLoaderAbortController=h(this._moduleLoaderAbortController),this._viewReadyAbortController=h(this._viewReadyAbortController),this._operationHandle&&this._operationHandle.cancel()}complete(){this._operationHandle&&this._operationHandle.complete()}delete(){const{state:e,updateGraphics:t}=this;if("active"===e&&t.length){const{activeTool:e,layer:o}=this,i=t.toArray();o.removeMany(i),this.cancel(),this._emitDeleteEvent({graphics:i,tool:e})}}async create(e,t){if(this.cancel(),await this._waitViewReady(),"disabled"===this.state)throw this.layer||this._logError("sketch:missing-property","Property 'layer' is missing on SketchViewModel."),this.view||this._logError("sketch:missing-property","Property 'view' is missing on SketchViewModel."),y();if(p(this.view.activeTool)&&(this.view.activeTool=null),!e)return void this._logError("sketch:missing-parameter","Missing parameter 'tool'.");x(this.view,this._internalGraphicsLayer);const o=await this._setupCreateOperation(e,t);if(c(o)||this.destroyed)return void this.view.map.remove(this._internalGraphicsLayer);const i=()=>{if(o===this._operationHandle){const t=this.createGraphic,i=this._operationHandle.cancelled;this._operationHandle.destroy(),this._operationHandle=null,this._set("createGraphic",null),this.view&&this.view.map&&this.view.map.remove(this._internalGraphicsLayer),o.cancelled||null==t||this.layer.add(t),this.emit("create",{graphic:t,state:i?"cancel":"complete",tool:e,toolEventInfo:null,type:"create"})}};o.on("complete",i),this._operationHandle=o,this.view.ready&&I(this.view)&&this.view.focus()}async update(e,t){this.cancel(),await this._waitViewReady();const{layer:o,view:i,state:a}=this;if("disabled"===a)throw i||this._logError("sketch:missing-property","Property 'view' is missing on SketchViewModel."),o||this._logError("sketch:missing-property","Property 'layer' is missing on SketchViewModel."),y();p(this.view.activeTool)&&(this.view.activeTool=null);const r=Array.isArray(e)?e:[e];if(null==e||!r||!r.length)return void this._logError("sketch:missing-parameter","Missing parameter 'graphics'.");if(r.some((e=>e.layer!==o?(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics missing from the supplied GraphicsLayer."),!0):!!c(e.geometry)&&(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics with an unsupported geometry."),!0))))return;const s=await this._setupUpdateOperation(r,t);this.destroyed||c(s)||re(s)||(x(this.view,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){this._beginAsyncOperation(),e=Array.isArray(e)?e:[e];for(const t of e)p(t.geometry)&&"mesh"!==t.geometry.type&&!C(t.geometry.spatialReference,this.view.spatialReference)&&(T(t.geometry.spatialReference,this.view.spatialReference)||E()||await O(),t.geometry=S(t.geometry,this.view.spatialReference));this._endAsyncOperation()}undo(){this.canUndo()&&this._operationHandle.undo()}redo(){this.canRedo()&&this._operationHandle.redo()}canUndo(){return!(!this._operationHandle||!this._operationHandle.canUndo())}canRedo(){return!(!this._operationHandle||!this._operationHandle.canRedo())}toggleUpdateTool(){this._operationHandle&&this._operationHandle.toggleTool&&this._operationHandle.toggleTool()}async _getFirstHit(e){const t=[];switch(this.view.type){case"2d":{const o=[];this.view.map.allLayers.forEach((e=>{"vector-tile"!==e.type&&"imagery"!==e.type||o.push(e)}));const i=await this.view.hitTest(e,{exclude:o});if(i.results.length>0){const e=i.results[0];e.graphic&&t.push(e)}}break;case"3d":{const o=[this.view.map.ground];this.view.map.allLayers.forEach((e=>{"integrated-mesh"===e.type&&o.push(e)}));const i=await this.view.hitTest(e,{exclude:o});if(i.results.length>0){const e=i.results[0];(!i.ground.mapPoint||this.view.map.ground.opacity<1||i.ground.distance-d(e.distance,0)>-Math.min(3*i.ground.distance,"global"===this.view.viewingMode?A(this.view.renderCoordsHelper.spatialReference).radius/this.view.renderCoordsHelper.unitInMeters:Number.POSITIVE_INFINITY))&&t.push(e)}}}return{screenPoint:e,results:t}}_generateViewHandles(e){return[e.on("immediate-click",(async t=>{const o="active"===this.state&&"create"===this._operationHandle.type;if("disabled"===this.state||o||!this.updateOnGraphicClick)return;this._beginAsyncOperation();const i=(await t.async((()=>this._getFirstHit(K(t))))).results;let a=null;if(i.length){for(const r of i)if(r.graphic){const o=r.graphic;if(this.updateGraphics.includes(o)||o.layer===this.layer){t.stopPropagation(),a=o;break}"2d"!==e.type||this._isComponentGraphic(o)||"active"!==this.state||this.cancel()}}else"active"===this.state&&this.cancel();p(a)&&!this.updateGraphics.includes(a)&&await this.update([a],{...this.defaultUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions}}),this._endAsyncOperation()}),j.WIDGET)]}async _setupCreateOperation(e,t){const o={hasZ:"3d"===this.view.type,...this.defaultCreateOptions,...t},i=await this._setupDrawGraphicTool(e,this.view,o);return c(i)?null:(this.view.tools.add(i),this.view.activeTool=i,this._setupCreateOperationHandle(i))}async _setupDrawGraphicTool(e,t,o){if("multipoint"===e&&"3d"===t.type)return this._logError("sketch:create","Multipoint geometries are not supported in SceneView"),null;const i="rectangle"!==e,a="rectangle"!==e;this.snappingOptions.enabledToggled=!1;const r={view:t,mode:"rectangle"===e||"circle"===e?"hybrid":"click",...o,snapToScene:!1,geometryType:e,graphicSymbol:this._getGraphicSymbolFromTool(e),snappingManager:this._snappingManager,forceUniformSize:a,centered:i};return"2d"===this.view.type?this._makeDrawGraphicTool2D(r):this._makeDrawGraphicTool3D(r)}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:ee(e.geometryType)?this.activeFillSymbol:null})}async _makeDrawGraphicTool3D(e){const t=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(re(t)||this.destroyed)return null;const{elevationInfo:o}=this.layer;return new t.module.DrawGraphicTool3D({...e,elevationInfo:o,snapToScene:!p(o)||"absolute-height"===o.mode,tooltipOptions:this.tooltipOptions})}_setupCreateOperationHandle(e){let t=null;const o=e.forceUniformSize,i=e.centered,a=[this.view.on("key-down",(t=>{if(t.key===L.pan)t.stopPropagation(),t.repeat||(e.enabled=!1);else if(t.key===L.complete)t.stopPropagation(),e.completeCreateOperation();else if(t.key!==L.vertexAdd||t.repeat)t.key===L.undo?(t.stopPropagation(),r.undo()):t.key===L.redo?(t.stopPropagation(),r.redo()):t.key!==L.snappingToggle||"rectangle"===e.geometryType||"circle"===e.geometryType||t.repeat?t.key!==L.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType||t.repeat?t.key===L.center&&(t.repeat||(e.centered=!i,t.stopPropagation())):(e.forceUniformSize=!o,t.stopPropagation()):(this.snappingOptions.enabledToggled=!0,t.stopPropagation());else{const o=e.drawOperation.geometryType;"polyline"!==o&&"polygon"!==o&&"multipoint"!==o||(t.stopPropagation(),e.drawOperation.commitStagedVertex())}}),j.WIDGET),this.view.on("key-up",(t=>{t.key===L.pan?e.enabled=!0:t.key===L.snappingToggle&&"rectangle"!==e.geometryType&&"circle"!==e.geometryType?(this.snappingOptions.enabledToggled=!1,t.stopPropagation()):t.key!==L.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType?t.key===L.center&&(e.centered=i,t.stopPropagation()):(e.forceUniformSize=o,t.stopPropagation())}),j.WIDGET),e.on("vertex-add",(o=>{switch(t=c(t)?"start":"active",o.operation){case"apply":this.emit("create",{graphic:l(e.graphic),state:t,tool:this.activeTool,toolEventInfo:o,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[l(e.graphic)],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[l(e.graphic)],tool:e.geometryType})}})),e.on("cursor-update",(t=>{e.drawOperation.numCommittedVertices>0&&this.emit("create",{graphic:l(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:l(e.graphic),state:"active",tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[l(e.graphic)],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[l(e.graphic)],tool:e.geometryType})}})),e.on("complete",(e=>{this._set("createGraphic",l(e.graphic)),t="complete",e.aborted?r&&r.cancel():r&&r.complete()})),g((()=>this._getGraphicSymbolFromTool(e.geometryType)),(t=>{e.graphicSymbol=t}))],r=new q({activeComponent:e,tool:e.geometryType,type:"create",onEnd:()=>{a.forEach((e=>e.remove())),a.length=0,this.view.tools?.remove(e)},undo:()=>{e.canUndo&&e.undo()},redo:()=>{e.canRedo&&e.redo()},canUndo:()=>e.canUndo,canRedo:()=>e.canRedo});return r}_getGraphicSymbolFromTool(e){switch(e){case"point":case"multipoint":return this.pointSymbol;case"polyline":return this.polylineSymbol;case"circle":case"rectangle":case"polygon":return this.polygonSymbol;default:return null}}async _setupUpdateOperation(e,t){const{layer:o,view:i}=this,a={tool:this._defaultUpdateTool,...this.defaultUpdateOptions,...t,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...t?.reshapeOptions}};let r=a.tool;for(const s of e)o.remove(s),o.add(s);if("3d"===i.type){if(0===e.length)return null;switch(r){case"move":return this._setupMove3DOperation(e,a,i,r);case"reshape":{if(e.length>1)return this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null;const t=U(e[0]);return t===R.SUPPORTED?this._setupReshape3DOperation(e[0],a,i):(this._logError("sketch:reshape",`Reshape operation not supported for provided graphic(s) (${D(t)}).`),null)}case"transform":return this._setupGraphicTransform3DOperation(e,a,i)}}switch(r){case"move":return this._setupMove2DOperation(e,a,i);case"reshape":{if(e.length>1)return this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null;const t=U(e[0]);return t===R.SUPPORTED?this._setupTransformOrReshape2DOperation(e,r,a,i):(this._logError("sketch:reshape",`Reshape operation not supported for provided graphic(s) (${D(t)}).`),null)}case"transform":if(1===e.length){const t=u(e[0].geometry,"type");"point"!==t&&"multipoint"!==t||(r="reshape")}return this._setupTransformOrReshape2DOperation(e,r,a,i)}}async _setupMove3DOperation(e,t,o,i,a=!1){for(const l of e){const e=M(l);if(e!==R.SUPPORTED)return this._logError("sketch:move",`Move operation not supported for provided graphic(s) (${D(e)}).`),null}const r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(re(r))return r;const s=new r.module.GraphicMoveTool({view:o,enableZ:t.enableZ,snappingManager:this._snappingManager});this.view.tools.add(s),s.graphics.addMany(e),a||this.updateGraphics.addMany(e);const n=[],p=new Z({activeComponent:s,tool:i,type:"update",onEnd:()=>{n.forEach((e=>e.remove())),n.length=0,this.view.tools?.remove(s),s.destroyed||s.destroy()},undo:()=>{te(p,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{oe(p,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:e=>{this.updateGraphics.push(e),s.graphics.push(e),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);p.history.undo.forEach((e=>e.updates.splice(t,1))),p.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?s.graphics.remove(e):p.complete()},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;if("transform"!==i)return;const e=this.updateGraphics.getItemAt(0);if(U(e)!==R.SUPPORTED)return;const a=await this._setupReshape3DOperation(e,t,o,!0);re(a)||(p.onEnd(),p.destroy(),this._setUpdateOperationHandle(a,t))}});return n.push(...this._getHandlesForComponent(p,t),this.view.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(p,e,t)),j.WIDGET),o.on("key-down",(e=>{this._getCommonUpdateOperationKeyDownHandlers(p,e),e.key===L.snappingToggle&&(this.snappingOptions.enabledToggled=!0,e.stopPropagation())}),j.WIDGET),o.on("key-up",(e=>{e.key===L.snappingToggle&&(this.snappingOptions.enabledToggled=!1,e.stopPropagation())}),j.WIDGET)),p}_setupGraphicTransform3DOperation(e,t,o,i=!1){if(1===e.length&&P(e[0])===R.SUPPORTED){const a=e[0],r=a.geometry;if(p(r)&&("point"===r.type||"mesh"===r.type))return this._setupPointTransform3DOperation(a,t,o);if(p(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 p=new n.module.GraphicTransformTool({graphic:e,view:o,enableRotation:a,enableScaling:r,enableZ:s,snappingManager:this._snappingManager});this.view.tools.add(p),this.updateGraphics.add(e);const l=[],h=new Z({activeComponent:p,tool:i,type:"update",onEnd:()=>{l.forEach((e=>e.remove())),l.length=0,this.view.tools?.remove(p),p.destroyed||p.destroy()},undo:()=>{te(h,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{oe(h,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"});const i=await this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0);re(i)||(h.onEnd(),h.destroy(),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"}),h.complete()},toggleTool:()=>{}});return l.push(...this._getHandlesForComponent(h,t),this.view.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(h,e,t)),j.WIDGET),o.on("key-down",(e=>{this._getCommonUpdateOperationKeyDownHandlers(h,e),e.key===L.snappingToggle&&(this.snappingOptions.enabledToggled=!0,e.stopPropagation())}),j.WIDGET),o.on("key-up",(e=>{e.key===L.snappingToggle&&(this.snappingOptions.enabledToggled=!1,e.stopPropagation())}),j.WIDGET)),h}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 h=new l.module.ExtentTransformTool({graphic:e,view:o,enableRotation:r,enableScaling:s,enableZ:n,preserveAspectRatio:p});this.view.tools.add(h),i||this.updateGraphics.add(e);const c=[],d=new Z({activeComponent:h,tool:a,type:"update",onEnd:()=>{c.forEach((e=>e.remove())),c.length=0,this.view.tools?.remove(h),h.destroyed||h.destroy()},canUndo:()=>h.canUndo,undo:()=>{h.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a})},canRedo:()=>h.canRedo,redo:()=>{h.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"});const i=await this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0);re(i)||(d.onEnd(),d.destroy(),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"}),d.complete()},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;const e=this.updateGraphics.getItemAt(0);if(U(e)!==R.SUPPORTED)return;const i=await this._setupReshape3DOperation(e,t,o,!0);re(i)||(d.onEnd(),d.destroy(),this._setUpdateOperationHandle(i,t))}});return c.push(...this._getHandlesForComponent(d,t),this.view.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(d,e,t)),j.WIDGET),this.view.on("key-down",(e=>this._getCommonUpdateOperationKeyDownHandlers(d,e)),j.WIDGET),this.view.on("key-down",(e=>{e.key!==L.constraint||e.repeat||(h.preserveAspectRatio=!h.preserveAspectRatio,e.stopPropagation())}),j.WIDGET),this.view.on("key-up",(e=>{e.key===L.constraint&&(h.preserveAspectRatio=!h.preserveAspectRatio,e.stopPropagation())}),j.WIDGET)),d}async _setupMove2DOperation(e,t,o){const i="move";this.updateGraphics.addMany(e),await this._updateSpatialReference(e);const a=await this._getGraphicMover(e,t,o);if(re(a))return a;const r=new Z({activeComponent:a,tool:i,type:"update",onEnd:()=>{this._displayDefaultCursor(),p.forEach((e=>e.remove())),n.forEach((e=>e.remove())),p=[],n=[],a.destroy(),this._internalGraphicsLayer?.removeMany([...this.updateGraphics.toArray()])},undo:()=>{const e=this.updateGraphics.toArray();te(r,e),r.refreshComponent(),this._emitUndoEvent({graphics:e,tool:i})},redo:()=>{const e=this.updateGraphics.toArray();oe(r,e),r.refreshComponent(),this._emitRedoEvent({graphics:e,tool:i})},addToSelection:async e=>{await 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,n=[o.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(r,e,t)),j.WIDGET),o.on("key-down",(e=>{this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key!==L.constraint||e.repeat||(s=!0,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)}),j.WIDGET),o.on("key-up",(e=>{e.key===L.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;this.snappingOptions.enabledToggled=!1;const s=new r.module.GraphicReshapeTool({view:o,graphic:e,enableZVertex:t.enableZ&&"move"===t.reshapeOptions.vertexOperation,enableZShape:t.enableZ&&"move"===t.reshapeOptions.shapeOperation,enableMoveGraphic:"move"===t.reshapeOptions.shapeOperation||"move-xy"===t.reshapeOptions.shapeOperation,enableMidpoints:"split"===t.reshapeOptions.edgeOperation,enableEdgeOffset:"offset"===t.reshapeOptions.edgeOperation,snappingManager:this._snappingManager,tooltipOptions:this.tooltipOptions});o.tools.add(s),i||this.updateGraphics.add(e);const n=[],p=new Z({activeComponent:s,tool:a,type:"update",onEnd:()=>{n.forEach((e=>e.remove())),n.length=0,this.view.tools?.remove(s),s.destroyed||s.destroy()},canUndo:()=>s.canUndo,undo:()=>{s.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a})},canRedo:()=>s.canRedo,redo:()=>{s.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"});const i=await this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0);re(i)||(p.onEnd(),p.destroy(),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"}),p.complete()},toggleTool:async()=>{if(!1===t.toggleToolOnClick)return;const e=await this._setupGraphicTransform3DOperation(this.updateGraphics.toArray(),t,o,!0);re(e)||(p.onEnd(),p.destroy(),this._setUpdateOperationHandle(e,t))}});return n.push(...this._getHandlesForComponent(p,t),o.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(p,e,t)),j.WIDGET),o.on("key-down",(e=>{this._getCommonUpdateOperationKeyDownHandlers(p,e),e.key===L.snappingToggle&&(this.snappingOptions.enabledToggled=!0,e.stopPropagation())}),j.WIDGET),o.on("key-up",(e=>{e.key===L.snappingToggle&&(this.snappingOptions.enabledToggled=!1,e.stopPropagation())}),j.WIDGET)),p}async _setupTransformOrReshape2DOperation(e,t,o,i){this.updateGraphics.addMany(e),await this._updateSpatialReference(e);const a="transform"===t?await this._getBox(e,o,i):await this._getReshape(e,o,i);if(re(a))return a;const r=new Z({activeComponent:a,type:"update",onEnd:()=>{n.forEach((e=>e.remove())),s.forEach((e=>e.remove())),n=[],s=[],r.activeComponent&&!r.activeComponent.destroyed&&r.activeComponent.destroy(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray())},undo:()=>{te(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},redo:()=>{oe(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();const a=await this._setupMove2DOperation(t,o,i);if(re(a))return;r.onEnd(),r.destroy(),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:async 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();if(0===o.length)r.complete();else{const e=o[0].geometry;1!==o.length||!p(e)||"point"!==e.type&&"multipoint"!==e.type?r.activeComponent.graphics=o:r.toggleTool()}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.getItemAt(0),t=e.geometry;if(p(t)&&("reshape"===r.tool&&("point"===t.type||"multipoint"===t.type)||"transform"===r.tool&&"extent"===t.type))return;let a=null;"transform"===r.tool?a=await this._getReshape([e],o,i):"reshape"===r.tool&&(a=await this._getBox([e],o,i)),re(a)||(r.activeComponent.destroy(),r.activeComponent=a,r.activeComponent&&(n.forEach((e=>e.remove())),n=this._getHandlesForComponent(r,o)))}});let 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!==L.snappingToggle||e.repeat||(this.snappingOptions.enabledToggled=!0,e.stopPropagation()),e.key===L.constraint&&!e.repeat&&r){const e=r.activeComponent;e&&"box"===e.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}}),j.WIDGET),i.on("key-up",(e=>{if(e.key===L.snappingToggle&&"reshape"===r?.activeComponent?.type&&(this.snappingOptions.enabledToggled=!1,e.stopPropagation()),e.key===L.constraint&&r){const e=r.activeComponent;e&&"box"===e.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}}),j.WIDGET)],n=this._getHandlesForComponent(r,o);return r}async _getGraphicMover(e,t,o){const{enableMoveAllGraphics:i}=t,a=await this._requireModule(import("../../views/draw/support/GraphicMover.js"));return re(a)?a:new a.module.default({enableMoveAllGraphics:i,highlightsEnabled:!0,indicatorsEnabled:!1,graphics:e,view:o,callbacks:{onGraphicMoveStart:({dx:e,dy:t,graphic:o})=>{this._displayGrabbingCursor(),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._displayPointerCursor(),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._displayPointerCursor(),onGraphicPointerOut:()=>this._displayDefaultCursor()}})}async _getBox(e,t,o){const{enableRotation:i,enableScaling:a,preserveAspectRatio:r}=t,s=await this._requireModule(import("../../views/draw/support/Box.js"));return re(s)?s:new s.module.default({graphics:e,enableRotation:i,enableScaling:a,preserveAspectRatio:r,layer:this._internalGraphicsLayer,view:o,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"})}})}async _getReshape(e,t,o){const i="split"===t.reshapeOptions?.edgeOperation,a="move"===t.reshapeOptions?.shapeOperation,r=await this._requireModule(import("../../views/draw/support/Reshape.js"));return re(r)?r:new r.module.default({enableMidpoints:i,enableMovement:a,graphic:e[0],layer:this._internalGraphicsLayer,snappingManager:this._snappingManager,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=>k(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=>k(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;switch(o.type){case"graphic-mover":return[o.on("graphic-click",(({graphic:t,viewEvent:o})=>{o.native?.shiftKey&&(o.stopPropagation(),e.removeFromSelection(t))})),o.on("graphic-move-start",(t=>e.addToHistory(ae(t.allGraphics))))];case"box":return[o.on("graphic-click",(o=>this._onTransformOrReshape2DGraphicClick(e,t,o))),o.on("move-start",(t=>e.addToHistory(ae(t.graphics)))),o.on("rotate-start",(t=>e.addToHistory(ae(t.graphics)))),o.on("scale-start",(t=>e.addToHistory(ae(t.graphics))))];case"reshape":return[o.on("graphic-click",(o=>this._onTransformOrReshape2DGraphicClick(e,t,o))),o.on("move-start",(t=>e.addToHistory(ae([t.mover])))),o.on("reshape-start",(t=>e.addToHistory(ae([t.graphic])))),o.on("vertex-add",(t=>e.addToHistory(ae([t.oldGraphic])))),o.on("vertex-remove",(t=>e.addToHistory(ae([t.oldGraphic]))))];case"move-3d":return[o.on("graphic-move-start",(t=>{e.addToHistory(ae(t.allGraphics)),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:t.allGraphics.length>0?t.allGraphics[0]:null,type:"move-start"},type:"update"})})),o.on("graphic-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.allGraphics.length>0?e.allGraphics[0]:null,type:"move"},type:"update"})})),o.on("graphic-move-stop",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:e.allGraphics.length>0?e.allGraphics[0]:null,type:"move-stop"},type:"update"})})),o.on("immediate-click",(o=>{o.shiftKey?this._toggleSelection([o.graphic],e,t):e.toggleTool()}))];case"transform-3d":return[o.on("record-undo",(({record:t})=>{e.addToHistory({updates:[t]})})),o.on("graphic-translate-start",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-start"},type:"update"})})),o.on("graphic-translate-stop",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-stop"},type:"update"})})),o.on("graphic-rotate-start",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,angle:e.angle,type:"rotate-start"},type:"update"})})),o.on("graphic-rotate-stop",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,angle:e.angle,type:"rotate-stop"},type:"update"})})),o.on("graphic-scale-start",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-start"},type:"update"})})),o.on("graphic-scale-stop",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-stop"},type:"update"})})),o.on("graphic-translate",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move"},type:"update"})})),o.on("graphic-rotate",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,angle:e.angle,type:"rotate"},type:"update"})})),o.on("graphic-scale",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale"},type:"update"})})),o.on("immediate-click",(o=>{o.shiftKey?this._toggleSelection([o.graphic],e,t):e.toggleTool()}))];case"reshape-3d":return[o.on("reshape",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})})),o.on("move",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})})),o.on("vertex-add",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})})),o.on("vertex-remove",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})})),o.on("immediate-click",(o=>{o.shiftKey?this._toggleSelection([o.graphic],e,t):e.toggleTool()}))];default:return}}_onTransformOrReshape2DGraphicClick(e,t,o){const{graphic:i,viewEvent:a}=o;return a.native?.shiftKey&&i.layer===this.layer?(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=K(t),a=(await t.async((()=>this._getFirstHit(i)))).results;if(!a.length)return void e.complete();if(t.native.shiftKey&&this._toggleSelection(a.map((e=>e.graphic)),e,o))return void t.stopPropagation();a.some((e=>e.graphic&&this.updateGraphics.includes(e.graphic)))?t.stopPropagation():e.complete()}_toggleSelection(e,t,o){const i=!!o.multipleSelectionEnabled;return e.some((e=>null!=e&&(!(!i||e.layer!==this.layer)&&(this.updateGraphics.includes(e)?t.removeFromSelection(e):t.addToSelection(e),!0))))}_getCommonUpdateOperationKeyDownHandlers(e,t){if(!e)return;const o=t.key;o===L.undo&&e.canUndo()?(t.stopPropagation(),e.undo()):o===L.redo&&e.canRedo()?(t.stopPropagation(),e.redo()):o===L.cancel?(t.stopPropagation(),e.cancel()):this.allowDeleteKey&&L.delete.includes(o)&&this._onDeleteKey(t)}_onDeleteKey(e){if(!this._operationHandle||"update"!==this._operationHandle.type)return;const t=this.activeComponent,o=this.updateGraphics.toArray();c(t)||"reshape-3d"===t.type||("reshape"!==t.type||1===o.length&&"point"===u(o[0].geometry,"type"))&&(e.stopPropagation(),this.delete())}_removeDefaultLayer(){this._internalGraphicsLayer&&(this.view&&this.view.map&&this.view.map.remove(this._internalGraphicsLayer),this._internalGraphicsLayer=n(this._internalGraphicsLayer))}_isComponentGraphic(e){const{activeComponent:t}=this;return!(!e||c(t))&&(e.attributes&&e.attributes.esriSketchTool||"draw-2d"===t.type&&t.graphic===e||("box"===t.type||"reshape"===t.type)&&t.isUIGraphic(e))}_displayPointerCursor(){this.view&&this.view.container&&"pointer"!==this.view.cursor&&(this.view.cursor="pointer")}_displayGrabbingCursor(){this.view&&this.view.container&&"grabbing"!==this.view.cursor&&(this.view.cursor="grabbing")}_displayDefaultCursor(){this.view&&this.view.container&&null!==this.view.cursor&&(this.view.cursor=null)}_logError(e,t,o){Y.error(new i(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"})}test(){return{operationHandle:this._operationHandle,defaultUpdateOptions:Q}}wait(){return _((()=>!this.updating))}_beginAsyncOperation(){this._numUpdating+=1,this.notifyChange("updating")}_endAsyncOperation(){this._numUpdating-=1,this.notifyChange("updating")}_disablePopupEnabled(e){return"3d"!==this.view?.type||this.updateOnGraphicClick||p(e)&&e.toggleToolOnClick}_disablePopup(e){if(!this._disablePopupEnabled(e))return;const t=this.view.popup;t&&c(this._originalAutoOpenEnabled)&&(this._originalAutoOpenEnabled=t.autoOpenEnabled,t.autoOpenEnabled=!1)}_restorePopup(e){if(!this._disablePopupEnabled(e))return;const t=this.view.popup;t&&p(this._originalAutoOpenEnabled)&&(t.autoOpenEnabled=this._originalAutoOpenEnabled,this._originalAutoOpenEnabled=null)}async _waitViewReady(){const e=this.view;e&&(h(this._viewReadyAbortController),this._viewReadyAbortController=new AbortController,await m(_((()=>e?.ready)),this._viewReadyAbortController.signal))}};function ee(e){return"polygon"===e||"rectangle"===e||"circle"===e}function te(e,t){ie("undo",e.history.undo,e.history.redo,t)}function oe(e,t){ie("redo",e.history.redo,e.history.undo,t)}function ie(e,t,o,i){const a=t.pop().updates,r=[];i.forEach(((t,o)=>{const i=a[o];null!=i&&("geometry"in i&&p(i.geometry)&&(r.push({geometry:t.geometry}),t.geometry=i.geometry),"symbol"in i&&p(i.symbol)&&(r.push({symbol:t.symbol}),t.symbol=i.symbol),"undo"in i&&(r.push(i),i[e](t)))})),o.push({updates:r})}function ae(e){return{updates:e.map((e=>({geometry:e.geometry})))}}function re(e){return"requireError"in e&&"aborted"===e.requireError}e([G()],X.prototype,"updating",null),e([G()],X.prototype,"_operationHandle",void 0),e([G({readOnly:!0})],X.prototype,"activeTool",null),e([G()],X.prototype,"activeFillSymbol",void 0),e([G()],X.prototype,"activeLineSymbol",void 0),e([G()],X.prototype,"activeVertexSymbol",void 0),e([G()],X.prototype,"allowDeleteKey",void 0),e([G({readOnly:!0})],X.prototype,"createGraphic",null),e([G()],X.prototype,"defaultCreateOptions",null),e([G()],X.prototype,"defaultUpdateOptions",null),e([G()],X.prototype,"layer",void 0),e([G({types:t})],X.prototype,"pointSymbol",void 0),e([G({types:t})],X.prototype,"polygonSymbol",void 0),e([G({types:t})],X.prototype,"polylineSymbol",void 0),e([G({type:V,nonNullable:!0})],X.prototype,"snappingOptions",null),e([G()],X.prototype,"_snappingManager",void 0),e([G({readOnly:!0})],X.prototype,"state",null),e([G({type:W,nonNullable:!0})],X.prototype,"tooltipOptions",void 0),e([G({readOnly:!0})],X.prototype,"updateGraphics",void 0),e([G()],X.prototype,"updateOnGraphicClick",void 0),e([G({types:t})],X.prototype,"updatePointSymbol",void 0),e([G({types:t})],X.prototype,"updatePolygonSymbol",void 0),e([G({types:t})],X.prototype,"updatePolylineSymbol",void 0),e([G({types:t})],X.prototype,"vertexSymbol",void 0),e([G({value:null})],X.prototype,"view",null),X=e([b($)],X);const se=X;export{se as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{symbolTypes as t}from"../../symbols.js";import o from"../../core/Collection.js";import"../../core/has.js";import i from"../../core/Error.js";import a from"../../core/Evented.js";import r from"../../core/Handles.js";import s from"../../core/Logger.js";import{destroyMaybe as n,isSome as p,unwrap as l,abortMaybe as h,isNone as c,unwrapOr as d,get as u}from"../../core/maybe.js";import{createAbortError as y,whenOrAbort as m}from"../../core/promiseUtils.js";import{on as g,watch as v,when as f,whenOnce as _,syncAndInitial as w}from"../../core/reactiveUtils.js";import{property as G}from"../../core/accessorSupport/decorators/property.js";import"../../core/arrayUtils.js";import"../../core/accessorSupport/ensureType.js";import{subclass as b}from"../../core/accessorSupport/decorators/subclass.js";import{canProjectWithoutEngine as T,isLoaded as E,load as O,project as S}from"../../geometry/projection.js";import{getReferenceEllipsoid as A}from"../../geometry/projectionEllipsoid.js";import{geometryToCoordinates as C}from"../../geometry/support/coordsUtils.js";import{equals as k}from"../../geometry/support/spatialReferenceUtils.js";import H from"../../layers/GraphicsLayer.js";import{isDOMContainer as I}from"../../views/DOMContainer.js";import{SupportedGraphicResult as R,isSupportedGraphicResultMessage as D}from"../../views/3d/interactive/editingTools/isSupportedGraphicUtils.js";import{isSupportedGraphic as M}from"../../views/3d/interactive/editingTools/moveGraphic/isSupportedGraphic.js";import{isSupportedGraphic as U}from"../../views/3d/interactive/editingTools/reshapeGraphic/isSupportedGraphic.js";import{isSupportedGraphic as P}from"../../views/3d/interactive/editingTools/transformGraphic/isSupportedGraphic.js";import{addUniqueLayer as x}from"../../views/draw/support/layerUtils.js";import{ViewEventPriorities as j}from"../../views/input/InputManager.js";import{SKETCH_KEYS as L}from"../../views/interactive/keybindings.js";import{SnappingManager as F}from"../../views/interactive/snapping/SnappingManager.js";import V from"../../views/interactive/snapping/SnappingOptions.js";import{TooltipOptions as W}from"../../views/interactive/tooltip/TooltipOptions.js";import{createScreenPointFromEvent as K}from"../../views/support/screenUtils.js";import{OperationHandle as q,UpdateOperationHandle as Z}from"./support/OperationHandle.js";import z from"../../symbols/SimpleMarkerSymbol.js";import N from"../../symbols/SimpleFillSymbol.js";import B from"../../symbols/SimpleLineSymbol.js";const $="esri.widgets.Sketch.SketchViewModel",Y=s.getLogger($),J={defaultZ:0},Q={reshapeOptions:{edgeOperation:"split",shapeOperation:"move",vertexOperation:"move"},enableMoveAllGraphics:!0,enableRotation:!0,enableScaling:!0,multipleSelectionEnabled:!0,preserveAspectRatio:!1,toggleToolOnClick:!0,enableZ:!0,tool:"transform"};let X=class extends a.EventedAccessor{constructor(e){super(e),this._numUpdating=0,this._handles=new r,this._internalGraphicsLayer=new H({listMode:"hide",internal:!0,title:"SVM Internal"}),this._operationHandle=null,this._viewHandles=new r,this.activeFillSymbol=null,this.activeLineSymbol=null,this.activeVertexSymbol=null,this.allowDeleteKey=!0,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 N({color:[150,150,150,.2],outline:{color:[50,50,50],width:2}}),this.polylineSymbol=new B({color:[130,130,130,1],width:2}),this._snappingManager=null,this.tooltipOptions=new W,this.updateGraphics=new o,this.updateOnGraphicClick=!0,this.updatePointSymbol=new z({size:10,color:[0,200,255,.5],outline:{color:"black",width:1}}),this.updatePolygonSymbol=new N({color:[12,207,255,.2],outline:{join:"round",color:[12,207,255],width:2}}),this.updatePolylineSymbol=new B({color:[12,207,255],width:2}),this.vertexSymbol=new z({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this._moduleLoaderAbortController=null,this._viewReadyAbortController=null,this._originalAutoOpenEnabled=null,this.defaultCreateOptions=J,this.defaultUpdateOptions=Q,this.snappingOptions=new V}initialize(){this._handles.add([g((()=>this.view?.map?.layers),"change",(e=>{e.removed.includes(this.layer)&&this.cancel()})),g((()=>this.layer?.graphics),"change",(e=>{if(p(this._operationHandle))for(const t of e.removed)this.updateGraphics.includes(t)&&(this.updateGraphics.length>1?this._operationHandle.removeFromSelection(t):this._operationHandle.cancel())})),v((()=>this.layer?.elevationInfo??null),(e=>{e!==this._internalGraphicsLayer.elevationInfo&&(this.cancel(),this._internalGraphicsLayer.elevationInfo=e)}),w),v((()=>this.view),(e=>{n(this._snappingManager),e&&(this._snappingManager=new F({view:e,options:this.snappingOptions}),"2d"===e.type?import("../../views/2d/interactive/editingTools.js"):"3d"===e.type&&(import("../../views/3d/interactive/editingTools.js"),import("../../views/3d/layers/GraphicsLayerView3D.js")))}),w),v((()=>this.view?.spatialReference),((e,t)=>{e&&t&&!e.equals(t)&&this.cancel()}))])}destroy(){this.cancel(),this._handles=n(this._handles),this._viewHandles=n(this._viewHandles),this._removeDefaultLayer(),this._snappingManager=n(this._snappingManager),this._set("view",null),this.emit("destroy")}get _defaultUpdateTool(){return"3d"===this.view.type?"move":"transform"}get updating(){return this._numUpdating>0}get activeTool(){return this._operationHandle&&this._operationHandle.tool?this._operationHandle.tool:null}get activeComponent(){return this._operationHandle?this._operationHandle.activeComponent:null}get createGraphic(){return!p(this.activeComponent)||"draw-3d"!==this.activeComponent.type&&"draw-2d"!==this.activeComponent.type?this._get("createGraphic"):l(this.activeComponent.graphic)}set defaultCreateOptions(e){this._set("defaultCreateOptions",{...J,...e})}set defaultUpdateOptions(e){this._set("defaultUpdateOptions",{...Q,...e,reshapeOptions:{...Q.reshapeOptions,...e?.reshapeOptions}})}set snappingOptions(e){p(this._snappingManager)&&(this._snappingManager.options=e),this._set("snappingOptions",e)}get state(){const e=!(!this.view?.ready||!this.layer),t=this._operationHandle;return e&&t?"active":e?"ready":"disabled"}get view(){return this._get("view")}set view(e){const t=this._get("view");if(t){const{container:e,map:o}=t;e&&(t.cursor=null),o&&o.remove(this._internalGraphicsLayer),this._viewHandles.removeAll(),this.cancel()}const o="view-ready";this._handles.remove(o),e&&this._handles.add(f((()=>e.ready),(t=>{this._viewHandles.removeAll(),t&&this._viewHandles.add(this._generateViewHandles(e))}),w),o),this._set("view",e)}cancel(){this._moduleLoaderAbortController=h(this._moduleLoaderAbortController),this._viewReadyAbortController=h(this._viewReadyAbortController),this._operationHandle&&this._operationHandle.cancel()}complete(){this._operationHandle&&this._operationHandle.complete()}delete(){const{state:e,updateGraphics:t}=this;if("active"===e&&t.length){const{activeTool:e,layer:o}=this,i=t.toArray();o.removeMany(i),this.cancel(),this._emitDeleteEvent({graphics:i,tool:e})}}async create(e,t){if(this.cancel(),await this._waitViewReady(),"disabled"===this.state)throw this.layer||this._logError("sketch:missing-property","Property 'layer' is missing on SketchViewModel."),this.view||this._logError("sketch:missing-property","Property 'view' is missing on SketchViewModel."),y();if(p(this.view.activeTool)&&(this.view.activeTool=null),!e)return void this._logError("sketch:missing-parameter","Missing parameter 'tool'.");x(this.view,this._internalGraphicsLayer);const o=await this._setupCreateOperation(e,t);if(c(o)||this.destroyed)return void this.view.map.remove(this._internalGraphicsLayer);const i=()=>{if(o===this._operationHandle){const t=this.createGraphic,i=this._operationHandle.cancelled;this._operationHandle.destroy(),this._operationHandle=null,this._set("createGraphic",null),this.view&&this.view.map&&this.view.map.remove(this._internalGraphicsLayer),o.cancelled||null==t||this.layer.add(t),this.emit("create",{graphic:t,state:i?"cancel":"complete",tool:e,toolEventInfo:null,type:"create"})}};o.on("complete",i),this._operationHandle=o,this.view.ready&&I(this.view)&&this.view.focus()}async update(e,t){this.cancel(),await this._waitViewReady();const{layer:o,view:i,state:a}=this;if("disabled"===a)throw i||this._logError("sketch:missing-property","Property 'view' is missing on SketchViewModel."),o||this._logError("sketch:missing-property","Property 'layer' is missing on SketchViewModel."),y();p(this.view.activeTool)&&(this.view.activeTool=null);const r=Array.isArray(e)?e:[e];if(null==e||!r||!r.length)return void this._logError("sketch:missing-parameter","Missing parameter 'graphics'.");if(r.some((e=>e.layer!==o?(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics missing from the supplied GraphicsLayer."),!0):!!c(e.geometry)&&(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics with an unsupported geometry."),!0))))return;const s=await this._setupUpdateOperation(r,t);this.destroyed||c(s)||re(s)||(x(this.view,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){this._beginAsyncOperation(),e=Array.isArray(e)?e:[e];for(const t of e)p(t.geometry)&&"mesh"!==t.geometry.type&&!k(t.geometry.spatialReference,this.view.spatialReference)&&(T(t.geometry.spatialReference,this.view.spatialReference)||E()||await O(),t.geometry=S(t.geometry,this.view.spatialReference));this._endAsyncOperation()}undo(){this.canUndo()&&this._operationHandle.undo()}redo(){this.canRedo()&&this._operationHandle.redo()}canUndo(){return!(!this._operationHandle||!this._operationHandle.canUndo())}canRedo(){return!(!this._operationHandle||!this._operationHandle.canRedo())}toggleUpdateTool(){this._operationHandle&&this._operationHandle.toggleTool&&this._operationHandle.toggleTool()}async _getFirstHit(e){const t=this.view;if("2d"===t.type){const t=[];this.view.map.allLayers.forEach((e=>{"vector-tile"!==e.type&&"imagery"!==e.type||t.push(e)}));return(await this.view.hitTest(e,{exclude:t})).results.find((e=>null!=e.graphic))??null}const o=[this.view.map.ground];t.map.allLayers.forEach((e=>{"integrated-mesh"===e.type&&o.push(e)}));const i=await t.hitTest(e,{exclude:o});if(i.results.length>0){const e=i.results[0];if(e.graphic&&(!i.ground.mapPoint||t.map.ground.opacity<1||i.ground.distance-d(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 t=>{const o="active"===this.state&&"create"===this._operationHandle.type;if("disabled"===this.state||o||!this.updateOnGraphicClick)return;this._beginAsyncOperation();const i=await t.async((()=>this._getFirstHit(K(t))));let a=null;if(i){const o=i.graphic;this.updateGraphics.includes(o)||o.layer===this.layer?(t.stopPropagation(),a=o):"2d"!==e.type||this._isComponentGraphic(o)||"active"!==this.state||this.cancel()}else"active"===this.state&&this.cancel();p(a)&&!this.updateGraphics.includes(a)&&await this.update([a],{...this.defaultUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions}}),this._endAsyncOperation()}),j.WIDGET)]}async _setupCreateOperation(e,t){const o={hasZ:"3d"===this.view.type,...this.defaultCreateOptions,...t},i=await this._setupDrawGraphicTool(e,this.view,o);return c(i)?null:(this.view.tools.add(i),this.view.activeTool=i,this._setupCreateOperationHandle(i))}async _setupDrawGraphicTool(e,t,o){if("multipoint"===e&&"3d"===t.type)return this._logError("sketch:create","Multipoint geometries are not supported in SceneView"),null;const i="rectangle"!==e,a="rectangle"!==e;this.snappingOptions.enabledToggled=!1;const r={view:t,mode:"rectangle"===e||"circle"===e?"hybrid":"click",...o,snapToScene:!1,geometryType:e,graphicSymbol:this._getGraphicSymbolFromTool(e),snappingManager:this._snappingManager,forceUniformSize:a,centered:i};return"2d"===this.view.type?this._makeDrawGraphicTool2D(r):this._makeDrawGraphicTool3D(r)}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:ee(e.geometryType)?this.activeFillSymbol:null})}async _makeDrawGraphicTool3D(e){const t=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(re(t)||this.destroyed)return null;const{elevationInfo:o}=this.layer;return new t.module.DrawGraphicTool3D({...e,elevationInfo:o,snapToScene:!p(o)||"absolute-height"===o.mode,tooltipOptions:this.tooltipOptions})}_setupCreateOperationHandle(e){let t=null;const o=e.forceUniformSize,i=e.centered,a=[this.view.on("key-down",(t=>{if(t.key===L.pan)t.stopPropagation(),t.repeat||(e.enabled=!1);else if(t.key===L.complete)t.stopPropagation(),e.completeCreateOperation();else if(t.key!==L.vertexAdd||t.repeat)t.key===L.undo?(t.stopPropagation(),r.undo()):t.key===L.redo?(t.stopPropagation(),r.redo()):t.key!==L.snappingToggle||"rectangle"===e.geometryType||"circle"===e.geometryType||t.repeat?t.key!==L.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType||t.repeat?t.key===L.center&&(t.repeat||(e.centered=!i,t.stopPropagation())):(e.forceUniformSize=!o,t.stopPropagation()):(this.snappingOptions.enabledToggled=!0,t.stopPropagation());else{const o=e.drawOperation.geometryType;"polyline"!==o&&"polygon"!==o&&"multipoint"!==o||(t.stopPropagation(),e.drawOperation.commitStagedVertex())}}),j.WIDGET),this.view.on("key-up",(t=>{t.key===L.pan?e.enabled=!0:t.key===L.snappingToggle&&"rectangle"!==e.geometryType&&"circle"!==e.geometryType?(this.snappingOptions.enabledToggled=!1,t.stopPropagation()):t.key!==L.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType?t.key===L.center&&(e.centered=i,t.stopPropagation()):(e.forceUniformSize=o,t.stopPropagation())}),j.WIDGET),e.on("vertex-add",(o=>{switch(t=c(t)?"start":"active",o.operation){case"apply":this.emit("create",{graphic:l(e.graphic),state:t,tool:this.activeTool,toolEventInfo:o,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[l(e.graphic)],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[l(e.graphic)],tool:e.geometryType})}})),e.on("cursor-update",(t=>{e.drawOperation.numCommittedVertices>0&&this.emit("create",{graphic:l(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:l(e.graphic),state:"active",tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[l(e.graphic)],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[l(e.graphic)],tool:e.geometryType})}})),e.on("complete",(e=>{this._set("createGraphic",l(e.graphic)),t="complete",e.aborted?r&&r.cancel():r&&r.complete()})),v((()=>this._getGraphicSymbolFromTool(e.geometryType)),(t=>{e.graphicSymbol=t}))],r=new q({activeComponent:e,tool:e.geometryType,type:"create",onEnd:()=>{a.forEach((e=>e.remove())),a.length=0,this.view.tools?.remove(e)},undo:()=>{e.canUndo&&e.undo()},redo:()=>{e.canRedo&&e.redo()},canUndo:()=>e.canUndo,canRedo:()=>e.canRedo});return r}_getGraphicSymbolFromTool(e){switch(e){case"point":case"multipoint":return this.pointSymbol;case"polyline":return this.polylineSymbol;case"circle":case"rectangle":case"polygon":return this.polygonSymbol;default:return null}}async _setupUpdateOperation(e,t){const{layer:o,view:i}=this,a={tool:this._defaultUpdateTool,...this.defaultUpdateOptions,...t,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...t?.reshapeOptions}};let r=a.tool;for(const s of e)o.remove(s),o.add(s);if("3d"===i.type){if(0===e.length)return null;switch(r){case"move":return this._setupMove3DOperation(e,a,i,r);case"reshape":{if(e.length>1)return this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null;const t=U(e[0]);return t===R.SUPPORTED?this._setupReshape3DOperation(e[0],a,i):(this._logError("sketch:reshape",`Reshape operation not supported for provided graphic(s) (${D(t)}).`),null)}case"transform":return this._setupGraphicTransform3DOperation(e,a,i)}}switch(r){case"move":return this._setupMove2DOperation(e,a,i);case"reshape":{if(e.length>1)return this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null;const t=U(e[0]);return t===R.SUPPORTED?this._setupTransformOrReshape2DOperation(e,r,a,i):(this._logError("sketch:reshape",`Reshape operation not supported for provided graphic(s) (${D(t)}).`),null)}case"transform":if(1===e.length){const t=u(e[0].geometry,"type");"point"!==t&&"multipoint"!==t||(r="reshape")}return this._setupTransformOrReshape2DOperation(e,r,a,i)}}async _setupMove3DOperation(e,t,o,i,a=!1){for(const l of e){const e=M(l);if(e!==R.SUPPORTED)return this._logError("sketch:move",`Move operation not supported for provided graphic(s) (${D(e)}).`),null}const r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(re(r))return r;const s=new r.module.GraphicMoveTool({view:o,enableZ:t.enableZ,snappingManager:this._snappingManager});this.view.tools.add(s),s.graphics.addMany(e),a||this.updateGraphics.addMany(e);const n=[],p=new Z({activeComponent:s,tool:i,type:"update",onEnd:()=>{n.forEach((e=>e.remove())),n.length=0,this.view.tools?.remove(s),s.destroyed||s.destroy()},undo:()=>{te(p,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{oe(p,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:e=>{this.updateGraphics.push(e),s.graphics.push(e),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);p.history.undo.forEach((e=>e.updates.splice(t,1))),p.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?s.graphics.remove(e):p.complete()},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;if("transform"!==i)return;const e=this.updateGraphics.getItemAt(0);if(U(e)!==R.SUPPORTED)return;const a=await this._setupReshape3DOperation(e,t,o,!0);re(a)||(p.onEnd(),p.destroy(),this._setUpdateOperationHandle(a,t))}});return n.push(...this._getHandlesForComponent(p,t),this.view.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(p,e,t)),j.WIDGET),o.on("key-down",(e=>{this._getCommonUpdateOperationKeyDownHandlers(p,e),e.key===L.snappingToggle&&(this.snappingOptions.enabledToggled=!0,e.stopPropagation())}),j.WIDGET),o.on("key-up",(e=>{e.key===L.snappingToggle&&(this.snappingOptions.enabledToggled=!1,e.stopPropagation())}),j.WIDGET)),p}_setupGraphicTransform3DOperation(e,t,o,i=!1){if(1===e.length&&P(e[0])===R.SUPPORTED){const a=e[0],r=a.geometry;if(p(r)&&("point"===r.type||"mesh"===r.type))return this._setupPointTransform3DOperation(a,t,o);if(p(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 p=new n.module.GraphicTransformTool({graphic:e,view:o,enableRotation:a,enableScaling:r,enableZ:s,snappingManager:this._snappingManager});this.view.tools.add(p),this.updateGraphics.add(e);const l=[],h=new Z({activeComponent:p,tool:i,type:"update",onEnd:()=>{l.forEach((e=>e.remove())),l.length=0,this.view.tools?.remove(p),p.destroyed||p.destroy()},undo:()=>{te(h,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{oe(h,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"});const i=await this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0);re(i)||(h.onEnd(),h.destroy(),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"}),h.complete()},toggleTool:()=>{}});return l.push(...this._getHandlesForComponent(h,t),this.view.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(h,e,t)),j.WIDGET),o.on("key-down",(e=>{this._getCommonUpdateOperationKeyDownHandlers(h,e),e.key===L.snappingToggle&&(this.snappingOptions.enabledToggled=!0,e.stopPropagation())}),j.WIDGET),o.on("key-up",(e=>{e.key===L.snappingToggle&&(this.snappingOptions.enabledToggled=!1,e.stopPropagation())}),j.WIDGET)),h}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 h=new l.module.ExtentTransformTool({graphic:e,view:o,enableRotation:r,enableScaling:s,enableZ:n,preserveAspectRatio:p});this.view.tools.add(h),i||this.updateGraphics.add(e);const c=[],d=new Z({activeComponent:h,tool:a,type:"update",onEnd:()=>{c.forEach((e=>e.remove())),c.length=0,this.view.tools?.remove(h),h.destroyed||h.destroy()},canUndo:()=>h.canUndo,undo:()=>{h.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a})},canRedo:()=>h.canRedo,redo:()=>{h.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"});const i=await this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0);re(i)||(d.onEnd(),d.destroy(),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"}),d.complete()},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;const e=this.updateGraphics.getItemAt(0);if(U(e)!==R.SUPPORTED)return;const i=await this._setupReshape3DOperation(e,t,o,!0);re(i)||(d.onEnd(),d.destroy(),this._setUpdateOperationHandle(i,t))}});return c.push(...this._getHandlesForComponent(d,t),this.view.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(d,e,t)),j.WIDGET),this.view.on("key-down",(e=>this._getCommonUpdateOperationKeyDownHandlers(d,e)),j.WIDGET),this.view.on("key-down",(e=>{e.key!==L.constraint||e.repeat||(h.preserveAspectRatio=!h.preserveAspectRatio,e.stopPropagation())}),j.WIDGET),this.view.on("key-up",(e=>{e.key===L.constraint&&(h.preserveAspectRatio=!h.preserveAspectRatio,e.stopPropagation())}),j.WIDGET)),d}async _setupMove2DOperation(e,t,o){const i="move";this.updateGraphics.addMany(e),await this._updateSpatialReference(e);const a=await this._getGraphicMover(e,t,o);if(re(a))return a;const r=new Z({activeComponent:a,tool:i,type:"update",onEnd:()=>{this._displayDefaultCursor(),p.forEach((e=>e.remove())),n.forEach((e=>e.remove())),p=[],n=[],a.destroy(),this._internalGraphicsLayer?.removeMany([...this.updateGraphics.toArray()])},undo:()=>{const e=this.updateGraphics.toArray();te(r,e),r.refreshComponent(),this._emitUndoEvent({graphics:e,tool:i})},redo:()=>{const e=this.updateGraphics.toArray();oe(r,e),r.refreshComponent(),this._emitRedoEvent({graphics:e,tool:i})},addToSelection:async e=>{await 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,n=[o.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(r,e,t)),j.WIDGET),o.on("key-down",(e=>{this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key!==L.constraint||e.repeat||(s=!0,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)}),j.WIDGET),o.on("key-up",(e=>{e.key===L.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;this.snappingOptions.enabledToggled=!1;const s=new r.module.GraphicReshapeTool({view:o,graphic:e,enableZVertex:t.enableZ&&"move"===t.reshapeOptions.vertexOperation,enableZShape:t.enableZ&&"move"===t.reshapeOptions.shapeOperation,enableMoveGraphic:"move"===t.reshapeOptions.shapeOperation||"move-xy"===t.reshapeOptions.shapeOperation,enableMidpoints:"split"===t.reshapeOptions.edgeOperation,enableEdgeOffset:"offset"===t.reshapeOptions.edgeOperation,snappingManager:this._snappingManager,tooltipOptions:this.tooltipOptions});o.tools.add(s),i||this.updateGraphics.add(e);const n=[],p=new Z({activeComponent:s,tool:a,type:"update",onEnd:()=>{n.forEach((e=>e.remove())),n.length=0,this.view.tools?.remove(s),s.destroyed||s.destroy()},canUndo:()=>s.canUndo,undo:()=>{s.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a})},canRedo:()=>s.canRedo,redo:()=>{s.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"});const i=await this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0);re(i)||(p.onEnd(),p.destroy(),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"}),p.complete()},toggleTool:async()=>{if(!1===t.toggleToolOnClick)return;const e=await this._setupGraphicTransform3DOperation(this.updateGraphics.toArray(),t,o,!0);re(e)||(p.onEnd(),p.destroy(),this._setUpdateOperationHandle(e,t))}});return n.push(...this._getHandlesForComponent(p,t),o.on("immediate-click",(e=>this._getCommonUpdateOperationClickHandlers(p,e,t)),j.WIDGET),o.on("key-down",(e=>{this._getCommonUpdateOperationKeyDownHandlers(p,e),e.key===L.snappingToggle&&(this.snappingOptions.enabledToggled=!0,e.stopPropagation())}),j.WIDGET),o.on("key-up",(e=>{e.key===L.snappingToggle&&(this.snappingOptions.enabledToggled=!1,e.stopPropagation())}),j.WIDGET)),p}async _setupTransformOrReshape2DOperation(e,t,o,i){this.updateGraphics.addMany(e),await this._updateSpatialReference(e);const a="transform"===t?await this._getBox(e,o,i):await this._getReshape(e,o,i);if(re(a))return a;const r=new Z({activeComponent:a,type:"update",onEnd:()=>{n.forEach((e=>e.remove())),s.forEach((e=>e.remove())),n=[],s=[],r.activeComponent&&!r.activeComponent.destroyed&&r.activeComponent.destroy(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray())},undo:()=>{te(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},redo:()=>{oe(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();const a=await this._setupMove2DOperation(t,o,i);if(re(a))return;r.onEnd(),r.destroy(),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:async 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();if(0===o.length)r.complete();else{const e=o[0].geometry;1!==o.length||!p(e)||"point"!==e.type&&"multipoint"!==e.type?r.activeComponent.graphics=o:r.toggleTool()}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.getItemAt(0),t=e.geometry;if(p(t)&&("reshape"===r.tool&&("point"===t.type||"multipoint"===t.type)||"transform"===r.tool&&"extent"===t.type))return;let a=null;"transform"===r.tool?a=await this._getReshape([e],o,i):"reshape"===r.tool&&(a=await this._getBox([e],o,i)),re(a)||(r.activeComponent.destroy(),r.activeComponent=a,r.activeComponent&&(n.forEach((e=>e.remove())),n=this._getHandlesForComponent(r,o)))}});let 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!==L.snappingToggle||e.repeat||(this.snappingOptions.enabledToggled=!0,e.stopPropagation()),e.key===L.constraint&&!e.repeat&&r){const e=r.activeComponent;e&&"box"===e.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}}),j.WIDGET),i.on("key-up",(e=>{if(e.key===L.snappingToggle&&"reshape"===r?.activeComponent?.type&&(this.snappingOptions.enabledToggled=!1,e.stopPropagation()),e.key===L.constraint&&r){const e=r.activeComponent;e&&"box"===e.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}}),j.WIDGET)],n=this._getHandlesForComponent(r,o);return r}async _getGraphicMover(e,t,o){const{enableMoveAllGraphics:i}=t,a=await this._requireModule(import("../../views/draw/support/GraphicMover.js"));return re(a)?a:new a.module.default({enableMoveAllGraphics:i,highlightsEnabled:!0,indicatorsEnabled:!1,graphics:e,view:o,callbacks:{onGraphicMoveStart:({dx:e,dy:t,graphic:o})=>{this._displayGrabbingCursor(),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._displayPointerCursor(),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._displayPointerCursor(),onGraphicPointerOut:()=>this._displayDefaultCursor()}})}async _getBox(e,t,o){const{enableRotation:i,enableScaling:a,preserveAspectRatio:r}=t,s=await this._requireModule(import("../../views/draw/support/Box.js"));return re(s)?s:new s.module.default({graphics:e,enableRotation:i,enableScaling:a,preserveAspectRatio:r,layer:this._internalGraphicsLayer,view:o,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"})}})}async _getReshape(e,t,o){const i="split"===t.reshapeOptions?.edgeOperation,a="move"===t.reshapeOptions?.shapeOperation,r=await this._requireModule(import("../../views/draw/support/Reshape.js"));return re(r)?r:new r.module.default({enableMidpoints:i,enableMovement:a,graphic:e[0],layer:this._internalGraphicsLayer,snappingManager:this._snappingManager,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=>C(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=>C(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;switch(o.type){case"graphic-mover":return[o.on("graphic-click",(({graphic:t,viewEvent:o})=>{o.native?.shiftKey&&(o.stopPropagation(),e.removeFromSelection(t))})),o.on("graphic-move-start",(t=>e.addToHistory(ae(t.allGraphics))))];case"box":return[o.on("graphic-click",(o=>this._onTransformOrReshape2DGraphicClick(e,t,o))),o.on("move-start",(t=>e.addToHistory(ae(t.graphics)))),o.on("rotate-start",(t=>e.addToHistory(ae(t.graphics)))),o.on("scale-start",(t=>e.addToHistory(ae(t.graphics))))];case"reshape":return[o.on("graphic-click",(o=>this._onTransformOrReshape2DGraphicClick(e,t,o))),o.on("move-start",(t=>e.addToHistory(ae([t.mover])))),o.on("reshape-start",(t=>e.addToHistory(ae([t.graphic])))),o.on("vertex-add",(t=>e.addToHistory(ae([t.oldGraphic])))),o.on("vertex-remove",(t=>e.addToHistory(ae([t.oldGraphic]))))];case"move-3d":return[o.on("graphic-move-start",(t=>{e.addToHistory(ae(t.allGraphics)),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:t.allGraphics.length>0?t.allGraphics[0]:null,type:"move-start"},type:"update"})})),o.on("graphic-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.allGraphics.length>0?e.allGraphics[0]:null,type:"move"},type:"update"})})),o.on("graphic-move-stop",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:e.allGraphics.length>0?e.allGraphics[0]:null,type:"move-stop"},type:"update"})})),o.on("immediate-click",(o=>{o.shiftKey?this._toggleSelection([o.graphic],e,t):e.toggleTool()}))];case"transform-3d":return[o.on("record-undo",(({record:t})=>{e.addToHistory({updates:[t]})})),o.on("graphic-translate-start",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-start"},type:"update"})})),o.on("graphic-translate-stop",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-stop"},type:"update"})})),o.on("graphic-rotate-start",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,angle:e.angle,type:"rotate-start"},type:"update"})})),o.on("graphic-rotate-stop",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,angle:e.angle,type:"rotate-stop"},type:"update"})})),o.on("graphic-scale-start",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-start"},type:"update"})})),o.on("graphic-scale-stop",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-stop"},type:"update"})})),o.on("graphic-translate",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move"},type:"update"})})),o.on("graphic-rotate",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,angle:e.angle,type:"rotate"},type:"update"})})),o.on("graphic-scale",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale"},type:"update"})})),o.on("immediate-click",(o=>{o.shiftKey?this._toggleSelection([o.graphic],e,t):e.toggleTool()}))];case"reshape-3d":return[o.on("reshape",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})})),o.on("move",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})})),o.on("vertex-add",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})})),o.on("vertex-remove",(e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})})),o.on("immediate-click",(o=>{o.shiftKey?this._toggleSelection([o.graphic],e,t):e.toggleTool()}))];default:return}}_onTransformOrReshape2DGraphicClick(e,t,o){const{graphic:i,viewEvent:a}=o;return a.native?.shiftKey&&i.layer===this.layer?(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=K(t),a=await t.async((()=>this._getFirstHit(i)));if(!a)return void 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||e.layer!==this.layer)&&(this.updateGraphics.includes(e)?t.removeFromSelection(e):t.addToSelection(e),!0))))}_getCommonUpdateOperationKeyDownHandlers(e,t){if(!e)return;const o=t.key;o===L.undo&&e.canUndo()?(t.stopPropagation(),e.undo()):o===L.redo&&e.canRedo()?(t.stopPropagation(),e.redo()):o===L.cancel?(t.stopPropagation(),e.cancel()):this.allowDeleteKey&&L.delete.includes(o)&&this._onDeleteKey(t)}_onDeleteKey(e){if(!this._operationHandle||"update"!==this._operationHandle.type)return;const t=this.activeComponent,o=this.updateGraphics.toArray();c(t)||"reshape-3d"===t.type||("reshape"!==t.type||1===o.length&&"point"===u(o[0].geometry,"type"))&&(e.stopPropagation(),this.delete())}_removeDefaultLayer(){this._internalGraphicsLayer&&(this.view&&this.view.map&&this.view.map.remove(this._internalGraphicsLayer),this._internalGraphicsLayer=n(this._internalGraphicsLayer))}_isComponentGraphic(e){const{activeComponent:t}=this;return!(!e||c(t))&&(e.attributes&&e.attributes.esriSketchTool||"draw-2d"===t.type&&t.graphic===e||("box"===t.type||"reshape"===t.type)&&t.isUIGraphic(e))}_displayPointerCursor(){this.view&&this.view.container&&"pointer"!==this.view.cursor&&(this.view.cursor="pointer")}_displayGrabbingCursor(){this.view&&this.view.container&&"grabbing"!==this.view.cursor&&(this.view.cursor="grabbing")}_displayDefaultCursor(){this.view&&this.view.container&&null!==this.view.cursor&&(this.view.cursor=null)}_logError(e,t,o){Y.error(new i(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"})}test(){return{operationHandle:this._operationHandle,defaultUpdateOptions:Q}}wait(){return _((()=>!this.updating))}_beginAsyncOperation(){this._numUpdating+=1,this.notifyChange("updating")}_endAsyncOperation(){this._numUpdating-=1,this.notifyChange("updating")}_disablePopupEnabled(e){return"3d"!==this.view?.type||this.updateOnGraphicClick||p(e)&&e.toggleToolOnClick}_disablePopup(e){if(!this._disablePopupEnabled(e))return;const t=this.view.popup;t&&c(this._originalAutoOpenEnabled)&&(this._originalAutoOpenEnabled=t.autoOpenEnabled,t.autoOpenEnabled=!1)}_restorePopup(e){if(!this._disablePopupEnabled(e))return;const t=this.view.popup;t&&p(this._originalAutoOpenEnabled)&&(t.autoOpenEnabled=this._originalAutoOpenEnabled,this._originalAutoOpenEnabled=null)}async _waitViewReady(){const e=this.view;e&&(h(this._viewReadyAbortController),this._viewReadyAbortController=new AbortController,await m(_((()=>e?.ready)),this._viewReadyAbortController.signal))}};function ee(e){return"polygon"===e||"rectangle"===e||"circle"===e}function te(e,t){ie("undo",e.history.undo,e.history.redo,t)}function oe(e,t){ie("redo",e.history.redo,e.history.undo,t)}function ie(e,t,o,i){const a=t.pop().updates,r=[];i.forEach(((t,o)=>{const i=a[o];null!=i&&("geometry"in i&&p(i.geometry)&&(r.push({geometry:t.geometry}),t.geometry=i.geometry),"symbol"in i&&p(i.symbol)&&(r.push({symbol:t.symbol}),t.symbol=i.symbol),"undo"in i&&(r.push(i),i[e](t)))})),o.push({updates:r})}function ae(e){return{updates:e.map((e=>({geometry:e.geometry})))}}function re(e){return"requireError"in e&&"aborted"===e.requireError}e([G()],X.prototype,"updating",null),e([G()],X.prototype,"_operationHandle",void 0),e([G({readOnly:!0})],X.prototype,"activeTool",null),e([G()],X.prototype,"activeFillSymbol",void 0),e([G()],X.prototype,"activeLineSymbol",void 0),e([G()],X.prototype,"activeVertexSymbol",void 0),e([G()],X.prototype,"allowDeleteKey",void 0),e([G({readOnly:!0})],X.prototype,"createGraphic",null),e([G()],X.prototype,"defaultCreateOptions",null),e([G()],X.prototype,"defaultUpdateOptions",null),e([G()],X.prototype,"layer",void 0),e([G({types:t})],X.prototype,"pointSymbol",void 0),e([G({types:t})],X.prototype,"polygonSymbol",void 0),e([G({types:t})],X.prototype,"polylineSymbol",void 0),e([G({type:V,nonNullable:!0})],X.prototype,"snappingOptions",null),e([G()],X.prototype,"_snappingManager",void 0),e([G({readOnly:!0})],X.prototype,"state",null),e([G({type:W,nonNullable:!0})],X.prototype,"tooltipOptions",void 0),e([G({readOnly:!0})],X.prototype,"updateGraphics",void 0),e([G()],X.prototype,"updateOnGraphicClick",void 0),e([G({types:t})],X.prototype,"updatePointSymbol",void 0),e([G({types:t})],X.prototype,"updatePolygonSymbol",void 0),e([G({types:t})],X.prototype,"updatePolylineSymbol",void 0),e([G({types:t})],X.prototype,"vertexSymbol",void 0),e([G({value:null})],X.prototype,"view",null),X=e([b($)],X);const se=X;export{se as default};