@arcgis/core 5.2.0-next.73 → 5.2.0-next.74

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 (183) hide show
  1. package/analysis/ViewshedAnalysis.js +1 -1
  2. package/arcgisGlobal.d.ts +1 -0
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/{d3be4d914fc99a1d686c.js → 075e65cc4275ac886f08.js} +1 -1
  5. package/assets/esri/core/workers/chunks/087bd698b80ca0cea71e.js +1 -0
  6. package/assets/esri/core/workers/chunks/{b6c7b7b7f87dce5de811.js → 0bf644f93c180a2bc2f8.js} +1 -1
  7. package/assets/esri/core/workers/chunks/0e81c6d4f1c81f9b0a1b.js +1 -0
  8. package/assets/esri/core/workers/chunks/193aed69de2dec4f36b6.js +1 -0
  9. package/assets/esri/core/workers/chunks/1a3afee3ecd806b4aa81.js +1 -0
  10. package/assets/esri/core/workers/chunks/{014f9fd2818e2c9d9a3b.js → 264fd750691d517ab1f3.js} +1 -1
  11. package/assets/esri/core/workers/chunks/28f87daaba1ae3441364.js +1 -0
  12. package/assets/esri/core/workers/chunks/2baa16ec8559e77c226f.js +1 -0
  13. package/assets/esri/core/workers/chunks/2c31648a4b95275516ee.js +1 -0
  14. package/assets/esri/core/workers/chunks/2f81047790c4890ae625.js +1 -0
  15. package/assets/esri/core/workers/chunks/305eea9c1fc4aee3309e.js +1 -0
  16. package/assets/esri/core/workers/chunks/31d19bb72a9e79b30070.js +1 -0
  17. package/assets/esri/core/workers/chunks/45ccca01db0027b9dc16.js +1 -0
  18. package/assets/esri/core/workers/chunks/495f90fe3d0ad32bb82d.js +1 -0
  19. package/assets/esri/core/workers/chunks/4b5bd0c9a55ea2998601.js +1 -0
  20. package/assets/esri/core/workers/chunks/509aecafbc629bee1c15.js +1 -0
  21. package/assets/esri/core/workers/chunks/{d901f8503a73277cfa58.js → 553be2bd69bd311477ea.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{31669511cfddf116d991.js → 66e60351aacbd162775f.js} +1 -1
  23. package/assets/esri/core/workers/chunks/762be5d3e6aeaea33f74.js +29 -0
  24. package/assets/esri/core/workers/chunks/76b573143d1a65fdbcb6.js +1 -0
  25. package/assets/esri/core/workers/chunks/7aaa051b51a8e34bbfb0.js +1 -0
  26. package/assets/esri/core/workers/chunks/{44b50d4716a2567ab6f1.js → 7b5b66ae79e0287e3ade.js} +1 -1
  27. package/assets/esri/core/workers/chunks/81130dbcb738d40f723b.js +1 -0
  28. package/assets/esri/core/workers/chunks/835af7b4fd92cb4e7af0.js +1 -0
  29. package/assets/esri/core/workers/chunks/859dd86c921053bf03a1.js +1 -0
  30. package/assets/esri/core/workers/chunks/877594b6db08da98acd7.js +1 -0
  31. package/assets/esri/core/workers/chunks/{96d861265566854760cd.js → 88fd698b940dadcc6dc5.js} +1 -1
  32. package/assets/esri/core/workers/chunks/8f0d4aec8bd3cbfefc40.js +1 -0
  33. package/assets/esri/core/workers/chunks/{7f208ef75ef2ce0d7cf9.js → 910c93bbbf8113a4a51f.js} +1 -1
  34. package/assets/esri/core/workers/chunks/92c4464b67fce6cea134.js +1 -0
  35. package/assets/esri/core/workers/chunks/{509cfac9e5d86a8ee449.js → 936d44c7bc3a181e64a3.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{b9953277d0cd4a01bdc6.js → 94368a097e6190ce3c7a.js} +1 -1
  37. package/assets/esri/core/workers/chunks/947f1ea4dbc3e3419ecc.js +1 -0
  38. package/assets/esri/core/workers/chunks/9b76c8974424a1908e86.js +1 -0
  39. package/assets/esri/core/workers/chunks/{c203df41f9d2e4b80889.js → 9ca59077712e45ef4d56.js} +1 -1
  40. package/assets/esri/core/workers/chunks/9e25f715cda59c686a4c.js +1 -0
  41. package/assets/esri/core/workers/chunks/{36171c72a3c04b0d13ef.js → a0a1f0bd3648738354a6.js} +1 -1
  42. package/assets/esri/core/workers/chunks/a101152066dd56259619.js +1 -0
  43. package/assets/esri/core/workers/chunks/a2a2c7e274fb32fecffa.js +1 -0
  44. package/assets/esri/core/workers/chunks/a50421fe79f264ae3619.js +1 -0
  45. package/assets/esri/core/workers/chunks/a9053ad0f4e8c4705665.js +1 -0
  46. package/assets/esri/core/workers/chunks/aca5c524bd3c955e9243.js +1 -0
  47. package/assets/esri/core/workers/chunks/b1a175b3b2d1a7ddde8e.js +1 -0
  48. package/assets/esri/core/workers/chunks/b3b53cf0a3a30164d337.js +1 -0
  49. package/assets/esri/core/workers/chunks/b6d26d9738c0787acc38.js +1 -0
  50. package/assets/esri/core/workers/chunks/b9c61b20bbc91cb63036.js +1 -0
  51. package/assets/esri/core/workers/chunks/bf3dc3ad8df8488da3f0.js +1 -0
  52. package/assets/esri/core/workers/chunks/bff75cc7413bf0d319db.js +1 -0
  53. package/assets/esri/core/workers/chunks/c1568bcd3f04014152e1.js +1 -0
  54. package/assets/esri/core/workers/chunks/c1a4d499a30f3d80567b.js +1 -0
  55. package/assets/esri/core/workers/chunks/c374e5d5980db74c4aca.js +1 -0
  56. package/assets/esri/core/workers/chunks/{8c76f31a363dd0c3354d.js → c46f79d5b7712adbbd1c.js} +1 -1
  57. package/assets/esri/core/workers/chunks/c67e4a848d41038367b8.js +1 -0
  58. package/assets/esri/core/workers/chunks/de5013f89f0eae93978f.js +1 -0
  59. package/assets/esri/core/workers/chunks/e557043f90c051e93925.js +1 -0
  60. package/assets/esri/core/workers/chunks/{bee5e738ecf8680909c4.js → eaf26c1cc938789d5336.js} +1 -1
  61. package/assets/esri/core/workers/chunks/ebfb3cdc0df15eb05d75.js +1 -0
  62. package/assets/esri/core/workers/chunks/f1727b4a32cb6f36a5e6.js +1 -0
  63. package/assets/esri/core/workers/chunks/f4bc563c71c478d3912f.js +1 -0
  64. package/assets/esri/core/workers/chunks/fb0b89bbb4f8607d5f20.js +1 -0
  65. package/assets/esri/core/workers/chunks/fdca9873914b9dbd9244.js +1 -0
  66. package/assets/esri/core/workers/chunks/ff890167ff2baabfc4ce.js +1 -0
  67. package/config.js +1 -1
  68. package/kernel.js +1 -1
  69. package/layers/DimensionFeatureLayer.d.ts +22 -0
  70. package/layers/DimensionFeatureLayer.js +1 -1
  71. package/layers/save/featureLayerUtils.js +1 -1
  72. package/layers/support/layerUtils.js +1 -1
  73. package/layers/support/layersMapping.js +1 -1
  74. package/package.json +1 -1
  75. package/support/revision.js +1 -1
  76. package/views/2d/interactive/editingTools/draw/DrawGraphicTool2D.js +1 -1
  77. package/views/3d/analysis/LineOfSight/LineOfSightReshapeTool3D.js +1 -1
  78. package/views/3d/analysis/LineOfSight/lineOfSightPlacementUtils.js +1 -1
  79. package/views/3d/analysis/Viewshed/ViewshedEditTool.js +1 -1
  80. package/views/3d/analysis/Viewshed/ViewshedPlacementController.js +1 -1
  81. package/views/3d/analysis/Viewshed/placementUtils.js +1 -1
  82. package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
  83. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementShiftTool.js +1 -1
  84. package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
  85. package/views/3d/interactive/editingTools/move/MoveTool3D.js +1 -1
  86. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  87. package/views/3d/interactive/editingTools/reshape/ReshapeTool3D.js +1 -1
  88. package/views/3d/interactive/editingTools/reshape/reshapeTooltipUtils3D.js +1 -1
  89. package/views/3d/interactive/editingTools/tooltipUtils3D.js +1 -1
  90. package/views/3d/interactive/editingTools/transform/ExtentTransformTool.js +1 -1
  91. package/views/3d/interactive/editingTools/transform/ScaleRotateTransform.js +1 -1
  92. package/views/3d/interactive/editingTools/transform/TransformTool3D.js +1 -1
  93. package/views/3d/interactive/editingTools/transform/extentTransform/ExtentMove.js +1 -1
  94. package/views/3d/interactive/editingTools/transform/extentTransform/ExtentRotate.js +1 -1
  95. package/views/3d/interactive/editingTools/transform/extentTransform/ExtentScale.js +1 -1
  96. package/views/3d/layers/graphics/tessellationUtils.js +1 -1
  97. package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
  98. package/views/3d/layers/support/MediaLayerInteraction.js +1 -1
  99. package/views/3d/support/flow/FlowSubViewTiles3D.js +1 -1
  100. package/views/3d/support/renderInfoUtils/polygon.js +1 -1
  101. package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
  102. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  103. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  104. package/views/3d/webgl-engine/lib/ViewshedShadowMap.js +1 -1
  105. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  106. package/views/draw/DrawGraphicTool.js +1 -1
  107. package/views/draw/DrawTool.js +1 -1
  108. package/views/draw/plugins/PolylinePlugin.js +1 -1
  109. package/views/draw/support/Box.js +1 -1
  110. package/views/draw/support/InteractiveHandle.js +1 -1
  111. package/views/draw/support/Reshape.js +1 -1
  112. package/views/draw/support/drawToolUtils.js +1 -1
  113. package/views/draw/support/managers/InteractiveHandleManager.js +1 -1
  114. package/views/draw/support/managers/TooltipManager.js +1 -1
  115. package/views/draw/support/reshapeTooltipUtils.js +1 -1
  116. package/views/draw/support/tooltipUtils.js +1 -1
  117. package/views/interactive/options/InteractiveToolOptions.d.ts +36 -0
  118. package/views/interactive/options/InteractiveToolOptions.js +2 -0
  119. package/views/interactive/sketch/SketchOptions.d.ts +4 -3
  120. package/views/interactive/sketch/SketchOptions.js +1 -1
  121. package/views/interactive/tooltip/components/DrawHeaderActions.js +1 -1
  122. package/views/interactive/tooltip/content/TooltipContent.js +1 -1
  123. package/views/interactive/tooltip/content/TooltipContentDrawPolygon.js +1 -1
  124. package/views/interactive/tooltip/content/TooltipContentDrawPolyline.js +1 -1
  125. package/views/interactive/tooltip/content/TooltipContentDynamic.js +1 -1
  126. package/views/interactive/tooltip/fields/fields.js +1 -1
  127. package/views/interactive/tooltip/infos/DynamicTooltipInfo.js +1 -1
  128. package/views/interactive/tooltip/infos/SketchTooltipInfo.js +1 -1
  129. package/views/interactive/tooltip/tooltipCommonUtils.js +1 -1
  130. package/widgets/Sketch/SketchViewModel.js +1 -1
  131. package/widgets/support/GridControls/GridControlsViewModel.js +1 -1
  132. package/assets/esri/core/workers/chunks/00cbff0b785e24e87d97.js +0 -1
  133. package/assets/esri/core/workers/chunks/0623acb2bd14a61b65c9.js +0 -29
  134. package/assets/esri/core/workers/chunks/06c9aac75a01d3af6d54.js +0 -1
  135. package/assets/esri/core/workers/chunks/089f8c60e96d920a2cb2.js +0 -1
  136. package/assets/esri/core/workers/chunks/0c3c311400ee352187ea.js +0 -1
  137. package/assets/esri/core/workers/chunks/158d2ac0333d53556e33.js +0 -1
  138. package/assets/esri/core/workers/chunks/16cade1c2ddf44e336ee.js +0 -1
  139. package/assets/esri/core/workers/chunks/1b130af7d14eaae69d96.js +0 -1
  140. package/assets/esri/core/workers/chunks/1e0140556c2e3fa72545.js +0 -1
  141. package/assets/esri/core/workers/chunks/1e5cb72830c7f32f2961.js +0 -1
  142. package/assets/esri/core/workers/chunks/259bdacfb7b0f866a8d0.js +0 -1
  143. package/assets/esri/core/workers/chunks/2f58e1f64df2da8259a2.js +0 -1
  144. package/assets/esri/core/workers/chunks/383304d33b496c5d8baa.js +0 -1
  145. package/assets/esri/core/workers/chunks/3aacb935d632834d4154.js +0 -1
  146. package/assets/esri/core/workers/chunks/3c8e98cf23ad8ef12fcb.js +0 -1
  147. package/assets/esri/core/workers/chunks/3dc71e03a630dd50b28e.js +0 -1
  148. package/assets/esri/core/workers/chunks/3fd022df127af32782ce.js +0 -1
  149. package/assets/esri/core/workers/chunks/4344ab1250a1c550bf8b.js +0 -1
  150. package/assets/esri/core/workers/chunks/43de723f765ec8f268ac.js +0 -1
  151. package/assets/esri/core/workers/chunks/4695cd6120f60b234d5c.js +0 -1
  152. package/assets/esri/core/workers/chunks/582a1d468089b9986416.js +0 -1
  153. package/assets/esri/core/workers/chunks/5f201c77a09ae0df29d6.js +0 -1
  154. package/assets/esri/core/workers/chunks/6080e46fc79127500283.js +0 -1
  155. package/assets/esri/core/workers/chunks/67d3ff7fcefaa7d5d27f.js +0 -1
  156. package/assets/esri/core/workers/chunks/6a9002fcba11e2cf3f2e.js +0 -1
  157. package/assets/esri/core/workers/chunks/72dcd4bd1a28bf8605c5.js +0 -1
  158. package/assets/esri/core/workers/chunks/73f228d966b89c73c9e9.js +0 -1
  159. package/assets/esri/core/workers/chunks/77df0bb35d2688729479.js +0 -1
  160. package/assets/esri/core/workers/chunks/7a143ca61c0a70306185.js +0 -1
  161. package/assets/esri/core/workers/chunks/869d292a60747c93dc84.js +0 -1
  162. package/assets/esri/core/workers/chunks/9c57161ad48d8d546dc7.js +0 -1
  163. package/assets/esri/core/workers/chunks/a7f42ada0aa69873a938.js +0 -1
  164. package/assets/esri/core/workers/chunks/a988fd54912969b812ce.js +0 -1
  165. package/assets/esri/core/workers/chunks/aff0e7761276036e029d.js +0 -1
  166. package/assets/esri/core/workers/chunks/b7d8817018b3d277c454.js +0 -1
  167. package/assets/esri/core/workers/chunks/ba4f419f46be09a9a55c.js +0 -1
  168. package/assets/esri/core/workers/chunks/bfb6566c27c09deb0929.js +0 -1
  169. package/assets/esri/core/workers/chunks/c715c585c42d8c2b86f5.js +0 -1
  170. package/assets/esri/core/workers/chunks/c7e9513f75b8ec205562.js +0 -1
  171. package/assets/esri/core/workers/chunks/c838cc1c786368b78598.js +0 -1
  172. package/assets/esri/core/workers/chunks/cd4e5c948d1bfa9b9a2d.js +0 -1
  173. package/assets/esri/core/workers/chunks/cfe31b7d1c6c05fbd268.js +0 -1
  174. package/assets/esri/core/workers/chunks/d0c1bc90e474f706211c.js +0 -1
  175. package/assets/esri/core/workers/chunks/da484787bd9fd3b13d15.js +0 -1
  176. package/assets/esri/core/workers/chunks/e21b3490bfce75405e55.js +0 -1
  177. package/assets/esri/core/workers/chunks/e4353f0792f45aa6a62f.js +0 -1
  178. package/assets/esri/core/workers/chunks/e702abaeccef20b64a81.js +0 -1
  179. package/assets/esri/core/workers/chunks/ebd619533be077059494.js +0 -1
  180. package/assets/esri/core/workers/chunks/f475672ff4c2ec9367c2.js +0 -1
  181. package/assets/esri/core/workers/chunks/f69329b85b362b349a8c.js +0 -1
  182. package/assets/esri/core/workers/chunks/fba8065a3a6fbd877e23.js +0 -1
  183. package/assets/esri/core/workers/chunks/fec07a16b72cdcafc641.js +0 -1
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{watch as t}from"../../../../core/reactiveUtils.js";import{property as i,subclass as s}from"../../../../core/accessorSupport/decorators.js";import{SketchTooltipInfo as l}from"./SketchTooltipInfo.js";let o=class extends l{constructor(e){super(e),this.type="dynamic",this.renderContext=null,this.helpMessage=void 0,this._isVisibleField=e=>{if(!e.visible)return!1;const t=e.name;switch(t){case"x":case"y":return this.visibleElements.coordinates;default:return this.visibleElements[t]??!0}}}initialize(){this.addHandles(t(()=>this.getHelpMessageKey?.(),e=>this.helpMessage=e??void 0))}get availableFields(){return this.getAllFields?.()?.map(e=>e.field)??[]}get availableFieldsForCurrentHandle(){const e=this.getAllFields?.(),t=this.getActiveHandle?.();return d(e??[],t)}get allManagedFields(){const{availableFieldsForCurrentHandle:e}=this,t=this.getActiveHandle?.(),i=this._getXyMode(t);return(this._useCoordinateDisplay(t,i)?e.filter(e=>n(e.field)):this._useDirectionDistanceDisplay(t,i)?e.filter(e=>a(e.field)):e).filter(e=>this._isVisibleField(e.field)).sort((e,t)=>r(e.field,t.field))}get fieldsGroupedForDisplay(){const e=this.allManagedFields,t=new Map,i=[];for(const s of e){const e=s.displayGroup;t.has(e)||t.set(e,[]),t.get(e)?.push(s)}for(const[s,l]of t.entries())if(2===l.length&&s){const e=l.toSorted((e,t)=>r(e.field,t.field));i.push({left:e[0].field,right:e[1].field})}else i.push(...l.map(e=>e.field));return i}get xyMode(){return this._getXyMode(this.getActiveHandle?.())}get allFields(){return this.allManagedFields.map(e=>e.field)}getConstraintFieldsForHandle(e){const t=this.getAllFields?.(),i=this._getXyMode(e),s=d(t??[],e).map(e=>e.field).filter(p);return(this._useCoordinateDisplay(e,i)?s.filter(n):this._useDirectionDistanceDisplay(e,i)?s.filter(a):s).filter(this._isVisibleField)}isEffectiveVisibleField(e){const{allFields:t,renderContext:i}=this;return e.visible&&!!i&&t.includes(e)}_getXyMode(e){const t=this.sketchOptions.tooltips.xyMode,i=e?.editSession?.endVertex?.leftSegment?.leftVertex;return"auto"===t?i&&"primary"===e?.role?"direction-distance":"coordinates":t}_useCoordinateDisplay(e,t){const{availableFields:i}=this;return("coordinates"===t||"secondary"===e?.role)&&i.some(e=>"x"===e.name)&&i.some(e=>"y"===e.name)}_useDirectionDistanceDisplay(e,t){const{availableFields:i}=this;return"direction-distance"===t&&"primary"===e?.role&&i.some(e=>"distance"===e.name)&&i.some(e=>"direction"===e.name)}};function r(e,t){return e.displayOrder-t.displayOrder}function n(e){return"direction"!==e.name&&"distance"!==e.name}function a(e){return"x"!==e.name&&"y"!==e.name}function d(e,t){const{name:i,role:s}=t??{};return e?.filter(e=>!(null!=e.appliesToHandlesWithName&&e.appliesToHandlesWithName!==i||null!=e.appliesToHandlesWithRole&&e.appliesToHandlesWithRole!==s))??[]}function p(e){switch(e.name){case"direction":case"distance":case"elevation":case"x":case"y":return!0;default:return!1}}e([i()],o.prototype,"type",void 0),e([i()],o.prototype,"getAllFields",void 0),e([i()],o.prototype,"getActiveHandle",void 0),e([i()],o.prototype,"getHelpMessageKey",void 0),e([i()],o.prototype,"availableFields",null),e([i()],o.prototype,"availableFieldsForCurrentHandle",null),e([i()],o.prototype,"allManagedFields",null),e([i()],o.prototype,"fieldsGroupedForDisplay",null),e([i()],o.prototype,"xyMode",null),e([i()],o.prototype,"allFields",null),e([i()],o.prototype,"renderContext",void 0),e([i()],o.prototype,"helpMessage",void 0),o=e([s("esri.views.interactive.tooltip.infos.DynamicTooltipInfo")],o);export{o as DynamicTooltipInfo,p as isKnownConstraintField};
2
+ import{__decorate as e}from"tslib";import{watch as t}from"../../../../core/reactiveUtils.js";import{property as i,subclass as s}from"../../../../core/accessorSupport/decorators.js";import{SketchTooltipInfo as l}from"./SketchTooltipInfo.js";let o=class extends l{constructor(e){super(e),this.type="dynamic",this.renderContext=null,this.helpMessage=void 0,this._isVisibleField=e=>{if(!e.visible)return!1;const t=e.name;switch(t){case"x":case"y":return this.visibleElements.coordinates;default:return this.visibleElements[t]??!0}}}initialize(){this.addHandles(t(()=>this.getHelpMessageKey?.(),e=>this.helpMessage=e??void 0))}get availableFields(){return this.getAllFields?.()?.map(e=>e.field)??[]}get availableFieldsForCurrentHandle(){const e=this.getAllFields?.(),t=this.getActiveHandle?.();return d(e??[],t)}get allManagedFields(){const{availableFieldsForCurrentHandle:e}=this,t=this.getActiveHandle?.(),i=this._getXyMode(t);return(this._useCoordinateDisplay(t,i)?e.filter(e=>n(e.field)):this._useDirectionDistanceDisplay(t,i)?e.filter(e=>a(e.field)):e).filter(e=>this._isVisibleField(e.field)).sort((e,t)=>r(e.field,t.field))}get fieldsGroupedForDisplay(){const e=this.allManagedFields,t=new Map,i=[];for(const s of e){const e=s.displayGroup;t.has(e)||t.set(e,[]),t.get(e)?.push(s)}for(const[s,l]of t.entries())if(2===l.length&&s){const e=l.toSorted((e,t)=>r(e.field,t.field));i.push({left:e[0].field,right:e[1].field})}else i.push(...l.map(e=>e.field));return i}get xyMode(){return this._getXyMode(this.getActiveHandle?.())}get allFields(){return this.allManagedFields.map(e=>e.field)}getConstraintFieldsForHandle(e){const t=this.getAllFields?.(),i=this._getXyMode(e),s=d(t??[],e).map(e=>e.field).filter(p);return(this._useCoordinateDisplay(e,i)?s.filter(n):this._useDirectionDistanceDisplay(e,i)?s.filter(a):s).filter(this._isVisibleField)}isEffectiveVisibleField(e){const{allFields:t,renderContext:i}=this;return e.visible&&!!i&&t.includes(e)}_getXyMode(e){const t=this.toolOptions.tooltips.xyMode,i=e?.editSession?.endVertex?.leftSegment?.leftVertex;return"auto"===t?i&&"primary"===e?.role?"direction-distance":"coordinates":t}_useCoordinateDisplay(e,t){const{availableFields:i}=this;return("coordinates"===t||"secondary"===e?.role)&&i.some(e=>"x"===e.name)&&i.some(e=>"y"===e.name)}_useDirectionDistanceDisplay(e,t){const{availableFields:i}=this;return"direction-distance"===t&&"primary"===e?.role&&i.some(e=>"distance"===e.name)&&i.some(e=>"direction"===e.name)}};function r(e,t){return e.displayOrder-t.displayOrder}function n(e){return"direction"!==e.name&&"distance"!==e.name}function a(e){return"x"!==e.name&&"y"!==e.name}function d(e,t){const{name:i,role:s}=t??{};return e?.filter(e=>!(null!=e.appliesToHandlesWithName&&e.appliesToHandlesWithName!==i||null!=e.appliesToHandlesWithRole&&e.appliesToHandlesWithRole!==s))??[]}function p(e){switch(e.name){case"direction":case"distance":case"elevation":case"x":case"y":return!0;default:return!1}}e([i()],o.prototype,"type",void 0),e([i()],o.prototype,"getAllFields",void 0),e([i()],o.prototype,"getActiveHandle",void 0),e([i()],o.prototype,"getHelpMessageKey",void 0),e([i()],o.prototype,"availableFields",null),e([i()],o.prototype,"availableFieldsForCurrentHandle",null),e([i()],o.prototype,"allManagedFields",null),e([i()],o.prototype,"fieldsGroupedForDisplay",null),e([i()],o.prototype,"xyMode",null),e([i()],o.prototype,"allFields",null),e([i()],o.prototype,"renderContext",void 0),e([i()],o.prototype,"helpMessage",void 0),o=e([s("esri.views.interactive.tooltip.infos.DynamicTooltipInfo")],o);export{o as DynamicTooltipInfo,p as isKnownConstraintField};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{property as o,subclass as s}from"../../../../core/accessorSupport/decorators.js";let i=class extends t{constructor(e){super(e),this.helpMessage=void 0,this.viewType=void 0}get visibleElements(){return this.sketchOptions.tooltips.visibleElements}get allFields(){return[]}get editableFields(){return this.allFields.filter(e=>e.visible&&!e.readOnly)}clearInputValues(){this.allFields.forEach(e=>e.clearInputValue())}};e([o()],i.prototype,"sketchOptions",void 0),e([o()],i.prototype,"visibleElements",null),e([o()],i.prototype,"helpMessage",void 0),e([o()],i.prototype,"viewType",void 0),e([o()],i.prototype,"allFields",null),e([o()],i.prototype,"editableFields",null),i=e([s("esri.views.interactive.tooltip.infos.SketchTooltipInfo")],i);export{i as SketchTooltipInfo};
2
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{property as o,subclass as l}from"../../../../core/accessorSupport/decorators.js";let i=class extends t{constructor(e){super(e),this.helpMessage=void 0,this.viewType=void 0}get visibleElements(){return this.toolOptions.tooltips.visibleElements}get allFields(){return[]}get editableFields(){return this.allFields.filter(e=>e.visible&&!e.readOnly)}clearInputValues(){this.allFields.forEach(e=>e.clearInputValue())}};e([o()],i.prototype,"toolOptions",void 0),e([o()],i.prototype,"visibleElements",null),e([o()],i.prototype,"helpMessage",void 0),e([o()],i.prototype,"viewType",void 0),e([o()],i.prototype,"allFields",null),e([o()],i.prototype,"editableFields",null),i=e([l("esri.views.interactive.tooltip.infos.SketchTooltipInfo")],i);export{i as SketchTooltipInfo};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{createTask as t}from"../../../core/asyncUtils.js";import{handlesGroup as o,makeHandle as e}from"../../../core/handleUtils.js";import{floatEqualUlp as n}from"../../../core/mathUtils.js";import{createAngle as r,createScalar as i,valueInUnit as l}from"../../../core/quantity.js";import{watch as a}from"../../../core/reactiveUtils.js";import{verticalLengthUnitFromSpatialReference as s}from"../../../core/units.js";import{scale as u,equals as c,negate as p}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{clone as f,ONES as m,create as d,UNIT_Z as g}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{isLoaded as y,load as v}from"../../../geometry/coordinateFormatter.js";import x from"../../../geometry/support/MeshTransform.js";import{isRelativeVertexSpace as j}from"../../../geometry/support/meshVertexSpaceUtils.js";import{isWebMercator as b}from"../../../geometry/support/spatialReferenceUtils.js";import{lngLatToXY as h}from"../../../geometry/support/webMercatorUtils.js";import{tooltipKeys as S}from"../keybindings.js";import U from"../Tooltip.js";import{parseLatitudeLongitude as w,parseXY as A}from"./fields/parsingAndFormattingUtils.js";import{getDegreesArithmetic as M,getDegreesGeographic as R}from"../../support/angularMeasurementUtils.js";function V(t){const o=new U(t());return o.addHandles(a(()=>t(),({view:t,options:e,info:n})=>{o.view=t,void 0!==e&&(o.options=e),void 0!==n&&(o.info=n)})),o}function k(t,o){const e=j(o.vertexSpace),{scale:n,orientation:l}=t,{transform:a}=o,s=T(a);e&&null!=s?(l.actual=r(s,"degrees","arithmetic"),l.visible=!0):(l.actual=null,l.visible=!1),e?(n.actual=i(H(a)),n.visible=!0):(n.actual=null,n.visible=!1)}function z(t,o,e){if(!o||!j(o.vertexSpace))return;const n=o.transform??=new x;D(t,n,e),P(t,n,e)}function D(t,o,e){const r=M(t.orientation.actual),i=q(o.rotationAxis);if(null==r||null==i)return;const l=r-90,a=o.rotationAngle,s=l*i,u=s-a;n(a,s)||(e?.onRotateStart(0),o.rotationAngle=s,e?.onRotate(u),e?.onRotateStop(u))}function P(t,o,e){const n=t.scale.actual?.value,r=H(o);if(null==n||n===r)return;const{scale:i}=o;let l;if(0===r)l=f(m);else{const t=n/r;l=u(d(),i,t)}e?.onScaleStart(i[0],i[1],i[2]),o.scale=l,e?.onScale(l[0],l[1],l[2]),e?.onScaleStop(l[0],l[1],l[2])}function F(t,o){const{x:e,y:r,z:i}=o,{x:l,y:a,z:s}=E(t,o.spatialReference);return{dx:null==l||n(l,e)?0:l-e,dy:null==a||n(a,r)?0:a-r,dz:null==s||null==i||n(s,i)?0:s-i}}function E(t,o){let e,n;t.geographic?(e=R(t.longitude.actual),n=R(t.latitude.actual),b(o)&&(null!=e&&null!=n?[e,n]=h(e,n,I):null!=e?e=h(e,0,I)[0]:null!=n&&(n=h(0,n,I)[1]))):(e=t.x.actual?.value,n=t.y.actual?.value);const r=t.elevation.actual,i=s(o);return{x:e,y:n,z:null!=i&&null!=r?l(r,i):void 0}}const I=[0,0];function T(t){const o=90;if(!t)return o;const e=q(t.rotationAxis)??1;return null!=e?o+e*t.rotationAngle:null}function q(t){return c(t,g)?1:c(t,B)?-1:null}const B=p(d(),g);function H(t){return t?Math.max(...t.scale):1}function O(t,o){return!("key-down"!==t.type||t.key!==S.enterInputMode||!o||!C(o.info))&&(o.enterInputMode(),t.preventDefault(),t.stopPropagation(),!0)}function C(t){const o=t?.sketchOptions;if(!o)return!1;const{inputEnabled:e,visibleElements:n}=o.tooltips;return e&&!0===t.editableFields.some(({name:t})=>"x"===t||"y"===t?n.coordinates:!t||n[t])}function G(n,r){let i=null;return o([n.on("paste",o=>{i?.abort(),i=t(async()=>{y()||await v(),J(o,n.info,r)})}),t(()=>v()),e(()=>i?.abort())])}function J(t,o,e){if(!o||!("geographic"in o))return;const n=t.clipboardData?.getData("text");if(!n)return;const r=o=>{t.stopPropagation(),t.preventDefault(),e?.onBeforePaste(),o(),e?.onAfterPaste()};if(o.geographic){const t=w(n);t&&r(()=>{o.longitude.applyValue(t.longitude),o.latitude.applyValue(t.latitude)})}else{const t=A(n);t&&r(()=>{o.x.applyValue(t.x),o.y.applyValue(t.y)})}}export{G as connectPasteEvent,O as enterInputModeIfAvailable,F as getXYZDeltasFromTooltipInfo,C as isInputModeAvailable,V as makeTooltip,J as pasteLocation,z as updateMeshTransformFromTooltipInfo,k as updateTooltipInfoFromMeshTransform};
2
+ import{createTask as t}from"../../../core/asyncUtils.js";import{handlesGroup as o,makeHandle as e}from"../../../core/handleUtils.js";import{floatEqualUlp as n}from"../../../core/mathUtils.js";import{createAngle as r,createScalar as i,valueInUnit as l}from"../../../core/quantity.js";import{watch as a}from"../../../core/reactiveUtils.js";import{verticalLengthUnitFromSpatialReference as s}from"../../../core/units.js";import{scale as u,equals as c,negate as p}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{clone as f,ONES as m,create as d,UNIT_Z as g}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{isLoaded as y,load as v}from"../../../geometry/coordinateFormatter.js";import x from"../../../geometry/support/MeshTransform.js";import{isRelativeVertexSpace as j}from"../../../geometry/support/meshVertexSpaceUtils.js";import{isWebMercator as b}from"../../../geometry/support/spatialReferenceUtils.js";import{lngLatToXY as h}from"../../../geometry/support/webMercatorUtils.js";import{tooltipKeys as S}from"../keybindings.js";import U from"../Tooltip.js";import{parseLatitudeLongitude as w,parseXY as A}from"./fields/parsingAndFormattingUtils.js";import{getDegreesArithmetic as M,getDegreesGeographic as R}from"../../support/angularMeasurementUtils.js";function V(t){const o=new U(t());return o.addHandles(a(()=>t(),({view:t,options:e,info:n})=>{o.view=t,void 0!==e&&(o.options=e),void 0!==n&&(o.info=n)})),o}function z(t,o){const e=j(o.vertexSpace),{scale:n,orientation:l}=t,{transform:a}=o,s=T(a);e&&null!=s?(l.actual=r(s,"degrees","arithmetic"),l.visible=!0):(l.actual=null,l.visible=!1),e?(n.actual=i(H(a)),n.visible=!0):(n.actual=null,n.visible=!1)}function D(t,o,e){if(!o||!j(o.vertexSpace))return;const n=o.transform??=new x;P(t,n,e),k(t,n,e)}function P(t,o,e){const r=M(t.orientation.actual),i=q(o.rotationAxis);if(null==r||null==i)return;const l=r-90,a=o.rotationAngle,s=l*i,u=s-a;n(a,s)||(e?.onRotateStart(0),o.rotationAngle=s,e?.onRotate(u),e?.onRotateStop(u))}function k(t,o,e){const n=t.scale.actual?.value,r=H(o);if(null==n||n===r)return;const{scale:i}=o;let l;if(0===r)l=f(m);else{const t=n/r;l=u(d(),i,t)}e?.onScaleStart(i[0],i[1],i[2]),o.scale=l,e?.onScale(l[0],l[1],l[2]),e?.onScaleStop(l[0],l[1],l[2])}function F(t,o){const{x:e,y:r,z:i}=o,{x:l,y:a,z:s}=E(t,o.spatialReference);return{dx:null==l||n(l,e)?0:l-e,dy:null==a||n(a,r)?0:a-r,dz:null==s||null==i||n(s,i)?0:s-i}}function E(t,o){let e,n;t.geographic?(e=R(t.longitude.actual),n=R(t.latitude.actual),b(o)&&(null!=e&&null!=n?[e,n]=h(e,n,I):null!=e?e=h(e,0,I)[0]:null!=n&&(n=h(0,n,I)[1]))):(e=t.x.actual?.value,n=t.y.actual?.value);const r=t.elevation.actual,i=s(o);return{x:e,y:n,z:null!=i&&null!=r?l(r,i):void 0}}const I=[0,0];function T(t){const o=90;if(!t)return o;const e=q(t.rotationAxis)??1;return null!=e?o+e*t.rotationAngle:null}function q(t){return c(t,g)?1:c(t,B)?-1:null}const B=p(d(),g);function H(t){return t?Math.max(...t.scale):1}function O(t,o){return!("key-down"!==t.type||t.key!==S.enterInputMode||!o||!C(o.info))&&(o.enterInputMode(),t.preventDefault(),t.stopPropagation(),!0)}function C(t){const o=t?.toolOptions;if(!o)return!1;const{inputEnabled:e,visibleElements:n}=o.tooltips;return e&&!0===t.editableFields.some(({name:t})=>"x"===t||"y"===t?n.coordinates:!t||n[t])}function G(n,r){let i=null;return o([n.on("paste",o=>{i?.abort(),i=t(async()=>{y()||await v(),J(o,n.info,r)})}),t(()=>v()),e(()=>i?.abort())])}function J(t,o,e){if(!o||!("geographic"in o))return;const n=t.clipboardData?.getData("text");if(!n)return;const r=o=>{t.stopPropagation(),t.preventDefault(),e?.onBeforePaste(),o(),e?.onAfterPaste()};if(o.geographic){const t=w(n);t&&r(()=>{o.longitude.applyValue(t.longitude),o.latitude.applyValue(t.latitude)})}else{const t=A(n);t&&r(()=>{o.x.applyValue(t.x),o.y.applyValue(t.y)})}}export{G as connectPasteEvent,O as enterInputModeIfAvailable,F as getXYZDeltasFromTooltipInfo,C as isInputModeAvailable,V as makeTooltip,J as pasteLocation,D as updateMeshTransformFromTooltipInfo,z as updateTooltipInfoFromMeshTransform};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{isSome as o}from"../../core/arrayUtils.js";import i from"../../core/Collection.js";import a from"../../core/Error.js";import{EventedAccessor as r}from"../../core/Evented.js";import{makeHandle as s,drainHandles as n,destroyHandle as p}from"../../core/handleUtils.js";import"../../core/has.js";import l from"../../core/Logger.js";import{destroyMaybe as h,abortMaybe as d}from"../../core/maybe.js";import{createAbortError as c,ignoreAbortErrors as u,whenOrAbort as m}from"../../core/promiseUtils.js";import{watch as g,syncAndInitial as y,on as v,when as f,whenOnce as _}from"../../core/reactiveUtils.js";import{property as b,subclass as w}from"../../core/accessorSupport/decorators.js";import{trackAccess as T}from"../../core/accessorSupport/tracking.js";import{SimpleObservable as G}from"../../core/accessorSupport/tracking/SimpleObservable.js";import{UpdatingHandles as O}from"../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as S}from"../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as C,isLoaded as A,load as E,project as k}from"../../geometry/projectionUtils.js";import{geometryToCoordinates as M}from"../../geometry/support/coordsUtils.js";import{equals as H}from"../../geometry/support/spatialReferenceUtils.js";import P from"../../layers/GraphicsLayer.js";import{isIntegratedMeshLayer as D}from"../../layers/support/layerUtils.js";import{getEffectiveElevationInfo as I}from"../../support/elevationInfoUtils.js";import U from"../../symbols/FillSymbol3DLayer.js";import j from"../../symbols/MeshSymbol3D.js";import R from"../../symbols/SimpleFillSymbol.js";import x from"../../symbols/SimpleLineSymbol.js";import L from"../../symbols/SimpleMarkerSymbol.js";import F from"../../symbols/TextSymbol.js";import{symbolTypes as V}from"../../symbols/support/typeUtils.js";import{isSupportedObjectResultMessage as W}from"../../views/3d/interactive/editingTools/isSupportedObjectUtils.js";import{isSupportedObject as K}from"../../views/3d/interactive/editingTools/move/isSupportedObject.js";import{isSupportedObject as Z}from"../../views/3d/interactive/editingTools/reshape/isSupportedObject.js";import{isSupportedGraphic as q}from"../../views/3d/interactive/editingTools/transform/isSupportedGraphic.js";import{addUniqueLayer as N}from"../../views/draw/support/layerUtils.js";import{ViewEventPriorities as z}from"../../views/input/InputManager.js";import{sketchKeys as B}from"../../views/interactive/keybindings.js";import $ from"../../views/interactive/sketch/SketchLabelOptions.js";import Y from"../../views/interactive/sketch/SketchOptions.js";import J from"../../views/interactive/sketch/SketchTooltipOptions.js";import Q from"../../views/interactive/sketch/SketchValueOptions.js";import{SnappingManager as X}from"../../views/interactive/snapping/SnappingManager.js";import ee from"../../views/interactive/snapping/SnappingOptions.js";import{setupSnappingToggleHandles as te}from"../../views/interactive/snapping/snappingUtils.js";import{GeometryWorkerHandle as oe}from"../../views/support/GeometryWorkerHandle.js";import{defaultHighlightName as ie}from"../../views/support/HighlightDefaults.js";import{findFirstGraphicHit as ae}from"../../views/support/hitTestSelectUtils.js";import{createScreenPointFromEvent as re}from"../../views/support/screenUtils.js";import se from"./adapters/layer/GraphicsLayerAdapter.js";import ne from"./adapters/layer/MapNotesLayerAdapter.js";import{CreateOperationHandle as pe,DrawToolOperationHandle as le,UpdateOperationHandle as he}from"./support/OperationHandle.js";import{PluginManager as de}from"./support/PluginManager.js";import{SettingsManager as ce}from"./support/SettingsManager.js";import{getLegacyTool as ue,isCompletelyDegenerate as me,graphicsHaveTooFewVerticesForBox as ge,getModeFromCreateOptions as ye,getDrawToolGeometryTypeFromCreateTool as ve}from"./support/sketchUtils.js";const fe={defaultZ:0},_e={reshapeOptions:{edgeOperation:"split",shapeOperation:"move",vertexOperation:"move",enableCreateCurveFromStraightEdge:!0},enableMoveAllGraphics:!0,enableRotation:!0,enableScaling:!0,multipleSelectionEnabled:!0,preserveAspectRatio:!1,toggleToolOnClick:!0,enableZ:!0,highlightOptions:{enabled:!0,name:ie},tool:"transform"},be=Symbol(),we=Symbol();let Te=class extends r{constructor(e){super(e),this._defaultSnappingManager=null,this._internalGraphicsLayer=new P({listMode:"hide",internal:!0,title:"SVM Internal"}),this._pluginManager=new de({sketchViewModel:this}),this.settingsManager=new ce({availablePlugins:()=>this.pluginManager.visiblePluginsFlat}),this._operationHandle=null,this._updatingHandles=new O,this._toolTransitionHandles=new O,this._drawToolSimplifyAbortController=null,this._geometryWorkerHandle=new oe,this._viewHandlesKey="viewHandles",this.activeFillSymbol=null,this.activeLineSymbol=null,this.activeVertexSymbol=null,this.allowDeleteKey=!0,this.activeUpdateOptions=null,this.layer=null,this.pointSymbol=new L({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.polygonSymbol=new R({color:[150,150,150,.2],outline:{color:[50,50,50],width:2}}),this.polylineSymbol=new x({color:[130,130,130,1],width:2}),this.meshSymbol=new j({symbolLayers:new i([new U])}),this.updateGraphics=new i,this.updateOnGraphicClick=!0,this.cancelUpdateOnClickAway=!0,this.creationMode="single",this.vertexSymbol=new L({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.sketchOptions=new Y,this.useLegacyCreateTools=!0,this._moduleLoaderAbortController=null,this._viewReadyAbortController=null,this._sketchContinuationFlag=!1,this._onLayerAdapterChange=async()=>{const{_layerAdapter:e}=this;if(this.removeHandles(we),!e)return;const t=[e.onGraphicsChange(e=>this._onLayerGraphicsChangeCallback(e)),g(()=>e.elevationInfo,e=>{e!==this._internalGraphicsLayer.elevationInfo&&(this.cancel(),this._internalGraphicsLayer&&(this._internalGraphicsLayer.elevationInfo=e))},y)].filter(o);this.addHandles(t,we)},this._originalPopupEnabled=null,this.defaultCreateOptions=fe,this.defaultUpdateOptions=_e,this.snappingOptions=e?.snappingManager?.options??e?.snappingOptions??new ee,this.textSymbol=new F({text:"text"})}initialize(){this._updatingHandles.consumePromise(this._setupAdvancedDrawToolIntegrationMaybe()),this.addHandles([v(()=>this.view?.map?.layers,"change",e=>{this.layer&&e.removed.includes(this.layer)&&this.cancel()}),g(()=>this._layerAdapter,()=>this._onLayerAdapterChange(),y),g(()=>this.view,e=>{this._defaultSnappingManager=h(this._defaultSnappingManager),e&&(this.snappingManager||(this._defaultSnappingManager=new X({view:e,options:this.snappingOptions})),"2d"===e.type?(import("../../views/2d/interactive/editingTools.js"),this._updatingHandles.consumePromise(this._setupAdvancedDrawToolIntegrationMaybe())):"3d"===e.type&&(import("../../views/3d/interactive/editingTools.js"),import("../../views/3d/layers/GraphicsLayerView3D.js")))},y),g(()=>this.view?.spatialReference,(e,t)=>{e&&t&&!e.equals(t)&&this.cancel()})]),te(this)}destroy(){this.cancel(),this._removeDefaultLayer(),this._defaultSnappingManager=h(this._defaultSnappingManager),this._set("snappingManager",null),this._set("view",null),this._updatingHandles.destroy(),this._toolTransitionHandles.destroy(),this._drawToolSimplifyAbortController=d(this._drawToolSimplifyAbortController),this._geometryWorkerHandle.destroy(),this._pluginManager?.destroy(),this.emit("destroy")}get _layerAdapter(){const{layer:e}=this;switch(e?.type){case"graphics":return new se(e);case"map-notes":return new ne(e);default:return null}}get activeTool(){return this._operationHandle?.tool??null}get geometrySimplificationInProgress(){return!!this._drawToolSimplifyAbortController}get activeCreateToolDrawMode(){const e=this._operationHandle;if("create"===e?.type&&e.activeComponent&&"mode"in e.activeComponent)return e.activeComponent.mode;if("draw-2.0"===e?.activeComponent?.type){const t=e.activeComponent.pluginStack.map(e=>e.configuration).filter(o).toArray();if(t.length>0)return this._pluginManager?.getDrawingModeEquivalentToPluginStack(t)}return null}get activeTooltip(){const{activeComponent:e,destroyed:t}=this,o=!t&&e&&"tooltip"in e?e.tooltip:null;return o?.visible?o:null}get activeComponent(){return this._operationHandle?.activeComponent??null}get createGraphic(){return null==this.activeComponent||"draw-3d"!==this.activeComponent.type&&"draw-2d"!==this.activeComponent.type?this._get("createGraphic"):this.activeComponent.graphic}get defaultCreateOptions(){return this._get("defaultCreateOptions")}set defaultCreateOptions(e){this._set("defaultCreateOptions",{...fe,...e})}get defaultUpdateOptions(){return this._get("defaultUpdateOptions")}set defaultUpdateOptions(e){this._set("defaultUpdateOptions",{..._e,...e,reshapeOptions:{..._e.reshapeOptions,...e?.reshapeOptions},highlightOptions:{..._e.highlightOptions,...e?.highlightOptions}})}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=e}get textSymbol(){return this._get("textSymbol")}set textSymbol(e){this._set("textSymbol",e)}get snappingOptions(){return this.snappingManager?.options??this._get("snappingOptions")}set snappingOptions(e){null!=this._defaultSnappingManager&&(this._defaultSnappingManager.options=e),this._set("snappingOptions",e)}get snappingManager(){return this._isOverridden("snappingManager")&&this._get("snappingManager"),this._defaultSnappingManager}set snappingManager(e){if(e)this._isOverridden("snappingManager")||(this._defaultSnappingManager=h(this._defaultSnappingManager)),this._override("snappingManager",e);else{const{view:e}=this;!this._defaultSnappingManager&&e&&(this._defaultSnappingManager=new X({options:this.snappingOptions,view:e})),this._clearOverride("snappingManager")}}get state(){const e=!(!this.view?.ready||!this.layer),t=this._operationHandle;return e&&t?"active":e?"ready":"disabled"}get toolTransitionInProgress(){return this._toolTransitionHandles.updating||!!this.drawTool?.lifecycleManager.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get updating(){return this.toolTransitionInProgress||this.activeComponent&&"updating"in this.activeComponent&&this.activeComponent.updating||!!(this._updatingHandles.updating||this._drawToolSimplifyAbortController||this.snappingManager?.updating||this.drawTool?.updating)}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}get view(){return this._get("view")}set view(e){const t=this._get("view");if(t){const{container:e,map:o}=t;e&&this._clearCursor(),o?.remove(this._internalGraphicsLayer),this.removeHandles(this._viewHandlesKey),this.cancel()}const o="view-ready";this.removeHandles(o),e&&this.addHandles(f(()=>e.ready,t=>{this.removeHandles(this._viewHandlesKey),t&&this.addHandles(this._generateViewHandles(e),this._viewHandlesKey)},y),o),this._set("view",e),this._updatingHandles.consumePromise(this._setupAdvancedDrawToolIntegrationMaybe())}get isUsingLegacyCreateTools(){return this.useLegacyCreateTools||"2d"!==this.view?.type}get pluginManager(){return this._pluginManager}get drawTool(){return"draw-2.0"!==this.activeComponent?.type?null:this.activeComponent}get rootPlugins(){return this._pluginManager?.availablePlugins}set rootPlugins(e){this._overrideIfSome("rootPlugins",e)}get effectiveAvailablePlugins(){if(this.isUsingLegacyCreateTools)return null;const e=this.view?.type??"2d",{firstPluginWithSwappableLeaf:t}=this;return t?t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e)):this.rootPlugins?.filter(t=>!t.excludedViews?.includes(e)).filter(o)??[]}get firstPluginWithSwappableLeaf(){const e=this.view?.type??"2d",t=this.drawTool?.pluginStack.toArray().map(e=>e.configuration).findLast(t=>null!=t&&!t.hidden&&t.availableDownstreamPlugins&&t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e))?.length>1);return t}get multiplePluginsActive(){return!!this.drawTool&&this.drawTool.pluginStack.length>1}addGraphic(e){this._layerAdapter?.add(e)}addGraphics(e){this._layerAdapter?.addMany(e)}hasGraphic(e){return!!this._layerAdapter?.has(e)}removeGraphic(e){this._layerAdapter?.remove(e)}removeGraphics(e){this._layerAdapter?.removeMany(e)}removeAllGraphics(){this._layerAdapter?.removeAll()}cancel(){this._moduleLoaderAbortController=d(this._moduleLoaderAbortController),this._viewReadyAbortController=d(this._viewReadyAbortController),this._drawToolSimplifyAbortController=d(this._drawToolSimplifyAbortController),this._sketchContinuationFlag=!0,this._operationHandle?.cancel()}complete(){this._operationHandle?.complete()}delete(){const{state:e,updateGraphics:t}=this;if("active"===e&&t.length){const{activeTool:e}=this,o=t.toArray();this.removeGraphics(o),this.cancel(),this._emitDeleteEvent({graphics:o,tool:e})}}duplicate(){if("active"===this.state&&this.updateGraphics.length){const e=this.updateGraphics.map(e=>e.clone()).toArray();return this.addGraphics(e),this.emit("duplicate",{graphics:e,type:"duplicate"}),e}return[]}async create(e,t){return this._toolTransitionHandles.addPromise(this._create(e,t))}async _create(e,t){this.cancel(),await this._updatingHandles.addPromise(this._waitViewReady());const{view:o,layer:i}=this;if(!o||"disabled"===this.state)throw i||this._logMissingLayer(),c();if(null!=o.activeTool&&(o.activeTool=null),!e)return void this._logError("sketch:missing-parameter","Missing parameter 'tool'.");N(o,this._internalGraphicsLayer);const a=await this._updatingHandles.addPromise(this._setupCreateOperation(e,t));if(null==a||this.destroyed)return void o.map?.remove(this._internalGraphicsLayer);const r=ue(e),s=()=>{if(a===this._operationHandle){const o=this.createGraphic,i=this._operationHandle.cancelled;if(this._operationHandle.destroy(),this._operationHandle=null,this._set("createGraphic",null),this.view?.map?.remove(this._internalGraphicsLayer),a.cancelled||null==o||this.addGraphic(o),this._sketchContinuationFlag=!1,this.emit("create",{graphic:o,state:i?"cancel":"complete",tool:r??"point",toolEventInfo:null,type:"create"}),i||this._sketchContinuationFlag)return;const{creationMode:s}=this;if("continuous"===s){if(t?.geometryToPlace)return;this._updatingHandles.consumePromise(u(this.create(e,t)))}else"update"===s&&o&&this._updatingHandles.consumePromise(u(this.update([o])))}};a.on("complete",s),this._operationHandle=a,o.ready&&o.focus()}async place(e,t){return await e.load(),this.create("mesh",{mode:"click",hasZ:e.hasZ,geometryToPlace:e,...t})}async update(e,t){return this._toolTransitionHandles.addPromise(this._update(e,t))}async _update(e,t){this.cancel(),await this._updatingHandles.addPromise(this._waitViewReady());const{layer:o,view:i,state:a}=this;if(!i||"disabled"===a)throw o||this._logMissingLayer(),c();null!=i.activeTool&&(i.activeTool=null);const r=Array.isArray(e)?e:[e];if(null==e||!r?.length)return void this._logError("sketch:missing-parameter","Missing parameter 'graphics'.");if(r.some(e=>this.hasGraphic(e)?null==e.geometry&&(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics with an unsupported geometry."),!0):(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics missing from the supplied GraphicsLayer."),!0)))return;const s=await this._updatingHandles.addPromise(this._setupUpdateOperation(r,t));this.destroyed||null==s||Pe(s)||(N(i,this._internalGraphicsLayer),this._setUpdateOperationHandle(s,t),this.emit("update",{graphics:r,state:"start",aborted:!1,tool:s.tool,toolEventInfo:null,type:"update"}))}async _updateSpatialReference(e){const t=this.view;if(t){e=Array.isArray(e)?e:[e];for(const o of e)null==o.geometry||"mesh"===o.geometry.type||H(o.geometry.spatialReference,t.spatialReference)||(C(o.geometry.spatialReference,t.spatialReference)||A()||await E(),o.geometry=k(o.geometry,t.spatialReference))}else this._logMissingView()}undo(){this.canUndo()&&this._operationHandle?.undo()}redo(){this.canRedo()&&this._operationHandle?.redo()}canUndo(){return!!this._operationHandle?.canUndo()}canRedo(){return!!this._operationHandle?.canRedo()}toggleUpdateTool(){this._updatingHandles.consumePromise(this._operationHandle?.toggleTool())}async _getFirstHit(e){const t=this.view;if(!t)return this._logMissingView(),null;if("2d"===t.type){const o=[];t.map.allLayers.forEach(e=>{"vector-tile"!==e.type&&"imagery"!==e.type||o.push(e)});const i=await t.hitTest(e,{exclude:o});return ae(i.results)}const o=[t.map.ground];t.map.allLayers.forEach(e=>{D(e)&&o.push(e)});const i=await t.hitTest(e,{exclude:o});if(i.results.length>0){const e=i.results[0];if(null!=e&&"graphic"===e.type&&e.graphic&&(!i.ground.mapPoint||t.map.ground.opacity<1||i.ground.distance-(e.distance??0)>-Math.min(3*i.ground.distance,"global"===t.viewingMode?S(t.renderCoordsHelper.spatialReference).radius/t.renderCoordsHelper.unitInMeters:Number.POSITIVE_INFINITY)))return e}return null}_generateViewHandles(e){return[e.on("immediate-click",async e=>{const t="active"===this.state&&"create"===this._operationHandle?.type;"disabled"!==this.state&&!t&&this.updateOnGraphicClick&&await this._updatingHandles.addPromise(this._handleImmediateClick(e))},z.WIDGET)]}async _handleImmediateClick(e){const t=await e.defer(()=>this._getFirstHit(re(e)));let o=null;if(null!=t){const i=t.graphic;this.updateGraphics.includes(i)||this.hasGraphic(i)?(e.stopPropagation(),o=i):"2d"!==this.view?.type||this._isComponentGraphic(i)||"active"!==this.state||this.cancel()}else"active"===this.state&&this.cancelUpdateOnClickAway&&this.cancel();null==o||this.updateGraphics.includes(o)||await this.update([o],{...this.defaultUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions}})}async _setupCreateOperation(e,t){const o=this.view;if(!o)return this._logMissingView(),null;const i={hasZ:"3d"===o.type,...this.defaultCreateOptions,...t},a="string"==typeof e?this.pluginManager?.getPluginsEquivalentToCreateTool(e,i.mode):e,r=ue(e);if(a&&!this.isUsingLegacyCreateTools){const e=await this._setupDrawTool(a,i,r??"polyline");if(e)return this._setupDrawToolOperationHandle(e,r??"point")}if(!r)return null;const s=await this._setupDrawGraphicTool(r,o,i);return null==s?null:(o.tools.add(s),o.activeTool=s,this._setupCreateOperationHandle(s,r))}async _setupDrawGraphicTool(e,t,o){if("multipoint"===e&&"3d"===t.type)return this._logError("sketch:create","Multipoint geometries are not supported in SceneView."),null;if(!t)return this._logMissingView(),null;const{cursor:i,defaultZ:a,hasZ:r,geometryToPlace:s,graphicProperties:n,mode:p,preserveAspectRatio:l}=o,h=ye(p,e),d=ve(e),c=o?.optionsPerTool?.has(e)?o.optionsPerTool.get(e):{},u=c?.preserveAspectRatio??l??"rectangle"!==e,m={centered:"rectangle"!==e&&!("circle"===e&&!u),cursor:i,defaultZ:a,forceUniformSize:u,graphicProperties:{...n,attributes:{...n?.attributes}},geometryToPlace:s,geometryType:d,mode:h,graphicSymbol:o.graphicSymbol??this._getGraphicSymbolFromTool(e),hasZ:r,snappingManager:this.snappingManager,snapToScene:!1,view:t,...c};return"2d"===t.type?this._makeDrawGraphicTool2D(m):this._makeDrawGraphicTool3D(m)}async _makeDrawGraphicTool2D(e){const t=await this._requireModule(import("../../views/2d/interactive/editingTools.js"));return Pe(t)||this.destroyed?null:new t.module.DrawGraphicTool2D({...e,activeVertexSymbol:this.activeVertexSymbol,regularVerticesSymbol:this.vertexSymbol,activeLineSymbol:this.activeLineSymbol,activeFillSymbol:Se(e.geometryType)?this.activeFillSymbol:null,sketchOptions:this.sketchOptions})}async _makeDrawGraphicTool3D(e){const t=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));return Pe(t)||this.destroyed?null:new t.module.DrawGraphicTool3D({...e,elevationInfo:this._layerAdapter?.elevationInfo,snapToScene:!0,sketchOptions:this.sketchOptions})}_setupCreateOperationHandle(e,t){const o=this.view;if(!o)return this._logMissingView(),null;let i=null;const a=e.forceUniformSize,r=e.centered,p=new G,l=[s(()=>p.destroy()),o.on("key-down",t=>{if(t.key===B.pan)t.stopPropagation(),t.repeat||(e.enabled=!1);else if(t.key===B.complete)t.stopPropagation(),e.completeCreateOperation();else if(t.key!==B.vertexAdd||t.repeat)t.key===B.undo?(t.stopPropagation(),h.undo()):t.key===B.redo?(t.stopPropagation(),h.redo()):t.key!==B.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType||t.repeat?t.key===B.center&&(t.repeat||(e.centered=!r,t.stopPropagation())):(e.forceUniformSize=!a,t.stopPropagation());else{const o=e.drawOperation.geometryType;"polyline"!==o&&"polygon"!==o&&"multipoint"!==o||(t.stopPropagation(),e.drawOperation.commitStagedVertex())}},z.WIDGET),o.on("key-up",t=>{t.key===B.pan?e.enabled=!0:t.key!==B.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType?t.key===B.center&&(e.centered=r,t.stopPropagation()):(e.forceUniformSize=a,t.stopPropagation())},z.WIDGET),e.on("vertex-update",()=>{p.notify()}),e.on("vertex-add",t=>{switch(p.notify(),i=null==i?"start":"active",t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:i,tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[e.graphic],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[e.graphic],tool:e.geometryType})}}),e.on("cursor-update",t=>{e.drawOperation.numCommittedVertices>0&&this.emit("create",{graphic:e.graphic,state:"active",tool:this.activeTool,toolEventInfo:{coordinates:t.vertices[0].coordinates,type:"cursor-update"},type:"create"})}),e.on("vertex-remove",t=>{switch(p.notify(),t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:"active",tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[e.graphic],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[e.graphic],tool:e.geometryType})}}),e.on("complete",e=>{this._set("createGraphic",e.graphic),i="complete",e.aborted?h&&h.cancel():h&&h.complete()}),g(()=>this._getGraphicSymbolFromTool(t),t=>{e.graphicSymbol=t})],h=new pe({activeComponent:e,type:"create",onEnd:()=>{n(l),o.tools?.remove(e)},undo:()=>{e.canUndo&&e.undo()},redo:()=>{e.canRedo&&e.redo()},canUndo:()=>(T(p),e.canUndo),canRedo:()=>(T(p),e.canRedo)});return h}_setupDrawToolOperationHandle(e,t){const i=this.view;if(!i)return this._logMissingView(),null;let a=null;const r=[i.on("key-down",t=>{t.key===B.pan&&(t.stopPropagation(),t.repeat||(e.editable=!1))},z.WIDGET),i.on("key-up",t=>{t.key===B.pan&&(e.editable=!0)},z.WIDGET),e.on("before-vertex-add",t=>{const o=e.mostUpstreamPlugin?.configuration;if(o&&"legacyCreateTool"in o&&("point"===o?.legacyCreateTool||"text"===o.legacyCreateTool)){const e=t.detail.originalEvent;return void(e&&"key"in e&&e.key===B.vertexAdd&&t.preventDefault())}}),e.on("before-complete",t=>{const o=e.getGeometryIfCompleted();(!o||me(o))&&t.preventDefault()}),e.on(["vertex-add","vertex-remove"],i=>{switch(this.createGraphic&&(this.createGraphic.geometry=e.getGeometryIfCompleted()),a=null==a&&"vertex-remove"!==i.type?"start":"active",i.operation){case"apply":this.emit("create",{graphic:this.createGraphic,state:a,tool:this.activeTool,toolEventInfo:i,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[this.createGraphic].filter(o),tool:t});break;case"redo":this._emitRedoEvent({graphics:[this.createGraphic].filter(o),tool:t})}}),e.on("cursor-update",t=>{this.createGraphic&&(this.createGraphic.geometry=e.unprocessedGeometry),(t.vertices[0]?.vertexIndex>0||t.vertices[0]?.componentIndex>0)&&this.emit("create",{graphic:this.createGraphic,state:"active",tool:this.activeTool,toolEventInfo:{coordinates:t.vertices[0].coordinates,type:"cursor-update"},type:"create"})}),e.on("complete",async({geometry:t,isSimple:o})=>{const i=this.createGraphic,a=!!t&&"mesh"!==t.type&&"extent"!==t.type&&!o;if(i&&(i.geometry=o?t:e.unprocessedGeometry??t),a&&i){this._internalGraphicsLayer.add(this.createGraphic);const e=new AbortController;this._drawToolSimplifyAbortController?.abort(),this._drawToolSimplifyAbortController=e,await this._updatingHandles.addPromise(u(this._finalizeDrawToolCompletion({abortController:e,geometry:t,graphic:i,handle:s})))}else s.complete()})],s=new le({activeComponent:e,type:"create",onEnd:()=>{n(r),i.tools.remove(e)},undo:()=>e.undo(),redo:()=>e.redo(),canUndo:()=>e.canUndo,canRedo:()=>e.canRedo});return r.push(e.on("cancel",()=>{this._drawToolSimplifyAbortController=d(this._drawToolSimplifyAbortController),s.cancel()})),s}async _finalizeDrawToolCompletion({abortController:e,geometry:t,graphic:o,handle:i}){const a=this.view?.acquireCursor("progress","high");a&&this.addHandles(a);const r=()=>!!e.signal.aborted&&(o&&(this._layerAdapter?.remove(o),this._internalGraphicsLayer?.remove(o)),this._set("createGraphic",null),!0);try{const a=await this._geometryWorkerHandle.simplify(t,e.signal);if(r())return;o.geometry=a??t,this._internalGraphicsLayer?.remove(o),i.complete()}finally{a?.remove(),this._drawToolSimplifyAbortController===e&&(this._drawToolSimplifyAbortController=null)}}_getGraphicSymbolFromTool(e){switch(e){case"point":case"multipoint":return this.pointSymbol;case"polyline":case"freehandPolyline":return this.polylineSymbol;case"circle":case"rectangle":case"polygon":case"freehandPolygon":return this.polygonSymbol;case"mesh":return this.meshSymbol;case"text":return this.textSymbol}}async _setupUpdateOperation(e,t){const{view:o}=this;if(!o)return this._logMissingView(),null;const i={...this.defaultUpdateOptions,...t,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...t?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...t?.highlightOptions}};this.activeUpdateOptions=i;let a=i.tool??_e.tool;if(this.removeGraphics(e),this.addGraphics(e),"3d"===o.type){if(0===e.length)return null;switch(a){case"move":return this._setupMove3DOperation(e,i,o,a);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupReshape3DOperation(e[0],i,o);case"transform":return this._setupGraphicTransform3DOperation(e,i,o)}}switch(a){case"move":return this._setupMove2DOperation(e,i,o);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupTransformOrReshape2DOperation(e,a,i,o);case"transform":return ge(e)&&(a="reshape"),this._setupTransformOrReshape2DOperation(e,a,i,o)}}async _setupMove3DOperation(e,t,o,i,a=!1){const r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Pe(r))return r;const{ManipulatedObject3DGraphic:s,MoveTool3D:p}=r.module,l=new Map,h=()=>{l.forEach(e=>e.destroy()),l.clear()};for(const n of e){const e=new s({view:o,graphic:n}),t=K(e);if(0!==t)return h(),this._logError("sketch:move",`Move operation not supported for provided graphic(s) (${W(t)}).`),null;l.set(n,e)}const d=new p({view:o,enableZ:t.enableZ,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(d),d.objects.addMany(Array.from(l.values())),a||this.updateGraphics.addMany(e);const c=[],u=new he({activeComponent:d,tool:i,type:"update",onEnd:()=>{n(c),He(o,d),h()},undo:()=>{ke(this.view,d),Ce(u,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{Ae(u,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:async e=>{this.updateGraphics.push(e);const t=new s({view:o,graphic:e});l.set(e,t),d.objects.push(t),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:async e=>{const t=this.updateGraphics.indexOf(e);if(u.history.undo.forEach(e=>e.updates.splice(t,1)),u.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0===this.updateGraphics.length)return void u.complete();const o=l.get(e);o&&(d.objects.remove(o),o.destroy(),l.delete(e))},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;if("transform"!==i)return;const e=this.updateGraphics.at(0),a=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,o,!0));a&&!Pe(a)&&(u.onEnd(),u.destroy(),this._setUpdateOperationHandle(a,t))}});return c.push(...this._getHandlesForComponent(u,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(u,e,t),z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(u,e)},z.WIDGET)),u}_setupGraphicTransform3DOperation(e,t,o,i=!1){if(1===e.length&&0===q(e[0])){const a=e[0],r=a.geometry;if(null!=r&&("point"===r.type||"mesh"===r.type))return this._setupPointTransform3DOperation(a,t,o);if(null!=r&&("polygon"===r.type||"polyline"===r.type))return this._setupPolyTransform3DOperation(a,t,o,i)}return this._setupMove3DOperation(e,t,o,"transform",i)}async _setupPointTransform3DOperation(e,t,o){const i="transform",{enableRotation:a,enableScaling:r,enableZ:s}=t,p=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Pe(p))return p;const{TransformTool3D:l,ManipulatedObject3DGraphic:h}=p.module,d=new h({graphic:e,view:o}),c=new l({object:d,view:o,enableRotation:a,enableScaling:r,enableZ:s,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(c),this.updateGraphics.add(e);const u=[],m=new he({activeComponent:c,tool:i,type:"update",onEnd:()=>{n(u),He(o,c),d.destroy()},undo:()=>{ke(this.view,c),Ce(m,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{Ae(m,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),m.onEnd(),m.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Pe(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:async e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),m.complete()},toggleTool:async()=>{}});return u.push(...this._getHandlesForComponent(m,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(m,e,t),z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(m,e)},z.WIDGET)),m}async _setupPolyTransform3DOperation(e,t,o,i=!1){const a="transform",{enableRotation:r,enableScaling:s,enableZ:p,preserveAspectRatio:l}=t,h=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Pe(h))return h;const{ManipulatedObject3DGraphic:d,ExtentTransformTool:c}=h.module,u=this.view?.inputManager?.isModifierKeyDown(B.constraint),m=new d({view:o,graphic:e}),g=new c({object:m,view:o,enableRotation:r,enableScaling:s,enableZ:p,preserveAspectRatio:!!l!=!!u,sketchOptions:this.sketchOptions});o.tools.add(g),i||this.updateGraphics.add(e);const y=[],v=new he({activeComponent:g,tool:a,type:"update",onEnd:()=>{n(y),He(o,g),m.destroy()},canUndo:()=>!g.destroyed&&g.canUndo,undo:()=>{g.destroyed||(g.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},canRedo:()=>!g.destroyed&&g.canRedo,redo:()=>{g.destroyed||(g.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),v.onEnd(),v.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Pe(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:async e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),v.complete()},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;const i=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,o,!0));i&&!Pe(i)&&(v.onEnd(),v.destroy(),this._setUpdateOperationHandle(i,t))}});return y.push(...this._getHandlesForComponent(v,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(v,e,t),z.WIDGET),o.on("key-down",e=>this._getCommonUpdateOperationKeyDownHandlers(v,e),z.WIDGET),o.on("key-down",e=>{e.key!==B.constraint||e.repeat||(g.preserveAspectRatio=!g.preserveAspectRatio,e.stopPropagation())},z.WIDGET),o.on("key-up",e=>{e.key===B.constraint&&(g.preserveAspectRatio=!g.preserveAspectRatio,e.stopPropagation())},z.WIDGET)),v}async _setupMove2DOperation(e,t,o){const i="move";this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const a=await this._updatingHandles.addPromise(this._getGraphicMover(e,t,o));if(Pe(a))return a;const r=new he({activeComponent:a,tool:i,type:"update",onEnd:()=>{this._clearCursor(),n(l),n(p),a.destroy(),this._internalGraphicsLayer?.removeMany([...this.updateGraphics.toArray()])},undo:()=>{const e=this.updateGraphics.toArray();Ce(r,e),r.refreshComponent(),this._emitUndoEvent({graphics:e,tool:i})},redo:()=>{const e=this.updateGraphics.toArray();Ae(r,e),r.refreshComponent(),this._emitRedoEvent({graphics:e,tool:i})},addToSelection:async e=>{await this._updatingHandles.addPromise(this._updateSpatialReference(e)),this.updateGraphics.push(e),a.graphics=this.updateGraphics.toArray(),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection: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();this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0!==this.updateGraphics.length?a.graphics=o:r.complete()}});let s=!1;const p=[o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(r,e,t),z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key!==B.constraint||e.repeat||(s=!0,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)},z.WIDGET),o.on("key-up",e=>{e.key===B.constraint&&s&&(s=!1,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)},z.WIDGET)],l=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(Pe(r))return r;const{ManipulatedObject3DGraphic:s,ReshapeTool3D:p}=r.module,l=new s({view:o,graphic:e}),h=Z(l);if(0!==h)return l.destroy(),this._logError("sketch:reshape",`Reshape operation not supported for provided graphic(s) (${W(h)}).`),null;const d=t.reshapeOptions,c=new p({view:o,object:l,enableZVertex:t.enableZ&&"move"===d?.vertexOperation,enableZShape:t.enableZ&&"move"===d?.shapeOperation,enableMoveObject:"move"===d?.shapeOperation||"move-xy"===d?.shapeOperation,enableMidpoints:"split"===d?.edgeOperation,enableEdgeOffset:"offset"===d?.edgeOperation,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions});o.tools.add(c),i||this.updateGraphics.add(l.graphic);const u=[],m=new he({activeComponent:c,tool:a,type:"update",onEnd:()=>{n(u),He(o,c),l.destroy()},canUndo:()=>!c.destroyed&&c.canUndo,undo:()=>{c.destroyed||(c.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},canRedo:()=>!c.destroyed&&c.canRedo,redo:()=>{c.destroyed||(c.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),m.onEnd(),m.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Pe(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:async e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),m.complete()},toggleTool:async()=>{if(!1===t.toggleToolOnClick)return;m.onEnd(),m.destroy();const e=await this._updatingHandles.addPromise(this._setupGraphicTransform3DOperation(this.updateGraphics.toArray(),t,o,!0));Pe(e)||this._setUpdateOperationHandle(e,t)}});return u.push(...this._getHandlesForComponent(m,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(m,e,t),z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(m,e)},z.WIDGET)),m}async _setupTransformOrReshape2DOperation(e,t,o,i){this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const a=await this._updatingHandles.addPromise("transform"===t?this._getBox(e,o,i):this._getReshape(e,o,i));if(Pe(a))return a;const r=new he({activeComponent:a,type:"update",onEnd:()=>{n(p),n(s),r.activeComponent&&!r.activeComponent.destroyed&&r.activeComponent.destroy(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray())},undo:()=>{Ce(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},redo:()=>{Ae(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},addToSelection:async e=>{let t=r.activeComponent;if("reshape"===t?.type){const t=[...this.updateGraphics,e];this.updateGraphics.removeAll(),r.onEnd(),r.destroy();const a=await this._updatingHandles.addPromise(this._setupTransformOrReshape2DOperation(t,"transform",o,i));if(Pe(a))return;this._setUpdateOperationHandle(a,o)}else this.updateGraphics.add(e),t.graphics=this.updateGraphics.toArray(),t.refresh(),r.resetHistory();this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection: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();0===o.length?r.complete():ge(o)?await r.toggleTool():r.activeComponent.graphics=o,this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"})},toggleTool:async()=>{if(this.updateGraphics.length>1)return;const e=this.updateGraphics.at(0),t=e.geometry;if(null!=t&&("reshape"===r.tool&&"point"===t.type||"transform"===r.tool&&"extent"===t.type))return;let a=null;const s={...this.defaultUpdateOptions,...o,...this.activeUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...o?.reshapeOptions,...this.activeUpdateOptions?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...o?.highlightOptions,...this.activeUpdateOptions?.highlightOptions}};"transform"===r.tool?a=await this._updatingHandles.addPromise(this._getReshape([e],s,i)):"reshape"===r.tool&&(a=await this._updatingHandles.addPromise(this._getBox([e],s,i))),Pe(a)||(r.activeComponent?.destroy(),r.activeComponent=a,r.activeComponent&&(n(p),p=this._getHandlesForComponent(r,s)))}}),s=[i.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(r,e,o),z.WIDGET),i.on("key-down",e=>{if(this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key===B.constraint&&!e.repeat&&r){const e=r.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},z.WIDGET),i.on("key-up",e=>{if(e.key===B.constraint&&r){const e=r.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},z.WIDGET)];let p=this._getHandlesForComponent(r,o);return r}async _getGraphicMover(e,t,o){const{enableMoveAllGraphics:i,highlightOptions:a}=t,r=await this._requireModule(import("../../views/draw/support/GraphicMover.js"));return Pe(r)?r:new r.module.default({enableMoveAllGraphics:i,highlightName:a?.name,highlightsEnabled:!!a?.enabled,indicatorsEnabled:!1,graphics:e,view:o,callbacks:{onGraphicMoveStart:({dx:e,dy:t,graphic:o})=>{this._displayCursor("grabbing"),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-start"},type:"update"})},onGraphicMove:({dx:e,dy:t,graphic:o})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move"},type:"update"}),onGraphicMoveStop:({dx:e,dy:t,graphic:o})=>{this._displayCursor("pointer"),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-stop"},type:"update"})},onGraphicPointerOver:()=>this._displayCursor("move"),onGraphicPointerOut:()=>this._clearCursor()}})}async _getBox(e,t,o){const{enableRotation:i,enableScaling:a,highlightOptions:r,preserveAspectRatio:s}=t,n=await this._requireModule(import("../../views/draw/support/Box.js"));if(Pe(n))return n;const p=this.view?.inputManager?.isModifierKeyDown(B.constraint),l=new n.module.default({graphics:e,enableRotation:i,enableScaling:a,highlightName:r?.name,highlightsEnabled:!!r?.enabled,preserveAspectRatio:!!s!=!!p,layer:this._internalGraphicsLayer,view:o,sketchOptions:this.sketchOptions,callbacks:{onMoveStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onMove:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onMoveStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScaleStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScale:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScaleStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotateStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotate:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotateStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"})}});return l.addHandles(g(()=>[this.activeUpdateOptions?.enableRotation,this.activeUpdateOptions?.enableScaling],([e,o])=>{l.enableRotation=e??t.enableRotation??!0,l.enableScaling=o??t.enableScaling??!0,l.refresh()},y)),l}async _getReshape(e,t,o){const{highlightOptions:i,reshapeOptions:a}=t,r="split"===a?.edgeOperation,s="move"===a?.shapeOperation,n=!!a?.enableCreateCurveFromStraightEdge,p=await this._requireModule(import("../../views/draw/support/Reshape.js"));return Pe(p)?p:new p.module.default({enableMidpoints:r,enableMovement:s,enableCurveOnMidpoint:n,graphic:e[0],highlightName:i?.name,highlightsEnabled:!!i?.enabled,layer:this._internalGraphicsLayer,snappingManager:this.snappingManager,sketchOptions:this.sketchOptions,view:o,callbacks:{onReshapeStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onReshape:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onReshapeStop:({mover:e,type:t})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e,type:t},type:"update"}),onMoveStart:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onMove:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onMoveStop:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onVertexAdd:({added:e,type:t,vertices:o})=>{const i=e.map(e=>M(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=>M(e.geometry));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{removed:i,vertices:o,type:t},type:"update"})}}})}_getHandlesForComponent(e,t){const o=e.activeComponent;if(!o)return[];switch(o.type){case"graphic-mover":return[o.on("graphic-click",({graphic:o,viewEvent:i})=>{i.native?.shiftKey&&t.multipleSelectionEnabled&&(i.stopPropagation(),this._updatingHandles.consumePromise(e.removeFromSelection(o)))}),o.on("graphic-move-start",t=>e.addToHistory(Me(t.allGraphics)))];case"box":return[o.on("graphic-click",o=>this._onTransformOrReshape2DGraphicClick(e,t,o)),o.on("move-start",t=>e.addToHistory(Me(t.graphics))),o.on("rotate-start",t=>e.addToHistory(Me(t.graphics))),o.on("scale-start",t=>e.addToHistory(Me(t.graphics)))];case"reshape":return[o.on("graphic-click",o=>this._onTransformOrReshape2DGraphicClick(e,t,o)),o.on("move-start",t=>e.addToHistory(Me([t.mover]))),o.on("reshape-start",t=>e.addToHistory(Me([t.graphic]))),o.on("vertex-add",t=>e.addToHistory(Me([t.oldGraphic]))),o.on("vertex-remove",t=>e.addToHistory(Me([t.oldGraphic])))];case"move-3d":return[o.events.on("record-undo",({updates:t})=>{e.addToHistory({updates:t})}),o.events.on("move-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move-start"},type:"update"})}),o.events.on("move",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e.dx,dy:e.dy,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move"},type:"update"})}),o.events.on("move-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move-stop"},type:"update"})}),o.events.on("immediate-click",o=>{this._updatingHandles.consumePromise(o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool())})];case"transform-3d":return[o.events.on("record-undo",({updates:t})=>{e.addToHistory({updates:t})}),o.events.on("translate-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-start"},type:"update"})}),o.events.on("translate-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-stop"},type:"update"})}),o.events.on("rotate-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate-start"},type:"update"})}),o.events.on("rotate-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate-stop"},type:"update"})}),o.events.on("scale-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-start"},type:"update"})}),o.events.on("scale-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-stop"},type:"update"})}),o.events.on("translate",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move"},type:"update"})}),o.events.on("rotate",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate"},type:"update"})}),o.events.on("scale",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale"},type:"update"})}),o.events.on("immediate-click",o=>{this._updatingHandles.consumePromise(o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool())})];case"reshape-3d":return[o.events.on("reshape",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e,mover:e.object.graphic},type:"update"})}),o.events.on("move",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e,mover:e.object.graphic},type:"update"})}),o.events.on("vertex-add",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})}),o.events.on("vertex-remove",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})}),o.events.on("immediate-click",o=>{this._updatingHandles.consumePromise(o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool())})]}}_onTransformOrReshape2DGraphicClick(e,t,o){const{graphic:i,viewEvent:a}=o;if(a.native?.shiftKey&&this.hasGraphic(i))return a.stopPropagation(),void this._updatingHandles.consumePromise(e.removeFromSelection(i));t.toggleToolOnClick&&(a.stopPropagation(),this._updatingHandles.consumePromise(e.toggleTool()))}_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)}_getCommonUpdateOperationClickHandlers(e,t,o){return this._updatingHandles.addPromise(this._handleCommonUpdateOperationClick(e,t,o))}async _handleCommonUpdateOperationClick(e,t,o){const i=re(t),a=await t.defer(()=>this._getFirstHit(i));if(null==a)return void(this.cancelUpdateOnClickAway&&e.complete());const r=t.native.shiftKey?this._toggleSelection([a.graphic],e,o):null;if(r)return t.stopPropagation(),void await r;this.updateGraphics.includes(a.graphic)?this._shouldTemporarilyDisablePopup(o)&&t.stopPropagation():e.complete()}async _toggleSelection(e,t,o){const i=!!o.multipleSelectionEnabled;for(const a of e)if(null!=a&&i&&this.hasGraphic(a))return this.updateGraphics.includes(a)?await t.removeFromSelection(a):await t.addToSelection(a)}_getCommonUpdateOperationKeyDownHandlers(e,t){if(!e)return;const o=t.key;o===B.undo&&e.canUndo()?(t.stopPropagation(),e.undo()):o===B.redo&&e.canRedo()?(t.stopPropagation(),e.redo()):o===B.cancel?(t.stopPropagation(),e.cancel()):this.allowDeleteKey&&B.delete.includes(o)&&this._onDeleteKey(t)}_onDeleteKey(e){this._operationHandle&&"update"===this._operationHandle.type&&null!=this.activeComponent&&(e.stopPropagation(),this.delete())}_removeDefaultLayer(){this._internalGraphicsLayer&&(this.view?.map?.remove(this._internalGraphicsLayer),this._internalGraphicsLayer=h(this._internalGraphicsLayer))}_isComponentGraphic(e){const{activeComponent:t}=this;return!(!e||null==t)&&(e.attributes?.esriSketchTool||"draw-2d"===t.type&&t.graphic===e||("box"===t.type||"reshape"===t.type)&&t.isUIGraphic(e))}_clearCursor(){this.removeHandles(be)}_displayCursor(e){this.removeHandles(be),this.view?.container&&null!=e&&this.addHandles(this.view.acquireCursor(e,"high"),be)}_logError(e,t,o){l.getLogger(this).error(new a(e,t,o))}async _requireModule(e){const t=new AbortController;this._moduleLoaderAbortController=t;const o=await e;return this._moduleLoaderAbortController!==t||t.signal.aborted?{requireError:"aborted"}:{module:o}}_emitUndoEvent(e){this.emit("undo",{...e,type:"undo"})}_emitRedoEvent(e){this.emit("redo",{...e,type:"redo"})}_emitDeleteEvent(e){this.emit("delete",{...e,type:"delete"})}_onLayerGraphicsChangeCallback(e){if(null!=this._operationHandle){const{updateGraphics:t}=this;for(const o of e.removed)if(t.includes(o)){if(!(t.length>1)){this._operationHandle.cancel();break}this._updatingHandles.consumePromise(this._operationHandle.removeFromSelection(o))}}}async _setupAdvancedDrawToolIntegrationMaybe(){this.isUsingLegacyCreateTools||this.pluginManager.loaded||await this.pluginManager.loadPlugins()}async _setupDrawTool(e,o,i){if(this.isUsingLegacyCreateTools||!this._pluginManager)return null;const a=this.view,r=await(import("../../views/draw/DrawTool.js"));await this.pluginManager.loadPlugins();const s=await this.pluginManager.makeRenderer({customSymbol:o.graphicSymbol,useTextSymbol:"text"===i}),n=new r.DrawTool({view:a,elevationInfo:this._layerAdapter?.elevationInfo??I("3d"===a.type),hasZ:!!o.hasZ,sketchOptions:this.sketchOptions,renderer:s,defaultZ:o.defaultZ??0,directionOptions:o.directionOptions,snappingManager:this.snappingManager,enableVertexVisuals:"rectangle"!==i&&"circle"!==i,readPluginSetting:(e,t)=>this.settingsManager.getValue(t)});n.addHandles(p(s));const l=new t({...o.graphicProperties,attributes:{...o.graphicProperties?.attributes},symbol:o.graphicSymbol??this._getGraphicSymbolFromTool(i)});return o.graphicSymbol||n.addHandles(g(()=>this._getGraphicSymbolFromTool(i),e=>l.symbol=e)),this._set("createGraphic",l),a.addAndActivateTool(n),n.begin(e),n}get test(){}wait(){return _(()=>!this.updating)}_shouldTemporarilyDisablePopup(e){return this.updateOnGraphicClick||(e?.toggleToolOnClick??!1)}_disablePopup(e){this._shouldTemporarilyDisablePopup(e)&&this.view&&null==this._originalPopupEnabled&&(this._originalPopupEnabled=this.view.popupEnabled,this.view.popupEnabled=!1)}_restorePopup(e){this._shouldTemporarilyDisablePopup(e)&&this.view&&null!=this._originalPopupEnabled&&(this.view.popupEnabled=this._originalPopupEnabled,this._originalPopupEnabled=null)}async _waitViewReady(){const e=this.view;e?(d(this._viewReadyAbortController),this._viewReadyAbortController=new AbortController,await m(_(()=>e?.ready),this._viewReadyAbortController.signal)):this._logMissingView()}_logMissingView(){this._logError("sketch:missing-property",Oe("view"))}_logMissingLayer(){this._logError(Ge,Oe("layer"))}};e([b()],Te.prototype,"_defaultSnappingManager",void 0),e([b()],Te.prototype,"_layerAdapter",null),e([b()],Te.prototype,"_pluginManager",void 0),e([b({readOnly:!0})],Te.prototype,"settingsManager",void 0),e([b()],Te.prototype,"_operationHandle",void 0),e([b({readOnly:!0})],Te.prototype,"_updatingHandles",void 0),e([b({readOnly:!0})],Te.prototype,"_toolTransitionHandles",void 0),e([b()],Te.prototype,"_drawToolSimplifyAbortController",void 0),e([b({readOnly:!0})],Te.prototype,"activeTool",null),e([b()],Te.prototype,"geometrySimplificationInProgress",null),e([b({readOnly:!0})],Te.prototype,"activeCreateToolDrawMode",null),e([b()],Te.prototype,"activeTooltip",null),e([b({types:V})],Te.prototype,"activeFillSymbol",void 0),e([b()],Te.prototype,"activeLineSymbol",void 0),e([b()],Te.prototype,"activeVertexSymbol",void 0),e([b()],Te.prototype,"allowDeleteKey",void 0),e([b({readOnly:!0})],Te.prototype,"createGraphic",null),e([b()],Te.prototype,"defaultCreateOptions",null),e([b()],Te.prototype,"defaultUpdateOptions",null),e([b()],Te.prototype,"activeUpdateOptions",void 0),e([b({type:$,nonNullable:!0})],Te.prototype,"labelOptions",null),e([b()],Te.prototype,"layer",void 0),e([b({types:V})],Te.prototype,"pointSymbol",void 0),e([b({types:V})],Te.prototype,"polygonSymbol",void 0),e([b({types:V})],Te.prototype,"polylineSymbol",void 0),e([b()],Te.prototype,"meshSymbol",void 0),e([b({type:F})],Te.prototype,"textSymbol",null),e([b({type:ee,nonNullable:!0})],Te.prototype,"snappingOptions",null),e([b()],Te.prototype,"snappingManager",null),e([b({readOnly:!0})],Te.prototype,"state",null),e([b()],Te.prototype,"toolTransitionInProgress",null),e([b({type:J,nonNullable:!0})],Te.prototype,"tooltipOptions",null),e([b({readOnly:!0})],Te.prototype,"updateGraphics",void 0),e([b()],Te.prototype,"updateOnGraphicClick",void 0),e([b()],Te.prototype,"cancelUpdateOnClickAway",void 0),e([b()],Te.prototype,"updating",null),e([b()],Te.prototype,"creationMode",void 0),e([b({type:Q,nonNullable:!0})],Te.prototype,"valueOptions",null),e([b({types:V})],Te.prototype,"vertexSymbol",void 0),e([b({value:null})],Te.prototype,"view",null),e([b({constructOnly:!0,type:Y})],Te.prototype,"sketchOptions",void 0),e([b()],Te.prototype,"useLegacyCreateTools",void 0),e([b()],Te.prototype,"isUsingLegacyCreateTools",null),e([b()],Te.prototype,"pluginManager",null),e([b()],Te.prototype,"drawTool",null),e([b()],Te.prototype,"rootPlugins",null),e([b()],Te.prototype,"effectiveAvailablePlugins",null),e([b()],Te.prototype,"firstPluginWithSwappableLeaf",null),e([b()],Te.prototype,"multiplePluginsActive",null),Te=e([w("esri.widgets.Sketch.SketchViewModel")],Te);const Ge="sketch:missing-property",Oe=e=>`Property '${e}' is missing on SketchViewModel.`;function Se(e){return"polygon"===e||"rectangle"===e||"circle"===e}function Ce(e,t){Ee("undo",e.history.undo,e.history.redo,t)}function Ae(e,t){Ee("redo",e.history.redo,e.history.undo,t)}function Ee(e,t,o,i){const a=t.pop();if(!a)return;const r=a.updates,s=[];i.forEach((t,o)=>{const i=r[o];null!=i&&("geometry"in i&&null!=i.geometry&&(s.push({geometry:t.geometry}),t.geometry=i.geometry),"symbol"in i&&null!=i.symbol&&(s.push({symbol:t.symbol}),t.symbol=i.symbol),"undo"in i&&(s.push(i),i[e](t)))}),o.push({updates:s})}function ke(e,t){null!=e&&t.hasGrabbedManipulators&&(e.activeTool=null)}function Me(e){return{updates:e.map(({geometry:e})=>"mesh"===e?.type?{geometry:e.cloneShallow()}:{geometry:e})}}function He(e,t){e.tools?.remove(t),t.destroyed||t.destroy()}function Pe(e){return"requireError"in e&&"aborted"===e.requireError}export{Te as default};
2
+ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{isSome as o}from"../../core/arrayUtils.js";import i from"../../core/Collection.js";import a from"../../core/Error.js";import{EventedAccessor as r}from"../../core/Evented.js";import{makeHandle as s,drainHandles as n,destroyHandle as p}from"../../core/handleUtils.js";import"../../core/has.js";import l from"../../core/Logger.js";import{destroyMaybe as h,abortMaybe as d}from"../../core/maybe.js";import{createAbortError as c,ignoreAbortErrors as u,whenOrAbort as m}from"../../core/promiseUtils.js";import{watch as g,syncAndInitial as y,on as v,when as f,whenOnce as _}from"../../core/reactiveUtils.js";import{property as b,subclass as w}from"../../core/accessorSupport/decorators.js";import{trackAccess as T}from"../../core/accessorSupport/tracking.js";import{SimpleObservable as G}from"../../core/accessorSupport/tracking/SimpleObservable.js";import{UpdatingHandles as O}from"../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as S}from"../../geometry/ellipsoidUtils.js";import{canProjectWithoutEngine as C,isLoaded as A,load as E,project as M}from"../../geometry/projectionUtils.js";import{geometryToCoordinates as H}from"../../geometry/support/coordsUtils.js";import{equals as k}from"../../geometry/support/spatialReferenceUtils.js";import P from"../../layers/GraphicsLayer.js";import{isIntegratedMeshLayer as D}from"../../layers/support/layerUtils.js";import{getEffectiveElevationInfo as I}from"../../support/elevationInfoUtils.js";import U from"../../symbols/FillSymbol3DLayer.js";import j from"../../symbols/MeshSymbol3D.js";import R from"../../symbols/SimpleFillSymbol.js";import x from"../../symbols/SimpleLineSymbol.js";import L from"../../symbols/SimpleMarkerSymbol.js";import F from"../../symbols/TextSymbol.js";import{symbolTypes as V}from"../../symbols/support/typeUtils.js";import{isSupportedObjectResultMessage as W}from"../../views/3d/interactive/editingTools/isSupportedObjectUtils.js";import{isSupportedObject as K}from"../../views/3d/interactive/editingTools/move/isSupportedObject.js";import{isSupportedObject as Z}from"../../views/3d/interactive/editingTools/reshape/isSupportedObject.js";import{isSupportedGraphic as q}from"../../views/3d/interactive/editingTools/transform/isSupportedGraphic.js";import{addUniqueLayer as N}from"../../views/draw/support/layerUtils.js";import{ViewEventPriorities as z}from"../../views/input/InputManager.js";import{sketchKeys as B}from"../../views/interactive/keybindings.js";import $ from"../../views/interactive/sketch/SketchLabelOptions.js";import Y from"../../views/interactive/sketch/SketchOptions.js";import J from"../../views/interactive/sketch/SketchTooltipOptions.js";import Q from"../../views/interactive/sketch/SketchValueOptions.js";import{SnappingManager as X}from"../../views/interactive/snapping/SnappingManager.js";import ee from"../../views/interactive/snapping/SnappingOptions.js";import{setupSnappingToggleHandles as te}from"../../views/interactive/snapping/snappingUtils.js";import{GeometryWorkerHandle as oe}from"../../views/support/GeometryWorkerHandle.js";import{defaultHighlightName as ie}from"../../views/support/HighlightDefaults.js";import{findFirstGraphicHit as ae}from"../../views/support/hitTestSelectUtils.js";import{createScreenPointFromEvent as re}from"../../views/support/screenUtils.js";import se from"./adapters/layer/GraphicsLayerAdapter.js";import ne from"./adapters/layer/MapNotesLayerAdapter.js";import{CreateOperationHandle as pe,DrawToolOperationHandle as le,UpdateOperationHandle as he}from"./support/OperationHandle.js";import{PluginManager as de}from"./support/PluginManager.js";import{SettingsManager as ce}from"./support/SettingsManager.js";import{getLegacyTool as ue,isCompletelyDegenerate as me,graphicsHaveTooFewVerticesForBox as ge,getModeFromCreateOptions as ye,getDrawToolGeometryTypeFromCreateTool as ve}from"./support/sketchUtils.js";const fe={defaultZ:0},_e={reshapeOptions:{edgeOperation:"split",shapeOperation:"move",vertexOperation:"move",enableCreateCurveFromStraightEdge:!0},enableMoveAllGraphics:!0,enableRotation:!0,enableScaling:!0,multipleSelectionEnabled:!0,preserveAspectRatio:!1,toggleToolOnClick:!0,enableZ:!0,highlightOptions:{enabled:!0,name:ie},tool:"transform"},be=Symbol(),we=Symbol();let Te=class extends r{constructor(e){super(e),this._defaultSnappingManager=null,this._internalGraphicsLayer=new P({listMode:"hide",internal:!0,title:"SVM Internal"}),this._pluginManager=new de({sketchViewModel:this}),this.settingsManager=new ce({availablePlugins:()=>this.pluginManager.visiblePluginsFlat}),this._operationHandle=null,this._updatingHandles=new O,this._toolTransitionHandles=new O,this._drawToolSimplifyAbortController=null,this._geometryWorkerHandle=new oe,this._viewHandlesKey="viewHandles",this.activeFillSymbol=null,this.activeLineSymbol=null,this.activeVertexSymbol=null,this.allowDeleteKey=!0,this.activeUpdateOptions=null,this.layer=null,this.pointSymbol=new L({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.polygonSymbol=new R({color:[150,150,150,.2],outline:{color:[50,50,50],width:2}}),this.polylineSymbol=new x({color:[130,130,130,1],width:2}),this.meshSymbol=new j({symbolLayers:new i([new U])}),this.updateGraphics=new i,this.updateOnGraphicClick=!0,this.cancelUpdateOnClickAway=!0,this.creationMode="single",this.vertexSymbol=new L({style:"circle",size:6,color:[255,255,255],outline:{color:[50,50,50],width:1}}),this.sketchOptions=new Y,this.useLegacyCreateTools=!0,this._moduleLoaderAbortController=null,this._viewReadyAbortController=null,this._sketchContinuationFlag=!1,this._onLayerAdapterChange=async()=>{const{_layerAdapter:e}=this;if(this.removeHandles(we),!e)return;const t=[e.onGraphicsChange(e=>this._onLayerGraphicsChangeCallback(e)),g(()=>e.elevationInfo,e=>{e!==this._internalGraphicsLayer.elevationInfo&&(this.cancel(),this._internalGraphicsLayer&&(this._internalGraphicsLayer.elevationInfo=e))},y)].filter(o);this.addHandles(t,we)},this._originalPopupEnabled=null,this.defaultCreateOptions=fe,this.defaultUpdateOptions=_e,this.snappingOptions=e?.snappingManager?.options??e?.snappingOptions??new ee,this.textSymbol=new F({text:"text"})}initialize(){this._updatingHandles.consumePromise(this._setupAdvancedDrawToolIntegrationMaybe()),this.addHandles([v(()=>this.view?.map?.layers,"change",e=>{this.layer&&e.removed.includes(this.layer)&&this.cancel()}),g(()=>this._layerAdapter,()=>this._onLayerAdapterChange(),y),g(()=>this.view,e=>{this._defaultSnappingManager=h(this._defaultSnappingManager),e&&(this.snappingManager||(this._defaultSnappingManager=new X({view:e,options:this.snappingOptions})),"2d"===e.type?(import("../../views/2d/interactive/editingTools.js"),this._updatingHandles.consumePromise(this._setupAdvancedDrawToolIntegrationMaybe())):"3d"===e.type&&(import("../../views/3d/interactive/editingTools.js"),import("../../views/3d/layers/GraphicsLayerView3D.js")))},y),g(()=>this.view?.spatialReference,(e,t)=>{e&&t&&!e.equals(t)&&this.cancel()})]),te(this)}destroy(){this.cancel(),this._removeDefaultLayer(),this._defaultSnappingManager=h(this._defaultSnappingManager),this._set("snappingManager",null),this._set("view",null),this._updatingHandles.destroy(),this._toolTransitionHandles.destroy(),this._drawToolSimplifyAbortController=d(this._drawToolSimplifyAbortController),this._geometryWorkerHandle.destroy(),this._pluginManager?.destroy(),this.emit("destroy")}get _layerAdapter(){const{layer:e}=this;switch(e?.type){case"graphics":return new se(e);case"map-notes":return new ne(e);default:return null}}get activeTool(){return this._operationHandle?.tool??null}get geometrySimplificationInProgress(){return!!this._drawToolSimplifyAbortController}get activeCreateToolDrawMode(){const e=this._operationHandle;if("create"===e?.type&&e.activeComponent&&"mode"in e.activeComponent)return e.activeComponent.mode;if("draw-2.0"===e?.activeComponent?.type){const t=e.activeComponent.pluginStack.map(e=>e.configuration).filter(o).toArray();if(t.length>0)return this._pluginManager?.getDrawingModeEquivalentToPluginStack(t)}return null}get activeTooltip(){const{activeComponent:e,destroyed:t}=this,o=!t&&e&&"tooltip"in e?e.tooltip:null;return o?.visible?o:null}get activeComponent(){return this._operationHandle?.activeComponent??null}get createGraphic(){return null==this.activeComponent||"draw-3d"!==this.activeComponent.type&&"draw-2d"!==this.activeComponent.type?this._get("createGraphic"):this.activeComponent.graphic}get defaultCreateOptions(){return this._get("defaultCreateOptions")}set defaultCreateOptions(e){this._set("defaultCreateOptions",{...fe,...e})}get defaultUpdateOptions(){return this._get("defaultUpdateOptions")}set defaultUpdateOptions(e){this._set("defaultUpdateOptions",{..._e,...e,reshapeOptions:{..._e.reshapeOptions,...e?.reshapeOptions},highlightOptions:{..._e.highlightOptions,...e?.highlightOptions}})}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=e}get textSymbol(){return this._get("textSymbol")}set textSymbol(e){this._set("textSymbol",e)}get snappingOptions(){return this.snappingManager?.options??this._get("snappingOptions")}set snappingOptions(e){null!=this._defaultSnappingManager&&(this._defaultSnappingManager.options=e),this._set("snappingOptions",e)}get snappingManager(){return this._isOverridden("snappingManager")&&this._get("snappingManager"),this._defaultSnappingManager}set snappingManager(e){if(e)this._isOverridden("snappingManager")||(this._defaultSnappingManager=h(this._defaultSnappingManager)),this._override("snappingManager",e);else{const{view:e}=this;!this._defaultSnappingManager&&e&&(this._defaultSnappingManager=new X({options:this.snappingOptions,view:e})),this._clearOverride("snappingManager")}}get state(){const e=!(!this.view?.ready||!this.layer),t=this._operationHandle;return e&&t?"active":e?"ready":"disabled"}get toolTransitionInProgress(){return this._toolTransitionHandles.updating||!!this.drawTool?.lifecycleManager.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get updating(){return this.toolTransitionInProgress||this.activeComponent&&"updating"in this.activeComponent&&this.activeComponent.updating||!!(this._updatingHandles.updating||this._drawToolSimplifyAbortController||this.snappingManager?.updating||this.drawTool?.updating)}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}get view(){return this._get("view")}set view(e){const t=this._get("view");if(t){const{container:e,map:o}=t;e&&this._clearCursor(),o?.remove(this._internalGraphicsLayer),this.removeHandles(this._viewHandlesKey),this.cancel()}const o="view-ready";this.removeHandles(o),e&&this.addHandles(f(()=>e.ready,t=>{this.removeHandles(this._viewHandlesKey),t&&this.addHandles(this._generateViewHandles(e),this._viewHandlesKey)},y),o),this._set("view",e),this._updatingHandles.consumePromise(this._setupAdvancedDrawToolIntegrationMaybe())}get isUsingLegacyCreateTools(){return this.useLegacyCreateTools||"2d"!==this.view?.type}get pluginManager(){return this._pluginManager}get drawTool(){return"draw-2.0"!==this.activeComponent?.type?null:this.activeComponent}get rootPlugins(){return this._pluginManager?.availablePlugins}set rootPlugins(e){this._overrideIfSome("rootPlugins",e)}get effectiveAvailablePlugins(){if(this.isUsingLegacyCreateTools)return null;const e=this.view?.type??"2d",{firstPluginWithSwappableLeaf:t}=this;return t?t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e)):this.rootPlugins?.filter(t=>!t.excludedViews?.includes(e)).filter(o)??[]}get firstPluginWithSwappableLeaf(){const e=this.view?.type??"2d",t=this.drawTool?.pluginStack.toArray().map(e=>e.configuration).findLast(t=>null!=t&&!t.hidden&&t.availableDownstreamPlugins&&t.availableDownstreamPlugins.filter(t=>!t.excludedViews?.includes(e))?.length>1);return t}get multiplePluginsActive(){return!!this.drawTool&&this.drawTool.pluginStack.length>1}addGraphic(e){this._layerAdapter?.add(e)}addGraphics(e){this._layerAdapter?.addMany(e)}hasGraphic(e){return!!this._layerAdapter?.has(e)}removeGraphic(e){this._layerAdapter?.remove(e)}removeGraphics(e){this._layerAdapter?.removeMany(e)}removeAllGraphics(){this._layerAdapter?.removeAll()}cancel(){this._moduleLoaderAbortController=d(this._moduleLoaderAbortController),this._viewReadyAbortController=d(this._viewReadyAbortController),this._drawToolSimplifyAbortController=d(this._drawToolSimplifyAbortController),this._sketchContinuationFlag=!0,this._operationHandle?.cancel()}complete(){this._operationHandle?.complete()}delete(){const{state:e,updateGraphics:t}=this;if("active"===e&&t.length){const{activeTool:e}=this,o=t.toArray();this.removeGraphics(o),this.cancel(),this._emitDeleteEvent({graphics:o,tool:e})}}duplicate(){if("active"===this.state&&this.updateGraphics.length){const e=this.updateGraphics.map(e=>e.clone()).toArray();return this.addGraphics(e),this.emit("duplicate",{graphics:e,type:"duplicate"}),e}return[]}async create(e,t){return this._toolTransitionHandles.addPromise(this._create(e,t))}async _create(e,t){this.cancel(),await this._updatingHandles.addPromise(this._waitViewReady());const{view:o,layer:i}=this;if(!o||"disabled"===this.state)throw i||this._logMissingLayer(),c();if(null!=o.activeTool&&(o.activeTool=null),!e)return void this._logError("sketch:missing-parameter","Missing parameter 'tool'.");N(o,this._internalGraphicsLayer);const a=await this._updatingHandles.addPromise(this._setupCreateOperation(e,t));if(null==a||this.destroyed)return void o.map?.remove(this._internalGraphicsLayer);const r=ue(e),s=()=>{if(a===this._operationHandle){const o=this.createGraphic,i=this._operationHandle.cancelled;if(this._operationHandle.destroy(),this._operationHandle=null,this._set("createGraphic",null),this.view?.map?.remove(this._internalGraphicsLayer),a.cancelled||null==o||this.addGraphic(o),this._sketchContinuationFlag=!1,this.emit("create",{graphic:o,state:i?"cancel":"complete",tool:r??"point",toolEventInfo:null,type:"create"}),i||this._sketchContinuationFlag)return;const{creationMode:s}=this;if("continuous"===s){if(t?.geometryToPlace)return;this._updatingHandles.consumePromise(u(this.create(e,t)))}else"update"===s&&o&&this._updatingHandles.consumePromise(u(this.update([o])))}};a.on("complete",s),this._operationHandle=a,o.ready&&o.focus()}async place(e,t){return await e.load(),this.create("mesh",{mode:"click",hasZ:e.hasZ,geometryToPlace:e,...t})}async update(e,t){return this._toolTransitionHandles.addPromise(this._update(e,t))}async _update(e,t){this.cancel(),await this._updatingHandles.addPromise(this._waitViewReady());const{layer:o,view:i,state:a}=this;if(!i||"disabled"===a)throw o||this._logMissingLayer(),c();null!=i.activeTool&&(i.activeTool=null);const r=Array.isArray(e)?e:[e];if(null==e||!r?.length)return void this._logError("sketch:missing-parameter","Missing parameter 'graphics'.");if(r.some(e=>this.hasGraphic(e)?null==e.geometry&&(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics with an unsupported geometry."),!0):(this._logError("sketch:invalid-parameter","Parameter 'graphics' contains one or more graphics missing from the supplied GraphicsLayer."),!0)))return;const s=await this._updatingHandles.addPromise(this._setupUpdateOperation(r,t));this.destroyed||null==s||Pe(s)||(N(i,this._internalGraphicsLayer),this._setUpdateOperationHandle(s,t),this.emit("update",{graphics:r,state:"start",aborted:!1,tool:s.tool,toolEventInfo:null,type:"update"}))}async _updateSpatialReference(e){const t=this.view;if(t){e=Array.isArray(e)?e:[e];for(const o of e)null==o.geometry||"mesh"===o.geometry.type||k(o.geometry.spatialReference,t.spatialReference)||(C(o.geometry.spatialReference,t.spatialReference)||A()||await E(),o.geometry=M(o.geometry,t.spatialReference))}else this._logMissingView()}undo(){this.canUndo()&&this._operationHandle?.undo()}redo(){this.canRedo()&&this._operationHandle?.redo()}canUndo(){return!!this._operationHandle?.canUndo()}canRedo(){return!!this._operationHandle?.canRedo()}toggleUpdateTool(){this._updatingHandles.consumePromise(this._operationHandle?.toggleTool())}async _getFirstHit(e){const t=this.view;if(!t)return this._logMissingView(),null;if("2d"===t.type){const o=[];t.map.allLayers.forEach(e=>{"vector-tile"!==e.type&&"imagery"!==e.type||o.push(e)});const i=await t.hitTest(e,{exclude:o});return ae(i.results)}const o=[t.map.ground];t.map.allLayers.forEach(e=>{D(e)&&o.push(e)});const i=await t.hitTest(e,{exclude:o});if(i.results.length>0){const e=i.results[0];if(null!=e&&"graphic"===e.type&&e.graphic&&(!i.ground.mapPoint||t.map.ground.opacity<1||i.ground.distance-(e.distance??0)>-Math.min(3*i.ground.distance,"global"===t.viewingMode?S(t.renderCoordsHelper.spatialReference).radius/t.renderCoordsHelper.unitInMeters:Number.POSITIVE_INFINITY)))return e}return null}_generateViewHandles(e){return[e.on("immediate-click",async e=>{const t="active"===this.state&&"create"===this._operationHandle?.type;"disabled"!==this.state&&!t&&this.updateOnGraphicClick&&await this._updatingHandles.addPromise(this._handleImmediateClick(e))},z.WIDGET)]}async _handleImmediateClick(e){const t=await e.defer(()=>this._getFirstHit(re(e)));let o=null;if(null!=t){const i=t.graphic;this.updateGraphics.includes(i)||this.hasGraphic(i)?(e.stopPropagation(),o=i):"2d"!==this.view?.type||this._isComponentGraphic(i)||"active"!==this.state||this.cancel()}else"active"===this.state&&this.cancelUpdateOnClickAway&&this.cancel();null==o||this.updateGraphics.includes(o)||await this.update([o],{...this.defaultUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions}})}async _setupCreateOperation(e,t){const o=this.view;if(!o)return this._logMissingView(),null;const i={hasZ:"3d"===o.type,...this.defaultCreateOptions,...t},a="string"==typeof e?this.pluginManager?.getPluginsEquivalentToCreateTool(e,i.mode):e,r=ue(e);if(a&&!this.isUsingLegacyCreateTools){const e=await this._setupDrawTool(a,i,r??"polyline");if(e)return this._setupDrawToolOperationHandle(e,r??"point")}if(!r)return null;const s=await this._setupDrawGraphicTool(r,o,i);return null==s?null:(o.tools.add(s),o.activeTool=s,this._setupCreateOperationHandle(s,r))}async _setupDrawGraphicTool(e,t,o){if("multipoint"===e&&"3d"===t.type)return this._logError("sketch:create","Multipoint geometries are not supported in SceneView."),null;if(!t)return this._logMissingView(),null;const{cursor:i,defaultZ:a,hasZ:r,geometryToPlace:s,graphicProperties:n,mode:p,preserveAspectRatio:l}=o,h=ye(p,e),d=ve(e),c=o?.optionsPerTool?.has(e)?o.optionsPerTool.get(e):{},u=c?.preserveAspectRatio??l??"rectangle"!==e,m={centered:"rectangle"!==e&&!("circle"===e&&!u),cursor:i,defaultZ:a,forceUniformSize:u,graphicProperties:{...n,attributes:{...n?.attributes}},geometryToPlace:s,geometryType:d,mode:h,graphicSymbol:o.graphicSymbol??this._getGraphicSymbolFromTool(e),hasZ:r,snappingManager:this.snappingManager,snapToScene:!1,view:t,...c};return"2d"===t.type?this._makeDrawGraphicTool2D(m):this._makeDrawGraphicTool3D(m)}async _makeDrawGraphicTool2D(e){const t=await this._requireModule(import("../../views/2d/interactive/editingTools.js"));return Pe(t)||this.destroyed?null:new t.module.DrawGraphicTool2D({...e,activeVertexSymbol:this.activeVertexSymbol,regularVerticesSymbol:this.vertexSymbol,activeLineSymbol:this.activeLineSymbol,activeFillSymbol:Se(e.geometryType)?this.activeFillSymbol:null,toolOptions:this.sketchOptions})}async _makeDrawGraphicTool3D(e){const t=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));return Pe(t)||this.destroyed?null:new t.module.DrawGraphicTool3D({...e,elevationInfo:this._layerAdapter?.elevationInfo,snapToScene:!0,toolOptions:this.sketchOptions})}_setupCreateOperationHandle(e,t){const o=this.view;if(!o)return this._logMissingView(),null;let i=null;const a=e.forceUniformSize,r=e.centered,p=new G,l=[s(()=>p.destroy()),o.on("key-down",t=>{if(t.key===B.pan)t.stopPropagation(),t.repeat||(e.enabled=!1);else if(t.key===B.complete)t.stopPropagation(),e.completeCreateOperation();else if(t.key!==B.vertexAdd||t.repeat)t.key===B.undo?(t.stopPropagation(),h.undo()):t.key===B.redo?(t.stopPropagation(),h.redo()):t.key!==B.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType||t.repeat?t.key===B.center&&(t.repeat||(e.centered=!r,t.stopPropagation())):(e.forceUniformSize=!a,t.stopPropagation());else{const o=e.drawOperation.geometryType;"polyline"!==o&&"polygon"!==o&&"multipoint"!==o||(t.stopPropagation(),e.drawOperation.commitStagedVertex())}},z.WIDGET),o.on("key-up",t=>{t.key===B.pan?e.enabled=!0:t.key!==B.constraint||"rectangle"!==e.geometryType&&"circle"!==e.geometryType?t.key===B.center&&(e.centered=r,t.stopPropagation()):(e.forceUniformSize=a,t.stopPropagation())},z.WIDGET),e.on("vertex-update",()=>{p.notify()}),e.on("vertex-add",t=>{switch(p.notify(),i=null==i?"start":"active",t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:i,tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[e.graphic],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[e.graphic],tool:e.geometryType})}}),e.on("cursor-update",t=>{e.drawOperation.numCommittedVertices>0&&this.emit("create",{graphic:e.graphic,state:"active",tool:this.activeTool,toolEventInfo:{coordinates:t.vertices[0].coordinates,type:"cursor-update"},type:"create"})}),e.on("vertex-remove",t=>{switch(p.notify(),t.operation){case"apply":this.emit("create",{graphic:e.graphic,state:"active",tool:this.activeTool,toolEventInfo:t,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[e.graphic],tool:e.geometryType});break;case"redo":this._emitRedoEvent({graphics:[e.graphic],tool:e.geometryType})}}),e.on("complete",e=>{this._set("createGraphic",e.graphic),i="complete",e.aborted?h&&h.cancel():h&&h.complete()}),g(()=>this._getGraphicSymbolFromTool(t),t=>{e.graphicSymbol=t})],h=new pe({activeComponent:e,type:"create",onEnd:()=>{n(l),o.tools?.remove(e)},undo:()=>{e.canUndo&&e.undo()},redo:()=>{e.canRedo&&e.redo()},canUndo:()=>(T(p),e.canUndo),canRedo:()=>(T(p),e.canRedo)});return h}_setupDrawToolOperationHandle(e,t){const i=this.view;if(!i)return this._logMissingView(),null;let a=null;const r=[i.on("key-down",t=>{t.key===B.pan&&(t.stopPropagation(),t.repeat||(e.editable=!1))},z.WIDGET),i.on("key-up",t=>{t.key===B.pan&&(e.editable=!0)},z.WIDGET),e.on("before-vertex-add",t=>{const o=e.mostUpstreamPlugin?.configuration;if(o&&"legacyCreateTool"in o&&("point"===o?.legacyCreateTool||"text"===o.legacyCreateTool)){const e=t.detail.originalEvent;return void(e&&"key"in e&&e.key===B.vertexAdd&&t.preventDefault())}}),e.on("before-complete",t=>{const o=e.getGeometryIfCompleted();(!o||me(o))&&t.preventDefault()}),e.on(["vertex-add","vertex-remove"],i=>{switch(this.createGraphic&&(this.createGraphic.geometry=e.getGeometryIfCompleted()),a=null==a&&"vertex-remove"!==i.type?"start":"active",i.operation){case"apply":this.emit("create",{graphic:this.createGraphic,state:a,tool:this.activeTool,toolEventInfo:i,type:"create"});break;case"undo":this._emitUndoEvent({graphics:[this.createGraphic].filter(o),tool:t});break;case"redo":this._emitRedoEvent({graphics:[this.createGraphic].filter(o),tool:t})}}),e.on("cursor-update",t=>{this.createGraphic&&(this.createGraphic.geometry=e.unprocessedGeometry),(t.vertices[0]?.vertexIndex>0||t.vertices[0]?.componentIndex>0)&&this.emit("create",{graphic:this.createGraphic,state:"active",tool:this.activeTool,toolEventInfo:{coordinates:t.vertices[0].coordinates,type:"cursor-update"},type:"create"})}),e.on("complete",async({geometry:t,isSimple:o})=>{const i=this.createGraphic,a=!!t&&"mesh"!==t.type&&"extent"!==t.type&&!o;if(i&&(i.geometry=o?t:e.unprocessedGeometry??t),a&&i){this._internalGraphicsLayer.add(this.createGraphic);const e=new AbortController;this._drawToolSimplifyAbortController?.abort(),this._drawToolSimplifyAbortController=e,await this._updatingHandles.addPromise(u(this._finalizeDrawToolCompletion({abortController:e,geometry:t,graphic:i,handle:s})))}else s.complete()})],s=new le({activeComponent:e,type:"create",onEnd:()=>{n(r),i.tools.remove(e)},undo:()=>e.undo(),redo:()=>e.redo(),canUndo:()=>e.canUndo,canRedo:()=>e.canRedo});return r.push(e.on("cancel",()=>{this._drawToolSimplifyAbortController=d(this._drawToolSimplifyAbortController),s.cancel()})),s}async _finalizeDrawToolCompletion({abortController:e,geometry:t,graphic:o,handle:i}){const a=this.view?.acquireCursor("progress","high");a&&this.addHandles(a);const r=()=>!!e.signal.aborted&&(o&&(this._layerAdapter?.remove(o),this._internalGraphicsLayer?.remove(o)),this._set("createGraphic",null),!0);try{const a=await this._geometryWorkerHandle.simplify(t,e.signal);if(r())return;o.geometry=a??t,this._internalGraphicsLayer?.remove(o),i.complete()}finally{a?.remove(),this._drawToolSimplifyAbortController===e&&(this._drawToolSimplifyAbortController=null)}}_getGraphicSymbolFromTool(e){switch(e){case"point":case"multipoint":return this.pointSymbol;case"polyline":case"freehandPolyline":return this.polylineSymbol;case"circle":case"rectangle":case"polygon":case"freehandPolygon":return this.polygonSymbol;case"mesh":return this.meshSymbol;case"text":return this.textSymbol}}async _setupUpdateOperation(e,t){const{view:o}=this;if(!o)return this._logMissingView(),null;const i={...this.defaultUpdateOptions,...t,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...t?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...t?.highlightOptions}};this.activeUpdateOptions=i;let a=i.tool??_e.tool;if(this.removeGraphics(e),this.addGraphics(e),"3d"===o.type){if(0===e.length)return null;switch(a){case"move":return this._setupMove3DOperation(e,i,o,a);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupReshape3DOperation(e[0],i,o);case"transform":return this._setupGraphicTransform3DOperation(e,i,o)}}switch(a){case"move":return this._setupMove2DOperation(e,i,o);case"reshape":return e.length>1?(this._logError("sketch:reshape-multiple","Reshape operation does not support multiple graphics."),null):this._setupTransformOrReshape2DOperation(e,a,i,o);case"transform":return ge(e)&&(a="reshape"),this._setupTransformOrReshape2DOperation(e,a,i,o)}}async _setupMove3DOperation(e,t,o,i,a=!1){const r=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Pe(r))return r;const{ManipulatedObject3DGraphic:s,MoveTool3D:p}=r.module,l=new Map,h=()=>{l.forEach(e=>e.destroy()),l.clear()};for(const n of e){const e=new s({view:o,graphic:n}),t=K(e);if(0!==t)return h(),this._logError("sketch:move",`Move operation not supported for provided graphic(s) (${W(t)}).`),null;l.set(n,e)}const d=new p({view:o,enableZ:t.enableZ,snappingManager:this.snappingManager,toolOptions:this.sketchOptions});o.tools.add(d),d.objects.addMany(Array.from(l.values())),a||this.updateGraphics.addMany(e);const c=[],u=new he({activeComponent:d,tool:i,type:"update",onEnd:()=>{n(c),ke(o,d),h()},undo:()=>{Me(this.view,d),Ce(u,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{Ae(u,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:async e=>{this.updateGraphics.push(e);const t=new s({view:o,graphic:e});l.set(e,t),d.objects.push(t),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection:async e=>{const t=this.updateGraphics.indexOf(e);if(u.history.undo.forEach(e=>e.updates.splice(t,1)),u.history.redo.forEach(e=>e.updates.splice(t,1)),this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0===this.updateGraphics.length)return void u.complete();const o=l.get(e);o&&(d.objects.remove(o),o.destroy(),l.delete(e))},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;if("transform"!==i)return;const e=this.updateGraphics.at(0),a=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,o,!0));a&&!Pe(a)&&(u.onEnd(),u.destroy(),this._setUpdateOperationHandle(a,t))}});return c.push(...this._getHandlesForComponent(u,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(u,e,t),z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(u,e)},z.WIDGET)),u}_setupGraphicTransform3DOperation(e,t,o,i=!1){if(1===e.length&&0===q(e[0])){const a=e[0],r=a.geometry;if(null!=r&&("point"===r.type||"mesh"===r.type))return this._setupPointTransform3DOperation(a,t,o);if(null!=r&&("polygon"===r.type||"polyline"===r.type))return this._setupPolyTransform3DOperation(a,t,o,i)}return this._setupMove3DOperation(e,t,o,"transform",i)}async _setupPointTransform3DOperation(e,t,o){const i="transform",{enableRotation:a,enableScaling:r,enableZ:s}=t,p=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Pe(p))return p;const{TransformTool3D:l,ManipulatedObject3DGraphic:h}=p.module,d=new h({graphic:e,view:o}),c=new l({object:d,view:o,enableRotation:a,enableScaling:r,enableZ:s,snappingManager:this.snappingManager,toolOptions:this.sketchOptions});o.tools.add(c),this.updateGraphics.add(e);const u=[],m=new he({activeComponent:c,tool:i,type:"update",onEnd:()=>{n(u),ke(o,c),d.destroy()},undo:()=>{Me(this.view,c),Ce(m,this.updateGraphics.toArray()),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:i})},redo:()=>{Ae(m,this.updateGraphics.toArray()),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:i})},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),m.onEnd(),m.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Pe(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:async e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),m.complete()},toggleTool:async()=>{}});return u.push(...this._getHandlesForComponent(m,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(m,e,t),z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(m,e)},z.WIDGET)),m}async _setupPolyTransform3DOperation(e,t,o,i=!1){const a="transform",{enableRotation:r,enableScaling:s,enableZ:p,preserveAspectRatio:l}=t,h=await this._requireModule(import("../../views/3d/interactive/editingTools.js"));if(Pe(h))return h;const{ManipulatedObject3DGraphic:d,ExtentTransformTool:c}=h.module,u=this.view?.inputManager?.isModifierKeyDown(B.constraint),m=new d({view:o,graphic:e}),g=new c({object:m,view:o,enableRotation:r,enableScaling:s,enableZ:p,preserveAspectRatio:!!l!=!!u,toolOptions:this.sketchOptions});o.tools.add(g),i||this.updateGraphics.add(e);const y=[],v=new he({activeComponent:g,tool:a,type:"update",onEnd:()=>{n(y),ke(o,g),m.destroy()},canUndo:()=>!g.destroyed&&g.canUndo,undo:()=>{g.destroyed||(g.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},canRedo:()=>!g.destroyed&&g.canRedo,redo:()=>{g.destroyed||(g.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),v.onEnd(),v.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Pe(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:async e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),v.complete()},toggleTool:async()=>{if(1!==this.updateGraphics.length||!1===t.toggleToolOnClick)return;const i=await this._updatingHandles.addPromise(this._setupReshape3DOperation(e,t,o,!0));i&&!Pe(i)&&(v.onEnd(),v.destroy(),this._setUpdateOperationHandle(i,t))}});return y.push(...this._getHandlesForComponent(v,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(v,e,t),z.WIDGET),o.on("key-down",e=>this._getCommonUpdateOperationKeyDownHandlers(v,e),z.WIDGET),o.on("key-down",e=>{e.key!==B.constraint||e.repeat||(g.preserveAspectRatio=!g.preserveAspectRatio,e.stopPropagation())},z.WIDGET),o.on("key-up",e=>{e.key===B.constraint&&(g.preserveAspectRatio=!g.preserveAspectRatio,e.stopPropagation())},z.WIDGET)),v}async _setupMove2DOperation(e,t,o){const i="move";this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const a=await this._updatingHandles.addPromise(this._getGraphicMover(e,t,o));if(Pe(a))return a;const r=new he({activeComponent:a,tool:i,type:"update",onEnd:()=>{this._clearCursor(),n(l),n(p),a.destroy(),this._internalGraphicsLayer?.removeMany([...this.updateGraphics.toArray()])},undo:()=>{const e=this.updateGraphics.toArray();Ce(r,e),r.refreshComponent(),this._emitUndoEvent({graphics:e,tool:i})},redo:()=>{const e=this.updateGraphics.toArray();Ae(r,e),r.refreshComponent(),this._emitRedoEvent({graphics:e,tool:i})},addToSelection:async e=>{await this._updatingHandles.addPromise(this._updateSpatialReference(e)),this.updateGraphics.push(e),a.graphics=this.updateGraphics.toArray(),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection: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();this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),0!==this.updateGraphics.length?a.graphics=o:r.complete()}});let s=!1;const p=[o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(r,e,t),z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key!==B.constraint||e.repeat||(s=!0,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)},z.WIDGET),o.on("key-up",e=>{e.key===B.constraint&&s&&(s=!1,a.enableMoveAllGraphics=!a.enableMoveAllGraphics)},z.WIDGET)],l=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(Pe(r))return r;const{ManipulatedObject3DGraphic:s,ReshapeTool3D:p}=r.module,l=new s({view:o,graphic:e}),h=Z(l);if(0!==h)return l.destroy(),this._logError("sketch:reshape",`Reshape operation not supported for provided graphic(s) (${W(h)}).`),null;const d=t.reshapeOptions,c=new p({view:o,object:l,enableZVertex:t.enableZ&&"move"===d?.vertexOperation,enableZShape:t.enableZ&&"move"===d?.shapeOperation,enableMoveObject:"move"===d?.shapeOperation||"move-xy"===d?.shapeOperation,enableMidpoints:"split"===d?.edgeOperation,enableEdgeOffset:"offset"===d?.edgeOperation,snappingManager:this.snappingManager,toolOptions:this.sketchOptions});o.tools.add(c),i||this.updateGraphics.add(l.graphic);const u=[],m=new he({activeComponent:c,tool:a,type:"update",onEnd:()=>{n(u),ke(o,c),l.destroy()},canUndo:()=>!c.destroyed&&c.canUndo,undo:()=>{c.destroyed||(c.undo(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},canRedo:()=>!c.destroyed&&c.canRedo,redo:()=>{c.destroyed||(c.redo(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:a}))},addToSelection:async e=>{this.updateGraphics.add(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"}),m.onEnd(),m.destroy();const i=await this._updatingHandles.addPromise(this._setupMove3DOperation(this.updateGraphics.toArray(),t,o,"transform",!0));Pe(i)||this._setUpdateOperationHandle(i,t)},removeFromSelection:async e=>{this.updateGraphics.remove(e),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"}),m.complete()},toggleTool:async()=>{if(!1===t.toggleToolOnClick)return;m.onEnd(),m.destroy();const e=await this._updatingHandles.addPromise(this._setupGraphicTransform3DOperation(this.updateGraphics.toArray(),t,o,!0));Pe(e)||this._setUpdateOperationHandle(e,t)}});return u.push(...this._getHandlesForComponent(m,t),o.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(m,e,t),z.WIDGET),o.on("key-down",e=>{this._getCommonUpdateOperationKeyDownHandlers(m,e)},z.WIDGET)),m}async _setupTransformOrReshape2DOperation(e,t,o,i){this.updateGraphics.addMany(e),await this._updatingHandles.addPromise(this._updateSpatialReference(e));const a=await this._updatingHandles.addPromise("transform"===t?this._getBox(e,o,i):this._getReshape(e,o,i));if(Pe(a))return a;const r=new he({activeComponent:a,type:"update",onEnd:()=>{n(p),n(s),r.activeComponent&&!r.activeComponent.destroyed&&r.activeComponent.destroy(),this._internalGraphicsLayer.removeMany(this.updateGraphics.toArray())},undo:()=>{Ce(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitUndoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},redo:()=>{Ae(r,this.updateGraphics.toArray()),r.refreshComponent(),this._emitRedoEvent({graphics:this.updateGraphics.toArray(),tool:r.tool})},addToSelection:async e=>{let t=r.activeComponent;if("reshape"===t?.type){const t=[...this.updateGraphics,e];this.updateGraphics.removeAll(),r.onEnd(),r.destroy();const a=await this._updatingHandles.addPromise(this._setupTransformOrReshape2DOperation(t,"transform",o,i));if(Pe(a))return;this._setUpdateOperationHandle(a,o)}else this.updateGraphics.add(e),t.graphics=this.updateGraphics.toArray(),t.refresh(),r.resetHistory();this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[e],removed:[],type:"selection-change"},type:"update"})},removeFromSelection: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();0===o.length?r.complete():ge(o)?await r.toggleTool():r.activeComponent.graphics=o,this.emit("update",{graphics:o,state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{added:[],removed:[e],type:"selection-change"},type:"update"})},toggleTool:async()=>{if(this.updateGraphics.length>1)return;const e=this.updateGraphics.at(0),t=e.geometry;if(null!=t&&("reshape"===r.tool&&"point"===t.type||"transform"===r.tool&&"extent"===t.type))return;let a=null;const s={...this.defaultUpdateOptions,...o,...this.activeUpdateOptions,reshapeOptions:{...this.defaultUpdateOptions.reshapeOptions,...o?.reshapeOptions,...this.activeUpdateOptions?.reshapeOptions},highlightOptions:{...this.defaultUpdateOptions.highlightOptions,...o?.highlightOptions,...this.activeUpdateOptions?.highlightOptions}};"transform"===r.tool?a=await this._updatingHandles.addPromise(this._getReshape([e],s,i)):"reshape"===r.tool&&(a=await this._updatingHandles.addPromise(this._getBox([e],s,i))),Pe(a)||(r.activeComponent?.destroy(),r.activeComponent=a,r.activeComponent&&(n(p),p=this._getHandlesForComponent(r,s)))}}),s=[i.on("immediate-click",e=>this._getCommonUpdateOperationClickHandlers(r,e,o),z.WIDGET),i.on("key-down",e=>{if(this._getCommonUpdateOperationKeyDownHandlers(r,e),e.key===B.constraint&&!e.repeat&&r){const e=r.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},z.WIDGET),i.on("key-up",e=>{if(e.key===B.constraint&&r){const e=r.activeComponent;"box"===e?.type&&(e.preserveAspectRatio=!e.preserveAspectRatio)}},z.WIDGET)];let p=this._getHandlesForComponent(r,o);return r}async _getGraphicMover(e,t,o){const{enableMoveAllGraphics:i,highlightOptions:a}=t,r=await this._requireModule(import("../../views/draw/support/GraphicMover.js"));return Pe(r)?r:new r.module.default({enableMoveAllGraphics:i,highlightName:a?.name,highlightsEnabled:!!a?.enabled,indicatorsEnabled:!1,graphics:e,view:o,callbacks:{onGraphicMoveStart:({dx:e,dy:t,graphic:o})=>{this._displayCursor("grabbing"),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-start"},type:"update"})},onGraphicMove:({dx:e,dy:t,graphic:o})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move"},type:"update"}),onGraphicMoveStop:({dx:e,dy:t,graphic:o})=>{this._displayCursor("pointer"),this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:"move-stop"},type:"update"})},onGraphicPointerOver:()=>this._displayCursor("move"),onGraphicPointerOut:()=>this._clearCursor()}})}async _getBox(e,t,o){const{enableRotation:i,enableScaling:a,highlightOptions:r,preserveAspectRatio:s}=t,n=await this._requireModule(import("../../views/draw/support/Box.js"));if(Pe(n))return n;const p=this.view?.inputManager?.isModifierKeyDown(B.constraint),l=new n.module.default({graphics:e,enableRotation:i,enableScaling:a,highlightName:r?.name,highlightsEnabled:!!r?.enabled,preserveAspectRatio:!!s!=!!p,layer:this._internalGraphicsLayer,view:o,toolOptions:this.sketchOptions,callbacks:{onMoveStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onMove:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onMoveStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScaleStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScale:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onScaleStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotateStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotate:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onRotateStop:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"})}});return l.addHandles(g(()=>[this.activeUpdateOptions?.enableRotation,this.activeUpdateOptions?.enableScaling],([e,o])=>{l.enableRotation=e??t.enableRotation??!0,l.enableScaling=o??t.enableScaling??!0,l.refresh()},y)),l}async _getReshape(e,t,o){const{highlightOptions:i,reshapeOptions:a}=t,r="split"===a?.edgeOperation,s="move"===a?.shapeOperation,n=!!a?.enableCreateCurveFromStraightEdge,p=await this._requireModule(import("../../views/draw/support/Reshape.js"));return Pe(p)?p:new p.module.default({enableMidpoints:r,enableMovement:s,enableCurveOnMidpoint:n,graphic:e[0],highlightName:i?.name,highlightsEnabled:!!i?.enabled,layer:this._internalGraphicsLayer,snappingManager:this.snappingManager,toolOptions:this.sketchOptions,view:o,callbacks:{onReshapeStart:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onReshape:e=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e},type:"update"}),onReshapeStop:({mover:e,type:t})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e,type:t},type:"update"}),onMoveStart:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onMove:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onMoveStop:({dx:e,dy:t,mover:o,type:i})=>this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e,dy:t,mover:o,type:i},type:"update"}),onVertexAdd:({added:e,type:t,vertices:o})=>{const i=e.map(e=>H(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=>H(e.geometry));this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{removed:i,vertices:o,type:t},type:"update"})}}})}_getHandlesForComponent(e,t){const o=e.activeComponent;if(!o)return[];switch(o.type){case"graphic-mover":return[o.on("graphic-click",({graphic:o,viewEvent:i})=>{i.native?.shiftKey&&t.multipleSelectionEnabled&&(i.stopPropagation(),this._updatingHandles.consumePromise(e.removeFromSelection(o)))}),o.on("graphic-move-start",t=>e.addToHistory(He(t.allGraphics)))];case"box":return[o.on("graphic-click",o=>this._onTransformOrReshape2DGraphicClick(e,t,o)),o.on("move-start",t=>e.addToHistory(He(t.graphics))),o.on("rotate-start",t=>e.addToHistory(He(t.graphics))),o.on("scale-start",t=>e.addToHistory(He(t.graphics)))];case"reshape":return[o.on("graphic-click",o=>this._onTransformOrReshape2DGraphicClick(e,t,o)),o.on("move-start",t=>e.addToHistory(He([t.mover]))),o.on("reshape-start",t=>e.addToHistory(He([t.graphic]))),o.on("vertex-add",t=>e.addToHistory(He([t.oldGraphic]))),o.on("vertex-remove",t=>e.addToHistory(He([t.oldGraphic])))];case"move-3d":return[o.events.on("record-undo",({updates:t})=>{e.addToHistory({updates:t})}),o.events.on("move-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move-start"},type:"update"})}),o.events.on("move",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:e.dx,dy:e.dy,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move"},type:"update"})}),o.events.on("move-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{dx:0,dy:0,mover:e.objects.length>0?e.objects[0].graphic:null,type:"move-stop"},type:"update"})}),o.events.on("immediate-click",o=>{this._updatingHandles.consumePromise(o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool())})];case"transform-3d":return[o.events.on("record-undo",({updates:t})=>{e.addToHistory({updates:t})}),o.events.on("translate-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-start"},type:"update"})}),o.events.on("translate-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move-stop"},type:"update"})}),o.events.on("rotate-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate-start"},type:"update"})}),o.events.on("rotate-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate-stop"},type:"update"})}),o.events.on("scale-start",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-start"},type:"update"})}),o.events.on("scale-stop",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale-stop"},type:"update"})}),o.events.on("translate",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,dx:e.dxScreen,dy:e.dyScreen,type:"move"},type:"update"})}),o.events.on("rotate",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,angle:e.angle,type:"rotate"},type:"update"})}),o.events.on("scale",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{mover:e.object.graphic,xScale:e.xScale,yScale:e.yScale,type:"scale"},type:"update"})}),o.events.on("immediate-click",o=>{this._updatingHandles.consumePromise(o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool())})];case"reshape-3d":return[o.events.on("reshape",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e,mover:e.object.graphic},type:"update"})}),o.events.on("move",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:{...e,mover:e.object.graphic},type:"update"})}),o.events.on("vertex-add",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})}),o.events.on("vertex-remove",e=>{this.emit("update",{graphics:this.updateGraphics.toArray(),state:"active",aborted:!1,tool:this.activeTool,toolEventInfo:e,type:"update"})}),o.events.on("immediate-click",o=>{this._updatingHandles.consumePromise(o.shiftKey?this._toggleSelection([o.object.graphic],e,t):e.toggleTool())})]}}_onTransformOrReshape2DGraphicClick(e,t,o){const{graphic:i,viewEvent:a}=o;if(a.native?.shiftKey&&this.hasGraphic(i))return a.stopPropagation(),void this._updatingHandles.consumePromise(e.removeFromSelection(i));t.toggleToolOnClick&&(a.stopPropagation(),this._updatingHandles.consumePromise(e.toggleTool()))}_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)}_getCommonUpdateOperationClickHandlers(e,t,o){return this._updatingHandles.addPromise(this._handleCommonUpdateOperationClick(e,t,o))}async _handleCommonUpdateOperationClick(e,t,o){const i=re(t),a=await t.defer(()=>this._getFirstHit(i));if(null==a)return void(this.cancelUpdateOnClickAway&&e.complete());const r=t.native.shiftKey?this._toggleSelection([a.graphic],e,o):null;if(r)return t.stopPropagation(),void await r;this.updateGraphics.includes(a.graphic)?this._shouldTemporarilyDisablePopup(o)&&t.stopPropagation():e.complete()}async _toggleSelection(e,t,o){const i=!!o.multipleSelectionEnabled;for(const a of e)if(null!=a&&i&&this.hasGraphic(a))return this.updateGraphics.includes(a)?await t.removeFromSelection(a):await t.addToSelection(a)}_getCommonUpdateOperationKeyDownHandlers(e,t){if(!e)return;const o=t.key;o===B.undo&&e.canUndo()?(t.stopPropagation(),e.undo()):o===B.redo&&e.canRedo()?(t.stopPropagation(),e.redo()):o===B.cancel?(t.stopPropagation(),e.cancel()):this.allowDeleteKey&&B.delete.includes(o)&&this._onDeleteKey(t)}_onDeleteKey(e){this._operationHandle&&"update"===this._operationHandle.type&&null!=this.activeComponent&&(e.stopPropagation(),this.delete())}_removeDefaultLayer(){this._internalGraphicsLayer&&(this.view?.map?.remove(this._internalGraphicsLayer),this._internalGraphicsLayer=h(this._internalGraphicsLayer))}_isComponentGraphic(e){const{activeComponent:t}=this;return!(!e||null==t)&&(e.attributes?.esriSketchTool||"draw-2d"===t.type&&t.graphic===e||("box"===t.type||"reshape"===t.type)&&t.isUIGraphic(e))}_clearCursor(){this.removeHandles(be)}_displayCursor(e){this.removeHandles(be),this.view?.container&&null!=e&&this.addHandles(this.view.acquireCursor(e,"high"),be)}_logError(e,t,o){l.getLogger(this).error(new a(e,t,o))}async _requireModule(e){const t=new AbortController;this._moduleLoaderAbortController=t;const o=await e;return this._moduleLoaderAbortController!==t||t.signal.aborted?{requireError:"aborted"}:{module:o}}_emitUndoEvent(e){this.emit("undo",{...e,type:"undo"})}_emitRedoEvent(e){this.emit("redo",{...e,type:"redo"})}_emitDeleteEvent(e){this.emit("delete",{...e,type:"delete"})}_onLayerGraphicsChangeCallback(e){if(null!=this._operationHandle){const{updateGraphics:t}=this;for(const o of e.removed)if(t.includes(o)){if(!(t.length>1)){this._operationHandle.cancel();break}this._updatingHandles.consumePromise(this._operationHandle.removeFromSelection(o))}}}async _setupAdvancedDrawToolIntegrationMaybe(){this.isUsingLegacyCreateTools||this.pluginManager.loaded||await this.pluginManager.loadPlugins()}async _setupDrawTool(e,o,i){if(this.isUsingLegacyCreateTools||!this._pluginManager)return null;const a=this.view,r=await(import("../../views/draw/DrawTool.js"));await this.pluginManager.loadPlugins();const s=await this.pluginManager.makeRenderer({customSymbol:o.graphicSymbol,useTextSymbol:"text"===i}),n=new r.DrawTool({view:a,elevationInfo:this._layerAdapter?.elevationInfo??I("3d"===a.type),hasZ:!!o.hasZ,toolOptions:this.sketchOptions,renderer:s,defaultZ:o.defaultZ??0,directionOptions:o.directionOptions,snappingManager:this.snappingManager,enableVertexVisuals:"rectangle"!==i&&"circle"!==i,readPluginSetting:(e,t)=>this.settingsManager.getValue(t)});n.addHandles(p(s));const l=new t({...o.graphicProperties,attributes:{...o.graphicProperties?.attributes},symbol:o.graphicSymbol??this._getGraphicSymbolFromTool(i)});return o.graphicSymbol||n.addHandles(g(()=>this._getGraphicSymbolFromTool(i),e=>l.symbol=e)),this._set("createGraphic",l),a.addAndActivateTool(n),n.begin(e),n}get test(){}wait(){return _(()=>!this.updating)}_shouldTemporarilyDisablePopup(e){return this.updateOnGraphicClick||(e?.toggleToolOnClick??!1)}_disablePopup(e){this._shouldTemporarilyDisablePopup(e)&&this.view&&null==this._originalPopupEnabled&&(this._originalPopupEnabled=this.view.popupEnabled,this.view.popupEnabled=!1)}_restorePopup(e){this._shouldTemporarilyDisablePopup(e)&&this.view&&null!=this._originalPopupEnabled&&(this.view.popupEnabled=this._originalPopupEnabled,this._originalPopupEnabled=null)}async _waitViewReady(){const e=this.view;e?(d(this._viewReadyAbortController),this._viewReadyAbortController=new AbortController,await m(_(()=>e?.ready),this._viewReadyAbortController.signal)):this._logMissingView()}_logMissingView(){this._logError("sketch:missing-property",Oe("view"))}_logMissingLayer(){this._logError(Ge,Oe("layer"))}};e([b()],Te.prototype,"_defaultSnappingManager",void 0),e([b()],Te.prototype,"_layerAdapter",null),e([b()],Te.prototype,"_pluginManager",void 0),e([b({readOnly:!0})],Te.prototype,"settingsManager",void 0),e([b()],Te.prototype,"_operationHandle",void 0),e([b({readOnly:!0})],Te.prototype,"_updatingHandles",void 0),e([b({readOnly:!0})],Te.prototype,"_toolTransitionHandles",void 0),e([b()],Te.prototype,"_drawToolSimplifyAbortController",void 0),e([b({readOnly:!0})],Te.prototype,"activeTool",null),e([b()],Te.prototype,"geometrySimplificationInProgress",null),e([b({readOnly:!0})],Te.prototype,"activeCreateToolDrawMode",null),e([b()],Te.prototype,"activeTooltip",null),e([b({types:V})],Te.prototype,"activeFillSymbol",void 0),e([b()],Te.prototype,"activeLineSymbol",void 0),e([b()],Te.prototype,"activeVertexSymbol",void 0),e([b()],Te.prototype,"allowDeleteKey",void 0),e([b({readOnly:!0})],Te.prototype,"createGraphic",null),e([b()],Te.prototype,"defaultCreateOptions",null),e([b()],Te.prototype,"defaultUpdateOptions",null),e([b()],Te.prototype,"activeUpdateOptions",void 0),e([b({type:$,nonNullable:!0})],Te.prototype,"labelOptions",null),e([b()],Te.prototype,"layer",void 0),e([b({types:V})],Te.prototype,"pointSymbol",void 0),e([b({types:V})],Te.prototype,"polygonSymbol",void 0),e([b({types:V})],Te.prototype,"polylineSymbol",void 0),e([b()],Te.prototype,"meshSymbol",void 0),e([b({type:F})],Te.prototype,"textSymbol",null),e([b({type:ee,nonNullable:!0})],Te.prototype,"snappingOptions",null),e([b()],Te.prototype,"snappingManager",null),e([b({readOnly:!0})],Te.prototype,"state",null),e([b()],Te.prototype,"toolTransitionInProgress",null),e([b({type:J,nonNullable:!0})],Te.prototype,"tooltipOptions",null),e([b({readOnly:!0})],Te.prototype,"updateGraphics",void 0),e([b()],Te.prototype,"updateOnGraphicClick",void 0),e([b()],Te.prototype,"cancelUpdateOnClickAway",void 0),e([b()],Te.prototype,"updating",null),e([b()],Te.prototype,"creationMode",void 0),e([b({type:Q,nonNullable:!0})],Te.prototype,"valueOptions",null),e([b({types:V})],Te.prototype,"vertexSymbol",void 0),e([b({value:null})],Te.prototype,"view",null),e([b({constructOnly:!0,type:Y})],Te.prototype,"sketchOptions",void 0),e([b()],Te.prototype,"useLegacyCreateTools",void 0),e([b()],Te.prototype,"isUsingLegacyCreateTools",null),e([b()],Te.prototype,"pluginManager",null),e([b()],Te.prototype,"drawTool",null),e([b()],Te.prototype,"rootPlugins",null),e([b()],Te.prototype,"effectiveAvailablePlugins",null),e([b()],Te.prototype,"firstPluginWithSwappableLeaf",null),e([b()],Te.prototype,"multiplePluginsActive",null),Te=e([w("esri.widgets.Sketch.SketchViewModel")],Te);const Ge="sketch:missing-property",Oe=e=>`Property '${e}' is missing on SketchViewModel.`;function Se(e){return"polygon"===e||"rectangle"===e||"circle"===e}function Ce(e,t){Ee("undo",e.history.undo,e.history.redo,t)}function Ae(e,t){Ee("redo",e.history.redo,e.history.undo,t)}function Ee(e,t,o,i){const a=t.pop();if(!a)return;const r=a.updates,s=[];i.forEach((t,o)=>{const i=r[o];null!=i&&("geometry"in i&&null!=i.geometry&&(s.push({geometry:t.geometry}),t.geometry=i.geometry),"symbol"in i&&null!=i.symbol&&(s.push({symbol:t.symbol}),t.symbol=i.symbol),"undo"in i&&(s.push(i),i[e](t)))}),o.push({updates:s})}function Me(e,t){null!=e&&t.hasGrabbedManipulators&&(e.activeTool=null)}function He(e){return{updates:e.map(({geometry:e})=>"mesh"===e?.type?{geometry:e.cloneShallow()}:{geometry:e})}}function ke(e,t){e.tools?.remove(t),t.destroyed||t.destroy()}function Pe(e){return"requireError"in e&&"aborted"===e.requireError}export{Te as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import e from"../../../Color.js";import{EventedAccessor as i}from"../../../core/Evented.js";import r from"../../../core/Logger.js";import{rad2deg as s}from"../../../core/mathUtils.js";import{destroyMaybe as n}from"../../../core/maybe.js";import{when as o,watch as a}from"../../../core/reactiveUtils.js";import{convertUnit as l}from"../../../core/units.js";import{property as c,subclass as h}from"../../../core/accessorSupport/decorators.js";import d from"../../../geometry/Point.js";import{isLoadedOrLoadFor as p,project as m}from"../../../geometry/projectionUtils.js";import{getResolutionForScale as g}from"../../../geometry/support/scaleUtils.js";import{MeasuredGrid as u}from"../../../grids/MeasuredGrid.js";import{makeDehydratedPoint as v}from"../../../layers/graphics/dehydratedPoint.js";import{defaultUnitPropertyMetadata as y}from"../../../properties/defaultUnit.js";import _ from"../../../symbols/SimpleLineSymbol.js";import w from"../../../symbols/SimpleMarkerSymbol.js";import{minimumPixelsPerStrideForDisplayWhenScalingOff as f}from"../../../views/2d/grid/constants.js";import{getScaleFactor as S,shouldUsePlanar as b,measureMetersPerUnitAtReferencePoint as P}from"../../../views/2d/grid/gridUtils.js";import{DrawGraphicTool2D as T}from"../../../views/2d/interactive/editingTools/draw/DrawGraphicTool2D.js";import"../../../views/2d/interactive/editingTools/ControlPointsTransformTool.js";import"../../../views/2d/interactive/editingTools/TransformTool.js";import"../../../views/2d/interactive/editingTools/MediaTransformToolsWrapper.js";import{ViewEventPriorities as C}from"../../../views/input/InputManager.js";import{KeyBindings as j,sketchKeys as x}from"../../../views/interactive/keybindings.js";import G from"../../../views/interactive/snapping/SnappingOptions.js";import{gridPlacementGraphicSymbol as O}from"../../../views/interactive/snapping/snappingUtils.js";import R from"../../../views/overlay/CrosshairOverlayItem.js";import I from"../../../views/overlay/TextOverlayItem.js";import{degreeSymbol as L}from"../../CoordinateConversion/support/formatUtils.js";import{applyColorToGrid as M,gridRotationToDegrees as k}from"./gridUtils.js";const E=Symbol("grid-interactivity");let V=class extends i{constructor(t){super(t),this._drawGraphicTool=null,this._keybindings=null,this._crosshairLabel=null,this._crosshairItem=null,this.snappingManager=null,this.snappingOptions=null,this.view=null,this.placementDisabled=!1,this._mostRecentlyShownGrid=null,this._sketchedVertexCount=0}initialize(){this.addHandles([o(()=>!this.displayEnabled,()=>{this.interactivePlacementState=null}),a(()=>this.view?.viewpoint,()=>{this._renderOverlays()}),a(()=>this.snappingOptions?.gridEnabled,t=>{null!=t&&this.trySetDisplayEnabled(t)}),a(()=>this.view?.grid,(t,e)=>{this._mostRecentlyShownGrid=!t&&e?e:null})])}destroy(){this._resetGridPlacementState(),this._crosshairItem&&(this.view?.overlay?.removeItem(this._crosshairItem),this._crosshairItem=n(this._crosshairItem)),this._crosshairLabel&&(this.view?.overlay?.removeItem(this._crosshairLabel),this._crosshairLabel=n(this._crosshairLabel))}get displayEnabled(){return!!this.view?.grid}get dynamicScaling(){return this.grid?.dynamicScaling??!1}set dynamicScaling(t){this.grid&&(this.grid.dynamicScaling=t)}get grid(){return this.view?.grid??this._mostRecentlyShownGrid}set gridColor(t){if(t?.equals(this.grid?.majorLineColor))return;if(!t)return;const[e,i,r,s]=t.toArray();M(this.grid,[e,i,r,s/255])}get gridColor(){return this.grid?.majorLineColor}get gridControlsEnabled(){return this.displayEnabled&&!this.interactivePlacementState}set interactivePlacementState(t){this._set("interactivePlacementState",t),this._resetGridPlacementState(),t&&this._startGridManipulation(t)}get majorLineInterval(){return this.grid?.majorLineInterval??10}set majorLineInterval(t){this.grid&&(this.grid.majorLineInterval=t<1?1:t>15?15:t)}get rotateWithMap(){return this.grid?.rotateWithMap??!1}set rotateWithMap(t){this.grid&&(this.grid.rotateWithMap=t)}get rotation(){return this.grid?.rotation??-180}set rotation(t){this.grid&&(this.grid.rotation=t)}get snappingEnabled(){return(this.grid&&this.snappingOptions?.gridEnabled)??!1}set snappingEnabled(t){const{snappingOptions:e}=this;e&&(e.gridEnabled=t)}get spacing(){return this.grid?.spacing??1}set spacing(t){this.grid&&t>0&&(this.grid.spacing=t)}get unit(){return this.grid?.units}set unit(t){this.grid&&(this.grid.units=t)}get gridOutOfScale(){return!this.dynamicScaling&&null!=this._pixelsPerStride&&this._pixelsPerStride<f}get effectiveSpacingAfterDynamicScaling(){return this.majorLineInterval<1||!this.dynamicScaling||!this.view||null==this._pixelsPerStride||!this.grid?.spacing?null:this.grid.spacing*S(this.majorLineInterval,this._pixelsPerStride,this.dynamicScaling)}get numericSpacingInputShouldBeVisible(){return!!this.view?.spatialReference&&b(this.view.spatialReference)}get _metersPerSRUnit(){if(!(this.view&&this.displayEnabled&&this.grid&&p(this.grid.center.spatialReference,this.view.spatialReference)))return null;const t=m(this.grid.center,this.view.spatialReference);return P(t)}get _pixelsPerStride(){if(!this.view?.scale||!this.displayEnabled||!this.grid||null==this._metersPerSRUnit)return null;const t=this.grid,{scale:e,spatialReference:i}=this.view;return l(t.spacing,t.units,"meters")/(this._metersPerSRUnit*g(e,i))}get _isPlacing(){if(!this._drawGraphicTool)return!1;const t=this.interactivePlacementState;return"place"===t||"interactive"===t&&0===this._sketchedVertexCount}get _isRotating(){if(!this._drawGraphicTool)return!1;const t=this.interactivePlacementState;return"rotate"===t||"interactive"===t&&1===this._sketchedVertexCount}get _isScaling(){if(!this._drawGraphicTool)return!1;return"interactive"===this.interactivePlacementState&&1===this._sketchedVertexCount}togglePlacementState(t){this.interactivePlacementState=this.interactivePlacementState===t?null:t}trySetDisplayEnabled(t){const{view:e}=this;if(e?.ready)if(!e.grid&&t)if(this._mostRecentlyShownGrid)e.grid=this._mostRecentlyShownGrid;else{const t="imperial"===this.defaultUnit?"feet":"meters";e.grid=new u({units:t,center:e.center??new d,rotateWithMap:!0}),M(this.grid,[115,115,115])}else t||(e.grid=null);else r.getLogger(this).warn("Attempting to enable grid display while view is not ready")}async startPlacement(t){const{view:e,snappingManager:i}=this;if(!e)return;this._set("interactivePlacementState",t),this._sketchedVertexCount=0;const r=new T({view:e,graphicProperties:{attributes:{[O]:O}},sketchOptions:{tooltips:{enabled:!0,visibleElements:{direction:!1,rotation:!1,totalLength:!1,elevation:!1,distance:!1,area:!1}}},geometryType:"polyline",mode:"click",snapToScene:!1,snappingManager:i,forceUniformSize:!0,centered:!1,cursor:"interactive"===this.interactivePlacementState||"place"===this.interactivePlacementState?"none":null,regularVerticesSymbol:void 0,activeVertexSymbol:D,activeLineSymbol:U,graphicSymbol:U});if(this._drawGraphicTool=r,e.addAndActivateTool(r),this._renderOverlays(),!this._keybindings){const t=new j;t.add(x.complete,()=>this._onDrawComplete()),t.add(x.vertexAdd,()=>this._drawGraphicTool?.drawOperation.commitStagedVertex()),this._keybindings=t}this.addHandles([r.on("cursor-update",t=>this._onCursorUpdate(t)),r.on("complete",()=>this._onDrawComplete()),r.on("vertex-add",e=>this._onVertexAdd(e,t)),this._keybindings.register(e,C.WIDGET)],E)}async _startGridManipulation(t){const{view:e}=this;if(!e)return void(this.interactivePlacementState=null);const i=new CustomEvent("before-placement",{cancelable:!0});this.emit("before-placement",i),i.defaultPrevented||await this.startPlacement(t)}_onCursorUpdate(t){try{if(this._isPlacing){const e=t.vertices[0].coordinates;return void this._handlePlace(e)}if(this._drawGraphicTool.cursor=null,this._isRotating&&this._handleRotate(t.vertices[0].coordinates),this._isScaling){const t=this._drawGraphicTool?.drawOperation.cursorVertex;this._handleScale(t)}}finally{this._renderOverlays()}}_onDrawComplete(){this._drawGraphicTool.cursor=null,this.interactivePlacementState=null}_onVertexAdd(t,e){const i=t.vertices[0].coordinates;this._isPlacing&&this._handlePlace(i),this._isRotating&&this._sketchedVertexCount>0&&this._handleRotate(i),this._isScaling&&this._sketchedVertexCount>0&&this._handleScale(v(i[0],i[1],void 0,this.view.spatialReference)),this._sketchedVertexCount++,this._drawGraphicTool.cursor=null,2!==this._sketchedVertexCount&&"interactive"===e||(this.interactivePlacementState=null),this._renderOverlays()}_handlePlace(t){const{grid:e,view:i}=this;e&&i&&(e.center=new d({x:t[0],y:t[1],spatialReference:i.spatialReference}))}_handleRotate(t){const{grid:e,view:i}=this;if(!e||!i)return;this._drawGraphicTool?.sketchOptions.tooltips.set("enabled",!1);const{x:r,y:n}=e.center,[o,a]=t,l=i.toScreen(e.center,{pickClosestTarget:!0}),c=l&&i.toMap(l),h=i.toScreen(v(o,a,void 0,i.spatialReference),{pickClosestTarget:!0}),d=h&&i.toMap(h),p=c?c.x:r,m=c?c.y:n,g=p-(d?d.x:o),u=m-(d?d.y:a);if(0===g&&0===u)return;const y=Math.atan2(u,g),_=s(y),w=e.rotateWithMap,f=i.viewpoint.rotation??0,S=w?_:_-f;e.rotation=Math.fround(S)%360}_handleScale(t){const{view:e,grid:i,_drawGraphicTool:r,interactivePlacementState:s,_metersPerSRUnit:n}=this;if(!(t&&e&&i&&r&&n))return;r.sketchOptions.tooltips.enabled=!1;const o="interactive"===s?i.center:r.drawOperation.firstVertex;if(!o||!t)return;const a=e?.toScreen(o),c=a&&e.toMap(a),h=e?.toScreen(t),d=c??o,p=(h&&e.toMap(h))??t,m=Math.sqrt((d.x-p.x)**2+(d.y-p.y)**2),g=l(m*n,"meters",i.units);this.spacing=g}_renderOverlays(){this._renderCrosshairOverlay(),this._renderTextOverlay()}_renderTextOverlay(){const{grid:t,view:e,_drawGraphicTool:i}=this,r=this._getCrosshairLabel();if(!(t&&e?.overlay&&i&&r))return;const s=e.toScreen(t.center,{pickClosestTarget:!0});s&&(r.position=[s.x+12,s.y+12]),this._isRotating?(r.text=`${k(t.rotation)}${L}`,r.visible=!0):r.visible=!1}_renderCrosshairOverlay(){const{grid:t,view:e,_drawGraphicTool:i}=this;if(!t||!e?.overlay||!i)return;const r=this._getCrosshair();if(!r)return;const s=e.toScreen(t.center);s&&(r.x=s.x,r.y=s.y,r.rotation=t.rotateWithMap?e.viewpoint.rotation-t.rotation:-t.rotation,r.visible=!!i)}_getCrosshairLabel(){if(this._crosshairLabel)return this._crosshairLabel;const{grid:t,view:i,_drawGraphicTool:r}=this;if(!t||!i?.overlay||!r)return null;const s=new I({anchor:"top-left",fontSize:10,textColor:new e([21,21,21]),backgroundColor:new e([248,248,248]),padding:8,borderRadius:20});return i.overlay.addItem(s),this._crosshairLabel=s,s}_getCrosshair(){const{_crosshairItem:t,view:e}=this;return e?.overlay?t&&e.overlay.items.includes(t)?t:(this._crosshairItem=new R({color:e.effectiveTheme.accentColor,thickness:4,length:36,visible:!0}),e.overlay?.addItem(this._crosshairItem),this._crosshairItem):null}_resetGridPlacementState(){this.removeHandles(E),this._crosshairItem&&(this._crosshairItem.visible=!1),this._crosshairLabel&&(this._crosshairLabel.visible=!1),this._drawGraphicTool&&(this.view?.activeTool===this._drawGraphicTool&&(this.view.activeTool=null),this.view?.tools.remove(this._drawGraphicTool)),this._drawGraphicTool=n(this._drawGraphicTool)}};t([c(y)],V.prototype,"defaultUnit",void 0),t([c({readOnly:!0})],V.prototype,"displayEnabled",null),t([c()],V.prototype,"dynamicScaling",null),t([c()],V.prototype,"grid",null),t([c()],V.prototype,"gridColor",null),t([c({readOnly:!0})],V.prototype,"gridControlsEnabled",null),t([c()],V.prototype,"interactivePlacementState",null),t([c()],V.prototype,"majorLineInterval",null),t([c()],V.prototype,"rotateWithMap",null),t([c()],V.prototype,"rotation",null),t([c()],V.prototype,"snappingEnabled",null),t([c()],V.prototype,"snappingManager",void 0),t([c({type:G})],V.prototype,"snappingOptions",void 0),t([c()],V.prototype,"spacing",null),t([c()],V.prototype,"unit",null),t([c()],V.prototype,"view",void 0),t([c({readOnly:!0})],V.prototype,"gridOutOfScale",null),t([c({readOnly:!0})],V.prototype,"effectiveSpacingAfterDynamicScaling",null),t([c({readOnly:!0})],V.prototype,"numericSpacingInputShouldBeVisible",null),t([c()],V.prototype,"placementDisabled",void 0),t([c()],V.prototype,"_metersPerSRUnit",null),t([c()],V.prototype,"_pixelsPerStride",null),t([c()],V.prototype,"_isPlacing",null),t([c()],V.prototype,"_isRotating",null),t([c()],V.prototype,"_isScaling",null),t([c()],V.prototype,"_mostRecentlyShownGrid",void 0),t([c()],V.prototype,"_sketchedVertexCount",void 0),V=t([h("esri.widgets.support.GridControls.GridControlsViewModel")],V);const U=new _({width:0}),D=new w({color:e.fromArray([0,0,0,0]),outline:new _({color:e.fromArray([0,0,0,0])})});export{V as default};
2
+ import{__decorate as t}from"tslib";import e from"../../../Color.js";import{EventedAccessor as i}from"../../../core/Evented.js";import r from"../../../core/Logger.js";import{rad2deg as s}from"../../../core/mathUtils.js";import{destroyMaybe as n}from"../../../core/maybe.js";import{when as o,watch as a}from"../../../core/reactiveUtils.js";import{convertUnit as l}from"../../../core/units.js";import{property as c,subclass as h}from"../../../core/accessorSupport/decorators.js";import d from"../../../geometry/Point.js";import{isLoadedOrLoadFor as p,project as m}from"../../../geometry/projectionUtils.js";import{getResolutionForScale as g}from"../../../geometry/support/scaleUtils.js";import{MeasuredGrid as u}from"../../../grids/MeasuredGrid.js";import{makeDehydratedPoint as v}from"../../../layers/graphics/dehydratedPoint.js";import{defaultUnitPropertyMetadata as y}from"../../../properties/defaultUnit.js";import _ from"../../../symbols/SimpleLineSymbol.js";import w from"../../../symbols/SimpleMarkerSymbol.js";import{minimumPixelsPerStrideForDisplayWhenScalingOff as f}from"../../../views/2d/grid/constants.js";import{getScaleFactor as S,shouldUsePlanar as b,measureMetersPerUnitAtReferencePoint as P}from"../../../views/2d/grid/gridUtils.js";import{DrawGraphicTool2D as T}from"../../../views/2d/interactive/editingTools/draw/DrawGraphicTool2D.js";import"../../../views/2d/interactive/editingTools/ControlPointsTransformTool.js";import"../../../views/2d/interactive/editingTools/TransformTool.js";import"../../../views/2d/interactive/editingTools/MediaTransformToolsWrapper.js";import{ViewEventPriorities as C}from"../../../views/input/InputManager.js";import{KeyBindings as j,sketchKeys as x}from"../../../views/interactive/keybindings.js";import G from"../../../views/interactive/snapping/SnappingOptions.js";import{gridPlacementGraphicSymbol as O}from"../../../views/interactive/snapping/snappingUtils.js";import R from"../../../views/overlay/CrosshairOverlayItem.js";import I from"../../../views/overlay/TextOverlayItem.js";import{degreeSymbol as L}from"../../CoordinateConversion/support/formatUtils.js";import{applyColorToGrid as M,gridRotationToDegrees as k}from"./gridUtils.js";const E=Symbol("grid-interactivity");let V=class extends i{constructor(t){super(t),this._drawGraphicTool=null,this._keybindings=null,this._crosshairLabel=null,this._crosshairItem=null,this.snappingManager=null,this.snappingOptions=null,this.view=null,this.placementDisabled=!1,this._mostRecentlyShownGrid=null,this._sketchedVertexCount=0}initialize(){this.addHandles([o(()=>!this.displayEnabled,()=>{this.interactivePlacementState=null}),a(()=>this.view?.viewpoint,()=>{this._renderOverlays()}),a(()=>this.snappingOptions?.gridEnabled,t=>{null!=t&&this.trySetDisplayEnabled(t)}),a(()=>this.view?.grid,(t,e)=>{this._mostRecentlyShownGrid=!t&&e?e:null})])}destroy(){this._resetGridPlacementState(),this._crosshairItem&&(this.view?.overlay?.removeItem(this._crosshairItem),this._crosshairItem=n(this._crosshairItem)),this._crosshairLabel&&(this.view?.overlay?.removeItem(this._crosshairLabel),this._crosshairLabel=n(this._crosshairLabel))}get displayEnabled(){return!!this.view?.grid}get dynamicScaling(){return this.grid?.dynamicScaling??!1}set dynamicScaling(t){this.grid&&(this.grid.dynamicScaling=t)}get grid(){return this.view?.grid??this._mostRecentlyShownGrid}set gridColor(t){if(t?.equals(this.grid?.majorLineColor))return;if(!t)return;const[e,i,r,s]=t.toArray();M(this.grid,[e,i,r,s/255])}get gridColor(){return this.grid?.majorLineColor}get gridControlsEnabled(){return this.displayEnabled&&!this.interactivePlacementState}set interactivePlacementState(t){this._set("interactivePlacementState",t),this._resetGridPlacementState(),t&&this._startGridManipulation(t)}get majorLineInterval(){return this.grid?.majorLineInterval??10}set majorLineInterval(t){this.grid&&(this.grid.majorLineInterval=t<1?1:t>15?15:t)}get rotateWithMap(){return this.grid?.rotateWithMap??!1}set rotateWithMap(t){this.grid&&(this.grid.rotateWithMap=t)}get rotation(){return this.grid?.rotation??-180}set rotation(t){this.grid&&(this.grid.rotation=t)}get snappingEnabled(){return(this.grid&&this.snappingOptions?.gridEnabled)??!1}set snappingEnabled(t){const{snappingOptions:e}=this;e&&(e.gridEnabled=t)}get spacing(){return this.grid?.spacing??1}set spacing(t){this.grid&&t>0&&(this.grid.spacing=t)}get unit(){return this.grid?.units}set unit(t){this.grid&&(this.grid.units=t)}get gridOutOfScale(){return!this.dynamicScaling&&null!=this._pixelsPerStride&&this._pixelsPerStride<f}get effectiveSpacingAfterDynamicScaling(){return this.majorLineInterval<1||!this.dynamicScaling||!this.view||null==this._pixelsPerStride||!this.grid?.spacing?null:this.grid.spacing*S(this.majorLineInterval,this._pixelsPerStride,this.dynamicScaling)}get numericSpacingInputShouldBeVisible(){return!!this.view?.spatialReference&&b(this.view.spatialReference)}get _metersPerSRUnit(){if(!(this.view&&this.displayEnabled&&this.grid&&p(this.grid.center.spatialReference,this.view.spatialReference)))return null;const t=m(this.grid.center,this.view.spatialReference);return P(t)}get _pixelsPerStride(){if(!this.view?.scale||!this.displayEnabled||!this.grid||null==this._metersPerSRUnit)return null;const t=this.grid,{scale:e,spatialReference:i}=this.view;return l(t.spacing,t.units,"meters")/(this._metersPerSRUnit*g(e,i))}get _isPlacing(){if(!this._drawGraphicTool)return!1;const t=this.interactivePlacementState;return"place"===t||"interactive"===t&&0===this._sketchedVertexCount}get _isRotating(){if(!this._drawGraphicTool)return!1;const t=this.interactivePlacementState;return"rotate"===t||"interactive"===t&&1===this._sketchedVertexCount}get _isScaling(){if(!this._drawGraphicTool)return!1;return"interactive"===this.interactivePlacementState&&1===this._sketchedVertexCount}togglePlacementState(t){this.interactivePlacementState=this.interactivePlacementState===t?null:t}trySetDisplayEnabled(t){const{view:e}=this;if(e?.ready)if(!e.grid&&t)if(this._mostRecentlyShownGrid)e.grid=this._mostRecentlyShownGrid;else{const t="imperial"===this.defaultUnit?"feet":"meters";e.grid=new u({units:t,center:e.center??new d,rotateWithMap:!0}),M(this.grid,[115,115,115])}else t||(e.grid=null);else r.getLogger(this).warn("Attempting to enable grid display while view is not ready")}async startPlacement(t){const{view:e,snappingManager:i}=this;if(!e)return;this._set("interactivePlacementState",t),this._sketchedVertexCount=0;const r=new T({view:e,graphicProperties:{attributes:{[O]:O}},toolOptions:{tooltips:{enabled:!0,visibleElements:{direction:!1,rotation:!1,totalLength:!1,elevation:!1,distance:!1,area:!1}}},geometryType:"polyline",mode:"click",snapToScene:!1,snappingManager:i,forceUniformSize:!0,centered:!1,cursor:"interactive"===this.interactivePlacementState||"place"===this.interactivePlacementState?"none":null,regularVerticesSymbol:void 0,activeVertexSymbol:D,activeLineSymbol:U,graphicSymbol:U});if(this._drawGraphicTool=r,e.addAndActivateTool(r),this._renderOverlays(),!this._keybindings){const t=new j;t.add(x.complete,()=>this._onDrawComplete()),t.add(x.vertexAdd,()=>this._drawGraphicTool?.drawOperation.commitStagedVertex()),this._keybindings=t}this.addHandles([r.on("cursor-update",t=>this._onCursorUpdate(t)),r.on("complete",()=>this._onDrawComplete()),r.on("vertex-add",e=>this._onVertexAdd(e,t)),this._keybindings.register(e,C.WIDGET)],E)}async _startGridManipulation(t){const{view:e}=this;if(!e)return void(this.interactivePlacementState=null);const i=new CustomEvent("before-placement",{cancelable:!0});this.emit("before-placement",i),i.defaultPrevented||await this.startPlacement(t)}_onCursorUpdate(t){try{if(this._isPlacing){const e=t.vertices[0].coordinates;return void this._handlePlace(e)}if(this._drawGraphicTool.cursor=null,this._isRotating&&this._handleRotate(t.vertices[0].coordinates),this._isScaling){const t=this._drawGraphicTool?.drawOperation.cursorVertex;this._handleScale(t)}}finally{this._renderOverlays()}}_onDrawComplete(){this._drawGraphicTool.cursor=null,this.interactivePlacementState=null}_onVertexAdd(t,e){const i=t.vertices[0].coordinates;this._isPlacing&&this._handlePlace(i),this._isRotating&&this._sketchedVertexCount>0&&this._handleRotate(i),this._isScaling&&this._sketchedVertexCount>0&&this._handleScale(v(i[0],i[1],void 0,this.view.spatialReference)),this._sketchedVertexCount++,this._drawGraphicTool.cursor=null,2!==this._sketchedVertexCount&&"interactive"===e||(this.interactivePlacementState=null),this._renderOverlays()}_handlePlace(t){const{grid:e,view:i}=this;e&&i&&(e.center=new d({x:t[0],y:t[1],spatialReference:i.spatialReference}))}_handleRotate(t){const{grid:e,view:i}=this;if(!e||!i)return;this._drawGraphicTool?.toolOptions.tooltips.set("enabled",!1);const{x:r,y:n}=e.center,[o,a]=t,l=i.toScreen(e.center,{pickClosestTarget:!0}),c=l&&i.toMap(l),h=i.toScreen(v(o,a,void 0,i.spatialReference),{pickClosestTarget:!0}),d=h&&i.toMap(h),p=c?c.x:r,m=c?c.y:n,g=p-(d?d.x:o),u=m-(d?d.y:a);if(0===g&&0===u)return;const y=Math.atan2(u,g),_=s(y),w=e.rotateWithMap,f=i.viewpoint.rotation??0,S=w?_:_-f;e.rotation=Math.fround(S)%360}_handleScale(t){const{view:e,grid:i,_drawGraphicTool:r,interactivePlacementState:s,_metersPerSRUnit:n}=this;if(!(t&&e&&i&&r&&n))return;r.toolOptions.tooltips.enabled=!1;const o="interactive"===s?i.center:r.drawOperation.firstVertex;if(!o||!t)return;const a=e?.toScreen(o),c=a&&e.toMap(a),h=e?.toScreen(t),d=c??o,p=(h&&e.toMap(h))??t,m=Math.sqrt((d.x-p.x)**2+(d.y-p.y)**2),g=l(m*n,"meters",i.units);this.spacing=g}_renderOverlays(){this._renderCrosshairOverlay(),this._renderTextOverlay()}_renderTextOverlay(){const{grid:t,view:e,_drawGraphicTool:i}=this,r=this._getCrosshairLabel();if(!(t&&e?.overlay&&i&&r))return;const s=e.toScreen(t.center,{pickClosestTarget:!0});s&&(r.position=[s.x+12,s.y+12]),this._isRotating?(r.text=`${k(t.rotation)}${L}`,r.visible=!0):r.visible=!1}_renderCrosshairOverlay(){const{grid:t,view:e,_drawGraphicTool:i}=this;if(!t||!e?.overlay||!i)return;const r=this._getCrosshair();if(!r)return;const s=e.toScreen(t.center);s&&(r.x=s.x,r.y=s.y,r.rotation=t.rotateWithMap?e.viewpoint.rotation-t.rotation:-t.rotation,r.visible=!!i)}_getCrosshairLabel(){if(this._crosshairLabel)return this._crosshairLabel;const{grid:t,view:i,_drawGraphicTool:r}=this;if(!t||!i?.overlay||!r)return null;const s=new I({anchor:"top-left",fontSize:10,textColor:new e([21,21,21]),backgroundColor:new e([248,248,248]),padding:8,borderRadius:20});return i.overlay.addItem(s),this._crosshairLabel=s,s}_getCrosshair(){const{_crosshairItem:t,view:e}=this;return e?.overlay?t&&e.overlay.items.includes(t)?t:(this._crosshairItem=new R({color:e.effectiveTheme.accentColor,thickness:4,length:36,visible:!0}),e.overlay?.addItem(this._crosshairItem),this._crosshairItem):null}_resetGridPlacementState(){this.removeHandles(E),this._crosshairItem&&(this._crosshairItem.visible=!1),this._crosshairLabel&&(this._crosshairLabel.visible=!1),this._drawGraphicTool&&(this.view?.activeTool===this._drawGraphicTool&&(this.view.activeTool=null),this.view?.tools.remove(this._drawGraphicTool)),this._drawGraphicTool=n(this._drawGraphicTool)}};t([c(y)],V.prototype,"defaultUnit",void 0),t([c({readOnly:!0})],V.prototype,"displayEnabled",null),t([c()],V.prototype,"dynamicScaling",null),t([c()],V.prototype,"grid",null),t([c()],V.prototype,"gridColor",null),t([c({readOnly:!0})],V.prototype,"gridControlsEnabled",null),t([c()],V.prototype,"interactivePlacementState",null),t([c()],V.prototype,"majorLineInterval",null),t([c()],V.prototype,"rotateWithMap",null),t([c()],V.prototype,"rotation",null),t([c()],V.prototype,"snappingEnabled",null),t([c()],V.prototype,"snappingManager",void 0),t([c({type:G})],V.prototype,"snappingOptions",void 0),t([c()],V.prototype,"spacing",null),t([c()],V.prototype,"unit",null),t([c()],V.prototype,"view",void 0),t([c({readOnly:!0})],V.prototype,"gridOutOfScale",null),t([c({readOnly:!0})],V.prototype,"effectiveSpacingAfterDynamicScaling",null),t([c({readOnly:!0})],V.prototype,"numericSpacingInputShouldBeVisible",null),t([c()],V.prototype,"placementDisabled",void 0),t([c()],V.prototype,"_metersPerSRUnit",null),t([c()],V.prototype,"_pixelsPerStride",null),t([c()],V.prototype,"_isPlacing",null),t([c()],V.prototype,"_isRotating",null),t([c()],V.prototype,"_isScaling",null),t([c()],V.prototype,"_mostRecentlyShownGrid",void 0),t([c()],V.prototype,"_sketchedVertexCount",void 0),V=t([h("esri.widgets.support.GridControls.GridControlsViewModel")],V);const U=new _({width:0}),D=new w({color:e.fromArray([0,0,0,0]),outline:new _({color:e.fromArray([0,0,0,0])})});export{V as default};