@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 t from"../../../../core/Accessor.js";import{toConst as r}from"../../../../core/compilerUtils.js";import{unpackFloatRGBA as i}from"../../../../core/floatRGBA.js";import has from"../../../../core/has.js";import s from"../../../../core/Logger.js";import{removeMaybe as n,destroyMaybe as o}from"../../../../core/maybe.js";import{when as a,initial as h,watch as l,syncAndInitial as d}from"../../../../core/reactiveUtils.js";import{addFrameTask as c}from"../../../../core/scheduling.js";import{signal as p}from"../../../../core/signal.js";import{Milliseconds as m}from"../../../../core/time.js";import{property as u,subclass as f}from"../../../../core/accessorSupport/decorators.js";import{isMoon as g,isMars as w}from"../../../../geometry/ellipsoidUtils.js";import{debugFlags as _}from"../../support/debugFlags.js";import{ComponentObjectCollection as v}from"../collections/Component/ComponentObjectCollection.js";import{ShaderTechniqueConstructionContext as x}from"../core/shaderTechnique/ShaderTechniqueConstructionContext.js";import{ShaderTechniqueRepository as j}from"../core/shaderTechnique/ShaderTechniqueRepository.js";import{ChapmanAtmosphere as y}from"../effects/atmosphere/ChapmanAtmosphere.js";import{LocalAtmosphere as b}from"../effects/atmosphere/LocalAtmosphere.js";import{MarsAtmosphere as R}from"../effects/atmosphere/MarsAtmosphere.js";import{CloudsComposition as A}from"../effects/clouds/CloudsComposition.js";import{Fog as C}from"../effects/fog/Fog.js";import{ObjectAndLayerID as S}from"../effects/geometry/ObjectAndLayerID.js";import{olidEnabled as T}from"../effects/geometry/olidUtils.js";import{RenderOccluded as U}from"../effects/geometry/RenderOccluded.js";import{GlobalIllumination as D}from"../effects/globalIllumination/GlobalIllumination.js";import{Glow as M}from"../effects/glow/Glow.js";import{Haze as O}from"../effects/haze/Haze.js";import{Highlight as q}from"../effects/highlight/Highlight.js";import{ShadowHighlight as F}from"../effects/highlight/ShadowHighlight.js";import{ShadowHighlightBuffer as L}from"../effects/highlight/ShadowHighlightBuffer.js";import{Magnifier as k}from"../effects/magnifier/Magnifier.js";import{SMAA as W}from"../effects/smaa/SMAA.js";import{SSAO as B}from"../effects/ssao/SSAO.js";import{Stars as E}from"../effects/stars/Stars.js";import{EmissionComposite as I}from"../lib/EmissionComposite.js";import{GLMaterialRepository as H}from"../lib/GLMaterialRepository.js";import{ObjectAndLayerIdRenderHelper as G}from"../lib/ObjectAndLayerIdRenderHelper.js";import{Renderer as P}from"../lib/Renderer.js";import{RenderingContext as N}from"../lib/RenderingContext.js";import{RenderingContextOptions as z}from"../lib/RenderingContextOptions.js";import{ShadowAccumulator as V}from"../lib/ShadowAccumulator.js";import{TextureRepository as X}from"../lib/TextureRepository.js";import{createMarkerTextureRepository as Q}from"../materials/markerTextureRepository.js";import{createStippleTextureRepository as J}from"../materials/stippleTextureRepository.js";import{WaterTextureRepository as K}from"../materials/internal/WaterTextureRepository.js";import{getContextCache as Y}from"./contextCache.js";import{removeLoadedShaderModules as Z}from"./renderUtils.js";import{ScreenshotManager as $,ScreenshotContext as ee}from"./ScreenshotManager.js";import{contextCache as te}from"./testUtils.js";import{noBudget as re}from"../../../support/Scheduler.js";import{checkWebGLError as ie}from"../../../webgl/checkWebGLError.js";const se=has("disable-feature:async-navigation-3d-depth-readback");let ne=class extends t{constructor(e,t){super(e),this.olidRenderHelper=T()?new G:null,this.waterTextures=new K,this._needsUpdate=!0,this._needsRender=!0,this._idleSuspend=!0,this._needsWaterReflectionUpdate=!1,this._lastAnimationUpdate=0,this.glow=null,this._fog=p(null),this.globalIllumination=null,this.shadowAccumulator=null,this.test=null,this._initializeContext(t);const{memoryController:r}=t.view.resourceController;this.stippleTextures=J(this._rctx,r),this.markerTextures=Q(this._rctx,r),this.techniques=new j(new x(this._rctx,this.stippleTextures,this.waterTextures,this.markerTextures)),this.textures=new X(t),this.addHandles(this.textures.events.on("changed",e=>this.requestRender(e)));const i=new H(this.textures,this.techniques,()=>this.requestRender(),()=>this.requestRender());this.renderer=new P(t,i,this.techniques,this._rctx,e=>this.requestRender(e)),this.addHandles([a(()=>t.view.ready,()=>this._createRenderNodes(),h),l(()=>this.waterTextures.updating,()=>this.requestRender(),h),l(()=>t.view.qualityProfile,e=>this.renderer?.updateRenderFeatures(e),d)]);const s={renderScene:(e,t,r,i)=>(this.renderer.setTime(t),this.renderer.render(e,r,i)),requestRenderScene:e=>this.requestRender(e),prepareOverlay:()=>t.options.screenshot.prepareOverlay(),renderOverlay:(e,r,i)=>t.options.screenshot.renderOverlay(e,r,i)};this._screenshotManager=new $(this._rctx,s,e=>t.view.overlayManager.updateOverlays(re,e.camera,0)),this._registerFrameTask(t)}destroy(){const e=this.stage?.container;e?.contains(this._canvas)&&e.removeChild(this._canvas),this._frameTask=n(this._frameTask),this.techniques.destroy(),this._componentObjectCollection=o(this._componentObjectCollection),this._screenshotManager.destroy(),this.renderer.destroy(),this.textures.destroy(),this.waterTextures.destroy(),this.markerTextures.destroy(),this.stippleTextures.destroy(),this._canvas=null,this._rctx=o(this._rctx),this.test?.destroy()}_createRenderNodes(){const{view:e,viewingMode:t}=this.stage;this.shadowAccumulator=new V({view:e}),this.renderer.setShadowAccumulator(this.shadowAccumulator),new E({view:e}),g(e.spatialReference)||(this.glow=new M({view:e}),2===t?new b({view:e}):w(e.spatialReference)?new R({view:e}):(new y({view:e}),new A({view:e}),new O({view:e}),this._fog.value=new C({view:e}))),has("enable-feature:global-illumination")?this.globalIllumination=new D({view:e}):new B({view:e}),new W({view:e,isEnabled:()=>this.renderer.hasSMAA}),new k({view:e}),new q({view:e}),new L({view:e}),new F({view:e,viewingMode:t}),new I({view:e}),new U({view:e}),T()&&new S({view:e})}requestRender(e=1){switch(e){case 2:this.view.state.fading=!0;case 1:this._needsUpdate=!0,this.globalIllumination?.resetAccumulatedFrames();case 0:this._needsRender=!0}}get updating(){const e=this._needsUpdate||this._needsWaterReflectionUpdate||this.renderer.updating||this.textures.updating||this.waterTextures.updating;return e&&_.UPDATING&&console.log(" RenderView:",this._needsUpdate,this._needsWaterReflectionUpdate,this.renderer.updating,this.textures.updating,this.waterTextures.updating),e}setIdleSuspend(e){this._idleSuspend!==e&&(this._idleSuspend=e,this.requestRender())}get renderingContext(){return this._rctx}get capabilities(){return this._rctx.capabilities}get canvas(){return this._canvas}takeScreenshot(e){return this._screenshotManager.takeScreenshot(r(e))}getAlpha(){return!!this._rctx.contextAttributes.alpha}getMinimalDepthForArea(e,t,r,i,s,n=s){let o=se?this._readMainDepthSynchronously(t,r,i,s,n):this.renderer.navigationDepthCache.getMinimalDepthForArea(t,r,i,s,n)??Number.MAX_VALUE;if(e){const s=e.pickDepth(t*i.pixelRatio,r*i.pixelRatio,i);null!=s&&o>s&&s!==i.nearFar[0]&&s!==i.nearFar[1]&&(o=s)}return o===Number.MAX_VALUE?void 0:o}whenRepresentativeDepthForArea(e,t,r,i,s,n=1){return this.renderer.navigationDepthCache.whenRepresentativeDepthForArea(e,t,r,i,s,n)}_readMainDepthSynchronously(e,t,r,i,s){const n=r.constrainWindowSize(e,t,i*r.pixelRatio,s*r.pixelRatio),o=this._ensureLinearDepthArrayBuffer(n);this.renderer.readMainDepth(n,o);let a=Number.MAX_VALUE;for(let h=0;h<n[2]*n[3];h++){const e=this._linearDepthFromTexture(4*h,o,r.nearFar);a>e&&e!==r.nearFar[0]&&e!==r.nearFar[1]&&(a=e)}return a}_linearDepthFromTexture(e,t,r){return i(t,e)*(r[1]-r[0])+r[0]}_ensureLinearDepthArrayBuffer(e){const t=4*e[2]*e[3];return(null==this._tmpDepthBuffer||this._tmpDepthBuffer.byteLength<t)&&(this._tmpDepthBuffer=new Uint8Array(t)),this._tmpDepthBuffer}async reloadShaders(){Z(),await this.techniques.reloadAll(),this.renderer.overlay?.reloadShaders(),this.requestRender()}_registerFrameTask(e){const t=e.view.state;let r=!1,i=0,s=!1;const n={preRender:({time:s})=>{r=this.updating,i=this._needsUpdate?1:0,this._needsRender&&this.renderer.updateSceneDepthRange(t.camera),e.commitSyncLayers(),s=this.test?.time??s;const n=m(s-this._lastAnimationUpdate);this.view.state.animationsEnabled&&(n>this.renderer.animationTimestep||r||this._needsRender)&&(this.renderer.updateAnimation(t,s)&&this.requestRender(0),this._lastAnimationUpdate=s)},render:({time:e})=>{if(e=this.test?.time??e,this.renderer.setTime(e),(this._needsRender||!this._idleSuspend||!this.renderer.isCameraFinal||this._needsWaterReflectionUpdate)&&t.camera.fullWidth>0&&t.camera.fullHeight>0){const e=this._needsUpdate&&this._idleSuspend&&this.renderer.isCameraFinal;this._needsRender=!1,this._needsUpdate=!1,this._needsWaterReflectionUpdate=!1,this.renderer.render(t,0),s=!0,e&&this.renderer.hasReflections&&(this.requestRender(0),this._needsWaterReflectionUpdate=!0)}},update:({time:e})=>{this.view.state.animationsEnabled&&this.textures.update();const r=new ee(t,this.renderer.fboCache);e=this.test?.time??e,this._screenshotManager.update(r,e)},finish:()=>{s&&(this.renderer.finish(2===t.mode?i:1),s=!1)}};this._frameTask=c(n)}_initializeContext(e){const{options:t}=e,r=t.canvas??document.createElement("canvas");r.setAttribute("style","width: 100%; height:100%; display:block;"),this._canvas=r;const i={alpha:t.alpha||!1,premultipliedAlpha:!0,antialias:!1,depth:!0,stencil:t.stencil??!0,powerPreference:"high-performance",preserveDrawingBuffer:t.preserveDrawingBuffer??!1},n=r.getContext("webgl2",i);if(null==n)return void s.getLogger(this).error("A WebGL2 context could not be created.");ie(n,!0),this._rctx=oe(n,e),this._loadShaderOnlyExtensions(),!t.alpha&&this._rctx.contextAttributes.alpha&&s.getLogger(this).error("WebGL context has alpha channel even though no alpha channel was requested");const{container:o}=e;!this._rctx.contextAttributes.alpha&&has("safari")>=11&&(o.style.backgroundColor="black"),o.contains(r)||o.appendChild(r)}_loadShaderOnlyExtensions(){this._rctx.capabilities.enable("textureFloatLinear")}get _viewingMode(){return this.stage.viewingMode}get stage(){return this.view.stage}getObjectAndLayerIdColor(e){return this.olidRenderHelper?.getObjectAndLayerIdColor(e)}get componentObjectCollection(){return this._componentObjectCollection??=new v(this.renderer.renderPassManager,this._viewingMode,this.view.spatialReference.isWebMercator),this._componentObjectCollection}updateQualitySettings(e){null!=this.test?.time&&null!=e.fadeDuration&&(this.test.savedFadeDuration=e.fadeDuration,e.fadeDuration=m(0)),this._rctx.updateOptions({maxPreferredTexturePixels:this.view.qualitySettings.maxTexturePixels})}get fog(){return r(this._fog.value)}};function oe(e,t){const r=new z(t);if(te.enabled){let t=ae.get(e);return 1===t?.refCount?(t.configure(r),t.ref(),t):(t=new N(e,r),ae.set(e,t),t.ref(),t)}return new N(e,r)}e([u({type:Boolean,readOnly:!0})],ne.prototype,"updating",null),e([u({constructOnly:!0})],ne.prototype,"view",void 0),e([u({readOnly:!0})],ne.prototype,"componentObjectCollection",null),e([u()],ne.prototype,"_componentObjectCollection",void 0),e([u()],ne.prototype,"_needsUpdate",void 0),e([u()],ne.prototype,"_needsWaterReflectionUpdate",void 0),ne=e([f("esri.views.3d.webgl-engine.parts.RenderView")],ne);const ae=Y();export{ne as RenderView};
2
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{toConst as r}from"../../../../core/compilerUtils.js";import{unpackFloatRGBA as i}from"../../../../core/floatRGBA.js";import has from"../../../../core/has.js";import s from"../../../../core/Logger.js";import{removeMaybe as n,destroyMaybe as o}from"../../../../core/maybe.js";import{when as a,initial as h,watch as l,syncAndInitial as d}from"../../../../core/reactiveUtils.js";import{addFrameTask as c}from"../../../../core/scheduling.js";import{signal as p}from"../../../../core/signal.js";import{Milliseconds as m}from"../../../../core/time.js";import{property as u,subclass as f}from"../../../../core/accessorSupport/decorators.js";import{isMoon as g,isMars as w}from"../../../../geometry/ellipsoidUtils.js";import{debugFlags as _}from"../../support/debugFlags.js";import{ComponentObjectCollection as v}from"../collections/Component/ComponentObjectCollection.js";import{ShaderTechniqueConstructionContext as x}from"../core/shaderTechnique/ShaderTechniqueConstructionContext.js";import{ShaderTechniqueRepository as j}from"../core/shaderTechnique/ShaderTechniqueRepository.js";import{ChapmanAtmosphere as y}from"../effects/atmosphere/ChapmanAtmosphere.js";import{LocalAtmosphere as b}from"../effects/atmosphere/LocalAtmosphere.js";import{MarsAtmosphere as R}from"../effects/atmosphere/MarsAtmosphere.js";import{CloudsComposition as A}from"../effects/clouds/CloudsComposition.js";import{Fog as C}from"../effects/fog/Fog.js";import{ObjectAndLayerID as S}from"../effects/geometry/ObjectAndLayerID.js";import{olidEnabled as T}from"../effects/geometry/olidUtils.js";import{RenderOccluded as U}from"../effects/geometry/RenderOccluded.js";import{GlobalIllumination as D}from"../effects/globalIllumination/GlobalIllumination.js";import{Glow as M}from"../effects/glow/Glow.js";import{Haze as O}from"../effects/haze/Haze.js";import{Highlight as q}from"../effects/highlight/Highlight.js";import{ShadowHighlight as F}from"../effects/highlight/ShadowHighlight.js";import{ShadowHighlightBuffer as L}from"../effects/highlight/ShadowHighlightBuffer.js";import{Magnifier as k}from"../effects/magnifier/Magnifier.js";import{SMAA as W}from"../effects/smaa/SMAA.js";import{SSAO as B}from"../effects/ssao/SSAO.js";import{Stars as E}from"../effects/stars/Stars.js";import{EmissionComposite as I}from"../lib/EmissionComposite.js";import{GLMaterialRepository as H}from"../lib/GLMaterialRepository.js";import{ObjectAndLayerIdRenderHelper as G}from"../lib/ObjectAndLayerIdRenderHelper.js";import{Renderer as P}from"../lib/Renderer.js";import{RenderingContext as N}from"../lib/RenderingContext.js";import{RenderingContextOptions as z}from"../lib/RenderingContextOptions.js";import{ShadowAccumulator as V}from"../lib/ShadowAccumulator.js";import{ShadowCastRenderer as X}from"../lib/ShadowCastRenderer.js";import{TextureRepository as Q}from"../lib/TextureRepository.js";import{createMarkerTextureRepository as J}from"../materials/markerTextureRepository.js";import{createStippleTextureRepository as K}from"../materials/stippleTextureRepository.js";import{WaterTextureRepository as Y}from"../materials/internal/WaterTextureRepository.js";import{getContextCache as Z}from"./contextCache.js";import{removeLoadedShaderModules as $}from"./renderUtils.js";import{ScreenshotManager as ee,ScreenshotContext as te}from"./ScreenshotManager.js";import{contextCache as re}from"./testUtils.js";import{noBudget as ie}from"../../../support/Scheduler.js";import{checkWebGLError as se}from"../../../webgl/checkWebGLError.js";const ne=has("disable-feature:async-navigation-3d-depth-readback");let oe=class extends t{constructor(e,t){super(e),this.olidRenderHelper=T()?new G:null,this.waterTextures=new Y,this._needsUpdate=!0,this._needsRender=!0,this._idleSuspend=!0,this._needsWaterReflectionUpdate=!1,this._lastAnimationUpdate=0,this.glow=null,this._fog=p(null),this.globalIllumination=null,this.shadowAccumulator=null,this.test=null,this._initializeContext(t);const{memoryController:r}=t.view.resourceController;this.stippleTextures=K(this._rctx,r),this.markerTextures=J(this._rctx,r),this.techniques=new j(new x(this._rctx,this.stippleTextures,this.waterTextures,this.markerTextures)),this.textures=new Q(t),this.addHandles(this.textures.events.on("changed",e=>this.requestRender(e)));const i=new H(this.textures,this.techniques,()=>this.requestRender(),()=>this.requestRender());this.renderer=new P(t,i,this.techniques,this._rctx,e=>this.requestRender(e)),this.addHandles([a(()=>t.view.ready,()=>this._createRenderNodes(),h),l(()=>this.waterTextures.updating,()=>this.requestRender(),h),l(()=>t.view.qualityProfile,e=>this.renderer?.updateRenderFeatures(e),d)]);const s={renderScene:(e,t,r,i)=>(this.renderer.setTime(t),this.renderer.render(e,r,i)),requestRenderScene:e=>this.requestRender(e),prepareOverlay:()=>t.options.screenshot.prepareOverlay(),renderOverlay:(e,r,i)=>t.options.screenshot.renderOverlay(e,r,i)};this._screenshotManager=new ee(this._rctx,s,e=>t.view.overlayManager.updateOverlays(ie,e.camera,0)),this._registerFrameTask(t)}destroy(){const e=this.stage?.container;e?.contains(this._canvas)&&e.removeChild(this._canvas),this._frameTask=n(this._frameTask),this.techniques.destroy(),this._componentObjectCollection=o(this._componentObjectCollection),this._screenshotManager.destroy(),this.renderer.destroy(),this.textures.destroy(),this.waterTextures.destroy(),this.markerTextures.destroy(),this.stippleTextures.destroy(),this._canvas=null,this._rctx=o(this._rctx),this.test?.destroy()}_createRenderNodes(){const{view:e,viewingMode:t}=this.stage;this.shadowAccumulator=new V({view:e}),this.shadowAccumulator.accumulationRenderer=new X({view:e,data:this.shadowAccumulator}),this.renderer.setShadowAccumulator(this.shadowAccumulator),new E({view:e}),g(e.spatialReference)||(this.glow=new M({view:e}),2===t?new b({view:e}):w(e.spatialReference)?new R({view:e}):(new y({view:e}),new A({view:e}),new O({view:e}),this._fog.value=new C({view:e}))),has("enable-feature:global-illumination")?this.globalIllumination=new D({view:e}):new B({view:e}),new W({view:e,isEnabled:()=>this.renderer.hasSMAA}),new k({view:e}),new q({view:e}),new L({view:e}),new F({view:e,viewingMode:t}),new I({view:e}),new U({view:e}),T()&&new S({view:e})}requestRender(e=1){switch(e){case 2:this.view.state.fading=!0;case 1:this._needsUpdate=!0,this.globalIllumination?.resetAccumulatedFrames();case 0:this._needsRender=!0}}get updating(){const e=this._needsUpdate||this._needsWaterReflectionUpdate||this.renderer.updating||this.textures.updating||this.waterTextures.updating;return e&&_.UPDATING&&console.log(" RenderView:",this._needsUpdate,this._needsWaterReflectionUpdate,this.renderer.updating,this.textures.updating,this.waterTextures.updating),e}setIdleSuspend(e){this._idleSuspend!==e&&(this._idleSuspend=e,this.requestRender())}get renderingContext(){return this._rctx}get capabilities(){return this._rctx.capabilities}get canvas(){return this._canvas}takeScreenshot(e){return this._screenshotManager.takeScreenshot(r(e))}getAlpha(){return!!this._rctx.contextAttributes.alpha}getMinimalDepthForArea(e,t,r,i,s,n=s){let o=ne?this._readMainDepthSynchronously(t,r,i,s,n):this.renderer.navigationDepthCache.getMinimalDepthForArea(t,r,i,s,n)??Number.MAX_VALUE;if(e){const s=e.pickDepth(t*i.pixelRatio,r*i.pixelRatio,i);null!=s&&o>s&&s!==i.nearFar[0]&&s!==i.nearFar[1]&&(o=s)}return o===Number.MAX_VALUE?void 0:o}whenRepresentativeDepthForArea(e,t,r,i,s,n=1){return this.renderer.navigationDepthCache.whenRepresentativeDepthForArea(e,t,r,i,s,n)}_readMainDepthSynchronously(e,t,r,i,s){const n=r.constrainWindowSize(e,t,i*r.pixelRatio,s*r.pixelRatio),o=this._ensureLinearDepthArrayBuffer(n);this.renderer.readMainDepth(n,o);let a=Number.MAX_VALUE;for(let h=0;h<n[2]*n[3];h++){const e=this._linearDepthFromTexture(4*h,o,r.nearFar);a>e&&e!==r.nearFar[0]&&e!==r.nearFar[1]&&(a=e)}return a}_linearDepthFromTexture(e,t,r){return i(t,e)*(r[1]-r[0])+r[0]}_ensureLinearDepthArrayBuffer(e){const t=4*e[2]*e[3];return(null==this._tmpDepthBuffer||this._tmpDepthBuffer.byteLength<t)&&(this._tmpDepthBuffer=new Uint8Array(t)),this._tmpDepthBuffer}async reloadShaders(){$(),await this.techniques.reloadAll(),this.renderer.overlay?.reloadShaders(),this.requestRender()}_registerFrameTask(e){const t=e.view.state;let r=!1,i=0,s=!1;const n={preRender:({time:s})=>{r=this.updating,i=this._needsUpdate?1:0,this._needsRender&&this.renderer.updateSceneDepthRange(t.camera),e.commitSyncLayers(),s=this.test?.time??s;const n=m(s-this._lastAnimationUpdate);this.view.state.animationsEnabled&&(n>this.renderer.animationTimestep||r||this._needsRender)&&(this.renderer.updateAnimation(t,s)&&this.requestRender(0),this._lastAnimationUpdate=s)},render:({time:e})=>{if(e=this.test?.time??e,this.renderer.setTime(e),(this._needsRender||!this._idleSuspend||!this.renderer.isCameraFinal||this._needsWaterReflectionUpdate)&&t.camera.fullWidth>0&&t.camera.fullHeight>0){const e=this._needsUpdate&&this._idleSuspend&&this.renderer.isCameraFinal;this._needsRender=!1,this._needsUpdate=!1,this._needsWaterReflectionUpdate=!1,this.renderer.render(t,0),s=!0,e&&this.renderer.hasReflections&&(this.requestRender(0),this._needsWaterReflectionUpdate=!0)}},update:({time:e})=>{this.view.state.animationsEnabled&&this.textures.update();const r=new te(t,this.renderer.fboCache);e=this.test?.time??e,this._screenshotManager.update(r,e)},finish:()=>{s&&(this.renderer.finish(2===t.mode?i:1),s=!1)}};this._frameTask=c(n)}_initializeContext(e){const{options:t}=e,r=t.canvas??document.createElement("canvas");r.setAttribute("style","width: 100%; height:100%; display:block;"),this._canvas=r;const i={alpha:t.alpha||!1,premultipliedAlpha:!0,antialias:!1,depth:!0,stencil:t.stencil??!0,powerPreference:"high-performance",preserveDrawingBuffer:t.preserveDrawingBuffer??!1},n=r.getContext("webgl2",i);if(null==n)return void s.getLogger(this).error("A WebGL2 context could not be created.");se(n,!0),this._rctx=ae(n,e),this._loadShaderOnlyExtensions(),!t.alpha&&this._rctx.contextAttributes.alpha&&s.getLogger(this).error("WebGL context has alpha channel even though no alpha channel was requested");const{container:o}=e;!this._rctx.contextAttributes.alpha&&has("safari")>=11&&(o.style.backgroundColor="black"),o.contains(r)||o.appendChild(r)}_loadShaderOnlyExtensions(){this._rctx.capabilities.enable("textureFloatLinear")}get _viewingMode(){return this.stage.viewingMode}get stage(){return this.view.stage}getObjectAndLayerIdColor(e){return this.olidRenderHelper?.getObjectAndLayerIdColor(e)}get componentObjectCollection(){return this._componentObjectCollection??=new v(this.renderer.renderPassManager,this._viewingMode,this.view.spatialReference.isWebMercator),this._componentObjectCollection}updateQualitySettings(e){null!=this.test?.time&&null!=e.fadeDuration&&(this.test.savedFadeDuration=e.fadeDuration,e.fadeDuration=m(0)),this._rctx.updateOptions({maxPreferredTexturePixels:this.view.qualitySettings.maxTexturePixels})}get fog(){return r(this._fog.value)}};function ae(e,t){const r=new z(t);if(re.enabled){let t=he.get(e);return 1===t?.refCount?(t.configure(r),t.ref(),t):(t=new N(e,r),he.set(e,t),t.ref(),t)}return new N(e,r)}e([u({type:Boolean,readOnly:!0})],oe.prototype,"updating",null),e([u({constructOnly:!0})],oe.prototype,"view",void 0),e([u({readOnly:!0})],oe.prototype,"componentObjectCollection",null),e([u()],oe.prototype,"_componentObjectCollection",void 0),e([u()],oe.prototype,"_needsUpdate",void 0),e([u()],oe.prototype,"_needsWaterReflectionUpdate",void 0),oe=e([f("esri.views.3d.webgl-engine.parts.RenderView")],oe);const he=Z();export{oe as RenderView};
@@ -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{UndoRedo as o}from"../../UndoRedo.js";import{createTask as r}from"../../core/asyncUtils.js";import{makeHandle as i}from"../../core/handleUtils.js";import{destroyMaybe as s}from"../../core/maybe.js";import{watch as n,syncAndInitial as a,sync as l}from"../../core/reactiveUtils.js";import{property as p,subclass as c}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as d}from"../../core/support/UpdatingHandles.js";import{load as h}from"../../geometry/coordinateFormatter.js";import u from"../../layers/GraphicsLayer.js";import{pointEquals as m}from"../../layers/graphics/dehydratedFeatureComparison.js";import{CreateOperationGeometry as y}from"./support/CreateOperationGeometry.js";import{createCircle as g,createEllipse as v,createSquare as f,createRectangle as _,createPolygon as O,createPolyline as w,createMultipoint as G}from"./support/createUtils.js";import{createViewAlignedCoordinateSystem as C}from"./support/surfaceCoordinateSystems.js";import{createTooltipInfos as x,initializeConstraints as V,updateTooltipInfo as k,getConstraintZ as b,unlockConstraintsOnVertexAddOrRemove as U,lockElevationOnVertexAdd as H,getActiveTooltipInfo as T}from"./support/tooltipUtils.js";import{InteractiveToolBase as S}from"../interactive/InteractiveToolBase.js";import j from"../interactive/sketch/SketchOptions.js";import{makeTooltip as L,pasteLocation as R,enterInputModeIfAvailable as z}from"../interactive/tooltip/tooltipCommonUtils.js";import{GeometryWorkerHandle as E}from"../support/GeometryWorkerHandle.js";import{autorun as I}from"../../core/accessorSupport/trackingUtils.js";let A=class extends S{constructor(e){super(e),this._graphic=null,this._coordinateFormatterLoadTask=null,this._createOperationGeometry=null,this.defaultZ=0,this.directionOptions=null,this.elevationLockOnVertexAddDisabled=!1,this.geometryType=null,this.hasZ=!0,this.geometryToPlace=null,this.snappingManager=null,this.snapToScene=!1,this.sketchOptions=new j,this._updatingHandles=new d,this._measurementWorker=new E({preloadGeodetic:!0})}initialize(){const{view:e}=this;this.internalGraphicsLayer=new u({listMode:"hide",internal:!0,title:"DrawGraphicTool layer"}),this.view.map.layers.add(this.internalGraphicsLayer);const t=this.drawOperation=this.makeDrawOperation();this.tooltipInfos=x(e.type,this.sketchOptions);const o=L(()=>({view:e,options:this.sketchOptions.tooltips}));this.tooltip=o,V(this._tooltipsContext),this._coordinateFormatterLoadTask=r(()=>h()),this.addHandles([t.on("vertex-add",e=>this.onVertexAdd(e)),t.on("vertex-remove",e=>this.onVertexRemove(e)),t.on("vertex-update",e=>this.onVertexUpdate(e)),t.on("cursor-update",e=>this.onCursorUpdate(e)),t.on("cursor-remove",()=>this._updateGraphic()),t.on("complete",e=>this.onComplete(e)),this._coordinateFormatterLoadTask,o.on("paste",e=>R(e,this.activeTooltipInfo)),n(()=>this.cursor,e=>{t.cursor=e},a),I(()=>{const{activeTooltipInfo:e,sketchOptions:t}=this;k(e,this._tooltipsContext,this._updatingHandles),o.info=t.tooltips.effectiveEnabled?e:null}),I(()=>{t.constraintZ=b(this._tooltipsContext)},l)]),this.finishToolCreation(),t.initializePointer()}destroy(){this.drawOperation=s(this.drawOperation),this.tooltip=s(this.tooltip),this._destroyAllVisualizations(),this.view.map.remove(this.internalGraphicsLayer),this.internalGraphicsLayer=s(this.internalGraphicsLayer),this._updatingHandles.destroy(),this._measurementWorker.destroy(),this._set("view",null)}get _drawSpatialReference(){return this.drawOperation.coordinateHelper.spatialReference}get _tooltipsContext(){const{defaultZ:e,directionOptions:t,drawOperation:o,forceUniformSize:r,geometryType:i,graphic:s,sketchOptions:n,tooltipInfos:a,view:l,_measurementWorker:p}=this;return{createOperationGeometry:this._createOperationGeometry,defaultZ:e,directionOptions:t,drawOperation:o,forceUniformSize:r,geometryType:i,graphic:s,sketchOptions:n,tooltipInfos:a,view:l,measurementWorker:p}}get canRedo(){return this.drawOperation.canRedo}get canUndo(){return this.drawOperation.canUndo}set centered(e){this._set("centered",e),this._updateGraphic()}get cursor(){return this._get("cursor")}set cursor(e){this._set("cursor",e)}set enabled(e){this.drawOperation.interactive=e,this._set("enabled",e)}set forceUniformSize(e){this._set("forceUniformSize",e),this._updateGraphic()}get graphic(){return this._graphic}set graphicSymbol(e){this._set("graphicSymbol",e),null!=this._graphic&&(this._graphic.symbol=e)}set mode(e){const t=this.drawOperation;t&&(t.drawingMode=e),this._set("mode",e)}get updating(){return(this._updatingHandles.updating||this.drawOperation?.updating)??!1}get undoRedo(){const{view:{type:e,map:t}}=this;return"2d"===e&&t&&"undoRedo"in t&&t.undoRedo instanceof o?t.undoRedo:null}set undoRedo(e){this._override("undoRedo",e)}completeCreateOperation(){this.drawOperation.complete()}onInputEvent(e){this.destroyed||z(e,this.tooltip)||this.drawOperation.onInputEvent(e)}redo(){this.drawOperation.redo()}reset(){}undo(){this.drawOperation.undo(),0===this.drawOperation.numCommittedVertices&&V(this._tooltipsContext)}_destroyAllVisualizations(){this.removeHandles(F.outline),this.removeHandles(F.regularVertices),this.removeHandles(F.activeVertex),this.removeHandles(F.activeEdge),this.removeHandles(D)}_createOrUpdateGraphic(e){if(null!=this._graphic)return this.updateGraphicGeometry(e),this._graphic;const o=new t({...this.graphicProperties,symbol:this.graphicSymbol});return this._graphic=o,this.updateGraphicGeometry(e),this.internalGraphicsLayer.add(o),this.addHandles(this.initializeGraphic(o)),this.notifyChange("graphic"),this.addHandles(i(()=>{this.internalGraphicsLayer.remove(o),this._graphic===o&&(this._graphic=null)}),D),o}updateGraphicGeometry(e){this._graphic.geometry=e}_getCreateOperationGeometry(e={operationComplete:!1}){if(null==this.drawOperation)return;const{coordinateHelper:t,view:o,visualizationCursorVertex:r,lastVertex:i,committedVertices:s,geometryIncludingUncommittedVertices:n,numCommittedVertices:a}=this.drawOperation;if(!(a>0||null!=r))return;const l=e.operationComplete?s:n,p=l.length,c=null!=r?t.pointToArray(r):null,d=this._drawSpatialReference,h="3d"===o.type&&"global"===o.viewingMode,u=new y;u.committedVertices=s,u.cursorVertex=c;const{geometryType:x}=this;switch(x){case"point":case"mesh":u.full=t.arrayToPoint(l[0]);break;case"multipoint":u.full=p>0?G(l,d):null;break;case"polyline":case"polygon":p>0&&(u.full="polygon"===x?O([l],d,h,!0):w([l],d,h),u.cursorEdge=null!=c&&i&&!m(r,i)?w([[c,t.pointToArray(i)]],d,h):null,u.outline=p>1?u.full:null);break;case"circle":case"rectangle":{if(u.committedVertices=u.cursorVertex=null,!p)break;const t=C(o,l[0]),r=l[0],i=t.makeMapPoint(r[0]+Z*o.resolution,r[1]);"circle"===x?1===p&&e.operationComplete?u.circle=g([r,i],t,!0):2===p&&(this.forceUniformSize?u.circle=g(l,t,this.centered):u.rectangle=v(l,t,this.centered)):1===p&&e.operationComplete?u.rectangle=f([r,i],t,!0):2===p&&(u.rectangle=this.forceUniformSize?f(l,t,this.centered):_(l,t,this.centered)),u.full=null!=u.circle?u.circle.geometry:u.rectangle?.geometry,u.outline="polygon"===u.full?.type?u.full:null;break}default:return null}return u}initializeGraphic(e){return i()}onComplete(e){if(!this.drawOperation)return;this._updateGraphic();let t=null;if(this.drawOperation.isCompleted){const e=this._getCreateOperationGeometry({operationComplete:!0});null!=e&&(t=this._createOrUpdateGraphic(e.full))}this._createOperationGeometry=null,this.emit("complete",{graphic:t,...e})}onCursorUpdate(e){this._updateGraphic(),this.emit("cursor-update",e)}onDeactivate(){const{drawOperation:e}=this;e&&(e.isCompleted||e.cancel())}onOutlineChanged(e){return i()}onCursorEdgeChanged(e){return i()}onVertexAdd(e){U(this._tooltipsContext),this._updateGraphic(),this.elevationLockOnVertexAddDisabled||H(e.vertices.at(0)?.coordinates,this._tooltipsContext),this.emit("vertex-add",e)}onVertexRemove(e){U(this._tooltipsContext),this._updateGraphic(),this.emit("vertex-remove",e)}onVertexUpdate(e){this._updateGraphic(),this.emit("vertex-update",e)}_updateGraphic(){const e=this._getCreateOperationGeometry();this._createOperationGeometry=e,null!=e?(null!=e.cursorEdge?this.addHandles(this.onCursorEdgeChanged(e.cursorEdge),F.activeEdge):this.removeHandles(F.activeEdge),null!=e.outline?this.addHandles(this.onOutlineChanged(e.outline),F.outline):this.removeHandles(F.outline),null!=e.committedVertices?this.addHandles(this.onRegularVerticesChanged(e.committedVertices),F.regularVertices):this.removeHandles(F.regularVertices),null!=e.cursorVertex?this.addHandles(this.onActiveVertexChanged(e.cursorVertex),F.activeVertex):this.removeHandles(F.activeVertex),null!=e.full?this._createOrUpdateGraphic(e.full):this.removeHandles(D)):this._destroyAllVisualizations()}get activeTooltipInfo(){return this._coordinateFormatterLoadTask?.finished?T(this._tooltipsContext):null}};e([p()],A.prototype,"_coordinateFormatterLoadTask",void 0),e([p()],A.prototype,"_createOperationGeometry",void 0),e([p()],A.prototype,"_tooltipsContext",null),e([p({value:!0})],A.prototype,"centered",null),e([p()],A.prototype,"cursor",null),e([p({nonNullable:!0})],A.prototype,"defaultZ",void 0),e([p({constructOnly:!0})],A.prototype,"directionOptions",void 0),e([p()],A.prototype,"drawOperation",void 0),e([p()],A.prototype,"elevationLockOnVertexAddDisabled",void 0),e([p({value:!0})],A.prototype,"enabled",null),e([p({value:!0})],A.prototype,"forceUniformSize",null),e([p({constructOnly:!0})],A.prototype,"geometryType",void 0),e([p()],A.prototype,"graphic",null),e([p({constructOnly:!0})],A.prototype,"graphicProperties",void 0),e([p()],A.prototype,"graphicSymbol",null),e([p({constructOnly:!0})],A.prototype,"hasZ",void 0),e([p({constructOnly:!0})],A.prototype,"geometryToPlace",void 0),e([p()],A.prototype,"mode",null),e([p()],A.prototype,"snappingManager",void 0),e([p()],A.prototype,"snapToScene",void 0),e([p()],A.prototype,"tooltip",void 0),e([p()],A.prototype,"tooltipInfos",void 0),e([p({constructOnly:!0,type:j})],A.prototype,"sketchOptions",void 0),e([p()],A.prototype,"updating",null),e([p({constructOnly:!0,nonNullable:!0})],A.prototype,"view",void 0),e([p({constructOnly:!0})],A.prototype,"undoRedo",null),e([p()],A.prototype,"activeTooltipInfo",null),A=e([c("esri.views.draw.DrawGraphicTool")],A);const D=Symbol("create-operation-graphic"),F={outline:Symbol("outline-visual"),regularVertices:Symbol("regular-vertices-visual"),activeVertex:Symbol("active-vertex-visual"),activeEdge:Symbol("active-edge-visual")};function P(e){switch(e){case"point":case"polyline":case"polygon":case"multipoint":return e;case"circle":case"rectangle":return"segment";case"mesh":return"point"}}const Z=48;export{A as DrawGraphicTool,P as geometryTypeToDrawOperationGeometryType};
2
+ import{__decorate as t}from"tslib";import e from"../../Graphic.js";import{UndoRedo as o}from"../../UndoRedo.js";import{createTask as r}from"../../core/asyncUtils.js";import{makeHandle as i}from"../../core/handleUtils.js";import{destroyMaybe as s}from"../../core/maybe.js";import{watch as n,syncAndInitial as a,sync as l}from"../../core/reactiveUtils.js";import{property as p,subclass as c}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as d}from"../../core/support/UpdatingHandles.js";import{load as h}from"../../geometry/coordinateFormatter.js";import u from"../../layers/GraphicsLayer.js";import{pointEquals as m}from"../../layers/graphics/dehydratedFeatureComparison.js";import{CreateOperationGeometry as y}from"./support/CreateOperationGeometry.js";import{createCircle as g,createEllipse as v,createSquare as f,createRectangle as _,createPolygon as O,createPolyline as w,createMultipoint as G}from"./support/createUtils.js";import{createViewAlignedCoordinateSystem as C}from"./support/surfaceCoordinateSystems.js";import{createTooltipInfos as x,initializeConstraints as V,updateTooltipInfo as b,getConstraintZ as T,unlockConstraintsOnVertexAddOrRemove as U,lockElevationOnVertexAdd as H,getActiveTooltipInfo as S}from"./support/tooltipUtils.js";import{InteractiveToolBase as k}from"../interactive/InteractiveToolBase.js";import j from"../interactive/options/InteractiveToolOptions.js";import{makeTooltip as L,pasteLocation as R,enterInputModeIfAvailable as z}from"../interactive/tooltip/tooltipCommonUtils.js";import{GeometryWorkerHandle as I}from"../support/GeometryWorkerHandle.js";import{autorun as E}from"../../core/accessorSupport/trackingUtils.js";let A=class extends k{constructor(t){super(t),this._graphic=null,this._coordinateFormatterLoadTask=null,this._createOperationGeometry=null,this.defaultZ=0,this.directionOptions=null,this.elevationLockOnVertexAddDisabled=!1,this.geometryType=null,this.hasZ=!0,this.geometryToPlace=null,this.snappingManager=null,this.snapToScene=!1,this.toolOptions=new j,this._updatingHandles=new d,this._measurementWorker=new I({preloadGeodetic:!0})}initialize(){const{view:t}=this;this.internalGraphicsLayer=new u({listMode:"hide",internal:!0,title:"DrawGraphicTool layer"}),this.view.map.layers.add(this.internalGraphicsLayer);const e=this.drawOperation=this.makeDrawOperation();this.tooltipInfos=x(t.type,this.toolOptions);const o=L(()=>({view:t,options:this.toolOptions.tooltips}));this.tooltip=o,V(this._tooltipsContext),this._coordinateFormatterLoadTask=r(()=>h()),this.addHandles([e.on("vertex-add",t=>this.onVertexAdd(t)),e.on("vertex-remove",t=>this.onVertexRemove(t)),e.on("vertex-update",t=>this.onVertexUpdate(t)),e.on("cursor-update",t=>this.onCursorUpdate(t)),e.on("cursor-remove",()=>this._updateGraphic()),e.on("complete",t=>this.onComplete(t)),this._coordinateFormatterLoadTask,o.on("paste",t=>R(t,this.activeTooltipInfo)),n(()=>this.cursor,t=>{e.cursor=t},a),E(()=>{const{activeTooltipInfo:t,toolOptions:e}=this;b(t,this._tooltipsContext,this._updatingHandles),o.info=e.tooltips.effectiveEnabled?t:null}),E(()=>{e.constraintZ=T(this._tooltipsContext)},l)]),this.finishToolCreation(),e.initializePointer()}destroy(){this.drawOperation=s(this.drawOperation),this.tooltip=s(this.tooltip),this._destroyAllVisualizations(),this.view.map.remove(this.internalGraphicsLayer),this.internalGraphicsLayer=s(this.internalGraphicsLayer),this._updatingHandles.destroy(),this._measurementWorker.destroy(),this._set("view",null)}get _drawSpatialReference(){return this.drawOperation.coordinateHelper.spatialReference}get _tooltipsContext(){const{defaultZ:t,directionOptions:e,drawOperation:o,forceUniformSize:r,geometryType:i,graphic:s,toolOptions:n,tooltipInfos:a,view:l,_measurementWorker:p}=this;return{createOperationGeometry:this._createOperationGeometry,defaultZ:t,directionOptions:e,drawOperation:o,forceUniformSize:r,geometryType:i,graphic:s,toolOptions:n,tooltipInfos:a,view:l,measurementWorker:p}}get canRedo(){return this.drawOperation.canRedo}get canUndo(){return this.drawOperation.canUndo}set centered(t){this._set("centered",t),this._updateGraphic()}get cursor(){return this._get("cursor")}set cursor(t){this._set("cursor",t)}set enabled(t){this.drawOperation.interactive=t,this._set("enabled",t)}set forceUniformSize(t){this._set("forceUniformSize",t),this._updateGraphic()}get graphic(){return this._graphic}set graphicSymbol(t){this._set("graphicSymbol",t),null!=this._graphic&&(this._graphic.symbol=t)}set mode(t){const e=this.drawOperation;e&&(e.drawingMode=t),this._set("mode",t)}get updating(){return(this._updatingHandles.updating||this.drawOperation?.updating)??!1}get undoRedo(){const{view:{type:t,map:e}}=this;return"2d"===t&&e&&"undoRedo"in e&&e.undoRedo instanceof o?e.undoRedo:null}set undoRedo(t){this._override("undoRedo",t)}completeCreateOperation(){this.drawOperation.complete()}onInputEvent(t){this.destroyed||z(t,this.tooltip)||this.drawOperation.onInputEvent(t)}redo(){this.drawOperation.redo()}reset(){}undo(){this.drawOperation.undo(),0===this.drawOperation.numCommittedVertices&&V(this._tooltipsContext)}_destroyAllVisualizations(){this.removeHandles(F.outline),this.removeHandles(F.regularVertices),this.removeHandles(F.activeVertex),this.removeHandles(F.activeEdge),this.removeHandles(D)}_createOrUpdateGraphic(t){if(null!=this._graphic)return this.updateGraphicGeometry(t),this._graphic;const o=new e({...this.graphicProperties,symbol:this.graphicSymbol});return this._graphic=o,this.updateGraphicGeometry(t),this.internalGraphicsLayer.add(o),this.addHandles(this.initializeGraphic(o)),this.notifyChange("graphic"),this.addHandles(i(()=>{this.internalGraphicsLayer.remove(o),this._graphic===o&&(this._graphic=null)}),D),o}updateGraphicGeometry(t){this._graphic.geometry=t}_getCreateOperationGeometry(t={operationComplete:!1}){if(null==this.drawOperation)return;const{coordinateHelper:e,view:o,visualizationCursorVertex:r,lastVertex:i,committedVertices:s,geometryIncludingUncommittedVertices:n,numCommittedVertices:a}=this.drawOperation;if(!(a>0||null!=r))return;const l=t.operationComplete?s:n,p=l.length,c=null!=r?e.pointToArray(r):null,d=this._drawSpatialReference,h="3d"===o.type&&"global"===o.viewingMode,u=new y;u.committedVertices=s,u.cursorVertex=c;const{geometryType:x}=this;switch(x){case"point":case"mesh":u.full=e.arrayToPoint(l[0]);break;case"multipoint":u.full=p>0?G(l,d):null;break;case"polyline":case"polygon":p>0&&(u.full="polygon"===x?O([l],d,h,!0):w([l],d,h),u.cursorEdge=null!=c&&i&&!m(r,i)?w([[c,e.pointToArray(i)]],d,h):null,u.outline=p>1?u.full:null);break;case"circle":case"rectangle":{if(u.committedVertices=u.cursorVertex=null,!p)break;const e=C(o,l[0]),r=l[0],i=e.makeMapPoint(r[0]+Z*o.resolution,r[1]);"circle"===x?1===p&&t.operationComplete?u.circle=g([r,i],e,!0):2===p&&(this.forceUniformSize?u.circle=g(l,e,this.centered):u.rectangle=v(l,e,this.centered)):1===p&&t.operationComplete?u.rectangle=f([r,i],e,!0):2===p&&(u.rectangle=this.forceUniformSize?f(l,e,this.centered):_(l,e,this.centered)),u.full=null!=u.circle?u.circle.geometry:u.rectangle?.geometry,u.outline="polygon"===u.full?.type?u.full:null;break}default:return null}return u}initializeGraphic(t){return i()}onComplete(t){if(!this.drawOperation)return;this._updateGraphic();let e=null;if(this.drawOperation.isCompleted){const t=this._getCreateOperationGeometry({operationComplete:!0});null!=t&&(e=this._createOrUpdateGraphic(t.full))}this._createOperationGeometry=null,this.emit("complete",{graphic:e,...t})}onCursorUpdate(t){this._updateGraphic(),this.emit("cursor-update",t)}onDeactivate(){const{drawOperation:t}=this;t&&(t.isCompleted||t.cancel())}onOutlineChanged(t){return i()}onCursorEdgeChanged(t){return i()}onVertexAdd(t){U(this._tooltipsContext),this._updateGraphic(),this.elevationLockOnVertexAddDisabled||H(t.vertices.at(0)?.coordinates,this._tooltipsContext),this.emit("vertex-add",t)}onVertexRemove(t){U(this._tooltipsContext),this._updateGraphic(),this.emit("vertex-remove",t)}onVertexUpdate(t){this._updateGraphic(),this.emit("vertex-update",t)}_updateGraphic(){const t=this._getCreateOperationGeometry();this._createOperationGeometry=t,null!=t?(null!=t.cursorEdge?this.addHandles(this.onCursorEdgeChanged(t.cursorEdge),F.activeEdge):this.removeHandles(F.activeEdge),null!=t.outline?this.addHandles(this.onOutlineChanged(t.outline),F.outline):this.removeHandles(F.outline),null!=t.committedVertices?this.addHandles(this.onRegularVerticesChanged(t.committedVertices),F.regularVertices):this.removeHandles(F.regularVertices),null!=t.cursorVertex?this.addHandles(this.onActiveVertexChanged(t.cursorVertex),F.activeVertex):this.removeHandles(F.activeVertex),null!=t.full?this._createOrUpdateGraphic(t.full):this.removeHandles(D)):this._destroyAllVisualizations()}get activeTooltipInfo(){return this._coordinateFormatterLoadTask?.finished?S(this._tooltipsContext):null}};t([p()],A.prototype,"_coordinateFormatterLoadTask",void 0),t([p()],A.prototype,"_createOperationGeometry",void 0),t([p()],A.prototype,"_tooltipsContext",null),t([p({value:!0})],A.prototype,"centered",null),t([p()],A.prototype,"cursor",null),t([p({nonNullable:!0})],A.prototype,"defaultZ",void 0),t([p({constructOnly:!0})],A.prototype,"directionOptions",void 0),t([p()],A.prototype,"drawOperation",void 0),t([p()],A.prototype,"elevationLockOnVertexAddDisabled",void 0),t([p({value:!0})],A.prototype,"enabled",null),t([p({value:!0})],A.prototype,"forceUniformSize",null),t([p({constructOnly:!0})],A.prototype,"geometryType",void 0),t([p()],A.prototype,"graphic",null),t([p({constructOnly:!0})],A.prototype,"graphicProperties",void 0),t([p()],A.prototype,"graphicSymbol",null),t([p({constructOnly:!0})],A.prototype,"hasZ",void 0),t([p({constructOnly:!0})],A.prototype,"geometryToPlace",void 0),t([p()],A.prototype,"mode",null),t([p()],A.prototype,"snappingManager",void 0),t([p()],A.prototype,"snapToScene",void 0),t([p()],A.prototype,"tooltip",void 0),t([p()],A.prototype,"tooltipInfos",void 0),t([p({constructOnly:!0,type:j})],A.prototype,"toolOptions",void 0),t([p()],A.prototype,"updating",null),t([p({constructOnly:!0,nonNullable:!0})],A.prototype,"view",void 0),t([p({constructOnly:!0})],A.prototype,"undoRedo",null),t([p()],A.prototype,"activeTooltipInfo",null),A=t([c("esri.views.draw.DrawGraphicTool")],A);const D=Symbol("create-operation-graphic"),F={outline:Symbol("outline-visual"),regularVertices:Symbol("regular-vertices-visual"),activeVertex:Symbol("active-vertex-visual"),activeEdge:Symbol("active-edge-visual")};function P(t){switch(t){case"point":case"polyline":case"polygon":case"multipoint":return t;case"circle":case"rectangle":return"segment";case"mesh":return"point"}}const Z=48;export{A as DrawGraphicTool,P as geometryTypeToDrawOperationGeometryType};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__addDisposableResource as e,__disposeResources as t,__decorate as i}from"tslib";import{createTask as n}from"../../core/asyncUtils.js";import{makeHandle as a,disposable as s}from"../../core/handleUtils.js";import r from"../../core/Logger.js";import{getOrCreateMapValue as o}from"../../core/MapUtils.js";import{destroyMaybe as l,abortMaybe as d}from"../../core/maybe.js";import{ignoreAbortErrors as p}from"../../core/promiseUtils.js";import{when as u,initial as c,watch as h,syncAndInitial as g,on as m,sync as v}from"../../core/reactiveUtils.js";import{screenPointEqual as y,createScreenPoint as f}from"../../core/screenUtils.js";import{diff as M}from"../../core/accessorSupport/diffUtils.js";import{property as _}from"../../core/accessorSupport/decorators/property.js";import{subclass as b}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as S}from"../../core/support/UpdatingHandles.js";import w from"../../geometry/Polygon.js";import{i as C,e as P}from"../../chunks/simplifyOperator.js";import{isPolygon as x}from"../../geometry/support/typeUtils.js";import{isCurvedGeometry as H}from"../../geometry/support/curves/curveUtils.js";import{densifyCurvedGeometry as L}from"../../geometry/support/curves/densifyCurvedGeometry.js";import{getEffectiveElevationInfo as k}from"../../support/elevationInfoUtils.js";import{getMaxDeviationInPixels as I,getMinSegmentsPerCurve as O}from"../2d/layers/graphics/densificationConstants.js";import{createSnappingVisualizer as V}from"./support/createSnappingVisualizer.js";import{multipointFromGeometry as G,markHandled as T,getPointerType as j}from"./support/drawToolUtils.js";import{PluginContext as E}from"./support/PluginContext.js";import{viewEventToCommand as D}from"./support/input/drawToolInput.js";import{EditSessionManager as U}from"./support/managers/EditSessionManager.js";import{GlobalStateManager as A}from"./support/managers/GlobalStateManager.js";import{InteractiveHandleManager as F}from"./support/managers/InteractiveHandleManager.js";import{MeasurementManager as R}from"./support/managers/MeasurementManager.js";import{PluginLifecycleManager as Z}from"./support/managers/PluginLifecycleManager.js";import{SurfaceManager as B}from"./support/managers/SurfaceManager.js";import{TooltipManager as q}from"./support/managers/TooltipManager.js";import{ViewEventPriorities as z}from"../input/InputManager.js";import{createCoordinateHelper as K}from"../interactive/coordinateHelper.js";import{InteractiveToolBase as N}from"../interactive/InteractiveToolBase.js";import{KeyBindings as Q,mediaKeys as W,sketchKeys as $,advancedSketchKeys as J,tooltipKeys as X}from"../interactive/keybindings.js";import{isInputModeAvailable as Y}from"../interactive/tooltip/tooltipCommonUtils.js";const ee=Symbol();let te=class extends N{constructor(e){super(e),this._shapeVisualId=Symbol(),this._vertexVisualId=Symbol(),this._pluginContexts=new Map,this._queuedFeedbackEvents=[],this._flushingQueuedFeedbackEvents=!1,this._commandsSuspended=!1,this._snappingVisualizer=null,this._segmentLabels=null,this._segmentLabelsImportTask=null,this._updatingHandles=new S,this._keybindings=this._makeKeyBindings(),this._pendingBeginRequest=null,this.type="draw-2.0",this.automaticManipulatorSelection=!0,this.snappingManager=null,this.sketchOptions=null,this.elevationInfo=null,this.hasZ=!1,this.defaultZ=0,this.lastScreenPosition=null,this.measurementManager=new R,this.globalStateManager=new A({getPluginStack:()=>this.pluginStack}),this.editSessionManager=new U({getContext:()=>this._editSessionManagerContext}),this.lifecycleManager=new Z({getContext:this._getContextForPlugin.bind(this),editSessionManager:this.editSessionManager,afterAttach:this._afterAttach.bind(this),afterDetach:this._afterDetach.bind(this),beforeResume:this._beforeResume.bind(this)}),this.surfaceManager=null,this.interactiveHandleManager=null,this.renderer=null,this.readPluginSetting=null,this.enableVertexVisuals=!0}initialize(){const{view:e}=this;this.interactiveHandleManager=new F({view:e,renderer:this.renderer}),this._override("manipulators",this.interactiveHandleManager.manipulators),this.tooltipManager=new q({getDependencies:()=>this._tooltipDependencies,getLastScreenPosition:()=>this.lastScreenPosition}),this.addHandles(u(()=>this.renderer,t=>{t.addOrUpdateVisual(this._shapeVisualId,{role:"outputGeometry"}),t.addOrUpdateVisual(this._vertexVisualId,{role:"vertex"}),this._updatingHandles.addPromise(V(e,t).then(e=>this._snappingVisualizer=e))},c)),this.addHandles([h(()=>[this.view,this.coordinateHelper.spatialReference,this.defaultZ,this.hasZ,this.elevationInfo],([e,t,i,n,a])=>{this.surfaceManager?.destroy(),this.surfaceManager=new B({spatialReference:t,excludedGraphicsLayer:null,defaultZ:i,hasZ:n,view:e,elevationInfo:a,getContext:()=>({drawAtFixedElevation:this.globalStateManager.drawAtFixedElevation,elevationConstraint:this.tooltipManager?.elevationConstraint,constraintsEnabled:this.tooltipManager?.constraintsEnabled??!1})})},g),u(()=>this.sketchOptions?.tooltips.effectiveEnabled,()=>this.measurementManager.preloadMeasurementUtils(),{once:!0,initial:!0}),h(()=>[this.editGeometryOperations,this.sketchOptions?.labels.enabled,this.globalStateManager.segmentLabelsDisabled],()=>{this._updatingHandles.addPromise(this._setupSegmentLabels())},c),m(()=>this.editSessionManager,"cancelPlugin",({plugin:e})=>{this._suspendPlugin(e)},v),m(()=>this.editSessionManager,"restartPlugin",({restartInfo:e})=>{this._resumePlugin(e)},v),h(()=>this.lifecycleManager.updating,e=>{e||this._emitQueuedFeedbackEvents()},v),m(()=>this.editGeometryOperations,["vertex-add","vertex-update","vertex-remove"],e=>{const t=e.vertices.map(e=>({componentIndex:0,vertexIndex:e.index,coordinates:this.coordinateHelper.vectorToArray(e.pos)})),i=t.map(e=>e.coordinates);switch(e.type){case"vertex-add":this._emitWhenReady(e.type,{...e,added:i,vertices:t});break;case"vertex-update":this._emitWhenReady(e.type,{...e,updated:i,vertices:t});break;case"vertex-remove":this._emitWhenReady(e.type,{...e,removed:i,vertices:t})}})])}destroy(){this.active&&this.onDeactivate(),this.editSessionManager.destroy(),this.lifecycleManager.destroy(),this.measurementManager.destroy(),this.globalStateManager.destroy();for(const e of this._pluginContexts.values())e.destroy();this._pluginContexts.clear(),this.surfaceManager=l(this.surfaceManager),this.interactiveHandleManager=l(this.interactiveHandleManager),this._segmentLabelsImportTask=d(this._segmentLabelsImportTask),this._segmentLabels=l(this._segmentLabels),this.tooltipManager=l(this.tooltipManager)}get _zOfLastUserInput(){const e=this.mostDownstreamPlugin&&this.editSessionManager.getSession(this.mostDownstreamPlugin),t=e?.firstPointAddedBySession?.point;return t?.hasZ?t.z:null}get _tooltipDependencies(){const{defaultZ:e,editGeometryOperations:t,sketchOptions:i,directionOptions:n,elevationInfo:a,view:s}=this;return t&&i&&s?{defaultZ:e,directionOptions:n,elevationInfo:a,editGeometryOperations:t,sketchOptions:i,view:s,getActiveHandle:()=>this.interactiveHandleManager?.focusedHandle,getAllHandles:()=>this.interactiveHandleManager?.allhandles,getHelpMessageKey:()=>this.helpMessageKey,notifyTooltipsChanged:()=>{const{interactiveHandleManager:e,movementCommandContext:t}=this;e&&t&&e.reapplyPositions(t)}}:null}get _editSessionManagerContext(){const{coordinateHelper:e,view:t}=this;if(!t)return null;return{coordinateHelper:e,viewingMode:"3d"===t.type&&"global"===t.viewingMode?1:2}}get _densificationParameters(){const{view:e,coordinateHelper:t}=this,i=t.spatialReference,n=e?.spatialReference,a=e.resolution;if(!(i&&n&&a&&Number.isFinite(a)))return null;const s=n.metersPerUnit/i.metersPerUnit;return{maxDeviation:2**Math.round(Math.log2(a))*I()*s,minSegmentsPerCurve:O()}}get test(){return{densificationParameters:this._densificationParameters,segmentLabels:this._segmentLabels}}get updating(){return this._updatingHandles.updating||this.snappingManager?.updating||this.lifecycleManager.updating||!!this._segmentLabels?.updating}get coordinateHelper(){return K(this.hasZ,!1,this.view.spatialReference)}get editGeometry(){return this.editGeometryOperations?.data}get editGeometryOperations(){return this.editSessionManager.editGeometryOperations}get unprocessedGeometry(){return this.editSessionManager.outputGeometry}get simplifiedGeometryPreview(){const e=this.editSessionManager.outputGeometry;if(e&&x(e))try{const t=this._densificationParameters,i=H(e)&&t?new w({...L(e,t)}):e;if(!C(i))return P(i)}catch(t){return e}return e}get _suppressCoincidentPointOverlaysIn3D(){return"3d"===this.view.type&&"point"===this.unprocessedGeometry?.type&&!!this.interactiveHandleManager?.allhandles?.find(e=>"primary"===e.role)?.outputMapPosition}get _shapeVisualGeometry(){return this._suppressCoincidentPointOverlaysIn3D?null:this.simplifiedGeometryPreview}get _vertexVisualGeometry(){return this._suppressCoincidentPointOverlaysIn3D?null:this.unprocessedGeometry}get canUndo(){return this.editSessionManager.canUndo}get canRedo(){return this.editSessionManager.canRedo}get pluginStack(){return this.lifecycleManager.pluginStack}get mostDownstreamPlugin(){return this.pluginStack.at(-1)}get mostUpstreamPlugin(){return this.pluginStack.at(0)}get positionOfLastUserInput(){const e=this.lastScreenPosition;return e?this.surfaceManager?.screenToMap(e,{firstPointZ:this._zOfLastUserInput})??this.view.toMap(e):this.view.center}get movementCommandContext(){const{editGeometryOperations:e,tooltipManager:t,surfaceManager:i,snappingManager:n,interactiveHandleManager:a,_snappingVisualizer:s,defaultZ:r,hasZ:o,globalStateManager:{drawAtFixedElevation:l},view:d}=this;return{tooltipManager:t,editGeometryOperations:e,surfaceManager:i,interactiveHandleManager:a,snappingManager:n,snappingVisualizer:s,pointerType:"mouse",hasZ:o,defaultZ:r,view:d,drawAtFixedElevation:l}}get tooltip(){return this.tooltipManager?.tooltip}get activeTooltipInfo(){return this.tooltipManager?.tooltipInfo}get helpMessageKey(){return this.pluginStack.items.findLast(e=>e.helpMessageKey)?.helpMessageKey??"noTool"}begin(e){this.active?(this.lifecycleManager.begin(e),this._pendingBeginRequest=null):this._pendingBeginRequest=e}complete(e){const t=this.lifecycleManager;if(e&&t.complete(e),0===t.pluginStack.length){const e=this.unprocessedGeometry,t=!e||"mesh"===e.type||C(e);this.emit("complete",{geometry:e,isSimple:t,aborted:!1,type:"complete",vertices:[]}),this.view?.activeTool===this&&(this.view.activeTool=null)}}cancelFirstUserLeafPlugin(){const e=this.pluginStack.toArray().findLast(e=>!0!==e.configuration?.hidden);e&&this.lifecycleManager.cancel(e)}getVertexSnappingCandidates(){return"secondary"===this.interactiveHandleManager?.capturingHandle?.role?[]:this.snappingManager?.getVertexCandidates()??[]}replaceLeaf(e){const t=this.lifecycleManager;t.updating?r.getLogger(this).info("Ignoring command; arrived while updating:","replaceLeaf"):t.replaceLeaf(e)}finishPart(){const e=this.mostUpstreamPlugin,t=e?.configuration;if(this.editGeometryOperations&&t&&t.kind?.includes("multipart")){const e=this.pluginStack.at(1);e&&this.complete(e)}}undo(){this._handleCommand({action:"undo"})}redo(){this._handleCommand({action:"redo"})}executeCommand(e){return this._handleCommand(e)}suspendCommands(){return this._commandsSuspended=!0,a(()=>{this._commandsSuspended=!1;const e=this.view?.inputManager.latestPointerInfo;if(e){const{x:t,y:i}=e.location;this._handleCommand({action:"manipulator-move-to",x:t,y:i})}})}addPromise(e){return this._updatingHandles.addPromise(e)}readPluginSettingValue(e,t){return this.readPluginSetting?.(e,t)}getGeometryIfCompleted(){const e=this.lifecycleManager.gatherCompletablePlugins();return this.editSessionManager?.generatePreviewGeometryForPlugins(e)}onActivate(){super.onActivate();const{view:e}=this;this.lastScreenPosition=e?.inputManager.latestPointerInfo?.location,this.renderer?.activate(),this._pendingBeginRequest&&(this.begin(this._pendingBeginRequest),this._pendingBeginRequest=null),this.enableVertexVisuals&&this.addHandles(h(()=>this._vertexVisualGeometry,e=>{this.renderer?.addOrUpdateVisual(this._vertexVisualId,{geometry:e?G(e):null})},c)),this.addHandles([h(()=>this._shapeVisualGeometry,e=>{this.renderer?.addOrUpdateVisual(this._shapeVisualId,{geometry:e})},c),u(()=>this.interactiveHandleManager?.capturingHandle?.screenPosition,e=>this.lastScreenPosition=e,{initial:!0,equals:y}),h(()=>this.interactiveHandleManager?.capturingHandle?.outputMapPosition,(e,t)=>{const i=this.interactiveHandleManager?.capturingHandle?.editSession?.endVertex;e&&t&&i&&this._emitWhenReady("cursor-update",{updated:i.pos,type:"vertex-update",operation:"apply",vertices:[{componentIndex:i.part.index,vertexIndex:i.index,coordinates:i.pos}]})},v),this._keybindings.register(e,z.TOOL),h(()=>e.viewpoint,(e,t)=>{e&&t&&M(e,t)&&this._handleCommand({action:"viewpoint-moved"})})],ee)}onDeactivate(){super.onDeactivate(),this.removeHandles(ee),this.renderer?.deactivate(),this.snappingManager?.doneSnapping(),this.lifecycleManager.cancelAll(),this._pendingBeginRequest=null}onInputEvent(e){const t=D(e);t&&this._handleCommand(t)}forceAddVertex(){this._commitNext()}_emitWhenReady(e,t){if(this.destroyed)return;const i=()=>{this.emit(e,t)};this.lifecycleManager.updating||this._flushingQueuedFeedbackEvents?this._queuedFeedbackEvents.push(i):i()}_emitQueuedFeedbackEvents(){if(!(this.destroyed||this._flushingQueuedFeedbackEvents||this.lifecycleManager.updating||0===this._queuedFeedbackEvents.length)){this._flushingQueuedFeedbackEvents=!0;try{for(;!this.destroyed&&!this.lifecycleManager.updating&&this._queuedFeedbackEvents.length>0;)this._queuedFeedbackEvents.shift()?.()}finally{this._flushingQueuedFeedbackEvents=!1}}}async _handleCommand(e){if(!this._commandsSuspended)if(this.lifecycleManager.updating)r.getLogger(this).info("Ignoring command; arrived while updating:",e.action);else switch(e.action){case"view-drag":return await this._handleViewDragCommand(e);case"vertex-add":return this._guardCommand(e,()=>{T(e),this._commitNext()});case"vertex-add-and-finish-part":return this._handleVertexAddAndFinishPartCommand(e);case"cancel":return this._guardCommand(e,()=>this.cancel());case"complete":return this._guardCommand(e,()=>{this.mostUpstreamPlugin&&(T(e),this.complete(this.mostUpstreamPlugin))});case"finish-part":return this._guardCommand(e,()=>this.finishPart());case"undo":return this._guardCommand(e,()=>this.editSessionManager.undo());case"redo":return this._guardCommand(e,()=>this.editSessionManager.redo());case"next-manipulator":return this._guardCommand(e,()=>this.interactiveHandleManager?.cycleManipulator("forward"));case"previous-manipulator":return this._guardCommand(e,()=>this.interactiveHandleManager?.cycleManipulator("backward"));case"toggle-manipulator-follow":this.interactiveHandleManager?.toggleFollow()&&T(e);break;case"viewpoint-moved":return await this._handleViewpointMovedCommand(e);case"manipulator-move-to":return await this._handleManipulatorMoveToCommand(e);case"manipulator-drag-to":return await this._handleManipulatorDragToCommand(e);case"vertex-add-at-point":return await this._handleVertexAddAtPointCommand(e);case"show-tooltip":return this._guardCommand(e,async()=>{const t=this.tooltipManager?.tooltip;t&&Y(t.info)&&(await t.enterInputMode(),T(e))});case"constraint-center":this.globalStateManager.setCentered(e.enabled);break;case"constraint-aspect":this.globalStateManager.setPreserveAspectRatio(e.enabled)}}async _handleViewDragCommand(e){if(!this.editable)return;const t=e.originalEvent,i=this.interactiveHandleManager?.capturingHandle;(!t||!("pointerType"in t)||"touch"!==t.pointerType||"capture-always"!==i?.captureMode&&"capture-when-engaged"!==i?.captureMode)&&"capture-when-engaged"!==this.interactiveHandleManager?.capturingHandle?.captureMode?this._before(e)&&T(e):T(e)}_handleVertexAddAndFinishPartCommand(e){this._before(e)||(T(e),this._commitNext(),this.finishPart())}async _handleViewpointMovedCommand(e){this.editable&&(await this._updatingHandles.addPromise(this.interactiveHandleManager?.capturingHandle?.moveTo(null,{...this.movementCommandContext,pointerType:j(e.originalEvent)})),this.interactiveHandleManager?.updateAllScreenPositions(this.movementCommandContext.surfaceManager))}async _handleManipulatorMoveToCommand(e){if(!this.editable)return;const t=this._updateLastScreenPosition(e);this.interactiveHandleManager?.capturingHandle&&T(e),await this._updatingHandles.addPromise(this.interactiveHandleManager?.capturingHandle?.moveTo(t,{...this.movementCommandContext,pointerType:j(e.originalEvent)}))}async _handleManipulatorDragToCommand(e){if(!this.editable)return;const t=j(e.originalEvent),i=this._updateLastScreenPosition(e),n=this.interactiveHandleManager?.findHandleByManipulator(i,t);"touch"===t&&n&&"start"===e.state&&this.interactiveHandleManager?.releaseHandle();const a=this.interactiveHandleManager?.findHandleDragging(),s=this.interactiveHandleManager?.capturingHandle,r=a??s??n;r&&!n&&T(e),"capture-when-engaged"===r?.captureMode||"capture-always"===r?.captureMode&&"touch"===t?"end"===e.state?await this._updatingHandles.addPromise(r.noteDragEnd(i,{...this.movementCommandContext,pointerType:t}).then(()=>{r&&"touch"===j(e.originalEvent)&&"grabbable-object"!==r.captureMode&&"capture-when-engaged"!==r.defaultCaptureMode&&"primary"===r.role&&(1===this.interactiveHandleManager?.handleCount?this._handleCommand({action:"vertex-add"}):this.interactiveHandleManager?.releaseHandle())})):"start"===e.state?await this._updatingHandles.addPromise(r.noteDragStart(i,{...this.movementCommandContext,pointerType:t}).then(()=>{r&&"touch"===j(e.originalEvent)&&"grabbable-object"!==r.captureMode&&"capture-when-engaged"!==r.defaultCaptureMode&&!r.editSession?.lastPointAddedBySession&&this._handleCommand({action:"vertex-add"})})):await this._updatingHandles.addPromise(r?.moveTo(i,{...this.movementCommandContext,pointerType:j(e.originalEvent)})):"grabbable-object"===r?.captureMode&&(this.interactiveHandleManager?.releaseHandle(s),await this._updatingHandles.addPromise(r.moveTo(i,{...this.movementCommandContext,pointerType:t})))}async _handleVertexAddAtPointCommand(e){const t=this._updateLastScreenPosition(e),i=j(e.originalEvent),n=this.interactiveHandleManager?.capturingHandle??this.interactiveHandleManager?.findHandleByManipulator(t,i);this.editable&&n&&(this._before(e)||(T(e),await this._updatingHandles.addPromise(n.moveTo(t,{...this.movementCommandContext,skipSnapping:!0,pointerType:i}).finally(()=>this._commitNext()))))}_makeKeyBindings(){const e=new Q,t=(t,i)=>{e.addToggle(t,e=>this._handleCommand({action:i,originalEvent:e,enabled:"key-down"===e.type}))},i=(t,i)=>{e.add(t,e=>this._handleCommand({action:i,originalEvent:e}))};return t(W.preserveAspectRatio,"constraint-aspect"),t($.center,"constraint-center"),i(J.toggleFollowManipulator,"toggle-manipulator-follow"),i($.undo,"undo"),i($.redo,"redo"),i($.complete,"complete"),i($.vertexAdd,"vertex-add"),i({key:X.enterInputMode,continuePropagation:!0,repeats:!0},"show-tooltip"),e}_afterAttach(){}_afterDetach(e){this.interactiveHandleManager?.unregisterCustomConstraint(e),this.interactiveHandleManager?.unregisterHandle(e),this.tooltipManager?.unregisterPluginFields(e),this.globalStateManager.clearPluginOverrides(e);const t=this._pluginContexts.get(e);t&&(t.destroy(),this._pluginContexts.delete(e))}_beforeResume(e,t){this.interactiveHandleManager?.replaceEditSessions(e,t)}_commitNext(){const i={stack:[],error:void 0,hasError:!1};try{const t=this.mostDownstreamPlugin;if(!t)return;this.tooltipManager?.storeConstraintSnapshot();let n=!1;const a=this.editGeometryOperations;e(i,a?s(a.on("vertex-add",()=>n=!0)):null,!1);t.completeStep?t.completeStep():this.complete(t),n&&this.tooltipManager?.unlockOnVertexPlacement()}catch(n){i.error=n,i.hasError=!0}finally{t(i)}}_suspendPlugin(e){this.lifecycleManager.suspend(e),this.measurementManager.suspendPlugin(e)}_resumePlugin(e){this.lifecycleManager.resume(e)}_updateLastScreenPosition(e){const t=f(e.x,e.y);return this.lastScreenPosition=t,t}_getContextForPlugin(e,t){const i=o(this._pluginContexts,e,()=>new E({drawTool:this,plugin:e,session:t}));return i.session=t,i}_before(e){if(!this.hasEventListener(`before-${e.action}`))return!1;const t=new CustomEvent(`before-${e.action}`,{detail:e,cancelable:!0});return this.emit(`before-${e.action}`,t),t.defaultPrevented}_guardCommand(e,t,i){return this._before(e)?i?.():t()}async _setupSegmentLabels(){const e=this.editGeometryOperations,t=this.sketchOptions?.labels,i=!!t?.enabled,n=this.globalStateManager.segmentLabelsDisabled;if(!e||!t||!i)return void(this._segmentLabels=l(this._segmentLabels));if(n)return void(this._segmentLabels&&(this._segmentLabels.visible=!1));if(this._segmentLabels?.context?.editGeometryOperations===e&&this._segmentLabels.context.labelOptions===t)return void(this._segmentLabels.visible=!0);const a=await this._createSegmentLabels(e,t);a&&(this._segmentLabels=l(this._segmentLabels),this._segmentLabels=a)}async _createSegmentLabels(e,t){this._segmentLabelsImportTask?.abort();const i=this._segmentLabelsImportTask=n(async i=>{if("3d"===this.view.type){const n=import("../3d/interactive/SegmentLabels3D.js"),{SegmentLabels3D:a}=await this._updatingHandles.addPromise(n);return this._isSegmentLabelsSetupStale(i,e,t)?null:new a({context:{view:this.view,editGeometryOperations:e,elevationInfo:k(this.hasZ,this.elevationInfo),labelOptions:t},visible:!0})}const n=import("../2d/interactive/SegmentLabels2D.js"),{SegmentLabels2D:a}=await this._updatingHandles.addPromise(n);return this._isSegmentLabelsSetupStale(i,e,t)?null:new a({context:{view:this.view,editGeometryOperations:e,elevationInfo:k(this.hasZ,this.elevationInfo),labelOptions:t},visible:!0})});return p(i.promise)}_isSegmentLabelsSetupStale(e,t,i){return e.aborted||this.editGeometryOperations!==t||this.sketchOptions?.labels!==i||!i.enabled||this.globalStateManager.segmentLabelsDisabled}};i([_()],te.prototype,"_commandsSuspended",void 0),i([_()],te.prototype,"_zOfLastUserInput",null),i([_()],te.prototype,"_snappingVisualizer",void 0),i([_()],te.prototype,"_segmentLabels",void 0),i([_()],te.prototype,"_segmentLabelsImportTask",void 0),i([_()],te.prototype,"_tooltipDependencies",null),i([_()],te.prototype,"_editSessionManagerContext",null),i([_()],te.prototype,"_densificationParameters",null),i([_({constructOnly:!0,nonNullable:!0})],te.prototype,"view",void 0),i([_()],te.prototype,"automaticManipulatorSelection",void 0),i([_()],te.prototype,"updating",null),i([_()],te.prototype,"coordinateHelper",null),i([_()],te.prototype,"editGeometry",null),i([_()],te.prototype,"editGeometryOperations",null),i([_()],te.prototype,"unprocessedGeometry",null),i([_()],te.prototype,"simplifiedGeometryPreview",null),i([_()],te.prototype,"_suppressCoincidentPointOverlaysIn3D",null),i([_()],te.prototype,"_shapeVisualGeometry",null),i([_()],te.prototype,"_vertexVisualGeometry",null),i([_()],te.prototype,"snappingManager",void 0),i([_()],te.prototype,"sketchOptions",void 0),i([_()],te.prototype,"elevationInfo",void 0),i([_()],te.prototype,"hasZ",void 0),i([_()],te.prototype,"defaultZ",void 0),i([_()],te.prototype,"directionOptions",void 0),i([_()],te.prototype,"canUndo",null),i([_()],te.prototype,"canRedo",null),i([_()],te.prototype,"pluginStack",null),i([_()],te.prototype,"mostDownstreamPlugin",null),i([_()],te.prototype,"mostUpstreamPlugin",null),i([_()],te.prototype,"lastScreenPosition",void 0),i([_()],te.prototype,"positionOfLastUserInput",null),i([_()],te.prototype,"tooltipManager",void 0),i([_()],te.prototype,"measurementManager",void 0),i([_()],te.prototype,"globalStateManager",void 0),i([_()],te.prototype,"editSessionManager",void 0),i([_()],te.prototype,"lifecycleManager",void 0),i([_()],te.prototype,"surfaceManager",void 0),i([_()],te.prototype,"interactiveHandleManager",void 0),i([_()],te.prototype,"renderer",void 0),i([_()],te.prototype,"readPluginSetting",void 0),i([_()],te.prototype,"movementCommandContext",null),i([_()],te.prototype,"tooltip",null),i([_()],te.prototype,"activeTooltipInfo",null),i([_()],te.prototype,"helpMessageKey",null),i([_({constructOnly:!0})],te.prototype,"enableVertexVisuals",void 0),te=i([b("esri.views.draw.DrawTool")],te);export{te as DrawTool};
2
+ import{__addDisposableResource as e,__disposeResources as t,__decorate as i}from"tslib";import{createTask as n}from"../../core/asyncUtils.js";import{makeHandle as a,disposable as s}from"../../core/handleUtils.js";import r from"../../core/Logger.js";import{getOrCreateMapValue as o}from"../../core/MapUtils.js";import{destroyMaybe as l,abortMaybe as d}from"../../core/maybe.js";import{ignoreAbortErrors as p}from"../../core/promiseUtils.js";import{when as u,initial as c,watch as h,syncAndInitial as g,on as m,sync as v}from"../../core/reactiveUtils.js";import{screenPointEqual as y,createScreenPoint as f}from"../../core/screenUtils.js";import{diff as M}from"../../core/accessorSupport/diffUtils.js";import{property as _}from"../../core/accessorSupport/decorators/property.js";import{subclass as b}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as w}from"../../core/support/UpdatingHandles.js";import S from"../../geometry/Polygon.js";import{i as C,e as P}from"../../chunks/simplifyOperator.js";import{isPolygon as H}from"../../geometry/support/typeUtils.js";import{isCurvedGeometry as x}from"../../geometry/support/curves/curveUtils.js";import{densifyCurvedGeometry as I}from"../../geometry/support/curves/densifyCurvedGeometry.js";import{getEffectiveElevationInfo as L}from"../../support/elevationInfoUtils.js";import{getMaxDeviationInPixels as O,getMinSegmentsPerCurve as k}from"../2d/layers/graphics/densificationConstants.js";import{createSnappingVisualizer as T}from"./support/createSnappingVisualizer.js";import{multipointFromGeometry as V,markHandled as G,getPointerType as j,getPointerId as E}from"./support/drawToolUtils.js";import{PluginContext as D}from"./support/PluginContext.js";import{viewEventToCommand as U}from"./support/input/drawToolInput.js";import{EditSessionManager as A}from"./support/managers/EditSessionManager.js";import{GlobalStateManager as F}from"./support/managers/GlobalStateManager.js";import{InteractiveHandleManager as R}from"./support/managers/InteractiveHandleManager.js";import{MeasurementManager as Z}from"./support/managers/MeasurementManager.js";import{PluginLifecycleManager as B}from"./support/managers/PluginLifecycleManager.js";import{SurfaceManager as q}from"./support/managers/SurfaceManager.js";import{TooltipManager as z}from"./support/managers/TooltipManager.js";import{ViewEventPriorities as K}from"../input/InputManager.js";import{createCoordinateHelper as N}from"../interactive/coordinateHelper.js";import{InteractiveToolBase as Q}from"../interactive/InteractiveToolBase.js";import{KeyBindings as W,mediaKeys as $,sketchKeys as J,advancedSketchKeys as X,tooltipKeys as Y}from"../interactive/keybindings.js";import{isInputModeAvailable as ee}from"../interactive/tooltip/tooltipCommonUtils.js";const te=Symbol();let ie=class extends Q{constructor(e){super(e),this._shapeVisualId=Symbol(),this._vertexVisualId=Symbol(),this._pluginContexts=new Map,this._queuedFeedbackEvents=[],this._flushingQueuedFeedbackEvents=!1,this._commandsSuspended=!1,this._snappingVisualizer=null,this._segmentLabels=null,this._segmentLabelsImportTask=null,this._updatingHandles=new w,this._keybindings=this._makeKeyBindings(),this._pendingBeginRequest=null,this.type="draw-2.0",this.automaticManipulatorSelection=!0,this.snappingManager=null,this.toolOptions=null,this.elevationInfo=null,this.hasZ=!1,this.defaultZ=0,this.lastScreenPosition=null,this.measurementManager=new Z,this.globalStateManager=new F({getPluginStack:()=>this.pluginStack}),this.editSessionManager=new A({getContext:()=>this._editSessionManagerContext}),this.lifecycleManager=new B({getContext:this._getContextForPlugin.bind(this),editSessionManager:this.editSessionManager,afterAttach:this._afterAttach.bind(this),afterDetach:this._afterDetach.bind(this),beforeResume:this._beforeResume.bind(this)}),this.surfaceManager=null,this.interactiveHandleManager=null,this.renderer=null,this.readPluginSetting=null,this.enableVertexVisuals=!0}initialize(){const{view:e}=this;this.interactiveHandleManager=new R({view:e,renderer:this.renderer}),this._override("manipulators",this.interactiveHandleManager.manipulators),this.tooltipManager=new z({getDependencies:()=>this._tooltipDependencies,getLastScreenPosition:()=>this.lastScreenPosition}),this.addHandles(u(()=>this.renderer,t=>{t.addOrUpdateVisual(this._shapeVisualId,{role:"outputGeometry"}),t.addOrUpdateVisual(this._vertexVisualId,{role:"vertex"}),this._updatingHandles.addPromise(T(e,t).then(e=>this._snappingVisualizer=e))},c)),this.addHandles([h(()=>[this.view,this.coordinateHelper.spatialReference,this.defaultZ,this.hasZ,this.elevationInfo],([e,t,i,n,a])=>{this.surfaceManager?.destroy(),this.surfaceManager=new q({spatialReference:t,excludedGraphicsLayer:null,defaultZ:i,hasZ:n,view:e,elevationInfo:a,getContext:()=>({drawAtFixedElevation:this.globalStateManager.drawAtFixedElevation,elevationConstraint:this.tooltipManager?.elevationConstraint,constraintsEnabled:this.tooltipManager?.constraintsEnabled??!1})})},g),u(()=>this.toolOptions?.tooltips.effectiveEnabled,()=>this.measurementManager.preloadMeasurementUtils(),{once:!0,initial:!0}),h(()=>[this.editGeometryOperations,this.toolOptions?.labels.enabled,this.globalStateManager.segmentLabelsDisabled],()=>{this._updatingHandles.addPromise(this._setupSegmentLabels())},c),m(()=>this.editSessionManager,"cancelPlugin",({plugin:e})=>{this._suspendPlugin(e)},v),m(()=>this.editSessionManager,"restartPlugin",({restartInfo:e})=>{this._resumePlugin(e)},v),h(()=>this.lifecycleManager.updating,e=>{e||this._emitQueuedFeedbackEvents()},v),m(()=>this.editGeometryOperations,["vertex-add","vertex-update","vertex-remove"],e=>{const t=e.vertices.map(e=>({componentIndex:0,vertexIndex:e.index,coordinates:this.coordinateHelper.vectorToArray(e.pos)})),i=t.map(e=>e.coordinates);switch(e.type){case"vertex-add":this._emitWhenReady(e.type,{...e,added:i,vertices:t});break;case"vertex-update":this._emitWhenReady(e.type,{...e,updated:i,vertices:t});break;case"vertex-remove":this._emitWhenReady(e.type,{...e,removed:i,vertices:t})}})])}destroy(){this.active&&this.onDeactivate(),this.editSessionManager.destroy(),this.lifecycleManager.destroy(),this.measurementManager.destroy(),this.globalStateManager.destroy();for(const e of this._pluginContexts.values())e.destroy();this._pluginContexts.clear(),this.surfaceManager=l(this.surfaceManager),this.interactiveHandleManager=l(this.interactiveHandleManager),this._segmentLabelsImportTask=d(this._segmentLabelsImportTask),this._segmentLabels=l(this._segmentLabels),this.tooltipManager=l(this.tooltipManager)}get _zOfLastUserInput(){const e=this.mostDownstreamPlugin&&this.editSessionManager.getSession(this.mostDownstreamPlugin),t=e?.firstPointAddedBySession?.point;return t?.hasZ?t.z:null}get _tooltipDependencies(){const{defaultZ:e,editGeometryOperations:t,toolOptions:i,directionOptions:n,elevationInfo:a,view:s}=this;return t&&i&&s?{defaultZ:e,directionOptions:n,elevationInfo:a,editGeometryOperations:t,toolOptions:i,view:s,getActiveHandle:()=>this.interactiveHandleManager?.focusedHandle,getAllHandles:()=>this.interactiveHandleManager?.allhandles,getHelpMessageKey:()=>this.helpMessageKey,notifyTooltipsChanged:()=>{const{interactiveHandleManager:e,movementCommandContext:t}=this;e&&t&&e.reapplyPositions(t)}}:null}get _editSessionManagerContext(){const{coordinateHelper:e,view:t}=this;if(!t)return null;return{coordinateHelper:e,viewingMode:"3d"===t.type&&"global"===t.viewingMode?1:2}}get _densificationParameters(){const{view:e,coordinateHelper:t}=this,i=t.spatialReference,n=e?.spatialReference,a=e.resolution;if(!(i&&n&&a&&Number.isFinite(a)))return null;const s=n.metersPerUnit/i.metersPerUnit;return{maxDeviation:2**Math.round(Math.log2(a))*O()*s,minSegmentsPerCurve:k()}}get test(){return{densificationParameters:this._densificationParameters,segmentLabels:this._segmentLabels}}get updating(){return this._updatingHandles.updating||this.snappingManager?.updating||this.lifecycleManager.updating||!!this._segmentLabels?.updating}get coordinateHelper(){return N(this.hasZ,!1,this.view.spatialReference)}get editGeometry(){return this.editGeometryOperations?.data}get editGeometryOperations(){return this.editSessionManager.editGeometryOperations}get unprocessedGeometry(){return this.editSessionManager.outputGeometry}get simplifiedGeometryPreview(){const e=this.editSessionManager.outputGeometry;if(e&&H(e))try{const t=this._densificationParameters,i=x(e)&&t?new S({...I(e,t)}):e;if(!C(i))return P(i)}catch(t){return e}return e}get _suppressCoincidentPointOverlaysIn3D(){return"3d"===this.view.type&&"point"===this.unprocessedGeometry?.type&&!!this.interactiveHandleManager?.allhandles?.find(e=>"primary"===e.role)?.outputMapPosition}get _shapeVisualGeometry(){return this._suppressCoincidentPointOverlaysIn3D?null:this.simplifiedGeometryPreview}get _vertexVisualGeometry(){return this._suppressCoincidentPointOverlaysIn3D?null:this.unprocessedGeometry}get canUndo(){return this.editSessionManager.canUndo}get canRedo(){return this.editSessionManager.canRedo}get pluginStack(){return this.lifecycleManager.pluginStack}get mostDownstreamPlugin(){return this.pluginStack.at(-1)}get mostUpstreamPlugin(){return this.pluginStack.at(0)}get positionOfLastUserInput(){const e=this.lastScreenPosition;return e?this.surfaceManager?.screenToMap(e,{firstPointZ:this._zOfLastUserInput})??this.view.toMap(e):this.view.center}get movementCommandContext(){const{editGeometryOperations:e,tooltipManager:t,surfaceManager:i,snappingManager:n,interactiveHandleManager:a,_snappingVisualizer:s,defaultZ:r,hasZ:o,globalStateManager:{drawAtFixedElevation:l},view:d}=this;return{tooltipManager:t,editGeometryOperations:e,surfaceManager:i,interactiveHandleManager:a,snappingManager:n,snappingVisualizer:s,pointerType:"mouse",hasZ:o,defaultZ:r,view:d,drawAtFixedElevation:l}}get tooltip(){return this.tooltipManager?.tooltip}get activeTooltipInfo(){return this.tooltipManager?.tooltipInfo}get helpMessageKey(){return this.pluginStack.items.findLast(e=>e.helpMessageKey)?.helpMessageKey??"noTool"}begin(e){this.active?(this.lifecycleManager.begin(e),this._pendingBeginRequest=null):this._pendingBeginRequest=e}complete(e){const t=this.lifecycleManager;if(e&&t.complete(e),0===t.pluginStack.length){const e=this.unprocessedGeometry,t=!e||"mesh"===e.type||C(e);this.emit("complete",{geometry:e,isSimple:t,aborted:!1,type:"complete",vertices:[]}),this.view?.activeTool===this&&(this.view.activeTool=null)}}cancelFirstUserLeafPlugin(){const e=this.pluginStack.toArray().findLast(e=>!0!==e.configuration?.hidden);e&&this.lifecycleManager.cancel(e)}getVertexSnappingCandidates(){return"secondary"===this.interactiveHandleManager?.capturingHandle?.role?[]:this.snappingManager?.getVertexCandidates()??[]}replaceLeaf(e){const t=this.lifecycleManager;t.updating?r.getLogger(this).info("Ignoring command; arrived while updating:","replaceLeaf"):t.replaceLeaf(e)}finishPart(){const e=this.mostUpstreamPlugin,t=e?.configuration;if(this.editGeometryOperations&&t&&t.kind?.includes("multipart")){const e=this.pluginStack.at(1);e&&this.complete(e)}}undo(){this._handleCommand({action:"undo"})}redo(){this._handleCommand({action:"redo"})}executeCommand(e){return this._handleCommand(e)}suspendCommands(){return this._commandsSuspended=!0,a(()=>{this._commandsSuspended=!1;const e=this.view?.inputManager.latestPointerInfo;if(e){const{x:t,y:i}=e.location;this._handleCommand({action:"manipulator-move-to",x:t,y:i})}})}addPromise(e){return this._updatingHandles.addPromise(e)}readPluginSettingValue(e,t){return this.readPluginSetting?.(e,t)}getGeometryIfCompleted(){const e=this.lifecycleManager.gatherCompletablePlugins();return this.editSessionManager?.generatePreviewGeometryForPlugins(e)}onActivate(){super.onActivate();const{view:e}=this;this.lastScreenPosition=e?.inputManager.latestPointerInfo?.location,this.renderer?.activate(),this._pendingBeginRequest&&(this.begin(this._pendingBeginRequest),this._pendingBeginRequest=null),this.enableVertexVisuals&&this.addHandles(h(()=>this._vertexVisualGeometry,e=>{this.renderer?.addOrUpdateVisual(this._vertexVisualId,{geometry:e?V(e):null})},c)),this.addHandles([h(()=>this._shapeVisualGeometry,e=>{this.renderer?.addOrUpdateVisual(this._shapeVisualId,{geometry:e})},c),u(()=>this.interactiveHandleManager?.capturingHandle?.screenPosition,e=>this.lastScreenPosition=e,{initial:!0,equals:y}),h(()=>this.interactiveHandleManager?.capturingHandle?.outputMapPosition,(e,t)=>{const i=this.interactiveHandleManager?.capturingHandle?.editSession?.endVertex;e&&t&&i&&this._emitWhenReady("cursor-update",{updated:i.pos,type:"vertex-update",operation:"apply",vertices:[{componentIndex:i.part.index,vertexIndex:i.index,coordinates:i.pos}]})},v),this._keybindings.register(e,K.TOOL),h(()=>e.viewpoint,(e,t)=>{e&&t&&M(e,t)&&this._handleCommand({action:"viewpoint-moved"})})],te)}onDeactivate(){super.onDeactivate(),this.removeHandles(te),this.renderer?.deactivate(),this.snappingManager?.doneSnapping(),this.lifecycleManager.cancelAll(),this._pendingBeginRequest=null}onInputEvent(e){"pointer-down"===e.type?this.interactiveHandleManager?.notePointerDown(e.pointerId,e.pointerType):"pointer-up"!==e.type&&"pointer-leave"!==e.type||this.interactiveHandleManager?.notePointerUp(e.pointerId,e.pointerType);const t=U(e);t&&this._handleCommand(t)}forceAddVertex(){this._commitNext()}_emitWhenReady(e,t){if(this.destroyed)return;const i=()=>{this.emit(e,t)};this.lifecycleManager.updating||this._flushingQueuedFeedbackEvents?this._queuedFeedbackEvents.push(i):i()}_emitQueuedFeedbackEvents(){if(!(this.destroyed||this._flushingQueuedFeedbackEvents||this.lifecycleManager.updating||0===this._queuedFeedbackEvents.length)){this._flushingQueuedFeedbackEvents=!0;try{for(;!this.destroyed&&!this.lifecycleManager.updating&&this._queuedFeedbackEvents.length>0;)this._queuedFeedbackEvents.shift()?.()}finally{this._flushingQueuedFeedbackEvents=!1}}}async _handleCommand(e){if(!this._commandsSuspended)if(this.lifecycleManager.updating)r.getLogger(this).info("Ignoring command; arrived while updating:",e.action);else switch(e.action){case"view-drag":return await this._handleViewDragCommand(e);case"vertex-add":return this._guardCommand(e,()=>{G(e),this._commitNext()});case"vertex-add-and-finish-part":return this._handleVertexAddAndFinishPartCommand(e);case"cancel":return this._guardCommand(e,()=>this.cancel());case"complete":return this._guardCommand(e,()=>{this.mostUpstreamPlugin&&(G(e),this.complete(this.mostUpstreamPlugin))});case"finish-part":return this._guardCommand(e,()=>this.finishPart());case"undo":return this._guardCommand(e,()=>this.editSessionManager.undo());case"redo":return this._guardCommand(e,()=>this.editSessionManager.redo());case"next-manipulator":return this._guardCommand(e,()=>this.interactiveHandleManager?.cycleManipulator("forward"));case"previous-manipulator":return this._guardCommand(e,()=>this.interactiveHandleManager?.cycleManipulator("backward"));case"toggle-manipulator-follow":this.interactiveHandleManager?.toggleFollow()&&G(e);break;case"viewpoint-moved":return await this._handleViewpointMovedCommand(e);case"manipulator-move-to":return await this._handleManipulatorMoveToCommand(e);case"manipulator-drag-to":return await this._handleManipulatorDragToCommand(e);case"vertex-add-at-point":return await this._handleVertexAddAtPointCommand(e);case"show-tooltip":return this._guardCommand(e,async()=>{const t=this.tooltipManager?.tooltip;t&&ee(t.info)&&(await t.enterInputMode(),G(e))});case"constraint-center":this.globalStateManager.setCentered(e.enabled);break;case"constraint-aspect":this.globalStateManager.setPreserveAspectRatio(e.enabled)}}async _handleViewDragCommand(e){if(!this.editable)return;const t=e.originalEvent,i=this.interactiveHandleManager?.capturingHandle;(!t||!("pointerType"in t)||"touch"!==t.pointerType||"capture-always"!==i?.captureMode&&"capture-when-engaged"!==i?.captureMode)&&"capture-when-engaged"!==this.interactiveHandleManager?.capturingHandle?.captureMode?this._before(e)&&G(e):G(e)}_handleVertexAddAndFinishPartCommand(e){this._before(e)||(G(e),this._commitNext(),this.finishPart())}async _handleViewpointMovedCommand(e){if(!this.editable)return;const t=j(e.originalEvent),i=E(e.originalEvent);await this._updatingHandles.addPromise(this.interactiveHandleManager?.capturingHandle?.moveTo(null,{...this.movementCommandContext,pointerType:t,pointerId:i})),this.interactiveHandleManager?.updateAllScreenPositions(this.movementCommandContext.surfaceManager)}async _handleManipulatorMoveToCommand(e){if(!this.editable)return;const t=j(e.originalEvent),i=E(e.originalEvent);if(!this.interactiveHandleManager?.shouldCaptureInput(i,t))return;const n=this._updateLastScreenPosition(e);this.interactiveHandleManager?.capturingHandle&&G(e),await this._updatingHandles.addPromise(this.interactiveHandleManager?.capturingHandle?.moveTo(n,{...this.movementCommandContext,pointerType:t,pointerId:i}))}async _handleManipulatorDragToCommand(e){if(!this.editable)return;const t=j(e.originalEvent),i=E(e.originalEvent);if(!this.interactiveHandleManager?.shouldCaptureInput(i,t))return;const n=this._updateLastScreenPosition(e),a=this.interactiveHandleManager?.findHandleByManipulator(n,t);"touch"===t&&a&&"start"===e.state&&this.interactiveHandleManager?.releaseHandle();const s=this.interactiveHandleManager?.findHandleDragging(),r=this.interactiveHandleManager?.capturingHandle,o=s??r??a;o&&!a&&G(e),"capture-when-engaged"===o?.captureMode||"capture-always"===o?.captureMode&&"touch"===t?"end"===e.state?await this._updatingHandles.addPromise(o.noteDragEnd(n,{...this.movementCommandContext,pointerType:t,pointerId:i}).then(()=>{o&&"touch"===j(e.originalEvent)&&"grabbable-object"!==o.captureMode&&"capture-when-engaged"!==o.defaultCaptureMode&&"primary"===o.role&&(1===this.interactiveHandleManager?.handleCount?this._handleCommand({action:"vertex-add"}):this.interactiveHandleManager?.releaseHandle())})):"start"===e.state?await this._updatingHandles.addPromise(o.noteDragStart(n,{...this.movementCommandContext,pointerType:t,pointerId:i}).then(()=>{o&&"touch"===j(e.originalEvent)&&"grabbable-object"!==o.captureMode&&"capture-when-engaged"!==o.defaultCaptureMode&&!o.editSession?.lastPointAddedBySession&&this._handleCommand({action:"vertex-add"})})):await this._updatingHandles.addPromise(o?.moveTo(n,{...this.movementCommandContext,pointerType:t,pointerId:i})):"grabbable-object"===o?.captureMode&&(this.interactiveHandleManager?.releaseHandle(r),await this._updatingHandles.addPromise(o.moveTo(n,{...this.movementCommandContext,pointerType:t,pointerId:i})))}async _handleVertexAddAtPointCommand(e){const t=this._updateLastScreenPosition(e),i=j(e.originalEvent),n=E(e.originalEvent);if(!this.interactiveHandleManager?.shouldCaptureInput(n,i))return;const a=this.interactiveHandleManager?.capturingHandle??this.interactiveHandleManager?.findHandleByManipulator(t,i);this.editable&&a&&(this._before(e)||(G(e),await this._updatingHandles.addPromise(a.moveTo(t,{...this.movementCommandContext,skipSnapping:!0,pointerType:i,pointerId:n}).finally(()=>this._commitNext()))))}_makeKeyBindings(){const e=new W,t=(t,i)=>{e.addToggle(t,e=>this._handleCommand({action:i,originalEvent:e,enabled:"key-down"===e.type}))},i=(t,i)=>{e.add(t,e=>this._handleCommand({action:i,originalEvent:e}))};return t($.preserveAspectRatio,"constraint-aspect"),t(J.center,"constraint-center"),i(X.toggleFollowManipulator,"toggle-manipulator-follow"),i(J.undo,"undo"),i(J.redo,"redo"),i(J.complete,"complete"),i(J.vertexAdd,"vertex-add"),i({key:Y.enterInputMode,continuePropagation:!0,repeats:!0},"show-tooltip"),e}_afterAttach(){}_afterDetach(e){this.interactiveHandleManager?.unregisterCustomConstraint(e),this.interactiveHandleManager?.unregisterHandle(e),this.tooltipManager?.unregisterPluginFields(e),this.globalStateManager.clearPluginOverrides(e);const t=this._pluginContexts.get(e);t&&(t.destroy(),this._pluginContexts.delete(e))}_beforeResume(e,t){this.interactiveHandleManager?.replaceEditSessions(e,t)}_commitNext(){const i={stack:[],error:void 0,hasError:!1};try{const t=this.mostDownstreamPlugin;if(!t)return;this.tooltipManager?.storeConstraintSnapshot();let n=!1;const a=this.editGeometryOperations;e(i,a?s(a.on("vertex-add",()=>n=!0)):null,!1);t.completeStep?t.completeStep():this.complete(t),n&&this.tooltipManager?.unlockOnVertexPlacement()}catch(n){i.error=n,i.hasError=!0}finally{t(i)}}_suspendPlugin(e){this.lifecycleManager.suspend(e),this.measurementManager.suspendPlugin(e)}_resumePlugin(e){this.lifecycleManager.resume(e)}_updateLastScreenPosition(e){const t=f(e.x,e.y);return this.lastScreenPosition=t,t}_getContextForPlugin(e,t){const i=o(this._pluginContexts,e,()=>new D({drawTool:this,plugin:e,session:t}));return i.session=t,i}_before(e){if(!this.hasEventListener(`before-${e.action}`))return!1;const t=new CustomEvent(`before-${e.action}`,{detail:e,cancelable:!0});return this.emit(`before-${e.action}`,t),t.defaultPrevented}_guardCommand(e,t,i){return this._before(e)?i?.():t()}async _setupSegmentLabels(){const e=this.editGeometryOperations,t=this.toolOptions?.labels,i=!!t?.enabled,n=this.globalStateManager.segmentLabelsDisabled;if(!e||!t||!i)return void(this._segmentLabels=l(this._segmentLabels));if(n)return void(this._segmentLabels&&(this._segmentLabels.visible=!1));if(this._segmentLabels?.context?.editGeometryOperations===e&&this._segmentLabels.context.labelOptions===t)return void(this._segmentLabels.visible=!0);const a=await this._createSegmentLabels(e,t);a&&(this._segmentLabels=l(this._segmentLabels),this._segmentLabels=a)}async _createSegmentLabels(e,t){this._segmentLabelsImportTask?.abort();const i=this._segmentLabelsImportTask=n(async i=>{if("3d"===this.view.type){const n=import("../3d/interactive/SegmentLabels3D.js"),{SegmentLabels3D:a}=await this._updatingHandles.addPromise(n);return this._isSegmentLabelsSetupStale(i,e,t)?null:new a({context:{view:this.view,editGeometryOperations:e,elevationInfo:L(this.hasZ,this.elevationInfo),labelOptions:t},visible:!0})}const n=import("../2d/interactive/SegmentLabels2D.js"),{SegmentLabels2D:a}=await this._updatingHandles.addPromise(n);return this._isSegmentLabelsSetupStale(i,e,t)?null:new a({context:{view:this.view,editGeometryOperations:e,elevationInfo:L(this.hasZ,this.elevationInfo),labelOptions:t},visible:!0})});return p(i.promise)}_isSegmentLabelsSetupStale(e,t,i){return e.aborted||this.editGeometryOperations!==t||this.toolOptions?.labels!==i||!i.enabled||this.globalStateManager.segmentLabelsDisabled}};i([_()],ie.prototype,"_commandsSuspended",void 0),i([_()],ie.prototype,"_zOfLastUserInput",null),i([_()],ie.prototype,"_snappingVisualizer",void 0),i([_()],ie.prototype,"_segmentLabels",void 0),i([_()],ie.prototype,"_segmentLabelsImportTask",void 0),i([_()],ie.prototype,"_tooltipDependencies",null),i([_()],ie.prototype,"_editSessionManagerContext",null),i([_()],ie.prototype,"_densificationParameters",null),i([_({constructOnly:!0,nonNullable:!0})],ie.prototype,"view",void 0),i([_()],ie.prototype,"automaticManipulatorSelection",void 0),i([_()],ie.prototype,"updating",null),i([_()],ie.prototype,"coordinateHelper",null),i([_()],ie.prototype,"editGeometry",null),i([_()],ie.prototype,"editGeometryOperations",null),i([_()],ie.prototype,"unprocessedGeometry",null),i([_()],ie.prototype,"simplifiedGeometryPreview",null),i([_()],ie.prototype,"_suppressCoincidentPointOverlaysIn3D",null),i([_()],ie.prototype,"_shapeVisualGeometry",null),i([_()],ie.prototype,"_vertexVisualGeometry",null),i([_()],ie.prototype,"snappingManager",void 0),i([_()],ie.prototype,"toolOptions",void 0),i([_()],ie.prototype,"elevationInfo",void 0),i([_()],ie.prototype,"hasZ",void 0),i([_()],ie.prototype,"defaultZ",void 0),i([_()],ie.prototype,"directionOptions",void 0),i([_()],ie.prototype,"canUndo",null),i([_()],ie.prototype,"canRedo",null),i([_()],ie.prototype,"pluginStack",null),i([_()],ie.prototype,"mostDownstreamPlugin",null),i([_()],ie.prototype,"mostUpstreamPlugin",null),i([_()],ie.prototype,"lastScreenPosition",void 0),i([_()],ie.prototype,"positionOfLastUserInput",null),i([_()],ie.prototype,"tooltipManager",void 0),i([_()],ie.prototype,"measurementManager",void 0),i([_()],ie.prototype,"globalStateManager",void 0),i([_()],ie.prototype,"editSessionManager",void 0),i([_()],ie.prototype,"lifecycleManager",void 0),i([_()],ie.prototype,"surfaceManager",void 0),i([_()],ie.prototype,"interactiveHandleManager",void 0),i([_()],ie.prototype,"renderer",void 0),i([_()],ie.prototype,"readPluginSetting",void 0),i([_()],ie.prototype,"movementCommandContext",null),i([_()],ie.prototype,"tooltip",null),i([_()],ie.prototype,"activeTooltipInfo",null),i([_()],ie.prototype,"helpMessageKey",null),i([_({constructOnly:!0})],ie.prototype,"enableVertexVisuals",void 0),ie=i([b("esri.views.draw.DrawTool")],ie);export{ie as DrawTool};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{zeroDegreesGeographic as t,createLength as i}from"../../../core/quantity.js";import{watch as o,initial as s}from"../../../core/reactiveUtils.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import{isPolyline as l}from"../../../geometry/support/typeUtils.js";import{PluginBase as a}from"./PluginBase.js";import{knownFieldDisplayOrders as d}from"../support/types.js";import{directionForVertices as p}from"../../support/angularMeasurementUtils.js";const m=Symbol("polyline-committed-length-measurement"),u=Symbol("polyline-staged-measurement"),c=Symbol("polyline-cursor-distance-measurement"),h=Symbol("polyline-distance-field"),_=Symbol("polyline-direction-field"),y=Symbol("polyline-total-length-field");let g=class extends a{constructor(){super(...arguments),this._lineVisualId=Symbol()}get _downstreamGeometry(){return this._downstreamEditSession?.generatePreviewGeometry({includeAutomaticConnection:!0,geometryType:"polyline"})}get _downstreamEditSession(){const{_downstreamPlugin:e,_context:t}=this;return e?t?.getSession(e):null}get _committed(){return this._getCommittedGeometry()}get helpMessageKey(){return this._session?.lastPointAddedBySession?"polylineOneVertex":"polylineZeroVertices"}start(e){super.start(e);const{session:t}=e;t.automaticRestart=!1,e.addOrUpdateVisual(this._lineVisualId,{role:"outline",state:"active"}),this.addHandles([o(()=>this._downstreamEditSession?.lastPointAddedBySession,t=>{this._cursorVertex=t;const i=this._downstreamGeometry,o=this._session;t&&o?(this._lastVertex=null!=t.pointIndex&&t.pointIndex>0?o.getInformationAboutPoint(t.pointIndex-1,t.partIndex):null,this._secondToLastVertex=null!=t.pointIndex&&t.pointIndex>1?o.getInformationAboutPoint(t.pointIndex-2,t.partIndex):null):(this._lastVertex=null,this._secondToLastVertex=null),e.addOrUpdateVisual(this._lineVisualId,{geometry:i})},s)],this._ownHandlesKey),this._setupTooltips()}complete(){this._session?.complete(),this._isComplete=!0,this.removeHandles(this._ownHandlesKey),this.removeHandles(this._downstreamHandlesKey)}attachPlugin(e){this._downstreamPlugin=e,this.notifyChange("_downstreamEditSession")}detachPlugin(e,t){this.notifyChange("_committed"),"complete"===t&&e.configuration&&this._context?.requestBeginDownstreamPlugin(e.configuration)}_getCommittedGeometry(){return this._session?.generatePreviewGeometry({includeAutomaticConnection:!1,geometryType:"polyline"})}_setupTooltips(){this._context&&(this._distanceField??=this._context.createMeasuredField({id:h,preset:"distance",getMeasurementInput:()=>[this._lastVertex?.point,this._cursorVertex?.point],measure:async(e,t)=>{if(!e||!e[0]||!e[1])return null;const i=t.inputUnitInfos.length.unit;return this._context?.measureDistance([e[0],e[1]],c,"tooltip",i)},fieldProperties:{displayOrder:d.Coordinates+11},fieldFilters:{appliesToHandlesWithRole:"primary"}}),this._directionField??=this._context.createMeasuredField({id:_,preset:"direction",getMeasurementInput:()=>[this._lastVertex?.point,this._cursorVertex?.point],measure:async([e,i],o)=>{const s=o.sketchOptions.values.effectiveDirectionMode;if(e&&i){const o=p(this._secondToLastVertex?.point,e,i,s);return this._directionField&&(this._directionField.readOnly="absolute"===s?!e:!this._secondToLastVertex?.point),o??("absolute"===s||this._secondToLastVertex?t:null)}return null},fieldProperties:{displayOrder:d.Coordinates+10},fieldFilters:{appliesToHandlesWithRole:"primary"}}),this._setupGeometrySpecificTooltip())}_setupGeometrySpecificTooltip(){this._context&&(this._lengthField??=this._context.createMeasuredField({id:y,preset:"totalLength",getMeasurementInput:()=>[this._committed,this._downstreamGeometry],measure:async([e,t],o,s)=>{const n=o.inputUnitInfos.length.unit,r=t&&l(t)?await(this._context?.measureLength(t,u,"tooltip",n)):void 0,a=e&&e!==s?.[0]&&l(e)?await(this._context?.measureLength(e,m,"tooltip",n)):e?this._cachedCommittedLength:null;return this._cachedCommittedLength=a,(a||r)&&(e||0!==r?.value)?i((a?.value??0)+(r?.value??0),n):null},fieldProperties:{displayOrder:d.ShapeMeasurements}}))}};e([n()],g.prototype,"_downstreamPlugin",void 0),e([n()],g.prototype,"_lastVertex",void 0),e([n()],g.prototype,"_cursorVertex",void 0),e([n()],g.prototype,"_secondToLastVertex",void 0),e([n()],g.prototype,"_lengthField",void 0),e([n()],g.prototype,"_distanceField",void 0),e([n()],g.prototype,"_directionField",void 0),e([n()],g.prototype,"_downstreamGeometry",null),e([n()],g.prototype,"_downstreamEditSession",null),e([n()],g.prototype,"_committed",null),e([n()],g.prototype,"helpMessageKey",null),g=e([r("esri.views.draw.plugins.PolylinePlugin")],g);export{g as PolylinePlugin};
2
+ import{__decorate as e}from"tslib";import{zeroDegreesGeographic as t,createLength as i}from"../../../core/quantity.js";import{watch as o,initial as s}from"../../../core/reactiveUtils.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import{isPolyline as l}from"../../../geometry/support/typeUtils.js";import{PluginBase as a}from"./PluginBase.js";import{knownFieldDisplayOrders as d}from"../support/types.js";import{directionForVertices as p}from"../../support/angularMeasurementUtils.js";const m=Symbol("polyline-committed-length-measurement"),u=Symbol("polyline-staged-measurement"),c=Symbol("polyline-cursor-distance-measurement"),h=Symbol("polyline-distance-field"),_=Symbol("polyline-direction-field"),y=Symbol("polyline-total-length-field");let g=class extends a{constructor(){super(...arguments),this._lineVisualId=Symbol()}get _downstreamGeometry(){return this._downstreamEditSession?.generatePreviewGeometry({includeAutomaticConnection:!0,geometryType:"polyline"})}get _downstreamEditSession(){const{_downstreamPlugin:e,_context:t}=this;return e?t?.getSession(e):null}get _committed(){return this._getCommittedGeometry()}get helpMessageKey(){return this._session?.lastPointAddedBySession?"polylineOneVertex":"polylineZeroVertices"}start(e){super.start(e);const{session:t}=e;t.automaticRestart=!1,e.addOrUpdateVisual(this._lineVisualId,{role:"outline",state:"active"}),this.addHandles([o(()=>this._downstreamEditSession?.lastPointAddedBySession,t=>{this._cursorVertex=t;const i=this._downstreamGeometry,o=this._session;t&&o?(this._lastVertex=null!=t.pointIndex&&t.pointIndex>0?o.getInformationAboutPoint(t.pointIndex-1,t.partIndex):null,this._secondToLastVertex=null!=t.pointIndex&&t.pointIndex>1?o.getInformationAboutPoint(t.pointIndex-2,t.partIndex):null):(this._lastVertex=null,this._secondToLastVertex=null),e.addOrUpdateVisual(this._lineVisualId,{geometry:i})},s)],this._ownHandlesKey),this._setupTooltips()}complete(){this._session?.complete(),this._isComplete=!0,this.removeHandles(this._ownHandlesKey),this.removeHandles(this._downstreamHandlesKey)}attachPlugin(e){this._downstreamPlugin=e,this.notifyChange("_downstreamEditSession")}detachPlugin(e,t){this.notifyChange("_committed"),"complete"===t&&e.configuration&&this._context?.requestBeginDownstreamPlugin(e.configuration)}_getCommittedGeometry(){return this._session?.generatePreviewGeometry({includeAutomaticConnection:!1,geometryType:"polyline"})}_setupTooltips(){this._context&&(this._distanceField??=this._context.createMeasuredField({id:h,preset:"distance",getMeasurementInput:()=>[this._lastVertex?.point,this._cursorVertex?.point],measure:async(e,t)=>{if(!e||!e[0]||!e[1])return null;const i=t.inputUnitInfos.length.unit;return this._context?.measureDistance([e[0],e[1]],c,"tooltip",i)},fieldProperties:{displayOrder:d.Coordinates+11},fieldFilters:{appliesToHandlesWithRole:"primary"}}),this._directionField??=this._context.createMeasuredField({id:_,preset:"direction",getMeasurementInput:()=>[this._lastVertex?.point,this._cursorVertex?.point],measure:async([e,i],o)=>{const s=o.toolOptions.values.effectiveDirectionMode;if(e&&i){const o=p(this._secondToLastVertex?.point,e,i,s);return this._directionField&&(this._directionField.readOnly="absolute"===s?!e:!this._secondToLastVertex?.point),o??("absolute"===s||this._secondToLastVertex?t:null)}return null},fieldProperties:{displayOrder:d.Coordinates+10},fieldFilters:{appliesToHandlesWithRole:"primary"}}),this._setupGeometrySpecificTooltip())}_setupGeometrySpecificTooltip(){this._context&&(this._lengthField??=this._context.createMeasuredField({id:y,preset:"totalLength",getMeasurementInput:()=>[this._committed,this._downstreamGeometry],measure:async([e,t],o,s)=>{const n=o.inputUnitInfos.length.unit,r=t&&l(t)?await(this._context?.measureLength(t,u,"tooltip",n)):void 0,a=e&&e!==s?.[0]&&l(e)?await(this._context?.measureLength(e,m,"tooltip",n)):e?this._cachedCommittedLength:null;return this._cachedCommittedLength=a,(a||r)&&(e||0!==r?.value)?i((a?.value??0)+(r?.value??0),n):null},fieldProperties:{displayOrder:d.ShapeMeasurements}}))}};e([n()],g.prototype,"_downstreamPlugin",void 0),e([n()],g.prototype,"_lastVertex",void 0),e([n()],g.prototype,"_cursorVertex",void 0),e([n()],g.prototype,"_secondToLastVertex",void 0),e([n()],g.prototype,"_lengthField",void 0),e([n()],g.prototype,"_distanceField",void 0),e([n()],g.prototype,"_directionField",void 0),e([n()],g.prototype,"_downstreamGeometry",null),e([n()],g.prototype,"_downstreamEditSession",null),e([n()],g.prototype,"_committed",null),e([n()],g.prototype,"helpMessageKey",null),g=e([r("esri.views.draw.plugins.PolylinePlugin")],g);export{g as PolylinePlugin};
@@ -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"../../../Graphic.js";import{EventedAccessor as i}from"../../../core/Evented.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{debounce as o}from"../../../core/promiseUtils.js";import{zeroMeters as r}from"../../../core/quantity.js";import{when as a,watch as h,syncAndInitial as c,initial as n}from"../../../core/reactiveUtils.js";import{property as l,subclass as p}from"../../../core/accessorSupport/decorators.js";import{UpdatingHandles as _}from"../../../core/support/UpdatingHandles.js";import d from"../../../geometry/Point.js";import m from"../../../geometry/Polygon.js";import u from"../../../geometry/Polyline.js";import{create as g,center as y}from"../../../geometry/support/aaBoundingRect.js";import{getBoundsXY as v}from"../../../geometry/support/boundsUtils.js";import f from"../../../geometry/support/rotate.js";import G from"../../../symbols/SimpleFillSymbol.js";import b from"../../../symbols/SimpleLineSymbol.js";import x from"../../../symbols/SimpleMarkerSymbol.js";import{cloneMove as w,scale as S,getRotationAngle as k,getScaleRatio as R}from"./drawUtils.js";import H from"./GraphicMover.js";import I from"./HighlightHelper.js";import{addUniqueLayer as C}from"./layerUtils.js";import{settings as M}from"./settings.js";import T from"../../interactive/sketch/SketchOptions.js";import{makeTooltip as O}from"../../interactive/tooltip/tooltipCommonUtils.js";import{ExtentRotateTooltipInfo as j}from"../../interactive/tooltip/infos/ExtentRotateTooltipInfo.js";import{ExtentScaleTooltipInfo as E}from"../../interactive/tooltip/infos/ExtentScaleTooltipInfo.js";import{TranslateTooltipInfo as B}from"../../interactive/tooltip/infos/TranslateTooltipInfo.js";import{GeometryWorkerHandle as L}from"../../support/GeometryWorkerHandle.js";const N=M.transformGraphics,z={centerIndicator:new x({style:"cross",size:N.center.size,color:N.center.color}),fill:{default:new G({color:N.fill.color,outline:{color:N.fill.outlineColor,join:"round",width:1}}),active:new G({color:N.fill.stagedColor,outline:{color:N.fill.outlineColor,join:"round",style:"dash",width:1}})},handles:{default:new x({style:"square",size:N.vertex.size,color:N.vertex.color,outline:{color:N.vertex.outlineColor,width:1}}),hover:new x({style:"square",size:N.vertex.hoverSize,color:N.vertex.hoverColor,outline:{color:N.vertex.hoverOutlineColor,width:1}})},rotator:{default:new x({style:"circle",size:N.vertex.size,color:N.vertex.color,outline:{color:N.vertex.outlineColor,width:1}}),hover:new x({style:"circle",size:N.vertex.hoverSize,color:N.vertex.hoverColor,outline:{color:N.vertex.hoverOutlineColor,width:1}})},rotatorLine:new b({color:N.line.color,width:1})},Y=Symbol();let A=class extends i{constructor(t){super(t),this._activeHandleGraphic=null,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._centerGraphic=null,this._backgroundGraphic=null,this._vertexGraphics=[],this._rotateHandleGraphic=null,this._rotateGraphicOffset=20,this._angleOfRotation=0,this._rotateLineGraphic=null,this._startInfo=null,this._totalDx=0,this._totalDy=0,this._xScale=1,this._yScale=1,this.tooltip=null,this.type="box",this.callbacks={onMoveStart(){},onMove(){},onMoveStop(){},onScaleStart(){},onScale(){},onScaleStop(){},onRotateStart(){},onRotate(){},onRotateStop(){},onGraphicClick(){}},this.enableMovement=!0,this.enableRotation=!0,this.enableScaling=!0,this.graphics=[],this.highlightName=null,this.highlightsEnabled=!0,this.layer=null,this.preserveAspectRatio=!1,this.showCenterGraphic=!0,this.symbols=z,this.sketchOptions=new T,this.view=null,this._updatingHandles=new _,this._getBounds=(()=>{const t=g();return(e,i)=>{e[0]=Number.POSITIVE_INFINITY,e[1]=Number.POSITIVE_INFINITY,e[2]=Number.NEGATIVE_INFINITY,e[3]=Number.NEGATIVE_INFINITY;for(const s of i){if(!s)continue;let i,o,r,a;if("point"===s.type)i=r=s.x,o=a=s.y;else if("extent"===s.type)[i,o,r,a]=[s.xmin,s.ymin,s.xmax,s.ymax];else{const e=v(t,s);[i,o,r,a]=e}e[0]=Math.min(i,e[0]),e[1]=Math.min(o,e[1]),e[2]=Math.max(r,e[2]),e[3]=Math.max(a,e[3])}return e}})(),this._extentScaleTooltipInfo=new E({sketchOptions:this.sketchOptions}),this._measurementWorker=new L({preloadGeodetic:!0}),this._updateScaleTooltipAsync=o(async()=>{const t=this._getCoordinates(),e=this.view.spatialReference,{width:i,height:s}=await this._measurementWorker.autoSize2D(new d({x:t[0][0],y:t[0][1],spatialReference:e}),new d({x:t[1][0],y:t[1][1],spatialReference:e}),new d({x:t[2][0],y:t[2][1],spatialReference:e}),new d({x:t[3][0],y:t[3][1],spatialReference:e}));this._extentScaleTooltipInfo.xSize=i,this._extentScaleTooltipInfo.ySize=s}),this._translateTooltipInfo=new B({sketchOptions:this.sketchOptions}),this._updateMoveTooltipAsync=o(async t=>{const{view:e}=this,i=this._translateTooltipInfo;if(!t)return void(i.distance=r);const{x:s,y:o}=t.origin,a=e.toMap(t),h=e.toMap({x:s,y:o}),c=await this._measurementWorker.autoDistance2DBetweenPoints(h,a);i.distance=null!=c?c:r})}initialize(){const t=this.view;this._highlightHelper=new I({view:t}),this._setup(),this.addHandles([a(()=>t?.ready,()=>{const{layer:t,view:e}=this;C(e,t)},{once:!0,initial:!0}),h(()=>this.preserveAspectRatio,()=>{this._activeHandleGraphic&&(this._scaleGraphic(this._activeHandleGraphic),this._updateGraphics(),this._updateTooltip(this._activeHandleGraphic))}),h(()=>t?.scale,()=>{this._updateRotateGraphic(),this._updateRotateLineGraphic()}),h(()=>this.graphics,()=>this.refresh()),h(()=>this.layer,(t,e)=>{e&&this._resetGraphics(e),this.refresh()}),h(()=>[this.highlightsEnabled,this.highlightName],()=>{this._highlightHelper?.removeAll(),this._setUpHighlights()}),h(()=>this.sketchOptions.tooltips.effectiveEnabled,e=>{this.tooltip=e?O(()=>({view:t,options:this.sketchOptions.tooltips})):s(this.tooltip)},c),h(()=>this.view.effectiveTheme.accentColor,()=>this._updateSymbolsForTheme(),n),this.on("move-start",t=>this.callbacks?.onMoveStart?.(t)),this.on("move",t=>this.callbacks?.onMove?.(t)),this.on("move-stop",t=>this.callbacks?.onMoveStop?.(t)),this.on("rotate-start",t=>this.callbacks?.onRotateStart?.(t)),this.on("rotate",t=>this.callbacks?.onRotate?.(t)),this.on("rotate-stop",t=>this.callbacks?.onRotateStop?.(t)),this.on("scale-start",t=>this.callbacks?.onScaleStart?.(t)),this.on("scale",t=>this.callbacks?.onScale?.(t)),this.on("scale-stop",t=>this.callbacks?.onScaleStop?.(t))])}destroy(){this._reset(),this.tooltip=s(this.tooltip)}get state(){const t=this.view?.ready??!1,e=this.graphics.length&&this.layer;return t&&e?"active":t?"ready":"disabled"}get updating(){return this._updatingHandles.updating}isUIGraphic(t){return this._vertexGraphics.includes(t)||t===this._backgroundGraphic||t===this._centerGraphic||t===this._rotateHandleGraphic||t===this._rotateLineGraphic}move(t,e){if(this._mover&&this.graphics.length){for(const i of this.graphics){const s=i.geometry,o=w(s,t,e,this.view);i.geometry=o}this.refresh(),this.emit("move-stop",{graphics:this.graphics,mover:null,dx:t,dy:e,type:"move-stop"})}}scale(t,e){if(!this._mover||!this.graphics.length)return;const i=this._getBoxBounds(g()),s=y(i);for(const o of this.graphics){const i=o.geometry,r=S(i,t,e,s);o.geometry=r}this.refresh(),this.emit("scale-stop",{graphics:this.graphics,mover:null,xScale:t,yScale:e,type:"scale-stop"})}rotate(t,e){if(this._mover&&this.graphics.length){if(!e){const t=this._vertexGraphics[1].geometry.x,i=this._vertexGraphics[3].geometry.y;e=new d(t,i,this.view.spatialReference)}for(const i of this.graphics){const s=i.geometry,o=f(s,t,e);i.geometry=o}this.refresh(),this.emit("rotate-stop",{graphics:this.graphics,mover:null,angle:t,type:"rotate-stop"})}}refresh(){this._reset(),this._setup()}reset(){this.graphics=[]}_setup(){"active"===this.state&&(this._setUpHighlights(),this._setupGraphics(),this._setupMover(),this._updateGraphics())}_reset(){this._highlightHelper?.removeAll(),this._resetGraphicStateVars(),this._resetGraphics(),this._updateTooltip(),this._mover?.destroy(),this._mover=null,this.removeHandles(Y)}_resetGraphicStateVars(){this._startInfo=null,this._activeHandleGraphic=null,this._totalDx=0,this._totalDy=0,this._xScale=1,this._yScale=1,this._angleOfRotation=0}_resetGraphics(t){(t=t||this.layer)&&(t.removeMany(this._vertexGraphics),t.remove(this._backgroundGraphic),t.remove(this._centerGraphic),t.remove(this._rotateHandleGraphic),t.remove(this._rotateLineGraphic)),this._vertexGraphics.forEach(t=>!t.destroyed&&t.destroy()),!this._backgroundGraphic.destroyed&&this._backgroundGraphic.destroy(),!this._centerGraphic.destroyed&&this._centerGraphic.destroy(),!this._rotateHandleGraphic.destroyed&&this._rotateHandleGraphic.destroy(),!this._rotateLineGraphic.destroyed&&this._rotateLineGraphic.destroy(),this._vertexGraphics=[],this._backgroundGraphic=null,this._centerGraphic=null,this._rotateHandleGraphic=null,this._rotateLineGraphic=null}_setupMover(){let t=[];this.enableScaling&&(t=t.concat(this._vertexGraphics)),this.enableRotation&&t.push(this._rotateHandleGraphic),this.enableMovement&&(t=t.concat(this.graphics,this._backgroundGraphic)),this.showCenterGraphic&&t.push(this._centerGraphic),this._mover=new H({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,view:this.view,graphics:t,callbacks:{onGraphicClick:t=>this._onGraphicClickCallback(t),onGraphicMoveStart:t=>this._onGraphicMoveStartCallback(t),onGraphicMove:t=>this._onGraphicMoveCallback(t),onGraphicMoveStop:t=>this._onGraphicMoveStopCallback(t),onGraphicPointerOver:t=>this._onGraphicPointerOverCallback(t),onGraphicPointerOut:t=>this._onGraphicPointerOutCallback(t)}})}_setCursor(t){this.addHandles(this.view.acquireCursor(t,"high"),Y)}_getStartInfo(t){const[e,i,s,o]=this._getBoxBounds(g()),r=Math.abs(s-e),a=Math.abs(o-i),h=(s+e)/2,c=(o+i)/2,{x:n,y:l}=t.geometry;return{width:r,height:a,centerX:h,centerY:c,startX:n,startY:l,graphicInfos:this._getGraphicInfos(),box:this._backgroundGraphic.geometry,rotate:this._rotateHandleGraphic.geometry}}_getGraphicInfos(){return this.graphics.map(t=>this._getGraphicInfo(t))}_getGraphicInfo(t){const e=t.geometry,[i,s,o,r]=this._getBounds(g(),[e]);return{width:Math.abs(o-i),height:Math.abs(r-s),centerX:(o+i)/2,centerY:(r+s)/2,geometry:e}}_onGraphicClickCallback(t){t.viewEvent.stopPropagation(),this.emit("graphic-click",t),this.callbacks.onGraphicClick&&this.callbacks.onGraphicClick(t)}_onGraphicMoveStartCallback(t){const{_angleOfRotation:e,_xScale:i,_yScale:s,_backgroundGraphic:o,_vertexGraphics:r,_rotateHandleGraphic:a,symbols:h,graphics:c}=this,{graphic:n,dx:l,dy:p,viewEvent:_}=t;this._resetGraphicStateVars(),this._hideGraphicsBeforeUpdate(),o.symbol=h.fill.active,this._startInfo=this._getStartInfo(n),this._updateTooltip(n,_),n===a?(this._setCursor("grabbing"),this.emit("rotate-start",{type:"rotate-start",mover:n,graphics:c,angle:e})):r.includes(n)?(this._activeHandleGraphic=n,this.emit("scale-start",{type:"scale-start",mover:n,graphics:c,xScale:i,yScale:s})):this.emit("move-start",{type:"move-start",graphics:c,mover:n,dx:l,dy:p})}_onGraphicMoveCallback(t){const e=t.graphic;if(!this._startInfo)return;const{_xScale:i,_yScale:s,_angleOfRotation:o,graphics:r}=this;if(this._vertexGraphics.includes(e))this._scaleGraphic(e),this._updateTooltip(e,t.viewEvent),this.emit("scale",{type:"scale",graphics:r,mover:e,xScale:i,yScale:s});else if(e===this._rotateHandleGraphic)this._rotateGraphic(e),this._updateTooltip(e,t.viewEvent),this.emit("rotate",{type:"rotate",graphics:r,mover:e,angle:o});else{const{dx:i,dy:s}=t;this._totalDx+=i,this._totalDy+=s,this._moveGraphic(e,i,s),this._updateTooltip(e,t.viewEvent),this.emit("move",{type:"move",graphics:r,mover:e,dx:i,dy:s})}}_onGraphicMoveStopCallback(t){const e=t.graphic;if(!this._startInfo)return void this.refresh();const{_angleOfRotation:i,_totalDx:s,_totalDy:o,_xScale:r,_yScale:a,_vertexGraphics:h,_rotateHandleGraphic:c,graphics:n}=this;this.refresh(),e===c?(this._setCursor("pointer"),this.emit("rotate-stop",{type:"rotate-stop",graphics:n,mover:e,angle:i})):h.includes(e)?this.emit("scale-stop",{type:"scale-stop",mover:e,graphics:n,xScale:r,yScale:a}):this.emit("move-stop",{type:"move-stop",graphics:n,mover:e,dx:s,dy:o})}_onGraphicPointerOverCallback(t){const{_backgroundGraphic:e,_vertexGraphics:i,graphics:s,_rotateHandleGraphic:o,symbols:r,view:a}=this,h=t.graphic;if(this._hoveredGraphic=h,h===o)return o.symbol=r.rotator.hover,this._setCursor("pointer"),void this._updateTooltip(h);if(s.includes(h)||h===e)return void this._setCursor("move");if(!i.includes(h))return void this._setCursor("pointer");this._updateTooltip(h),t.graphic.symbol=r.handles.hover;const c=a.rotation;let n,l=t.index;switch(l<8&&(c>=0&&c<45?l%=8:l=c>=45&&c<90?(l+1)%8:c>=90&&c<135?(l+2)%8:c>=135&&c<180?(l+3)%8:c>=180&&c<225?(l+4)%8:c>=225&&c<270?(l+5)%8:c>=270&&c<315?(l+6)%8:(l+7)%8),l){case 0:case 4:n="nwse-resize";break;case 1:case 5:n="ns-resize";break;case 2:case 6:n="nesw-resize";break;case 3:case 7:n="ew-resize";break;default:n="pointer"}this._setCursor(n)}_onGraphicPointerOutCallback(t){const{_vertexGraphics:e,_rotateHandleGraphic:i,symbols:s}=this;this._hoveredGraphic=null,t.graphic===i?i.symbol=s.rotator.default:e.includes(t.graphic)&&(t.graphic.symbol=s.handles.default),this.removeHandles(Y),this._updateTooltip()}_scaleGraphic(t){const{_startInfo:e,_vertexGraphics:i,preserveAspectRatio:s,view:o}=this,{centerX:r,centerY:a,graphicInfos:h,height:c,startX:n,startY:l,width:p}=e,{resolution:_,transform:m}=o.state,u=i.indexOf(t);1!==u&&5!==u||this._updateX(t,r),3!==u&&7!==u||this._updateY(t,a);const{x:g,y}=t.geometry,v=m[0]*g+m[2]*y+m[4],f=m[1]*g+m[3]*y+m[5],G=h?.map(t=>t.geometry)??[],b=G.every(t=>"point"===t.type);if((0===p||0===c)&&b){const t=P((g-n)/_),i=P((l-y)/_);for(let e=0;e<G.length;e++)this.graphics[e].geometry=w(G[e],t,i,o,!0);return this._centerGraphic.geometry=new d(g,y,o.spatialReference),void(this._backgroundGraphic.geometry=w(e.box,t,i,o,!0))}if(s){const t=P(m[0]*r+m[2]*a+m[4],2),e=P(m[1]*r+m[3]*a+m[5],2),i=P(m[0]*n+m[2]*l+m[4],2),s=P(m[1]*n+m[3]*l+m[5],2);let o=R(t,e,i,s,v,f);0!==o&&Math.abs(o)!==1/0||(o=1),this._xScale=this._yScale=o;for(const h of G){const t=G.indexOf(h);this.graphics[t].geometry=S(h,this._xScale,this._yScale,[r,a])}this._updateBackgroundGraphic()}else{let t=g-n,i=l-y;if(1===u||5===u?t=0:3!==u&&7!==u||(i=0),0===t&&0===i)return;const s=r+t/2,h=a+i/2;let m=(p+(n>r?t:-1*t))/p,v=(c+(l<a?i:-1*i))/c;1!==u&&5!==u&&0!==m&&Math.abs(m)!==1/0||(m=1),3!==u&&7!==u&&0!==v&&Math.abs(v)!==1/0||(v=1),this._xScale=m,this._yScale=v;const f=(s-r)/_,b=(h-a)/_,x=S(e.box,this._xScale,this._yScale);this._backgroundGraphic.geometry=w(x,f,b,o,!0);const{centerX:k,centerY:R}=this._getGraphicInfo(this._backgroundGraphic),H=(k-r)/_,I=-1*(R-a)/_;for(const e of G){const t=G.indexOf(e),i=S(e,this._xScale,this._yScale,[r,a]);this.graphics[t].geometry=w(i,H,I,o,!0)}this._centerGraphic.geometry=new d(k,R,o.spatialReference)}}_rotateGraphic(t){const{centerX:e,centerY:i,startX:s,startY:o,box:r,rotate:a}=this._startInfo,h=this.view.spatialReference,c=new d(s,o,h),n=new d(e,i,h),l=t.geometry;this._angleOfRotation=k(c,l,n);const p=this._startInfo.graphicInfos?.map(t=>t.geometry)??[];for(const _ of p){const t=p.indexOf(_),e=f(_,this._angleOfRotation,n);this.graphics[t].geometry=e}this._backgroundGraphic.geometry=f(r,this._angleOfRotation,n),this._rotateHandleGraphic.geometry=f(a,this._angleOfRotation,n)}_moveGraphic(t,e,i){if(this.graphics.includes(t)){const s=this._backgroundGraphic.geometry;this._backgroundGraphic.geometry=w(s,e,i,this.view);for(const o of this.graphics)o!==t&&(o.geometry=w(o.geometry,e,i,this.view))}else if(t===this._centerGraphic){const t=this._backgroundGraphic.geometry;this._backgroundGraphic.geometry=w(t,e,i,this.view)}if(t===this._backgroundGraphic||t===this._centerGraphic)for(const s of this.graphics)s.geometry=w(s.geometry,e,i,this.view)}_setUpHighlights(){this.highlightsEnabled&&this.graphics.length&&this._highlightHelper?.add(this.graphics,this.highlightName)}_setupGraphics(){const{_graphicAttributes:t,symbols:i}=this;this._centerGraphic=new e({symbol:i.centerIndicator,attributes:t}),this.showCenterGraphic&&this.layer.add(this._centerGraphic),this._backgroundGraphic=new e({symbol:i.fill.default,attributes:t}),this.layer.add(this._backgroundGraphic),this._rotateLineGraphic=new e({symbol:i.rotatorLine,attributes:t}),this._rotateHandleGraphic=new e({symbol:i.rotator.default,attributes:t}),this.enableRotation&&!this._hasExtentGraphic()&&this.layer.addMany([this._rotateLineGraphic,this._rotateHandleGraphic]);for(let s=0;s<8;s++)this._vertexGraphics.push(new e({symbol:i.handles.default,attributes:t}));this.enableScaling&&this.layer.addMany(this._vertexGraphics)}_updateSymbolsForTheme(){const t=this.view.effectiveTheme.accentColor;this.symbols={...this.symbols,fill:{active:this.symbols.fill.active?.clone().set("outline.color",t),default:this.symbols.fill.default?.clone().set("outline.color",t)},handles:{...this.symbols.handles,default:this.symbols.handles.default.clone().set("outline.color",t)},rotator:{...this.symbols.rotator,default:this.symbols.rotator.default.clone().set("outline.color",t)},rotatorLine:this.symbols.rotatorLine.clone().set("color",t)};for(const e of this._vertexGraphics)e.symbol=e===this._hoveredGraphic?this.symbols.handles.hover:this.symbols.handles.default;this._backgroundGraphic.symbol=this.symbols.fill.default,this._rotateHandleGraphic.symbol=this._rotateHandleGraphic===this._hoveredGraphic?this.symbols.rotator.hover:this.symbols.rotator.default,this._rotateLineGraphic.symbol=this.symbols.rotatorLine}_updateGraphics(){this._updateBackgroundGraphic(),this._updateHandleGraphics(),this._updateCenterGraphic(),this._updateRotateGraphic(),this._updateRotateLineGraphic()}_hideGraphicsBeforeUpdate(){this._centerGraphic.visible=!1,this._rotateHandleGraphic.visible=!1,this._rotateLineGraphic.visible=!1,this._vertexGraphics.forEach(t=>t.visible=!1)}_updateHandleGraphics(){const t=this._getCoordinates(!0);this._vertexGraphics.forEach((e,i)=>{const[s,o]=t[i];this._updateXY(e,s,o)})}_updateBackgroundGraphic(){const t=this._getCoordinates().map(([t,e])=>[t,e]);this._backgroundGraphic.geometry=new m({rings:[t],spatialReference:this.view.spatialReference})}_updateCenterGraphic(){const[t,e,i,s]=this._getBoxBounds(g()),o=(i+t)/2,r=(s+e)/2;this._centerGraphic.geometry=new d(o,r,this.view.spatialReference)}_updateRotateGraphic(){if(!this._vertexGraphics.length)return;const{x:t,y:e}=this._vertexGraphics[1].geometry,i=e+this.view.state.resolution*this._rotateGraphicOffset;this._rotateHandleGraphic.geometry=new d(t,i,this.view.spatialReference)}_updateRotateLineGraphic(){if(!this._vertexGraphics.length||!this._rotateHandleGraphic?.geometry)return;const t=this._vertexGraphics[1].geometry,e=this._rotateHandleGraphic.geometry;this._rotateLineGraphic.geometry=new u({paths:[[[t.x,t.y],[e.x,e.y]]],spatialReference:this.view.spatialReference})}_updateXY(t,e,i){t.geometry=new d(e,i,this.view.spatialReference)}_updateX(t,e){const i=t.geometry.y;t.geometry=new d(e,i,this.view.spatialReference)}_updateY(t,e){const i=t.geometry.x;t.geometry=new d(i,e,this.view.spatialReference)}_hasExtentGraphic(){return this.graphics.some(t=>null!=t?.geometry&&"extent"===t.geometry.type)}_getBoxBounds(t){const e=this.graphics.map(t=>t.geometry);return this._getBounds(t,e)}_getCoordinates(t){const[e,i,s,o]=this._getBoxBounds(g());if(t){const t=(e+s)/2,r=(o+i)/2;return[[e,o],[t,o],[s,o],[s,r],[s,i],[t,i],[e,i],[e,r]]}return[[e,o],[s,o],[s,i],[e,i]]}_updateTooltip(t,e){if(null==this.tooltip)return;if(!t)return void this.tooltip.clear();const{_backgroundGraphic:i,graphics:s,_vertexGraphics:o,_rotateHandleGraphic:r}=this;t===r?this._updateRotateTooltip():o.includes(t)?this._updateScaleTooltip():(s.includes(t)||t===i)&&this._updateMoveTooltip(e)}_updateRotateTooltip(){null!=this.tooltip&&(this.tooltip.info=new j({sketchOptions:this.sketchOptions,angle:-this._angleOfRotation}))}_updateScaleTooltip(){const{tooltip:t,_xScale:e,_yScale:i,sketchOptions:s}=this;if(null==t)return;const o=Math.abs(e),r=Math.abs(i),a=this._extentScaleTooltipInfo;a.sketchOptions=s,a.xScale=o,a.yScale=r,this._updatingHandles.consumePromise(this._updateScaleTooltipAsync()),t.info=a}_updateMoveTooltip(t){const{tooltip:e}=this;if(null==e)return;const i=this._translateTooltipInfo;this._updatingHandles.consumePromise(this._updateMoveTooltipAsync(t)),e.info=i}};function P(t,e=2){return Number.parseFloat(t.toFixed(e))}t([l()],A.prototype,"tooltip",void 0),t([l({readOnly:!0})],A.prototype,"type",void 0),t([l()],A.prototype,"callbacks",void 0),t([l()],A.prototype,"enableMovement",void 0),t([l()],A.prototype,"enableRotation",void 0),t([l()],A.prototype,"enableScaling",void 0),t([l()],A.prototype,"graphics",void 0),t([l()],A.prototype,"highlightName",void 0),t([l()],A.prototype,"highlightsEnabled",void 0),t([l()],A.prototype,"layer",void 0),t([l()],A.prototype,"preserveAspectRatio",void 0),t([l()],A.prototype,"showCenterGraphic",void 0),t([l({readOnly:!0})],A.prototype,"state",null),t([l()],A.prototype,"symbols",void 0),t([l({type:T})],A.prototype,"sketchOptions",void 0),t([l({constructOnly:!0})],A.prototype,"view",void 0),A=t([p("esri.views.draw.support.Box")],A);const U=A;export{U as default};
2
+ import{__decorate as t}from"tslib";import e from"../../../Graphic.js";import{EventedAccessor as i}from"../../../core/Evented.js";import{destroyMaybe as o}from"../../../core/maybe.js";import{debounce as s}from"../../../core/promiseUtils.js";import{zeroMeters as r}from"../../../core/quantity.js";import{when as a,watch as h,syncAndInitial as n,initial as c}from"../../../core/reactiveUtils.js";import{property as l,subclass as p}from"../../../core/accessorSupport/decorators.js";import{UpdatingHandles as _}from"../../../core/support/UpdatingHandles.js";import d from"../../../geometry/Point.js";import m from"../../../geometry/Polygon.js";import u from"../../../geometry/Polyline.js";import{create as g,center as y}from"../../../geometry/support/aaBoundingRect.js";import{getBoundsXY as v}from"../../../geometry/support/boundsUtils.js";import f from"../../../geometry/support/rotate.js";import G from"../../../symbols/SimpleFillSymbol.js";import b from"../../../symbols/SimpleLineSymbol.js";import x from"../../../symbols/SimpleMarkerSymbol.js";import{cloneMove as w,scale as S,getRotationAngle as k,getScaleRatio as R}from"./drawUtils.js";import H from"./GraphicMover.js";import I from"./HighlightHelper.js";import{addUniqueLayer as C}from"./layerUtils.js";import{settings as M}from"./settings.js";import T from"../../interactive/options/InteractiveToolOptions.js";import{makeTooltip as O}from"../../interactive/tooltip/tooltipCommonUtils.js";import{ExtentRotateTooltipInfo as j}from"../../interactive/tooltip/infos/ExtentRotateTooltipInfo.js";import{ExtentScaleTooltipInfo as E}from"../../interactive/tooltip/infos/ExtentScaleTooltipInfo.js";import{TranslateTooltipInfo as B}from"../../interactive/tooltip/infos/TranslateTooltipInfo.js";import{GeometryWorkerHandle as L}from"../../support/GeometryWorkerHandle.js";const N=M.transformGraphics,z={centerIndicator:new x({style:"cross",size:N.center.size,color:N.center.color}),fill:{default:new G({color:N.fill.color,outline:{color:N.fill.outlineColor,join:"round",width:1}}),active:new G({color:N.fill.stagedColor,outline:{color:N.fill.outlineColor,join:"round",style:"dash",width:1}})},handles:{default:new x({style:"square",size:N.vertex.size,color:N.vertex.color,outline:{color:N.vertex.outlineColor,width:1}}),hover:new x({style:"square",size:N.vertex.hoverSize,color:N.vertex.hoverColor,outline:{color:N.vertex.hoverOutlineColor,width:1}})},rotator:{default:new x({style:"circle",size:N.vertex.size,color:N.vertex.color,outline:{color:N.vertex.outlineColor,width:1}}),hover:new x({style:"circle",size:N.vertex.hoverSize,color:N.vertex.hoverColor,outline:{color:N.vertex.hoverOutlineColor,width:1}})},rotatorLine:new b({color:N.line.color,width:1})},Y=Symbol();let A=class extends i{constructor(t){super(t),this._activeHandleGraphic=null,this._graphicAttributes={esriSketchTool:"box"},this._mover=null,this._centerGraphic=null,this._backgroundGraphic=null,this._vertexGraphics=[],this._rotateHandleGraphic=null,this._rotateGraphicOffset=20,this._angleOfRotation=0,this._rotateLineGraphic=null,this._startInfo=null,this._totalDx=0,this._totalDy=0,this._xScale=1,this._yScale=1,this.tooltip=null,this.type="box",this.callbacks={onMoveStart(){},onMove(){},onMoveStop(){},onScaleStart(){},onScale(){},onScaleStop(){},onRotateStart(){},onRotate(){},onRotateStop(){},onGraphicClick(){}},this.enableMovement=!0,this.enableRotation=!0,this.enableScaling=!0,this.graphics=[],this.highlightName=null,this.highlightsEnabled=!0,this.layer=null,this.preserveAspectRatio=!1,this.showCenterGraphic=!0,this.symbols=z,this.toolOptions=new T,this.view=null,this._updatingHandles=new _,this._getBounds=(()=>{const t=g();return(e,i)=>{e[0]=Number.POSITIVE_INFINITY,e[1]=Number.POSITIVE_INFINITY,e[2]=Number.NEGATIVE_INFINITY,e[3]=Number.NEGATIVE_INFINITY;for(const o of i){if(!o)continue;let i,s,r,a;if("point"===o.type)i=r=o.x,s=a=o.y;else if("extent"===o.type)[i,s,r,a]=[o.xmin,o.ymin,o.xmax,o.ymax];else{const e=v(t,o);[i,s,r,a]=e}e[0]=Math.min(i,e[0]),e[1]=Math.min(s,e[1]),e[2]=Math.max(r,e[2]),e[3]=Math.max(a,e[3])}return e}})(),this._extentScaleTooltipInfo=new E({toolOptions:this.toolOptions}),this._measurementWorker=new L({preloadGeodetic:!0}),this._updateScaleTooltipAsync=s(async()=>{const t=this._getCoordinates(),e=this.view.spatialReference,{width:i,height:o}=await this._measurementWorker.autoSize2D(new d({x:t[0][0],y:t[0][1],spatialReference:e}),new d({x:t[1][0],y:t[1][1],spatialReference:e}),new d({x:t[2][0],y:t[2][1],spatialReference:e}),new d({x:t[3][0],y:t[3][1],spatialReference:e}));this._extentScaleTooltipInfo.xSize=i,this._extentScaleTooltipInfo.ySize=o}),this._translateTooltipInfo=new B({toolOptions:this.toolOptions}),this._updateMoveTooltipAsync=s(async t=>{const{view:e}=this,i=this._translateTooltipInfo;if(!t)return void(i.distance=r);const{x:o,y:s}=t.origin,a=e.toMap(t),h=e.toMap({x:o,y:s}),n=await this._measurementWorker.autoDistance2DBetweenPoints(h,a);i.distance=null!=n?n:r})}initialize(){const t=this.view;this._highlightHelper=new I({view:t}),this._setup(),this.addHandles([a(()=>t?.ready,()=>{const{layer:t,view:e}=this;C(e,t)},{once:!0,initial:!0}),h(()=>this.preserveAspectRatio,()=>{this._activeHandleGraphic&&(this._scaleGraphic(this._activeHandleGraphic),this._updateGraphics(),this._updateTooltip(this._activeHandleGraphic))}),h(()=>t?.scale,()=>{this._updateRotateGraphic(),this._updateRotateLineGraphic()}),h(()=>this.graphics,()=>this.refresh()),h(()=>this.layer,(t,e)=>{e&&this._resetGraphics(e),this.refresh()}),h(()=>[this.highlightsEnabled,this.highlightName],()=>{this._highlightHelper?.removeAll(),this._setUpHighlights()}),h(()=>this.toolOptions.tooltips.effectiveEnabled,e=>{this.tooltip=e?O(()=>({view:t,options:this.toolOptions.tooltips})):o(this.tooltip)},n),h(()=>this.view.effectiveTheme.accentColor,()=>this._updateSymbolsForTheme(),c),this.on("move-start",t=>this.callbacks?.onMoveStart?.(t)),this.on("move",t=>this.callbacks?.onMove?.(t)),this.on("move-stop",t=>this.callbacks?.onMoveStop?.(t)),this.on("rotate-start",t=>this.callbacks?.onRotateStart?.(t)),this.on("rotate",t=>this.callbacks?.onRotate?.(t)),this.on("rotate-stop",t=>this.callbacks?.onRotateStop?.(t)),this.on("scale-start",t=>this.callbacks?.onScaleStart?.(t)),this.on("scale",t=>this.callbacks?.onScale?.(t)),this.on("scale-stop",t=>this.callbacks?.onScaleStop?.(t))])}destroy(){this._reset(),this.tooltip=o(this.tooltip)}get state(){const t=this.view?.ready??!1,e=this.graphics.length&&this.layer;return t&&e?"active":t?"ready":"disabled"}get updating(){return this._updatingHandles.updating}isUIGraphic(t){return this._vertexGraphics.includes(t)||t===this._backgroundGraphic||t===this._centerGraphic||t===this._rotateHandleGraphic||t===this._rotateLineGraphic}move(t,e){if(this._mover&&this.graphics.length){for(const i of this.graphics){const o=i.geometry,s=w(o,t,e,this.view);i.geometry=s}this.refresh(),this.emit("move-stop",{graphics:this.graphics,mover:null,dx:t,dy:e,type:"move-stop"})}}scale(t,e){if(!this._mover||!this.graphics.length)return;const i=this._getBoxBounds(g()),o=y(i);for(const s of this.graphics){const i=s.geometry,r=S(i,t,e,o);s.geometry=r}this.refresh(),this.emit("scale-stop",{graphics:this.graphics,mover:null,xScale:t,yScale:e,type:"scale-stop"})}rotate(t,e){if(this._mover&&this.graphics.length){if(!e){const t=this._vertexGraphics[1].geometry.x,i=this._vertexGraphics[3].geometry.y;e=new d(t,i,this.view.spatialReference)}for(const i of this.graphics){const o=i.geometry,s=f(o,t,e);i.geometry=s}this.refresh(),this.emit("rotate-stop",{graphics:this.graphics,mover:null,angle:t,type:"rotate-stop"})}}refresh(){this._reset(),this._setup()}reset(){this.graphics=[]}_setup(){"active"===this.state&&(this._setUpHighlights(),this._setupGraphics(),this._setupMover(),this._updateGraphics())}_reset(){this._highlightHelper?.removeAll(),this._resetGraphicStateVars(),this._resetGraphics(),this._updateTooltip(),this._mover?.destroy(),this._mover=null,this.removeHandles(Y)}_resetGraphicStateVars(){this._startInfo=null,this._activeHandleGraphic=null,this._totalDx=0,this._totalDy=0,this._xScale=1,this._yScale=1,this._angleOfRotation=0}_resetGraphics(t){(t=t||this.layer)&&(t.removeMany(this._vertexGraphics),t.remove(this._backgroundGraphic),t.remove(this._centerGraphic),t.remove(this._rotateHandleGraphic),t.remove(this._rotateLineGraphic)),this._vertexGraphics.forEach(t=>!t.destroyed&&t.destroy()),!this._backgroundGraphic.destroyed&&this._backgroundGraphic.destroy(),!this._centerGraphic.destroyed&&this._centerGraphic.destroy(),!this._rotateHandleGraphic.destroyed&&this._rotateHandleGraphic.destroy(),!this._rotateLineGraphic.destroyed&&this._rotateLineGraphic.destroy(),this._vertexGraphics=[],this._backgroundGraphic=null,this._centerGraphic=null,this._rotateHandleGraphic=null,this._rotateLineGraphic=null}_setupMover(){let t=[];this.enableScaling&&(t=t.concat(this._vertexGraphics)),this.enableRotation&&t.push(this._rotateHandleGraphic),this.enableMovement&&(t=t.concat(this.graphics,this._backgroundGraphic)),this.showCenterGraphic&&t.push(this._centerGraphic),this._mover=new H({enableMoveAllGraphics:!1,highlightsEnabled:!1,indicatorsEnabled:!1,view:this.view,graphics:t,callbacks:{onGraphicClick:t=>this._onGraphicClickCallback(t),onGraphicMoveStart:t=>this._onGraphicMoveStartCallback(t),onGraphicMove:t=>this._onGraphicMoveCallback(t),onGraphicMoveStop:t=>this._onGraphicMoveStopCallback(t),onGraphicPointerOver:t=>this._onGraphicPointerOverCallback(t),onGraphicPointerOut:t=>this._onGraphicPointerOutCallback(t)}})}_setCursor(t){this.addHandles(this.view.acquireCursor(t,"high"),Y)}_getStartInfo(t){const[e,i,o,s]=this._getBoxBounds(g()),r=Math.abs(o-e),a=Math.abs(s-i),h=(o+e)/2,n=(s+i)/2,{x:c,y:l}=t.geometry;return{width:r,height:a,centerX:h,centerY:n,startX:c,startY:l,graphicInfos:this._getGraphicInfos(),box:this._backgroundGraphic.geometry,rotate:this._rotateHandleGraphic.geometry}}_getGraphicInfos(){return this.graphics.map(t=>this._getGraphicInfo(t))}_getGraphicInfo(t){const e=t.geometry,[i,o,s,r]=this._getBounds(g(),[e]);return{width:Math.abs(s-i),height:Math.abs(r-o),centerX:(s+i)/2,centerY:(r+o)/2,geometry:e}}_onGraphicClickCallback(t){t.viewEvent.stopPropagation(),this.emit("graphic-click",t),this.callbacks.onGraphicClick&&this.callbacks.onGraphicClick(t)}_onGraphicMoveStartCallback(t){const{_angleOfRotation:e,_xScale:i,_yScale:o,_backgroundGraphic:s,_vertexGraphics:r,_rotateHandleGraphic:a,symbols:h,graphics:n}=this,{graphic:c,dx:l,dy:p,viewEvent:_}=t;this._resetGraphicStateVars(),this._hideGraphicsBeforeUpdate(),s.symbol=h.fill.active,this._startInfo=this._getStartInfo(c),this._updateTooltip(c,_),c===a?(this._setCursor("grabbing"),this.emit("rotate-start",{type:"rotate-start",mover:c,graphics:n,angle:e})):r.includes(c)?(this._activeHandleGraphic=c,this.emit("scale-start",{type:"scale-start",mover:c,graphics:n,xScale:i,yScale:o})):this.emit("move-start",{type:"move-start",graphics:n,mover:c,dx:l,dy:p})}_onGraphicMoveCallback(t){const e=t.graphic;if(!this._startInfo)return;const{_xScale:i,_yScale:o,_angleOfRotation:s,graphics:r}=this;if(this._vertexGraphics.includes(e))this._scaleGraphic(e),this._updateTooltip(e,t.viewEvent),this.emit("scale",{type:"scale",graphics:r,mover:e,xScale:i,yScale:o});else if(e===this._rotateHandleGraphic)this._rotateGraphic(e),this._updateTooltip(e,t.viewEvent),this.emit("rotate",{type:"rotate",graphics:r,mover:e,angle:s});else{const{dx:i,dy:o}=t;this._totalDx+=i,this._totalDy+=o,this._moveGraphic(e,i,o),this._updateTooltip(e,t.viewEvent),this.emit("move",{type:"move",graphics:r,mover:e,dx:i,dy:o})}}_onGraphicMoveStopCallback(t){const e=t.graphic;if(!this._startInfo)return void this.refresh();const{_angleOfRotation:i,_totalDx:o,_totalDy:s,_xScale:r,_yScale:a,_vertexGraphics:h,_rotateHandleGraphic:n,graphics:c}=this;this.refresh(),e===n?(this._setCursor("pointer"),this.emit("rotate-stop",{type:"rotate-stop",graphics:c,mover:e,angle:i})):h.includes(e)?this.emit("scale-stop",{type:"scale-stop",mover:e,graphics:c,xScale:r,yScale:a}):this.emit("move-stop",{type:"move-stop",graphics:c,mover:e,dx:o,dy:s})}_onGraphicPointerOverCallback(t){const{_backgroundGraphic:e,_vertexGraphics:i,graphics:o,_rotateHandleGraphic:s,symbols:r,view:a}=this,h=t.graphic;if(this._hoveredGraphic=h,h===s)return s.symbol=r.rotator.hover,this._setCursor("pointer"),void this._updateTooltip(h);if(o.includes(h)||h===e)return void this._setCursor("move");if(!i.includes(h))return void this._setCursor("pointer");this._updateTooltip(h),t.graphic.symbol=r.handles.hover;const n=a.rotation;let c,l=t.index;switch(l<8&&(n>=0&&n<45?l%=8:l=n>=45&&n<90?(l+1)%8:n>=90&&n<135?(l+2)%8:n>=135&&n<180?(l+3)%8:n>=180&&n<225?(l+4)%8:n>=225&&n<270?(l+5)%8:n>=270&&n<315?(l+6)%8:(l+7)%8),l){case 0:case 4:c="nwse-resize";break;case 1:case 5:c="ns-resize";break;case 2:case 6:c="nesw-resize";break;case 3:case 7:c="ew-resize";break;default:c="pointer"}this._setCursor(c)}_onGraphicPointerOutCallback(t){const{_vertexGraphics:e,_rotateHandleGraphic:i,symbols:o}=this;this._hoveredGraphic=null,t.graphic===i?i.symbol=o.rotator.default:e.includes(t.graphic)&&(t.graphic.symbol=o.handles.default),this.removeHandles(Y),this._updateTooltip()}_scaleGraphic(t){const{_startInfo:e,_vertexGraphics:i,preserveAspectRatio:o,view:s}=this,{centerX:r,centerY:a,graphicInfos:h,height:n,startX:c,startY:l,width:p}=e,{resolution:_,transform:m}=s.state,u=i.indexOf(t);1!==u&&5!==u||this._updateX(t,r),3!==u&&7!==u||this._updateY(t,a);const{x:g,y}=t.geometry,v=m[0]*g+m[2]*y+m[4],f=m[1]*g+m[3]*y+m[5],G=h?.map(t=>t.geometry)??[],b=G.every(t=>"point"===t.type);if((0===p||0===n)&&b){const t=P((g-c)/_),i=P((l-y)/_);for(let e=0;e<G.length;e++)this.graphics[e].geometry=w(G[e],t,i,s,!0);return this._centerGraphic.geometry=new d(g,y,s.spatialReference),void(this._backgroundGraphic.geometry=w(e.box,t,i,s,!0))}if(o){const t=P(m[0]*r+m[2]*a+m[4],2),e=P(m[1]*r+m[3]*a+m[5],2),i=P(m[0]*c+m[2]*l+m[4],2),o=P(m[1]*c+m[3]*l+m[5],2);let s=R(t,e,i,o,v,f);0!==s&&Math.abs(s)!==1/0||(s=1),this._xScale=this._yScale=s;for(const h of G){const t=G.indexOf(h);this.graphics[t].geometry=S(h,this._xScale,this._yScale,[r,a])}this._updateBackgroundGraphic()}else{let t=g-c,i=l-y;if(1===u||5===u?t=0:3!==u&&7!==u||(i=0),0===t&&0===i)return;const o=r+t/2,h=a+i/2;let m=(p+(c>r?t:-1*t))/p,v=(n+(l<a?i:-1*i))/n;1!==u&&5!==u&&0!==m&&Math.abs(m)!==1/0||(m=1),3!==u&&7!==u&&0!==v&&Math.abs(v)!==1/0||(v=1),this._xScale=m,this._yScale=v;const f=(o-r)/_,b=(h-a)/_,x=S(e.box,this._xScale,this._yScale);this._backgroundGraphic.geometry=w(x,f,b,s,!0);const{centerX:k,centerY:R}=this._getGraphicInfo(this._backgroundGraphic),H=(k-r)/_,I=-1*(R-a)/_;for(const e of G){const t=G.indexOf(e),i=S(e,this._xScale,this._yScale,[r,a]);this.graphics[t].geometry=w(i,H,I,s,!0)}this._centerGraphic.geometry=new d(k,R,s.spatialReference)}}_rotateGraphic(t){const{centerX:e,centerY:i,startX:o,startY:s,box:r,rotate:a}=this._startInfo,h=this.view.spatialReference,n=new d(o,s,h),c=new d(e,i,h),l=t.geometry;this._angleOfRotation=k(n,l,c);const p=this._startInfo.graphicInfos?.map(t=>t.geometry)??[];for(const _ of p){const t=p.indexOf(_),e=f(_,this._angleOfRotation,c);this.graphics[t].geometry=e}this._backgroundGraphic.geometry=f(r,this._angleOfRotation,c),this._rotateHandleGraphic.geometry=f(a,this._angleOfRotation,c)}_moveGraphic(t,e,i){if(this.graphics.includes(t)){const o=this._backgroundGraphic.geometry;this._backgroundGraphic.geometry=w(o,e,i,this.view);for(const s of this.graphics)s!==t&&(s.geometry=w(s.geometry,e,i,this.view))}else if(t===this._centerGraphic){const t=this._backgroundGraphic.geometry;this._backgroundGraphic.geometry=w(t,e,i,this.view)}if(t===this._backgroundGraphic||t===this._centerGraphic)for(const o of this.graphics)o.geometry=w(o.geometry,e,i,this.view)}_setUpHighlights(){this.highlightsEnabled&&this.graphics.length&&this._highlightHelper?.add(this.graphics,this.highlightName)}_setupGraphics(){const{_graphicAttributes:t,symbols:i}=this;this._centerGraphic=new e({symbol:i.centerIndicator,attributes:t}),this.showCenterGraphic&&this.layer.add(this._centerGraphic),this._backgroundGraphic=new e({symbol:i.fill.default,attributes:t}),this.layer.add(this._backgroundGraphic),this._rotateLineGraphic=new e({symbol:i.rotatorLine,attributes:t}),this._rotateHandleGraphic=new e({symbol:i.rotator.default,attributes:t}),this.enableRotation&&!this._hasExtentGraphic()&&this.layer.addMany([this._rotateLineGraphic,this._rotateHandleGraphic]);for(let o=0;o<8;o++)this._vertexGraphics.push(new e({symbol:i.handles.default,attributes:t}));this.enableScaling&&this.layer.addMany(this._vertexGraphics)}_updateSymbolsForTheme(){const t=this.view.effectiveTheme.accentColor;this.symbols={...this.symbols,fill:{active:this.symbols.fill.active?.clone().set("outline.color",t),default:this.symbols.fill.default?.clone().set("outline.color",t)},handles:{...this.symbols.handles,default:this.symbols.handles.default.clone().set("outline.color",t)},rotator:{...this.symbols.rotator,default:this.symbols.rotator.default.clone().set("outline.color",t)},rotatorLine:this.symbols.rotatorLine.clone().set("color",t)};for(const e of this._vertexGraphics)e.symbol=e===this._hoveredGraphic?this.symbols.handles.hover:this.symbols.handles.default;this._backgroundGraphic.symbol=this.symbols.fill.default,this._rotateHandleGraphic.symbol=this._rotateHandleGraphic===this._hoveredGraphic?this.symbols.rotator.hover:this.symbols.rotator.default,this._rotateLineGraphic.symbol=this.symbols.rotatorLine}_updateGraphics(){this._updateBackgroundGraphic(),this._updateHandleGraphics(),this._updateCenterGraphic(),this._updateRotateGraphic(),this._updateRotateLineGraphic()}_hideGraphicsBeforeUpdate(){this._centerGraphic.visible=!1,this._rotateHandleGraphic.visible=!1,this._rotateLineGraphic.visible=!1,this._vertexGraphics.forEach(t=>t.visible=!1)}_updateHandleGraphics(){const t=this._getCoordinates(!0);this._vertexGraphics.forEach((e,i)=>{const[o,s]=t[i];this._updateXY(e,o,s)})}_updateBackgroundGraphic(){const t=this._getCoordinates().map(([t,e])=>[t,e]);this._backgroundGraphic.geometry=new m({rings:[t],spatialReference:this.view.spatialReference})}_updateCenterGraphic(){const[t,e,i,o]=this._getBoxBounds(g()),s=(i+t)/2,r=(o+e)/2;this._centerGraphic.geometry=new d(s,r,this.view.spatialReference)}_updateRotateGraphic(){if(!this._vertexGraphics.length)return;const{x:t,y:e}=this._vertexGraphics[1].geometry,i=e+this.view.state.resolution*this._rotateGraphicOffset;this._rotateHandleGraphic.geometry=new d(t,i,this.view.spatialReference)}_updateRotateLineGraphic(){if(!this._vertexGraphics.length||!this._rotateHandleGraphic?.geometry)return;const t=this._vertexGraphics[1].geometry,e=this._rotateHandleGraphic.geometry;this._rotateLineGraphic.geometry=new u({paths:[[[t.x,t.y],[e.x,e.y]]],spatialReference:this.view.spatialReference})}_updateXY(t,e,i){t.geometry=new d(e,i,this.view.spatialReference)}_updateX(t,e){const i=t.geometry.y;t.geometry=new d(e,i,this.view.spatialReference)}_updateY(t,e){const i=t.geometry.x;t.geometry=new d(i,e,this.view.spatialReference)}_hasExtentGraphic(){return this.graphics.some(t=>null!=t?.geometry&&"extent"===t.geometry.type)}_getBoxBounds(t){const e=this.graphics.map(t=>t.geometry);return this._getBounds(t,e)}_getCoordinates(t){const[e,i,o,s]=this._getBoxBounds(g());if(t){const t=(e+o)/2,r=(s+i)/2;return[[e,s],[t,s],[o,s],[o,r],[o,i],[t,i],[e,i],[e,r]]}return[[e,s],[o,s],[o,i],[e,i]]}_updateTooltip(t,e){if(null==this.tooltip)return;if(!t)return void this.tooltip.clear();const{_backgroundGraphic:i,graphics:o,_vertexGraphics:s,_rotateHandleGraphic:r}=this;t===r?this._updateRotateTooltip():s.includes(t)?this._updateScaleTooltip():(o.includes(t)||t===i)&&this._updateMoveTooltip(e)}_updateRotateTooltip(){null!=this.tooltip&&(this.tooltip.info=new j({toolOptions:this.toolOptions,angle:-this._angleOfRotation}))}_updateScaleTooltip(){const{tooltip:t,_xScale:e,_yScale:i,toolOptions:o}=this;if(null==t)return;const s=Math.abs(e),r=Math.abs(i),a=this._extentScaleTooltipInfo;a.toolOptions=o,a.xScale=s,a.yScale=r,this._updatingHandles.consumePromise(this._updateScaleTooltipAsync()),t.info=a}_updateMoveTooltip(t){const{tooltip:e}=this;if(null==e)return;const i=this._translateTooltipInfo;this._updatingHandles.consumePromise(this._updateMoveTooltipAsync(t)),e.info=i}};function P(t,e=2){return Number.parseFloat(t.toFixed(e))}t([l()],A.prototype,"tooltip",void 0),t([l({readOnly:!0})],A.prototype,"type",void 0),t([l()],A.prototype,"callbacks",void 0),t([l()],A.prototype,"enableMovement",void 0),t([l()],A.prototype,"enableRotation",void 0),t([l()],A.prototype,"enableScaling",void 0),t([l()],A.prototype,"graphics",void 0),t([l()],A.prototype,"highlightName",void 0),t([l()],A.prototype,"highlightsEnabled",void 0),t([l()],A.prototype,"layer",void 0),t([l()],A.prototype,"preserveAspectRatio",void 0),t([l()],A.prototype,"showCenterGraphic",void 0),t([l({readOnly:!0})],A.prototype,"state",null),t([l()],A.prototype,"symbols",void 0),t([l({type:T})],A.prototype,"toolOptions",void 0),t([l({constructOnly:!0})],A.prototype,"view",void 0),A=t([p("esri.views.draw.support.Box")],A);const U=A;export{U 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"../../../core/Accessor.js";import n from"../../../core/Logger.js";import{memoize as i}from"../../../core/memoize.js";import{ignoreAbortErrors as o}from"../../../core/promiseUtils.js";import{valueInUnit as s}from"../../../core/quantity.js";import{createScreenPoint as r}from"../../../core/screenUtils.js";import{property as a,subclass as p}from"../../../core/accessorSupport/decorators.js";import{fromArray as l,create as u}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{normalize as c}from"../../../core/libs/gl-matrix-2/math/vec2.js";import g from"../../../geometry/Point.js";import{pointEquals as d}from"../../../layers/graphics/dehydratedFeatureComparison.js";import{makeDehydratedPoint as f}from"../../../layers/graphics/dehydratedPoint.js";import{getZFromVertexSnappingCandidates as h}from"./drawUtils.js";import{getPolylineOrPolygonConstraint as m,getPointConstraint as S,pointToConstraintSpace as P,constraintSpaceToPoint as y}from"../../interactive/sketch/constraintUtils.js";import{SnappingContext as v}from"../../interactive/snapping/SnappingContext.js";import{SnappingOperation as M}from"../../interactive/snapping/SnappingOperation.js";let T=class extends e{constructor(t){super(t),this._snappingOperation=null,this.role="primary",this.captureMode="capture-always",this.defaultCaptureMode="capture-always",this.snappingEnabled=!0,this.selfSnappingEnabled=!0,this.editSession=null,this.outputMapPositionOfDragStart=null,this.selectedSnappingResult=null,this.screenPosition=null,this.inputMapPosition=null,this.drawToolDragging=!1,this.manipulatorDragging=!1,this._getSnappingContext=i((t,e,n,i,o,s)=>n?new v({elevationInfo:i,pointer:t,vertexHandle:e,editGeometryOperations:n,visualizer:o,suppressSelfSnapping:!s}):null)}get grabbable(){return"grabbable-object"===this.captureMode}get following(){const{captureMode:t}=this;return"capture-always"===t||"capture-when-engaged"===t}get outputMapPosition(){return this._get("outputMapPosition")}set outputMapPosition(t){const e=this._get("outputMapPosition");t&&e&&d(t,e)||this._set("outputMapPosition",t)}get dragging(){return this.drawToolDragging||this.manipulatorDragging}get firstPointZ(){const t=this.editSession?.lastPointAddedBySession;if(!t)return null;const e=this.editSession?.getInformationAboutPoint(0,t.partIndex);return e?.point.hasZ?e.point.z:null}async moveTo(t,e){const{snappingManager:n,skipSnapping:i,surfaceManager:s,pointerType:r,editGeometryOperations:a,snappingVisualizer:p}=e,l=this._getSnappingContext(r??"mouse",this.editSession?.endVertex,a,s?.elevationInfo,p,this.selfSnappingEnabled),u=this._ensureSnappingOperation(e);t&&(this.screenPosition=t);const c=this.screenPosition;if(!c)return null;const h=this.firstPointZ,m=s?.screenToMap(c,{firstPointZ:h});if(this.inputMapPosition=m,this.selectedSnappingResult=null,!n||!m||!l||i||!this.snappingEnabled)return this.selectedSnappingResult=void 0,this.outputMapPosition=this._finalizeSnappingAndConstraintResult(null,m,e);const S=f(m.x,m.y,m.z,m?.spatialReference),P=s?.screenToScene?.(c,{firstPointZ:h}),y=u.snap({point:S,scenePoint:P},n,l);return o(y.then(()=>{const t=u.stagedPoint;return d(this.selectedSnappingResult,t)||(this.selectedSnappingResult=new g({...t})),this.outputMapPosition=this._finalizeSnappingAndConstraintResult(this.selectedSnappingResult,m,e)}))}async moveDeltaRelativeToScreen(t,e,n){const{inputMapPosition:i,screenPosition:o,firstPointZ:s}=this;if(!i)return null;const a=n.surfaceManager?n.surfaceManager.mapToScreen(i,{firstPointZ:s}):o;if(!a)return null;const p=r(a.x+t,a.y+e);return this.moveTo(p,n)}async noteDragStart(t,e){if(this.drawToolDragging=!0,e.skipSnapping||!this.snappingEnabled)return null;const{snappingManager:i,surfaceManager:s,pointerType:r,editGeometryOperations:a,snappingVisualizer:p}=e,l=this._getSnappingContext(r??"mouse",this.editSession?.endVertex,a,s?.elevationInfo,p,this.selfSnappingEnabled),u=this._ensureSnappingOperation(e),c=this.firstPointZ,d=s?.screenToMap(t,{firstPointZ:c});if(this.outputMapPositionOfDragStart=null,i&&l&&d){const r=u.snap({point:f(d.x,d.y,d.z,d?.spatialReference),scenePoint:s?.screenToScene?.(t,{firstPointZ:c})},i,l);return o(r.then(()=>{const t=u.stagedPoint?new g({...u.stagedPoint}):null;return this.outputMapPositionOfDragStart=this._finalizeSnappingAndConstraintResult(t,d,e)})).catch(t=>(n.getLogger(this).error("drawtool:handle:snapping-failed",t),null))}return this.outputMapPositionOfDragStart=d,null}async noteDragEnd(t,e){return this.moveTo(t,e).finally(()=>this.drawToolDragging=!1)}async moveDeltaRelativeToSketchSegment(t,e){const n=this.editSession?.endVertex?.leftSegment?.leftVertex?.pos,{firstPointZ:i}=this,o=this.inputMapPosition?e.surfaceManager?.mapToScreen(this.inputMapPosition,{firstPointZ:i})??this.screenPosition:this.screenPosition;if(!n||!o)return null;const s=e.editGeometryOperations?.data?.coordinateHelper.vectorToPoint(n);if(!s)return null;const r=e.surfaceManager?.mapToScreen(s,{firstPointZ:i});if(!r)return null;const a=[o.x-r.x,o.y-r.y],p=c(u(),l(a)),[g,d]=[p[0]*t,p[1]*t];return this.moveDeltaRelativeToScreen(g,d,e)}refreshConstraint(t){const e=this.outputMapPosition??this.inputMapPosition;return this.outputMapPosition=this._finalizeSnappingAndConstraintResult(null,e,t)}_finalizeSnappingAndConstraintResult(t,e,n){const i=t??e;i&&(i.z=h(n.snappingManager)??i.z);const o=(i?n.surfaceManager?.constrainZToEffectiveSurface?.(i):null)??i;return this._ensureZ(this._applyTooltipConstraints(o,n),n)}_applyTooltipConstraints(t,e){let n=t;const i=e.tooltipManager?.getConstraints(this);if(!i&&!e.interactiveHandleManager?.customConstraints)return n;if(!n)return n;const o=e.interactiveHandleManager?.customConstraints,r=e.editGeometryOperations?.data?.coordinateHelper;if(!r)return n;if(o&&this.editSession&&n){const t={handle:this,editSession:this.editSession,toScreen:t=>e.surfaceManager?.mapToScreen(t,{firstPointZ:this.firstPointZ})??null};for(const e of o)n=e(n,t)||n}const a=this.editSession?.endVertex,p=a?.leftSegment?.leftVertex,l=p?.leftSegment?.leftVertex,u=p&&r.vectorToPoint(p.pos),c=l&&r.vectorToPoint(l.pos);if(!i)return n;const d=(u||c)&&"primary"===this.role?m(u,c,i):S(i);if(!n||!i||!d)return n;const{context:f}=i,h=P(n,f),v=h?d.closestTo(h):void 0;if(!v)return n;const M=y(v,n,f),T="2d"===e.surfaceManager?.view?.type||"absolute-height"!==f.elevationInfo.mode,Z=i.elevation,{hasZ:x,metersPerVerticalUnit:b}=e.surfaceManager??{};if(null!=M&&T&&null!=Z&&x&&b&&(M.z=s(Z,"meters")/b),!M)return null;return new g({x:M.x,y:M.y,z:M.z,hasM:M.hasM,hasZ:M.hasZ,m:M.m,spatialReference:M.spatialReference})}_ensureZ(t,e){return t&&e.hasZ?(null!=t.z&&t.hasZ||(t.z=e.defaultZ??0,t.hasZ=!0),t):t}_ensureSnappingOperation({view:t}){return this._snappingOperation??=new M({view:t})}};t([a()],T.prototype,"_snappingOperation",void 0),t([a()],T.prototype,"role",void 0),t([a()],T.prototype,"name",void 0),t([a()],T.prototype,"captureMode",void 0),t([a()],T.prototype,"defaultCaptureMode",void 0),t([a()],T.prototype,"grabbable",null),t([a()],T.prototype,"following",null),t([a()],T.prototype,"snappingEnabled",void 0),t([a()],T.prototype,"selfSnappingEnabled",void 0),t([a()],T.prototype,"editSession",void 0),t([a()],T.prototype,"outputMapPosition",null),t([a()],T.prototype,"outputMapPositionOfDragStart",void 0),t([a()],T.prototype,"selectedSnappingResult",void 0),t([a()],T.prototype,"screenPosition",void 0),t([a()],T.prototype,"inputMapPosition",void 0),t([a()],T.prototype,"dragging",null),t([a()],T.prototype,"drawToolDragging",void 0),t([a()],T.prototype,"manipulatorDragging",void 0),t([a({readOnly:!0})],T.prototype,"firstPointZ",null),T=t([p("esri.views.draw.support.InteractiveHandle")],T);export{T as InteractiveHandle};
2
+ import{__decorate as t}from"tslib";import e from"../../../core/Accessor.js";import n from"../../../core/Logger.js";import{memoize as i}from"../../../core/memoize.js";import{ignoreAbortErrors as o}from"../../../core/promiseUtils.js";import{valueInUnit as r}from"../../../core/quantity.js";import{createScreenPoint as s}from"../../../core/screenUtils.js";import{property as a,subclass as p}from"../../../core/accessorSupport/decorators.js";import{fromArray as l,create as u}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{normalize as c}from"../../../core/libs/gl-matrix-2/math/vec2.js";import g from"../../../geometry/Point.js";import{pointEquals as d}from"../../../layers/graphics/dehydratedFeatureComparison.js";import{makeDehydratedPoint as h}from"../../../layers/graphics/dehydratedPoint.js";import{getZFromVertexSnappingCandidates as f}from"./drawUtils.js";import{getPolylineOrPolygonConstraint as m,getPointConstraint as P,pointToConstraintSpace as y,constraintSpaceToPoint as v}from"../../interactive/sketch/constraintUtils.js";import{SnappingContext as S}from"../../interactive/snapping/SnappingContext.js";import{SnappingOperation as M}from"../../interactive/snapping/SnappingOperation.js";let T=class extends e{constructor(t){super(t),this._snappingOperation=null,this.role="primary",this.captureMode="capture-always",this.defaultCaptureMode="capture-always",this.snappingEnabled=!0,this.selfSnappingEnabled=!0,this.editSession=null,this.outputMapPositionOfDragStart=null,this.selectedSnappingResult=null,this.screenPosition=null,this.inputMapPosition=null,this.drawToolDragging=!1,this.manipulatorDragging=!1,this.activePointerId=null,this.activePointerType=null,this._getSnappingContext=i((t,e,n,i,o,r)=>n?new S({elevationInfo:i,pointer:t,vertexHandle:e,editGeometryOperations:n,visualizer:o,suppressSelfSnapping:!r}):null)}get grabbable(){return"grabbable-object"===this.captureMode}get following(){const{captureMode:t}=this;return"capture-always"===t||"capture-when-engaged"===t}get outputMapPosition(){return this._get("outputMapPosition")}set outputMapPosition(t){const e=this._get("outputMapPosition");t&&e&&d(t,e)||this._set("outputMapPosition",t)}get dragging(){return this.drawToolDragging||this.manipulatorDragging}get firstPointZ(){const t=this.editSession?.lastPointAddedBySession;if(!t)return null;const e=this.editSession?.getInformationAboutPoint(0,t.partIndex);return e?.point.hasZ?e.point.z:null}async moveTo(t,e){const{snappingManager:n,skipSnapping:i,surfaceManager:r,pointerType:s,editGeometryOperations:a,snappingVisualizer:p}=e;this.notePointerActivity(e.pointerId,s);const l=this._getSnappingContext(s??"mouse",this.editSession?.endVertex,a,r?.elevationInfo,p,this.selfSnappingEnabled),u=this._ensureSnappingOperation(e);t&&(this.screenPosition=t);const c=this.screenPosition;if(!c)return null;const f=this.firstPointZ,m=r?.screenToMap(c,{firstPointZ:f});if(this.inputMapPosition=m,this.selectedSnappingResult=null,!n||!m||!l||i||!this.snappingEnabled)return this.selectedSnappingResult=void 0,this.outputMapPosition=this._finalizeSnappingAndConstraintResult(null,m,e);const P=h(m.x,m.y,m.z,m?.spatialReference),y=r?.screenToScene?.(c,{firstPointZ:f}),v=u.snap({point:P,scenePoint:y},n,l);return o(v.then(()=>{const t=u.stagedPoint;return d(this.selectedSnappingResult,t)||(this.selectedSnappingResult=new g({...t})),this.outputMapPosition=this._finalizeSnappingAndConstraintResult(this.selectedSnappingResult,m,e)}))}async moveDeltaRelativeToScreen(t,e,n){const{inputMapPosition:i,screenPosition:o,firstPointZ:r}=this;if(!i)return null;const a=n.surfaceManager?n.surfaceManager.mapToScreen(i,{firstPointZ:r}):o;if(!a)return null;const p=s(a.x+t,a.y+e);return this.moveTo(p,n)}async noteDragStart(t,e){if(this.notePointerDown(e.pointerId,e.pointerType),this.drawToolDragging=!0,e.skipSnapping||!this.snappingEnabled)return null;const{snappingManager:i,surfaceManager:r,pointerType:s,editGeometryOperations:a,snappingVisualizer:p}=e,l=this._getSnappingContext(s??"mouse",this.editSession?.endVertex,a,r?.elevationInfo,p,this.selfSnappingEnabled),u=this._ensureSnappingOperation(e),c=this.firstPointZ,d=r?.screenToMap(t,{firstPointZ:c});if(this.outputMapPositionOfDragStart=null,i&&l&&d){const s=u.snap({point:h(d.x,d.y,d.z,d?.spatialReference),scenePoint:r?.screenToScene?.(t,{firstPointZ:c})},i,l);return o(s.then(()=>{const t=u.stagedPoint?new g({...u.stagedPoint}):null;return this.outputMapPositionOfDragStart=this._finalizeSnappingAndConstraintResult(t,d,e)})).catch(t=>(n.getLogger(this).error("drawtool:handle:snapping-failed",t),null))}return this.outputMapPositionOfDragStart=d,null}async noteDragEnd(t,e){return this.moveTo(t,e).finally(()=>{this.drawToolDragging=!1,this.notePointerUp(e.pointerId,e.pointerType)})}notePointerActivity(t=null,e=null){e&&(this.activePointerType=e),null!=t&&this.dragging&&(this.activePointerId=t)}notePointerDown(t=null,e=null){null!=t&&(this.activePointerId=t),e&&(this.activePointerType=e)}notePointerUp(t=null,e=null){null!=t&&null!=this.activePointerId&&this.activePointerId!==t||(this.activePointerId=null),e&&this.activePointerType===e&&(this.activePointerType=null)}async moveDeltaRelativeToSketchSegment(t,e){const n=this.editSession?.endVertex?.leftSegment?.leftVertex?.pos,{firstPointZ:i}=this,o=this.inputMapPosition?e.surfaceManager?.mapToScreen(this.inputMapPosition,{firstPointZ:i})??this.screenPosition:this.screenPosition;if(!n||!o)return null;const r=e.editGeometryOperations?.data?.coordinateHelper.vectorToPoint(n);if(!r)return null;const s=e.surfaceManager?.mapToScreen(r,{firstPointZ:i});if(!s)return null;const a=[o.x-s.x,o.y-s.y],p=c(u(),l(a)),[g,d]=[p[0]*t,p[1]*t];return this.moveDeltaRelativeToScreen(g,d,e)}refreshConstraint(t){const e=this.outputMapPosition??this.inputMapPosition;return this.outputMapPosition=this._finalizeSnappingAndConstraintResult(null,e,t)}_finalizeSnappingAndConstraintResult(t,e,n){const i=t??e;i&&(i.z=f(n.snappingManager)??i.z);const o=(i?n.surfaceManager?.constrainZToEffectiveSurface?.(i):null)??i;return this._ensureZ(this._applyTooltipConstraints(o,n),n)}_applyTooltipConstraints(t,e){let n=t;const i=e.tooltipManager?.getConstraints(this);if(!i&&!e.interactiveHandleManager?.customConstraints)return n;if(!n)return n;const o=e.interactiveHandleManager?.customConstraints,s=e.editGeometryOperations?.data?.coordinateHelper;if(!s)return n;if(o&&this.editSession&&n){const t={handle:this,editSession:this.editSession,toScreen:t=>e.surfaceManager?.mapToScreen(t,{firstPointZ:this.firstPointZ})??null};for(const e of o)n=e(n,t)||n}const a=this.editSession?.endVertex,p=a?.leftSegment?.leftVertex,l=p?.leftSegment?.leftVertex,u=p&&s.vectorToPoint(p.pos),c=l&&s.vectorToPoint(l.pos);if(!i)return n;const d=(u||c)&&"primary"===this.role?m(u,c,i):P(i);if(!n||!i||!d)return n;const{context:h}=i,f=y(n,h),S=f?d.closestTo(f):void 0;if(!S)return n;const M=v(S,n,h),T="2d"===e.surfaceManager?.view?.type||"absolute-height"!==h.elevationInfo.mode,Z=i.elevation,{hasZ:w,metersPerVerticalUnit:x}=e.surfaceManager??{};if(null!=M&&T&&null!=Z&&w&&x&&(M.z=r(Z,"meters")/x),!M)return null;return new g({x:M.x,y:M.y,z:M.z,hasM:M.hasM,hasZ:M.hasZ,m:M.m,spatialReference:M.spatialReference})}_ensureZ(t,e){return t&&e.hasZ?(null!=t.z&&t.hasZ||(t.z=e.defaultZ??0,t.hasZ=!0),t):t}_ensureSnappingOperation({view:t}){return this._snappingOperation??=new M({view:t})}};t([a()],T.prototype,"_snappingOperation",void 0),t([a()],T.prototype,"role",void 0),t([a()],T.prototype,"name",void 0),t([a()],T.prototype,"captureMode",void 0),t([a()],T.prototype,"defaultCaptureMode",void 0),t([a()],T.prototype,"grabbable",null),t([a()],T.prototype,"following",null),t([a()],T.prototype,"snappingEnabled",void 0),t([a()],T.prototype,"selfSnappingEnabled",void 0),t([a()],T.prototype,"editSession",void 0),t([a()],T.prototype,"outputMapPosition",null),t([a()],T.prototype,"outputMapPositionOfDragStart",void 0),t([a()],T.prototype,"selectedSnappingResult",void 0),t([a()],T.prototype,"screenPosition",void 0),t([a()],T.prototype,"inputMapPosition",void 0),t([a()],T.prototype,"dragging",null),t([a()],T.prototype,"drawToolDragging",void 0),t([a()],T.prototype,"manipulatorDragging",void 0),t([a()],T.prototype,"activePointerId",void 0),t([a()],T.prototype,"activePointerType",void 0),t([a({readOnly:!0})],T.prototype,"firstPointZ",null),T=t([p("esri.views.draw.support.InteractiveHandle")],T);export{T as InteractiveHandle};