@arcgis/core 4.24.0-next.20220607 → 4.24.0-next.20220610

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 (206) hide show
  1. package/analysis/Analysis.js +1 -1
  2. package/analysis/LineOfSightAnalysis.js +1 -1
  3. package/arcade/arcadeCompiler.js +1 -1
  4. package/arcade.d.ts +4 -0
  5. package/arcade.js +1 -1
  6. package/assets/esri/core/workers/RemoteClient.js +1 -1
  7. package/assets/esri/core/workers/chunks/{4d2181bde97983ecac8b.js → 03ddf44e6fb8bf9db3ff.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{2e2d7f5952934af43fd7.js → 04034dabc8e0a489b0f8.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{d7168ff8f26ca2537080.js → 0747c28fce0b344dc89b.js} +1 -1
  10. package/assets/esri/core/workers/chunks/1e4e5d147263e98536bc.js +1 -0
  11. package/assets/esri/core/workers/chunks/{cbe98327181d8d7ad9e5.js → 262fabdc409d55831ffa.js} +1 -1
  12. package/assets/esri/core/workers/chunks/2a52c2c6edd70432f4a5.js +1 -0
  13. package/assets/esri/core/workers/chunks/{71d445d1e6812e03a1d7.js → 3ce7adaefc9de28d9c87.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{c165845a117c21246b1e.js → 42aa8ce4eb7bd851475e.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{a9a4bb1d781b1a995fb3.js → 4824926501e11d04eb4a.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{e51420d231c286b9c062.js → 540f1ed1ea9cddc739af.js} +1 -1
  17. package/assets/esri/core/workers/chunks/6196cfdeb91ceba52af3.js +1 -0
  18. package/assets/esri/core/workers/chunks/71a4618d959a09302c51.js +1 -0
  19. package/assets/esri/core/workers/chunks/76fbc8eaabba62fd4f9c.js +1 -0
  20. package/assets/esri/core/workers/chunks/{cb906a3f03dd0805c880.js → 7cc17b716b16a6684023.js} +1 -1
  21. package/assets/esri/core/workers/chunks/871681c1353026cb6d4b.js +1 -0
  22. package/assets/esri/core/workers/chunks/{13e9e6f0b4942d79b0eb.js → 88942e9f60687ac006dc.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{4c5b80ba3dbfe6f6cafb.js → acb1e649cda99d4f69a5.js} +1 -1
  24. package/assets/esri/core/workers/chunks/b71a0a8a2f446c671161.js +1 -0
  25. package/assets/esri/core/workers/chunks/b8002aaa665712299121.js +1 -0
  26. package/assets/esri/core/workers/chunks/{e4ca3f04ca7f71b46240.js → bb3480e231934b7bb34e.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{185da42e7cc8e440c0f0.js → c157b46b0724f3f0947e.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{1aba8c73c62a64e0658c.js → c6af8b0903d8d934d542.js} +1 -1
  29. package/assets/esri/core/workers/chunks/c8402e32307a7b7eaaeb.js +1 -0
  30. package/assets/esri/core/workers/chunks/c8e08a956b16034d9819.js +1 -0
  31. package/assets/esri/core/workers/chunks/d0d2566bedc493ed0a3b.js +1 -0
  32. package/assets/esri/core/workers/chunks/{8152cd26ebeae910b753.js → d3c73da9c2abb59e762a.js} +1 -1
  33. package/assets/esri/core/workers/chunks/d828a0656e7351a74fc4.js +1 -0
  34. package/assets/esri/core/workers/chunks/{172368d4eb6e6f8d2bdb.js → d8b9551df1bd196d0126.js} +1 -1
  35. package/assets/esri/core/workers/chunks/e5c8584ae764892c324d.js +1 -0
  36. package/assets/esri/core/workers/chunks/{1d893ebc6f203ff1fc3d.js → efe605ff4ba2a95c14c5.js} +1 -1
  37. package/assets/esri/core/workers/chunks/f54d5abbb9668c45bd19.js +1 -0
  38. package/assets/esri/core/workers/chunks/{bd2f4a01cb71e25837ba.js → f7ba74fc4eb541c424fc.js} +1 -1
  39. package/assets/esri/core/workers/chunks/{1ebed6d6f561f926bd36.js → faf6e48f9f1205fb2e43.js} +1 -1
  40. package/assets/esri/geometry/support/pe-wasm.wasm +0 -0
  41. package/assets/esri/themes/base/widgets/_BasemapToggle.scss +6 -23
  42. package/assets/esri/themes/base/widgets/_Directions.scss +0 -3
  43. package/assets/esri/themes/base/widgets/_FeatureTable.scss +10 -2
  44. package/assets/esri/themes/base/widgets/_Slider.scss +8 -3
  45. package/assets/esri/themes/base/widgets/_Tooltip.scss +8 -8
  46. package/assets/esri/themes/base/widgets/_Weather.scss +5 -1
  47. package/assets/esri/themes/dark/main.css +1 -1
  48. package/assets/esri/themes/light/main.css +1 -1
  49. package/assets/esri/themes/light/view.css +1 -1
  50. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle.json +1 -1
  51. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_ar.json +1 -1
  52. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_bg.json +1 -1
  53. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_bs.json +1 -1
  54. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_ca.json +1 -1
  55. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_cs.json +1 -1
  56. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_da.json +1 -1
  57. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_de.json +1 -1
  58. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_el.json +1 -1
  59. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_en.json +1 -1
  60. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_es.json +1 -1
  61. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_et.json +1 -1
  62. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_fi.json +1 -1
  63. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_fr.json +1 -1
  64. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_he.json +1 -1
  65. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_hr.json +1 -1
  66. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_hu.json +1 -1
  67. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_id.json +1 -1
  68. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_it.json +1 -1
  69. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_ja.json +1 -1
  70. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_ko.json +1 -1
  71. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_lt.json +1 -1
  72. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_lv.json +1 -1
  73. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_nb.json +1 -1
  74. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_nl.json +1 -1
  75. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_pl.json +1 -1
  76. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_pt-BR.json +1 -1
  77. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_pt-PT.json +1 -1
  78. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_ro.json +1 -1
  79. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_ru.json +1 -1
  80. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_sk.json +1 -1
  81. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_sl.json +1 -1
  82. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_sr.json +1 -1
  83. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_sv.json +1 -1
  84. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_th.json +1 -1
  85. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_tr.json +1 -1
  86. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_uk.json +1 -1
  87. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_vi.json +1 -1
  88. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_zh-CN.json +1 -1
  89. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_zh-HK.json +1 -1
  90. package/assets/esri/widgets/BasemapToggle/t9n/BasemapToggle_zh-TW.json +1 -1
  91. package/assets/esri/widgets/UtilityNetworkTrace/t9n/UtilityNetworkTrace_en.json +1 -1
  92. package/chunks/RasterColorizer.glsl.js +22 -18
  93. package/chunks/basis_transcoder.js +1 -1
  94. package/chunks/i3s.js +1 -1
  95. package/chunks/lclayout.js +1 -1
  96. package/chunks/lerc-wasm.js +1 -1
  97. package/chunks/libtess-asm.js +1 -1
  98. package/chunks/libtess.js +1 -1
  99. package/chunks/pe-wasm.js +1 -1
  100. package/chunks/persistableUrlUtils.js +1 -1
  101. package/chunks/vxlLayer.js +1 -1
  102. package/core/quantityUtils.js +1 -1
  103. package/geometry/projection.js +1 -1
  104. package/geometry/support/geodesicUtils.js +1 -1
  105. package/geometry/support/plane.js +1 -1
  106. package/interfaces.d.ts +471 -52
  107. package/layers/LineOfSightLayer.js +1 -1
  108. package/layers/RouteLayer.js +1 -1
  109. package/layers/VectorTileLayer.js +1 -1
  110. package/layers/support/LayerContingentValuesCache.js +1 -1
  111. package/layers/support/RasterInfo.js +1 -1
  112. package/layers/support/rasterDatasets/ImageAuxRaster.js +1 -1
  113. package/layers/support/rasterDatasets/InMemoryRaster.js +1 -1
  114. package/layers/support/rasterDatasets/WCSRaster.js +1 -1
  115. package/layers/support/rasterDatasets/wcsCoverageParser.js +1 -1
  116. package/layers/support/rasterFormats/JpgPlus.js +1 -1
  117. package/layers/support/rasterFormats/RasterCodec.js +1 -1
  118. package/layers/support/rasterFormats/TiffDecoder.js +1 -1
  119. package/package.json +1 -1
  120. package/portal/support/urlUtils.js +5 -0
  121. package/renderers/support/colorRampUtils.js +1 -1
  122. package/rest/imageService/fetchRasterInfo.js +1 -1
  123. package/smartMapping/renderers/pieChart.js +1 -1
  124. package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
  125. package/support/arcadeUtils.js +1 -1
  126. package/support/elevationInfoUtils.js +1 -1
  127. package/support/persistableUrlUtils.js +1 -1
  128. package/support/revision.js +1 -1
  129. package/symbols/cim/cimAnalyzer.js +1 -1
  130. package/views/2d/engine/vectorTiles/shaders/VTLMaterial.js +1 -1
  131. package/views/2d/engine/webgl/Utils.js +1 -1
  132. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  133. package/views/2d/layers/graphics/GraphicStoreItem.js +1 -1
  134. package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
  135. package/views/3d/analysis/AnalysisViewManager3D.js +1 -1
  136. package/views/3d/analysis/Dimensioning/LengthDimensionComputation.js +1 -1
  137. package/views/3d/analysis/DirectLineMeasurement/DirectLineMeasurementVisualization.js +1 -1
  138. package/views/3d/analysis/DirectLineMeasurementAnalysisView3D.js +1 -1
  139. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  140. package/views/3d/analysis/LineOfSight/LineOfSightRayIntersector.js +1 -1
  141. package/views/3d/input/SceneInputManager.js +1 -1
  142. package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
  143. package/views/3d/interactive/editingTools/moveGraphic/GraphicMoveTool.js +1 -1
  144. package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
  145. package/views/3d/interactive/editingTools/transformGraphic/ExtentTransformTool.js +1 -1
  146. package/views/3d/interactive/editingTools/transformGraphic/GraphicTransformTool.js +1 -1
  147. package/views/3d/layers/i3s/I3SAttributeOverrides.js +1 -1
  148. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  149. package/views/3d/support/MemoryController.js +1 -1
  150. package/views/3d/terrain/RasterColorizerTechnique.js +1 -1
  151. package/views/3d/terrain/TerrainSurface.js +1 -1
  152. package/views/3d/terrain/TileCompositor.js +1 -1
  153. package/views/3d/terrain/TileRenderer.js +1 -1
  154. package/views/3d/webgl-engine/core/shaderLibrary/output/BlendOptions.js +1 -1
  155. package/views/MapView.js +1 -1
  156. package/views/SceneView.js +1 -1
  157. package/views/View.js +1 -1
  158. package/views/draw/DrawOperation.js +1 -1
  159. package/views/draw/support/GraphicMover.js +1 -1
  160. package/views/interactive/SegmentLabels.js +1 -1
  161. package/views/interactive/editGeometry/support/editPlaneUtils.js +1 -1
  162. package/views/interactive/tooltip/TranslateTooltipInfos.js +1 -1
  163. package/views/interactive/tooltip/content/TooltipContentTranslateVertex.js +1 -1
  164. package/views/interactive/tooltip/support/measurements.js +1 -1
  165. package/views/support/areaMeasurementUtils.js +1 -1
  166. package/views/support/automaticLengthMeasurementUtils.js +5 -0
  167. package/views/support/euclideanLengthMeasurementUtils.js +5 -0
  168. package/views/support/geodesicLengthMeasurementUtils.js +5 -0
  169. package/views/support/measurementUtils.js +5 -0
  170. package/widgets/BasemapToggle/BasemapToggleViewModel.js +1 -1
  171. package/widgets/BasemapToggle.js +1 -1
  172. package/widgets/BuildingExplorer/BuildingDisciplinesTree/BuildingDisciplinesTree.js +1 -1
  173. package/widgets/BuildingExplorer/BuildingLevelPicker/BuildingLevelPicker.js +1 -1
  174. package/widgets/BuildingExplorer/BuildingPhasePicker/BuildingPhasePicker.js +1 -1
  175. package/widgets/BuildingExplorer.js +1 -1
  176. package/widgets/Daylight/DaylightViewModel.js +1 -1
  177. package/widgets/Directions/DirectionsViewModel.js +1 -1
  178. package/widgets/Directions.js +1 -1
  179. package/widgets/Feature/FeatureMedia/FeatureMediaViewModel.js +1 -1
  180. package/widgets/Feature/support/featureUtils.js +1 -1
  181. package/widgets/FeatureTable/FieldColumn.js +1 -1
  182. package/widgets/Legend/support/sizeRampUtils.js +1 -1
  183. package/widgets/Print/PrintViewModel.js +1 -1
  184. package/widgets/Sketch/SketchViewModel.js +1 -1
  185. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
  186. package/widgets/UtilityNetworkTrace.js +1 -1
  187. package/widgets/Weather.js +1 -1
  188. package/widgets/Widget.js +1 -1
  189. package/widgets/support/AnalysisViewModel.js +1 -1
  190. package/widgets/support/AnchorElementViewModel.js +1 -1
  191. package/widgets/support/InteractiveAnalysisViewModel.js +1 -1
  192. package/assets/esri/core/workers/chunks/2ac6c99aacb873134f7c.js +0 -1
  193. package/assets/esri/core/workers/chunks/471beeb6924599209567.js +0 -1
  194. package/assets/esri/core/workers/chunks/5242c9badca17ba2ab25.js +0 -1
  195. package/assets/esri/core/workers/chunks/72c7d48408d1f8050026.js +0 -1
  196. package/assets/esri/core/workers/chunks/770cf0a66102100abe74.js +0 -1
  197. package/assets/esri/core/workers/chunks/96ff15d6c2bfca0c6061.js +0 -1
  198. package/assets/esri/core/workers/chunks/9c4c721d890b49697132.js +0 -1
  199. package/assets/esri/core/workers/chunks/af3766a2d27419c7766c.js +0 -1
  200. package/assets/esri/core/workers/chunks/b50bbfd75768d9a8de88.js +0 -1
  201. package/assets/esri/core/workers/chunks/b577ec80647cf2ece397.js +0 -1
  202. package/assets/esri/core/workers/chunks/c1653b6cb201ecbaabaa.js +0 -1
  203. package/assets/esri/core/workers/chunks/e99b58d07475bffce7ea.js +0 -1
  204. package/assets/esri/core/workers/chunks/f3d885aec4bca18928d4.js +0 -1
  205. package/assets/esri/core/workers/chunks/fc0da1dfeef041182ddf.js +0 -1
  206. package/views/support/lengthMeasurementUtils.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import"../../../../../core/has.js";import t from"../../../../../core/Evented.js";import{HandleOwner as i}from"../../../../../core/HandleOwner.js";import a from"../../../../../core/Handles.js";import{handlesGroup as o,destroyHandle as n}from"../../../../../core/handleUtils.js";import{destroyMaybe as r,isSome as s,isNone as l,unwrap as p,removeMaybe as h}from"../../../../../core/maybe.js";import{createLength as d}from"../../../../../core/quantityUtils.js";import{watch as u,when as c,initial as m}from"../../../../../core/reactiveUtils.js";import{getMetersPerUnitForSR as g}from"../../../../../core/unitUtils.js";import{property as _}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/accessorSupport/ensureType.js";import{subclass as f}from"../../../../../core/accessorSupport/decorators/subclass.js";import{I as v}from"../../../../../chunks/mat4f64.js";import{l as M,b as y,h as O,s as x,a as b,g as E}from"../../../../../chunks/vec3.js";import{f as G,c as S}from"../../../../../chunks/vec3f64.js";import I from"../../../../../geometry/Polyline.js";import{makeDehydratedPoint as V}from"../../../../../layers/graphics/dehydratedFeatures.js";import{getGraphicEffectiveElevationInfo as H}from"../../../../../support/elevationInfoUtils.js";import{isVolumetricSymbol as w}from"../../../../../symbols/support/utils.js";import{Manipulator3D as A}from"../../Manipulator3D.js";import{createManipulatorMaterial as L,createManipulatorOutlineMaterial as D,placeAtGraphic as P}from"../../manipulatorUtils.js";import{SegmentLabels3D as T}from"../../SegmentLabels3D.js";import{SnappingVisualizer3D as j}from"../../SnappingVisualizer3D.js";import{screenToRenderPlaneFromEvent as N,convertToMapCoordinates as U,screenToMapXYAtLocation as k,screenToMapXYForGraphicAtLocation as R}from"../dragEventPipeline3D.js";import{ManipulatorType as C}from"../ManipulatorType.js";import{canMoveZ as F}from"../manipulatorUtils.js";import{settings as z,colors as Z}from"../settings.js";import{createVisualElements as X}from"../visualElementUtils.js";import{DISC_RADIUS_SMALL as Y}from"../manipulations/config.js";import{ManipulationType as q,MoveManipulation as W}from"../manipulations/MoveManipulation.js";import{shapeOrientation as K}from"../manipulations/moveUtils.js";import{MoveXYGraphicManipulation as B}from"../manipulations/MoveXYGraphicManipulation.js";import{createEdgeOffsetIntersectionPlane as J,createEdgeOffsetOperation as Q,edgeOffsetRotationMatrix as $,screenEdgeLengthSquared as ee}from"./edgeOffsetUtils.js";import{OutlineVisualElement as te}from"../../visualElements/OutlineVisualElement.js";import{GraphicState as ie}from"../../../layers/graphics/GraphicState.js";import ae from"../../../webgl-engine/lib/GeometryUtil.js";import{MouseButton as oe}from"../../../../input/IViewEvents.js";import{addMapDelta as ne,createManipulatorDragEventPipeline as re,dragAtLocation as se,addScreenDelta as le}from"../../../../interactive/dragEventPipeline.js";import{ManipulatorStateFlags as pe,ManipulatorStateCustomFlags as he}from"../../../../interactive/interfaces.js";import{EditGeometryOperations as de}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import{AccumulationBehaviour as ue}from"../../../../interactive/editGeometry/interfaces.js";import{SnappingContext as ce}from"../../../../interactive/snapping/SnappingContext.js";import{SnappingPipeline as me}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{ReshapeEdgeOffsetTooltipInfo as ge}from"../../../../interactive/tooltip/ReshapeTooltipInfos.js";import{Tooltip as _e}from"../../../../interactive/tooltip/Tooltip.js";import{TranslateGraphicTooltipInfo as fe,TranslateZTooltipInfo as ve}from"../../../../interactive/tooltip/TranslateTooltipInfos.js";import{euclideanHorizontalDistanceBetweenPoints as Me,verticalSignedDistanceBetweenPoints as ye}from"../../../../support/lengthMeasurementUtils.js";let Oe=class extends(t.EventedMixin(i)){constructor(e){super(e),this._vertexManipulatorMaterial=L(z.colorToVec4(z.reshapeManipulators.vertex.color),z.reshapeManipulators.vertex.renderOccluded),this._vertexManipulatorOutlineMaterial=D(z.colorToVec4(z.reshapeManipulators.vertex.outlineColor),z.reshapeManipulators.vertex.renderOccluded),this._vertexManipulatorHoverOutlineMaterial=D(z.colorToVec4(z.reshapeManipulators.vertex.hoverOutlineColor),z.reshapeManipulators.vertex.renderOccluded),this._edgeManipulatorMaterial=L(z.colorToVec4(z.reshapeManipulators.edge.color),z.reshapeManipulators.edge.renderOccluded),this._edgeManipulatorOutlineMaterial=D(z.colorToVec4(z.reshapeManipulators.edge.outlineColor),z.reshapeManipulators.edge.renderOccluded),this._edgeOffsetManipulatorMaterial=L(z.colorToVec4(z.reshapeManipulators.edgeOffset.color),z.reshapeManipulators.edgeOffset.renderOccluded,!1),this._edgeOffsetManipulatorHoverMaterial=L(z.colorToVec4(z.reshapeManipulators.edgeOffset.hoverColor),z.reshapeManipulators.edgeOffset.renderOccluded,!1),this._selectedManipulatorMaterial=L(z.colorToVec4(z.reshapeManipulators.selected.color),z.reshapeManipulators.selected.renderOccluded),this._selectedManipulatorOutlineMaterial=D(z.colorToVec4(z.reshapeManipulators.selected.outlineColor),z.reshapeManipulators.selected.renderOccluded),this._selectedManipulatorHoverOutlineMaterial=D(z.colorToVec4(z.reshapeManipulators.selected.hoverOutlineColor),z.reshapeManipulators.selected.renderOccluded),this._selectedIndex=0,this._vertexManipulatorGeometry=null,this._vertexManipulatorOutlineGeometry=null,this._edgeManipulatorGeometry=null,this._edgeManipulatorOutlineGeometry=null,this._edgeOffsetManipulatorGeometryInside=null,this._edgeOffsetManipulatorGeometryOutside=null,this._manipulatorHandles=new a,this._manipulatorInfos=[],this._editGeometryOperations=null,this._graphicMoveManipulation=null,this._moveManipulation=null,this._numGrabbing=0,this._numDragging=0,this._reshapeEventState=Se.NONE,this._outlineVisualElement=null,this._segmentLabels=null,this.outputGeometry=null,this._snappingPipeline=new me,this._snappingPipelineHandle=new me,this._vertexLaserLineVisualElement=null}initialize(){const{graphic:e,view:t}=this,i=this._graphicState=new ie({graphic:e});this._tooltip=new _e({view:t}),this.own([u((()=>i.displaying),(e=>{for(const t of this._manipulatorInfos)t.manipulator.available=e})),u((()=>this._labelOptions.enabled),(()=>this._updateSegmentLabelsVisibility()),m),c((()=>!this._tooltipOptions.enabled),(()=>this._tooltip.clear()),m),this.view.trackGraphicState(i)])}destroy(){this._segmentLabels=r(this._segmentLabels),this._tooltip=r(this._tooltip),this._editGeometryOperations=r(this._editGeometryOperations),this._moveManipulation=r(this._moveManipulation),this._graphicMoveManipulation=r(this._graphicMoveManipulation),this._manipulatorHandles=r(this._manipulatorHandles),this.manipulators.removeAll(),this._manipulatorInfos=[],this._resetGrabbingDragging()}get inputGeometry(){return s(this._editGeometryOperations)?this._editGeometryOperations.data.geometry:null}set inputGeometry(e){this._recreateEditGeometryAndManipulators(e)}get updating(){return this.updatingHandles.updating}get manipulators(){return this.tool.manipulators}get view(){return this.tool.view}get graphic(){return this.tool.graphic}get enableZShape(){return this.tool.enableZShape}get enableZVertex(){return this.tool.enableZVertex}get enableMoveGraphic(){return this.tool.enableMoveGraphic}get enableMidpoints(){return this.tool.enableMidpoints}get enableEdgeOffset(){return this.tool.enableEdgeOffset}get _labelOptions(){return this.tool.labelOptions}get _tooltipOptions(){return this.tool.tooltipOptions}removeSelectedVertices(){const e=this._manipulatorInfos.filter((e=>e.manipulator.selected&&"vertex"===e.type));this._removeVertices(e)}manipulatorSelectionChanged(){this.emit("manipulators-changed")}_removeManipulators(){this._moveManipulation=r(this._moveManipulation),this._graphicMoveManipulation=r(this._graphicMoveManipulation),this._manipulatorHandles.removeAll(),this.manipulators.removeAll(),this._manipulatorInfos=[]}_resetGrabbingDragging(){this._numGrabbing=0,this._numDragging=0}_createManipulators(){if(l(this._editGeometryOperations))return;const e=H(this.graphic);for(const t of this._editGeometryOperations.data.components){for(const i of t.vertices)this._createVertexOrEdgeManipulator(i,e);for(const i of t.edges)this._createVertexOrEdgeManipulator(i,e)}this._createGraphicMoveManipulators(e)}get canRedo(){return s(this._editGeometryOperations)&&this._editGeometryOperations.canRedo}get canUndo(){return s(this._editGeometryOperations)&&this._editGeometryOperations.canUndo}redo(){if(l(this._editGeometryOperations))return null;const e=this._editGeometryOperations.redo();return s(e)&&(this.outputGeometry=this._editGeometryOperations.data.geometry,this._recreateManipulators()),e}undo(){if(l(this._editGeometryOperations))return null;this.emit("undo");const e=this._editGeometryOperations.undo();return s(e)&&(this.outputGeometry=this._editGeometryOperations.data.geometry,this._recreateManipulators()),e}_recreateManipulators(){this._removeManipulators(),this._resetGrabbingDragging(),this._tooltip.clear(),this._createManipulators()}_recreateEditGeometryAndManipulators(e=this.inputGeometry){this._removeManipulators(),this._resetGrabbingDragging(),this._tooltip.clear(),l(e)||(r(this._editGeometryOperations),this._editGeometryOperations=de.fromGeometry(e,this.view.state.viewingMode),this._createManipulators(),r(this._segmentLabels),this._segmentLabels=new T({context:{view:this.view,editGeometryOperations:this._editGeometryOperations,elevationInfo:H(this.graphic),labelOptions:this._labelOptions}}),this._updateSegmentLabelsVisibility())}_perGraphicManipulatorDragAction(e,t){if("end"===t.action)return t;let i=0;const a=[],o=this._manipulatorInfos.some((e=>"vertex"===e.type&&e.manipulator.selected)),n=e===Ie.SELECTED_OR_ALL&&o;for(const r of this._manipulatorInfos)"vertex"===r.type&&(r.manipulator.grabbing||n&&!r.manipulator.selected||a.push(r),i++);if(0===a.length)return t;this._moveVertices(a,t);if(a.length===i){if(this._updateEventState(Se.MOVING),this.destroyed)return t;this.emit("move",{type:"move",dx:t.screenDeltaX,dy:t.screenDeltaY,mover:this.graphic})}else{if(this._updateEventState(Se.RESHAPING),this.destroyed)return t;this.emit("reshape",{type:"reshape",mover:this.graphic})}return t}_isMultiVertexSelection(){let e=0;for(const t of this._manipulatorInfos)"vertex"===t.type&&t.manipulator.selected&&e++;return e>1}_perVertexManipulatorDragAction(e){if(this._updateEventState(Se.RESHAPING),this.destroyed)return;const{mapDeltaX:t,mapDeltaY:i,mapDeltaZ:a}=e;if(!t&&!i&&!a)return;const o=[];for(const n of this._manipulatorInfos)"vertex"===n.type&&(n.manipulator.selected&&!n.manipulator.grabbing||n===e.info)&&o.push(n);this._moveVertices(o,e,ue.ACCUMULATE_STEPS),this.emit("reshape",{type:"reshape",mover:this.graphic})}_updateEventState(e){if(e===this._reshapeEventState)return!1;switch(e){case Se.NONE:if(0!==this._numGrabbing||0!==this._numDragging)return!1;switch(this._reshapeEventState){case Se.MOVING:this.emit("move",{type:"move-stop",dx:0,dy:0,mover:this.graphic});break;case Se.RESHAPING:this.emit("reshape",{type:"reshape-stop",mover:this.graphic})}break;case Se.MOVING:switch(this._reshapeEventState){case Se.NONE:this.emit("move",{type:"move-start",dx:0,dy:0,mover:this.graphic});break;case Se.RESHAPING:this.emit("reshape",{type:"reshape-stop",mover:this.graphic}),this.destroyed||this.emit("move",{type:"move-start",dx:0,dy:0,mover:this.graphic})}break;case Se.RESHAPING:switch(this._reshapeEventState){case Se.NONE:this.emit("reshape",{type:"reshape-start",mover:this.graphic});break;case Se.MOVING:this.emit("move",{type:"move-stop",dx:0,dy:0,mover:this.graphic}),this.destroyed||this.emit("reshape",{type:"reshape-start",mover:this.graphic})}}if(this.destroyed)return!1;const t=this._reshapeEventState!==e;return this._reshapeEventState=e,t}_createGraphicMoveManipulators(e){const{graphic:t,handles:i,tool:a,view:o}=this,n=this._graphicState;if(this._graphicMoveManipulation=new B({tool:a,view:o,graphicState:n}),this.enableMoveGraphic){let e=null;this._graphicMoveManipulation.forEachManipulator((e=>{this._manipulatorHandles.add(e.events.on("grab-changed",(({action:e})=>{const t=this._tooltipOptions;"start"===e&&t.enabled?this._tooltip.info=new fe({tooltipOptions:t}):this._tooltip.clear()})))})),this._manipulatorHandles.add(this._graphicMoveManipulation.createDragPipeline(((t,i,a)=>{i.next((e=>this._trackNumDragging(e))).next((t=>("start"===t.action&&(e=p(this._editGeometryOperations).createUndoGroup()),t))).next((e=>this._perGraphicManipulatorDragAction(Ie.ALL,e))).next((e=>this._updateMoveTooltip(e,q.XY))).next((t=>{"end"===t.action&&(e=h(e))})),a.next(this._cancelDragOperation((()=>e=h(e))))})))}else this._graphicMoveManipulation.forEachManipulator((e=>{e.grabbable=!1,e.cursor=null}));this._graphicMoveManipulation.forEachManipulator((e=>this._manipulatorHandles.add([this._watchAndUpdateGrabState(e,!1),e.events.on("immediate-click",(e=>{this._manipulatorInfos.some((e=>e.manipulator.selected))?this._clearSelection():this.emit("immediate-click",{...e,graphic:this.graphic}),e.stopPropagation()}))]))),this._moveManipulation=new W({tool:a,view:o,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:this.enableZShape&&F(t),snapToScene:!1,radius:W.radiusForSymbol(t.symbol)}),this._moveManipulation.forEachManipulator(((e,a)=>{i.add([this._watchAndUpdateGrabState(e,!1),e.events.on("immediate-click",(i=>{this._moveManipulation.zManipulation.hasManipulator(e)||this._manipulatorInfos.some((e=>e.manipulator.selected))||this.emit("immediate-click",{...i,graphic:t}),i.stopPropagation()}))]),a===C.TRANSLATE_XY&&i.add(e.events.on("focus-changed",(({action:e})=>{const t=this._tooltipOptions;"focus"===e&&t.enabled?this._tooltip.info=new fe({tooltipOptions:t}):this._tooltip.clear()}))),a===C.TRANSLATE_Z&&i.add(e.events.on("focus-changed",(({action:e})=>{const t=this._tooltipOptions;"focus"===e&&t.enabled?this._tooltip.info=new ve({tooltipOptions:t}):this._tooltip.clear()})))})),this._moveManipulation.elevationInfo={mode:"absolute-height",offset:0};const r=p(t.geometry).spatialReference;i.add([this._moveManipulation.createDragPipeline(((i,o,n,r,s)=>{const l=n.next((e=>this._trackNumDragging(e))).next((e=>{const t=this._manipulatorInfos.filter((e=>"vertex"===e.type&&e.manipulator.selected));return e.manipulatorType===C.TRANSLATE_XY&&1===t.length?{...e,info:t[0],snapOrigin:t[0].handle.pos}:{...e,info:null}})).next(this._snappingPipelineHandle.createSnapDragEventPipelineStep({predicate:e=>!!e.info,cancel:r,snappingManager:a.snappingManager,snappingContext:new ce({editGeometryOperations:p(this._editGeometryOperations),elevationInfo:e,pointer:s,excludeFeature:t,visualizer:new j}),updatingHandles:this.updatingHandles}),this._snappingPipelineHandle.next).next(ne()).next((e=>this._perGraphicManipulatorDragAction(Ie.SELECTED_OR_ALL,e))).next((e=>this._updateMoveTooltip(e,i)));return r.next(this._cancelDragOperation()),l}),e,r,t),u((()=>n?.displaying),(()=>{this._updateMoveManipulationPosition()}),m),n.on("changed",(()=>this._updateMoveManipulationPosition())),u((()=>n?.isDraped),(e=>{const t="align-move-manipulation";e?i.add(this.view.elevationProvider.on("elevation-change",(()=>this._updateMoveManipulationPosition())),t):i.remove(t)}),m)]),this._updateMoveManipulationPosition();const l=X({view:o,graphic:t,forEachManipulator:e=>{if(!this.destroyed){s(this._graphicMoveManipulation)&&this._graphicMoveManipulation.forEachManipulator(e);for(const t of this._manipulatorInfos)e(t.manipulator,C.TRANSLATE_XY);this._moveManipulation.forEachManipulator(e)}},onManipulatorsChanged:e=>this.on("manipulators-changed",e)});s(l)&&(this._outlineVisualElement=l.visualElement instanceof te?l.visualElement:null),s(this._outlineVisualElement)&&this._manipulatorHandles.add([this._outlineVisualElement.events.on("attachment-origin-changed",(()=>{n.isDraped||this._updateMoveManipulationPosition()})),u((()=>n.isDraped),(()=>this._updateMoveManipulationPosition()))]),this._manipulatorHandles.add(l)}_createEdgeOffsetManipulator(e,t=H(this.graphic)){const i=z.reshapeManipulators.edgeOffset,a=i.size/2,n=a+i.collisionPadding;if(l(this._edgeOffsetManipulatorGeometryInside)||l(this._edgeOffsetManipulatorGeometryOutside)){const e=a/n,t=e*Math.sqrt(3)/2;this._edgeOffsetManipulatorGeometryInside=ae.createExtrudedTriangle(t,e/2,e/2,i.height,i.offset),this._edgeOffsetManipulatorGeometryOutside=ae.createExtrudedTriangle(-t,e/2,e/2,i.height,-i.offset)}const r=[{geometry:this._edgeOffsetManipulatorGeometryInside,material:this._edgeOffsetManipulatorMaterial,stateMask:pe.Unfocused},{geometry:this._edgeOffsetManipulatorGeometryInside,material:this._edgeOffsetManipulatorHoverMaterial,stateMask:pe.Focused},{geometry:this._edgeOffsetManipulatorGeometryOutside,material:this._edgeOffsetManipulatorMaterial,stateMask:pe.Unfocused},{geometry:this._edgeOffsetManipulatorGeometryOutside,material:this._edgeOffsetManipulatorHoverMaterial,stateMask:pe.Focused}],p=new A({view:this.view,renderObjects:r,elevationInfo:"on-the-ground"!==t.mode||w(this.graphic.symbol)?{mode:"absolute-height",offset:0}:t,worldOriented:!1,focusMultiplier:1,radius:n,available:!(!this.graphic.visible||!this.graphic.layer.visible),collisionType:{type:"disc",direction:G(0,0,1)},collisionPriority:1}),h=new A({view:this.view,renderObjects:[],worldSized:!0,worldOriented:!1,available:!(!this.graphic.visible||!this.graphic.layer.visible),collisionPriority:-10,cursor:this.enableMoveGraphic?"move":"default"}),d={manipulator:p,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0,edgeManipulator:h,elevationInfo:t,visibilityHandle:null};this._autoHideEdgeOffsetManipulator(d,i.minSquaredEdgeLength),this._updateEdgeOffsetManipulator(d);const u=this._getManipulatorInfoFromHandle(d.handle.leftVertex).manipulator.events.on("location-update",(()=>this._updateEdgeOffsetManipulator(d))),c=this._getManipulatorInfoFromHandle(d.handle.rightVertex).manipulator.events.on("location-update",(()=>this._updateEdgeOffsetManipulator(d)));d.locationUpdateHandle=o([u,c]),this._manipulatorHandles.add(d.locationUpdateHandle,p),this._manipulatorHandles.add([this._watchAndUpdateGrabState(p,!0),this._watchAndUpdateGrabState(h,!0)],p),this._manipulatorHandles.add(re(p,this._createEdgeOffsetPipeline(d,t)),p),this._manipulatorHandles.add(re(h,((e,i,a,o)=>{if("touch"===o){this._createEdgeOffsetPipeline(d,t)(e,i,a)}else if(this.enableMoveGraphic){const o=this.graphic,n=s(o.geometry)?o.geometry.spatialReference:null;i.next((e=>this._trackNumDragging(e))).next(se(this.view,e.elevationAlignedLocation)).next(k(this.view,e.elevationAlignedLocation,t,n,o)).next(le()).next(ne()).next((e=>this._perGraphicManipulatorDragAction(Ie.ALL,e))),a.next(this._cancelDragOperation())}})),p);const m=e=>{this._manipulatorInfos.some((e=>e.manipulator.selected))?this._clearSelection():this.emit("immediate-click",{...e,graphic:this.graphic}),e.stopPropagation()};return this._manipulatorHandles.add([p.events.on("immediate-click",m),h.events.on("immediate-click",m),p.events.on("focus-changed",(({action:e})=>{const t=this._tooltipOptions;"focus"===e&&t.enabled?this._tooltip.info=new ge({tooltipOptions:t}):this._tooltip.clear()}))],p),this._manipulatorInfos.push(d),this.manipulators.add(p),this.manipulators.add(h),this.emit("manipulators-changed"),d}_autoHideEdgeOffsetManipulator(e,t){const i=e.manipulator,a=e.edgeManipulator,n=()=>{h(e.visibilityHandle);const n=ee(this._getManipulatorInfoFromHandle(e.handle.leftVertex).manipulator.renderLocation,this._getManipulatorInfoFromHandle(e.handle.rightVertex).manipulator.renderLocation,this.view.state.camera)<t;(!i.focused&&!a.focused||n)&&(i.grabbable=!n,a.grabbable=!n,e.visibilityHandle=o([i.disableDisplay(),{remove:()=>{i.grabbable=!0,a.grabbable=this.enableMoveGraphic}}]))};this._manipulatorHandles.add([i.events.on("focus-changed",n),a.events.on("focus-changed",n),{remove:()=>{h(e.visibilityHandle),this.manipulators.remove(a)}}],i),n()}_updateEdgeOffsetManipulator(e){this._updateManipulatorPosition(e);const t=p(this._editGeometryOperations).data.coordinateHelper,i=J(this.view,e.manipulator.elevationAlignedLocation,Q(t,e.handle,p(e.manipulator.elevationInfo))),a=this._getManipulatorInfoFromHandle(e.handle.leftVertex).manipulator.renderLocation,o=this._getManipulatorInfoFromHandle(e.handle.rightVertex).manipulator.renderLocation,n=s(i)?$(i,a,o):v;e.manipulator.modelTransform=n,e.edgeManipulator.elevationAlignedLocation=e.manipulator.elevationAlignedLocation,e.edgeManipulator.modelTransform=n;const r=M(y(Ee,a,o))/2;e.edgeManipulator.collisionType={type:"line",paths:[[[-r,0,0],[r,0,0]]]}}_createEdgeOffsetPipeline(e,t){return(i,a,o)=>{this._clearSelection();const{step:n,cleanup:r}=this._initializeEdgeOffset(e,t);a.next((e=>this._trackNumDragging(e))).next(se(this.view,i.elevationAlignedLocation)).next(n).next(N(this.view)).next(U(this.view,p(this._editGeometryOperations).data.spatialReference)).next(ne()).next(this._applyComputeEdgeOffsetDistanceStep()).next(this._applyEdgeOffsetStep(e)).next(this._showEdgeOffsetTooltip()).next((e=>{"end"===e.action&&r()})),o.next((e=>(r(),e))).next((e=>(this._tooltip.clear(),e))).next(this._cancelDragOperation())}}_initializeEdgeOffset(e,t){const i=p(this._editGeometryOperations),a=Q(i.data.coordinateHelper,e.handle,t),r=i.createUndoGroup(),s=J(this.view,e.manipulator.elevationAlignedLocation,a);a.requiresSplitEdgeLeft&&this._splitEdgeManipulator(this._getManipulatorInfoFromHandle(e.handle.leftVertex.leftEdge),1),a.requiresSplitEdgeRight&&this._splitEdgeManipulator(this._getManipulatorInfoFromHandle(e.handle.rightVertex.rightEdge),0);const d=()=>new I({paths:[[e.handle.leftVertex.pos,e.handle.rightVertex.pos]],spatialReference:p(this._editGeometryOperations).data.spatialReference}),c=new te({view:this.view,isDraped:this._graphicState.isDraped,geometry:d(),elevationInfo:e.elevationInfo,width:z.visualElements.lineGraphics.outline.width,color:z.colorToVec4(Z.main),attached:!0});let m;const g=()=>{this._cleanEdgeOffsetCollapsedEdges(e),m=h(m)},_=this.on("undo",g);return m=o([n(c),u((()=>this._graphicState.isDraped),(e=>c.isDraped=e)),this._graphicState.on("changed",(()=>c.geometry=d())),r,_]),{step:e=>l(a)||l(s)?(g(),null):{...e,operation:a,plane:s},cleanup:g}}_applyEdgeOffsetStep(e){return t=>{if(this.destroyed||l(t.operation))return t;this._updateEventState(Se.RESHAPING);const{mapDeltaX:i,mapDeltaY:a,mapDeltaZ:o}=t;return(i||a||o)&&(this._offsetEdge(e,t),this.emit("reshape",{type:"reshape",mover:this.graphic})),t}}_applyComputeEdgeOffsetDistanceStep(){return e=>{const{operation:t,mapEnd:i}=e;if(l(t)||l(i))return e;const a=t.signedDistanceToPoint(i);return{...e,signedDistance:a}}}_showEdgeOffsetTooltip(){return e=>{const{mapEnd:t,signedDistance:i}=e,a=this._tooltip,o=this._tooltipOptions;if(!o.enabled||l(i))return a.clear(),e;const n=g(t.spatialReference),r=d(-i*n,"meters");return l(a.info)||"reshape-edge-offset"!==a.info.type?a.info=new ge({tooltipOptions:o,distance:r}):a.info.distance=r,e}}_cleanEdgeOffsetCollapsedEdges(e){const t=e.handle.leftVertex.leftEdge?.leftVertex,i=e.handle.leftVertex,a=e.handle.rightVertex.rightEdge?.rightVertex,o=e.handle.rightVertex,n=p(this._editGeometryOperations).data.coordinateHelper,r=1e-6,s=[];t&&n.distance(t.pos,i.pos)<r&&s.push(this._getManipulatorInfoFromHandle(i)),(n.distance(i.pos,o.pos)<r||a&&n.distance(a.pos,o.pos)<r)&&s.push(this._getManipulatorInfoFromHandle(o)),s.length&&this._removeVertices(s)}_computeVertexManipulatorSizeAndOutline(e){const t=e.size/2,i=t+e.collisionPadding;return{size:t/i,outlineSize:(t+e.outlineSize)/i}}_createVertexOrEdgeManipulator(e,t=H(this.graphic)){if("edge"===e.type){if(this.enableEdgeOffset)return this._createEdgeOffsetManipulator(e,t);if(!this.enableMidpoints)return null}if(l(this._vertexManipulatorGeometry)||l(this._vertexManipulatorOutlineGeometry)){const{size:e,outlineSize:t}=this._computeVertexManipulatorSizeAndOutline(z.reshapeManipulators.vertex);this._vertexManipulatorGeometry=ae.createSphereGeometry(e,16,16),this._vertexManipulatorOutlineGeometry=ae.createSphereGeometry(t,16,16)}if(l(this._edgeManipulatorGeometry)||l(this._edgeManipulatorOutlineGeometry)){const{size:e,outlineSize:t}=this._computeVertexManipulatorSizeAndOutline(z.reshapeManipulators.edge);this._edgeManipulatorGeometry=ae.createSphereGeometry(e,16,16),this._edgeManipulatorOutlineGeometry=ae.createSphereGeometry(t,16,16)}const i=s(this.graphic.geometry)&&"point"===this.graphic.geometry.type?[]:[{geometry:this._vertexManipulatorGeometry,material:this._vertexManipulatorMaterial,stateMask:Ge.Vertex|pe.Unselected},{geometry:this._vertexManipulatorOutlineGeometry,material:this._vertexManipulatorOutlineMaterial,stateMask:Ge.Vertex|pe.Unfocused|pe.Unselected},{geometry:this._vertexManipulatorOutlineGeometry,material:this._vertexManipulatorHoverOutlineMaterial,stateMask:Ge.Vertex|pe.Focused|pe.Unselected},{geometry:this._vertexManipulatorGeometry,material:this._selectedManipulatorMaterial,stateMask:pe.Selected},{geometry:this._vertexManipulatorOutlineGeometry,material:this._selectedManipulatorOutlineMaterial,stateMask:pe.Selected|pe.Unfocused},{geometry:this._vertexManipulatorOutlineGeometry,material:this._selectedManipulatorHoverOutlineMaterial,stateMask:pe.Selected|pe.Focused}];this.enableMidpoints&&i.push({geometry:this._edgeManipulatorGeometry,material:this._vertexManipulatorMaterial,stateMask:Ge.Edge|pe.Focused|pe.Unselected},{geometry:this._edgeManipulatorOutlineGeometry,material:this._vertexManipulatorHoverOutlineMaterial,stateMask:Ge.Edge|pe.Focused|pe.Unselected},{geometry:this._edgeManipulatorGeometry,material:this._edgeManipulatorMaterial,stateMask:Ge.Edge|pe.Unfocused|pe.Unselected},{geometry:this._edgeManipulatorOutlineGeometry,material:this._edgeManipulatorOutlineMaterial,stateMask:Ge.Edge|pe.Unfocused|pe.Unselected});const a=new A({view:this.view,renderObjects:i,elevationInfo:t,focusMultiplier:1,touchMultiplier:1,available:!(!this.graphic.visible||!this.graphic.layer.visible)});this._setTypeSpecificManipulatorSettings(a,e,t);const n="edge"===e.type?{manipulator:a,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0}:{manipulator:a,handle:e,type:"vertex",selectedIndex:0};if(this._manipulatorInfos.push(n),this.manipulators.add(a),this._updateManipulatorPosition(n),"edge"===n.type){const e=this._getManipulatorInfoFromHandle(n.handle.leftVertex).manipulator.events.on("location-update",(()=>this._updateManipulatorPosition(n))),t=this._getManipulatorInfoFromHandle(n.handle.rightVertex).manipulator.events.on("location-update",(()=>this._updateManipulatorPosition(n)));n.locationUpdateHandle=o([e,t]),this._manipulatorHandles.add(n.locationUpdateHandle,a)}this._manipulatorHandles.add(this._watchAndUpdateGrabState(a,!0),a);const r=re(a,((e,i,a,o)=>{let r=null;i.next((e=>this._trackNumDragging(e))).next((e=>{if("start"===e.action&&(r=p(this._editGeometryOperations).createUndoGroup()),"edge"===n.type){const t=this._splitEdgeManipulator(n);return{...e,info:t,snapOrigin:t.handle.pos}}return{...e,info:n,snapOrigin:n.handle.pos}})).next(se(this.view,e.elevationAlignedLocation)).next(R(this.view,this.graphic,e.elevationAlignedLocation,e.location.spatialReference,this.graphic)).next(this._snappingPipeline.createSnapDragEventPipelineStep({predicate:()=>!this._isMultiVertexSelection(),cancel:a,snappingManager:this.tool.snappingManager,snappingContext:new ce({editGeometryOperations:p(this._editGeometryOperations),elevationInfo:t,pointer:o,excludeFeature:this.graphic,visualizer:new j}),updatingHandles:this.updatingHandles}),this._snappingPipeline.next).next(ne()).next((e=>{this._perVertexManipulatorDragAction(e),"end"===e.action&&(r=h(r))})),a.next(this._cancelDragOperation((()=>r=h(r))))}));return this._manipulatorHandles.add([r,a.events.on("immediate-click",(e=>this._manipulatorClickCallback(e,n))),a.events.on("select-changed",(()=>{n.selectedIndex=++this._selectedIndex,this._updateMoveManipulationPosition()})),a.events.on("focus-changed",(()=>this._updateSegmentLabelsVisibility()))],a),this.emit("manipulators-changed"),n}_trackNumDragging(e){switch(e.action){case"start":this._numDragging++;break;case"end":this._numDragging--}return e}_updateSegmentLabelsVisibility(){l(this._segmentLabels)||(this._segmentLabels.visible=this._labelOptions.enabled&&!this._manipulatorInfos.some((e=>"edge"===e.type&&e.manipulator.focused)))}_cancelDragOperation(e){return()=>{switch(this._numDragging--,this.undo(),this.outputGeometry=s(this._editGeometryOperations)?this._editGeometryOperations.data.geometry:null,s(this.tool.snappingManager)&&this.tool.snappingManager.doneSnapping(),this._reshapeEventState){case Se.NONE:break;case Se.MOVING:this.emit("move",{type:"move",dx:0,dy:0,mover:this.graphic});break;case Se.RESHAPING:this.emit("reshape",{type:"reshape",mover:this.graphic})}e&&e(),this.destroyed||this._updateEventState(Se.NONE)}}_setTypeSpecificManipulatorSettings(e,t,i){switch(t.type){case"vertex":e.state=Ge.Vertex,e.selectable=!0,e.cursor="move",e.collisionPriority=2,e.radius=z.reshapeManipulators.vertex.size/2+z.reshapeManipulators.vertex.collisionPadding,e.elevationInfo=i,e.interactive=s(this.graphic.geometry)&&"point"!==this.graphic.geometry.type;break;case"edge":e.state=Ge.Edge,e.selectable=!1,e.cursor="copy",e.collisionPriority=-1,e.radius=z.reshapeManipulators.edge.size/2+z.reshapeManipulators.edge.collisionPadding,e.elevationInfo="on-the-ground"!==i.mode||w(this.graphic.symbol)?{mode:"absolute-height",offset:0}:i}}_watchAndUpdateGrabState(e,t){return e.events.on("grab-changed",(i=>{if("start"===i.action)t&&this._updateSelection(e),this._numGrabbing++;else if(this._numGrabbing--,this._updateEventState(Se.NONE),this.destroyed)return;this._moveManipulation.interactive=!this._numGrabbing,("touch"!==i.pointerType||this.enableEdgeOffset)&&(this._manipulatorInfos.forEach((e=>{e.manipulator.interactive=!this._numGrabbing&&s(this.graphic.geometry)&&"point"!==this.graphic.geometry.type,"edgeManipulator"in e&&(e.edgeManipulator.interactive=!this._numGrabbing)})),p(this._graphicMoveManipulation).forEachManipulator((e=>e.interactive=!this._numGrabbing)))}))}_clearSelection(){for(const e of this._manipulatorInfos)e.manipulator.grabbing||(e.manipulator.selected=!1)}_updateSelection(e){e.grabbing&&!e.selected&&e.selectable&&(this._clearSelection(),e.selected=!0,this.emit("manipulators-changed"))}_removeManipulator(e){e&&(this._manipulatorHandles.remove(e.manipulator),this._manipulatorInfos.splice(this._manipulatorInfos.indexOf(e),1),this.manipulators.remove(e.manipulator),this.emit("manipulators-changed"))}_getManipulatorInfoFromHandle(e){if(e)for(const t of this._manipulatorInfos)if(e===t.handle)return t;return null}_updateManipulatorPosition(e){if(!e)return;const t=p(this._editGeometryOperations);if("vertex"===e.type)e.manipulator.location=t.data.coordinateHelper.vectorToDehydratedPoint(e.handle.pos,be),e.manipulator.grabbing&&s(this._vertexLaserLineVisualElement)&&(this._vertexLaserLineVisualElement.visualElement.intersectsWorldUpAtLocation=e.manipulator.renderLocation);else if("edge"===e.type){const i=this._getManipulatorInfoFromHandle(e.handle.leftVertex).manipulator,a=this._getManipulatorInfoFromHandle(e.handle.rightVertex).manipulator;if(s(e.manipulator.elevationInfo)&&"on-the-ground"===e.manipulator.elevationInfo.mode){const o=i.location,n=a.location,r=.5,s=o.x+r*(n.x-o.x),l=o.y+r*(n.y-o.y),p=o.hasZ&&n.hasZ?0:void 0;e.manipulator.location=V(s,l,p,t.data.spatialReference)}else O(Ee,i.renderLocation,a.renderLocation,.5),e.manipulator.renderLocation=Ee}}_splitEdgeManipulator(e,t=.5){const i=p(this._editGeometryOperations),a=p(i.splitEdge(e.handle,t).createdVertex);e.locationUpdateHandle.remove(),e.locationUpdateHandle=void 0;const o=H(this.graphic);let n;this.enableEdgeOffset?(this._removeManipulator(e),n=this._createVertexOrEdgeManipulator(a)):(n=e,n.handle=a,n.type="vertex",this._setTypeSpecificManipulatorSettings(e.manipulator,e.handle,o)),this._updateSegmentLabelsVisibility(),a.leftEdge&&this._createVertexOrEdgeManipulator(a.leftEdge),a.rightEdge&&this._createVertexOrEdgeManipulator(a.rightEdge),this.outputGeometry=i.data.geometry,this._updateManipulatorPosition(n),this._updateSelection(e.manipulator);const r=this._updateEventState(Se.RESHAPING),s=i.data.coordinateHelper.vectorToArray(n.handle.pos),l=i.data.components.indexOf(a.component);return this.emit("vertex-add",{type:"vertex-add",vertices:[{coordinates:s,componentIndex:l,vertexIndex:p(a.index)}],added:s}),r&&this._updateEventState(Se.NONE),n}_updateMoveManipulationPosition(){const e=x(Ee,0,0,0);let t=0,i=!1,a=null,o=null;for(const n of this._manipulatorInfos)"vertex"===n.type&&(n.manipulator.selected?(t++,b(e,e,n.manipulator.renderLocation),l(a)||n.selectedIndex>a.selectedIndex?(o=a,a=n):(l(o)||n.selectedIndex>o.selectedIndex)&&(o=n)):i=!0);if(0!==t){const e=this._graphicState.displaying;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.zManipulation.available=e&&this.enableZVertex&&F(this.graphic),this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e&&1!==t}else{const e=this._graphicState.displaying&&this.enableMoveGraphic;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e,this._moveManipulation.zManipulation.available=e&&this.enableZShape&&F(this.graphic)}if(0!==t){let e=0;if(s(a)){const t=a.handle.pos,i=s(o)?o.handle.pos:a.handle.leftEdge&&a.handle.leftEdge.leftVertex?a.handle.leftEdge.leftVertex.pos:null,n=l(o)&&a.handle.rightEdge&&a.handle.rightEdge.rightVertex?a.handle.rightEdge.rightVertex.pos:null;i&&n?this._moveManipulation.xyAxisManipulation.available=!1:i?e=xe(i,t):n&&(e=xe(t,n))}this._moveManipulation.angle=e,this._moveManipulation.radius=Y}else this._moveManipulation.angleDeferred=()=>K(p(this.graphic.geometry)),this._moveManipulation.radius=W.radiusForSymbol(this.graphic.symbol);0!==t&&i?(E(e,e,1/t),be.spatialReference=p(this._editGeometryOperations).data.spatialReference,be.hasZ=!0,this.view.renderCoordsHelper.fromRenderCoords(e,be),this._moveManipulation.elevationAlignedLocation=be):s(this._outlineVisualElement)&&!this._graphicState.isDraped&&s(this._outlineVisualElement.attachmentOrigin)?this._moveManipulation.elevationAlignedLocation=this._outlineVisualElement.attachmentOrigin:P(this.view,this._moveManipulation,this.graphic)}_removeVertices(e){const t=[],i=p(this._editGeometryOperations);for(const a of e)if("vertex"===a.type&&i.canRemoveVertex()){t.push(a.handle),this._removeManipulator(a),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.leftEdge)),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.rightEdge));const e=p(i.removeVertices([a.handle]).removedVertices[0].createdEdge);e&&this._createVertexOrEdgeManipulator(e)}if(t.length>0){const e=t.map((e=>{const t=i.data.components.indexOf(e.component);return{coordinates:i.data.coordinateHelper.vectorToArray(e.pos),componentIndex:t,vertexIndex:p(e.index)}}));this.outputGeometry=i.data.geometry;const a=this._updateEventState(Se.RESHAPING);if(this.destroyed)return;if(this.emit("vertex-remove",{type:"vertex-remove",removed:e.map((e=>e.coordinates)),vertices:e}),this.destroyed)return;if(a&&(this._updateEventState(Se.NONE),this.destroyed))return;this._updateMoveManipulationPosition()}}_moveVertices(e,t,i=("start"===t.action?ue.NEW_STEP:ue.ACCUMULATE_STEPS)){const a=p(this._editGeometryOperations);a.moveVertices(e.map((e=>e.handle)),t.mapDeltaX,t.mapDeltaY,t.mapDeltaZ,i),this.outputGeometry=a.data.geometry;for(const o of e)this._updateManipulatorPosition(o)}_offsetEdge(e,t){if(l(t.operation)||l(t.signedDistance))return;const i=p(this._editGeometryOperations),a=t.operation.clone();a.distance=t.signedDistance,i.updateVertices([e.handle.leftVertex,e.handle.rightVertex],a),this.outputGeometry=i.data.geometry,this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(e.handle.leftVertex)),this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(e.handle.rightVertex))}_manipulatorClickCallback(e,t){e.shiftKey||this._clearSelection(),"vertex"===t.type&&(t.manipulator.selected=!t.manipulator.selected,e.button===oe.Right&&this._removeVertices([t])),"edge"===t.type&&e.button===oe.Left&&this._splitEdgeManipulator(t),e.stopPropagation()}_updateMoveTooltip(e,t){const i=this._tooltipOptions;if(!i.enabled)return e;if(t===q.XY||t===q.XY_AXIS){const t=Me(e.mapStart,e.mapEnd);s(t)&&(this._tooltip.info=new fe({tooltipOptions:i,distance:t}))}if(t===q.Z){const t=ye(e.mapStart,e.mapEnd);s(t)&&(this._tooltip.info=new ve({tooltipOptions:i,distance:t}))}return e}get test(){return{segmentLabels:this._segmentLabels,tooltip:this._tooltip}}};function xe(e,t){return Math.atan2(t[1]-e[1],t[0]-e[0])+Math.PI/2}e([_({constructOnly:!0})],Oe.prototype,"tool",void 0),e([_()],Oe.prototype,"_tooltip",void 0),e([_()],Oe.prototype,"inputGeometry",null),e([_()],Oe.prototype,"outputGeometry",void 0),e([_({readOnly:!0})],Oe.prototype,"updating",null),e([_()],Oe.prototype,"_labelOptions",null),e([_()],Oe.prototype,"_tooltipOptions",null),Oe=e([f("esri.views.3d.interactive.editingTools.reshapeGraphic.ReshapeOperation")],Oe);const be=V(0,0,null,null),Ee=S();var Ge,Se,Ie;!function(e){e.Vertex=he.Custom1,e.Edge=he.Custom2}(Ge||(Ge={})),function(e){e[e.NONE=0]="NONE",e[e.MOVING=1]="MOVING",e[e.RESHAPING=2]="RESHAPING"}(Se||(Se={})),function(e){e[e.ALL=0]="ALL",e[e.SELECTED_OR_ALL=1]="SELECTED_OR_ALL"}(Ie||(Ie={}));export{Oe as ReshapeOperation};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import"../../../../../core/has.js";import t from"../../../../../core/Evented.js";import{HandleOwner as i}from"../../../../../core/HandleOwner.js";import a from"../../../../../core/Handles.js";import{handlesGroup as o,destroyHandle as n}from"../../../../../core/handleUtils.js";import{destroyMaybe as r,isSome as s,isNone as l,unwrap as p,removeMaybe as h}from"../../../../../core/maybe.js";import{createLength as d,zeroMeters as u}from"../../../../../core/quantityUtils.js";import{watch as c,when as m,initial as g}from"../../../../../core/reactiveUtils.js";import{getMetersPerUnitForSR as _}from"../../../../../core/unitUtils.js";import{property as f}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/accessorSupport/ensureType.js";import{subclass as v}from"../../../../../core/accessorSupport/decorators/subclass.js";import{I as M}from"../../../../../chunks/mat4f64.js";import{l as y,b as O,h as x,s as b,a as E,g as G}from"../../../../../chunks/vec3.js";import{f as S,c as V}from"../../../../../chunks/vec3f64.js";import I from"../../../../../geometry/Polyline.js";import{makeDehydratedPoint as H}from"../../../../../layers/graphics/dehydratedFeatures.js";import{getGraphicEffectiveElevationInfo as w}from"../../../../../support/elevationInfoUtils.js";import{isVolumetricSymbol as A}from"../../../../../symbols/support/utils.js";import{Manipulator3D as T}from"../../Manipulator3D.js";import{createManipulatorMaterial as D,createManipulatorOutlineMaterial as L,placeAtGraphic as P}from"../../manipulatorUtils.js";import{SegmentLabels3D as j}from"../../SegmentLabels3D.js";import{SnappingVisualizer3D as U}from"../../SnappingVisualizer3D.js";import{screenToRenderPlaneFromEvent as N,convertToMapCoordinates as k,screenToMapXYAtLocation as R,screenToMapXYForGraphicAtLocation as C}from"../dragEventPipeline3D.js";import{ManipulatorType as F}from"../ManipulatorType.js";import{canMoveZ as z}from"../manipulatorUtils.js";import{settings as Z,colors as X}from"../settings.js";import{createVisualElements as Y}from"../visualElementUtils.js";import{DISC_RADIUS_SMALL as q}from"../manipulations/config.js";import{ManipulationType as W,MoveManipulation as K}from"../manipulations/MoveManipulation.js";import{shapeOrientation as B}from"../manipulations/moveUtils.js";import{MoveXYGraphicManipulation as J}from"../manipulations/MoveXYGraphicManipulation.js";import{createEdgeOffsetIntersectionPlane as Q,createEdgeOffsetOperation as $,edgeOffsetRotationMatrix as ee,screenEdgeLengthSquared as te}from"./edgeOffsetUtils.js";import{OutlineVisualElement as ie}from"../../visualElements/OutlineVisualElement.js";import{GraphicState as ae}from"../../../layers/graphics/GraphicState.js";import oe from"../../../webgl-engine/lib/GeometryUtil.js";import{MouseButton as ne}from"../../../../input/IViewEvents.js";import{addMapDelta as re,createManipulatorDragEventPipeline as se,dragAtLocation as le,addScreenDelta as pe}from"../../../../interactive/dragEventPipeline.js";import{ManipulatorStateFlags as he,ManipulatorStateCustomFlags as de}from"../../../../interactive/interfaces.js";import{EditGeometryOperations as ue}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import{AccumulationBehaviour as ce}from"../../../../interactive/editGeometry/interfaces.js";import{SnappingContext as me}from"../../../../interactive/snapping/SnappingContext.js";import{SnappingPipeline as ge}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{ReshapeEdgeOffsetTooltipInfo as _e}from"../../../../interactive/tooltip/ReshapeTooltipInfos.js";import{Tooltip as fe}from"../../../../interactive/tooltip/Tooltip.js";import{TranslateZTooltipInfo as ve,TranslateGraphicTooltipInfo as Me,TranslateVertexTooltipInfo as ye}from"../../../../interactive/tooltip/TranslateTooltipInfos.js";import{euclideanPlanarArea as Oe}from"../../../../support/areaMeasurementUtils.js";import{verticalSignedDistanceBetweenPoints as xe,euclideanHorizontalDistanceBetweenPoints as be,elevationOfPoint as Ee,euclideanLength as Ge}from"../../../../support/euclideanLengthMeasurementUtils.js";let Se=class extends(t.EventedMixin(i)){constructor(e){super(e),this._vertexManipulatorMaterial=D(Z.colorToVec4(Z.reshapeManipulators.vertex.color),Z.reshapeManipulators.vertex.renderOccluded),this._vertexManipulatorOutlineMaterial=L(Z.colorToVec4(Z.reshapeManipulators.vertex.outlineColor),Z.reshapeManipulators.vertex.renderOccluded),this._vertexManipulatorHoverOutlineMaterial=L(Z.colorToVec4(Z.reshapeManipulators.vertex.hoverOutlineColor),Z.reshapeManipulators.vertex.renderOccluded),this._edgeManipulatorMaterial=D(Z.colorToVec4(Z.reshapeManipulators.edge.color),Z.reshapeManipulators.edge.renderOccluded),this._edgeManipulatorOutlineMaterial=L(Z.colorToVec4(Z.reshapeManipulators.edge.outlineColor),Z.reshapeManipulators.edge.renderOccluded),this._edgeOffsetManipulatorMaterial=D(Z.colorToVec4(Z.reshapeManipulators.edgeOffset.color),Z.reshapeManipulators.edgeOffset.renderOccluded,!1),this._edgeOffsetManipulatorHoverMaterial=D(Z.colorToVec4(Z.reshapeManipulators.edgeOffset.hoverColor),Z.reshapeManipulators.edgeOffset.renderOccluded,!1),this._selectedManipulatorMaterial=D(Z.colorToVec4(Z.reshapeManipulators.selected.color),Z.reshapeManipulators.selected.renderOccluded),this._selectedManipulatorOutlineMaterial=L(Z.colorToVec4(Z.reshapeManipulators.selected.outlineColor),Z.reshapeManipulators.selected.renderOccluded),this._selectedManipulatorHoverOutlineMaterial=L(Z.colorToVec4(Z.reshapeManipulators.selected.hoverOutlineColor),Z.reshapeManipulators.selected.renderOccluded),this._selectedIndex=0,this._vertexManipulatorGeometry=null,this._vertexManipulatorOutlineGeometry=null,this._edgeManipulatorGeometry=null,this._edgeManipulatorOutlineGeometry=null,this._edgeOffsetManipulatorGeometryInside=null,this._edgeOffsetManipulatorGeometryOutside=null,this._manipulatorHandles=new a,this._manipulatorInfos=[],this._editGeometryOperations=null,this._graphicMoveManipulation=null,this._moveManipulation=null,this._numGrabbing=0,this._numDragging=0,this._reshapeEventState=Ae.NONE,this._outlineVisualElement=null,this._segmentLabels=null,this.outputGeometry=null,this._snappingPipeline=new ge,this._snappingPipelineHandle=new ge,this._vertexLaserLineVisualElement=null}initialize(){const{graphic:e,view:t}=this,i=this._graphicState=new ae({graphic:e});this._tooltip=new fe({view:t}),this.own([c((()=>i.displaying),(e=>{for(const t of this._manipulatorInfos)t.manipulator.available=e})),c((()=>({labels:this._segmentLabels,enabled:this._labelOptions.enabled,edgeOffsetEnabled:this.enableEdgeOffset})),(({labels:e,enabled:t,edgeOffsetEnabled:i})=>{s(e)&&(e.visible=t,e.edgeDistance=i?"far":"default")}),g),m((()=>!this._tooltipOptions.enabled),(()=>this._tooltip.clear()),g),this.view.trackGraphicState(i)])}destroy(){this._segmentLabels=r(this._segmentLabels),this._tooltip=r(this._tooltip),this._editGeometryOperations=r(this._editGeometryOperations),this._moveManipulation=r(this._moveManipulation),this._graphicMoveManipulation=r(this._graphicMoveManipulation),this._manipulatorHandles=r(this._manipulatorHandles),this.manipulators.removeAll(),this._manipulatorInfos=[],this._resetGrabbingDragging()}get inputGeometry(){return s(this._editGeometryOperations)?this._editGeometryOperations.data.geometry:null}set inputGeometry(e){this._recreateEditGeometryAndManipulators(e)}get updating(){return this.updatingHandles.updating}get manipulators(){return this.tool.manipulators}get view(){return this.tool.view}get graphic(){return this.tool.graphic}get enableZShape(){return this.tool.enableZShape}get enableZVertex(){return this.tool.enableZVertex}get enableMoveGraphic(){return this.tool.enableMoveGraphic}get enableMidpoints(){return this.tool.enableMidpoints}get enableEdgeOffset(){return this.tool.enableEdgeOffset}get _labelOptions(){return this.tool.labelOptions}get _tooltipOptions(){return this.tool.tooltipOptions}removeSelectedVertices(){const e=this._manipulatorInfos.filter((e=>e.manipulator.selected&&"vertex"===e.type));this._removeVertices(e)}manipulatorSelectionChanged(){this.emit("manipulators-changed")}_removeManipulators(){this._moveManipulation=r(this._moveManipulation),this._graphicMoveManipulation=r(this._graphicMoveManipulation),this._manipulatorHandles.removeAll(),this.manipulators.removeAll(),this._manipulatorInfos=[]}_resetGrabbingDragging(){this._numGrabbing=0,this._numDragging=0}_createManipulators(){if(l(this._editGeometryOperations))return;const e=w(this.graphic);for(const t of this._editGeometryOperations.data.components){for(const i of t.vertices)this._createVertexOrEdgeManipulator(i,e);for(const i of t.edges)this._createVertexOrEdgeManipulator(i,e)}this._createGraphicMoveManipulators(e)}get canRedo(){return s(this._editGeometryOperations)&&this._editGeometryOperations.canRedo}get canUndo(){return s(this._editGeometryOperations)&&this._editGeometryOperations.canUndo}redo(){if(l(this._editGeometryOperations))return null;const e=this._editGeometryOperations.redo();return s(e)&&(this.outputGeometry=this._editGeometryOperations.data.geometry,this._recreateManipulators()),e}undo(){if(l(this._editGeometryOperations))return null;this.emit("undo");const e=this._editGeometryOperations.undo();return s(e)&&(this.outputGeometry=this._editGeometryOperations.data.geometry,this._recreateManipulators()),e}_recreateManipulators(){this._removeManipulators(),this._resetGrabbingDragging(),this._tooltip.clear(),this._createManipulators()}_recreateEditGeometryAndManipulators(e=this.inputGeometry){this._removeManipulators(),this._resetGrabbingDragging(),this._tooltip.clear(),l(e)||(r(this._editGeometryOperations),this._editGeometryOperations=ue.fromGeometry(e,this.view.state.viewingMode),this._createManipulators(),r(this._segmentLabels),this._segmentLabels=new j({context:{view:this.view,editGeometryOperations:this._editGeometryOperations,elevationInfo:w(this.graphic),labelOptions:this._labelOptions},visible:this._labelOptions.enabled}))}_perGraphicManipulatorDragAction(e,t){if("end"===t.action)return t;let i=0;const a=[],o=this._manipulatorInfos.some((e=>"vertex"===e.type&&e.manipulator.selected)),n=e===Te.SELECTED_OR_ALL&&o;for(const r of this._manipulatorInfos)"vertex"===r.type&&(r.manipulator.grabbing||n&&!r.manipulator.selected||a.push(r),i++);if(0===a.length)return t;this._moveVertices(a,t);if(a.length===i){if(this._updateEventState(Ae.MOVING),this.destroyed)return t;this.emit("move",{type:"move",dx:t.screenDeltaX,dy:t.screenDeltaY,mover:this.graphic})}else{if(this._updateEventState(Ae.RESHAPING),this.destroyed)return t;this.emit("reshape",{type:"reshape",mover:this.graphic})}return t}_isMultiVertexSelection(){let e=0;for(const t of this._manipulatorInfos)"vertex"===t.type&&t.manipulator.selected&&e++;return e>1}_perVertexManipulatorDragAction(e){if(this._updateEventState(Ae.RESHAPING),this.destroyed)return;const{mapDeltaX:t,mapDeltaY:i,mapDeltaZ:a}=e;if(!t&&!i&&!a)return;const o=[];for(const n of this._manipulatorInfos)"vertex"===n.type&&(n.manipulator.selected&&!n.manipulator.grabbing||n===e.info)&&o.push(n);this._moveVertices(o,e,ce.ACCUMULATE_STEPS),this.emit("reshape",{type:"reshape",mover:this.graphic})}_updateEventState(e){if(e===this._reshapeEventState)return!1;switch(e){case Ae.NONE:if(0!==this._numGrabbing||0!==this._numDragging)return!1;switch(this._reshapeEventState){case Ae.MOVING:this.emit("move",{type:"move-stop",dx:0,dy:0,mover:this.graphic});break;case Ae.RESHAPING:this.emit("reshape",{type:"reshape-stop",mover:this.graphic})}break;case Ae.MOVING:switch(this._reshapeEventState){case Ae.NONE:this.emit("move",{type:"move-start",dx:0,dy:0,mover:this.graphic});break;case Ae.RESHAPING:this.emit("reshape",{type:"reshape-stop",mover:this.graphic}),this.destroyed||this.emit("move",{type:"move-start",dx:0,dy:0,mover:this.graphic})}break;case Ae.RESHAPING:switch(this._reshapeEventState){case Ae.NONE:this.emit("reshape",{type:"reshape-start",mover:this.graphic});break;case Ae.MOVING:this.emit("move",{type:"move-stop",dx:0,dy:0,mover:this.graphic}),this.destroyed||this.emit("reshape",{type:"reshape-start",mover:this.graphic})}}if(this.destroyed)return!1;const t=this._reshapeEventState!==e;return this._reshapeEventState=e,t}_createGraphicMoveManipulators(e){const{graphic:t,handles:i,tool:a,view:o}=this,n=this._graphicState;if(this._graphicMoveManipulation=new J({tool:a,view:o,graphicState:n}),this.enableMoveGraphic){let e=null;this._manipulatorHandles.add(this._graphicMoveManipulation.createDragPipeline(((t,i,a)=>{i.next((e=>this._trackNumDragging(e))).next((t=>("start"===t.action&&(e=p(this._editGeometryOperations).createUndoGroup()),t))).next((e=>this._perGraphicManipulatorDragAction(Te.ALL,e))).next((e=>(this._updateTranslateGraphicTooltip(W.XY,e),e))).next((t=>{"end"===t.action&&(this._tooltip.clear(),e=h(e))})),a.next(this._cancelDragOperation((()=>e=h(e))))})))}else this._graphicMoveManipulation.forEachManipulator((e=>{e.grabbable=!1,e.cursor=null}));this._graphicMoveManipulation.forEachManipulator((e=>this._manipulatorHandles.add([this._watchAndUpdateGrabState(e,!1),e.events.on("immediate-click",(e=>{this._manipulatorInfos.some((e=>e.manipulator.selected))?this._clearSelection():this.emit("immediate-click",{...e,graphic:this.graphic}),e.stopPropagation()}))]))),this._moveManipulation=new K({tool:a,view:o,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:this.enableZShape&&z(t),snapToScene:!1,radius:K.radiusForSymbol(t.symbol)}),this._moveManipulation.forEachManipulator(((e,a)=>{i.add([this._watchAndUpdateGrabState(e,!1),e.events.on("immediate-click",(i=>{this._moveManipulation.zManipulation.hasManipulator(e)||this._manipulatorInfos.some((e=>e.manipulator.selected))||this.emit("immediate-click",{...i,graphic:t}),i.stopPropagation()}))]),i.add(e.events.on("focus-changed",(({action:e})=>{"focus"===e&&this._tooltipOptions.enabled?this._updateTranslateTooltip(a===F.TRANSLATE_Z?W.Z:W.XY):this._tooltip.clear()})))})),this._moveManipulation.elevationInfo={mode:"absolute-height",offset:0};const r=p(t.geometry).spatialReference;i.add([this._moveManipulation.createDragPipeline(((i,o,n,r,s)=>{const l=n.next((e=>this._trackNumDragging(e))).next((e=>{const t=this._manipulatorInfos.filter((e=>"vertex"===e.type&&e.manipulator.selected));return e.manipulatorType===F.TRANSLATE_XY&&1===t.length?{...e,info:t[0],snapOrigin:t[0].handle.pos}:{...e,info:null}})).next(this._snappingPipelineHandle.createSnapDragEventPipelineStep({predicate:e=>!!e.info,cancel:r,snappingManager:a.snappingManager,snappingContext:new me({editGeometryOperations:p(this._editGeometryOperations),elevationInfo:e,pointer:s,excludeFeature:t,visualizer:new U}),updatingHandles:this.updatingHandles}),this._snappingPipelineHandle.next).next(re()).next((e=>this._perGraphicManipulatorDragAction(Te.SELECTED_OR_ALL,e))).next((e=>(this._updateTranslateTooltip(i,e),e)));return r.next(this._cancelDragOperation()),l}),e,r,t),c((()=>n?.displaying),(()=>{this._updateMoveManipulationPosition()}),g),n.on("changed",(()=>this._updateMoveManipulationPosition())),c((()=>n?.isDraped),(e=>{const t="align-move-manipulation";e?i.add(this.view.elevationProvider.on("elevation-change",(()=>this._updateMoveManipulationPosition())),t):i.remove(t)}),g)]),this._updateMoveManipulationPosition();const l=Y({view:o,graphic:t,forEachManipulator:e=>{if(!this.destroyed){s(this._graphicMoveManipulation)&&this._graphicMoveManipulation.forEachManipulator(e);for(const t of this._manipulatorInfos)e(t.manipulator,F.TRANSLATE_XY);this._moveManipulation.forEachManipulator(e)}},onManipulatorsChanged:e=>this.on("manipulators-changed",e)});s(l)&&(this._outlineVisualElement=l.visualElement instanceof ie?l.visualElement:null),s(this._outlineVisualElement)&&this._manipulatorHandles.add([this._outlineVisualElement.events.on("attachment-origin-changed",(()=>{n.isDraped||this._updateMoveManipulationPosition()})),c((()=>n.isDraped),(()=>this._updateMoveManipulationPosition()))]),this._manipulatorHandles.add(l)}_createEdgeOffsetManipulator(e,t=w(this.graphic)){const i=Z.reshapeManipulators.edgeOffset,a=i.size/2,n=a+i.collisionPadding;if(l(this._edgeOffsetManipulatorGeometryInside)||l(this._edgeOffsetManipulatorGeometryOutside)){const e=a/n,t=e*Math.sqrt(3)/2;this._edgeOffsetManipulatorGeometryInside=oe.createExtrudedTriangle(t,e/2,e/2,i.height,i.offset),this._edgeOffsetManipulatorGeometryOutside=oe.createExtrudedTriangle(-t,e/2,e/2,i.height,-i.offset)}const r=[{geometry:this._edgeOffsetManipulatorGeometryInside,material:this._edgeOffsetManipulatorMaterial,stateMask:he.Unfocused},{geometry:this._edgeOffsetManipulatorGeometryInside,material:this._edgeOffsetManipulatorHoverMaterial,stateMask:he.Focused},{geometry:this._edgeOffsetManipulatorGeometryOutside,material:this._edgeOffsetManipulatorMaterial,stateMask:he.Unfocused},{geometry:this._edgeOffsetManipulatorGeometryOutside,material:this._edgeOffsetManipulatorHoverMaterial,stateMask:he.Focused}],p=new T({view:this.view,renderObjects:r,elevationInfo:"on-the-ground"!==t.mode||A(this.graphic.symbol)?{mode:"absolute-height",offset:0}:t,worldOriented:!1,focusMultiplier:1,radius:n,available:!(!this.graphic.visible||!this.graphic.layer.visible),collisionType:{type:"disc",direction:S(0,0,1)},collisionPriority:1}),h=new T({view:this.view,renderObjects:[],worldSized:!0,worldOriented:!1,available:!(!this.graphic.visible||!this.graphic.layer.visible),collisionPriority:-10,cursor:this.enableMoveGraphic?"move":"default"}),d={manipulator:p,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0,edgeManipulator:h,elevationInfo:t,visibilityHandle:null};this._autoHideEdgeOffsetManipulator(d,i.minSquaredEdgeLength),this._updateEdgeOffsetManipulator(d);const u=this._getManipulatorInfoFromHandle(d.handle.leftVertex).manipulator.events.on("location-update",(()=>this._updateEdgeOffsetManipulator(d))),c=this._getManipulatorInfoFromHandle(d.handle.rightVertex).manipulator.events.on("location-update",(()=>this._updateEdgeOffsetManipulator(d)));d.locationUpdateHandle=o([u,c]),this._manipulatorHandles.add(d.locationUpdateHandle,p),this._manipulatorHandles.add([this._watchAndUpdateGrabState(p,!0),this._watchAndUpdateGrabState(h,!0)],p),this._manipulatorHandles.add(se(p,this._createEdgeOffsetPipeline(d,t)),p),this._manipulatorHandles.add(se(h,((e,i,a,o)=>{if("touch"===o){this._createEdgeOffsetPipeline(d,t)(e,i,a)}else if(this.enableMoveGraphic){const o=this.graphic,n=s(o.geometry)?o.geometry.spatialReference:null;i.next((e=>this._trackNumDragging(e))).next(le(this.view,e.elevationAlignedLocation)).next(R(this.view,e.elevationAlignedLocation,t,n,o)).next(pe()).next(re()).next((e=>this._perGraphicManipulatorDragAction(Te.ALL,e))).next((e=>(this._updateTranslateGraphicTooltip(W.XY,e),e))).next((e=>{"end"===e.action&&this._tooltip.clear()})),a.next(this._cancelDragOperation())}})),p);const m=e=>{this._manipulatorInfos.some((e=>e.manipulator.selected))?this._clearSelection():this.emit("immediate-click",{...e,graphic:this.graphic}),e.stopPropagation()};return this._manipulatorHandles.add([p.events.on("immediate-click",m),h.events.on("immediate-click",m),p.events.on("focus-changed",(({action:e})=>{const t=this._tooltipOptions;"focus"===e&&t.enabled?this._tooltip.info=new _e({tooltipOptions:t}):this._tooltip.clear()}))],p),this._manipulatorInfos.push(d),this.manipulators.add(p),this.manipulators.add(h),this.emit("manipulators-changed"),d}_autoHideEdgeOffsetManipulator(e,t){const i=e.manipulator,a=e.edgeManipulator,n=()=>{h(e.visibilityHandle);const n=te(this._getManipulatorInfoFromHandle(e.handle.leftVertex).manipulator.renderLocation,this._getManipulatorInfoFromHandle(e.handle.rightVertex).manipulator.renderLocation,this.view.state.camera)<t;(!i.focused&&!a.focused||n)&&(i.grabbable=!n,a.grabbable=!n,e.visibilityHandle=o([i.disableDisplay(),{remove:()=>{i.grabbable=!0,a.grabbable=this.enableMoveGraphic}}]))};this._manipulatorHandles.add([i.events.on("focus-changed",n),a.events.on("focus-changed",n),{remove:()=>{h(e.visibilityHandle),this.manipulators.remove(a)}}],i),n()}_updateEdgeOffsetManipulator(e){this._updateManipulatorPosition(e);const t=p(this._editGeometryOperations).data.coordinateHelper,i=Q(this.view,e.manipulator.elevationAlignedLocation,$(t,e.handle,p(e.manipulator.elevationInfo))),a=this._getManipulatorInfoFromHandle(e.handle.leftVertex).manipulator.renderLocation,o=this._getManipulatorInfoFromHandle(e.handle.rightVertex).manipulator.renderLocation,n=s(i)?ee(i,a,o):M;e.manipulator.modelTransform=n,e.edgeManipulator.elevationAlignedLocation=e.manipulator.elevationAlignedLocation,e.edgeManipulator.modelTransform=n;const r=y(O(He,a,o))/2;e.edgeManipulator.collisionType={type:"line",paths:[[[-r,0,0],[r,0,0]]]}}_createEdgeOffsetPipeline(e,t){return(i,a,o)=>{this._clearSelection();const{step:n,cleanup:r}=this._initializeEdgeOffset(e,t);a.next((e=>this._trackNumDragging(e))).next(le(this.view,i.elevationAlignedLocation)).next(n).next(N(this.view)).next(k(this.view,p(this._editGeometryOperations).data.spatialReference)).next(re()).next(this._applyComputeEdgeOffsetDistanceStep()).next(this._applyEdgeOffsetStep(e)).next(this._showEdgeOffsetTooltip()).next((e=>{"end"===e.action&&r()})),o.next((e=>(r(),e))).next((e=>(this._tooltip.clear(),e))).next(this._cancelDragOperation())}}_initializeEdgeOffset(e,t){const i=p(this._editGeometryOperations),a=$(i.data.coordinateHelper,e.handle,t),r=i.createUndoGroup(),s=Q(this.view,e.manipulator.elevationAlignedLocation,a);a.requiresSplitEdgeLeft&&this._splitEdgeManipulator(this._getManipulatorInfoFromHandle(e.handle.leftVertex.leftEdge),1),a.requiresSplitEdgeRight&&this._splitEdgeManipulator(this._getManipulatorInfoFromHandle(e.handle.rightVertex.rightEdge),0);const d=()=>new I({paths:[[e.handle.leftVertex.pos,e.handle.rightVertex.pos]],spatialReference:p(this._editGeometryOperations).data.spatialReference}),u=new ie({view:this.view,isDraped:this._graphicState.isDraped,geometry:d(),elevationInfo:e.elevationInfo,width:Z.visualElements.lineGraphics.outline.width,color:Z.colorToVec4(X.main),attached:!0});let m;const g=()=>{this._cleanEdgeOffsetCollapsedEdges(e),m=h(m)},_=this.on("undo",g);return m=o([n(u),c((()=>this._graphicState.isDraped),(e=>u.isDraped=e)),this._graphicState.on("changed",(()=>u.geometry=d())),r,_]),{step:e=>l(a)||l(s)?(g(),null):{...e,operation:a,plane:s},cleanup:g}}_applyEdgeOffsetStep(e){return t=>{if(this.destroyed||l(t.operation))return t;this._updateEventState(Ae.RESHAPING);const{mapDeltaX:i,mapDeltaY:a,mapDeltaZ:o}=t;return(i||a||o)&&(this._offsetEdge(e,t),this.emit("reshape",{type:"reshape",mover:this.graphic})),t}}_applyComputeEdgeOffsetDistanceStep(){return e=>{const{operation:t,mapEnd:i}=e;if(l(t)||l(i))return e;const a=t.signedDistanceToPoint(i);return{...e,signedDistance:a}}}_showEdgeOffsetTooltip(){return e=>{const{mapEnd:t,signedDistance:i}=e,a=this._tooltip,o=this._tooltipOptions;if(!o.enabled||l(i))return a.clear(),e;const n=_(t.spatialReference),r=d(-i*n,"meters");return l(a.info)||"reshape-edge-offset"!==a.info.type?a.info=new _e({tooltipOptions:o,distance:r}):a.info.distance=r,e}}_cleanEdgeOffsetCollapsedEdges(e){const t=e.handle.leftVertex.leftEdge?.leftVertex,i=e.handle.leftVertex,a=e.handle.rightVertex.rightEdge?.rightVertex,o=e.handle.rightVertex,n=p(this._editGeometryOperations).data.coordinateHelper,r=1e-6,s=[];t&&n.distance(t.pos,i.pos)<r&&s.push(this._getManipulatorInfoFromHandle(i)),(n.distance(i.pos,o.pos)<r||a&&n.distance(a.pos,o.pos)<r)&&s.push(this._getManipulatorInfoFromHandle(o)),s.length&&this._removeVertices(s)}_computeVertexManipulatorSizeAndOutline(e){const t=e.size/2,i=t+e.collisionPadding;return{size:t/i,outlineSize:(t+e.outlineSize)/i}}_createVertexOrEdgeManipulator(e,t=w(this.graphic)){if("edge"===e.type){if(this.enableEdgeOffset)return this._createEdgeOffsetManipulator(e,t);if(!this.enableMidpoints)return null}if(l(this._vertexManipulatorGeometry)||l(this._vertexManipulatorOutlineGeometry)){const{size:e,outlineSize:t}=this._computeVertexManipulatorSizeAndOutline(Z.reshapeManipulators.vertex);this._vertexManipulatorGeometry=oe.createSphereGeometry(e,16,16),this._vertexManipulatorOutlineGeometry=oe.createSphereGeometry(t,16,16)}if(l(this._edgeManipulatorGeometry)||l(this._edgeManipulatorOutlineGeometry)){const{size:e,outlineSize:t}=this._computeVertexManipulatorSizeAndOutline(Z.reshapeManipulators.edge);this._edgeManipulatorGeometry=oe.createSphereGeometry(e,16,16),this._edgeManipulatorOutlineGeometry=oe.createSphereGeometry(t,16,16)}const i=s(this.graphic.geometry)&&"point"===this.graphic.geometry.type?[]:[{geometry:this._vertexManipulatorGeometry,material:this._vertexManipulatorMaterial,stateMask:we.Vertex|he.Unselected},{geometry:this._vertexManipulatorOutlineGeometry,material:this._vertexManipulatorOutlineMaterial,stateMask:we.Vertex|he.Unfocused|he.Unselected},{geometry:this._vertexManipulatorOutlineGeometry,material:this._vertexManipulatorHoverOutlineMaterial,stateMask:we.Vertex|he.Focused|he.Unselected},{geometry:this._vertexManipulatorGeometry,material:this._selectedManipulatorMaterial,stateMask:he.Selected},{geometry:this._vertexManipulatorOutlineGeometry,material:this._selectedManipulatorOutlineMaterial,stateMask:he.Selected|he.Unfocused},{geometry:this._vertexManipulatorOutlineGeometry,material:this._selectedManipulatorHoverOutlineMaterial,stateMask:he.Selected|he.Focused}];this.enableMidpoints&&i.push({geometry:this._edgeManipulatorGeometry,material:this._vertexManipulatorMaterial,stateMask:we.Edge|he.Focused|he.Unselected},{geometry:this._edgeManipulatorOutlineGeometry,material:this._vertexManipulatorHoverOutlineMaterial,stateMask:we.Edge|he.Focused|he.Unselected},{geometry:this._edgeManipulatorGeometry,material:this._edgeManipulatorMaterial,stateMask:we.Edge|he.Unfocused|he.Unselected},{geometry:this._edgeManipulatorOutlineGeometry,material:this._edgeManipulatorOutlineMaterial,stateMask:we.Edge|he.Unfocused|he.Unselected});const a=new T({view:this.view,renderObjects:i,elevationInfo:t,focusMultiplier:1,touchMultiplier:1,available:!(!this.graphic.visible||!this.graphic.layer.visible)});this._setTypeSpecificManipulatorSettings(a,e,t);const n="edge"===e.type?{manipulator:a,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0}:{manipulator:a,handle:e,type:"vertex",selectedIndex:0};if(this._manipulatorInfos.push(n),this.manipulators.add(a),this._updateManipulatorPosition(n),"edge"===n.type){const e=this._getManipulatorInfoFromHandle(n.handle.leftVertex).manipulator.events.on("location-update",(()=>this._updateManipulatorPosition(n))),t=this._getManipulatorInfoFromHandle(n.handle.rightVertex).manipulator.events.on("location-update",(()=>this._updateManipulatorPosition(n)));n.locationUpdateHandle=o([e,t]),this._manipulatorHandles.add(n.locationUpdateHandle,a)}this._manipulatorHandles.add(this._watchAndUpdateGrabState(a,!0),a);const r=se(a,((e,i,a,o)=>{let r=null;i.next((e=>this._trackNumDragging(e))).next((e=>{if("start"===e.action&&(r=p(this._editGeometryOperations).createUndoGroup()),"edge"===n.type){const t=this._splitEdgeManipulator(n);return{...e,info:t,snapOrigin:t.handle.pos}}return{...e,info:n,snapOrigin:n.handle.pos}})).next(le(this.view,e.elevationAlignedLocation)).next(C(this.view,this.graphic,e.elevationAlignedLocation,e.location.spatialReference,this.graphic)).next(this._snappingPipeline.createSnapDragEventPipelineStep({predicate:()=>!this._isMultiVertexSelection(),cancel:a,snappingManager:this.tool.snappingManager,snappingContext:new me({editGeometryOperations:p(this._editGeometryOperations),elevationInfo:t,pointer:o,excludeFeature:this.graphic,visualizer:new U}),updatingHandles:this.updatingHandles}),this._snappingPipeline.next).next(re()).next((t=>{this._perVertexManipulatorDragAction(t),"end"===t.action&&(r=h(r)),this._updateTranslateVertexTooltip(e,W.XY,t)})),a.next(this._cancelDragOperation((()=>r=h(r))))}));return this._manipulatorHandles.add([r,a.events.on("immediate-click",(e=>this._manipulatorClickCallback(e,n))),a.events.on("select-changed",(()=>{n.selectedIndex=++this._selectedIndex,this._updateMoveManipulationPosition()})),a.events.on("focus-changed",(({action:e})=>{"focus"===e&&"edge"!==n.type?this._updateTranslateVertexTooltip(a,W.XY):this._tooltip.clear()}))],a),this.emit("manipulators-changed"),n}_trackNumDragging(e){switch(e.action){case"start":this._numDragging++;break;case"end":this._numDragging--}return e}_cancelDragOperation(e){return()=>{switch(this._numDragging--,this.undo(),this.outputGeometry=s(this._editGeometryOperations)?this._editGeometryOperations.data.geometry:null,s(this.tool.snappingManager)&&this.tool.snappingManager.doneSnapping(),this._tooltip.clear(),this._reshapeEventState){case Ae.NONE:break;case Ae.MOVING:this.emit("move",{type:"move",dx:0,dy:0,mover:this.graphic});break;case Ae.RESHAPING:this.emit("reshape",{type:"reshape",mover:this.graphic})}e&&e(),this.destroyed||this._updateEventState(Ae.NONE)}}_setTypeSpecificManipulatorSettings(e,t,i){switch(t.type){case"vertex":e.state=we.Vertex,e.selectable=!0,e.cursor="move",e.collisionPriority=2,e.radius=Z.reshapeManipulators.vertex.size/2+Z.reshapeManipulators.vertex.collisionPadding,e.elevationInfo=i,e.interactive=s(this.graphic.geometry)&&"point"!==this.graphic.geometry.type;break;case"edge":e.state=we.Edge,e.selectable=!1,e.cursor="copy",e.collisionPriority=-1,e.radius=Z.reshapeManipulators.edge.size/2+Z.reshapeManipulators.edge.collisionPadding,e.elevationInfo="on-the-ground"!==i.mode||A(this.graphic.symbol)?{mode:"absolute-height",offset:0}:i}}_watchAndUpdateGrabState(e,t){return e.events.on("grab-changed",(i=>{if("start"===i.action)t&&this._updateSelection(e),this._numGrabbing++;else if(this._numGrabbing--,this._updateEventState(Ae.NONE),this.destroyed)return;this._moveManipulation.interactive=!this._numGrabbing,("touch"!==i.pointerType||this.enableEdgeOffset)&&(this._manipulatorInfos.forEach((e=>{e.manipulator.interactive=!this._numGrabbing&&s(this.graphic.geometry)&&"point"!==this.graphic.geometry.type,"edgeManipulator"in e&&(e.edgeManipulator.interactive=!this._numGrabbing)})),p(this._graphicMoveManipulation).forEachManipulator((e=>e.interactive=!this._numGrabbing)))}))}_clearSelection(){for(const e of this._manipulatorInfos)e.manipulator.grabbing||(e.manipulator.selected=!1)}_updateSelection(e){e.grabbing&&!e.selected&&e.selectable&&(this._clearSelection(),e.selected=!0,this.emit("manipulators-changed"))}_removeManipulator(e){e&&(this._manipulatorHandles.remove(e.manipulator),this._manipulatorInfos.splice(this._manipulatorInfos.indexOf(e),1),this.manipulators.remove(e.manipulator),this.emit("manipulators-changed"))}_getManipulatorInfoFromHandle(e){if(e)for(const t of this._manipulatorInfos)if(e===t.handle)return t;return null}_updateManipulatorPosition(e){if(!e)return;const t=p(this._editGeometryOperations);if("vertex"===e.type)e.manipulator.location=t.data.coordinateHelper.vectorToDehydratedPoint(e.handle.pos,Ie),e.manipulator.grabbing&&s(this._vertexLaserLineVisualElement)&&(this._vertexLaserLineVisualElement.visualElement.intersectsWorldUpAtLocation=e.manipulator.renderLocation);else if("edge"===e.type){const i=this._getManipulatorInfoFromHandle(e.handle.leftVertex).manipulator,a=this._getManipulatorInfoFromHandle(e.handle.rightVertex).manipulator;if(s(e.manipulator.elevationInfo)&&"on-the-ground"===e.manipulator.elevationInfo.mode){const o=i.location,n=a.location,r=.5,s=o.x+r*(n.x-o.x),l=o.y+r*(n.y-o.y),p=o.hasZ&&n.hasZ?0:void 0;e.manipulator.location=H(s,l,p,t.data.spatialReference)}else x(He,i.renderLocation,a.renderLocation,.5),e.manipulator.renderLocation=He}}_splitEdgeManipulator(e,t=.5){const i=p(this._editGeometryOperations),a=p(i.splitEdge(e.handle,t).createdVertex);e.locationUpdateHandle.remove(),e.locationUpdateHandle=void 0;const o=w(this.graphic);let n;this.enableEdgeOffset?(this._removeManipulator(e),n=this._createVertexOrEdgeManipulator(a)):(n=e,n.handle=a,n.type="vertex",this._setTypeSpecificManipulatorSettings(e.manipulator,e.handle,o)),a.leftEdge&&this._createVertexOrEdgeManipulator(a.leftEdge),a.rightEdge&&this._createVertexOrEdgeManipulator(a.rightEdge),this.outputGeometry=i.data.geometry,this._updateManipulatorPosition(n),this._updateSelection(e.manipulator);const r=this._updateEventState(Ae.RESHAPING),s=i.data.coordinateHelper.vectorToArray(n.handle.pos),l=i.data.components.indexOf(a.component);return this.emit("vertex-add",{type:"vertex-add",vertices:[{coordinates:s,componentIndex:l,vertexIndex:p(a.index)}],added:s}),r&&this._updateEventState(Ae.NONE),n}_updateMoveManipulationPosition(){const e=b(He,0,0,0);let t=0,i=!1,a=null,o=null;for(const n of this._manipulatorInfos)"vertex"===n.type&&(n.manipulator.selected?(t++,E(e,e,n.manipulator.renderLocation),l(a)||n.selectedIndex>a.selectedIndex?(o=a,a=n):(l(o)||n.selectedIndex>o.selectedIndex)&&(o=n)):i=!0);if(0!==t){const e=this._graphicState.displaying;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.zManipulation.available=e&&this.enableZVertex&&z(this.graphic),this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e&&1!==t}else{const e=this._graphicState.displaying&&this.enableMoveGraphic;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e,this._moveManipulation.zManipulation.available=e&&this.enableZShape&&z(this.graphic)}if(0!==t){let e=0;if(s(a)){const t=a.handle.pos,i=s(o)?o.handle.pos:a.handle.leftEdge&&a.handle.leftEdge.leftVertex?a.handle.leftEdge.leftVertex.pos:null,n=l(o)&&a.handle.rightEdge&&a.handle.rightEdge.rightVertex?a.handle.rightEdge.rightVertex.pos:null;i&&n?this._moveManipulation.xyAxisManipulation.available=!1:i?e=Ve(i,t):n&&(e=Ve(t,n))}this._moveManipulation.angle=e,this._moveManipulation.radius=q}else this._moveManipulation.angleDeferred=()=>B(p(this.graphic.geometry)),this._moveManipulation.radius=K.radiusForSymbol(this.graphic.symbol);0!==t&&i?(G(e,e,1/t),Ie.spatialReference=p(this._editGeometryOperations).data.spatialReference,Ie.hasZ=!0,this.view.renderCoordsHelper.fromRenderCoords(e,Ie),this._moveManipulation.elevationAlignedLocation=Ie):s(this._outlineVisualElement)&&!this._graphicState.isDraped&&s(this._outlineVisualElement.attachmentOrigin)?this._moveManipulation.elevationAlignedLocation=this._outlineVisualElement.attachmentOrigin:P(this.view,this._moveManipulation,this.graphic)}_removeVertices(e){const t=[],i=p(this._editGeometryOperations);for(const a of e)if("vertex"===a.type&&i.canRemoveVertex()){t.push(a.handle),this._removeManipulator(a),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.leftEdge)),this._removeManipulator(this._getManipulatorInfoFromHandle(a.handle.rightEdge));const e=p(i.removeVertices([a.handle]).removedVertices[0].createdEdge);e&&this._createVertexOrEdgeManipulator(e)}if(t.length>0){const e=t.map((e=>{const t=i.data.components.indexOf(e.component);return{coordinates:i.data.coordinateHelper.vectorToArray(e.pos),componentIndex:t,vertexIndex:p(e.index)}}));this.outputGeometry=i.data.geometry;const a=this._updateEventState(Ae.RESHAPING);if(this.destroyed)return;if(this.emit("vertex-remove",{type:"vertex-remove",removed:e.map((e=>e.coordinates)),vertices:e}),this.destroyed)return;if(a&&(this._updateEventState(Ae.NONE),this.destroyed))return;this._updateMoveManipulationPosition()}}_moveVertices(e,t,i=("start"===t.action?ce.NEW_STEP:ce.ACCUMULATE_STEPS)){const a=p(this._editGeometryOperations);a.moveVertices(e.map((e=>e.handle)),t.mapDeltaX,t.mapDeltaY,t.mapDeltaZ,i),this.outputGeometry=a.data.geometry;for(const o of e)this._updateManipulatorPosition(o)}_offsetEdge(e,t){if(l(t.operation)||l(t.signedDistance))return;const i=p(this._editGeometryOperations),a=t.operation.clone();a.distance=t.signedDistance,i.updateVertices([e.handle.leftVertex,e.handle.rightVertex],a),this.outputGeometry=i.data.geometry,this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(e.handle.leftVertex)),this._updateManipulatorPosition(this._getManipulatorInfoFromHandle(e.handle.rightVertex))}_manipulatorClickCallback(e,t){e.shiftKey||this._clearSelection(),"vertex"===t.type&&(t.manipulator.selected=!t.manipulator.selected,e.button===ne.Right&&this._removeVertices([t])),"edge"===t.type&&e.button===ne.Left&&this._splitEdgeManipulator(t),e.stopPropagation()}_updateTranslateTooltip(e,t){const i=this._manipulatorInfos.filter((e=>"vertex"===e.type&&e.manipulator.selected));1===i.length?this._updateTranslateVertexTooltip(i[0].manipulator,e,t):this._updateTranslateGraphicTooltip(e,t)}_updateTranslateGraphicTooltip(e,t){const i=this._tooltipOptions;if(!i.enabled)return;const a=e===W.Z,o=a?new ve({tooltipOptions:i}):new Me({tooltipOptions:i});if(s(t)&&"end"!==t.action){const{mapStart:e,mapEnd:i}=t,n=a?xe(e,i):be(e,i);o.distance=s(n)?n:u}this._tooltip.info=o}_updateTranslateVertexTooltip(e,t,i){const a=this._tooltipOptions;if(!a.enabled)return;const o=t===W.Z,n=new ye({tooltipOptions:a});if(s(i)&&"end"!==i.action){const{mapStart:e,mapEnd:t}=i,a=o?xe(e,t):be(e,t);n.distance=s(a)?a:u}const r=Ee(e.elevationAlignedLocation);s(r)&&(n.elevation={mode:"absolute-height",...r});const{geometry:l}=this.graphic;s(l)&&!o&&(n.area="polygon"===l.type?Oe(l):null,n.totalLength="polyline"===l.type?Ge(l):null),this._tooltip.info=n}get test(){return{segmentLabels:this._segmentLabels,tooltip:this._tooltip}}};function Ve(e,t){return Math.atan2(t[1]-e[1],t[0]-e[0])+Math.PI/2}e([f()],Se.prototype,"_segmentLabels",void 0),e([f({constructOnly:!0})],Se.prototype,"tool",void 0),e([f()],Se.prototype,"_tooltip",void 0),e([f()],Se.prototype,"inputGeometry",null),e([f()],Se.prototype,"outputGeometry",void 0),e([f({readOnly:!0})],Se.prototype,"updating",null),e([f()],Se.prototype,"manipulators",null),e([f()],Se.prototype,"view",null),e([f()],Se.prototype,"graphic",null),e([f()],Se.prototype,"enableZShape",null),e([f()],Se.prototype,"enableZVertex",null),e([f()],Se.prototype,"enableMoveGraphic",null),e([f()],Se.prototype,"enableMidpoints",null),e([f()],Se.prototype,"enableEdgeOffset",null),e([f()],Se.prototype,"_labelOptions",null),e([f()],Se.prototype,"_tooltipOptions",null),Se=e([v("esri.views.3d.interactive.editingTools.reshapeGraphic.ReshapeOperation")],Se);const Ie=H(0,0,null,null),He=V();var we,Ae,Te;!function(e){e.Vertex=de.Custom1,e.Edge=de.Custom2}(we||(we={})),function(e){e[e.NONE=0]="NONE",e[e.MOVING=1]="MOVING",e[e.RESHAPING=2]="RESHAPING"}(Ae||(Ae={})),function(e){e[e.ALL=0]="ALL",e[e.SELECTED_OR_ALL=1]="SELECTED_OR_ALL"}(Te||(Te={}));export{Se as ReshapeOperation};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../../../chunks/tslib.es6.js";import e from"../../../../../core/Evented.js";import i from"../../../../../core/Handles.js";import{makeHandle as a}from"../../../../../core/handleUtils.js";import{rad2deg as s}from"../../../../../core/mathUtils.js";import{isSome as o,isNone as r,unwrapOr as n,unwrap as p}from"../../../../../core/maybe.js";import{createLength as l}from"../../../../../core/quantityUtils.js";import{watch as h,initial as c}from"../../../../../core/reactiveUtils.js";import{screenPointObjectToArray as d}from"../../../../../core/screenUtils.js";import{lengthUnitFromSpatialReference as u,getMetersPerUnitForSR as m}from"../../../../../core/unitUtils.js";import{property as g}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import"../../../../../core/accessorSupport/ensureType.js";import{subclass as y}from"../../../../../core/accessorSupport/decorators/subclass.js";import{g as v}from"../../../../../chunks/mat4.js";import{a as f,g as _,i as S}from"../../../../../chunks/vec2.js";import{a as M}from"../../../../../chunks/vec2f64.js";import{l as b,c as B,C as T,b as E,n as A,e as x}from"../../../../../chunks/vec3.js";import{c as O,a as j}from"../../../../../chunks/vec3f64.js";import{containsXY as R}from"../../../../../geometry/support/aaBoundingRect.js";import{c as G,a as D}from"../../../../../chunks/boundedPlane.js";import{intersectRay as w,create as P,normal as U}from"../../../../../geometry/support/plane.js";import{create as z}from"../../../../../geometry/support/ray.js";import{sv2d as Z,sv3d as C,sm4d as I}from"../../../../../geometry/support/vectorStacks.js";import{getGraphicEffectiveElevationInfo as k}from"../../../../../support/elevationInfoUtils.js";import{createShiftManipulator as L,OffsetMode as X,IsShiftEdgeOnScreenFlag as V,createResizeManipulator as Y,createRotateManipulator as N,resizeNormal as H,resizeOutlineOnly as F,isDiagonalResizeHandle as q,calculateDiagonalResizeHandleScale as W,createRotatePlane as J,RotationAxis as K,calculateBoundedPlaneTranslateRotate as Q,updateRotateHeadingHandle as $,updateResizeHandle as tt}from"../../../analysis/Slice/sliceToolUtils.js";import{getRotateHeadingTexture as et}from"../../../analysis/Slice/images/Factory.js";import{Manipulator3D as it}from"../../Manipulator3D.js";import{getGraphicAttachmentOrigin as at,calculateInputRotationTransform as st}from"../../manipulatorUtils.js";import{screenToZConstrained as ot,screenToRenderPlane as rt}from"../dragEventPipeline3D.js";import{ManipulatorType as nt}from"../ManipulatorType.js";import{canMoveZ as pt}from"../manipulatorUtils.js";import{createVisualElements as lt}from"../visualElementUtils.js";import{ManipulationType as ht}from"../manipulations/MoveManipulation.js";import{MoveXYGraphicManipulation as ct}from"../manipulations/MoveXYGraphicManipulation.js";import{PreserveAspectRatio as dt}from"./PreserveAspectRatio.js";import{OutlineVisualElement as ut}from"../../visualElements/OutlineVisualElement.js";import{evaluateElevationAlignmentAtPoint as mt}from"../../../layers/graphics/elevationAlignmentUtils.js";import{ElevationContext as gt}from"../../../layers/graphics/ElevationContext.js";import{GraphicState as yt}from"../../../layers/graphics/GraphicState.js";import{fromScreen as vt}from"../../../support/geometryUtils/ray.js";import{createManipulatorDragEventPipeline as ft,addMapDelta as _t,addScreenDelta as St}from"../../../../interactive/dragEventPipeline.js";import{InteractiveToolBase as Mt}from"../../../../interactive/InteractiveToolBase.js";import{EditGeometryOperations as bt}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import{AccumulationBehaviour as Bt}from"../../../../interactive/editGeometry/interfaces.js";import{AccumulationType as Tt}from"../../../../interactive/editGeometry/operations/UpdateVertices.js";import{calculateOrientedBounds as Et,mapPlaneToRenderPlane as At,apply as xt,unapply as Ot}from"../../../../interactive/editGeometry/support/editPlaneUtils.js";import jt from"../../../../interactive/sketch/SketchTooltipOptions.js";import{ExtentRotateTooltipInfo as Rt,ExtentScaleTooltipInfo as Gt}from"../../../../interactive/tooltip/ExtentTooltipInfos.js";import{Tooltip as Dt}from"../../../../interactive/tooltip/Tooltip.js";import{TranslateGraphicTooltipInfo as wt,TranslateZTooltipInfo as Pt}from"../../../../interactive/tooltip/TranslateTooltipInfos.js";import{euclideanHorizontalDistanceBetweenPoints as Ut}from"../../../../support/lengthMeasurementUtils.js";let zt=class extends(e.EventedMixin(Mt)){constructor(t){super(t),this.enableZ=!0,this.enableRotation=!0,this.enableScaling=!0,this.tooltipOptions=new jt,this._preserveAspectRatio=new dt,this.grabbing=!1,this.inputState=null,this.type="transform-3d",this.handles=new i,this.moveZManipulator=null,this.resizeManipulators=null,this.rotateManipulator=null,this.attachmentOrigin=null,this.outlineVisualElement=null,this.mapBounds=G(),this.mapBoundsStart=G(),this.displayBounds=G(),this.displayBoundsStart=G(),this.displayBoundsMarginStart=0,this.resizeHandles=[{direction:[1,0]},{direction:[1,1]},{direction:[0,1]},{direction:[-1,1]},{direction:[-1,0]},{direction:[-1,-1]},{direction:[0,-1]},{direction:[1,-1]}],this._moveXYTooltipInfo=null,this._moveZTooltipInfo=null,this._rotateTooltipInfo=null,this._scaleTooltipInfo=null,this._startAngle=0,this._endAngle=0,this._startScale=M(),this._endScale=M()}initialize(){const{view:t,graphic:e,manipulators:i,handles:s}=this,r=this.graphicState=new yt({graphic:e}),n=e.geometry;this.editGeometryOperations=bt.fromGeometry(n,t.state.viewingMode),this.graphicMoveManipulation=new ct({tool:this,view:t,graphicState:r}),this.moveZManipulator=L(t,X.CENTER_ON_CALLOUT),this.moveZManipulator.state|=V,s.add([this._createMoveXYGraphicDragPipeline(),h((()=>this.enableZ),(()=>this._updateManipulatorAvailability(this.moveZManipulator,nt.TRANSLATE_Z))),this._createMoveZDragPipeline()]),i.add(this.moveZManipulator),this.resizeManipulators=this.resizeHandles.map((e=>{const i=Y(t,e);return s.add([h((()=>this.enableScaling),(()=>this._updateManipulatorAvailability(i,nt.SCALE))),i.events.on("grab-changed",(t=>this._onResizeGrab(t))),this._createResizeDragPipeline(i,e)]),i})),i.addMany(this.resizeManipulators),this.rotateManipulatorTexture=et(t.toolViewManager.textures),this.rotateManipulator=N(t,this.rotateManipulatorTexture.texture),s.add([h((()=>this.enableRotation),(()=>this._updateManipulatorAvailability(this.rotateManipulator,nt.ROTATE))),this.rotateManipulator.events.on("grab-changed",(t=>{this._onRotateGrab(t)})),this._createRotateDragPipeline(this.rotateManipulator)]),i.add(this.rotateManipulator),this._calculateMapBounds(),this._updateDisplayBounds();const p=lt({view:t,graphic:e,forEachManipulator:t=>this._forEachManipulator(t),onManipulatorsChanged:()=>a()});o(p)&&(this.outlineVisualElement=p.visualElement instanceof ut?p.visualElement:null),o(this.outlineVisualElement)&&s.add(this.outlineVisualElement.events.on("attachment-origin-changed",(()=>this._updateDisplayBounds()))),s.add(p),s.add([r.on("changed",(()=>this._onGeometryChanged())),h((()=>r.displaying),(()=>this._updateAllManipulatorAvailability())),h((()=>r.isDraped),(()=>this._graphicDrapedChanged()),c),t.trackGraphicState(r)]);const l=t.pointsOfInterest;l&&s.add(h((()=>l.centerOnSurfaceFrequent.location),(()=>this._updateDisplayBounds())));const d=t=>{s.add(t.events.on("grab-changed",(()=>{this.grabbing=t.grabbing,this._updateAllManipulatorAvailability()})))};this._forEachManipulator(d);const u=(t,i)=>{s.add(t.events.on("immediate-click",(t=>{i===nt.TRANSLATE_XY&&this.emit("immediate-click",{...t,graphic:e}),t.stopPropagation()})))};this._forEachManipulator(u),this._onGeometryChanged(),this._updateAllManipulatorAvailability(),this._initializeTooltip(),this.finishToolCreation()}destroy(){this.mapBounds=null,this.displayBounds=null,this.rotateManipulatorTexture.release(),this.handles.destroy(),this.graphicMoveManipulation.destroy(),this.editGeometryOperations.destroy(),this._tooltip.destroy(),this._set("view",null),this._set("graphic",null)}_initializeTooltip(){const{handles:t,view:e}=this,i=this._tooltip=new Dt({view:e}),a=()=>{i.info=this._getUpdatedTooltipInfo()};t.add([this.on("graphic-translate-start",a),this.on("graphic-translate",a),this.on("graphic-translate-stop",a),this.on("graphic-rotate-start",(t=>{this._startAngle=t.angle,a()})),this.on("graphic-rotate",(t=>{this._endAngle=t.angle,a()})),this.on("graphic-rotate-stop",(()=>{this._startAngle=0,this._endAngle=0,a()})),this.on("graphic-scale-start",(t=>{f(this._startScale,t.xScale,t.yScale),f(this._endScale,t.xScale,t.yScale),a()})),this.on("graphic-scale",(t=>{f(this._endScale,t.xScale,t.yScale),a()})),this.on("graphic-scale-stop",(()=>{f(this._startScale,0,0),f(this._endScale,0,0),a()}))]),this._forEachManipulator((e=>{t.add([e.events.on("focus-changed",a),e.events.on("grab-changed",a),e.events.on("drag",a)])}))}_getUpdatedTooltipInfo(){const{tooltipOptions:t}=this;if(!t.enabled)return null;if(this.graphicMoveManipulation.grabbing||this.graphicMoveManipulation.dragging){let e=this._moveXYTooltipInfo;return r(e)&&(e=this._moveXYTooltipInfo=new wt({tooltipOptions:t})),e}if(this.moveZManipulator.focused){let e=this._moveZTooltipInfo;r(e)&&(e=this._moveZTooltipInfo=new Pt({tooltipOptions:t}));const i=this._moveUnit;if(this.moveZManipulator.dragging){const t=this.mapBoundsStart.origin,a=this.mapBounds.origin;e.distance=l(a[2]-t[2],i)}else e.distance=l(0,i);return e}if(this.rotateManipulator.focused){let e=this._rotateTooltipInfo;return r(e)&&(e=this._rotateTooltipInfo=new Rt({tooltipOptions:t})),e.angle=this._startAngle-this._endAngle,e}if(this.resizeManipulators.some((t=>t.focused))){let e=this._scaleTooltipInfo;r(e)&&(e=this._scaleTooltipInfo=new Gt({tooltipOptions:t}));const i=this._moveUnit,[a,s]=_(Lt,this._endScale,this._startScale);e.xScale=1+a,e.yScale=1+s;const o=this.mapBounds;return e.xSize=l(b(o.basis1),i),e.ySize=l(b(o.basis2),i),e}return null}_graphicDrapedChanged(){this.handles.remove(Zt),this._updateDisplayBounds(),this.graphicState.isDraped&&this.handles.add(this.view.elevationProvider.on("elevation-change",(t=>{o(this.attachmentOrigin)&&R(t.extent,this.attachmentOrigin.x,this.attachmentOrigin.y)&&this._updateDisplayBounds()})),Zt)}_updateAllManipulatorAvailability(){this._forEachManipulator(((t,e)=>this._updateManipulatorAvailability(t,e)))}_updateManipulatorAvailability(t,e){const i=this.grabbing&&!t.grabbing;if(t.interactive=!i,t instanceof it){const a=this.graphicState.displaying,s=this.enableZ&&pt(this.graphic);switch(e){case nt.ROTATE:t.available=a&&this.enableRotation;break;case nt.SCALE:t.available=a&&(this.enableScaling||this.enableRotation||s),t.interactive=!i&&this.enableScaling,t.state=this.enableScaling?H:F;break;case nt.TRANSLATE_Z:t.available=a&&s;break;default:t.available=a}}}_forEachManipulator(t){this.graphicMoveManipulation.forEachManipulator(t),this.resizeManipulators.forEach((e=>t(e,nt.SCALE))),t(this.rotateManipulator,nt.ROTATE),t(this.moveZManipulator,nt.TRANSLATE_Z)}get preserveAspectRatio(){return this._preserveAspectRatio.enabled}set preserveAspectRatio(t){this._preserveAspectRatio.enabled=t,this._set("preserveAspectRatio",t)}get _moveUnit(){return n(u(this.view.spatialReference),"meters")}reset(){}_onGeometryChanged(){this._updateDisplayBounds()}_calculateMapBounds(){const t=this.graphic.geometry,e=this.editGeometryOperations.data,i=e.components[0].edges[0],a=_(Z.get(),i.leftVertex.pos,i.rightVertex.pos);S(a,a);const s=n(at(this.view,this.graphic),t.extent.center);let o=It*this.view.pixelSizeAt(s);const r=this.view.spatialReference;r!==t.spatialReference&&(o*=m(r)/m(t.spatialReference)),Et(a,e,o,this.mapBounds)}_updateDisplayBounds(){const t=this.graphic.geometry;if(r(t))return;const e=o(this.outlineVisualElement)&&!this.graphicState.isDraped&&o(this.outlineVisualElement.attachmentOrigin)?this.outlineVisualElement.attachmentOrigin:at(this.view,this.graphic);this.attachmentOrigin=n(e,t.extent.center);const i=o(e)?e.z:mt(this.mapBounds.origin,this.view.elevationProvider,gt.fromElevationInfo(k(this.graphic)),this.view.renderCoordsHelper),a=D(this.mapBounds);a.origin[2]=i,At(a,this.view.renderCoordsHelper,t.spatialReference,this.displayBoundsMargin,this.displayBounds),this._updateManipulators()}get displayBoundsMargin(){const t=this.view.pointsOfInterest,e=t?t.centerOnSurfaceFrequent.location:this.editGeometryOperations.data.geometry.extent.center;return Ct*this.view.pixelSizeAt(e)}_createMoveXYGraphicDragPipeline(){return this.graphicMoveManipulation.createDragPipeline(((t,e,i)=>this._applyGraphicMoveSteps(e,i,ht.XY)))}_createMoveZDragPipeline(){const t=this.view,e=this.editGeometryOperations.data.spatialReference;return ft(this.moveZManipulator,((i,a,s)=>{const o=j(i.renderLocation),r=a.next(ot(t,o,e)).next(St());this._applyGraphicMoveSteps(r,s,ht.Z)}))}_applyGraphicMoveSteps(t,e,i){const a=t.next((t=>("start"===t.action&&(this.inputState={type:"move"},D(this.mapBounds,this.mapBoundsStart),this.emit("graphic-translate-start",{graphic:this.graphic,dxScreen:t.screenDeltaX,dyScreen:t.screenDeltaY})),t))).next(_t()).next(this._moveDragUpdateGeometry()).next((t=>{const e={graphic:this.graphic,dxScreen:t.screenDeltaX,dyScreen:t.screenDeltaY};switch(t.action){case"start":case"update":(t.mapEnd.x-t.mapStart.x||t.mapEnd.y-t.mapStart.y||t.mapEnd.z-t.mapStart.z)&&this.emit("graphic-translate",e);break;case"end":this.inputState=null,this.emit("graphic-translate-stop",e)}return t})).next((t=>this._updateMoveTooltip(t,i)));return e.next((()=>{o(this.inputState)&&this.emit("graphic-translate-stop",{graphic:this.graphic,dxScreen:0,dyScreen:0}),this._cancel()})),a}_moveDragUpdateGeometry(){return t=>{if(r(this.inputState)||"move"!==this.inputState.type)return t;const e=[];for(const s of this.editGeometryOperations.data.components)e.push(...s.vertices);const i="start"===t.action?Bt.NEW_STEP:Bt.ACCUMULATE_STEPS,a=this.editGeometryOperations.moveVertices(e,t.mapDeltaX,t.mapDeltaY,t.mapDeltaZ,i);return xt(a,this.mapBounds),this.graphic.geometry=this.editGeometryOperations.data.geometry,t}}_updateMoveTooltip(t,e){if(e===ht.XY||e===ht.XY_AXIS){const e=Ut(t.mapStart,t.mapEnd);o(e)&&o(this._moveXYTooltipInfo)&&(this._moveXYTooltipInfo.distance=e)}return t}_onResizeGrab(t){if("start"!==t.action)return;const e=this._calculatePickRay(t.screenPoint);w(this.displayBounds.plane,e,C.get())&&(D(this.displayBounds,this.displayBoundsStart),D(this.mapBounds,this.mapBoundsStart),this.displayBoundsMarginStart=this.displayBoundsMargin,this.inputState={type:"resize"})}_createResizeDragPipeline(t,e){return ft(t,((t,i,a)=>{r(this.inputState)||(i.next((t=>("start"===t.action&&this.emit("graphic-scale-start",{graphic:this.graphic,xScale:1,yScale:1}),t))).next(rt(this.view,this.displayBoundsStart.plane)).next((t=>({...t,handle:e}))).next(this._resizeDragRenderPlaneToFactors()).next(this._preserveAspectRatio.createDragEventPipelineStep(),this._preserveAspectRatio.next).next(this._resizeDragUpdateGeometry()).next((t=>{const e={graphic:this.graphic,xScale:t.factor1,yScale:t.factor2};switch(t.action){case"start":case"update":this.emit("graphic-scale",e);break;case"end":this.inputState=null,this.emit("graphic-scale-stop",e)}return t})),a.next((()=>{o(this.inputState)&&this.emit("graphic-scale-stop",{graphic:this.graphic,xScale:1,yScale:1}),this._cancel()})))}))}_resizeDragRenderPlaneToFactors(){return t=>{const e=this.displayBoundsStart,i=t.handle.direction,a=this.displayBoundsMargin,s=this.displayBoundsMarginStart,o=B(C.get(),e.origin);T(o,o,e.basis1,-i[0]),T(o,o,e.basis2,-i[1]);const r=E(C.get(),t.renderEnd,o),n=E(C.get(),t.renderStart,o),p=q(t.handle),l=W(e),h=W(this.displayBounds)/l,c=(t,e)=>{if(0===t)return 1;let i=b(e),o=.5*t*x(e,r)/i;const l=o<0?-1:1;if(p){o+=(i-.5*t*x(e,n)/i)*l*h}const c=i<1.5*s?1:kt;return i=Math.max(i-s,kt),l>0&&(o-=a),l*Math.max(l*(o/i),c)};return{...t,factor1:c(i[0],e.basis1),factor2:c(i[1],e.basis2)}}}_resizeDragUpdateGeometry(){return t=>{const e=B(O(),this.mapBoundsStart.origin);T(e,e,this.mapBoundsStart.basis1,-t.handle.direction[0]),T(e,e,this.mapBoundsStart.basis2,-t.handle.direction[1]);const i=f(M(),this.mapBoundsStart.basis1[0],this.mapBoundsStart.basis1[1]);S(i,i);const a=[];for(const r of this.editGeometryOperations.data.components)a.push(...r.vertices);const s="start"===t.action?Bt.NEW_STEP:Bt.ACCUMULATE_STEPS,o=this.editGeometryOperations.scaleVertices(a,e,i,t.factor1,t.factor2,s,Tt.REPLACE);return D(this.mapBoundsStart,this.mapBounds),xt(o,this.mapBounds),this.graphic.geometry=this.editGeometryOperations.data.geometry,t}}_onRotateGrab(t){if("start"!==t.action)return;const e=J(this.displayBounds,this.view.renderCoordsHelper,K.HEADING,P()),i=this._calculatePickRay(t.screenPoint);w(e,i,C.get())&&(D(this.displayBounds,this.displayBoundsStart),D(this.mapBounds,this.mapBoundsStart),this.inputState={type:"rotate",rotatePlane:e})}_createRotateDragPipeline(t){return ft(t,((t,e,i)=>{const a=this.inputState;r(a)||(e.next((t=>("start"===t.action&&this.emit("graphic-rotate-start",{graphic:this.graphic,angle:0}),t))).next(rt(this.view,a.rotatePlane)).next(this._rotateDragRenderPlaneToRotate(a)).next(this._rotateDragUpdateGeometry()).next((t=>{const e={graphic:this.graphic,angle:s(t.rotateAngle)};switch(t.action){case"start":case"update":this.emit("graphic-rotate",e);break;case"end":this.inputState=null,this.emit("graphic-rotate-stop",e)}return t})),i.next((()=>{o(this.inputState)&&this.emit("graphic-rotate-stop",{graphic:this.graphic,angle:0}),this._cancel()})))}))}_rotateDragRenderPlaneToRotate(t){return e=>{const i=U(t.rotatePlane),a=st(e.renderStart,e.renderEnd,this.displayBounds.origin,i);return{...e,rotateAxis:i,rotateAngle:a}}}_rotateDragUpdateGeometry(){return t=>{const e=B(O(),this.mapBoundsStart.origin),i=[];for(const o of this.editGeometryOperations.data.components)i.push(...o.vertices);const a="start"===t.action?Bt.NEW_STEP:Bt.ACCUMULATE_STEPS,s=this.editGeometryOperations.rotateVertices(i,e,t.rotateAngle,a,Tt.REPLACE);return D(this.mapBoundsStart,this.mapBounds),xt(s,this.mapBounds),this.graphic.geometry=this.editGeometryOperations.data.geometry,t}}_calculatePickRay(t){const e=z(),i=d(t);return vt(this.view.state.camera,i,e),A(e.direction,e.direction),e}_updateManipulators(){if(!this.visible)return;const t=Q(this.displayBounds,I.get());$(this.rotateManipulator,t,this.displayBounds,this.view.renderCoordsHelper),this._updateZMoveHandle(this.moveZManipulator,t),this.resizeManipulators.forEach(((e,i)=>{tt(e,this.resizeHandles[i],t,this.displayBounds)}))}_updateZMoveHandle(t,e){const i=this.displayBounds,a={basis:i.basis1,direction:-1,position:E(C.get(),i.origin,i.basis1),edge:2},s=I.get();v(s,e,a.edge*Math.PI/2),s[12]=0,s[13]=0,s[14]=0,t.modelTransform=s,t.renderLocation=a.position}_cancel(){const t=this.editGeometryOperations.lastOperation;r(t)||(this.editGeometryOperations.undo(),this.graphic.geometry=this.editGeometryOperations.data.geometry,Ot(t,this.mapBounds),this._updateDisplayBounds(),this.inputState=null)}get canUndo(){return this.editGeometryOperations.canUndo}undo(){if(o(this.inputState))this.view.activeTool=null;else if(this.canUndo){const t=this.editGeometryOperations.undo();this.graphic.geometry=this.editGeometryOperations.data.geometry,Ot(p(t),this.mapBounds),this._updateDisplayBounds()}}get canRedo(){return this.editGeometryOperations.canRedo}redo(){if(this.canRedo){const t=this.editGeometryOperations.redo();this.graphic.geometry=this.editGeometryOperations.data.geometry,xt(p(t),this.mapBounds),this._updateDisplayBounds()}}get test(){return{resizeManipulators:this.resizeManipulators,rotateManipulator:this.rotateManipulator,moveZManipulator:this.moveZManipulator}}};t([g({constructOnly:!0,nonNullable:!0})],zt.prototype,"view",void 0),t([g({constructOnly:!0,nonNullable:!0})],zt.prototype,"graphic",void 0),t([g({constructOnly:!0,nonNullable:!0})],zt.prototype,"enableZ",void 0),t([g()],zt.prototype,"enableRotation",void 0),t([g()],zt.prototype,"enableScaling",void 0),t([g({constructOnly:!0,type:jt})],zt.prototype,"tooltipOptions",void 0),t([g()],zt.prototype,"preserveAspectRatio",null),t([g()],zt.prototype,"grabbing",void 0),t([g()],zt.prototype,"inputState",void 0),t([g({readOnly:!0})],zt.prototype,"type",void 0),t([g()],zt.prototype,"_moveUnit",null),zt=t([y("esri.views.3d.interactive.editingTools.graphicTransform3D.ExtentTransformTool")],zt);const Zt="draped-elevation-changes",Ct=10,It=80,kt=1e-6,Lt=M();export{kt as EPSILON,zt as ExtentTransformTool};
5
+ import{_ as t}from"../../../../../chunks/tslib.es6.js";import e from"../../../../../core/Evented.js";import i from"../../../../../core/Handles.js";import{makeHandle as a}from"../../../../../core/handleUtils.js";import{rad2deg as s}from"../../../../../core/mathUtils.js";import{isSome as o,unwrapOr as r,isNone as n,unwrap as p}from"../../../../../core/maybe.js";import{createLength as l}from"../../../../../core/quantityUtils.js";import{watch as h,initial as c}from"../../../../../core/reactiveUtils.js";import{screenPointObjectToArray as d}from"../../../../../core/screenUtils.js";import{lengthUnitFromSpatialReference as u,getMetersPerUnitForSR as m}from"../../../../../core/unitUtils.js";import{property as g}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import"../../../../../core/accessorSupport/ensureType.js";import{subclass as y}from"../../../../../core/accessorSupport/decorators/subclass.js";import{g as v}from"../../../../../chunks/mat4.js";import{a as f,g as _,i as S}from"../../../../../chunks/vec2.js";import{a as M}from"../../../../../chunks/vec2f64.js";import{c as b,C as T,b as B,n as E,l as x,e as A}from"../../../../../chunks/vec3.js";import{c as O,a as R}from"../../../../../chunks/vec3f64.js";import{containsXY as j}from"../../../../../geometry/support/aaBoundingRect.js";import{c as G,a as z}from"../../../../../chunks/boundedPlane.js";import{intersectRay as D,create as w,normal as P}from"../../../../../geometry/support/plane.js";import{create as I}from"../../../../../geometry/support/ray.js";import{sv2d as U,sv3d as Z,sm4d as C}from"../../../../../geometry/support/vectorStacks.js";import{getGraphicEffectiveElevationInfo as k}from"../../../../../support/elevationInfoUtils.js";import{createShiftManipulator as X,OffsetMode as Y,IsShiftEdgeOnScreenFlag as L,createResizeManipulator as N,createRotateManipulator as V,resizeNormal as H,resizeOutlineOnly as F,isDiagonalResizeHandle as q,calculateDiagonalResizeHandleScale as W,createRotatePlane as J,RotationAxis as K,calculateBoundedPlaneTranslateRotate as Q,updateRotateHeadingHandle as $,updateResizeHandle as tt}from"../../../analysis/Slice/sliceToolUtils.js";import{getRotateHeadingTexture as et}from"../../../analysis/Slice/images/Factory.js";import{Manipulator3D as it}from"../../Manipulator3D.js";import{getGraphicAttachmentOrigin as at,calculateInputRotationTransform as st}from"../../manipulatorUtils.js";import{screenToZConstrained as ot,screenToRenderPlane as rt}from"../dragEventPipeline3D.js";import{ManipulatorType as nt}from"../ManipulatorType.js";import{canMoveZ as pt}from"../manipulatorUtils.js";import{createVisualElements as lt}from"../visualElementUtils.js";import{ManipulationType as ht}from"../manipulations/MoveManipulation.js";import{MoveXYGraphicManipulation as ct}from"../manipulations/MoveXYGraphicManipulation.js";import{PreserveAspectRatio as dt}from"./PreserveAspectRatio.js";import{OutlineVisualElement as ut}from"../../visualElements/OutlineVisualElement.js";import{evaluateElevationAlignmentAtPoint as mt}from"../../../layers/graphics/elevationAlignmentUtils.js";import{ElevationContext as gt}from"../../../layers/graphics/ElevationContext.js";import{GraphicState as yt}from"../../../layers/graphics/GraphicState.js";import{fromScreen as vt}from"../../../support/geometryUtils/ray.js";import{createManipulatorDragEventPipeline as ft,addMapDelta as _t,addScreenDelta as St}from"../../../../interactive/dragEventPipeline.js";import{InteractiveToolBase as Mt}from"../../../../interactive/InteractiveToolBase.js";import{EditGeometryOperations as bt}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import{AccumulationBehaviour as Tt}from"../../../../interactive/editGeometry/interfaces.js";import{AccumulationType as Bt}from"../../../../interactive/editGeometry/operations/UpdateVertices.js";import{mapPlaneEuclideanHorizontalSize as Et,calculateOrientedBounds as xt,mapPlaneToRenderPlane as At,apply as Ot,unapply as Rt}from"../../../../interactive/editGeometry/support/editPlaneUtils.js";import jt from"../../../../interactive/sketch/SketchTooltipOptions.js";import{ExtentRotateTooltipInfo as Gt,ExtentScaleTooltipInfo as zt}from"../../../../interactive/tooltip/ExtentTooltipInfos.js";import{Tooltip as Dt}from"../../../../interactive/tooltip/Tooltip.js";import{TranslateGraphicTooltipInfo as wt,TranslateZTooltipInfo as Pt}from"../../../../interactive/tooltip/TranslateTooltipInfos.js";import{verticalSignedDistance as It,euclideanHorizontalDistanceBetweenPoints as Ut}from"../../../../support/euclideanLengthMeasurementUtils.js";let Zt=class extends(e.EventedMixin(Mt)){constructor(t){super(t),this.enableZ=!0,this.enableRotation=!0,this.enableScaling=!0,this.tooltipOptions=new jt,this._preserveAspectRatio=new dt,this.grabbing=!1,this.inputState=null,this.type="transform-3d",this.handles=new i,this.moveZManipulator=null,this.resizeManipulators=null,this.rotateManipulator=null,this.attachmentOrigin=null,this.outlineVisualElement=null,this.mapBounds=G(),this.mapBoundsStart=G(),this.zmax=0,this.sizeStart=null,this.displayBounds=G(),this.displayBoundsStart=G(),this.displayBoundsMarginStart=0,this.resizeHandles=[{direction:[1,0]},{direction:[1,1]},{direction:[0,1]},{direction:[-1,1]},{direction:[-1,0]},{direction:[-1,-1]},{direction:[0,-1]},{direction:[1,-1]}],this._moveXYTooltipInfo=null,this._moveZTooltipInfo=null,this._rotateTooltipInfo=null,this._scaleTooltipInfo=null,this._startAngle=0,this._endAngle=0,this._startScale=M(),this._endScale=M()}initialize(){const{view:t,graphic:e,manipulators:i,handles:s}=this,r=this.graphicState=new yt({graphic:e}),n=e.geometry;this.editGeometryOperations=bt.fromGeometry(n,t.state.viewingMode),this.graphicMoveManipulation=new ct({tool:this,view:t,graphicState:r}),this.moveZManipulator=X(t,Y.CENTER_ON_CALLOUT),this.moveZManipulator.state|=L,s.add([this._createMoveXYGraphicDragPipeline(),h((()=>this.enableZ),(()=>this._updateManipulatorAvailability(this.moveZManipulator,nt.TRANSLATE_Z))),this._createMoveZDragPipeline()]),i.add(this.moveZManipulator),this.resizeManipulators=this.resizeHandles.map((e=>{const i=N(t,e);return s.add([h((()=>this.enableScaling),(()=>this._updateManipulatorAvailability(i,nt.SCALE))),i.events.on("grab-changed",(t=>this._onResizeGrab(t))),this._createResizeDragPipeline(i,e)]),i})),i.addMany(this.resizeManipulators),this.rotateManipulatorTexture=et(t.toolViewManager.textures),this.rotateManipulator=V(t,this.rotateManipulatorTexture.texture),s.add([h((()=>this.enableRotation),(()=>this._updateManipulatorAvailability(this.rotateManipulator,nt.ROTATE))),this.rotateManipulator.events.on("grab-changed",(t=>{this._onRotateGrab(t)})),this._createRotateDragPipeline(this.rotateManipulator)]),i.add(this.rotateManipulator),this._calculateMapBounds(),this._updateDisplayBounds();const p=lt({view:t,graphic:e,forEachManipulator:t=>this._forEachManipulator(t),onManipulatorsChanged:()=>a()});o(p)&&(this.outlineVisualElement=p.visualElement instanceof ut?p.visualElement:null),o(this.outlineVisualElement)&&s.add(this.outlineVisualElement.events.on("attachment-origin-changed",(()=>this._updateDisplayBounds()))),s.add(p),s.add([r.on("changed",(()=>this._onGeometryChanged())),h((()=>r.displaying),(()=>this._updateAllManipulatorAvailability())),h((()=>r.isDraped),(()=>this._graphicDrapedChanged()),c),t.trackGraphicState(r)]);const l=t.pointsOfInterest;l&&s.add(h((()=>l.centerOnSurfaceFrequent.location),(()=>this._updateDisplayBounds())));const d=t=>{s.add(t.events.on("grab-changed",(()=>{this.grabbing=t.grabbing,this._updateAllManipulatorAvailability()})))};this._forEachManipulator(d);const u=(t,i)=>{s.add(t.events.on("immediate-click",(t=>{i===nt.TRANSLATE_XY&&this.emit("immediate-click",{...t,graphic:e}),t.stopPropagation()})))};this._forEachManipulator(u),this._onGeometryChanged(),this._updateAllManipulatorAvailability(),this._initializeTooltip(),this.finishToolCreation()}destroy(){this.mapBounds=null,this.displayBounds=null,this.rotateManipulatorTexture.release(),this.handles.destroy(),this.graphicMoveManipulation.destroy(),this.editGeometryOperations.destroy(),this._tooltip.destroy(),this._set("view",null),this._set("graphic",null)}_initializeTooltip(){const{handles:t,view:e}=this,i=this._tooltip=new Dt({view:e}),a=()=>{i.info=this._getUpdatedTooltipInfo()};t.add([this.on("graphic-translate-start",a),this.on("graphic-translate",a),this.on("graphic-translate-stop",a),this.on("graphic-rotate-start",(t=>{this._startAngle=t.angle,a()})),this.on("graphic-rotate",(t=>{this._endAngle=t.angle,a()})),this.on("graphic-rotate-stop",(()=>{this._startAngle=0,this._endAngle=0,a()})),this.on("graphic-scale-start",(t=>{f(this._startScale,t.xScale,t.yScale),f(this._endScale,t.xScale,t.yScale),a()})),this.on("graphic-scale",(t=>{f(this._endScale,t.xScale,t.yScale),a()})),this.on("graphic-scale-stop",(()=>{f(this._startScale,0,0),f(this._endScale,0,0),a()}))]),this._forEachManipulator((e=>{t.add([e.events.on("focus-changed",a),e.events.on("grab-changed",a),e.events.on("drag",a)])}))}_getUpdatedTooltipInfo(){return this.tooltipOptions.enabled?this.graphicMoveManipulation.grabbing||this.graphicMoveManipulation.dragging?this._computeMoveXYTooltipInfo():this.moveZManipulator.focused?this._computeMoveZTooltipInfo():this.rotateManipulator.focused?this._computeRotateTooltipInfo():this.resizeManipulators.some((t=>t.focused))?this._computeScaleTooltipInfo():null:null}_computeMoveXYTooltipInfo(){return this._moveXYTooltipInfo=r(this._moveXYTooltipInfo,(()=>new wt({tooltipOptions:this.tooltipOptions})))}_computeMoveZTooltipInfo(){const t=this._moveZTooltipInfo=r(this._moveZTooltipInfo,(()=>new Pt({tooltipOptions:this.tooltipOptions}))),e=this._moveUnit;if(this.moveZManipulator.dragging){const e=this.mapBoundsStart.origin,i=this.mapBounds.origin,a=It(e,i,this.view.spatialReference);if(n(a))return null;t.distance=a}else t.distance=l(0,e);return t}_computeRotateTooltipInfo(){const t=this._rotateTooltipInfo=r(this._rotateTooltipInfo,(()=>new Gt({tooltipOptions:this.tooltipOptions})));return t.angle=this._startAngle-this._endAngle,t}_computeScaleTooltipInfo(){const t=this.graphic.geometry;if(n(t))return null;const e=this._scaleTooltipInfo=r(this._scaleTooltipInfo,(()=>new zt({tooltipOptions:this.tooltipOptions}))),i=Et(this.mapBounds,this.zmax,t.spatialReference);return n(i)?null:(e.xSize=i[0],e.ySize=i[1],o(this.sizeStart)&&this.resizeManipulators.some((t=>t.dragging))?(e.xScale=i[0].value/this.sizeStart[0].value,e.yScale=i[1].value/this.sizeStart[1].value):(e.xScale=1,e.yScale=1),e)}_graphicDrapedChanged(){this.handles.remove(Ct),this._updateDisplayBounds(),this.graphicState.isDraped&&this.handles.add(this.view.elevationProvider.on("elevation-change",(t=>{o(this.attachmentOrigin)&&j(t.extent,this.attachmentOrigin.x,this.attachmentOrigin.y)&&this._updateDisplayBounds()})),Ct)}_updateAllManipulatorAvailability(){this._forEachManipulator(((t,e)=>this._updateManipulatorAvailability(t,e)))}_updateManipulatorAvailability(t,e){const i=this.grabbing&&!t.grabbing;if(t.interactive=!i,t instanceof it){const a=this.graphicState.displaying,s=this.enableZ&&pt(this.graphic);switch(e){case nt.ROTATE:t.available=a&&this.enableRotation;break;case nt.SCALE:t.available=a&&(this.enableScaling||this.enableRotation||s),t.interactive=!i&&this.enableScaling,t.state=this.enableScaling?H:F;break;case nt.TRANSLATE_Z:t.available=a&&s;break;default:t.available=a}}}_forEachManipulator(t){this.graphicMoveManipulation.forEachManipulator(t),this.resizeManipulators.forEach((e=>t(e,nt.SCALE))),t(this.rotateManipulator,nt.ROTATE),t(this.moveZManipulator,nt.TRANSLATE_Z)}get preserveAspectRatio(){return this._preserveAspectRatio.enabled}set preserveAspectRatio(t){this._preserveAspectRatio.enabled=t,this._set("preserveAspectRatio",t)}get _moveUnit(){return r(u(this.view.spatialReference),"meters")}reset(){}_onGeometryChanged(){this._updateDisplayBounds()}_calculateMapBounds(){const t=this.graphic.geometry,e=this.editGeometryOperations.data,i=e.components[0].edges[0],a=_(U.get(),i.leftVertex.pos,i.rightVertex.pos);S(a,a);const s=r(at(this.view,this.graphic),(()=>t.extent.center));let o=Xt*this.view.pixelSizeAt(s);const n=this.view.spatialReference,p=t.spatialReference;n.equals(p)||(o*=m(n)/m(p)),xt(a,e,o,this.mapBounds),this._calculateZMax()}_calculateZMax(){const t=this.editGeometryOperations.data;if(!t.geometry.hasZ)return void(this.zmax=0);const e=t.coordinateHelper;let i=Number.NEGATIVE_INFINITY;for(const a of t.components)for(const t of a.vertices){const a=e.getZ(t.pos);i=Math.max(a,i)}this.zmax=i}_updateDisplayBounds(){const t=this.graphic.geometry;if(n(t))return;const e=o(this.outlineVisualElement)&&!this.graphicState.isDraped&&o(this.outlineVisualElement.attachmentOrigin)?this.outlineVisualElement.attachmentOrigin:at(this.view,this.graphic);this.attachmentOrigin=r(e,t.extent.center);const i=o(e)?e.z:mt(this.mapBounds.origin,this.view.elevationProvider,gt.fromElevationInfo(k(this.graphic)),this.view.renderCoordsHelper),a=z(this.mapBounds);a.origin[2]=i,At(a,this.view.renderCoordsHelper,t.spatialReference,this.displayBoundsMargin,this.displayBounds),this._updateManipulators()}get displayBoundsMargin(){const t=this.view.pointsOfInterest,e=t?t.centerOnSurfaceFrequent.location:this.editGeometryOperations.data.geometry.extent.center;return kt*this.view.pixelSizeAt(e)}_createMoveXYGraphicDragPipeline(){return this.graphicMoveManipulation.createDragPipeline(((t,e,i)=>this._applyGraphicMoveSteps(e,i,ht.XY)))}_createMoveZDragPipeline(){const t=this.view,e=this.editGeometryOperations.data.spatialReference;return ft(this.moveZManipulator,((i,a,s)=>{const o=R(i.renderLocation),r=a.next(ot(t,o,e)).next(St());this._applyGraphicMoveSteps(r,s,ht.Z)}))}_applyGraphicMoveSteps(t,e,i){const a=t.next((t=>("start"===t.action&&(this.inputState={type:"move"},z(this.mapBounds,this.mapBoundsStart),this._calculateSizeStart(),this.emit("graphic-translate-start",{graphic:this.graphic,dxScreen:t.screenDeltaX,dyScreen:t.screenDeltaY})),t))).next(_t()).next(this._moveDragUpdateGeometry()).next((t=>{const e={graphic:this.graphic,dxScreen:t.screenDeltaX,dyScreen:t.screenDeltaY};switch(t.action){case"start":case"update":(t.mapEnd.x-t.mapStart.x||t.mapEnd.y-t.mapStart.y||t.mapEnd.z-t.mapStart.z)&&this.emit("graphic-translate",e);break;case"end":this.inputState=null,this.emit("graphic-translate-stop",e)}return t})).next((t=>this._updateMoveTooltip(t,i)));return e.next((()=>{o(this.inputState)&&this.emit("graphic-translate-stop",{graphic:this.graphic,dxScreen:0,dyScreen:0}),this._cancel()})),a}_calculateSizeStart(){n(this.graphic.geometry)?this.sizeStart=null:this.sizeStart=Et(this.mapBoundsStart,this.zmax,this.graphic.geometry.spatialReference)}_moveDragUpdateGeometry(){return t=>{if(n(this.inputState)||"move"!==this.inputState.type)return t;const e=[];for(const s of this.editGeometryOperations.data.components)e.push(...s.vertices);const i="start"===t.action?Tt.NEW_STEP:Tt.ACCUMULATE_STEPS,a=this.editGeometryOperations.moveVertices(e,t.mapDeltaX,t.mapDeltaY,t.mapDeltaZ,i);return Ot(a,this.mapBounds),this.graphic.geometry=this.editGeometryOperations.data.geometry,t}}_updateMoveTooltip(t,e){if(e===ht.XY||e===ht.XY_AXIS){const e=Ut(t.mapStart,t.mapEnd);o(e)&&o(this._moveXYTooltipInfo)&&(this._moveXYTooltipInfo.distance=e)}return t}_onResizeGrab(t){if("start"!==t.action)return;const e=this._calculatePickRay(t.screenPoint);D(this.displayBounds.plane,e,Z.get())&&(z(this.displayBounds,this.displayBoundsStart),z(this.mapBounds,this.mapBoundsStart),this._calculateSizeStart(),this.displayBoundsMarginStart=this.displayBoundsMargin,this.inputState={type:"resize"})}_createResizeDragPipeline(t,e){return ft(t,((t,i,a)=>{n(this.inputState)||(i.next((t=>("start"===t.action&&this.emit("graphic-scale-start",{graphic:this.graphic,xScale:1,yScale:1}),t))).next(rt(this.view,this.displayBoundsStart.plane)).next((t=>({...t,handle:e}))).next(this._resizeDragRenderPlaneToFactors()).next(this._preserveAspectRatio.createDragEventPipelineStep(),this._preserveAspectRatio.next).next(this._resizeDragUpdateGeometry()).next((t=>{const e={graphic:this.graphic,xScale:t.factor1,yScale:t.factor2};switch(t.action){case"start":case"update":this.emit("graphic-scale",e);break;case"end":this.inputState=null,this.emit("graphic-scale-stop",e)}return t})),a.next((()=>{o(this.inputState)&&this.emit("graphic-scale-stop",{graphic:this.graphic,xScale:1,yScale:1}),this._cancel()})))}))}_resizeDragRenderPlaneToFactors(){return t=>{const e=this.displayBoundsStart,i=t.handle.direction,a=this.displayBoundsMargin,s=this.displayBoundsMarginStart,o=b(Z.get(),e.origin);T(o,o,e.basis1,-i[0]),T(o,o,e.basis2,-i[1]);const r=B(Z.get(),t.renderEnd,o),n=B(Z.get(),t.renderStart,o),p=q(t.handle),l=W(e),h=W(this.displayBounds)/l,c=(t,e)=>{if(0===t)return 1;let i=x(e),o=.5*t*A(e,r)/i;const l=o<0?-1:1;if(p){o+=(i-.5*t*A(e,n)/i)*l*h}const c=i<1.5*s?1:Yt;return i=Math.max(i-s,Yt),l>0&&(o-=a),l*Math.max(l*(o/i),c)};return{...t,factor1:c(i[0],e.basis1),factor2:c(i[1],e.basis2)}}}_resizeDragUpdateGeometry(){return t=>{const e=b(O(),this.mapBoundsStart.origin);T(e,e,this.mapBoundsStart.basis1,-t.handle.direction[0]),T(e,e,this.mapBoundsStart.basis2,-t.handle.direction[1]);const i=f(M(),this.mapBoundsStart.basis1[0],this.mapBoundsStart.basis1[1]);S(i,i);const a=[];for(const r of this.editGeometryOperations.data.components)a.push(...r.vertices);const s="start"===t.action?Tt.NEW_STEP:Tt.ACCUMULATE_STEPS,o=this.editGeometryOperations.scaleVertices(a,e,i,t.factor1,t.factor2,s,Bt.REPLACE);return z(this.mapBoundsStart,this.mapBounds),Ot(o,this.mapBounds),this.graphic.geometry=this.editGeometryOperations.data.geometry,t}}_onRotateGrab(t){if("start"!==t.action)return;const e=J(this.displayBounds,this.view.renderCoordsHelper,K.HEADING,w()),i=this._calculatePickRay(t.screenPoint);D(e,i,Z.get())&&(z(this.displayBounds,this.displayBoundsStart),z(this.mapBounds,this.mapBoundsStart),this._calculateSizeStart(),this.inputState={type:"rotate",rotatePlane:e})}_createRotateDragPipeline(t){return ft(t,((t,e,i)=>{const a=this.inputState;n(a)||(e.next((t=>("start"===t.action&&this.emit("graphic-rotate-start",{graphic:this.graphic,angle:0}),t))).next(rt(this.view,a.rotatePlane)).next(this._rotateDragRenderPlaneToRotate(a)).next(this._rotateDragUpdateGeometry()).next((t=>{const e={graphic:this.graphic,angle:s(t.rotateAngle)};switch(t.action){case"start":case"update":this.emit("graphic-rotate",e);break;case"end":this.inputState=null,this.emit("graphic-rotate-stop",e)}return t})),i.next((()=>{o(this.inputState)&&this.emit("graphic-rotate-stop",{graphic:this.graphic,angle:0}),this._cancel()})))}))}_rotateDragRenderPlaneToRotate(t){return e=>{const i=P(t.rotatePlane),a=st(e.renderStart,e.renderEnd,this.displayBounds.origin,i);return{...e,rotateAxis:i,rotateAngle:a}}}_rotateDragUpdateGeometry(){return t=>{const e=b(O(),this.mapBoundsStart.origin),i=[];for(const o of this.editGeometryOperations.data.components)i.push(...o.vertices);const a="start"===t.action?Tt.NEW_STEP:Tt.ACCUMULATE_STEPS,s=this.editGeometryOperations.rotateVertices(i,e,t.rotateAngle,a,Bt.REPLACE);return z(this.mapBoundsStart,this.mapBounds),Ot(s,this.mapBounds),this.graphic.geometry=this.editGeometryOperations.data.geometry,t}}_calculatePickRay(t){const e=I(),i=d(t);return vt(this.view.state.camera,i,e),E(e.direction,e.direction),e}_updateManipulators(){if(!this.visible)return;const t=Q(this.displayBounds,C.get());$(this.rotateManipulator,t,this.displayBounds,this.view.renderCoordsHelper),this._updateZMoveHandle(this.moveZManipulator,t),this.resizeManipulators.forEach(((e,i)=>{tt(e,this.resizeHandles[i],t,this.displayBounds)}))}_updateZMoveHandle(t,e){const i=this.displayBounds,a={basis:i.basis1,direction:-1,position:B(Z.get(),i.origin,i.basis1),edge:2},s=C.get();v(s,e,a.edge*Math.PI/2),s[12]=0,s[13]=0,s[14]=0,t.modelTransform=s,t.renderLocation=a.position}_cancel(){const t=this.editGeometryOperations.lastOperation;n(t)||(this.editGeometryOperations.undo(),this.graphic.geometry=this.editGeometryOperations.data.geometry,Rt(t,this.mapBounds),this._updateDisplayBounds(),this.inputState=null)}get canUndo(){return this.editGeometryOperations.canUndo}undo(){if(o(this.inputState))this.view.activeTool=null;else if(this.canUndo){const t=this.editGeometryOperations.undo();this.graphic.geometry=this.editGeometryOperations.data.geometry,Rt(p(t),this.mapBounds),this._updateDisplayBounds()}}get canRedo(){return this.editGeometryOperations.canRedo}redo(){if(this.canRedo){const t=this.editGeometryOperations.redo();this.graphic.geometry=this.editGeometryOperations.data.geometry,Ot(p(t),this.mapBounds),this._updateDisplayBounds()}}get test(){return{resizeManipulators:this.resizeManipulators,rotateManipulator:this.rotateManipulator,moveZManipulator:this.moveZManipulator,tooltip:this._tooltip}}};t([g({constructOnly:!0,nonNullable:!0})],Zt.prototype,"view",void 0),t([g({constructOnly:!0,nonNullable:!0})],Zt.prototype,"graphic",void 0),t([g({constructOnly:!0,nonNullable:!0})],Zt.prototype,"enableZ",void 0),t([g()],Zt.prototype,"enableRotation",void 0),t([g()],Zt.prototype,"enableScaling",void 0),t([g({constructOnly:!0,type:jt})],Zt.prototype,"tooltipOptions",void 0),t([g()],Zt.prototype,"preserveAspectRatio",null),t([g()],Zt.prototype,"grabbing",void 0),t([g()],Zt.prototype,"inputState",void 0),t([g({readOnly:!0})],Zt.prototype,"type",void 0),t([g()],Zt.prototype,"_moveUnit",null),Zt=t([y("esri.views.3d.interactive.editingTools.graphicTransform3D.ExtentTransformTool")],Zt);const Ct="draped-elevation-changes",kt=10,Xt=80,Yt=1e-6;export{Yt as EPSILON,Zt as ExtentTransformTool};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../../../chunks/tslib.es6.js";import e from"../../../../../core/Evented.js";import{HandleOwnerMixin as i}from"../../../../../core/HandleOwner.js";import{makeHandle as a}from"../../../../../core/handleUtils.js";import{isSome as o,destroyMaybe as s,isNone as n}from"../../../../../core/maybe.js";import{watch as r}from"../../../../../core/reactiveUtils.js";import{property as p}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import"../../../../../core/accessorSupport/ensureType.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import c from"../../../../../geometry/Point.js";import{getGraphicEffectiveElevationInfo as h}from"../../../../../support/elevationInfoUtils.js";import{ViewingMode as m}from"../../../../ViewingMode.js";import{Manipulator3D as d}from"../../Manipulator3D.js";import{placeAtGraphic as u}from"../../manipulatorUtils.js";import{SnappingVisualizer3D as g}from"../../SnappingVisualizer3D.js";import{ManipulatorType as v}from"../ManipulatorType.js";import{canMoveZ as _}from"../manipulatorUtils.js";import{createVisualElements as f}from"../visualElementUtils.js";import{ALIGN_ARROWS_SCALE_THRESHOLD as M}from"../manipulations/config.js";import{MoveManipulation as y,ManipulationType as S}from"../manipulations/MoveManipulation.js";import{GraphicScaleRotateTransform as R}from"./GraphicScaleRotateTransform.js";import{ScaleRotateMeshAdapter as b}from"./ScaleRotateMeshAdapter.js";import{ScaleRotateObjectSymbol3DAdapter as w}from"./ScaleRotateObjectSymbol3DAdapter.js";import{createGraphicGeometryUndoRecord as j}from"./undoRecords.js";import{GraphicState as A}from"../../../layers/graphics/GraphicState.js";import{InteractiveToolBase as O}from"../../../../interactive/InteractiveToolBase.js";import{EditGeometryOperations as T}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import x from"../../../../interactive/sketch/SketchTooltipOptions.js";import{SnappingContext as G}from"../../../../interactive/snapping/SnappingContext.js";import{SnappingPipeline as E}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{Tooltip as z}from"../../../../interactive/tooltip/Tooltip.js";import{TranslateZTooltipInfo as U,TranslateGraphicTooltipInfo as C}from"../../../../interactive/tooltip/TranslateTooltipInfos.js";import{euclideanHorizontalDistanceBetweenPoints as P}from"../../../../support/lengthMeasurementUtils.js";let k=class extends(i(e.EventedMixin(O))){constructor(t){super(t),this.enableZ=!0,this.enableRotation=!0,this.enableScaling=!0,this.tooltipOptions=new x,this.type="transform-3d",this._scaleRotate=null,this._snappingPipeline=new E}initialize(){const{graphic:t,view:e}=this;this.graphicState=new A({graphic:t}),this._tooltip=new z({view:e}),this._moveManipulation=new y({tool:this,view:e,snapToScene:this.snapToScene,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:this.enableZ&&_(t),radius:y.radiusForSymbol(t.symbol)}),this._moveManipulation.forEachManipulator(((e,i)=>this.handles.add([e.events.on("immediate-click",(e=>{this.emit("immediate-click",{...e,graphic:t}),e.stopPropagation()})),e.events.on("focus-changed",(({action:t})=>{const{tooltipOptions:e}=this;"focus"===t&&e.enabled?this._tooltip.info=new(i===v.TRANSLATE_Z?U:C)({tooltipOptions:e}):this._tooltip.clear()}))]))),this._moveManipulation.elevationInfo=h(t);const i=t.geometry;if(this._moveManipulation.createGraphicDragPipeline(((a,s,n,r,p)=>(o(i)&&a===S.XY&&(n=n.next(this._snappingPipeline.createSnapDragEventPipelineStep({snappingContext:new G({elevationInfo:h(t),pointer:p,editGeometryOperations:T.fromGeometry(new c({spatialReference:i.spatialReference}),e.state.viewingMode),visualizer:new g,excludeFeature:t}),snappingManager:this.snappingManager,updatingHandles:this.updatingHandles,cancel:r}),this._snappingPipeline.next)),n=n.next((t=>{const e=P(t.mapStart,t.mapEnd),{tooltipOptions:i}=this;return o(e)&&i.enabled?this._tooltip.info=new(a===S.Z?U:C)({tooltipOptions:i,distance:e}):this._tooltip.clear(),t})))),this.graphicState,(t=>{const{action:e,graphic:i,dxScreen:a,dyScreen:o}=t,s={graphic:i,dxScreen:a,dyScreen:o};switch(e){case"start":this.emit("graphic-translate-start",s),this.emit("record-undo",{record:this._createGeometryUndoRecord()});break;case"update":this.emit("graphic-translate",s);break;case"end":this.emit("graphic-translate-stop",s)}})),this._moveManipulation.angle=o(this._scaleRotate)?this._scaleRotate.angle:0,this._scaleRotateAdapter=this._createScaleRotateAdapter(),this.handles.add(r((()=>this._scaleRotateAdapter.angle),(()=>this._updateMoveAngle()))),this.enableScaling||this.enableRotation){const t=this.enableScaling&&this.enableRotation?null:this.enableScaling?"scale":"rotate";this._scaleRotate=new R({tool:this,mode:t,adapter:this._scaleRotateAdapter,tooltipOptions:this.tooltipOptions}),this.handles.add(this._scaleRotate.events.on("scale-changed",(()=>this._onScaleChanged())))}this.handles.add([f({view:this.view,graphic:this.graphic,forEachManipulator:t=>this._forEachManipulator(t),onManipulatorsChanged:()=>a()}),this.graphicState.on("changed",(()=>this._onGeometryChanged())),this._hideManipulatorsForGraphicState(),r((()=>e.scale),(()=>this._updateMoveAngle()))]),this.handles.add(this.view.trackGraphicState(this.graphicState)),this._onGeometryChanged(),this._updateMoveAngle(),this._forEachManipulator((t=>{t instanceof d&&this.handles.add(t.events.on("grab-changed",(()=>this._updateManipulatorsInteractive())))})),this.finishToolCreation()}destroy(){this._tooltip=s(this._tooltip),this._moveManipulation.destroy(),this._scaleRotate=s(this._scaleRotate),this._scaleRotateAdapter=s(this._scaleRotateAdapter),this._set("view",null),this._set("graphic",null)}_updateManipulatorsInteractive(){n(this._scaleRotate)||(this._scaleRotate.interactive=!this._moveManipulation.grabbing,this._moveManipulation.interactive=!this._scaleRotate.grabbing)}_createScaleRotateAdapter(){return o(this.graphic.geometry)&&"mesh"===this.graphic.geometry.type?new b({graphic:this.graphic,geometry:this.graphic.geometry,viewingMode:this.view.state.viewingMode}):new w({graphic:this.graphic,sizeFilter:t=>this._enforceNonZeroSize(t),findLayerView:()=>this.view.allLayerViews.find((t=>t.layer===this.graphic.layer)),sizeAxis:o(this.tooltipOptions.visualVariables)&&o(this.tooltipOptions.visualVariables.size)?this.tooltipOptions.visualVariables.size.axis:null})}_forEachManipulator(t){this._moveManipulation.forEachManipulator(t),o(this._scaleRotate)&&this._scaleRotate.forEachManipulator(t)}_hideManipulatorsForGraphicState(){return r((()=>this.graphicState.displaying),(t=>{this._forEachManipulator((e=>e.available=t)),this._moveManipulation.zManipulation.available=t&&this.enableZ&&_(this.graphic)}))}_createGeometryUndoRecord(){return j(this.graphic)}set snapToScene(t){this._moveManipulation&&(this._moveManipulation.snapToScene=t),this._set("snapToScene",t)}get updating(){return this.updatingHandles.updating}set location(t){this._moveManipulation.location=t,o(this._scaleRotate)&&(this._scaleRotate.location=t)}set elevationAlignedLocation(t){this._moveManipulation.elevationAlignedLocation=t,o(this._scaleRotate)&&(this._scaleRotate.elevationAlignedLocation=t)}reset(){}onHide(){o(this._scaleRotate)&&this._scaleRotate.cancelActiveAnimation()}_onScaleChanged(){if(n(this._scaleRotate))return;const t=this._scaleRotate.getScale();this._moveManipulation.displayScale=t}_updateMoveAngle(){this.view.state.viewingMode===m.Local||this.view.scale<M?this._moveManipulation.angle=this._scaleRotateAdapter.angle:this._moveManipulation.angle=0}_onGeometryChanged(){u(this.view,this,this.graphic)}_enforceNonZeroSize(t){return t||this.view.state.camera.computeRenderPixelSizeAt(this._moveManipulation.renderLocation)}get test(){return{discManipulator:this._moveManipulation.xyManipulation.test.discManipulator,zManipulator:this._moveManipulation.zManipulation.test.manipulator,ringManipulator:o(this._scaleRotate)?this._scaleRotate.test.ringManipulator:null,arrowManipulators:this._moveManipulation.xyAxisManipulation.test.arrowManipulators,scaleRotateAdapter:this._scaleRotateAdapter,scaleRotateTransform:this._scaleRotate}}};t([p({constructOnly:!0,nonNullable:!0})],k.prototype,"view",void 0),t([p({constructOnly:!0,nonNullable:!0})],k.prototype,"graphic",void 0),t([p({constructOnly:!0,nonNullable:!0})],k.prototype,"enableZ",void 0),t([p()],k.prototype,"enableRotation",void 0),t([p()],k.prototype,"enableScaling",void 0),t([p({constructOnly:!0,type:x})],k.prototype,"tooltipOptions",void 0),t([p()],k.prototype,"graphicState",void 0),t([p({value:!1})],k.prototype,"snapToScene",null),t([p({constructOnly:!0})],k.prototype,"snappingManager",void 0),t([p({readOnly:!0})],k.prototype,"type",void 0),t([p({readOnly:!0})],k.prototype,"updating",null),k=t([l("esri.views.3d.interactive.editingTools.graphicTransform3D.GraphicTransformTool")],k);export{k as GraphicTransformTool};
5
+ import{_ as t}from"../../../../../chunks/tslib.es6.js";import e from"../../../../../core/Evented.js";import{HandleOwnerMixin as i}from"../../../../../core/HandleOwner.js";import{makeHandle as a}from"../../../../../core/handleUtils.js";import{isSome as o,destroyMaybe as s,isNone as n}from"../../../../../core/maybe.js";import{watch as r}from"../../../../../core/reactiveUtils.js";import{property as p}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import"../../../../../core/accessorSupport/ensureType.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import c from"../../../../../geometry/Point.js";import{getGraphicEffectiveElevationInfo as h}from"../../../../../support/elevationInfoUtils.js";import{ViewingMode as m}from"../../../../ViewingMode.js";import{Manipulator3D as d}from"../../Manipulator3D.js";import{placeAtGraphic as u}from"../../manipulatorUtils.js";import{SnappingVisualizer3D as g}from"../../SnappingVisualizer3D.js";import{ManipulatorType as v}from"../ManipulatorType.js";import{canMoveZ as _}from"../manipulatorUtils.js";import{createVisualElements as f}from"../visualElementUtils.js";import{ALIGN_ARROWS_SCALE_THRESHOLD as M}from"../manipulations/config.js";import{MoveManipulation as y,ManipulationType as S}from"../manipulations/MoveManipulation.js";import{GraphicScaleRotateTransform as R}from"./GraphicScaleRotateTransform.js";import{ScaleRotateMeshAdapter as b}from"./ScaleRotateMeshAdapter.js";import{ScaleRotateObjectSymbol3DAdapter as w}from"./ScaleRotateObjectSymbol3DAdapter.js";import{createGraphicGeometryUndoRecord as j}from"./undoRecords.js";import{GraphicState as A}from"../../../layers/graphics/GraphicState.js";import{InteractiveToolBase as O}from"../../../../interactive/InteractiveToolBase.js";import{EditGeometryOperations as T}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import x from"../../../../interactive/sketch/SketchTooltipOptions.js";import{SnappingContext as G}from"../../../../interactive/snapping/SnappingContext.js";import{SnappingPipeline as E}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{Tooltip as z}from"../../../../interactive/tooltip/Tooltip.js";import{TranslateZTooltipInfo as U,TranslateGraphicTooltipInfo as C}from"../../../../interactive/tooltip/TranslateTooltipInfos.js";import{euclideanHorizontalDistanceBetweenPoints as L}from"../../../../support/euclideanLengthMeasurementUtils.js";let P=class extends(i(e.EventedMixin(O))){constructor(t){super(t),this.enableZ=!0,this.enableRotation=!0,this.enableScaling=!0,this.tooltipOptions=new x,this.type="transform-3d",this._scaleRotate=null,this._snappingPipeline=new E}initialize(){const{graphic:t,view:e}=this;this.graphicState=new A({graphic:t}),this._tooltip=new z({view:e}),this._moveManipulation=new y({tool:this,view:e,snapToScene:this.snapToScene,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:this.enableZ&&_(t),radius:y.radiusForSymbol(t.symbol)}),this._moveManipulation.forEachManipulator(((e,i)=>this.handles.add([e.events.on("immediate-click",(e=>{this.emit("immediate-click",{...e,graphic:t}),e.stopPropagation()})),e.events.on("focus-changed",(({action:t})=>{const{tooltipOptions:e}=this;"focus"===t&&e.enabled?this._tooltip.info=new(i===v.TRANSLATE_Z?U:C)({tooltipOptions:e}):this._tooltip.clear()}))]))),this._moveManipulation.elevationInfo=h(t);const i=t.geometry;if(this._moveManipulation.createGraphicDragPipeline(((a,s,n,r,p)=>(o(i)&&a===S.XY&&(n=n.next(this._snappingPipeline.createSnapDragEventPipelineStep({snappingContext:new G({elevationInfo:h(t),pointer:p,editGeometryOperations:T.fromGeometry(new c({spatialReference:i.spatialReference}),e.state.viewingMode),visualizer:new g,excludeFeature:t}),snappingManager:this.snappingManager,updatingHandles:this.updatingHandles,cancel:r}),this._snappingPipeline.next)),n=n.next((t=>{const e=L(t.mapStart,t.mapEnd),{tooltipOptions:i}=this;return o(e)&&i.enabled?this._tooltip.info=new(a===S.Z?U:C)({tooltipOptions:i,distance:e}):this._tooltip.clear(),t})))),this.graphicState,(t=>{const{action:e,graphic:i,dxScreen:a,dyScreen:o}=t,s={graphic:i,dxScreen:a,dyScreen:o};switch(e){case"start":this.emit("graphic-translate-start",s),this.emit("record-undo",{record:this._createGeometryUndoRecord()});break;case"update":this.emit("graphic-translate",s);break;case"end":this.emit("graphic-translate-stop",s)}})),this._moveManipulation.angle=o(this._scaleRotate)?this._scaleRotate.angle:0,this._scaleRotateAdapter=this._createScaleRotateAdapter(),this.handles.add(r((()=>this._scaleRotateAdapter.angle),(()=>this._updateMoveAngle()))),this.enableScaling||this.enableRotation){const t=this.enableScaling&&this.enableRotation?null:this.enableScaling?"scale":"rotate";this._scaleRotate=new R({tool:this,mode:t,adapter:this._scaleRotateAdapter,tooltipOptions:this.tooltipOptions}),this.handles.add(this._scaleRotate.events.on("scale-changed",(()=>this._onScaleChanged())))}this.handles.add([f({view:this.view,graphic:this.graphic,forEachManipulator:t=>this._forEachManipulator(t),onManipulatorsChanged:()=>a()}),this.graphicState.on("changed",(()=>this._onGeometryChanged())),this._hideManipulatorsForGraphicState(),r((()=>e.scale),(()=>this._updateMoveAngle()))]),this.handles.add(this.view.trackGraphicState(this.graphicState)),this._onGeometryChanged(),this._updateMoveAngle(),this._forEachManipulator((t=>{t instanceof d&&this.handles.add(t.events.on("grab-changed",(()=>this._updateManipulatorsInteractive())))})),this.finishToolCreation()}destroy(){this._tooltip=s(this._tooltip),this._moveManipulation.destroy(),this._scaleRotate=s(this._scaleRotate),this._scaleRotateAdapter=s(this._scaleRotateAdapter),this._set("view",null),this._set("graphic",null)}_updateManipulatorsInteractive(){n(this._scaleRotate)||(this._scaleRotate.interactive=!this._moveManipulation.grabbing,this._moveManipulation.interactive=!this._scaleRotate.grabbing)}_createScaleRotateAdapter(){return o(this.graphic.geometry)&&"mesh"===this.graphic.geometry.type?new b({graphic:this.graphic,geometry:this.graphic.geometry,viewingMode:this.view.state.viewingMode}):new w({graphic:this.graphic,sizeFilter:t=>this._enforceNonZeroSize(t),findLayerView:()=>this.view.allLayerViews.find((t=>t.layer===this.graphic.layer)),sizeAxis:o(this.tooltipOptions.visualVariables)&&o(this.tooltipOptions.visualVariables.size)?this.tooltipOptions.visualVariables.size.axis:null})}_forEachManipulator(t){this._moveManipulation.forEachManipulator(t),o(this._scaleRotate)&&this._scaleRotate.forEachManipulator(t)}_hideManipulatorsForGraphicState(){return r((()=>this.graphicState.displaying),(t=>{this._forEachManipulator((e=>e.available=t)),this._moveManipulation.zManipulation.available=t&&this.enableZ&&_(this.graphic)}))}_createGeometryUndoRecord(){return j(this.graphic)}set snapToScene(t){this._moveManipulation&&(this._moveManipulation.snapToScene=t),this._set("snapToScene",t)}get updating(){return this.updatingHandles.updating}set location(t){this._moveManipulation.location=t,o(this._scaleRotate)&&(this._scaleRotate.location=t)}set elevationAlignedLocation(t){this._moveManipulation.elevationAlignedLocation=t,o(this._scaleRotate)&&(this._scaleRotate.elevationAlignedLocation=t)}reset(){}onHide(){o(this._scaleRotate)&&this._scaleRotate.cancelActiveAnimation()}_onScaleChanged(){if(n(this._scaleRotate))return;const t=this._scaleRotate.getScale();this._moveManipulation.displayScale=t}_updateMoveAngle(){this.view.state.viewingMode===m.Local||this.view.scale<M?this._moveManipulation.angle=this._scaleRotateAdapter.angle:this._moveManipulation.angle=0}_onGeometryChanged(){u(this.view,this,this.graphic)}_enforceNonZeroSize(t){return t||this.view.state.camera.computeRenderPixelSizeAt(this._moveManipulation.renderLocation)}get test(){return{discManipulator:this._moveManipulation.xyManipulation.test.discManipulator,zManipulator:this._moveManipulation.zManipulation.test.manipulator,ringManipulator:o(this._scaleRotate)?this._scaleRotate.test.ringManipulator:null,arrowManipulators:this._moveManipulation.xyAxisManipulation.test.arrowManipulators,scaleRotateAdapter:this._scaleRotateAdapter,scaleRotateTransform:this._scaleRotate}}};t([p({constructOnly:!0,nonNullable:!0})],P.prototype,"view",void 0),t([p({constructOnly:!0,nonNullable:!0})],P.prototype,"graphic",void 0),t([p({constructOnly:!0,nonNullable:!0})],P.prototype,"enableZ",void 0),t([p()],P.prototype,"enableRotation",void 0),t([p()],P.prototype,"enableScaling",void 0),t([p({constructOnly:!0,type:x})],P.prototype,"tooltipOptions",void 0),t([p()],P.prototype,"graphicState",void 0),t([p({value:!1})],P.prototype,"snapToScene",null),t([p({constructOnly:!0})],P.prototype,"snappingManager",void 0),t([p({readOnly:!0})],P.prototype,"type",void 0),t([p({readOnly:!0})],P.prototype,"updating",null),P=t([l("esri.views.3d.interactive.editingTools.graphicTransform3D.GraphicTransformTool")],P);export{P as GraphicTransformTool};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../request.js";import{splitIntoChunks as t,remove as s}from"../../../../core/arrayUtils.js";import{resultOrAbort as i,result as r}from"../../../../core/asyncUtils.js";import{estimateStringByteSize as a,estimateNumberByteSize as n}from"../../../../core/byteSizeEstimations.js";import o from"../../../../core/Logger.js";import{isNone as c,unwrap as d,get as h,isSome as l}from"../../../../core/maybe.js";import{whenOrAbort as m}from"../../../../core/promiseUtils.js";import{formatNumber as u}from"../../../../intl/number.js";import{getMaximumQuerySize as g,queryAllJSON as b}from"../../../../layers/support/featureQueryAll.js";const p=o.getLogger("esri.views.3d.layers.i3s.I3SAttributeOverrides");class f{constructor(e,t){this.layer=e,this.warnMaximumChangedObjectsExceeded=!1,this.changedObjectIds=new Set,this.pendingFetchAbortController=new AbortController,this.interactiveEditingSessions=null,this._maximumNumberOfEditOVerrides=j,this.memCache=t.newCache(`${e.uid}-attribute-overrides`),this.pendingFetchChangedObjectIds=this._fetchChangedObjectIds(this.pendingFetchAbortController.signal),this.pendingFetchChangedObjectIds.then((()=>this.pendingFetchAbortController=null))}destroy(){this.layer=null,this.memCache.destroy(),this.memCache=null,this.pendingFetchAbortController&&(this.pendingFetchAbortController.abort(),this.pendingFetchAbortController=null),this.pendingFetchChangedObjectIds=null}createInteractiveEditSession(e){this.changedObjectIds.add(e),c(this.interactiveEditingSessions)&&(this.interactiveEditingSessions=[]);const t=this.interactiveEditingSessions,i=new y(e,{rollback:()=>{s(t,i),0===t.length&&(this.interactiveEditingSessions=null)},commit:t=>{for(const[s,i]of t)this.updateValue(e,s,i)}});return t.unshift(i),i}async apply(e,t,s){if(c(t))return;const{loadedAttributes:i,attributeData:r}=t;if(c(i)||0===i.length||c(r))return;if(await m(this.pendingFetchChangedObjectIds,s),0===this.changedObjectIds.size)return;const a={loadedAttributes:i,attributeData:r},n=this._getOverridesFromCache(e,a,this.changedObjectIds),{objectIds:o,fieldNames:d}=n,h=await this._queryOverridesFromAssociatedLayer(o,d,s);c(h)||this._processOverridesFromAssociatedLayer(e,h,d,a)}updateValue(e,t,s){this.changedObjectIds.add(e),this._cacheValue(e,t,s)}_cacheValue(e,t,s){this.memCache.put(this._getCacheKey(e,t),s,this._memCacheValueSize(s))}_getOverridesFromCache(e,{loadedAttributes:t,attributeData:s},i){const r=new Set,a=new Array;for(const o of t)a[o.index]=s[o.name];const n=new Set;for(let o=0;o<e.length;o++){const s=e[o];if(i.has(s))for(const e of t){const t=this._fromCache(s,e.index);void 0===t?(r.add(s),n.add(e.name)):a[e.index][o]=t}}return{objectIds:Array.from(r),fieldNames:Array.from(n)}}_fromCache(e,t){const s=this._fromInteractiveEditingSession(e,t);if(void 0!==s)return s;const i=this._getCacheKey(e,t);return this.memCache.get(i)}_fromInteractiveEditingSession(e,t){if(!c(this.interactiveEditingSessions))for(const s of this.interactiveEditingSessions){if(s.objectId!==e)continue;const i=s.get(t);if(void 0!==i)return i}}_getCacheKey(e,t){return`${e}-${t}`}async _queryOverridesFromAssociatedLayer(e,s,r){if(0===e.length||0===s.length)return null;e=e.sort(((e,t)=>e-t)),this.warnMaximumChangedObjectsExceeded&&(this.warnMaximumChangedObjectsExceeded=!1,this._logMaximumObjectsExceededWarning());const a=d(this.layer.associatedLayer),n=a.createQuery();n.where="1=1",n.returnGeometry=!1,n.outFields=[a.objectIdField,...s],n.cacheHint=!0,n.objectIds=e;const o=g(a),c=e.length>o?t(e,o).map((e=>{const t=n.clone();return t.objectIds=e,i(b(a,t,{signal:r}))})):[i(b(a,n,{signal:r}))];return(await Promise.all(c)).reduce(((e,t)=>e.concat(t.ok?t.value.features:[])),[])}_logMaximumObjectsExceededWarning(){let e=`The number of edited objects that are not yet cached in the scene service exceeds the maximum limit. Attribute changes will only be available for the first ${u(this._maximumNumberOfEditOVerrides)} objects. Please consider re-caching the scene service`;const t=this.layer.portalItem;t&&t.loaded?e+=` (${t.portal.url}/home/item.html?id=${t.id}#settings)`:e+=` (${this.layer.parsedUrl.path})`,p.warn("#queryOverrides()",this.layer.title,`${e}.`)}_processOverridesFromAssociatedLayer(e,t,s,{loadedAttributes:i,attributeData:r}){const a=d(this.layer.associatedLayer).objectIdField,n=s.map((e=>r[e])),o=new Map(i.map((e=>[e.name,e.index]))),c=s.map((e=>o.get(e))),h=new Map(Array.from(e,((e,t)=>[e,t])));for(const d of t){const e=d.attributes[a];for(let t=0;t<s.length;t++){const i=c[t],r=h.get(e),a=d.attributes[s[t]];n[t][r]=a,this._cacheValue(e,i,a)}}}_memCacheValueSize(e){return"string"==typeof e?a(e):n()}async _fetchChangedObjectIds(t){const s=this.layer;if(await s.load({signal:t}),this.changedObjectIds.clear(),c(s.associatedLayer)||!s.associatedLayer.capabilities?.operations?.supportsChangeTracking)return;const i=this._getFetchChangedObjectIdsServerGen();if(c(i))return null;const a=s.associatedLayer.layerId,n=await r(e(`${s.associatedLayer.url}/extractChanges`,{method:"post",query:{f:"json",returnIdsOnly:!0,layers:`${a}`,returnUpdates:!0,returnDeletes:!1,returnInserts:!1,layerServerGens:JSON.stringify([{id:a,serverGen:i}])},timeout:C,signal:t})),o=n.ok&&n.value.data?.edits?h(n.value.data.edits[0],"objectIds","updates"):null;if(l(o)){const e=Math.min(this._maximumNumberOfEditOVerrides,o.length);e<o.length&&(this.warnMaximumChangedObjectsExceeded=!0);const t=o.sort(((e,t)=>e-t));for(let s=0;s<e;s++)this.changedObjectIds.add(t[s])}}_getFetchChangedObjectIdsServerGen(){const e=this.layer;if(l(e.serviceUpdateTimeStamp)&&l(e.serviceUpdateTimeStamp.lastUpdate))return e.serviceUpdateTimeStamp.lastUpdate;const t=e.associatedLayer;return l(t)&&l(t.serverGens)&&l(t.serverGens.minServerGen)?t.serverGens.minServerGen:null}get test(){const e=Array.from(this.changedObjectIds),t=this.pendingFetchChangedObjectIds,s=this;return{changedObjectIds:e,pendingFetchChangedObjectIds:t,get maximumNumberOfEditOVerrides(){return s._maximumNumberOfEditOVerrides},set maximumNumberOfEditOVerrides(e){s._maximumNumberOfEditOVerrides=e}}}}class y{constructor(e,t){this.objectId=e,this.options=t,this.updates=new Map,this.state=O.ACTIVE}get(e){return this.updates.get(e)}set(e,t){this.isActive&&this.updates.set(e,t)}rollback(){this.isActive&&(this.state=O.ROLLED_BACK,this.options.rollback())}commit(){this.isActive&&(this.state=O.COMMITTED,this.options.commit(this.updates),this.updates.clear())}get isActive(){return this.state===O.ACTIVE}}var O;!function(e){e[e.ACTIVE=0]="ACTIVE",e[e.COMMITTED=1]="COMMITTED",e[e.ROLLED_BACK=2]="ROLLED_BACK"}(O||(O={}));const C=1e4,j=5e4;export{f as I3SAttributeOverrides};
5
+ import e from"../../../../request.js";import{remove as t,splitIntoChunks as s}from"../../../../core/arrayUtils.js";import{resultOrAbort as i,result as r}from"../../../../core/asyncUtils.js";import{estimateStringByteSize as a,estimateNumberByteSize as n}from"../../../../core/byteSizeEstimations.js";import o from"../../../../core/Logger.js";import{isNone as c,unwrap as d,get as h,isSome as l}from"../../../../core/maybe.js";import{whenOrAbort as m}from"../../../../core/promiseUtils.js";import{formatNumber as u}from"../../../../intl/number.js";import{getMaximumQuerySize as g,queryAllJSON as b}from"../../../../layers/support/featureQueryAll.js";const p=o.getLogger("esri.views.3d.layers.i3s.I3SAttributeOverrides");class f{constructor(e,t){this.layer=e,this.warnMaximumChangedObjectsExceeded=!1,this.changedObjectIds=new Set,this.pendingFetchAbortController=new AbortController,this.interactiveEditingSessions=null,this._maximumNumberOfEditOVerrides=j,this.memCache=t.newCache(`${e.uid}-attribute-overrides`),this.pendingFetchChangedObjectIds=this._fetchChangedObjectIds(this.pendingFetchAbortController.signal),this.pendingFetchChangedObjectIds.then((()=>this.pendingFetchAbortController=null))}destroy(){this.layer=null,this.memCache.destroy(),this.memCache=null,this.pendingFetchAbortController&&(this.pendingFetchAbortController.abort(),this.pendingFetchAbortController=null),this.pendingFetchChangedObjectIds=null}createInteractiveEditSession(e){this.changedObjectIds.add(e),c(this.interactiveEditingSessions)&&(this.interactiveEditingSessions=[]);const s=this.interactiveEditingSessions,i=new y(e,{rollback:()=>{t(s,i),0===s.length&&(this.interactiveEditingSessions=null)},commit:t=>{for(const[s,i]of t)this.updateValue(e,s,i)}});return s.unshift(i),i}async apply(e,t,s){if(c(t))return;const{loadedAttributes:i,attributeData:r}=t;if(c(i)||0===i.length||c(r))return;if(await m(this.pendingFetchChangedObjectIds,s),0===this.changedObjectIds.size)return;const a={loadedAttributes:i,attributeData:r},n=this._getOverridesFromCache(e,a,this.changedObjectIds),{objectIds:o,fieldNames:d}=n,h=await this._queryOverridesFromAssociatedLayer(o,d,s);c(h)||this._processOverridesFromAssociatedLayer(e,h,d,a)}updateValue(e,t,s){this.changedObjectIds.add(e),this._cacheValue(e,t,s)}_cacheValue(e,t,s){this.memCache.put(this._getCacheKey(e,t),s,this._memCacheValueSize(s))}_getOverridesFromCache(e,{loadedAttributes:t,attributeData:s},i){const r=new Set,a=new Array;for(const o of t)a[o.index]=s[o.name];const n=new Set;for(let o=0;o<e.length;o++){const s=e[o];if(i.has(s))for(const e of t){const t=this._fromCache(s,e.index);void 0===t?(r.add(s),n.add(e.name)):a[e.index][o]=t}}return{objectIds:Array.from(r),fieldNames:Array.from(n)}}_fromCache(e,t){const s=this._fromInteractiveEditingSession(e,t);if(void 0!==s)return s;const i=this._getCacheKey(e,t);return this.memCache.get(i)}_fromInteractiveEditingSession(e,t){if(!c(this.interactiveEditingSessions))for(const s of this.interactiveEditingSessions){if(s.objectId!==e)continue;const i=s.get(t);if(void 0!==i)return i}}_getCacheKey(e,t){return`${e}-${t}`}async _queryOverridesFromAssociatedLayer(e,t,r){if(0===e.length||0===t.length)return null;e=e.sort(((e,t)=>e-t)),this.warnMaximumChangedObjectsExceeded&&(this.warnMaximumChangedObjectsExceeded=!1,this._logMaximumObjectsExceededWarning());const a=d(this.layer.associatedLayer),n=a.createQuery();n.where="1=1",n.returnGeometry=!1,n.outFields=[a.objectIdField,...t],n.cacheHint=!0,n.objectIds=e;const o=g(a),c=e.length>o?s(e,o).map((e=>{const t=n.clone();return t.objectIds=e,i(b(a,t,{signal:r}))})):[i(b(a,n,{signal:r}))];return(await Promise.all(c)).reduce(((e,t)=>e.concat(t.ok?t.value.features:[])),[])}_logMaximumObjectsExceededWarning(){let e=`The number of edited objects that are not yet cached in the scene service exceeds the maximum limit. Attribute changes will only be available for the first ${u(this._maximumNumberOfEditOVerrides)} objects. Please consider re-caching the scene service`;const t=this.layer.portalItem;t&&t.loaded?e+=` (${t.portal.url}/home/item.html?id=${t.id}#settings)`:e+=` (${this.layer.parsedUrl.path})`,p.warn("#queryOverrides()",this.layer.title,`${e}.`)}_processOverridesFromAssociatedLayer(e,t,s,{loadedAttributes:i,attributeData:r}){const a=d(this.layer.associatedLayer).objectIdField,n=s.map((e=>r[e])),o=new Map(i.map((e=>[e.name,e.index]))),c=s.map((e=>o.get(e))),h=new Map(Array.from(e,((e,t)=>[e,t])));for(const d of t){const e=d.attributes[a];for(let t=0;t<s.length;t++){const i=c[t],r=h.get(e),a=d.attributes[s[t]];n[t][r]=a,this._cacheValue(e,i,a)}}}_memCacheValueSize(e){return"string"==typeof e?a(e):n()}async _fetchChangedObjectIds(t){const s=this.layer;if(await s.load({signal:t}),this.changedObjectIds.clear(),c(s.associatedLayer)||!s.associatedLayer.capabilities?.operations?.supportsChangeTracking)return;const i=this._getFetchChangedObjectIdsServerGen();if(c(i))return null;const a=s.associatedLayer.layerId,n=await r(e(`${s.associatedLayer.url}/extractChanges`,{method:"post",query:{f:"json",returnIdsOnly:!0,layers:`${a}`,returnUpdates:!0,returnDeletes:!1,returnInserts:!1,layerServerGens:JSON.stringify([{id:a,serverGen:i}])},timeout:C,signal:t})),o=n.ok&&n.value.data?.edits?h(n.value.data.edits[0],"objectIds","updates"):null;if(l(o)){const e=Math.min(this._maximumNumberOfEditOVerrides,o.length);e<o.length&&(this.warnMaximumChangedObjectsExceeded=!0);const t=o.sort(((e,t)=>e-t));for(let s=0;s<e;s++)this.changedObjectIds.add(t[s])}}_getFetchChangedObjectIdsServerGen(){const e=this.layer;if(l(e.serviceUpdateTimeStamp)&&l(e.serviceUpdateTimeStamp.lastUpdate))return e.serviceUpdateTimeStamp.lastUpdate;const t=e.associatedLayer;return l(t)&&l(t.serverGens)&&l(t.serverGens.minServerGen)?t.serverGens.minServerGen:null}get test(){const e=Array.from(this.changedObjectIds),t=this.pendingFetchChangedObjectIds,s=this;return{changedObjectIds:e,pendingFetchChangedObjectIds:t,get maximumNumberOfEditOVerrides(){return s._maximumNumberOfEditOVerrides},set maximumNumberOfEditOVerrides(e){s._maximumNumberOfEditOVerrides=e}}}}class y{constructor(e,t){this.objectId=e,this.options=t,this.updates=new Map,this.state=O.ACTIVE}get(e){return this.updates.get(e)}set(e,t){this.isActive&&this.updates.set(e,t)}rollback(){this.isActive&&(this.state=O.ROLLED_BACK,this.options.rollback())}commit(){this.isActive&&(this.state=O.COMMITTED,this.options.commit(this.updates),this.updates.clear())}get isActive(){return this.state===O.ACTIVE}}var O;!function(e){e[e.ACTIVE=0]="ACTIVE",e[e.COMMITTED=1]="COMMITTED",e[e.ROLLED_BACK=2]="ROLLED_BACK"}(O||(O={}));const C=1e4,j=5e4;export{f as I3SAttributeOverrides};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{isSome as t,isNone as e}from"../../../../core/maybe.js";import{d as i,i as s,l as r,g as n,e as a,p as o,b as h,a as c}from"../../../../chunks/vec3.js";import{c as m}from"../../../../chunks/vec3f64.js";import{c as p}from"../../../../chunks/vec4.js";import{projectBoundingSphere as u}from"../../../../geometry/projection.js";import{getSphericalPCPF as _}from"../../../../geometry/projectionEllipsoid.js";import{create as l,fromMatrix as d,intersectsSphere as g}from"../../../../geometry/support/frustum.js";import{w as b}from"../../../../chunks/sphere.js";import{makeDehydratedPoint as f}from"../../../../layers/graphics/dehydratedFeatures.js";import{evaluateElevationAlignmentAtPoint as D}from"../graphics/elevationAlignmentUtils.js";import{ElevationContext as M}from"../graphics/ElevationContext.js";import{createContextWithoutExpressionSupport as v,extractExpressionInfo as x}from"../graphics/featureExpressionInfoUtils.js";import{LodMetric as C}from"./I3SNode.js";import{isValidMbs as R,isValidObb as S,transformObb as P,intersectBoundingRectWithMbs as E,MbsIntersectResult as L}from"./I3SUtil.js";import{create as O,isVisible as j}from"../../support/orientedBoundingBox.js";const F=1e5;class y{constructor(t,e,i,s,r,n,a,o={}){this._indexSR=t,this._renderCoordsHelper=e,this.clippingArea=r,this._elevationProvider=n,this._options=o,this._frustum=l(),this._useFrustumCulling=!1,this._poi=m(),this.minDistance=1/0,this.maxDistance=0,this.maxLodLevel=2,this._tmp1=m(),this._tmp2=m(),this._tmp3=m(),this._tmp0=m(),this._screenspaceErrorBias=o.screenspaceErrorBias||1,this._progressiveLoadFactor=o.progressiveLoadFactor||1,this.updateCamera(i,s),this.engineSR=this._renderCoordsHelper.spatialReference,this.updateElevationInfo(a),this._tmpPoint=f(0,0,0,t)}updateElevationInfo(t){null!=t?(this._elevationContext=M.fromElevationInfo(t),this._elevationContext.updateFeatureExpressionInfoContext(v(x(t,!1)))):this._elevationContext=null}updateCamera(t,e){this._useFrustumCulling=e,e&&d(t.viewMatrix,t.projectionMatrix,this._frustum),this._screenSizeFactor=1/(t.perScreenPixelRatio/2),this._camPos=t.eye,this.minDistance=1/0,this.maxDistance=0}setPointOfInterest(t){this._poi=t}updateScreenSpaceErrorBias(t){const e=this._screenspaceErrorBias;return this._screenspaceErrorBias=t,e}updateClippingArea(t){this.clippingArea=t}getRenderMbs(t){const e=t.renderMbs;return R(e)||(p(e,t.mbs),this._elevationContext&&e[3]<F&&(this._tmpPoint.x=e[0],this._tmpPoint.y=e[1],this._tmpPoint.z=e[2],e[2]=D(this._tmpPoint,this._elevationProvider,this._elevationContext,this._renderCoordsHelper)),u(e,this._indexSR,e,this.engineSR)),e}getVisibilityObb(i){if(t(i.visibilityObb))return i.visibilityObb;const s=i.serviceObb;return e(s)||!S(s)?null:(i.serviceObbInRenderSR=this._computeRenderObb(s,i.serviceObbInRenderSR,i.mbs[3]),i.serviceObbInRenderSR)}_computeRenderObb(t,i,s){if(e(i))i=O();else if(S(i))return i;let r=0;return this._elevationContext&&s<F&&(this._tmpPoint.x=t.center[0],this._tmpPoint.y=t.center[1],this._tmpPoint.z=t.center[2],r=D(this._tmpPoint,this._elevationProvider,this._elevationContext,this._renderCoordsHelper)-t.center[2]),P(t,this._indexSR,i,this.engineSR,r),i}isNodeVisible(e){const i=this.getRenderMbs(e);if(!this._isMBSinClippingArea(i))return!1;if(!this._useFrustumCulling)return!0;const s=this.getVisibilityObb(e);return t(s)?j(s,this._frustum):g(this._frustum,b(i))}isGeometryVisible(e){if(!this._useFrustumCulling)return!0;const i=e.geometryObb;return t(i)?j(i,this._frustum):this.isNodeVisible(e)}_isMBSinClippingArea(t){return!!e(this.clippingArea)||E(this.clippingArea,t)!==L.OUTSIDE}_screenSpaceDiameterMbs(t,e){const s=this.getRenderMbs(t),r=Math.sqrt(i(s,this._camPos)),n=r-s[3];return this._updateMinMaxDistance(r),n<0?.5*Number.MAX_VALUE:e/n*this._screenSizeFactor}calcCameraDistance(t){return this.calcCameraDistanceToCenter(t)-this.getRenderMbs(t)[3]}calcCameraDistanceToCenter(t){const e=this.getRenderMbs(t),i=s(e,this._camPos);return this._updateMinMaxDistance(i),i}calcAngleDependentLoD(t){const e=this.getRenderMbs(t),i=e[3],n=(Math.abs(e[0]*(e[0]-this._camPos[0])+e[1]*(e[1]-this._camPos[1])+e[2]*(e[2]-this._camPos[2]))/r(e)+i)/s(e,this._camPos);return Math.min(1,n)}hasLOD(t){return t.lodMetric!==C.None}_getDistancePlanarMode(t,e){const i=t[0]-e[0],s=t[1]-e[1],r=t[2]-e[2],n=i*i+s*s,a=e[3];if(n<=a*a)return Math.abs(r);const o=Math.sqrt(n)-a;return Math.sqrt(r*r+o*o)}_getDistanceGlobeMode(t,e){const m=r(e),p=r(t)-m;n(this._tmp0,t,a(t,e)/o(t));const u=i(e,this._tmp0),_=e[3];if(u<=_*_)return Math.abs(p);{const i=n(this._tmp0,e,1/m),o=m,u=_*_/2/o,l=n(this._tmp1,i,o-u),d=t,g=h(this._tmp2,d,l),b=h(this._tmp2,g,n(this._tmp3,i,a(i,g))),f=c(this._tmp2,l,n(this._tmp2,b,_/r(b)));let D=s(d,f);if(p>=2e5){const t=h(this._tmp1,d,f);let e=a(t,i)/r(t);e<.08&&(e=1e-4),D/=e}return D}}_getDistance(t,e){return this.engineSR===_(this.engineSR)?this._getDistanceGlobeMode(t,e):this._getDistancePlanarMode(t,e)}_updateMinMaxDistance(t){t>0?(this.minDistance=Math.min(this.minDistance,t),this.maxDistance=Math.max(this.maxDistance,t)):(this.minDistance=0,this.maxDistance=Math.max(this.maxDistance,-t))}getLodLevel(t){if(t.lodMetric===C.None)return 0;if(0===t.childCount)return this.maxLodLevel;if(this._useFrustumCulling&&this._progressiveLoadFactor<1){const e=this._progressiveLoadFactor*this._screenspaceErrorBias,i=this._screenspaceErrorBias;return this.evaluateLODmetric(t,e)?this.evaluateLODmetric(t,i)?2:1:0}return this.evaluateLODmetric(t,this._screenspaceErrorBias)?this.maxLodLevel:0}evaluateLODmetric(t,e){switch(t.lodMetric){case C.ScreenSpaceRelative:{const i=this.getRenderMbs(t),s=this._getDistance(this._camPos,i),r=2*s/this._screenSizeFactor,n=s+i[3];return this._updateMinMaxDistance(n),t.maxError*e<=r}case C.MaxScreenThreshold:{let i=this._screenSpaceDiameterMbs(t,t.mbs[3]*e);return this._options.angleDependentLoD&&(i*=this.calcAngleDependentLoD(t)),i<t.maxError}case C.RemovedFeatureDiameter:return this._screenSpaceDiameterMbs(t,t.maxError)*e<10;case C.DistanceRangeFromDefaultCamera:return this.calcCameraDistance(t)>t.maxError*e}return!1}distToPOI(t){const e=this.getRenderMbs(t);return s(e,this._poi)-e[3]}distCameraToPOI(){return s(this._camPos,this._poi)}}export{y as default};
5
+ import{isSome as t,isNone as e}from"../../../../core/maybe.js";import{d as i,i as s,l as r,g as n,e as a,p as o,b as h,a as c}from"../../../../chunks/vec3.js";import{c as m}from"../../../../chunks/vec3f64.js";import{c as p}from"../../../../chunks/vec4.js";import{projectBoundingSphere as u}from"../../../../geometry/projection.js";import{getReferenceEllipsoid as l,getSphericalPCPF as _}from"../../../../geometry/projectionEllipsoid.js";import{create as d,fromMatrix as g,intersectsSphere as b}from"../../../../geometry/support/frustum.js";import{isPlateCarree as f}from"../../../../geometry/support/spatialReferenceUtils.js";import{w as M}from"../../../../chunks/sphere.js";import{makeDehydratedPoint as x}from"../../../../layers/graphics/dehydratedFeatures.js";import{evaluateElevationAlignmentAtPoint as D}from"../graphics/elevationAlignmentUtils.js";import{ElevationContext as v}from"../graphics/ElevationContext.js";import{createContextWithoutExpressionSupport as R,extractExpressionInfo as S}from"../graphics/featureExpressionInfoUtils.js";import{LodMetric as C}from"./I3SNode.js";import{isValidMbs as E,isValidObb as P,transformObb as L,intersectBoundingRectWithMbs as O,MbsIntersectResult as j}from"./I3SUtil.js";import{create as F,isVisible as y}from"../../support/orientedBoundingBox.js";const B=1e5;class I{constructor(t,e,i,s,r,n,a,o={}){this._indexSR=t,this._renderCoordsHelper=e,this.clippingArea=r,this._elevationProvider=n,this._options=o,this._frustum=d(),this._useFrustumCulling=!1,this._poi=m(),this.minDistance=1/0,this.maxDistance=0,this.maxLodLevel=2,this._tmp1=m(),this._tmp2=m(),this._tmp3=m(),this._tmp0=m(),this._screenspaceErrorBias=o.screenspaceErrorBias||1,this._progressiveLoadFactor=o.progressiveLoadFactor||1,this.updateCamera(i,s),this.engineSR=this._renderCoordsHelper.spatialReference,this.updateElevationInfo(a),this._tmpPoint=x(0,0,0,t),this._isECEFOBBInLocalMode=this._indexSR.isWGS84&&(this.engineSR.isWebMercator||f(this.engineSR)),this._indexSREllipsoidRadius=l(this._indexSR).radius}updateElevationInfo(t){null!=t?(this._elevationContext=v.fromElevationInfo(t),this._elevationContext.updateFeatureExpressionInfoContext(R(S(t,!1)))):this._elevationContext=null}updateCamera(t,e){this._useFrustumCulling=e,e&&g(t.viewMatrix,t.projectionMatrix,this._frustum),this._screenSizeFactor=1/(t.perScreenPixelRatio/2),this._camPos=t.eye,this.minDistance=1/0,this.maxDistance=0}setPointOfInterest(t){this._poi=t}updateScreenSpaceErrorBias(t){const e=this._screenspaceErrorBias;return this._screenspaceErrorBias=t,e}updateClippingArea(t){this.clippingArea=t}getRenderMbs(t){const e=t.renderMbs;return E(e)||(p(e,t.mbs),this._elevationContext&&e[3]<B&&(this._tmpPoint.x=e[0],this._tmpPoint.y=e[1],this._tmpPoint.z=e[2],e[2]=D(this._tmpPoint,this._elevationProvider,this._elevationContext,this._renderCoordsHelper)),u(e,this._indexSR,e,this.engineSR)),e}getVisibilityObb(i){if(t(i.visibilityObb))return i.visibilityObb;const s=i.serviceObb,r=.01*this._indexSREllipsoidRadius;return e(s)||!P(s)||this._isECEFOBBInLocalMode&&s.halfSize.some((t=>t>r))?null:(i.serviceObbInRenderSR=this._computeRenderObb(s,i.serviceObbInRenderSR,i.mbs[3]),i.serviceObbInRenderSR)}_computeRenderObb(t,i,s){if(e(i))i=F();else if(P(i))return i;let r=0;return this._elevationContext&&s<B&&(this._tmpPoint.x=t.center[0],this._tmpPoint.y=t.center[1],this._tmpPoint.z=t.center[2],r=D(this._tmpPoint,this._elevationProvider,this._elevationContext,this._renderCoordsHelper)-t.center[2]),L(t,this._indexSR,i,this.engineSR,r),i}isNodeVisible(e){const i=this.getRenderMbs(e);if(!this._isMBSinClippingArea(i))return!1;if(!this._useFrustumCulling)return!0;const s=this.getVisibilityObb(e);return t(s)?y(s,this._frustum):b(this._frustum,M(i))}isGeometryVisible(e){if(!this._useFrustumCulling)return!0;const i=e.geometryObb;return t(i)?y(i,this._frustum):this.isNodeVisible(e)}_isMBSinClippingArea(t){return!!e(this.clippingArea)||O(this.clippingArea,t)!==j.OUTSIDE}_screenSpaceDiameterMbs(t,e){const s=this.getRenderMbs(t),r=Math.sqrt(i(s,this._camPos)),n=r-s[3];return this._updateMinMaxDistance(r),n<0?.5*Number.MAX_VALUE:e/n*this._screenSizeFactor}calcCameraDistance(t){return this.calcCameraDistanceToCenter(t)-this.getRenderMbs(t)[3]}calcCameraDistanceToCenter(t){const e=this.getRenderMbs(t),i=s(e,this._camPos);return this._updateMinMaxDistance(i),i}calcAngleDependentLoD(t){const e=this.getRenderMbs(t),i=e[3],n=(Math.abs(e[0]*(e[0]-this._camPos[0])+e[1]*(e[1]-this._camPos[1])+e[2]*(e[2]-this._camPos[2]))/r(e)+i)/s(e,this._camPos);return Math.min(1,n)}hasLOD(t){return t.lodMetric!==C.None}_getDistancePlanarMode(t,e){const i=t[0]-e[0],s=t[1]-e[1],r=t[2]-e[2],n=i*i+s*s,a=e[3];if(n<=a*a)return Math.abs(r);const o=Math.sqrt(n)-a;return Math.sqrt(r*r+o*o)}_getDistanceGlobeMode(t,e){const m=r(e),p=r(t)-m;n(this._tmp0,t,a(t,e)/o(t));const u=i(e,this._tmp0),l=e[3];if(u<=l*l)return Math.abs(p);{const i=n(this._tmp0,e,1/m),o=m,u=l*l/2/o,_=n(this._tmp1,i,o-u),d=t,g=h(this._tmp2,d,_),b=h(this._tmp2,g,n(this._tmp3,i,a(i,g))),f=c(this._tmp2,_,n(this._tmp2,b,l/r(b)));let M=s(d,f);if(p>=2e5){const t=h(this._tmp1,d,f);let e=a(t,i)/r(t);e<.08&&(e=1e-4),M/=e}return M}}_getDistance(t,e){return this.engineSR===_(this.engineSR)?this._getDistanceGlobeMode(t,e):this._getDistancePlanarMode(t,e)}_updateMinMaxDistance(t){t>0?(this.minDistance=Math.min(this.minDistance,t),this.maxDistance=Math.max(this.maxDistance,t)):(this.minDistance=0,this.maxDistance=Math.max(this.maxDistance,-t))}getLodLevel(t){if(t.lodMetric===C.None)return 0;if(0===t.childCount)return this.maxLodLevel;if(this._useFrustumCulling&&this._progressiveLoadFactor<1){const e=this._progressiveLoadFactor*this._screenspaceErrorBias,i=this._screenspaceErrorBias;return this.evaluateLODmetric(t,e)?this.evaluateLODmetric(t,i)?2:1:0}return this.evaluateLODmetric(t,this._screenspaceErrorBias)?this.maxLodLevel:0}evaluateLODmetric(t,e){switch(t.lodMetric){case C.ScreenSpaceRelative:{const i=this.getRenderMbs(t),s=this._getDistance(this._camPos,i),r=2*s/this._screenSizeFactor,n=s+i[3];return this._updateMinMaxDistance(n),t.maxError*e<=r}case C.MaxScreenThreshold:{let i=this._screenSpaceDiameterMbs(t,t.mbs[3]*e);return this._options.angleDependentLoD&&(i*=this.calcAngleDependentLoD(t)),i<t.maxError}case C.RemovedFeatureDiameter:return this._screenSpaceDiameterMbs(t,t.maxError)*e<10;case C.DistanceRangeFromDefaultCamera:return this.calcCameraDistance(t)>t.maxError*e}return!1}distToPOI(t){const e=this.getRenderMbs(t);return s(e,this._poi)-e[3]}distCameraToPOI(){return s(this._camPos,this._poi)}}export{I as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import i from"../../../core/Logger.js";import{isSome as s}from"../../../core/maybe.js";import{MemCacheStorage as r,MemCache as a}from"../../../core/MemCache.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import{isMemoryManagedLayerView as m}from"../layers/support/MemoryManagedLayerView.js";const y=i.getLogger("esri.views.3d.support.MemoryController");function l(e){return new p({view:e})}const n=1,u=1,d=.75,c=.6,_=1.3;let p=class extends t{constructor(e){super(e),this._quality=1,this._memoryUsed=0,this._updating=!1,this.minQuality=.1,this._stableQuality=0,this._downscaleMemoryUsed=0,this._canFastRecover=!1,this._memoryPredicted=0,this._cacheStorage=new r,this._numQualityChanges=0,this._maxMemory=500,this._additionalCacheMemory=100}destroy(){this._cacheStorage.destroy()}set maxMemory(e){null==e||e<=0||(this._stableQuality=0,this._canFastRecover=!1,this._maxMemory<e&&this._updateQuality(n),this._maxMemory=e)}get maxMemory(){return this._maxMemory}set additionalCacheMemory(e){null!=e&&e>=0&&(this._additionalCacheMemory=e)}get additionalCacheMemory(){return this._additionalCacheMemory}get memoryFactor(){return this._quality}get updating(){return this._updating}get usedMemory(){return this._memoryUsed}newCache(e,t){return new a(e,this._cacheStorage,t)}resetStableQuality(){this._stableQuality=0}disableMemCache(){this.additionalCacheMemory=-4096}update(){if(this._updateMemory(),this._memoryPredicted<=0&&!this._updating)return;let e=this._layersUpdating();if(this._memoryPredicted<c&&this._canFastRecover)this._downscaleMemoryUsed=0,this._stableQuality=0,this._canFastRecover=!1,this._updateQuality(n);else if(e)(this._memoryPredicted>1.1*u||this._memoryUsed>u)&&(this._stableQuality>0?(this._downscaleMemoryUsed=0,this._updateQuality(this._stableQuality)):this._quality>this.minQuality&&this._downscaleMemoryUsed<this._memoryUsed&&(this._updateQuality(this._quality/_),this._downscaleMemoryUsed=this._memoryUsed,this._canFastRecover=!1));else if(this._downscaleMemoryUsed=0,this._memoryUsed>u)this._stableQuality=0,this._canFastRecover=!1,e=this._updateQuality(this._quality/_),this._downscaleMemoryUsed=this._memoryPredicted;else if(this._stableQuality!==this._quality)if(this._memoryUsed<d&&this._quality<n){this._stableQuality=this._quality;const t=.05;e=this._updateQuality(this._quality+t)}else this._quality<1&&(this._canFastRecover=!0);this._updating=e}_updateQuality(e){return(e=Math.min(Math.max(e,this.minQuality),n))!==this._quality&&(this._quality=e,++this._numQualityChanges,!0)}_layersUpdating(){return this.view.allLayerViews.some((e=>!!e.updating))}_updateMemory(){let e=0,t=0;this.view.basemapTerrain&&this.view.basemapTerrain.getUsedMemory&&(e+=this.view.basemapTerrain.getUsedMemory());const i=this.view._stage&&this.view._stage.renderView&&this.view._stage.renderView.edgeView;s(i)&&(e+=i.usedMemory),this.view.allLayerViews&&this.view.allLayerViews.forEach((i=>{if(m(i)){const s=i.ignoresMemoryFactor()?this._quality:1;e+=i.getUsedMemory()*s,t+=i.getUnloadedMemory()*s}}));const r=null==this._warnMemoryUsage||Math.round(10*e)!==Math.round(10*this._warnMemoryUsage),a=1048576*this.maxMemory;if(e>a&&r){this._warnMemoryUsage=e;const i=e=>(e/1048576).toLocaleString(void 0,{maximumFractionDigits:1})+" MB",s=Math.round(100*this._quality);y.warn(`Memory Limit exceeded! Limit: ${i(a)} Current: ${i(e)} Projected: ${i(e+t)} Quality: ${s}%`)}this._memoryUsed=e/a,this._memoryPredicted=(e+t)/a;const o=a-e;this._cacheStorage.maxSize=Math.max(0,o+1048576*this.additionalCacheMemory)}get test(){const e=this;return{cacheStorage:this._cacheStorage,resetQualityChanges:()=>{const t=e._numQualityChanges;return e._numQualityChanges=0,t}}}};e([o({constructOnly:!0})],p.prototype,"view",void 0),e([o()],p.prototype,"maxMemory",null),e([o()],p.prototype,"additionalCacheMemory",null),e([o()],p.prototype,"memoryFactor",null),e([o()],p.prototype,"updating",null),e([o()],p.prototype,"usedMemory",null),e([o()],p.prototype,"_quality",void 0),e([o()],p.prototype,"_memoryUsed",void 0),e([o()],p.prototype,"_updating",void 0),p=e([h("esri.views.3d.support.MemoryController")],p);export{l as newMemoryController};
5
+ import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../core/Accessor.js";import i from"../../../core/Logger.js";import{isSome as s}from"../../../core/maybe.js";import{MemCacheStorage as r,MemCache as a}from"../../../core/MemCache.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as h}from"../../../core/accessorSupport/decorators/subclass.js";import{isMemoryManagedLayerView as m}from"../layers/support/MemoryManagedLayerView.js";const y=i.getLogger("esri.views.3d.support.MemoryController");function l(t){return new p({view:t})}const n=1,d=1,u=.75,c=.6,_=1.3;let p=class extends e{constructor(t){super(t),this._quality=1,this._memoryUsed=0,this._updating=!1,this.minQuality=.1,this._stableQuality=0,this._downscaleMemoryUsed=0,this._canFastRecover=!1,this._memoryPredicted=0,this._cacheStorage=new r,this._numQualityChanges=0,this._maxMemory=500,this._additionalCacheMemory=100}destroy(){this._cacheStorage.destroy()}set maxMemory(t){null==t||t<=0||(this._stableQuality=0,this._canFastRecover=!1,this._maxMemory<t&&this._updateQuality(n),this._maxMemory=t)}get maxMemory(){return this._maxMemory}set additionalCacheMemory(t){null!=t&&t>=0&&(this._additionalCacheMemory=t)}get additionalCacheMemory(){return this._additionalCacheMemory}get memoryFactor(){return this._quality}get updating(){return this._updating}get usedMemory(){return this._memoryUsed}newCache(t,e){return new a(t,this._cacheStorage,e)}resetStableQuality(){this._stableQuality=0}disableMemCache(){this.additionalCacheMemory=-4096}update(){if(this._updateMemory(),this._memoryPredicted<=0&&!this._updating)return;let t=this._layersUpdating();if(this._memoryPredicted<c&&this._canFastRecover)this._downscaleMemoryUsed=0,this._stableQuality=0,this._canFastRecover=!1,this._updateQuality(n);else if(t)(this._memoryPredicted>1.1*d||this._memoryUsed>d)&&(this._stableQuality>0?(this._downscaleMemoryUsed=0,this._updateQuality(this._stableQuality)):this._quality>this.minQuality&&this._downscaleMemoryUsed<this._memoryUsed&&(this._updateQuality(this._quality/_),this._downscaleMemoryUsed=this._memoryUsed,this._canFastRecover=!1));else if(this._downscaleMemoryUsed=0,this._memoryUsed>d)this._stableQuality=0,this._canFastRecover=!1,t=this._updateQuality(this._quality/_),this._downscaleMemoryUsed=this._memoryPredicted;else if(this._stableQuality!==this._quality)if(this._memoryUsed<u&&this._quality<n){this._stableQuality=this._quality;const e=.05;t=this._updateQuality(this._quality+e)}else this._quality<1&&(this._canFastRecover=!0);this._updating=t}_updateQuality(t){return(t=Math.min(Math.max(t,this.minQuality),n))!==this._quality&&(this._quality=t,++this._numQualityChanges,!0)}_layersUpdating(){return this.view.allLayerViews.some((t=>!!t.updating))}_updateMemory(){let t=0,e=0;this.view.basemapTerrain&&this.view.basemapTerrain.getUsedMemory&&(t+=this.view.basemapTerrain.getUsedMemory());const i=this.view._stage&&this.view._stage.renderView&&this.view._stage.renderView.edgeView;s(i)&&(t+=i.usedMemory),this.view.allLayerViews&&this.view.allLayerViews.forEach((i=>{if(m(i)){const s=i.ignoresMemoryFactor()?this._quality:1;t+=i.getUsedMemory()*s,e+=i.getUnloadedMemory()*s}}));const r=null==this._warnMemoryUsage||Math.round(10*t)!==Math.round(10*this._warnMemoryUsage),a=1048576*this.maxMemory;if(t>a&&r){this._warnMemoryUsage=t;const i=t=>(t/1048576).toLocaleString(void 0,{maximumFractionDigits:1})+" MB",s=Math.round(100*this._quality);y.warn(`Memory Limit exceeded! Limit: ${i(a)} Current: ${i(t)} Projected: ${i(t+e)} Quality: ${s}%`)}this._memoryUsed=t/a,this._memoryPredicted=(t+e)/a;const o=a-t;this._cacheStorage.maxSize=Math.max(0,o+1048576*this.additionalCacheMemory)}get test(){const t=this;return{cacheStorage:this._cacheStorage,resetQualityChanges:()=>{const e=t._numQualityChanges;return t._numQualityChanges=0,e}}}};t([o({constructOnly:!0})],p.prototype,"view",void 0),t([o()],p.prototype,"maxMemory",null),t([o()],p.prototype,"additionalCacheMemory",null),t([o()],p.prototype,"memoryFactor",null),t([o()],p.prototype,"updating",null),t([o()],p.prototype,"usedMemory",null),t([o()],p.prototype,"_quality",void 0),t([o()],p.prototype,"_memoryUsed",void 0),t([o()],p.prototype,"_updating",void 0),t([o()],p.prototype,"_stableQuality",void 0),t([o()],p.prototype,"_maxMemory",void 0),t([o()],p.prototype,"_additionalCacheMemory",void 0),p=t([h("esri.views.3d.support.MemoryController")],p);export{l as newMemoryController};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import{RasterColorizerType as r,RasterColorizerStretchType as o}from"../../2d/engine/imagery/enums.js";import{BlendModeTechniqueConfiguration as i}from"./BlendModeTechniqueConfiguration.js";import{R as t}from"../../../chunks/RasterColorizer.glsl.js";import{TileBlendInput as n}from"../webgl-engine/core/shaderLibrary/terrain/TileBlendInput.js";import{ReloadableShaderModule as s}from"../webgl-engine/core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as l}from"../webgl-engine/core/shaderTechnique/ShaderTechnique.js";import{parameter as a}from"../webgl-engine/core/shaderTechnique/ShaderTechniqueConfiguration.js";import{Default3D as p}from"../webgl-engine/lib/DefaultVertexAttributeLocations.js";import{Program as m}from"../webgl-engine/lib/Program.js";import{BlendFactor as c}from"../../webgl/enums.js";import{makePipelineState as d,simpleBlendingParams as g,defaultColorWriteParams as u}from"../../webgl/renderState.js";class h extends l{initializeProgram(e){const r=h.shader.get().build(this.configuration);return new m(e.rctx,r,p)}initializePipeline(){return d({blending:g(c.ONE,c.ONE_MINUS_SRC_ALPHA),colorWrite:u})}}h.shader=new s(t,(()=>import("../webgl-engine/core/shaderLibrary/raster/RasterColorizer.glsl.js")));class b extends i{constructor(){super(...arguments),this.colorizerType=r.Stretch,this.stretchType=o.Noop,this.tileBlendInput=n.LayerOnly,this.applyColormap=!0}}e([a({count:r.COUNT})],b.prototype,"colorizerType",void 0),e([a({count:o.COUNT})],b.prototype,"stretchType",void 0),e([a({count:n.COUNT})],b.prototype,"tileBlendInput",void 0),e([a()],b.prototype,"applyColormap",void 0);export{h as RasterColorizerTechnique,b as RasterColorizerTechniqueConfiguration};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import{RasterColorizerType as r,RasterColorizerStretchType as o}from"../../2d/engine/imagery/enums.js";import{BlendModeTechniqueConfiguration as t}from"./BlendModeTechniqueConfiguration.js";import{R as i}from"../../../chunks/RasterColorizer.glsl.js";import{TileBlendInput as n}from"../webgl-engine/core/shaderLibrary/terrain/TileBlendInput.js";import{ReloadableShaderModule as s}from"../webgl-engine/core/shaderTechnique/ReloadableShaderModule.js";import{ShaderTechnique as l}from"../webgl-engine/core/shaderTechnique/ShaderTechnique.js";import{parameter as p}from"../webgl-engine/core/shaderTechnique/ShaderTechniqueConfiguration.js";import{Default3D as a}from"../webgl-engine/lib/DefaultVertexAttributeLocations.js";import{Program as m}from"../webgl-engine/lib/Program.js";import{BlendFactor as u}from"../../webgl/enums.js";import{makePipelineState as c,simpleBlendingParams as d,defaultColorWriteParams as g}from"../../webgl/renderState.js";class h extends l{initializeProgram(e){const r=h.shader.get().build(this.configuration);return new m(e.rctx,r,a)}initializePipeline(){return c({blending:d(u.ONE,u.ONE_MINUS_SRC_ALPHA),colorWrite:g})}}h.shader=new s(i,(()=>import("../webgl-engine/core/shaderLibrary/raster/RasterColorizer.glsl.js")));class b extends t{constructor(){super(...arguments),this.colorizerType=r.Stretch,this.stretchType=o.Noop,this.tileBlendInput=n.LayerOnly,this.postBlendOuput=n.LayerOnly,this.applyColormap=!0}}e([p({count:r.COUNT})],b.prototype,"colorizerType",void 0),e([p({count:o.COUNT})],b.prototype,"stretchType",void 0),e([p({count:n.COUNT})],b.prototype,"tileBlendInput",void 0),e([p({count:n.COUNT})],b.prototype,"postBlendOuput",void 0),e([p()],b.prototype,"applyColormap",void 0);export{h as RasterColorizerTechnique,b as RasterColorizerTechniqueConfiguration};