@arcgis/core 4.28.0-next.20230713 → 4.28.0-next.20230715

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 (273) hide show
  1. package/Basemap.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{0b28b5eec6dc67be8ce9.js → 0121bfc81b794745e024.js} +1 -1
  4. package/assets/esri/core/workers/chunks/067d3d45caeaaba18d81.js +1 -0
  5. package/assets/esri/core/workers/chunks/080a13dc08a8db498ffa.js +1 -0
  6. package/assets/esri/core/workers/chunks/0dccbc6c2559fdc0c2ad.js +1 -0
  7. package/assets/esri/core/workers/chunks/{c912466351e37db68b6c.js → 14ab33573bb02d6c6b1a.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{c4b066760e9aa85b7607.js → 1b948f8429d8f9b1bbfb.js} +1 -1
  9. package/assets/esri/core/workers/chunks/204ed2ebd2d3da659791.js +1 -0
  10. package/assets/esri/core/workers/chunks/{5d5d4a4fdf5ca8d7837f.js → 239d4176ff2d5142b7f1.js} +1 -1
  11. package/assets/esri/core/workers/chunks/23bb98aaa20b180ee680.js +1 -0
  12. package/assets/esri/core/workers/chunks/27cf3ef9566d5226b0df.js +1 -0
  13. package/assets/esri/core/workers/chunks/{1c86f80d73dee1a4d9b7.js → 2f1695e4807a534e1743.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{60b422009f58d7bbb8c4.js → 3164b862a6b3f654fade.js} +1 -1
  15. package/assets/esri/core/workers/chunks/35f60625ada14eb801fd.js +1 -0
  16. package/assets/esri/core/workers/chunks/{4e4e62462deec25e82ce.js → 3a04bf1cdce263fe2191.js} +1 -1
  17. package/assets/esri/core/workers/chunks/41011207b6cc5eb6232f.js +1 -0
  18. package/assets/esri/core/workers/chunks/{8d50449c029c73136204.js → 432e3558db53574d21b4.js} +1 -1
  19. package/assets/esri/core/workers/chunks/4767f69b81d36dde9550.js +1 -0
  20. package/assets/esri/core/workers/chunks/{08ee2bd914867fd2cbd5.js → 490629c6f9fee501c9cd.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{044b15794b6403792f04.js → 4f079d0e69189c1d8bd9.js} +1 -1
  22. package/assets/esri/core/workers/chunks/4f1f4cc82fea0d1f79ec.js +1 -0
  23. package/assets/esri/core/workers/chunks/503a393327df755d8843.js +1 -0
  24. package/assets/esri/core/workers/chunks/50e05f479c7d414fc06b.js +1 -0
  25. package/assets/esri/core/workers/chunks/{3835a76c017431f19422.js → 51da3c5c50b153ce6bc7.js} +1 -1
  26. package/assets/esri/core/workers/chunks/54b97ca5f2164b941f5b.js +1 -0
  27. package/assets/esri/core/workers/chunks/5a3fb63dab89cf3418f7.js +1 -0
  28. package/assets/esri/core/workers/chunks/5ceaf1f05b219034a10c.js +1 -0
  29. package/assets/esri/core/workers/chunks/70aabffaaa0a1da8e609.js +1 -0
  30. package/assets/esri/core/workers/chunks/78cb95d1594a0cb0dd7a.js +1 -0
  31. package/assets/esri/core/workers/chunks/7f391ae5e0ea7812baca.js +1 -0
  32. package/assets/esri/core/workers/chunks/{1d2b8b937bbda91a6549.js → 82dfbc175b52c7a10475.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{036cd65514eab1749363.js → 8467d05626a3a72462c9.js} +1 -1
  34. package/assets/esri/core/workers/chunks/9038b1317f1252e31f09.js +1 -0
  35. package/assets/esri/core/workers/chunks/929ddc4d9975ed893767.js +1 -0
  36. package/assets/esri/core/workers/chunks/{e86dcc239c6a57000afc.js → 94633cc9cfb089ef010e.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{2f5f398374ff77fb17f0.js → 975eef6d20c17a0ed07b.js} +1 -1
  38. package/assets/esri/core/workers/chunks/{8913bddc76b82cb24664.js → 98cf4e744e8f2c3fc536.js} +1 -1
  39. package/assets/esri/core/workers/chunks/a00414550fa21c5662f3.js +1 -0
  40. package/assets/esri/core/workers/chunks/a3a1d4f32e518e97d071.js +1 -0
  41. package/assets/esri/core/workers/chunks/{4e2029c8cc8a5afe5759.js → a5348f117dacdcae99ee.js} +1 -1
  42. package/assets/esri/core/workers/chunks/b0f0a3178d88fa600a11.js +1 -0
  43. package/assets/esri/core/workers/chunks/b4446ce010bc4a5aa917.js +1 -0
  44. package/assets/esri/core/workers/chunks/b8a45b28a915a423d09d.js +1 -0
  45. package/assets/esri/core/workers/chunks/{fb97d39b25b0b009d2f0.js → bd9e6f38c9ec4195322a.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{30deb5a8e9a82186991d.js → c15c4bd52d4472ed50bc.js} +1 -1
  47. package/assets/esri/core/workers/chunks/{55109f141c9f120833f6.js → c3d773c93efb41088c54.js} +1 -1
  48. package/assets/esri/core/workers/chunks/c518410b1214ffc58017.js +1 -0
  49. package/assets/esri/core/workers/chunks/d55faafe2ac914a3ebd1.js +1 -0
  50. package/assets/esri/core/workers/chunks/d5fd4780d57173f3e303.js +1 -0
  51. package/assets/esri/core/workers/chunks/da01e520a1ae0048e73e.js +1 -0
  52. package/assets/esri/core/workers/chunks/dd7603c9e5fd178c88f7.js +1 -0
  53. package/assets/esri/core/workers/chunks/ddcf58937924ab5a3d76.js +1 -0
  54. package/assets/esri/core/workers/chunks/e03a0f52d438f53a3057.js +1 -0
  55. package/assets/esri/core/workers/chunks/e433440fecd0114cb23d.js +1 -0
  56. package/assets/esri/core/workers/chunks/ea1560129e426980a4e2.js +1 -0
  57. package/assets/esri/core/workers/chunks/f73e2143f8d053aef092.js +1 -0
  58. package/assets/esri/core/workers/chunks/{0a0af540f4fe64c3d292.js → fa14238f1c308a74f843.js} +1 -1
  59. package/assets/esri/themes/base/widgets/_ElevationProfile.scss +3 -0
  60. package/assets/esri/themes/dark/main.css +1 -1
  61. package/assets/esri/themes/light/main.css +1 -1
  62. package/assets/esri/themes/light/view.css +1 -1
  63. package/chunks/RibbonLine.glsl.js +57 -72
  64. package/chunks/ar.js +1 -1
  65. package/chunks/ar2.js +1 -1
  66. package/chunks/bg_BG.js +1 -1
  67. package/chunks/bg_BG2.js +1 -1
  68. package/chunks/bs_BA.js +1 -1
  69. package/chunks/bs_BA2.js +1 -1
  70. package/chunks/ca_ES.js +1 -1
  71. package/chunks/ca_ES2.js +1 -1
  72. package/chunks/chartUtilsAm5.js +1 -1
  73. package/chunks/cs_CZ.js +1 -1
  74. package/chunks/cs_CZ2.js +1 -1
  75. package/chunks/da_DK.js +1 -1
  76. package/chunks/da_DK2.js +1 -1
  77. package/chunks/de_CH.js +1 -1
  78. package/chunks/de_CH2.js +1 -1
  79. package/chunks/de_DE.js +1 -1
  80. package/chunks/de_DE2.js +1 -1
  81. package/chunks/el_GR.js +1 -1
  82. package/chunks/el_GR2.js +1 -1
  83. package/chunks/en_CA.js +1 -1
  84. package/chunks/en_CA2.js +1 -1
  85. package/chunks/en_US.js +1 -1
  86. package/chunks/en_US2.js +1 -1
  87. package/chunks/es_ES.js +1 -1
  88. package/chunks/es_ES2.js +1 -1
  89. package/chunks/et_EE.js +1 -1
  90. package/chunks/et_EE2.js +1 -1
  91. package/chunks/fi_FI.js +1 -1
  92. package/chunks/fi_FI2.js +1 -1
  93. package/chunks/fr_FR.js +1 -1
  94. package/chunks/fr_FR2.js +1 -1
  95. package/chunks/he_IL.js +1 -1
  96. package/chunks/he_IL2.js +1 -1
  97. package/chunks/hr_HR.js +1 -1
  98. package/chunks/hr_HR2.js +1 -1
  99. package/chunks/hu_HU.js +1 -1
  100. package/chunks/hu_HU2.js +1 -1
  101. package/chunks/id_ID.js +1 -1
  102. package/chunks/id_ID2.js +1 -1
  103. package/chunks/it_IT.js +1 -1
  104. package/chunks/it_IT2.js +1 -1
  105. package/chunks/ja_JP.js +1 -1
  106. package/chunks/ja_JP2.js +1 -1
  107. package/chunks/ko_KR.js +1 -1
  108. package/chunks/ko_KR2.js +1 -1
  109. package/chunks/lt_LT.js +1 -1
  110. package/chunks/lt_LT2.js +1 -1
  111. package/chunks/lv_LV.js +1 -1
  112. package/chunks/lv_LV2.js +1 -1
  113. package/chunks/nb_NO.js +1 -1
  114. package/chunks/nb_NO2.js +1 -1
  115. package/chunks/nl_NL.js +1 -1
  116. package/chunks/nl_NL2.js +1 -1
  117. package/chunks/pl_PL.js +1 -1
  118. package/chunks/pl_PL2.js +1 -1
  119. package/chunks/pt_BR.js +1 -1
  120. package/chunks/pt_BR2.js +1 -1
  121. package/chunks/pt_PT.js +1 -1
  122. package/chunks/pt_PT2.js +1 -1
  123. package/chunks/ro_RO.js +1 -1
  124. package/chunks/ro_RO2.js +1 -1
  125. package/chunks/ru_RU.js +1 -1
  126. package/chunks/ru_RU2.js +1 -1
  127. package/chunks/sk_SK.js +1 -1
  128. package/chunks/sk_SK2.js +1 -1
  129. package/chunks/sl_SL.js +1 -1
  130. package/chunks/sl_SL2.js +1 -1
  131. package/chunks/sr_RS.js +1 -1
  132. package/chunks/sr_RS2.js +1 -1
  133. package/chunks/sv_SE.js +1 -1
  134. package/chunks/sv_SE2.js +1 -1
  135. package/chunks/th_TH.js +1 -1
  136. package/chunks/th_TH2.js +1 -1
  137. package/chunks/tr_TR.js +1 -1
  138. package/chunks/tr_TR2.js +1 -1
  139. package/chunks/uk_UA.js +1 -1
  140. package/chunks/uk_UA2.js +1 -1
  141. package/chunks/vi_VN.js +1 -1
  142. package/chunks/vi_VN2.js +1 -1
  143. package/chunks/zh_Hans.js +1 -1
  144. package/chunks/zh_Hans2.js +1 -1
  145. package/chunks/zh_Hant.js +1 -1
  146. package/chunks/zh_Hant2.js +1 -1
  147. package/config.js +1 -1
  148. package/core/colorUtils.js +1 -1
  149. package/core/image/apng.js +1 -1
  150. package/core/image/gif.js +1 -1
  151. package/core/urlUtils.js +1 -1
  152. package/core/workers/WorkerOwner.js +1 -1
  153. package/core/workers/staticWorkerMessages.js +5 -0
  154. package/geometry/projection.js +1 -1
  155. package/interfaces.d.ts +42 -2
  156. package/kernel.js +1 -1
  157. package/layers/support/ImageElement.js +1 -1
  158. package/layers/video/VideoController.js +1 -1
  159. package/package.json +1 -1
  160. package/portal/Portal.js +1 -1
  161. package/support/BasemapStyle.js +5 -0
  162. package/support/basemapUtils.js +1 -1
  163. package/support/revision.js +1 -1
  164. package/symbols/support/previewSymbol2D.js +1 -1
  165. package/views/2d/GoToManager.js +5 -0
  166. package/views/2d/engine/Stage.js +1 -1
  167. package/views/2d/engine/webgl/Overlay.js +1 -1
  168. package/views/2d/engine/webgl/animatedFormats/utils.js +1 -1
  169. package/views/2d/interactive/editingTools/ControlPointsTransformTool.js +1 -1
  170. package/views/2d/interactive/editingTools/TransformTool.js +1 -1
  171. package/views/2d/layers/BaseLayerViewGL2D.js +1 -1
  172. package/views/2d/layers/MediaLayerView2D.js +1 -1
  173. package/views/2d/layers/TileLayerView2D.js +1 -1
  174. package/views/2d/support/engineHelpers.js +1 -1
  175. package/views/2d/support/screenshotUtils.js +5 -0
  176. package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementVisualization.js +1 -1
  177. package/views/3d/analysis/Dimension/DimensionTool.js +1 -1
  178. package/views/3d/analysis/Dimension/DimensionVisualization.js +1 -1
  179. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  180. package/views/3d/analysis/Dimension/LengthDimensionVisualization.js +1 -1
  181. package/views/3d/analysis/Dimension/lengthDimensionConstraintUtils.js +1 -1
  182. package/views/3d/analysis/Dimension/lengthDimensionManipulatorUtils.js +1 -1
  183. package/views/3d/analysis/Dimension/settings.js +1 -1
  184. package/views/3d/analysis/DirectLineMeasurement/DirectLineMeasurementVisualization.js +1 -1
  185. package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
  186. package/views/3d/analysis/LineOfSight/LineOfSightToolConfiguration.js +1 -1
  187. package/views/3d/analysis/Slice/SliceTool.js +1 -1
  188. package/views/3d/analysis/Slice/SliceVisualization.js +1 -1
  189. package/views/3d/analysis/Slice/settings.js +1 -1
  190. package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
  191. package/views/3d/interactive/SnappingVisualizer3D.js +1 -1
  192. package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
  193. package/views/3d/interactive/editingTools/lineGraphicVisualElementUtils.js +1 -1
  194. package/views/3d/interactive/editingTools/manipulations/MoveXYAxisManipulation.js +1 -1
  195. package/views/3d/interactive/editingTools/manipulations/MoveXYDiscManipulation.js +1 -1
  196. package/views/3d/interactive/editingTools/manipulations/MoveZManipulation.js +1 -1
  197. package/views/3d/interactive/editingTools/originGraphicVisualElementUtils.js +1 -1
  198. package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
  199. package/views/3d/interactive/editingTools/settings.js +1 -1
  200. package/views/3d/interactive/editingTools/transformGraphic/ExtentTransformTool.js +1 -1
  201. package/views/3d/interactive/editingTools/transformGraphic/GraphicScaleRotateTransform.js +1 -1
  202. package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DView.js +1 -1
  203. package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DView.js +1 -1
  204. package/views/3d/interactive/visualElements/MeasurementArrowVisualElement.js +1 -1
  205. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  206. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  207. package/views/3d/terrain/TerrainRenderer.js +1 -1
  208. package/views/3d/terrain/TerrainSurface.js +1 -1
  209. package/views/3d/terrain/Tile.js +1 -1
  210. package/views/3d/terrain/TileRenderer.js +1 -1
  211. package/views/3d/terrain/TileTexture.js +1 -1
  212. package/views/3d/webgl-engine/core/shaderLibrary/shading/LineStipple.glsl.js +12 -13
  213. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  214. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBuffer.js +1 -1
  215. package/views/3d/webgl-engine/lib/edgeRendering/strokes.js +1 -1
  216. package/views/3d/webgl-engine/lib/glUtil3D.js +1 -1
  217. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  218. package/views/3d/webgl-engine/materials/internal/WaterTextureRepository.js +1 -1
  219. package/views/3d/webgl-engine/shaders/HUDMaterialTechnique.js +1 -1
  220. package/views/3d/webgl-engine/shaders/RibbonLineTechniqueConfiguration.js +1 -1
  221. package/views/3d/webgl-engine/statistics/RendererPerformanceInfo.js +1 -1
  222. package/views/MapView.js +1 -1
  223. package/views/Theme.js +5 -0
  224. package/views/View.js +1 -1
  225. package/views/interactive/SegmentLabels.js +1 -1
  226. package/views/support/colorUtils.js +1 -1
  227. package/views/webgl/Texture.js +1 -1
  228. package/widgets/AreaMeasurement2D/AreaMeasurement2DTool.js +1 -1
  229. package/widgets/Attachments.js +1 -1
  230. package/widgets/DistanceMeasurement2D/DistanceMeasurement2DTool.js +1 -1
  231. package/widgets/ElevationProfile/support/InputRepresentation3D.js +1 -1
  232. package/widgets/ElevationProfile/support/chartUtils.js +1 -1
  233. package/widgets/Feature/FeatureMedia/chartCommon.js +1 -1
  234. package/widgets/Feature/FeatureMedia.js +1 -1
  235. package/widgets/support/chartUtils.js +1 -1
  236. package/widgets/support/chartUtilsAm5.js +1 -1
  237. package/assets/esri/core/workers/chunks/05f3374114bce72d3560.js +0 -1
  238. package/assets/esri/core/workers/chunks/10028df973ef7f9531c8.js +0 -1
  239. package/assets/esri/core/workers/chunks/1cbb03eec9dc23ef043b.js +0 -1
  240. package/assets/esri/core/workers/chunks/289061552a2a64bebd76.js +0 -1
  241. package/assets/esri/core/workers/chunks/308eeeaec591b4eea1de.js +0 -1
  242. package/assets/esri/core/workers/chunks/3155c750fc5a4e04a785.js +0 -1
  243. package/assets/esri/core/workers/chunks/346f67995b327bca8ee0.js +0 -1
  244. package/assets/esri/core/workers/chunks/3736e17dd6461f74cfaf.js +0 -1
  245. package/assets/esri/core/workers/chunks/37e60f9ca86f9d4bf4ea.js +0 -1
  246. package/assets/esri/core/workers/chunks/3a0b45ecc48e23a3a5d5.js +0 -1
  247. package/assets/esri/core/workers/chunks/417377c8e76944f428a7.js +0 -1
  248. package/assets/esri/core/workers/chunks/498dca81073e1fb477b9.js +0 -1
  249. package/assets/esri/core/workers/chunks/536962375ce4f1394481.js +0 -1
  250. package/assets/esri/core/workers/chunks/64bb4093c019a02d5309.js +0 -1
  251. package/assets/esri/core/workers/chunks/69de4733173ee2dee6e1.js +0 -1
  252. package/assets/esri/core/workers/chunks/6dcffe6683a798a42c78.js +0 -1
  253. package/assets/esri/core/workers/chunks/7a898d167029ee11a680.js +0 -1
  254. package/assets/esri/core/workers/chunks/7a973d70e6bc42d804ee.js +0 -1
  255. package/assets/esri/core/workers/chunks/7d9d2629af373c84624f.js +0 -1
  256. package/assets/esri/core/workers/chunks/885cb0da78e6853b23a4.js +0 -1
  257. package/assets/esri/core/workers/chunks/8e28862296972e9e6f82.js +0 -1
  258. package/assets/esri/core/workers/chunks/928431e1c449c6054547.js +0 -1
  259. package/assets/esri/core/workers/chunks/afdf30439d71a7cc19ae.js +0 -1
  260. package/assets/esri/core/workers/chunks/b1fa1571fd98d3b8dffe.js +0 -1
  261. package/assets/esri/core/workers/chunks/b20167d9163d0ee74b65.js +0 -1
  262. package/assets/esri/core/workers/chunks/b2a0e3e1dfccda7ed12e.js +0 -1
  263. package/assets/esri/core/workers/chunks/c09db831248054600e16.js +0 -1
  264. package/assets/esri/core/workers/chunks/dcccc9760998271254b5.js +0 -1
  265. package/assets/esri/core/workers/chunks/ddea45acae89759e57fa.js +0 -1
  266. package/assets/esri/core/workers/chunks/e039108eb3a592f6d8e3.js +0 -1
  267. package/assets/esri/core/workers/chunks/e70314ac10cc1f8f9f86.js +0 -1
  268. package/assets/esri/core/workers/chunks/f2d399b394a1a9156214.js +0 -1
  269. package/assets/esri/core/workers/chunks/f74d4e1eecec06f84ee2.js +0 -1
  270. package/assets/esri/core/workers/chunks/fb7eff7f76386f81d57b.js +0 -1
  271. package/assets/esri/core/workers/chunks/fe277d33b5b8a11c76df.js +0 -1
  272. package/core/analysisThemeUtils.js +0 -5
  273. package/views/support/createScreenshotPlan.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.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../../chunks/tslib.es6.js";import"../../../../../geometry.js";import t from"../../../../../core/Accessor.js";import{removeUnordered as i}from"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import a from"../../../../../core/Evented.js";import n from"../../../../../core/Handles.js";import{handlesGroup as o,makeHandle as r,destroyHandle as s}from"../../../../../core/handleUtils.js";import{destroyMaybe as l,removeMaybe as p}from"../../../../../core/maybe.js";import{zeroMeters as h,scale as d,createLength 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/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 x,h as O,s as b,a as E,g as G}from"../../../../../chunks/vec3.js";import{f as S,c as w}from"../../../../../chunks/vec3f64.js";import{UpdatingHandles as I}from"../../../../../core/support/UpdatingHandles.js";import V from"../../../../../geometry/Polyline.js";import{hasCompatibleTopology as H}from"../../../../../geometry/support/coordsUtils.js";import{projectPoint as A}from"../../../../../geometry/support/plane.js";import{sv3d as T}from"../../../../../geometry/support/vectorStacks.js";import{makeDehydratedPoint as D}from"../../../../../layers/graphics/dehydratedFeatures.js";import{getGraphicEffectiveElevationInfo as L}from"../../../../../support/elevationInfoUtils.js";import{isVolumetricSymbol as j}from"../../../../../symbols/support/utils.js";import{Manipulator3D as P}from"../../Manipulator3D.js";import{createManipulatorMaterial as U,createManipulatorOutlineMaterial as N,placeAtGraphic as C}from"../../manipulatorUtils.js";import{RenderObject as k}from"../../RenderObject.js";import{SegmentLabels3D as R}from"../../SegmentLabels3D.js";import{SnappingVisualizer3D as F}from"../../SnappingVisualizer3D.js";import{screenToRenderPlaneFromEvent as z,convertToMapCoordinates as X,screenToMapXYAtLocation as Z,screenToMapXYForGraphicAtLocation as Y}from"../dragEventPipeline3D.js";import{ManipulatorType as q}from"../ManipulatorType.js";import{canMoveZ as W}from"../manipulatorUtils.js";import{getSettings as K}from"../settings.js";import{createVisualElements as B}from"../visualElementUtils.js";import{DISC_RADIUS_SMALL as J}from"../manipulations/config.js";import{ManipulationType as Q,MoveManipulation as $}from"../manipulations/MoveManipulation.js";import{shapeOrientation as ee,axisConstrainedDragSign as te}from"../manipulations/moveUtils.js";import{MoveXYGraphicManipulation as ie}from"../manipulations/MoveXYGraphicManipulation.js";import{createEdgeOffsetIntersectionPlane as ae,createEdgeOffsetOperation as ne,edgeOffsetRotationMatrix as oe,screenEdgeLengthSquared as re}from"./edgeOffsetUtils.js";import{OutlineVisualElement as se}from"../../visualElements/OutlineVisualElement.js";import{GraphicState as le}from"../../../layers/graphics/GraphicState.js";import{createExtrudedTriangle as pe,createSphereGeometry as he}from"../../../webgl-engine/lib/GeometryUtil.js";import{MouseButton as de}from"../../../../input/IViewEvents.js";import{sceneSnappingAtLocation as ue,addMapDelta as ce,createManipulatorDragEventPipeline as me,dragAtLocation as ge,addScreenDelta as _e}from"../../../../interactive/dragEventPipeline.js";import{ManipulatorStateFlags as fe,ManipulatorStateCustomFlags as ve}from"../../../../interactive/interfaces.js";import{EditGeometryOperations as Me}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import{AccumulationBehaviour as ye}from"../../../../interactive/editGeometry/interfaces.js";import{SnappingContext as xe}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as Oe}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{ReshapeEdgeOffsetTooltipInfo as be}from"../../../../interactive/tooltip/ReshapeTooltipInfos.js";import{Tooltip as Ee}from"../../../../interactive/tooltip/Tooltip.js";import{TranslateGraphicZTooltipInfo as Ge,TranslateGraphicXYTooltipInfo as Se,TranslateGraphicTooltipInfo as we,TranslateVertexZTooltipInfo as Ie,TranslateVertexXYTooltipInfo as Ve,TranslateVertexTooltipInfo as He}from"../../../../interactive/tooltip/TranslateTooltipInfos.js";import{autoAreaByElevationMode as Ae}from"../../../../support/automaticAreaMeasurementUtils.js";import{autoHorizontalDistanceByElevationModeBetweenPoints as Te,autoLengthByElevationMode as De}from"../../../../support/automaticLengthMeasurementUtils.js";import{unitRGBAFromColor as Le}from"../../../../support/colorUtils.js";import{verticalSignedDistanceBetweenPoints as je,elevationOfPoint as Pe}from"../../../../support/euclideanLengthMeasurementUtils.js";import{geodesicDistance as Ue}from"../../../../support/geodesicLengthMeasurementUtils.js";import Ne from"../../../../../geometry/SpatialReference.js";let Ce=class extends(a.EventedMixin(t)){constructor(e){super(e),this._selectedIndex=0,this._manipulatorHandles=new n,this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0,this._reshapeEventState=Ye.NONE,this._updatingHandles=new I,this._recreatingManipulators=!1,this.outputGeometry=null,this._vertexLaserLineVisualElement=null;const t=K(e.tool.view).manipulators,i=t.vertex;this._vertexManipulatorMaterial=U(Le(i.color),i.renderOccluded),this._vertexManipulatorOutlineMaterial=N(Le(i.outlineColor),i.renderOccluded),this._vertexManipulatorHoverOutlineMaterial=N(Le(i.hoverOutlineColor),i.renderOccluded);const a=t.edge;this._edgeManipulatorMaterial=U(Le(a.color),a.renderOccluded),this._edgeManipulatorOutlineMaterial=N(Le(a.outlineColor),a.renderOccluded);const o=t.edgeOffset;this._edgeOffsetManipulatorMaterial=U(Le(o.color),o.renderOccluded,!1),this._edgeOffsetManipulatorHoverMaterial=U(Le(o.hoverColor),o.renderOccluded,!1);const r=t.selected;this._selectedManipulatorMaterial=U(Le(r.color),r.renderOccluded),this._selectedManipulatorOutlineMaterial=N(Le(r.outlineColor),r.renderOccluded),this._selectedManipulatorHoverOutlineMaterial=N(Le(r.hoverOutlineColor),r.renderOccluded)}initialize(){const{graphic:e,view:t}=this,i=this._graphicState=new le({graphic:e});this._tooltip=new Ee({view:t}),this.addHandles([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})=>{null!=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=l(this._segmentLabels),this._tooltip=l(this._tooltip),this._removeManipulators(),this._updatingHandles.destroy()}get inputGeometry(){return null!=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)}onManipulatorSelectionChanged(){this.emit("manipulators-changed")}_removeManipulators(){this._manipulatorHandles.removeAll(),this._moveManipulation=l(this._moveManipulation),this._graphicMoveManipulation=l(this._graphicMoveManipulation),this.manipulators.removeAll(),this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0}_createManipulators(e){if(null==this._editGeometryOperations)return;const t=L(this.graphic);for(const i of this._editGeometryOperations.data.components){const a=e?.byComponentIndex.get(i.index);for(const e of i.vertices){const i=a?.has(e.index);this._createVertexOrEdgeManipulator(e,t,i)}for(const e of i.edges)this._createVertexOrEdgeManipulator(e,t)}this._createGraphicMoveManipulation(),this._createMoveManipulation(t),this._createVisualElements()}get canRedo(){return null!=this._editGeometryOperations&&this._editGeometryOperations.canRedo}get canUndo(){return null!=this._editGeometryOperations&&this._editGeometryOperations.canUndo}redo(){if(null==this._editGeometryOperations)return null;const e=this._editGeometryOperations.redo();return null!=e&&(this.outputGeometry=this._editGeometryOperations.data.geometry,this._recreateManipulators()),e}undo(){if(null==this._editGeometryOperations)return null;this.emit("undo");const e=this._editGeometryOperations.undo();return null!=e&&(this.outputGeometry=this._editGeometryOperations.data.geometry,this._recreateManipulators()),e}_recreateManipulators(){this._recreatingManipulators||(this._recreatingManipulators=!0,this._removeManipulators(),this._tooltip.clear(),this._createManipulators(),this._recreatingManipulators=!1)}_recreateEditGeometryAndManipulators(e){const t={byComponentIndex:new Map};if(null!=e&&null!=this.inputGeometry&&H(e,this.inputGeometry))for(const a of this._manipulatorInfos)if("vertex"===a.type&&a.manipulator.selected){const{index:e,component:{index:i}}=a.handle,{byComponentIndex:n}=t,o=n.get(i)||new Set;o.add(e),n.set(i,o)}if(this._recreatingManipulators=!0,this._removeManipulators(),this._tooltip.clear(),this._editGeometryOperations=l(this._editGeometryOperations),this._segmentLabels=l(this._segmentLabels),null==e)return void(this._recreatingManipulators=!1);const i="mesh"===e.type?e.anchor:e;this._editGeometryOperations=Me.fromGeometry(i,this.view.state.viewingMode),this._createManipulators(t),this._segmentLabels=new R({context:{view:this.view,editGeometryOperations:this._editGeometryOperations,elevationInfo:L(this.graphic),labelOptions:this._labelOptions,graphic:this.graphic,graphicState:this._graphicState},visible:this._labelOptions.enabled}),this._recreatingManipulators=!1}_perGraphicManipulatorDragAction(e,t){if("end"===t.action)return t;let i=0;const a=[],n=this._manipulatorInfos.some((e=>"vertex"===e.type&&e.manipulator.selected)),o=e===qe.SELECTED_OR_ALL&&n;for(const r of this._manipulatorInfos)"vertex"===r.type&&(r.manipulator.grabbing||o&&!r.manipulator.selected||a.push(r),i++);if(0===a.length)return t;this._moveVertices(a,t);if(a.length===i){if(this._updateEventState(Ye.MOVING),this.destroyed)return t;this.emit("move",{type:"move",dx:t.screenDeltaX,dy:t.screenDeltaY,mover:this.graphic})}else{if(this._updateEventState(Ye.RESHAPING),this.destroyed)return t;this.emit("reshape",{type:"reshape",mover:this.graphic})}return t}_isMultiVertexSelection(){return this._manipulatorInfos.reduce(((e,t)=>"vertex"===t.type&&t.manipulator.selected?e+1:e),0)>1}_perVertexManipulatorDragAction(e){if(this._updateEventState(Ye.RESHAPING),this.destroyed)return;const{mapDeltaX:t,mapDeltaY:i,mapDeltaZ:a}=e;if(!t&&!i&&!a)return;const n=[];for(const o of this._manipulatorInfos)"vertex"===o.type&&(o.manipulator.selected&&!o.manipulator.grabbing||o===e.info)&&n.push(o);this._moveVertices(n,e,ye.ACCUMULATE_STEPS),this.emit("reshape",{type:"reshape",mover:this.graphic})}_updateEventState(e){if(e===this._reshapeEventState)return!1;switch(e){case Ye.NONE:if(0!==this._numGrabbing||0!==this._numDragging)return!1;switch(this._reshapeEventState){case Ye.MOVING:this.emit("move",{type:"move-stop",dx:0,dy:0,mover:this.graphic});break;case Ye.RESHAPING:this.emit("reshape",{type:"reshape-stop",mover:this.graphic})}break;case Ye.MOVING:switch(this._reshapeEventState){case Ye.NONE:this.emit("move",{type:"move-start",dx:0,dy:0,mover:this.graphic});break;case Ye.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 Ye.RESHAPING:switch(this._reshapeEventState){case Ye.NONE:this.emit("reshape",{type:"reshape-start",mover:this.graphic});break;case Ye.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}_createGraphicMoveManipulation(){const{tool:e,view:t}=this,i=this._graphicState;if(this._graphicMoveManipulation=new ie({tool:e,view:t,graphicState:i}),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=this._editGeometryOperations.createUndoGroup()),t))).next((e=>this._perGraphicManipulatorDragAction(qe.ALL,e))).next((e=>(this._updateTranslateGraphicTooltip(Q.XY,e),e))).next((t=>{"end"===t.action&&(this._tooltip.clear(),e=p(e))})),a.next((()=>this._onDragCancel(!0,(()=>e=p(e)))))}))),this._graphicMoveManipulation.forEachManipulator((e=>this._manipulatorHandles.add(this._watchAndUpdateGrabState(e,!1))))}else this._graphicMoveManipulation.forEachManipulator((e=>{e.grabbable=!1,e.cursor=null}));this._graphicMoveManipulation.forEachManipulator((e=>this._manipulatorHandles.add(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()})))))}_createMoveManipulation(e){const{graphic:t,tool:i,view:a}=this,n=this._graphicState;this._moveManipulation=new $({tool:i,view:a,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:this.enableZShape&&W(t),snapToScene:!1,radius:$.radiusForSymbol(t.symbol)}),this._moveManipulation.forEachManipulator((e=>this.addHandles([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()})),this._watchAndUpdateGrabState(e,!1)])));const o=e=>t=>{this.addHandles(t.events.on("focus-changed",(({action:t})=>{"focus"===t&&this._tooltipOptions.enabled?this._updateTranslateTooltip(e):this._tooltip.clear()})))};this._moveManipulation.xyManipulation.forEachManipulator(o(Q.XY)),this._moveManipulation.xyAxisManipulation.forEachManipulator(o(Q.XY_AXIS)),this._moveManipulation.zManipulation.forEachManipulator(o(Q.Z)),this._moveManipulation.elevationInfo={mode:"absolute-height",offset:0};const r=t.geometry.spatialReference;this.addHandles([this._moveManipulation.createDragPipeline(((a,n,o,r,s)=>{const{snappingStep:l,cancelSnapping:p}=Oe({predicate:e=>!!e.info,snappingManager:i.snappingManager,snappingContext:new xe({editGeometryOperations:this._editGeometryOperations,elevationInfo:e,pointer:s,excludeFeature:t,visualizer:new F}),updatingHandles:this._updatingHandles,useZ:!1});return r=r.next((e=>(this._onDragCancel(),e))).next(p),{steps:o=o.next((e=>this._trackNumDragging(e))).next((e=>{const t=this._manipulatorInfos.filter((e=>"vertex"===e.type&&e.manipulator.selected));return e.manipulatorType===q.TRANSLATE_XY&&1===t.length?{...e,info:t[0],snapOrigin:t[0].handle.pos}:e})).next(ue(this.view,e,t)).next(...l).next(ce()).next((e=>this._perGraphicManipulatorDragAction(qe.SELECTED_OR_ALL,e))).next((e=>(this._updateTranslateTooltip(a,e),e))),cancel:r}}),e,r,t),c((()=>n.displaying),(()=>this._updateMoveManipulationPosition()),g),n.on("changed",(()=>{this._recreatingManipulators||this._updateMoveManipulationPosition()})),c((()=>n.isDraped),(e=>{this._updateMoveManipulationPosition();const t="align-move-manipulation";e?this.addHandles(this.view.elevationProvider.on("elevation-change",(()=>this._updateMoveManipulationPosition())),t):this.removeHandles(t)}),g)])}_createVisualElements(){const{graphic:e,view:t}=this,i=B({view:t,graphic:e,forEachManipulator:e=>{if(!this.destroyed&&!this._recreatingManipulators){this._graphicMoveManipulation.forEachManipulator(e),this._moveManipulation.forEachManipulator(e);for(const t of this._manipulatorInfos)e(t.manipulator,q.TRANSLATE_XY)}},onManipulatorsChanged:e=>this.on("manipulators-changed",e)});null!=i&&(this._outlineVisualElement=i.visualElement instanceof se?i.visualElement:null),null!=this._outlineVisualElement&&this._manipulatorHandles.add(this._outlineVisualElement.events.on("attachment-origin-changed",(()=>{this._graphicState.isDraped||this._updateMoveManipulationPosition()}))),this._manipulatorHandles.add(i)}_createEdgeOffsetManipulator(e,t=L(this.graphic)){const i=K(this.view).manipulators.edgeOffset,a=i.size/2,n=a+i.collisionPadding,r=a/n,s=r*Math.sqrt(3)/2;null==this._edgeOffsetManipulatorGeometryInside&&(this._edgeOffsetManipulatorGeometryInside=pe(this._edgeOffsetManipulatorMaterial,s,r/2,r/2,i.height,i.offset)),null==this._edgeOffsetManipulatorGeometryOutside&&(this._edgeOffsetManipulatorGeometryOutside=pe(this._edgeOffsetManipulatorMaterial,-s,r/2,r/2,i.height,-i.offset));const l=[new k(this._edgeOffsetManipulatorGeometryInside.instantiate(),fe.Unfocused),new k(this._edgeOffsetManipulatorGeometryInside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),fe.Focused),new k(this._edgeOffsetManipulatorGeometryOutside.instantiate(),fe.Unfocused),new k(this._edgeOffsetManipulatorGeometryOutside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),fe.Focused)],p=new P({view:this.view,renderObjects:l,elevationInfo:"on-the-ground"!==t.mode||j(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,metadata:{deleting:!1}}),h=new P({view:this.view,worldSized:!0,worldOriented:!1,available:!(!this.graphic.visible||!this.graphic.layer?.visible),collisionPriority:-10,cursor:this.enableMoveGraphic?"move":"default",metadata:{deleting:!1}}),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=[];for(const o of[d.handle.leftVertex,d.handle.rightVertex]){const e=this._getManipulatorInfoFromHandle(o);null!=e&&u.push(e.manipulator.events.on("location-update",(()=>this._updateEdgeOffsetManipulator(d))))}d.locationUpdateHandle=o(u),this._manipulatorHandles.add(d.locationUpdateHandle,p),this._manipulatorHandles.add([this._watchAndUpdateGrabState(p,!0),this._watchAndUpdateGrabState(h,!0)],p),this._manipulatorHandles.add(me(p,this._createEdgeOffsetPipeline(d,t)),p),this._manipulatorHandles.add(me(h,((e,i,a,n)=>{if("touch"===n){this._createEdgeOffsetPipeline(d,t)(e,i,a)}else if(this.enableMoveGraphic){const n=this.graphic,o=null!=n.geometry?n.geometry.spatialReference:null;i.next((e=>this._trackNumDragging(e))).next(ge(this.view,e.elevationAlignedLocation)).next(Z(this.view,e.elevationAlignedLocation,t,o,n)).next(_e()).next(ce()).next((e=>this._perGraphicManipulatorDragAction(qe.ALL,e))).next((e=>(this._updateTranslateGraphicTooltip(Q.XY,e),e))).next((e=>{"end"===e.action&&this._tooltip.clear()})),a.next((()=>this._onDragCancel(!e.metadata.deleting)))}})),p);const c=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",c),h.events.on("immediate-click",c),p.events.on("focus-changed",(({action:e})=>{const t=this._tooltipOptions;if("focus"===e&&t.enabled){const e=this._tooltip.info=new be({tooltipOptions:t});this._updateTooltipAreaOrTotalLength(e)}else 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=()=>{e.visibilityHandle=p(e.visibilityHandle);const n=this._getManipulatorInfoFromHandle(e.handle.leftVertex),s=this._getManipulatorInfoFromHandle(e.handle.rightVertex),l=null!=n&&null!=s&&re(n.manipulator.renderLocation,s.manipulator.renderLocation,this.view.state.camera)<t;(!i.focused&&!a.focused||l)&&(i.grabbable=!l,a.grabbable=!l,e.visibilityHandle=o([i.disableDisplay(),r((()=>{i.grabbable=!0,a.grabbable=this.enableMoveGraphic}))]))};this._manipulatorHandles.add([i.events.on("focus-changed",n),a.events.on("focus-changed",n),r((()=>{p(e.visibilityHandle),a.metadata.deleting=!0,this.manipulators.remove(a)}))],i),n()}_updateEdgeOffsetManipulator(e){this._updateManipulatorPosition(e);const{coordinateHelper:t}=this._editGeometryOperations.data,i=ae(this.view,e.manipulator.elevationAlignedLocation,ne(t,e.handle,e.manipulator.elevationInfo)),a=this._getManipulatorInfoFromHandle(e.handle.leftVertex),n=this._getManipulatorInfoFromHandle(e.handle.rightVertex);if(null==a||null==n)return;const o=a.manipulator.renderLocation,r=n.manipulator.renderLocation,s=null!=i?oe(i,o,r):M;e.manipulator.modelTransform=s,e.edgeManipulator.elevationAlignedLocation=e.manipulator.elevationAlignedLocation,e.edgeManipulator.modelTransform=s;const l=y(x(ze,o,r))/2;e.edgeManipulator.collisionType={type:"line",paths:[[[-l,0,0],[l,0,0]]]}}_createEdgeOffsetPipeline(e,t){return(i,a,n)=>{this._clearSelection();const{step:o,cleanup:r}=this._initializeEdgeOffset(e,t);a.next((e=>this._trackNumDragging(e))).next(ge(this.view,i.elevationAlignedLocation)).next(o).next(z(this.view)).next(X(this.view,this._editGeometryOperations.data.spatialReference)).next(ce()).next(this._applyComputeEdgeOffsetDistanceStep()).next(this._applyEdgeOffsetStep(e)).next(this._showEdgeOffsetTooltip()).next((e=>{"end"===e.action&&r()})),n.next((()=>{i.metadata.deleting||(r(),this._onDragCancel())}))}}_initializeEdgeOffset(e,t){const{view:i}=this,a=this._editGeometryOperations,n=ne(a.data.coordinateHelper,e.handle,t),r=a.createUndoGroup(),l=ae(i,e.manipulator.elevationAlignedLocation,n);if(n.requiresSplitEdgeLeft){const t=this._getManipulatorInfoFromHandle(e.handle.leftVertex.leftEdge);null!=t&&this._splitEdgeManipulator(t,1)}if(n.requiresSplitEdgeRight){const t=this._getManipulatorInfoFromHandle(e.handle.rightVertex.rightEdge);null!=t&&this._splitEdgeManipulator(t,0)}const h=()=>new V({paths:[[e.handle.leftVertex.pos,e.handle.rightVertex.pos]],spatialReference:a.data.spatialReference}),d=K(i),u=new se({view:i,isDraped:this._graphicState.isDraped,geometry:h(),elevationInfo:e.elevationInfo,width:d.visualElements.lineGraphics.outline.width,color:Le(d.colors.accent),attached:!0,isDecoration:!0});let m;const g=()=>{this._cleanEdgeOffsetCollapsedEdges(e),m=p(m)},_=this.on("undo",g);return m=o([s(u),c((()=>this._graphicState.isDraped),(e=>u.isDraped=e)),this._graphicState.on("changed",(()=>u.geometry=h())),r,_]),{step:e=>null==n||null==l?(g(),null):{...e,operation:n,plane:l},cleanup:g}}_applyEdgeOffsetStep(e){return t=>{if(this.destroyed||null==t.operation)return t;this._updateEventState(Ye.RESHAPING);const{mapDeltaX:i,mapDeltaY:a,mapDeltaZ:n}=t;return(i||a||n)&&(this._offsetEdge(e,t),this.emit("reshape",{type:"reshape",mover:this.graphic})),t}}_applyComputeEdgeOffsetDistanceStep(){return e=>{const{operation:t,mapEnd:i}=e;return null==t||null==i?e:("start"===e.action&&t.selectArrowFromStartPoint(i),{...e,signedDistance:t.signedDistanceToPoint(i)})}}_showEdgeOffsetTooltip(){return e=>{const{mapEnd:t,signedDistance:i,operation:a}=e,n=this._tooltip,o=this._tooltipOptions;if(!o.enabled||null==i)return n.clear(),e;let r=n.info;null!=r&&"reshape-edge-offset"===r.type||(r=n.info=new be({tooltipOptions:o}));const{coordinateHelper:s}=this._editGeometryOperations.data;return r.distance="end"===e.action?h:Re(this._graphicState.isDraped,i*a.selectedArrow,t,a.plane,s),this._updateTooltipAreaOrTotalLength(r),e}}_cleanEdgeOffsetCollapsedEdges(e){const t=e.handle.leftVertex.leftEdge?.leftVertex,i=e.handle.leftVertex,a=e.handle.rightVertex.rightEdge?.rightVertex,n=e.handle.rightVertex,o=this._editGeometryOperations.data.coordinateHelper,r=[];if(t&&o.distance(t.pos,i.pos)<Xe){const e=this._getManipulatorInfoFromHandle(i);null!=e&&r.push(e)}if(o.distance(i.pos,n.pos)<Xe||a&&o.distance(a.pos,n.pos)<Xe){const e=this._getManipulatorInfoFromHandle(n);null!=e&&r.push(e)}r.length&&this._removeVertices(r)}_computeVertexManipulatorSizeAndOutline(e){const t=e.size/2,i=t+e.collisionPadding;return{size:t/i,outlineSize:(t+e.outlineSize)/i}}_createVertexOrEdgeManipulator(e,t=L(this.graphic),i=!1){const{view:a}=this,n=K(a);if("edge"===e.type){if(this.enableEdgeOffset)return this._createEdgeOffsetManipulator(e,t);if(!this.enableMidpoints)return null}if(null==this._vertexManipulatorGeometry||null==this._vertexManipulatorOutlineGeometry){const{size:e,outlineSize:t}=this._computeVertexManipulatorSizeAndOutline(n.manipulators.vertex);this._vertexManipulatorGeometry=he(this._vertexManipulatorMaterial,e,16,16),this._vertexManipulatorOutlineGeometry=he(this._vertexManipulatorOutlineMaterial,t,16,16)}if(null==this._edgeManipulatorGeometry||null==this._edgeManipulatorOutlineGeometry){const{size:e,outlineSize:t}=this._computeVertexManipulatorSizeAndOutline(n.manipulators.edge);this._edgeManipulatorGeometry=he(this._edgeManipulatorMaterial,e,16,16),this._edgeManipulatorOutlineGeometry=he(this._edgeManipulatorOutlineMaterial,t,16,16)}const{geometry:r}=this.graphic,s=r?.type,l="point"===s||"mesh"===s?[]:[new k(this._vertexManipulatorGeometry.instantiate(),Ze.Vertex|fe.Unselected),new k(this._vertexManipulatorOutlineGeometry.instantiate(),Ze.Vertex|fe.Unfocused|fe.Unselected),new k(this._vertexManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),Ze.Vertex|fe.Focused|fe.Unselected),new k(this._vertexManipulatorGeometry.instantiate({material:this._selectedManipulatorMaterial}),fe.Selected),new k(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorOutlineMaterial}),fe.Selected|fe.Unfocused),new k(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorHoverOutlineMaterial}),fe.Selected|fe.Focused)];this.enableMidpoints&&l.push(new k(this._edgeManipulatorGeometry.instantiate({material:this._vertexManipulatorMaterial}),Ze.Edge|fe.Focused|fe.Unselected),new k(this._edgeManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),Ze.Edge|fe.Focused|fe.Unselected),new k(this._edgeManipulatorGeometry.instantiate(),Ze.Edge|fe.Unfocused|fe.Unselected),new k(this._edgeManipulatorOutlineGeometry.instantiate(),Ze.Edge|fe.Unfocused|fe.Unselected));const h=new P({view:a,renderObjects:l,elevationInfo:t,focusMultiplier:1,touchMultiplier:1,available:!(!this.graphic.visible||!this.graphic.layer?.visible),metadata:{deleting:!1}});h.selected=i,this._setTypeSpecificManipulatorSettings(h,e,t);const d="edge"===e.type?{manipulator:h,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0}:{manipulator:h,handle:e,type:"vertex",selectedIndex:0};if(this._manipulatorInfos.push(d),this.manipulators.add(h),this._updateManipulatorPosition(d),"edge"===d.type){const e=[];for(const t of[d.handle.leftVertex,d.handle.rightVertex]){const i=this._getManipulatorInfoFromHandle(t);null!=i&&e.push(i.manipulator.events.on("location-update",(()=>this._updateManipulatorPosition(d))))}d.locationUpdateHandle=o(e),this._manipulatorHandles.add(d.locationUpdateHandle,h)}this._manipulatorHandles.add(this._watchAndUpdateGrabState(h,!0),h);const u=me(h,((e,i,a,n)=>{let o=null;const{snappingStep:r,cancelSnapping:s}=Oe({predicate:()=>!this._isMultiVertexSelection(),snappingManager:this.tool.snappingManager,snappingContext:new xe({editGeometryOperations:this._editGeometryOperations,elevationInfo:t,pointer:n,excludeFeature:this.graphic,visualizer:new F}),updatingHandles:this._updatingHandles,useZ:!1});a=a.next((t=>(this._onDragCancel(!e.metadata.deleting,(()=>o=p(o))),t))).next(s),i.next((e=>this._trackNumDragging(e))).next((e=>{if("start"===e.action&&(o=this._editGeometryOperations.createUndoGroup()),"edge"===d.type){const t=this._splitEdgeManipulator(d);return{...e,info:t,snapOrigin:t.handle.pos}}return{...e,info:d,snapOrigin:d.handle.pos}})).next(ge(this.view,e.elevationAlignedLocation)).next(Y(this.view,this.graphic,e.elevationAlignedLocation,e.location.spatialReference,this.graphic)).next(ue(this.view,t,this.graphic)).next(...r).next(ce()).next((t=>{this._perVertexManipulatorDragAction(t),"end"===t.action&&(o=p(o)),this._updateTranslateVertexTooltip(e,Q.XY,t)}))}));return this._manipulatorHandles.add([u,h.events.on("immediate-click",(e=>this._manipulatorClickCallback(e,d))),h.events.on("select-changed",(()=>{d.selectedIndex=++this._selectedIndex,this._updateMoveManipulationPosition()})),h.events.on("focus-changed",(({action:e})=>{"focus"===e&&"edge"!==d.type?this._updateTranslateVertexTooltip(h,Q.XY):this._tooltip.clear()}))],h),this.emit("manipulators-changed"),d}_trackNumDragging(e){switch(e.action){case"start":this._numDragging++;break;case"end":this._numDragging--}return e}_onDragCancel(e=!0,t){switch(this._numDragging--,e&&(this.undo(),this.outputGeometry=null!=this._editGeometryOperations?this._editGeometryOperations.data.geometry:null),null!=this.tool.snappingManager&&this.tool.snappingManager.doneSnapping(),this._tooltip.clear(),this._reshapeEventState){case Ye.NONE:break;case Ye.MOVING:this.emit("move",{type:"move",dx:0,dy:0,mover:this.graphic});break;case Ye.RESHAPING:this.emit("reshape",{type:"reshape",mover:this.graphic})}t&&t(),this.destroyed||this._updateEventState(Ye.NONE)}_setTypeSpecificManipulatorSettings(e,t,i){const{graphic:a,view:n}=this,o=K(n);switch(t.type){case"vertex":{e.state=Ze.Vertex,e.selectable=!0,e.cursor="move",e.collisionPriority=2;const{size:t,collisionPadding:n}=o.manipulators.vertex;e.radius=t/2+n,e.elevationInfo=i;const{geometry:r}=a,s=r?.type;e.interactive=null!=s&&"point"!==s&&"mesh"!==s;break}case"edge":{e.state=Ze.Edge,e.selectable=!1,e.cursor="copy",e.collisionPriority=-1;const{size:t,collisionPadding:n}=o.manipulators.edge;e.radius=t/2+n,e.elevationInfo="on-the-ground"!==i.mode||j(a.symbol)?{mode:"absolute-height",offset:0}:i;break}}}_watchAndUpdateGrabState(e,t){return e.events.on("grab-changed",(i=>this._onGrabStateChanged(e,t,i.action,i.pointerType)))}_onGrabStateChanged(e,t,i,a="mouse"){if(!this._recreatingManipulators){if("start"===i)t&&this._updateSelection(e),this._numGrabbing++;else if(this._numGrabbing--,this._updateEventState(Ye.NONE),this.destroyed)return;this._moveManipulation.interactive=!this._numGrabbing,("touch"!==a||this.enableEdgeOffset)&&(this._manipulatorInfos.forEach((e=>{const{manipulator:t}=e,{geometry:i}=this.graphic,a=i?.type;t.interactive=t.grabbing||!this._numGrabbing&&null!=a&&"point"!==a&&"mesh"!==a,"edgeManipulator"in e&&(e.edgeManipulator.interactive=e.edgeManipulator.grabbing||!this._numGrabbing)})),this._graphicMoveManipulation.forEachManipulator((e=>{e.interactive=e.grabbing||!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){null!=e&&(e.manipulator.metadata.deleting=!0,this.manipulators.remove(e.manipulator),this._manipulatorHandles.remove(e.manipulator),i(this._manipulatorInfos,e),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(null==e)return;const t=this._editGeometryOperations;if("vertex"===e.type)e.manipulator.location=t.data.coordinateHelper.vectorToDehydratedPoint(e.handle.pos,Fe),e.manipulator.grabbing&&null!=this._vertexLaserLineVisualElement&&(this._vertexLaserLineVisualElement.visualElement.intersectsWorldUpAtLocation=e.manipulator.renderLocation);else if("edge"===e.type){const i=this._getManipulatorInfoFromHandle(e.handle.leftVertex),a=this._getManipulatorInfoFromHandle(e.handle.rightVertex);if(null==i||null==a)return;const n=i.manipulator,o=a.manipulator;if(null!=e.manipulator.elevationInfo&&"on-the-ground"===e.manipulator.elevationInfo.mode){const i=n.location,a=o.location,r=.5,s=i.x+r*(a.x-i.x),l=i.y+r*(a.y-i.y),p=i.hasZ&&a.hasZ?0:void 0;e.manipulator.location=D(s,l,p,t.data.spatialReference)}else O(ze,n.renderLocation,o.renderLocation,.5),e.manipulator.renderLocation=ze}}_splitEdgeManipulator(e,t=.5){const i=this._editGeometryOperations,a=i.splitEdge(e.handle,t).createdVertex;e.locationUpdateHandle=p(e.locationUpdateHandle);const n=L(this.graphic);let o;this.enableEdgeOffset?(this._removeManipulator(e),o=this._createVertexOrEdgeManipulator(a)):(o=e,o.handle=a,o.type="vertex",this._setTypeSpecificManipulatorSettings(e.manipulator,e.handle,n)),a.leftEdge&&this._createVertexOrEdgeManipulator(a.leftEdge),a.rightEdge&&this._createVertexOrEdgeManipulator(a.rightEdge),this.outputGeometry=i.data.geometry,this._updateManipulatorPosition(o),this.enableEdgeOffset||this._updateTranslateVertexTooltip(o.manipulator,Q.XY),this._updateSelection(e.manipulator);const r=this._updateEventState(Ye.RESHAPING),s=i.data.coordinateHelper.vectorToArray(o.handle.pos),l=i.data.components.indexOf(a.component);return this.emit("vertex-add",{type:"vertex-add",vertices:[{coordinates:s,componentIndex:l,vertexIndex:a.index}],added:s}),r&&this._updateEventState(Ye.NONE),o}_updateMoveManipulationPosition(){const e=b(ze,0,0,0);let t=0,i=!1,a=null,n=null;for(const o of this._manipulatorInfos)"vertex"===o.type&&(o.manipulator.selected?(t++,E(e,e,o.manipulator.renderLocation),null==a||o.selectedIndex>a.selectedIndex?(n=a,a=o):(null==n||o.selectedIndex>n.selectedIndex)&&(n=o)):i=!0);if(0===t){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&&W(this.graphic),this._moveManipulation.angle=ee(this.graphic.geometry),this._moveManipulation.radius=$.radiusForSymbol(this.graphic.symbol)}else{const e=this._graphicState.displaying;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.zManipulation.available=e&&this.enableZVertex&&W(this.graphic),this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e&&1!==t;let i=0;if(null!=a){const e=a.handle.pos,t=null!=n?n.handle.pos:a.handle.leftEdge&&a.handle.leftEdge.leftVertex?a.handle.leftEdge.leftVertex.pos:null,o=null==n&&a.handle.rightEdge&&a.handle.rightEdge.rightVertex?a.handle.rightEdge.rightVertex.pos:null;t&&o?this._moveManipulation.xyAxisManipulation.available=!1:t?i=ke(t,e):o&&(i=ke(e,o))}this._moveManipulation.angle=i,this._moveManipulation.radius=J}0!==t&&i?(G(e,e,1/t),Fe.spatialReference=this._editGeometryOperations.data.spatialReference,Fe.hasZ=!0,this.view.renderCoordsHelper.fromRenderCoords(e,Fe),this._moveManipulation.elevationAlignedLocation=Fe):null==this._outlineVisualElement||this._graphicState.isDraped||null==this._outlineVisualElement.attachmentOrigin?C(this.view,this._moveManipulation,this.graphic):this._moveManipulation.elevationAlignedLocation=this._outlineVisualElement.attachmentOrigin}_removeVertices(e){const t=new Array,i=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=i.removeVertices([a.handle]),n=e.removedVertices?.[0].createdEdge;n&&this._createVertexOrEdgeManipulator(n)}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:e.index}}));this.outputGeometry=i.data.geometry;const a=this._updateEventState(Ye.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(Ye.NONE),this.destroyed))return;this._updateMoveManipulationPosition()}}_moveVertices(e,t,i=("start"===t.action?ye.NEW_STEP:ye.ACCUMULATE_STEPS)){const a=this._editGeometryOperations;a.moveVertices(e.map((e=>e.handle)),t.mapDeltaX,t.mapDeltaY,t.mapDeltaZ,i),this.outputGeometry=a.data.geometry;for(const n of e)this._updateManipulatorPosition(n)}_offsetEdge(e,t){if(null==t.operation||null==t.signedDistance)return;const i=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===de.Right&&this._removeVertices([t])),"edge"===t.type&&e.button===de.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=this._graphicState.isDraped?"on-the-ground":"absolute-height";switch(e){case Q.XY:this._tooltip.info=new we({tooltipOptions:i}),this._updateTranslateTooltipDistance(this._tooltip.info,t,((e,t)=>Te(e,t,a)));break;case Q.XY_AXIS:this._tooltip.info=new Se({tooltipOptions:i}),this._updateTranslateTooltipDistance(this._tooltip.info,t,((e,i)=>{const n=Te(e,i,a);return d(n,te(t))}));break;case Q.Z:this._tooltip.info=new Ge({tooltipOptions:i}),this._updateTranslateTooltipDistance(this._tooltip.info,t,je)}}_updateTranslateVertexTooltip(e,t,i){const a=this._tooltipOptions;if(!a.enabled)return;let n;const o=this._graphicState.isDraped?"on-the-ground":"absolute-height";switch(t){case Q.XY:n=new He({tooltipOptions:a}),this._updateTranslateTooltipDistance(n,i,((e,t)=>Te(e,t,o))),this._updateTooltipAreaOrTotalLength(n);break;case Q.XY_AXIS:n=new Ve({tooltipOptions:a}),this._updateTranslateTooltipDistance(n,i,((e,t)=>{const a=Te(e,t,o);return d(a,te(i))})),this._updateTooltipAreaOrTotalLength(n);break;case Q.Z:n=new Ie({tooltipOptions:a}),this._updateTranslateTooltipDistance(n,i,je)}const r=Pe(e.elevationAlignedLocation);null!=r&&(n.elevation={mode:"absolute-height",...r}),this._tooltip.info=n}_updateTranslateTooltipDistance(e,t,i){if(null!=t&&"end"!==t.action){const{mapStart:a,mapEnd:n}=t,o=i(a,n);e.distance=null!=o?o:h}}_updateTooltipAreaOrTotalLength(e){const{geometry:t}=this.graphic;if(null==t)return;const i=this._graphicState.isDraped?"on-the-ground":"absolute-height";e.area="polygon"===t.type?Ae(t,i):null,e.totalLength="polyline"===t.type?De(t,i):null}get test(){return{segmentLabels:this._segmentLabels,tooltip:this._tooltip}}};function ke(e,t){return Math.atan2(t[1]-e[1],t[0]-e[0])+Math.PI/2}function Re(e,t,i,a,n){if(e){const e=n.toXYZ(n.pointToVector(i)),o=A(a,e,T.get()),r=Ue(o,e,n.spatialReference);if(null!=r)return u(r.value*Math.sign(t),r.unit)}return u(t*_(i.spatialReference),"meters")}e([f()],Ce.prototype,"_editGeometryOperations",void 0),e([f()],Ce.prototype,"_segmentLabels",void 0),e([f({constructOnly:!0})],Ce.prototype,"tool",void 0),e([f()],Ce.prototype,"_tooltip",void 0),e([f()],Ce.prototype,"inputGeometry",null),e([f()],Ce.prototype,"outputGeometry",void 0),e([f({readOnly:!0})],Ce.prototype,"updating",null),e([f()],Ce.prototype,"manipulators",null),e([f()],Ce.prototype,"view",null),e([f()],Ce.prototype,"graphic",null),e([f()],Ce.prototype,"enableZShape",null),e([f()],Ce.prototype,"enableZVertex",null),e([f()],Ce.prototype,"enableMoveGraphic",null),e([f()],Ce.prototype,"enableMidpoints",null),e([f()],Ce.prototype,"enableEdgeOffset",null),e([f()],Ce.prototype,"_labelOptions",null),e([f()],Ce.prototype,"_tooltipOptions",null),Ce=e([v("esri.views.3d.interactive.editingTools.reshapeGraphic.ReshapeOperation")],Ce);const Fe=D(0,0,void 0,Ne.WGS84),ze=w(),Xe=1e-6;var Ze,Ye,qe;!function(e){e.Vertex=ve.Custom1,e.Edge=ve.Custom2}(Ze||(Ze={})),function(e){e[e.NONE=0]="NONE",e[e.MOVING=1]="MOVING",e[e.RESHAPING=2]="RESHAPING"}(Ye||(Ye={})),function(e){e[e.ALL=0]="ALL",e[e.SELECTED_OR_ALL=1]="SELECTED_OR_ALL"}(qe||(qe={}));export{Ce as ReshapeOperation};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import"../../../../../geometry.js";import t from"../../../../../core/Accessor.js";import{removeUnordered as i}from"../../../../../core/arrayUtils.js";import{unitRGBAFromColor as a}from"../../../../../core/colorUtils.js";import"../../../../../core/has.js";import n from"../../../../../core/Evented.js";import o from"../../../../../core/Handles.js";import{handlesGroup as r,makeHandle as s,destroyHandle as l}from"../../../../../core/handleUtils.js";import{destroyMaybe as p,removeMaybe as h}from"../../../../../core/maybe.js";import{zeroMeters as d,scale as u,createLength as c}from"../../../../../core/quantityUtils.js";import{watch as m,when as g,initial as _}from"../../../../../core/reactiveUtils.js";import{getMetersPerUnitForSR as f}from"../../../../../core/unitUtils.js";import{property as v}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import{subclass as M}from"../../../../../core/accessorSupport/decorators/subclass.js";import{I as y}from"../../../../../chunks/mat4f64.js";import{l as x,b as O,h as b,s as E,a as G,g as S}from"../../../../../chunks/vec3.js";import{f as w,c as I}from"../../../../../chunks/vec3f64.js";import{UpdatingHandles as V}from"../../../../../core/support/UpdatingHandles.js";import H from"../../../../../geometry/Polyline.js";import{hasCompatibleTopology as T}from"../../../../../geometry/support/coordsUtils.js";import{projectPoint as A}from"../../../../../geometry/support/plane.js";import{sv3d as D}from"../../../../../geometry/support/vectorStacks.js";import{makeDehydratedPoint as L}from"../../../../../layers/graphics/dehydratedFeatures.js";import{getGraphicEffectiveElevationInfo as j}from"../../../../../support/elevationInfoUtils.js";import{isVolumetricSymbol as P}from"../../../../../symbols/support/utils.js";import{Manipulator3D as U}from"../../Manipulator3D.js";import{createManipulatorMaterial as N,createManipulatorOutlineMaterial as C,placeAtGraphic as k}from"../../manipulatorUtils.js";import{RenderObject as R}from"../../RenderObject.js";import{SegmentLabels3D as F}from"../../SegmentLabels3D.js";import{SnappingVisualizer3D as z}from"../../SnappingVisualizer3D.js";import{screenToRenderPlaneFromEvent as X,convertToMapCoordinates as Z,screenToMapXYAtLocation as Y,screenToMapXYForGraphicAtLocation as q}from"../dragEventPipeline3D.js";import{ManipulatorType as W}from"../ManipulatorType.js";import{canMoveZ as K}from"../manipulatorUtils.js";import{getSettings as B}from"../settings.js";import{createVisualElements as J}from"../visualElementUtils.js";import{DISC_RADIUS_SMALL as Q}from"../manipulations/config.js";import{ManipulationType as $,MoveManipulation as ee}from"../manipulations/MoveManipulation.js";import{shapeOrientation as te,axisConstrainedDragSign as ie}from"../manipulations/moveUtils.js";import{MoveXYGraphicManipulation as ae}from"../manipulations/MoveXYGraphicManipulation.js";import{createEdgeOffsetIntersectionPlane as ne,createEdgeOffsetOperation as oe,edgeOffsetRotationMatrix as re,screenEdgeLengthSquared as se}from"./edgeOffsetUtils.js";import{OutlineVisualElement as le}from"../../visualElements/OutlineVisualElement.js";import{GraphicState as pe}from"../../../layers/graphics/GraphicState.js";import{createExtrudedTriangle as he,createSphereGeometry as de}from"../../../webgl-engine/lib/GeometryUtil.js";import{MouseButton as ue}from"../../../../input/IViewEvents.js";import{sceneSnappingAtLocation as ce,addMapDelta as me,createManipulatorDragEventPipeline as ge,dragAtLocation as _e,addScreenDelta as fe}from"../../../../interactive/dragEventPipeline.js";import{ManipulatorStateFlags as ve,ManipulatorStateCustomFlags as Me}from"../../../../interactive/interfaces.js";import{EditGeometryOperations as ye}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import{AccumulationBehaviour as xe}from"../../../../interactive/editGeometry/interfaces.js";import{SnappingContext as Oe}from"../../../../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as be}from"../../../../interactive/snapping/SnappingDragPipelineStep.js";import{ReshapeEdgeOffsetTooltipInfo as Ee}from"../../../../interactive/tooltip/ReshapeTooltipInfos.js";import{Tooltip as Ge}from"../../../../interactive/tooltip/Tooltip.js";import{TranslateGraphicZTooltipInfo as Se,TranslateGraphicXYTooltipInfo as we,TranslateGraphicTooltipInfo as Ie,TranslateVertexZTooltipInfo as Ve,TranslateVertexXYTooltipInfo as He,TranslateVertexTooltipInfo as Te}from"../../../../interactive/tooltip/TranslateTooltipInfos.js";import{autoAreaByElevationMode as Ae}from"../../../../support/automaticAreaMeasurementUtils.js";import{autoHorizontalDistanceByElevationModeBetweenPoints as De,autoLengthByElevationMode as Le}from"../../../../support/automaticLengthMeasurementUtils.js";import{verticalSignedDistanceBetweenPoints as je,elevationOfPoint as Pe}from"../../../../support/euclideanLengthMeasurementUtils.js";import{geodesicDistance as Ue}from"../../../../support/geodesicLengthMeasurementUtils.js";import Ne from"../../../../../geometry/SpatialReference.js";let Ce=class extends(n.EventedMixin(t)){constructor(e){super(e),this._selectedIndex=0,this._manipulatorHandles=new o,this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0,this._reshapeEventState=Ye.NONE,this._updatingHandles=new V,this._recreatingManipulators=!1,this.outputGeometry=null,this._vertexLaserLineVisualElement=null;const t=B(e.tool.view.effectiveTheme).manipulators,i=t.vertex;this._vertexManipulatorMaterial=N(a(i.color),i.renderOccluded),this._vertexManipulatorOutlineMaterial=C(a(i.outlineColor),i.renderOccluded),this._vertexManipulatorHoverOutlineMaterial=C(a(i.hoverOutlineColor),i.renderOccluded);const n=t.edge;this._edgeManipulatorMaterial=N(a(n.color),n.renderOccluded),this._edgeManipulatorOutlineMaterial=C(a(n.outlineColor),n.renderOccluded);const r=t.edgeOffset;this._edgeOffsetManipulatorMaterial=N(a(r.color),r.renderOccluded,!1),this._edgeOffsetManipulatorHoverMaterial=N(a(r.hoverColor),r.renderOccluded,!1);const s=t.selected;this._selectedManipulatorMaterial=N(a(s.color),s.renderOccluded),this._selectedManipulatorOutlineMaterial=C(a(s.outlineColor),s.renderOccluded),this._selectedManipulatorHoverOutlineMaterial=C(a(s.hoverOutlineColor),s.renderOccluded)}initialize(){const{graphic:e,view:t}=this,i=this._graphicState=new pe({graphic:e});this._tooltip=new Ge({view:t}),this.addHandles([m((()=>i.displaying),(e=>{for(const t of this._manipulatorInfos)t.manipulator.available=e})),m((()=>({labels:this._segmentLabels,enabled:this._labelOptions.enabled,edgeOffsetEnabled:this.enableEdgeOffset})),(({labels:e,enabled:t,edgeOffsetEnabled:i})=>{null!=e&&(e.visible=t,e.edgeDistance=i?"far":"default")}),_),g((()=>!this._tooltipOptions.enabled),(()=>this._tooltip.clear()),_),this.view.trackGraphicState(i)])}destroy(){this._segmentLabels=p(this._segmentLabels),this._tooltip=p(this._tooltip),this._removeManipulators(),this._updatingHandles.destroy()}get inputGeometry(){return null!=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)}onManipulatorSelectionChanged(){this.emit("manipulators-changed")}_removeManipulators(){this._manipulatorHandles.removeAll(),this._moveManipulation=p(this._moveManipulation),this._graphicMoveManipulation=p(this._graphicMoveManipulation),this.manipulators.removeAll(),this._manipulatorInfos=[],this._numGrabbing=0,this._numDragging=0}_createManipulators(e){if(null==this._editGeometryOperations)return;const t=j(this.graphic);for(const i of this._editGeometryOperations.data.components){const a=e?.byComponentIndex.get(i.index);for(const e of i.vertices){const i=a?.has(e.index);this._createVertexOrEdgeManipulator(e,t,i)}for(const e of i.edges)this._createVertexOrEdgeManipulator(e,t)}this._createGraphicMoveManipulation(),this._createMoveManipulation(t),this._createVisualElements()}get canRedo(){return null!=this._editGeometryOperations&&this._editGeometryOperations.canRedo}get canUndo(){return null!=this._editGeometryOperations&&this._editGeometryOperations.canUndo}redo(){if(null==this._editGeometryOperations)return null;const e=this._editGeometryOperations.redo();return null!=e&&(this.outputGeometry=this._editGeometryOperations.data.geometry,this._recreateManipulators()),e}undo(){if(null==this._editGeometryOperations)return null;this.emit("undo");const e=this._editGeometryOperations.undo();return null!=e&&(this.outputGeometry=this._editGeometryOperations.data.geometry,this._recreateManipulators()),e}_recreateManipulators(){this._recreatingManipulators||(this._recreatingManipulators=!0,this._removeManipulators(),this._tooltip.clear(),this._createManipulators(),this._recreatingManipulators=!1)}_recreateEditGeometryAndManipulators(e){const t={byComponentIndex:new Map};if(null!=e&&null!=this.inputGeometry&&T(e,this.inputGeometry))for(const a of this._manipulatorInfos)if("vertex"===a.type&&a.manipulator.selected){const{index:e,component:{index:i}}=a.handle,{byComponentIndex:n}=t,o=n.get(i)||new Set;o.add(e),n.set(i,o)}if(this._recreatingManipulators=!0,this._removeManipulators(),this._tooltip.clear(),this._editGeometryOperations=p(this._editGeometryOperations),this._segmentLabels=p(this._segmentLabels),null==e)return void(this._recreatingManipulators=!1);const i="mesh"===e.type?e.anchor:e;this._editGeometryOperations=ye.fromGeometry(i,this.view.state.viewingMode),this._createManipulators(t),this._segmentLabels=new F({context:{view:this.view,editGeometryOperations:this._editGeometryOperations,elevationInfo:j(this.graphic),labelOptions:this._labelOptions,graphic:this.graphic,graphicState:this._graphicState},visible:this._labelOptions.enabled}),this._recreatingManipulators=!1}_perGraphicManipulatorDragAction(e,t){if("end"===t.action)return t;let i=0;const a=[],n=this._manipulatorInfos.some((e=>"vertex"===e.type&&e.manipulator.selected)),o=e===qe.SELECTED_OR_ALL&&n;for(const r of this._manipulatorInfos)"vertex"===r.type&&(r.manipulator.grabbing||o&&!r.manipulator.selected||a.push(r),i++);if(0===a.length)return t;this._moveVertices(a,t);if(a.length===i){if(this._updateEventState(Ye.MOVING),this.destroyed)return t;this.emit("move",{type:"move",dx:t.screenDeltaX,dy:t.screenDeltaY,mover:this.graphic})}else{if(this._updateEventState(Ye.RESHAPING),this.destroyed)return t;this.emit("reshape",{type:"reshape",mover:this.graphic})}return t}_isMultiVertexSelection(){return this._manipulatorInfos.reduce(((e,t)=>"vertex"===t.type&&t.manipulator.selected?e+1:e),0)>1}_perVertexManipulatorDragAction(e){if(this._updateEventState(Ye.RESHAPING),this.destroyed)return;const{mapDeltaX:t,mapDeltaY:i,mapDeltaZ:a}=e;if(!t&&!i&&!a)return;const n=[];for(const o of this._manipulatorInfos)"vertex"===o.type&&(o.manipulator.selected&&!o.manipulator.grabbing||o===e.info)&&n.push(o);this._moveVertices(n,e,xe.ACCUMULATE_STEPS),this.emit("reshape",{type:"reshape",mover:this.graphic})}_updateEventState(e){if(e===this._reshapeEventState)return!1;switch(e){case Ye.NONE:if(0!==this._numGrabbing||0!==this._numDragging)return!1;switch(this._reshapeEventState){case Ye.MOVING:this.emit("move",{type:"move-stop",dx:0,dy:0,mover:this.graphic});break;case Ye.RESHAPING:this.emit("reshape",{type:"reshape-stop",mover:this.graphic})}break;case Ye.MOVING:switch(this._reshapeEventState){case Ye.NONE:this.emit("move",{type:"move-start",dx:0,dy:0,mover:this.graphic});break;case Ye.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 Ye.RESHAPING:switch(this._reshapeEventState){case Ye.NONE:this.emit("reshape",{type:"reshape-start",mover:this.graphic});break;case Ye.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}_createGraphicMoveManipulation(){const{tool:e,view:t}=this,i=this._graphicState;if(this._graphicMoveManipulation=new ae({tool:e,view:t,graphicState:i}),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=this._editGeometryOperations.createUndoGroup()),t))).next((e=>this._perGraphicManipulatorDragAction(qe.ALL,e))).next((e=>(this._updateTranslateGraphicTooltip($.XY,e),e))).next((t=>{"end"===t.action&&(this._tooltip.clear(),e=h(e))})),a.next((()=>this._onDragCancel(!0,(()=>e=h(e)))))}))),this._graphicMoveManipulation.forEachManipulator((e=>this._manipulatorHandles.add(this._watchAndUpdateGrabState(e,!1))))}else this._graphicMoveManipulation.forEachManipulator((e=>{e.grabbable=!1,e.cursor=null}));this._graphicMoveManipulation.forEachManipulator((e=>this._manipulatorHandles.add(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()})))))}_createMoveManipulation(e){const{graphic:t,tool:i,view:a}=this,n=this._graphicState;this._moveManipulation=new ee({tool:i,view:a,xyAvailable:!0,xyAxisAvailable:!0,zAvailable:this.enableZShape&&K(t),snapToScene:!1,radius:ee.radiusForSymbol(t.symbol)}),this._moveManipulation.forEachManipulator((e=>this.addHandles([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()})),this._watchAndUpdateGrabState(e,!1)])));const o=e=>t=>{this.addHandles(t.events.on("focus-changed",(({action:t})=>{"focus"===t&&this._tooltipOptions.enabled?this._updateTranslateTooltip(e):this._tooltip.clear()})))};this._moveManipulation.xyManipulation.forEachManipulator(o($.XY)),this._moveManipulation.xyAxisManipulation.forEachManipulator(o($.XY_AXIS)),this._moveManipulation.zManipulation.forEachManipulator(o($.Z)),this._moveManipulation.elevationInfo={mode:"absolute-height",offset:0};const r=t.geometry.spatialReference;this.addHandles([this._moveManipulation.createDragPipeline(((a,n,o,r,s)=>{const{snappingStep:l,cancelSnapping:p}=be({predicate:e=>!!e.info,snappingManager:i.snappingManager,snappingContext:new Oe({editGeometryOperations:this._editGeometryOperations,elevationInfo:e,pointer:s,excludeFeature:t,visualizer:new z}),updatingHandles:this._updatingHandles,useZ:!1});return r=r.next((e=>(this._onDragCancel(),e))).next(p),{steps:o=o.next((e=>this._trackNumDragging(e))).next((e=>{const t=this._manipulatorInfos.filter((e=>"vertex"===e.type&&e.manipulator.selected));return e.manipulatorType===W.TRANSLATE_XY&&1===t.length?{...e,info:t[0],snapOrigin:t[0].handle.pos}:e})).next(ce(this.view,e,t)).next(...l).next(me()).next((e=>this._perGraphicManipulatorDragAction(qe.SELECTED_OR_ALL,e))).next((e=>(this._updateTranslateTooltip(a,e),e))),cancel:r}}),e,r,t),m((()=>n.displaying),(()=>this._updateMoveManipulationPosition()),_),n.on("changed",(()=>{this._recreatingManipulators||this._updateMoveManipulationPosition()})),m((()=>n.isDraped),(e=>{this._updateMoveManipulationPosition();const t="align-move-manipulation";e?this.addHandles(this.view.elevationProvider.on("elevation-change",(()=>this._updateMoveManipulationPosition())),t):this.removeHandles(t)}),_)])}_createVisualElements(){const{graphic:e,view:t}=this,i=J({view:t,graphic:e,forEachManipulator:e=>{if(!this.destroyed&&!this._recreatingManipulators){this._graphicMoveManipulation.forEachManipulator(e),this._moveManipulation.forEachManipulator(e);for(const t of this._manipulatorInfos)e(t.manipulator,W.TRANSLATE_XY)}},onManipulatorsChanged:e=>this.on("manipulators-changed",e)});null!=i&&(this._outlineVisualElement=i.visualElement instanceof le?i.visualElement:null),null!=this._outlineVisualElement&&this._manipulatorHandles.add(this._outlineVisualElement.events.on("attachment-origin-changed",(()=>{this._graphicState.isDraped||this._updateMoveManipulationPosition()}))),this._manipulatorHandles.add(i)}_createEdgeOffsetManipulator(e,t=j(this.graphic)){const i=B(this.view.effectiveTheme).manipulators.edgeOffset,a=i.size/2,n=a+i.collisionPadding,o=a/n,s=o*Math.sqrt(3)/2;null==this._edgeOffsetManipulatorGeometryInside&&(this._edgeOffsetManipulatorGeometryInside=he(this._edgeOffsetManipulatorMaterial,s,o/2,o/2,i.height,i.offset)),null==this._edgeOffsetManipulatorGeometryOutside&&(this._edgeOffsetManipulatorGeometryOutside=he(this._edgeOffsetManipulatorMaterial,-s,o/2,o/2,i.height,-i.offset));const l=[new R(this._edgeOffsetManipulatorGeometryInside.instantiate(),ve.Unfocused),new R(this._edgeOffsetManipulatorGeometryInside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),ve.Focused),new R(this._edgeOffsetManipulatorGeometryOutside.instantiate(),ve.Unfocused),new R(this._edgeOffsetManipulatorGeometryOutside.instantiate({material:this._edgeOffsetManipulatorHoverMaterial}),ve.Focused)],p=new U({view:this.view,renderObjects:l,elevationInfo:"on-the-ground"!==t.mode||P(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:w(0,0,1)},collisionPriority:1,metadata:{deleting:!1}}),h=new U({view:this.view,worldSized:!0,worldOriented:!1,available:!(!this.graphic.visible||!this.graphic.layer?.visible),collisionPriority:-10,cursor:this.enableMoveGraphic?"move":"default",metadata:{deleting:!1}}),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=[];for(const r of[d.handle.leftVertex,d.handle.rightVertex]){const e=this._getManipulatorInfoFromHandle(r);null!=e&&u.push(e.manipulator.events.on("location-update",(()=>this._updateEdgeOffsetManipulator(d))))}d.locationUpdateHandle=r(u),this._manipulatorHandles.add(d.locationUpdateHandle,p),this._manipulatorHandles.add([this._watchAndUpdateGrabState(p,!0),this._watchAndUpdateGrabState(h,!0)],p),this._manipulatorHandles.add(ge(p,this._createEdgeOffsetPipeline(d,t)),p),this._manipulatorHandles.add(ge(h,((e,i,a,n)=>{if("touch"===n){this._createEdgeOffsetPipeline(d,t)(e,i,a)}else if(this.enableMoveGraphic){const n=this.graphic,o=null!=n.geometry?n.geometry.spatialReference:null;i.next((e=>this._trackNumDragging(e))).next(_e(this.view,e.elevationAlignedLocation)).next(Y(this.view,e.elevationAlignedLocation,t,o,n)).next(fe()).next(me()).next((e=>this._perGraphicManipulatorDragAction(qe.ALL,e))).next((e=>(this._updateTranslateGraphicTooltip($.XY,e),e))).next((e=>{"end"===e.action&&this._tooltip.clear()})),a.next((()=>this._onDragCancel(!e.metadata.deleting)))}})),p);const c=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",c),h.events.on("immediate-click",c),p.events.on("focus-changed",(({action:e})=>{const t=this._tooltipOptions;if("focus"===e&&t.enabled){const e=this._tooltip.info=new Ee({tooltipOptions:t});this._updateTooltipAreaOrTotalLength(e)}else 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=()=>{e.visibilityHandle=h(e.visibilityHandle);const n=this._getManipulatorInfoFromHandle(e.handle.leftVertex),o=this._getManipulatorInfoFromHandle(e.handle.rightVertex),l=null!=n&&null!=o&&se(n.manipulator.renderLocation,o.manipulator.renderLocation,this.view.state.camera)<t;(!i.focused&&!a.focused||l)&&(i.grabbable=!l,a.grabbable=!l,e.visibilityHandle=r([i.disableDisplay(),s((()=>{i.grabbable=!0,a.grabbable=this.enableMoveGraphic}))]))};this._manipulatorHandles.add([i.events.on("focus-changed",n),a.events.on("focus-changed",n),s((()=>{h(e.visibilityHandle),a.metadata.deleting=!0,this.manipulators.remove(a)}))],i),n()}_updateEdgeOffsetManipulator(e){this._updateManipulatorPosition(e);const{coordinateHelper:t}=this._editGeometryOperations.data,i=ne(this.view,e.manipulator.elevationAlignedLocation,oe(t,e.handle,e.manipulator.elevationInfo)),a=this._getManipulatorInfoFromHandle(e.handle.leftVertex),n=this._getManipulatorInfoFromHandle(e.handle.rightVertex);if(null==a||null==n)return;const o=a.manipulator.renderLocation,r=n.manipulator.renderLocation,s=null!=i?re(i,o,r):y;e.manipulator.modelTransform=s,e.edgeManipulator.elevationAlignedLocation=e.manipulator.elevationAlignedLocation,e.edgeManipulator.modelTransform=s;const l=x(O(ze,o,r))/2;e.edgeManipulator.collisionType={type:"line",paths:[[[-l,0,0],[l,0,0]]]}}_createEdgeOffsetPipeline(e,t){return(i,a,n)=>{this._clearSelection();const{step:o,cleanup:r}=this._initializeEdgeOffset(e,t);a.next((e=>this._trackNumDragging(e))).next(_e(this.view,i.elevationAlignedLocation)).next(o).next(X(this.view)).next(Z(this.view,this._editGeometryOperations.data.spatialReference)).next(me()).next(this._applyComputeEdgeOffsetDistanceStep()).next(this._applyEdgeOffsetStep(e)).next(this._showEdgeOffsetTooltip()).next((e=>{"end"===e.action&&r()})),n.next((()=>{i.metadata.deleting||(r(),this._onDragCancel())}))}}_initializeEdgeOffset(e,t){const{view:i}=this,n=this._editGeometryOperations,o=oe(n.data.coordinateHelper,e.handle,t),s=n.createUndoGroup(),p=ne(i,e.manipulator.elevationAlignedLocation,o);if(o.requiresSplitEdgeLeft){const t=this._getManipulatorInfoFromHandle(e.handle.leftVertex.leftEdge);null!=t&&this._splitEdgeManipulator(t,1)}if(o.requiresSplitEdgeRight){const t=this._getManipulatorInfoFromHandle(e.handle.rightVertex.rightEdge);null!=t&&this._splitEdgeManipulator(t,0)}const d=()=>new H({paths:[[e.handle.leftVertex.pos,e.handle.rightVertex.pos]],spatialReference:n.data.spatialReference}),u=B(i.effectiveTheme),c=new le({view:i,isDraped:this._graphicState.isDraped,geometry:d(),elevationInfo:e.elevationInfo,width:u.visualElements.lineGraphics.outline.width,color:a(u.colors.accent),attached:!0,isDecoration:!0});let g;const _=()=>{this._cleanEdgeOffsetCollapsedEdges(e),g=h(g)},f=this.on("undo",_);return g=r([l(c),m((()=>this._graphicState.isDraped),(e=>c.isDraped=e)),this._graphicState.on("changed",(()=>c.geometry=d())),s,f]),{step:e=>null==o||null==p?(_(),null):{...e,operation:o,plane:p},cleanup:_}}_applyEdgeOffsetStep(e){return t=>{if(this.destroyed||null==t.operation)return t;this._updateEventState(Ye.RESHAPING);const{mapDeltaX:i,mapDeltaY:a,mapDeltaZ:n}=t;return(i||a||n)&&(this._offsetEdge(e,t),this.emit("reshape",{type:"reshape",mover:this.graphic})),t}}_applyComputeEdgeOffsetDistanceStep(){return e=>{const{operation:t,mapEnd:i}=e;return null==t||null==i?e:("start"===e.action&&t.selectArrowFromStartPoint(i),{...e,signedDistance:t.signedDistanceToPoint(i)})}}_showEdgeOffsetTooltip(){return e=>{const{mapEnd:t,signedDistance:i,operation:a}=e,n=this._tooltip,o=this._tooltipOptions;if(!o.enabled||null==i)return n.clear(),e;let r=n.info;null!=r&&"reshape-edge-offset"===r.type||(r=n.info=new Ee({tooltipOptions:o}));const{coordinateHelper:s}=this._editGeometryOperations.data;return r.distance="end"===e.action?d:Re(this._graphicState.isDraped,i*a.selectedArrow,t,a.plane,s),this._updateTooltipAreaOrTotalLength(r),e}}_cleanEdgeOffsetCollapsedEdges(e){const t=e.handle.leftVertex.leftEdge?.leftVertex,i=e.handle.leftVertex,a=e.handle.rightVertex.rightEdge?.rightVertex,n=e.handle.rightVertex,o=this._editGeometryOperations.data.coordinateHelper,r=[];if(t&&o.distance(t.pos,i.pos)<Xe){const e=this._getManipulatorInfoFromHandle(i);null!=e&&r.push(e)}if(o.distance(i.pos,n.pos)<Xe||a&&o.distance(a.pos,n.pos)<Xe){const e=this._getManipulatorInfoFromHandle(n);null!=e&&r.push(e)}r.length&&this._removeVertices(r)}_computeVertexManipulatorSizeAndOutline(e){const t=e.size/2,i=t+e.collisionPadding;return{size:t/i,outlineSize:(t+e.outlineSize)/i}}_createVertexOrEdgeManipulator(e,t=j(this.graphic),i=!1){const{view:a}=this,n=B(a.effectiveTheme);if("edge"===e.type){if(this.enableEdgeOffset)return this._createEdgeOffsetManipulator(e,t);if(!this.enableMidpoints)return null}if(null==this._vertexManipulatorGeometry||null==this._vertexManipulatorOutlineGeometry){const{size:e,outlineSize:t}=this._computeVertexManipulatorSizeAndOutline(n.manipulators.vertex);this._vertexManipulatorGeometry=de(this._vertexManipulatorMaterial,e,16,16),this._vertexManipulatorOutlineGeometry=de(this._vertexManipulatorOutlineMaterial,t,16,16)}if(null==this._edgeManipulatorGeometry||null==this._edgeManipulatorOutlineGeometry){const{size:e,outlineSize:t}=this._computeVertexManipulatorSizeAndOutline(n.manipulators.edge);this._edgeManipulatorGeometry=de(this._edgeManipulatorMaterial,e,16,16),this._edgeManipulatorOutlineGeometry=de(this._edgeManipulatorOutlineMaterial,t,16,16)}const{geometry:o}=this.graphic,s=o?.type,l="point"===s||"mesh"===s?[]:[new R(this._vertexManipulatorGeometry.instantiate(),Ze.Vertex|ve.Unselected),new R(this._vertexManipulatorOutlineGeometry.instantiate(),Ze.Vertex|ve.Unfocused|ve.Unselected),new R(this._vertexManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),Ze.Vertex|ve.Focused|ve.Unselected),new R(this._vertexManipulatorGeometry.instantiate({material:this._selectedManipulatorMaterial}),ve.Selected),new R(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorOutlineMaterial}),ve.Selected|ve.Unfocused),new R(this._vertexManipulatorOutlineGeometry.instantiate({material:this._selectedManipulatorHoverOutlineMaterial}),ve.Selected|ve.Focused)];this.enableMidpoints&&l.push(new R(this._edgeManipulatorGeometry.instantiate({material:this._vertexManipulatorMaterial}),Ze.Edge|ve.Focused|ve.Unselected),new R(this._edgeManipulatorOutlineGeometry.instantiate({material:this._vertexManipulatorHoverOutlineMaterial}),Ze.Edge|ve.Focused|ve.Unselected),new R(this._edgeManipulatorGeometry.instantiate(),Ze.Edge|ve.Unfocused|ve.Unselected),new R(this._edgeManipulatorOutlineGeometry.instantiate(),Ze.Edge|ve.Unfocused|ve.Unselected));const p=new U({view:a,renderObjects:l,elevationInfo:t,focusMultiplier:1,touchMultiplier:1,available:!(!this.graphic.visible||!this.graphic.layer?.visible),metadata:{deleting:!1}});p.selected=i,this._setTypeSpecificManipulatorSettings(p,e,t);const d="edge"===e.type?{manipulator:p,handle:e,locationUpdateHandle:null,type:"edge",selectedIndex:0}:{manipulator:p,handle:e,type:"vertex",selectedIndex:0};if(this._manipulatorInfos.push(d),this.manipulators.add(p),this._updateManipulatorPosition(d),"edge"===d.type){const e=[];for(const t of[d.handle.leftVertex,d.handle.rightVertex]){const i=this._getManipulatorInfoFromHandle(t);null!=i&&e.push(i.manipulator.events.on("location-update",(()=>this._updateManipulatorPosition(d))))}d.locationUpdateHandle=r(e),this._manipulatorHandles.add(d.locationUpdateHandle,p)}this._manipulatorHandles.add(this._watchAndUpdateGrabState(p,!0),p);const u=ge(p,((e,i,a,n)=>{let o=null;const{snappingStep:r,cancelSnapping:s}=be({predicate:()=>!this._isMultiVertexSelection(),snappingManager:this.tool.snappingManager,snappingContext:new Oe({editGeometryOperations:this._editGeometryOperations,elevationInfo:t,pointer:n,excludeFeature:this.graphic,visualizer:new z}),updatingHandles:this._updatingHandles,useZ:!1});a=a.next((t=>(this._onDragCancel(!e.metadata.deleting,(()=>o=h(o))),t))).next(s),i.next((e=>this._trackNumDragging(e))).next((e=>{if("start"===e.action&&(o=this._editGeometryOperations.createUndoGroup()),"edge"===d.type){const t=this._splitEdgeManipulator(d);return{...e,info:t,snapOrigin:t.handle.pos}}return{...e,info:d,snapOrigin:d.handle.pos}})).next(_e(this.view,e.elevationAlignedLocation)).next(q(this.view,this.graphic,e.elevationAlignedLocation,e.location.spatialReference,this.graphic)).next(ce(this.view,t,this.graphic)).next(...r).next(me()).next((t=>{this._perVertexManipulatorDragAction(t),"end"===t.action&&(o=h(o)),this._updateTranslateVertexTooltip(e,$.XY,t)}))}));return this._manipulatorHandles.add([u,p.events.on("immediate-click",(e=>this._manipulatorClickCallback(e,d))),p.events.on("select-changed",(()=>{d.selectedIndex=++this._selectedIndex,this._updateMoveManipulationPosition()})),p.events.on("focus-changed",(({action:e})=>{"focus"===e&&"edge"!==d.type?this._updateTranslateVertexTooltip(p,$.XY):this._tooltip.clear()}))],p),this.emit("manipulators-changed"),d}_trackNumDragging(e){switch(e.action){case"start":this._numDragging++;break;case"end":this._numDragging--}return e}_onDragCancel(e=!0,t){switch(this._numDragging--,e&&(this.undo(),this.outputGeometry=null!=this._editGeometryOperations?this._editGeometryOperations.data.geometry:null),null!=this.tool.snappingManager&&this.tool.snappingManager.doneSnapping(),this._tooltip.clear(),this._reshapeEventState){case Ye.NONE:break;case Ye.MOVING:this.emit("move",{type:"move",dx:0,dy:0,mover:this.graphic});break;case Ye.RESHAPING:this.emit("reshape",{type:"reshape",mover:this.graphic})}t&&t(),this.destroyed||this._updateEventState(Ye.NONE)}_setTypeSpecificManipulatorSettings(e,t,i){const{graphic:a,view:n}=this,o=B(n.effectiveTheme);switch(t.type){case"vertex":{e.state=Ze.Vertex,e.selectable=!0,e.cursor="move",e.collisionPriority=2;const{size:t,collisionPadding:n}=o.manipulators.vertex;e.radius=t/2+n,e.elevationInfo=i;const{geometry:r}=a,s=r?.type;e.interactive=null!=s&&"point"!==s&&"mesh"!==s;break}case"edge":{e.state=Ze.Edge,e.selectable=!1,e.cursor="copy",e.collisionPriority=-1;const{size:t,collisionPadding:n}=o.manipulators.edge;e.radius=t/2+n,e.elevationInfo="on-the-ground"!==i.mode||P(a.symbol)?{mode:"absolute-height",offset:0}:i;break}}}_watchAndUpdateGrabState(e,t){return e.events.on("grab-changed",(i=>this._onGrabStateChanged(e,t,i.action,i.pointerType)))}_onGrabStateChanged(e,t,i,a="mouse"){if(!this._recreatingManipulators){if("start"===i)t&&this._updateSelection(e),this._numGrabbing++;else if(this._numGrabbing--,this._updateEventState(Ye.NONE),this.destroyed)return;this._moveManipulation.interactive=!this._numGrabbing,("touch"!==a||this.enableEdgeOffset)&&(this._manipulatorInfos.forEach((e=>{const{manipulator:t}=e,{geometry:i}=this.graphic,a=i?.type;t.interactive=t.grabbing||!this._numGrabbing&&null!=a&&"point"!==a&&"mesh"!==a,"edgeManipulator"in e&&(e.edgeManipulator.interactive=e.edgeManipulator.grabbing||!this._numGrabbing)})),this._graphicMoveManipulation.forEachManipulator((e=>{e.interactive=e.grabbing||!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){null!=e&&(e.manipulator.metadata.deleting=!0,this.manipulators.remove(e.manipulator),this._manipulatorHandles.remove(e.manipulator),i(this._manipulatorInfos,e),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(null==e)return;const t=this._editGeometryOperations;if("vertex"===e.type)e.manipulator.location=t.data.coordinateHelper.vectorToDehydratedPoint(e.handle.pos,Fe),e.manipulator.grabbing&&null!=this._vertexLaserLineVisualElement&&(this._vertexLaserLineVisualElement.visualElement.intersectsWorldUpAtLocation=e.manipulator.renderLocation);else if("edge"===e.type){const i=this._getManipulatorInfoFromHandle(e.handle.leftVertex),a=this._getManipulatorInfoFromHandle(e.handle.rightVertex);if(null==i||null==a)return;const n=i.manipulator,o=a.manipulator;if(null!=e.manipulator.elevationInfo&&"on-the-ground"===e.manipulator.elevationInfo.mode){const i=n.location,a=o.location,r=.5,s=i.x+r*(a.x-i.x),l=i.y+r*(a.y-i.y),p=i.hasZ&&a.hasZ?0:void 0;e.manipulator.location=L(s,l,p,t.data.spatialReference)}else b(ze,n.renderLocation,o.renderLocation,.5),e.manipulator.renderLocation=ze}}_splitEdgeManipulator(e,t=.5){const i=this._editGeometryOperations,a=i.splitEdge(e.handle,t).createdVertex;e.locationUpdateHandle=h(e.locationUpdateHandle);const n=j(this.graphic);let o;this.enableEdgeOffset?(this._removeManipulator(e),o=this._createVertexOrEdgeManipulator(a)):(o=e,o.handle=a,o.type="vertex",this._setTypeSpecificManipulatorSettings(e.manipulator,e.handle,n)),a.leftEdge&&this._createVertexOrEdgeManipulator(a.leftEdge),a.rightEdge&&this._createVertexOrEdgeManipulator(a.rightEdge),this.outputGeometry=i.data.geometry,this._updateManipulatorPosition(o),this.enableEdgeOffset||this._updateTranslateVertexTooltip(o.manipulator,$.XY),this._updateSelection(e.manipulator);const r=this._updateEventState(Ye.RESHAPING),s=i.data.coordinateHelper.vectorToArray(o.handle.pos),l=i.data.components.indexOf(a.component);return this.emit("vertex-add",{type:"vertex-add",vertices:[{coordinates:s,componentIndex:l,vertexIndex:a.index}],added:s}),r&&this._updateEventState(Ye.NONE),o}_updateMoveManipulationPosition(){const e=E(ze,0,0,0);let t=0,i=!1,a=null,n=null;for(const o of this._manipulatorInfos)"vertex"===o.type&&(o.manipulator.selected?(t++,G(e,e,o.manipulator.renderLocation),null==a||o.selectedIndex>a.selectedIndex?(n=a,a=o):(null==n||o.selectedIndex>n.selectedIndex)&&(n=o)):i=!0);if(0===t){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&&K(this.graphic),this._moveManipulation.angle=te(this.graphic.geometry),this._moveManipulation.radius=ee.radiusForSymbol(this.graphic.symbol)}else{const e=this._graphicState.displaying;this._moveManipulation.xyManipulation.available=e,this._moveManipulation.xyAxisManipulation.available=e,this._moveManipulation.zManipulation.available=e&&this.enableZVertex&&K(this.graphic),this._moveManipulation.xyAxisManipulation.orthogonalAvailable=e&&1!==t;let i=0;if(null!=a){const e=a.handle.pos,t=null!=n?n.handle.pos:a.handle.leftEdge&&a.handle.leftEdge.leftVertex?a.handle.leftEdge.leftVertex.pos:null,o=null==n&&a.handle.rightEdge&&a.handle.rightEdge.rightVertex?a.handle.rightEdge.rightVertex.pos:null;t&&o?this._moveManipulation.xyAxisManipulation.available=!1:t?i=ke(t,e):o&&(i=ke(e,o))}this._moveManipulation.angle=i,this._moveManipulation.radius=Q}0!==t&&i?(S(e,e,1/t),Fe.spatialReference=this._editGeometryOperations.data.spatialReference,Fe.hasZ=!0,this.view.renderCoordsHelper.fromRenderCoords(e,Fe),this._moveManipulation.elevationAlignedLocation=Fe):null==this._outlineVisualElement||this._graphicState.isDraped||null==this._outlineVisualElement.attachmentOrigin?k(this.view,this._moveManipulation,this.graphic):this._moveManipulation.elevationAlignedLocation=this._outlineVisualElement.attachmentOrigin}_removeVertices(e){const t=new Array,i=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=i.removeVertices([a.handle]),n=e.removedVertices?.[0].createdEdge;n&&this._createVertexOrEdgeManipulator(n)}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:e.index}}));this.outputGeometry=i.data.geometry;const a=this._updateEventState(Ye.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(Ye.NONE),this.destroyed))return;this._updateMoveManipulationPosition()}}_moveVertices(e,t,i=("start"===t.action?xe.NEW_STEP:xe.ACCUMULATE_STEPS)){const a=this._editGeometryOperations;a.moveVertices(e.map((e=>e.handle)),t.mapDeltaX,t.mapDeltaY,t.mapDeltaZ,i),this.outputGeometry=a.data.geometry;for(const n of e)this._updateManipulatorPosition(n)}_offsetEdge(e,t){if(null==t.operation||null==t.signedDistance)return;const i=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===ue.Right&&this._removeVertices([t])),"edge"===t.type&&e.button===ue.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=this._graphicState.isDraped?"on-the-ground":"absolute-height";switch(e){case $.XY:this._tooltip.info=new Ie({tooltipOptions:i}),this._updateTranslateTooltipDistance(this._tooltip.info,t,((e,t)=>De(e,t,a)));break;case $.XY_AXIS:this._tooltip.info=new we({tooltipOptions:i}),this._updateTranslateTooltipDistance(this._tooltip.info,t,((e,i)=>{const n=De(e,i,a);return u(n,ie(t))}));break;case $.Z:this._tooltip.info=new Se({tooltipOptions:i}),this._updateTranslateTooltipDistance(this._tooltip.info,t,je)}}_updateTranslateVertexTooltip(e,t,i){const a=this._tooltipOptions;if(!a.enabled)return;let n;const o=this._graphicState.isDraped?"on-the-ground":"absolute-height";switch(t){case $.XY:n=new Te({tooltipOptions:a}),this._updateTranslateTooltipDistance(n,i,((e,t)=>De(e,t,o))),this._updateTooltipAreaOrTotalLength(n);break;case $.XY_AXIS:n=new He({tooltipOptions:a}),this._updateTranslateTooltipDistance(n,i,((e,t)=>{const a=De(e,t,o);return u(a,ie(i))})),this._updateTooltipAreaOrTotalLength(n);break;case $.Z:n=new Ve({tooltipOptions:a}),this._updateTranslateTooltipDistance(n,i,je)}const r=Pe(e.elevationAlignedLocation);null!=r&&(n.elevation={mode:"absolute-height",...r}),this._tooltip.info=n}_updateTranslateTooltipDistance(e,t,i){if(null!=t&&"end"!==t.action){const{mapStart:a,mapEnd:n}=t,o=i(a,n);e.distance=null!=o?o:d}}_updateTooltipAreaOrTotalLength(e){const{geometry:t}=this.graphic;if(null==t)return;const i=this._graphicState.isDraped?"on-the-ground":"absolute-height";e.area="polygon"===t.type?Ae(t,i):null,e.totalLength="polyline"===t.type?Le(t,i):null}get test(){return{segmentLabels:this._segmentLabels,tooltip:this._tooltip}}};function ke(e,t){return Math.atan2(t[1]-e[1],t[0]-e[0])+Math.PI/2}function Re(e,t,i,a,n){if(e){const e=n.toXYZ(n.pointToVector(i)),o=A(a,e,D.get()),r=Ue(o,e,n.spatialReference);if(null!=r)return c(r.value*Math.sign(t),r.unit)}return c(t*f(i.spatialReference),"meters")}e([v()],Ce.prototype,"_editGeometryOperations",void 0),e([v()],Ce.prototype,"_segmentLabels",void 0),e([v({constructOnly:!0})],Ce.prototype,"tool",void 0),e([v()],Ce.prototype,"_tooltip",void 0),e([v()],Ce.prototype,"inputGeometry",null),e([v()],Ce.prototype,"outputGeometry",void 0),e([v({readOnly:!0})],Ce.prototype,"updating",null),e([v()],Ce.prototype,"manipulators",null),e([v()],Ce.prototype,"view",null),e([v()],Ce.prototype,"graphic",null),e([v()],Ce.prototype,"enableZShape",null),e([v()],Ce.prototype,"enableZVertex",null),e([v()],Ce.prototype,"enableMoveGraphic",null),e([v()],Ce.prototype,"enableMidpoints",null),e([v()],Ce.prototype,"enableEdgeOffset",null),e([v()],Ce.prototype,"_labelOptions",null),e([v()],Ce.prototype,"_tooltipOptions",null),Ce=e([M("esri.views.3d.interactive.editingTools.reshapeGraphic.ReshapeOperation")],Ce);const Fe=L(0,0,void 0,Ne.WGS84),ze=I(),Xe=1e-6;var Ze,Ye,qe;!function(e){e.Vertex=Me.Custom1,e.Edge=Me.Custom2}(Ze||(Ze={})),function(e){e[e.NONE=0]="NONE",e[e.MOVING=1]="MOVING",e[e.RESHAPING=2]="RESHAPING"}(Ye||(Ye={})),function(e){e[e.ALL=0]="ALL",e[e.SELECTED_OR_ALL=1]="SELECTED_OR_ALL"}(qe||(qe={}));export{Ce 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.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import{getAccentColor as t,getContrastColor as o}from"../../../../core/analysisThemeUtils.js";import{memoize as i}from"../../../../core/memoize.js";import{ExtensionType as l}from"../visualElements/ExtendedLineVisualElement.js";import{RenderOccludedFlag as s}from"../../webgl-engine/lib/Material.js";import{createStipplePatternSimple as n}from"../../webgl-engine/materials/lineStippleUtils.js";import{desaturate as r,multiplyOpacity as h,unitRGBAFromColor as c}from"../../../support/colorUtils.js";const a=i((i=>({accent:t(),contrast:o(),selected:new e([255,255,255]),selectedOutline:new e([255,255,255]),staged:new e([12,207,255]),outline:new e([0,0,0,.5])}))),d=.3;function p(e,t){t&&Object.assign(e,t)}class u{constructor({theme:e,...t}){this.height=90,this.coneHeight=40,this.coneWidth=23,this.width=3,this.renderOccluded=s.Opaque,this.color=a(e).accent,p(this,t)}}class g{constructor({theme:e,...t}){this.size=11,this.outlineSize=1,this.collisionPadding=9;const o=a(e);this.color=o.accent,this.outlineColor=o.outline,this.renderOccluded=s.Opaque,this.hoverOutlineColor=o.selectedOutline,p(this,t)}apply(e,t){const o=this[e];t.setParameters({color:c(o),transparent:"color"!==e||o.a<1,renderOccluded:this.renderOccluded})}}class m{constructor({theme:e,...t}){this.size=40,this.height=.2,this.offset=.25,this.collisionPadding=2,this.renderOccluded=s.Transparent,this.minSquaredEdgeLength=900;const o=a(e);this.color=h(o.accent,.5),this.hoverColor=o.accent,p(this,t)}apply(e,t){const o=this[e];t.setParameters({color:c(o),transparent:o.a<1,renderOccluded:this.renderOccluded})}}class w{constructor({theme:e}){const t=a(e);this.vertex=new g({theme:e,color:t.accent,outlineColor:t.outline}),this.edge=new g({theme:e,color:r(h(t.accent,2/3),.5),outlineColor:h(t.outline,.5),size:8,collisionPadding:8}),this.selected=new g({theme:e,color:t.selected,outlineColor:t.outline}),this.edgeOffset=new m({theme:e})}}class f{constructor({theme:e,...t}){this.width=1.5,this.stipplePattern=n(5),this.falloff=0,this.innerWidth=1.5,this.renderOccluded=s.OccludeAndTransparent;const o=a(e);this.color=o.selected,this.stippleOffColor=o.outline,this.innerColor=o.selected,p(this,t)}apply(e){e.color=c(this.color),e.width=this.width,e.stipplePattern=this.stipplePattern,e.stippleOffColor=c(this.stippleOffColor),e.falloff=this.falloff,e.innerWidth=this.innerWidth,e.innerColor=c(this.innerColor),e.renderOccluded=this.renderOccluded}}class C{constructor({theme:e,...t}){this.size=4,this.outlineSize=1,this.shape="square";const o=a(e);this.color=o.selected,this.outlineColor=o.outline,p(this,t)}apply(e){e.color=c(this.color),e.size=this.size,e.outlineSize=this.outlineSize,e.outlineColor=c(this.outlineColor),e.primitive=this.shape}}class O{constructor({theme:e,...t}){this.innerWidth=1,this.glowWidth=8,this.glowFalloff=8,this.globalAlpha=d,this.globalAlphaContrastBoost=1.5,this.radius=3;const o=a(e);this.innerColor=o.selected,this.glowColor=o.accent,this.heightFillColor=o.accent,p(this,t)}apply(t,o=1){const i={glowColor:e.toUnitRGB(this.glowColor),glowFalloff:this.glowFalloff,glowWidth:this.glowWidth,innerColor:e.toUnitRGB(this.innerColor),innerWidth:this.innerWidth,globalAlpha:this.globalAlpha*o,globalAlphaContrastBoost:this.globalAlphaContrastBoost,intersectsLineRadius:this.radius};"style"in t?t.style=i:t.laserlineStyle=i}}class W{constructor({theme:e,...t}){const o=a(e);this.outline=new f({theme:e,color:o.outline,renderOccluded:s.OccludeAndTransparentStencil,stippleOffColor:o.selected,stipplePattern:n(5),width:1.5,innerWidth:0}),this.staged=new f({theme:e,color:o.selected,renderOccluded:s.OccludeAndTransparentStencil,innerColor:o.staged,stippleOffColor:o.outline,stipplePattern:n(5),width:1.5}),this.shadowStyle=new O({theme:e,globalAlpha:d,glowColor:o.accent,glowFalloff:8,glowWidth:8,innerColor:o.selected,innerWidth:1}),p(this,t)}}class A{constructor({theme:e,...t}){const o=a(e);this.outline=new C({theme:e,color:o.selected,outlineColor:o.outline,outlineSize:1,shape:"circle",size:4}),this.shadowStyle=new O({theme:e,globalAlpha:d,glowColor:o.accent,glowFalloff:1.5,glowWidth:6,innerColor:o.selected,innerWidth:1,radius:2}),p(this,t)}}class z extends f{constructor({theme:e,...t}){super({theme:e}),this.extensionType=l.GROUND_RAY,p(this,t)}}class b{constructor({theme:e}){this.laserlineAlphaMultiplier=1.5,this.heightPlaneAngleCutoff=20;const t=a(e);this.lineGraphics=new W({theme:e}),this.pointGraphics=new A({theme:e}),this.heightPlane=new O({theme:e,globalAlpha:d,glowColor:t.accent,glowFalloff:8,glowWidth:8,innerColor:t.selected,innerWidth:1}),this.heightBox=new O({theme:e,globalAlpha:d,glowColor:t.accent,glowFalloff:8,glowWidth:8,innerColor:t.selected,innerWidth:0,heightFillColor:t.accent}),this.zVerticalLine=new z({theme:e,color:h(t.accent,5*d/3),falloff:2,innerColor:h(t.selected,0),renderOccluded:s.OccludeAndTransparent,stipplePattern:null,width:5,extensionType:l.GROUND_RAY})}}class y{constructor(e){this.colors=a(e.theme),this.visualElements=new b(e),this.manipulators=new w(e),this.zManipulator=new u(e)}}const P=i((e=>new y({theme:e})));export{P as getSettings};
5
+ import e from"../../../../Color.js";import{getContrast as t,desaturate as o,multiplyOpacity as l,unitRGBAFromColor as i}from"../../../../core/colorUtils.js";import{memoize as s}from"../../../../core/memoize.js";import{ExtensionType as n}from"../visualElements/ExtendedLineVisualElement.js";import{RenderOccludedFlag as r}from"../../webgl-engine/lib/Material.js";import{createStipplePatternSimple as h}from"../../webgl-engine/materials/lineStippleUtils.js";const c=s((o=>({accent:o.accentColor,contrast:t(o.accentColor),selected:new e([255,255,255]),selectedOutline:new e([255,255,255]),staged:new e([12,207,255]),outline:new e([0,0,0,.5])}))),a=.3;function d(e,t){t&&Object.assign(e,t)}class u{constructor({theme:e,...t}){this.height=90,this.coneHeight=40,this.coneWidth=23,this.width=3,this.renderOccluded=r.Opaque,this.color=c(e).accent,d(this,t)}}class p{constructor({theme:e,...t}){this.size=11,this.outlineSize=1,this.collisionPadding=9;const o=c(e);this.color=o.accent,this.outlineColor=o.outline,this.renderOccluded=r.Opaque,this.hoverOutlineColor=o.selectedOutline,d(this,t)}apply(e,t){const o=this[e];t.setParameters({color:i(o),transparent:"color"!==e||o.a<1,renderOccluded:this.renderOccluded})}}class g{constructor({theme:e,...t}){this.size=40,this.height=.2,this.offset=.25,this.collisionPadding=2,this.renderOccluded=r.Transparent,this.minSquaredEdgeLength=900;const o=c(e);this.color=l(o.accent,.5),this.hoverColor=o.accent,d(this,t)}apply(e,t){const o=this[e];t.setParameters({color:i(o),transparent:o.a<1,renderOccluded:this.renderOccluded})}}class w{constructor({theme:e}){const t=c(e);this.vertex=new p({theme:e,color:t.accent,outlineColor:t.outline}),this.edge=new p({theme:e,color:o(l(t.accent,2/3),.5),outlineColor:l(t.outline,.5),size:8,collisionPadding:8}),this.selected=new p({theme:e,color:t.selected,outlineColor:t.outline}),this.edgeOffset=new g({theme:e})}}class m{constructor({theme:e,...t}){this.width=1.5,this.stipplePattern=h(3.3),this.falloff=0,this.innerWidth=1.5,this.renderOccluded=r.OccludeAndTransparent;const o=c(e);this.color=o.selected,this.stippleOffColor=o.outline,this.innerColor=o.selected,d(this,t)}apply(e){e.color=i(this.color),e.width=this.width,e.stipplePattern=this.stipplePattern,e.stippleOffColor=i(this.stippleOffColor),e.falloff=this.falloff,e.innerWidth=this.innerWidth,e.innerColor=i(this.innerColor),e.renderOccluded=this.renderOccluded}}class f{constructor({theme:e,...t}){this.size=4,this.outlineSize=1,this.shape="square";const o=c(e);this.color=o.selected,this.outlineColor=o.outline,d(this,t)}apply(e){e.color=i(this.color),e.size=this.size,e.outlineSize=this.outlineSize,e.outlineColor=i(this.outlineColor),e.primitive=this.shape}}class C{constructor({theme:e,...t}){this.innerWidth=1,this.glowWidth=8,this.glowFalloff=8,this.globalAlpha=a,this.globalAlphaContrastBoost=1.5,this.radius=3;const o=c(e);this.innerColor=o.selected,this.glowColor=o.accent,this.heightFillColor=o.accent,d(this,t)}apply(t,o=1){const l={glowColor:e.toUnitRGB(this.glowColor),glowFalloff:this.glowFalloff,glowWidth:this.glowWidth,innerColor:e.toUnitRGB(this.innerColor),innerWidth:this.innerWidth,globalAlpha:this.globalAlpha*o,globalAlphaContrastBoost:this.globalAlphaContrastBoost,intersectsLineRadius:this.radius};"style"in t?t.style=l:t.laserlineStyle=l}}class O{constructor({theme:e,...t}){const o=c(e);this.outline=new m({theme:e,color:o.outline,renderOccluded:r.OccludeAndTransparentStencil,stippleOffColor:o.selected,stipplePattern:h(3.3),width:1.5,innerWidth:0}),this.staged=new m({theme:e,color:o.selected,renderOccluded:r.OccludeAndTransparentStencil,innerColor:o.staged,stippleOffColor:o.outline,stipplePattern:h(3.3),width:1.5}),this.shadowStyle=new C({theme:e,globalAlpha:a,glowColor:o.accent,glowFalloff:8,glowWidth:8,innerColor:o.selected,innerWidth:1}),d(this,t)}}class W{constructor({theme:e,...t}){const o=c(e);this.outline=new f({theme:e,color:o.selected,outlineColor:o.outline,outlineSize:1,shape:"circle",size:4}),this.shadowStyle=new C({theme:e,globalAlpha:a,glowColor:o.accent,glowFalloff:1.5,glowWidth:6,innerColor:o.selected,innerWidth:1,radius:2}),d(this,t)}}class A extends m{constructor({theme:e,...t}){super({theme:e}),this.extensionType=n.GROUND_RAY,d(this,t)}}class z{constructor({theme:e}){this.laserlineAlphaMultiplier=1.5,this.heightPlaneAngleCutoff=20;const t=c(e);this.lineGraphics=new O({theme:e}),this.pointGraphics=new W({theme:e}),this.heightPlane=new C({theme:e,globalAlpha:a,glowColor:t.accent,glowFalloff:8,glowWidth:8,innerColor:t.selected,innerWidth:1}),this.heightBox=new C({theme:e,globalAlpha:a,glowColor:t.accent,glowFalloff:8,glowWidth:8,innerColor:t.selected,innerWidth:0,heightFillColor:t.accent}),this.zVerticalLine=new A({theme:e,color:l(t.accent,5*a/3),falloff:2,innerColor:l(t.selected,0),renderOccluded:r.OccludeAndTransparent,stipplePattern:null,width:5,extensionType:n.GROUND_RAY})}}class b{constructor(e){this.colors=c(e.theme),this.visualElements=new z(e),this.manipulators=new w(e),this.zManipulator=new u(e)}}const P=s((e=>new b({theme:e})));export{P as getSettings};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../../../chunks/tslib.es6.js";import e from"../../../../../core/Evented.js";import{makeHandle as i}from"../../../../../core/handleUtils.js";import{rad2deg as a}from"../../../../../core/mathUtils.js";import{createLength as s}from"../../../../../core/quantityUtils.js";import{watch as o,initial as r}from"../../../../../core/reactiveUtils.js";import{screenPointObjectToArray as n}from"../../../../../core/screenUtils.js";import{lengthUnitFromSpatialReference as p,getMetersPerUnitForSR as l}from"../../../../../core/unitUtils.js";import{property as h}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as c}from"../../../../../core/accessorSupport/decorators/subclass.js";import{o as u}from"../../../../../chunks/mat4.js";import{s as d,c as m,e as _}from"../../../../../chunks/vec2.js";import{a as g}from"../../../../../chunks/vec2f64.js";import{c as v,q as y,b as f,n as S,l as M,e as b}from"../../../../../chunks/vec3.js";import{c as T,a as E}from"../../../../../chunks/vec3f64.js";import{containsXY as x}from"../../../../../geometry/support/aaBoundingRect.js";import{a as A,c as B}from"../../../../../chunks/boundedPlane.js";import{intersectRay as O,create as R,normal as j}from"../../../../../geometry/support/plane.js";import{create as G}from"../../../../../geometry/support/ray.js";import{sv2d as D,sv3d as w,sm4d as P}from"../../../../../geometry/support/vectorStacks.js";import{getGraphicEffectiveElevationInfo as z}from"../../../../../support/elevationInfoUtils.js";import{createShiftManipulator as U,OffsetMode as I,IsShiftEdgeOnScreenFlag as Z,createResizeManipulator as C,resizeNormal as H,resizeOutlineOnly as k,isDiagonalResizeHandle as L,calculateDiagonalResizeHandleScale as N,createRotatePlane as V,RotationAxis as X,calculateBoundedPlaneTranslateRotate as Y,updateRotateHeadingHandle as F,updateResizeHandle as q}from"../../../analysis/Slice/sliceToolUtils.js";import{getRotateHeadingTexture as W}from"../../../analysis/Slice/images/Factory.js";import{Manipulator3D as J}from"../../Manipulator3D.js";import{createRotateManipulator as K,getGraphicAttachmentOrigin as Q,calculateInputRotationTransform as $}from"../../manipulatorUtils.js";import{screenToZConstrained as tt,screenToRenderPlane as et}from"../dragEventPipeline3D.js";import{ManipulatorType as it}from"../ManipulatorType.js";import{canMoveZ as at}from"../manipulatorUtils.js";import{getSettings as st}from"../settings.js";import{createVisualElements as ot}from"../visualElementUtils.js";import{ManipulationType as rt}from"../manipulations/MoveManipulation.js";import{MoveXYGraphicManipulation as nt}from"../manipulations/MoveXYGraphicManipulation.js";import{PreserveAspectRatio as pt}from"./PreserveAspectRatio.js";import{OutlineVisualElement as lt}from"../../visualElements/OutlineVisualElement.js";import{evaluateElevationAlignmentAtPoint as ht}from"../../../layers/graphics/elevationAlignmentUtils.js";import{ElevationContext as ct}from"../../../layers/graphics/ElevationContext.js";import{GraphicState as ut}from"../../../layers/graphics/GraphicState.js";import{fromScreen as dt}from"../../../support/geometryUtils/ray.js";import{createManipulatorDragEventPipeline as mt,addMapDelta as _t,addScreenDelta as gt}from"../../../../interactive/dragEventPipeline.js";import{InteractiveToolBase as vt}from"../../../../interactive/InteractiveToolBase.js";import{EditGeometryOperations as yt}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import{AccumulationBehaviour as ft}from"../../../../interactive/editGeometry/interfaces.js";import{AccumulationType as St}from"../../../../interactive/editGeometry/operations/UpdateVertices.js";import{mapPlaneAutoHorizontalSizeByElevationMode as Mt,calculateOrientedBounds as bt,mapPlaneToRenderPlane as Tt,apply as Et,unapply as xt}from"../../../../interactive/editGeometry/support/editPlaneUtils.js";import At from"../../../../interactive/sketch/SketchTooltipOptions.js";import{ExtentRotateTooltipInfo as Bt,ExtentScaleTooltipInfo as Ot}from"../../../../interactive/tooltip/ExtentTooltipInfos.js";import{Tooltip as Rt}from"../../../../interactive/tooltip/Tooltip.js";import{TranslateGraphicTooltipInfo as jt,TranslateGraphicZTooltipInfo as Gt}from"../../../../interactive/tooltip/TranslateTooltipInfos.js";import{autoHorizontalDistanceByElevationModeBetweenPoints as Dt}from"../../../../support/automaticLengthMeasurementUtils.js";import{multiplyOpacity as wt,unitRGBAFromColor as Pt}from"../../../../support/colorUtils.js";import{verticalSignedDistance as zt}from"../../../../support/euclideanLengthMeasurementUtils.js";let Ut=class extends(e.EventedMixin(vt)){constructor(t){super(t),this.enableZ=!0,this.enableRotation=!0,this.enableScaling=!0,this.tooltipOptions=new At,this._preserveAspectRatio=new pt,this.grabbing=!1,this.inputState=null,this.type="transform-3d",this._attachmentOrigin=null,this._outlineVisualElement=null,this._mapBounds=A(),this._mapBoundsStart=A(),this._zmax=0,this._sizeStart=null,this._displayBounds=A(),this._displayBoundsStart=A(),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=g(),this._endScale=g()}initialize(){const{view:t,graphic:e,manipulators:a}=this,s=st(t).colors,n=this._graphicState=new ut({graphic:e}),p=e.geometry;this._editGeometryOperations=yt.fromGeometry(p,t.state.viewingMode),this._graphicMoveManipulation=new nt({tool:this,view:t,graphicState:n}),this._moveZManipulator=U(t,{offsetMode:I.CENTER_ON_CALLOUT,calloutColor:s.accent,color:s.contrast,outlineColor:s.accent}),this._moveZManipulator.state|=Z,this.addHandles([this._createMoveXYGraphicDragPipeline(),o((()=>this.enableZ),(()=>this._updateManipulatorAvailability(this._moveZManipulator,it.TRANSLATE_Z))),this._createMoveZDragPipeline()]),a.add(this._moveZManipulator),this._resizeManipulators=this._resizeHandles.map((e=>{const i=C(t,e,{color:s.accent});return this.addHandles([o((()=>this.enableScaling),(()=>this._updateManipulatorAvailability(i,it.SCALE))),i.events.on("grab-changed",(t=>this._onResizeGrab(t))),this._createResizeDragPipeline(i,e)]),i})),a.addMany(this._resizeManipulators);const l=!this.view._stage?.renderView.renderingContext.driverTest.svgPremultipliesAlpha.result;this._rotateManipulatorTexture=W(t.toolViewManager.textures,{accentColor:wt(s.accent,.5),contrastColor:s.contrast,preMultiplyAlpha:l}),this._rotateManipulator=K(t,{calloutColor:Pt(s.accent),texture:this._rotateManipulatorTexture.texture}),this.addHandles([o((()=>this.enableRotation),(()=>this._updateManipulatorAvailability(this._rotateManipulator,it.ROTATE))),this._rotateManipulator.events.on("grab-changed",(t=>{this._onRotateGrab(t)})),this._createRotateDragPipeline(this._rotateManipulator)]),a.add(this._rotateManipulator),this._calculateMapBounds(),this._updateDisplayBounds();const h=ot({view:t,graphic:e,forEachManipulator:t=>this._forEachManipulator(t),onManipulatorsChanged:()=>i()});null!=h&&(this._outlineVisualElement=h.visualElement instanceof lt?h.visualElement:null),null!=this._outlineVisualElement&&this.addHandles(this._outlineVisualElement.events.on("attachment-origin-changed",(()=>this._updateDisplayBounds()))),h&&this.addHandles(h),this.addHandles([n.on("changed",(()=>this._onGeometryChanged())),o((()=>n.displaying),(()=>this._updateAllManipulatorAvailability())),o((()=>n.isDraped),(()=>this._graphicDrapedChanged()),r),t.trackGraphicState(n)]);const c=t.pointsOfInterest;this.addHandles(o((()=>c?.centerOnSurfaceFrequent.location),(()=>this._updateDisplayBounds())));const u=t=>{this.addHandles(t.events.on("grab-changed",(()=>{this.grabbing=t.grabbing,this._updateAllManipulatorAvailability()})))};this._forEachManipulator(u);const d=(t,i)=>{this.addHandles(t.events.on("immediate-click",(t=>{i===it.TRANSLATE_XY&&this.emit("immediate-click",{...t,graphic:e}),t.stopPropagation()})))};this._forEachManipulator(d),this._onGeometryChanged(),this._updateAllManipulatorAvailability(),this._initializeTooltip(),this.finishToolCreation()}destroy(){this._mapBounds=null,this._displayBounds=null,this._rotateManipulatorTexture.release(),this._graphicMoveManipulation.destroy(),this._editGeometryOperations.destroy(),this._tooltip.destroy(),this._set("view",null),this._set("graphic",null)}_initializeTooltip(){const{view:t}=this,e=this._tooltip=new Rt({view:t}),i=()=>{e.info=this._getUpdatedTooltipInfo()};this.addHandles([this.on("graphic-translate-start",i),this.on("graphic-translate",i),this.on("graphic-translate-stop",(()=>{this._moveXYTooltipInfo=null,this._moveZTooltipInfo=null,this._tooltip.clear()})),this.on("graphic-rotate-start",(t=>{this._startAngle=t.angle,i()})),this.on("graphic-rotate",(t=>{this._endAngle=t.angle,i()})),this.on("graphic-rotate-stop",(()=>{this._startAngle=0,this._endAngle=0,i()})),this.on("graphic-scale-start",(t=>{d(this._startScale,t.xScale,t.yScale),d(this._endScale,t.xScale,t.yScale),i()})),this.on("graphic-scale",(t=>{d(this._endScale,t.xScale,t.yScale),i()})),this.on("graphic-scale-stop",(()=>{d(this._startScale,0,0),d(this._endScale,0,0),i()}))]),this._forEachManipulator((t=>{this.addHandles([t.events.on("focus-changed",i),t.events.on("grab-changed",i),t.events.on("drag",(t=>{"cancel"===t.action?this._tooltip.clear():i()}))])}))}_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??=new jt({tooltipOptions:this.tooltipOptions})}_computeMoveZTooltipInfo(){const t=this._moveZTooltipInfo??=new Gt({tooltipOptions:this.tooltipOptions}),e=this._moveUnit;if(this._moveZManipulator.dragging){const e=this._mapBoundsStart.origin,i=this._mapBounds.origin,a=zt(e,i,this.view.spatialReference);if(null==a)return null;t.distance=a}else t.distance=s(0,e);return t}_computeRotateTooltipInfo(){const t=this._rotateTooltipInfo??=new Bt({tooltipOptions:this.tooltipOptions});return t.angle=this._startAngle-this._endAngle,t}_computeScaleTooltipInfo(){const t=this.graphic.geometry;if(null==t)return null;const e=this._scaleTooltipInfo??=new Ot({tooltipOptions:this.tooltipOptions}),i=Mt(this._mapBounds,this._zmax,t.spatialReference,this._graphicState.isDraped);return null==i?null:(e.xSize=i[0],e.ySize=i[1],null!=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.removeHandles(It),this._updateDisplayBounds(),this._graphicState.isDraped&&this.addHandles(this.view.elevationProvider.on("elevation-change",(t=>{null!=this._attachmentOrigin&&x(t.extent,this._attachmentOrigin.x,this._attachmentOrigin.y)&&this._updateDisplayBounds()})),It)}_updateAllManipulatorAvailability(){this._forEachManipulator(((t,e)=>this._updateManipulatorAvailability(t,e)))}_updateManipulatorAvailability(t,e){const i=this.grabbing&&!t.grabbing;if(t.interactive=!i,t instanceof J){const a=this._graphicState.displaying,s=this.enableZ&&at(this.graphic);switch(e){case it.ROTATE:t.available=a&&this.enableRotation;break;case it.SCALE:t.available=a&&(this.enableScaling||this.enableRotation||s),t.interactive=!i&&this.enableScaling,t.state=this.enableScaling?H:k;break;case it.TRANSLATE_Z:t.available=a&&s;break;default:t.available=a}}}_forEachManipulator(t){this._graphicMoveManipulation.forEachManipulator(t),this._resizeManipulators.forEach((e=>t(e,it.SCALE))),t(this._rotateManipulator,it.ROTATE),t(this._moveZManipulator,it.TRANSLATE_Z)}get preserveAspectRatio(){return this._preserveAspectRatio.enabled}set preserveAspectRatio(t){this._preserveAspectRatio.enabled=t,this._set("preserveAspectRatio",t)}get _moveUnit(){return p(this.view.spatialReference)??"meters"}reset(){}_onGeometryChanged(){this._updateDisplayBounds()}_calculateMapBounds(){const t=this.graphic.geometry,e=this._editGeometryOperations.data,i=e.firstNonVerticalEdge(),a=d(D.get(),1,0);i&&(m(a,i.leftVertex.pos,i.rightVertex.pos),_(a,a));const s=Q(this.view,this.graphic)??t.extent?.center;let o=s?Ct*this.view.pixelSizeAt(s):0;const r=this.view.spatialReference,n=t.spatialReference;r.equals(n)||(o*=l(r)/l(n)),bt(a,e,o,this._mapBounds),this._updateZMax()}_updateZMax(){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)??0;i=Math.max(a,i)}this._zmax=i}_updateDisplayBounds(){const{geometry:t}=this.graphic;if(null==t)return;const{extent:e}=t;if(!e)return;const i=null==this._outlineVisualElement||this._graphicState.isDraped||null==this._outlineVisualElement.attachmentOrigin?Q(this.view,this.graphic):this._outlineVisualElement.attachmentOrigin;this._attachmentOrigin=i??e.center;const a=null!=i?i.z:ht(this._mapBounds.origin,this.view.elevationProvider,ct.fromElevationInfo(z(this.graphic)),this.view.renderCoordsHelper),s=B(this._mapBounds);s.origin[2]=a??0,Tt(s,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 e?Zt*this.view.pixelSizeAt(e):0}_createMoveXYGraphicDragPipeline(){return this._graphicMoveManipulation.createDragPipeline(((t,e,i)=>this._applyGraphicMoveSteps(e,i,rt.XY)))}_createMoveZDragPipeline(){const t=this.view,e=this._editGeometryOperations.data.spatialReference;return mt(this._moveZManipulator,((i,a,s)=>{const o=E(i.renderLocation),r=a.next(tt(t,o,e)).next(gt());this._applyGraphicMoveSteps(r,s,rt.Z)}))}_applyGraphicMoveSteps(t,e,i){const a=t.next((t=>("start"===t.action&&(this.inputState={type:"move"},this._updateOperationStartProperties(),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??0)-(t.mapStart.z??0))&&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((()=>{null!=this.inputState&&this.emit("graphic-translate-stop",{graphic:this.graphic,dxScreen:0,dyScreen:0}),this._cancel()})),a}_updateOperationStartProperties(){B(this._displayBounds,this._displayBoundsStart),B(this._mapBounds,this._mapBoundsStart),null!=this.graphic.geometry?this._sizeStart=Mt(this._mapBoundsStart,this._zmax,this.graphic.geometry.spatialReference,this._graphicState.isDraped):this._sizeStart=null}_moveDragUpdateGeometry(){return t=>{if(null==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?ft.NEW_STEP:ft.ACCUMULATE_STEPS,a=this._editGeometryOperations.moveVertices(e,t.mapDeltaX,t.mapDeltaY,t.mapDeltaZ,i);return Et(a,this._mapBounds),this.graphic.geometry=this._editGeometryOperations.data.geometry,t}}_updateMoveTooltip(t,e){if(e===rt.XY||e===rt.XY_AXIS){const e=Dt(t.mapStart,t.mapEnd,this._graphicState.isDraped?"on-the-ground":"absolute-height");null!=e&&null!=this._moveXYTooltipInfo&&(this._moveXYTooltipInfo.distance=e)}return t}_onResizeGrab({action:t,screenPoint:e}){if("start"!==t||!e)return;const i=this._calculatePickRay(e);O(this._displayBounds.plane,i,w.get())&&(this._updateOperationStartProperties(),this._displayBoundsMarginStart=this._displayBoundsMargin,this.inputState={type:"resize"})}_createResizeDragPipeline(t,e){return mt(t,((t,i,a)=>{null!=this.inputState&&(i.next((t=>("start"===t.action&&this.emit("graphic-scale-start",{graphic:this.graphic,xScale:1,yScale:1}),t))).next(et(this.view,this._displayBoundsStart.plane)).next((t=>({...t,handle:e}))).next(this._resizeDragRenderPlaneToFactors()).next(...this._preserveAspectRatio.createDragEventPipelineStep()).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((()=>{null!=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=v(w.get(),e.origin);y(o,o,e.basis1,-i[0]),y(o,o,e.basis2,-i[1]);const r=f(w.get(),t.renderEnd,o),n=f(w.get(),t.renderStart,o),p=L(t.handle),l=N(e),h=N(this._displayBounds)/l,c=(t,e)=>{if(0===t)return 1;let i=M(e),o=.5*t*b(e,r)/i;const l=o<0?-1:1;if(p){o+=(i-.5*t*b(e,n)/i)*l*h}const c=i<1.5*s?1:Ht;return i=Math.max(i-s,Ht),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=v(T(),this._mapBoundsStart.origin);y(e,e,this._mapBoundsStart.basis1,-t.handle.direction[0]),y(e,e,this._mapBoundsStart.basis2,-t.handle.direction[1]);const i=d(g(),this._mapBoundsStart.basis1[0],this._mapBoundsStart.basis1[1]);_(i,i);const a=[];for(const r of this._editGeometryOperations.data.components)a.push(...r.vertices);const s="start"===t.action?ft.NEW_STEP:ft.ACCUMULATE_STEPS,o=this._editGeometryOperations.scaleVertices(a,e,i,t.factor1,t.factor2,s,St.REPLACE);return B(this._mapBoundsStart,this._mapBounds),Et(o,this._mapBounds),this.graphic.geometry=this._editGeometryOperations.data.geometry,t}}_onRotateGrab({action:t,screenPoint:e}){if("start"!==t||!e)return;const i=V(this._displayBounds,this.view.renderCoordsHelper,X.HEADING,R()),a=this._calculatePickRay(e);O(i,a,w.get())&&(this._updateOperationStartProperties(),this.inputState={type:"rotate",rotatePlane:i})}_createRotateDragPipeline(t){return mt(t,((t,e,i)=>{const s=this.inputState;null!=s&&(e.next((t=>("start"===t.action&&this.emit("graphic-rotate-start",{graphic:this.graphic,angle:0}),t))).next(et(this.view,s.rotatePlane)).next(this._rotateDragRenderPlaneToRotate(s)).next(this._rotateDragUpdateGeometry()).next((t=>{const e={graphic:this.graphic,angle:a(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((()=>{null!=this.inputState&&this.emit("graphic-rotate-stop",{graphic:this.graphic,angle:0}),this._cancel()})))}))}_rotateDragRenderPlaneToRotate(t){return e=>{const i=j(t.rotatePlane),a=$(e.renderStart,e.renderEnd,this._displayBounds.origin,i);return{...e,rotateAxis:i,rotateAngle:a}}}_rotateDragUpdateGeometry(){return t=>{const e=v(T(),this._mapBoundsStart.origin),i=[];for(const o of this._editGeometryOperations.data.components)i.push(...o.vertices);const a="start"===t.action?ft.NEW_STEP:ft.ACCUMULATE_STEPS,s=this._editGeometryOperations.rotateVertices(i,e,t.rotateAngle,a,St.REPLACE);return B(this._mapBoundsStart,this._mapBounds),Et(s,this._mapBounds),this.graphic.geometry=this._editGeometryOperations.data.geometry,t}}_calculatePickRay(t){const e=G(),i=n(t);return dt(this.view.state.camera,i,e),S(e.direction,e.direction),e}_updateManipulators(){if(!this.visible)return;const t=Y(this._displayBounds,P.get());F(this._rotateManipulator,t,this._displayBounds,this.view.renderCoordsHelper),this._updateZMoveHandle(this._moveZManipulator,t),this._resizeManipulators.forEach(((e,i)=>{q(e,this._resizeHandles[i],t,this._displayBounds)}))}_updateZMoveHandle(t,e){const i=this._displayBounds,a={basis:i.basis1,direction:-1,position:f(w.get(),i.origin,i.basis1),edge:2},s=P.get();u(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;null!=t&&(this._editGeometryOperations.undo(),this.graphic.geometry=this._editGeometryOperations.data.geometry,xt(t,this._mapBounds),this._updateDisplayBounds(),this.inputState=null)}get canUndo(){return this._editGeometryOperations.canUndo}undo(){if(null!=this.inputState)this.view.activeTool=null;else if(this.canUndo){const t=this._editGeometryOperations.undo();this.graphic.geometry=this._editGeometryOperations.data.geometry,xt(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,Et(t,this._mapBounds),this._updateDisplayBounds()}}get test(){return{resizeManipulators:this._resizeManipulators,rotateManipulator:this._rotateManipulator,moveZManipulator:this._moveZManipulator,tooltip:this._tooltip}}};t([h({constructOnly:!0,nonNullable:!0})],Ut.prototype,"view",void 0),t([h({constructOnly:!0,nonNullable:!0})],Ut.prototype,"graphic",void 0),t([h({constructOnly:!0,nonNullable:!0})],Ut.prototype,"enableZ",void 0),t([h()],Ut.prototype,"enableRotation",void 0),t([h()],Ut.prototype,"enableScaling",void 0),t([h({constructOnly:!0,type:At})],Ut.prototype,"tooltipOptions",void 0),t([h()],Ut.prototype,"preserveAspectRatio",null),t([h()],Ut.prototype,"grabbing",void 0),t([h()],Ut.prototype,"inputState",void 0),t([h({readOnly:!0})],Ut.prototype,"type",void 0),t([h()],Ut.prototype,"_moveUnit",null),Ut=t([c("esri.views.3d.interactive.editingTools.graphicTransform3D.ExtentTransformTool")],Ut);const It="draped-elevation-changes",Zt=10,Ct=80,Ht=1e-6;export{Ht as EPSILON,Ut as ExtentTransformTool};
5
+ import{_ as t}from"../../../../../chunks/tslib.es6.js";import{multiplyOpacity as e,unitRGBAFromColor as i}from"../../../../../core/colorUtils.js";import a from"../../../../../core/Evented.js";import{makeHandle as s}from"../../../../../core/handleUtils.js";import{rad2deg as o}from"../../../../../core/mathUtils.js";import{createLength as r}from"../../../../../core/quantityUtils.js";import{watch as n,initial as p}from"../../../../../core/reactiveUtils.js";import{screenPointObjectToArray as l}from"../../../../../core/screenUtils.js";import{lengthUnitFromSpatialReference as h,getMetersPerUnitForSR as c}from"../../../../../core/unitUtils.js";import{property as u}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as d}from"../../../../../core/accessorSupport/decorators/subclass.js";import{o as m}from"../../../../../chunks/mat4.js";import{s as _,c as g,e as v}from"../../../../../chunks/vec2.js";import{a as y}from"../../../../../chunks/vec2f64.js";import{c as f,q as S,b as M,n as b,l as T,e as E}from"../../../../../chunks/vec3.js";import{c as x,a as A}from"../../../../../chunks/vec3f64.js";import{containsXY as B}from"../../../../../geometry/support/aaBoundingRect.js";import{a as O,c as R}from"../../../../../chunks/boundedPlane.js";import{intersectRay as j,create as G,normal as D}from"../../../../../geometry/support/plane.js";import{create as w}from"../../../../../geometry/support/ray.js";import{sv2d as P,sv3d as z,sm4d as U}from"../../../../../geometry/support/vectorStacks.js";import{getGraphicEffectiveElevationInfo as I}from"../../../../../support/elevationInfoUtils.js";import{createShiftManipulator as Z,OffsetMode as C,IsShiftEdgeOnScreenFlag as H,createResizeManipulator as k,resizeNormal as L,resizeOutlineOnly as N,isDiagonalResizeHandle as V,calculateDiagonalResizeHandleScale as X,createRotatePlane as Y,RotationAxis as F,calculateBoundedPlaneTranslateRotate as q,updateRotateHeadingHandle as W,updateResizeHandle as J}from"../../../analysis/Slice/sliceToolUtils.js";import{getRotateHeadingTexture as K}from"../../../analysis/Slice/images/Factory.js";import{Manipulator3D as Q}from"../../Manipulator3D.js";import{createRotateManipulator as $,getGraphicAttachmentOrigin as tt,calculateInputRotationTransform as et}from"../../manipulatorUtils.js";import{screenToZConstrained as it,screenToRenderPlane as at}from"../dragEventPipeline3D.js";import{ManipulatorType as st}from"../ManipulatorType.js";import{canMoveZ as ot}from"../manipulatorUtils.js";import{getSettings as rt}from"../settings.js";import{createVisualElements as nt}from"../visualElementUtils.js";import{ManipulationType as pt}from"../manipulations/MoveManipulation.js";import{MoveXYGraphicManipulation as lt}from"../manipulations/MoveXYGraphicManipulation.js";import{PreserveAspectRatio as ht}from"./PreserveAspectRatio.js";import{OutlineVisualElement as ct}from"../../visualElements/OutlineVisualElement.js";import{evaluateElevationAlignmentAtPoint as ut}from"../../../layers/graphics/elevationAlignmentUtils.js";import{ElevationContext as dt}from"../../../layers/graphics/ElevationContext.js";import{GraphicState as mt}from"../../../layers/graphics/GraphicState.js";import{fromScreen as _t}from"../../../support/geometryUtils/ray.js";import{createManipulatorDragEventPipeline as gt,addMapDelta as vt,addScreenDelta as yt}from"../../../../interactive/dragEventPipeline.js";import{InteractiveToolBase as ft}from"../../../../interactive/InteractiveToolBase.js";import{EditGeometryOperations as St}from"../../../../interactive/editGeometry/EditGeometryOperations.js";import{AccumulationBehaviour as Mt}from"../../../../interactive/editGeometry/interfaces.js";import{AccumulationType as bt}from"../../../../interactive/editGeometry/operations/UpdateVertices.js";import{mapPlaneAutoHorizontalSizeByElevationMode as Tt,calculateOrientedBounds as Et,mapPlaneToRenderPlane as xt,apply as At,unapply as Bt}from"../../../../interactive/editGeometry/support/editPlaneUtils.js";import Ot from"../../../../interactive/sketch/SketchTooltipOptions.js";import{ExtentRotateTooltipInfo as Rt,ExtentScaleTooltipInfo as jt}from"../../../../interactive/tooltip/ExtentTooltipInfos.js";import{Tooltip as Gt}from"../../../../interactive/tooltip/Tooltip.js";import{TranslateGraphicTooltipInfo as Dt,TranslateGraphicZTooltipInfo as wt}from"../../../../interactive/tooltip/TranslateTooltipInfos.js";import{autoHorizontalDistanceByElevationModeBetweenPoints as Pt}from"../../../../support/automaticLengthMeasurementUtils.js";import{verticalSignedDistance as zt}from"../../../../support/euclideanLengthMeasurementUtils.js";let Ut=class extends(a.EventedMixin(ft)){constructor(t){super(t),this.enableZ=!0,this.enableRotation=!0,this.enableScaling=!0,this.tooltipOptions=new Ot,this._preserveAspectRatio=new ht,this.grabbing=!1,this.inputState=null,this.type="transform-3d",this._attachmentOrigin=null,this._outlineVisualElement=null,this._mapBounds=O(),this._mapBoundsStart=O(),this._zmax=0,this._sizeStart=null,this._displayBounds=O(),this._displayBoundsStart=O(),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=y(),this._endScale=y()}initialize(){const{view:t,graphic:a,manipulators:o}=this,r=rt(t.effectiveTheme).colors,l=this._graphicState=new mt({graphic:a}),h=a.geometry;this._editGeometryOperations=St.fromGeometry(h,t.state.viewingMode),this._graphicMoveManipulation=new lt({tool:this,view:t,graphicState:l}),this._moveZManipulator=Z(t,{offsetMode:C.CENTER_ON_CALLOUT,calloutColor:r.accent,color:r.contrast,outlineColor:r.accent}),this._moveZManipulator.state|=H,this.addHandles([this._createMoveXYGraphicDragPipeline(),n((()=>this.enableZ),(()=>this._updateManipulatorAvailability(this._moveZManipulator,st.TRANSLATE_Z))),this._createMoveZDragPipeline()]),o.add(this._moveZManipulator),this._resizeManipulators=this._resizeHandles.map((e=>{const i=k(t,e,{color:r.accent});return this.addHandles([n((()=>this.enableScaling),(()=>this._updateManipulatorAvailability(i,st.SCALE))),i.events.on("grab-changed",(t=>this._onResizeGrab(t))),this._createResizeDragPipeline(i,e)]),i})),o.addMany(this._resizeManipulators);const c=!this.view._stage?.renderView.renderingContext.driverTest.svgPremultipliesAlpha.result;this._rotateManipulatorTexture=K(t.toolViewManager.textures,{accentColor:e(r.accent,.5),contrastColor:r.contrast,preMultiplyAlpha:c}),this._rotateManipulator=$(t,{calloutColor:i(r.accent),texture:this._rotateManipulatorTexture.texture}),this.addHandles([n((()=>this.enableRotation),(()=>this._updateManipulatorAvailability(this._rotateManipulator,st.ROTATE))),this._rotateManipulator.events.on("grab-changed",(t=>{this._onRotateGrab(t)})),this._createRotateDragPipeline(this._rotateManipulator)]),o.add(this._rotateManipulator),this._calculateMapBounds(),this._updateDisplayBounds();const u=nt({view:t,graphic:a,forEachManipulator:t=>this._forEachManipulator(t),onManipulatorsChanged:()=>s()});null!=u&&(this._outlineVisualElement=u.visualElement instanceof ct?u.visualElement:null),null!=this._outlineVisualElement&&this.addHandles(this._outlineVisualElement.events.on("attachment-origin-changed",(()=>this._updateDisplayBounds()))),u&&this.addHandles(u),this.addHandles([l.on("changed",(()=>this._onGeometryChanged())),n((()=>l.displaying),(()=>this._updateAllManipulatorAvailability())),n((()=>l.isDraped),(()=>this._graphicDrapedChanged()),p),t.trackGraphicState(l)]);const d=t.pointsOfInterest;this.addHandles(n((()=>d?.centerOnSurfaceFrequent.location),(()=>this._updateDisplayBounds())));const m=t=>{this.addHandles(t.events.on("grab-changed",(()=>{this.grabbing=t.grabbing,this._updateAllManipulatorAvailability()})))};this._forEachManipulator(m);const _=(t,e)=>{this.addHandles(t.events.on("immediate-click",(t=>{e===st.TRANSLATE_XY&&this.emit("immediate-click",{...t,graphic:a}),t.stopPropagation()})))};this._forEachManipulator(_),this._onGeometryChanged(),this._updateAllManipulatorAvailability(),this._initializeTooltip(),this.finishToolCreation()}destroy(){this._mapBounds=null,this._displayBounds=null,this._rotateManipulatorTexture.release(),this._graphicMoveManipulation.destroy(),this._editGeometryOperations.destroy(),this._tooltip.destroy(),this._set("view",null),this._set("graphic",null)}_initializeTooltip(){const{view:t}=this,e=this._tooltip=new Gt({view:t}),i=()=>{e.info=this._getUpdatedTooltipInfo()};this.addHandles([this.on("graphic-translate-start",i),this.on("graphic-translate",i),this.on("graphic-translate-stop",(()=>{this._moveXYTooltipInfo=null,this._moveZTooltipInfo=null,this._tooltip.clear()})),this.on("graphic-rotate-start",(t=>{this._startAngle=t.angle,i()})),this.on("graphic-rotate",(t=>{this._endAngle=t.angle,i()})),this.on("graphic-rotate-stop",(()=>{this._startAngle=0,this._endAngle=0,i()})),this.on("graphic-scale-start",(t=>{_(this._startScale,t.xScale,t.yScale),_(this._endScale,t.xScale,t.yScale),i()})),this.on("graphic-scale",(t=>{_(this._endScale,t.xScale,t.yScale),i()})),this.on("graphic-scale-stop",(()=>{_(this._startScale,0,0),_(this._endScale,0,0),i()}))]),this._forEachManipulator((t=>{this.addHandles([t.events.on("focus-changed",i),t.events.on("grab-changed",i),t.events.on("drag",(t=>{"cancel"===t.action?this._tooltip.clear():i()}))])}))}_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??=new Dt({tooltipOptions:this.tooltipOptions})}_computeMoveZTooltipInfo(){const t=this._moveZTooltipInfo??=new wt({tooltipOptions:this.tooltipOptions}),e=this._moveUnit;if(this._moveZManipulator.dragging){const e=this._mapBoundsStart.origin,i=this._mapBounds.origin,a=zt(e,i,this.view.spatialReference);if(null==a)return null;t.distance=a}else t.distance=r(0,e);return t}_computeRotateTooltipInfo(){const t=this._rotateTooltipInfo??=new Rt({tooltipOptions:this.tooltipOptions});return t.angle=this._startAngle-this._endAngle,t}_computeScaleTooltipInfo(){const t=this.graphic.geometry;if(null==t)return null;const e=this._scaleTooltipInfo??=new jt({tooltipOptions:this.tooltipOptions}),i=Tt(this._mapBounds,this._zmax,t.spatialReference,this._graphicState.isDraped);return null==i?null:(e.xSize=i[0],e.ySize=i[1],null!=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.removeHandles(It),this._updateDisplayBounds(),this._graphicState.isDraped&&this.addHandles(this.view.elevationProvider.on("elevation-change",(t=>{null!=this._attachmentOrigin&&B(t.extent,this._attachmentOrigin.x,this._attachmentOrigin.y)&&this._updateDisplayBounds()})),It)}_updateAllManipulatorAvailability(){this._forEachManipulator(((t,e)=>this._updateManipulatorAvailability(t,e)))}_updateManipulatorAvailability(t,e){const i=this.grabbing&&!t.grabbing;if(t.interactive=!i,t instanceof Q){const a=this._graphicState.displaying,s=this.enableZ&&ot(this.graphic);switch(e){case st.ROTATE:t.available=a&&this.enableRotation;break;case st.SCALE:t.available=a&&(this.enableScaling||this.enableRotation||s),t.interactive=!i&&this.enableScaling,t.state=this.enableScaling?L:N;break;case st.TRANSLATE_Z:t.available=a&&s;break;default:t.available=a}}}_forEachManipulator(t){this._graphicMoveManipulation.forEachManipulator(t),this._resizeManipulators.forEach((e=>t(e,st.SCALE))),t(this._rotateManipulator,st.ROTATE),t(this._moveZManipulator,st.TRANSLATE_Z)}get preserveAspectRatio(){return this._preserveAspectRatio.enabled}set preserveAspectRatio(t){this._preserveAspectRatio.enabled=t,this._set("preserveAspectRatio",t)}get _moveUnit(){return h(this.view.spatialReference)??"meters"}reset(){}_onGeometryChanged(){this._updateDisplayBounds()}_calculateMapBounds(){const t=this.graphic.geometry,e=this._editGeometryOperations.data,i=e.firstNonVerticalEdge(),a=_(P.get(),1,0);i&&(g(a,i.leftVertex.pos,i.rightVertex.pos),v(a,a));const s=tt(this.view,this.graphic)??t.extent?.center;let o=s?Ct*this.view.pixelSizeAt(s):0;const r=this.view.spatialReference,n=t.spatialReference;r.equals(n)||(o*=c(r)/c(n)),Et(a,e,o,this._mapBounds),this._updateZMax()}_updateZMax(){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)??0;i=Math.max(a,i)}this._zmax=i}_updateDisplayBounds(){const{geometry:t}=this.graphic;if(null==t)return;const{extent:e}=t;if(!e)return;const i=null==this._outlineVisualElement||this._graphicState.isDraped||null==this._outlineVisualElement.attachmentOrigin?tt(this.view,this.graphic):this._outlineVisualElement.attachmentOrigin;this._attachmentOrigin=i??e.center;const a=null!=i?i.z:ut(this._mapBounds.origin,this.view.elevationProvider,dt.fromElevationInfo(I(this.graphic)),this.view.renderCoordsHelper),s=R(this._mapBounds);s.origin[2]=a??0,xt(s,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 e?Zt*this.view.pixelSizeAt(e):0}_createMoveXYGraphicDragPipeline(){return this._graphicMoveManipulation.createDragPipeline(((t,e,i)=>this._applyGraphicMoveSteps(e,i,pt.XY)))}_createMoveZDragPipeline(){const t=this.view,e=this._editGeometryOperations.data.spatialReference;return gt(this._moveZManipulator,((i,a,s)=>{const o=A(i.renderLocation),r=a.next(it(t,o,e)).next(yt());this._applyGraphicMoveSteps(r,s,pt.Z)}))}_applyGraphicMoveSteps(t,e,i){const a=t.next((t=>("start"===t.action&&(this.inputState={type:"move"},this._updateOperationStartProperties(),this.emit("graphic-translate-start",{graphic:this.graphic,dxScreen:t.screenDeltaX,dyScreen:t.screenDeltaY})),t))).next(vt()).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??0)-(t.mapStart.z??0))&&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((()=>{null!=this.inputState&&this.emit("graphic-translate-stop",{graphic:this.graphic,dxScreen:0,dyScreen:0}),this._cancel()})),a}_updateOperationStartProperties(){R(this._displayBounds,this._displayBoundsStart),R(this._mapBounds,this._mapBoundsStart),null!=this.graphic.geometry?this._sizeStart=Tt(this._mapBoundsStart,this._zmax,this.graphic.geometry.spatialReference,this._graphicState.isDraped):this._sizeStart=null}_moveDragUpdateGeometry(){return t=>{if(null==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?Mt.NEW_STEP:Mt.ACCUMULATE_STEPS,a=this._editGeometryOperations.moveVertices(e,t.mapDeltaX,t.mapDeltaY,t.mapDeltaZ,i);return At(a,this._mapBounds),this.graphic.geometry=this._editGeometryOperations.data.geometry,t}}_updateMoveTooltip(t,e){if(e===pt.XY||e===pt.XY_AXIS){const e=Pt(t.mapStart,t.mapEnd,this._graphicState.isDraped?"on-the-ground":"absolute-height");null!=e&&null!=this._moveXYTooltipInfo&&(this._moveXYTooltipInfo.distance=e)}return t}_onResizeGrab({action:t,screenPoint:e}){if("start"!==t||!e)return;const i=this._calculatePickRay(e);j(this._displayBounds.plane,i,z.get())&&(this._updateOperationStartProperties(),this._displayBoundsMarginStart=this._displayBoundsMargin,this.inputState={type:"resize"})}_createResizeDragPipeline(t,e){return gt(t,((t,i,a)=>{null!=this.inputState&&(i.next((t=>("start"===t.action&&this.emit("graphic-scale-start",{graphic:this.graphic,xScale:1,yScale:1}),t))).next(at(this.view,this._displayBoundsStart.plane)).next((t=>({...t,handle:e}))).next(this._resizeDragRenderPlaneToFactors()).next(...this._preserveAspectRatio.createDragEventPipelineStep()).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((()=>{null!=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=f(z.get(),e.origin);S(o,o,e.basis1,-i[0]),S(o,o,e.basis2,-i[1]);const r=M(z.get(),t.renderEnd,o),n=M(z.get(),t.renderStart,o),p=V(t.handle),l=X(e),h=X(this._displayBounds)/l,c=(t,e)=>{if(0===t)return 1;let i=T(e),o=.5*t*E(e,r)/i;const l=o<0?-1:1;if(p){o+=(i-.5*t*E(e,n)/i)*l*h}const c=i<1.5*s?1:Ht;return i=Math.max(i-s,Ht),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=f(x(),this._mapBoundsStart.origin);S(e,e,this._mapBoundsStart.basis1,-t.handle.direction[0]),S(e,e,this._mapBoundsStart.basis2,-t.handle.direction[1]);const i=_(y(),this._mapBoundsStart.basis1[0],this._mapBoundsStart.basis1[1]);v(i,i);const a=[];for(const r of this._editGeometryOperations.data.components)a.push(...r.vertices);const s="start"===t.action?Mt.NEW_STEP:Mt.ACCUMULATE_STEPS,o=this._editGeometryOperations.scaleVertices(a,e,i,t.factor1,t.factor2,s,bt.REPLACE);return R(this._mapBoundsStart,this._mapBounds),At(o,this._mapBounds),this.graphic.geometry=this._editGeometryOperations.data.geometry,t}}_onRotateGrab({action:t,screenPoint:e}){if("start"!==t||!e)return;const i=Y(this._displayBounds,this.view.renderCoordsHelper,F.HEADING,G()),a=this._calculatePickRay(e);j(i,a,z.get())&&(this._updateOperationStartProperties(),this.inputState={type:"rotate",rotatePlane:i})}_createRotateDragPipeline(t){return gt(t,((t,e,i)=>{const a=this.inputState;null!=a&&(e.next((t=>("start"===t.action&&this.emit("graphic-rotate-start",{graphic:this.graphic,angle:0}),t))).next(at(this.view,a.rotatePlane)).next(this._rotateDragRenderPlaneToRotate(a)).next(this._rotateDragUpdateGeometry()).next((t=>{const e={graphic:this.graphic,angle:o(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((()=>{null!=this.inputState&&this.emit("graphic-rotate-stop",{graphic:this.graphic,angle:0}),this._cancel()})))}))}_rotateDragRenderPlaneToRotate(t){return e=>{const i=D(t.rotatePlane),a=et(e.renderStart,e.renderEnd,this._displayBounds.origin,i);return{...e,rotateAxis:i,rotateAngle:a}}}_rotateDragUpdateGeometry(){return t=>{const e=f(x(),this._mapBoundsStart.origin),i=[];for(const o of this._editGeometryOperations.data.components)i.push(...o.vertices);const a="start"===t.action?Mt.NEW_STEP:Mt.ACCUMULATE_STEPS,s=this._editGeometryOperations.rotateVertices(i,e,t.rotateAngle,a,bt.REPLACE);return R(this._mapBoundsStart,this._mapBounds),At(s,this._mapBounds),this.graphic.geometry=this._editGeometryOperations.data.geometry,t}}_calculatePickRay(t){const e=w(),i=l(t);return _t(this.view.state.camera,i,e),b(e.direction,e.direction),e}_updateManipulators(){if(!this.visible)return;const t=q(this._displayBounds,U.get());W(this._rotateManipulator,t,this._displayBounds,this.view.renderCoordsHelper),this._updateZMoveHandle(this._moveZManipulator,t),this._resizeManipulators.forEach(((e,i)=>{J(e,this._resizeHandles[i],t,this._displayBounds)}))}_updateZMoveHandle(t,e){const i=this._displayBounds,a={basis:i.basis1,direction:-1,position:M(z.get(),i.origin,i.basis1),edge:2},s=U.get();m(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;null!=t&&(this._editGeometryOperations.undo(),this.graphic.geometry=this._editGeometryOperations.data.geometry,Bt(t,this._mapBounds),this._updateDisplayBounds(),this.inputState=null)}get canUndo(){return this._editGeometryOperations.canUndo}undo(){if(null!=this.inputState)this.view.activeTool=null;else if(this.canUndo){const t=this._editGeometryOperations.undo();this.graphic.geometry=this._editGeometryOperations.data.geometry,Bt(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,At(t,this._mapBounds),this._updateDisplayBounds()}}get test(){return{resizeManipulators:this._resizeManipulators,rotateManipulator:this._rotateManipulator,moveZManipulator:this._moveZManipulator,tooltip:this._tooltip}}};t([u({constructOnly:!0,nonNullable:!0})],Ut.prototype,"view",void 0),t([u({constructOnly:!0,nonNullable:!0})],Ut.prototype,"graphic",void 0),t([u({constructOnly:!0,nonNullable:!0})],Ut.prototype,"enableZ",void 0),t([u()],Ut.prototype,"enableRotation",void 0),t([u()],Ut.prototype,"enableScaling",void 0),t([u({constructOnly:!0,type:Ot})],Ut.prototype,"tooltipOptions",void 0),t([u()],Ut.prototype,"preserveAspectRatio",null),t([u()],Ut.prototype,"grabbing",void 0),t([u()],Ut.prototype,"inputState",void 0),t([u({readOnly:!0})],Ut.prototype,"type",void 0),t([u()],Ut.prototype,"_moveUnit",null),Ut=t([d("esri.views.3d.interactive.editingTools.graphicTransform3D.ExtentTransformTool")],Ut);const It="draped-elevation-changes",Zt=10,Ct=80,Ht=1e-6;export{Ht as EPSILON,Ut 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.28/esri/copyright.txt for details.
4
4
  */
5
- import{cyclicalPI as t}from"../../../../../core/Cyclical.js";import e from"../../../../../core/Evented.js";import a from"../../../../../core/Handles.js";import{clamp as i,rad2deg as o}from"../../../../../core/mathUtils.js";import{destroyMaybe as s}from"../../../../../core/maybe.js";import{createAngle as n,createLength as r}from"../../../../../core/quantityUtils.js";import{when as l,initial as c,watch as h}from"../../../../../core/reactiveUtils.js";import{addFrameTask as p}from"../../../../../core/scheduling.js";import{createScreenPointArray as d}from"../../../../../core/screenUtils.js";import{d as u,E as g,m,k as _,e as f}from"../../../../../chunks/mat4.js";import{c as D}from"../../../../../chunks/mat4f64.js";import{s as S,b as M,l as v,d as y,f as w,a as b}from"../../../../../chunks/vec3.js";import{a as T,f as R}from"../../../../../chunks/vec3f64.js";import{fromPositionAndNormal as j,create as O,normal as I}from"../../../../../geometry/support/plane.js";import{wrap as k,distance2 as A}from"../../../../../geometry/support/ray.js";import{sv3d as F,sm4d as P}from"../../../../../geometry/support/vectorStacks.js";import{getGraphicEffectiveElevationInfo as C}from"../../../../../support/elevationInfoUtils.js";import{Manipulator3D as E}from"../../Manipulator3D.js";import{calculateInputRotationTransform as U}from"../../manipulatorUtils.js";import{RenderObject as L}from"../../RenderObject.js";import{screenToRenderPlane as z}from"../dragEventPipeline3D.js";import{ManipulatorType as x}from"../ManipulatorType.js";import{getSettings as N}from"../settings.js";import{RING_INDICATOR_DELAY_MS as H,ROTATE_INDICATOR_DIRECTION_BUFFER as V,SCALE_INDICATOR_DIRECTION_BUFFER as q,ROTATE_INDICATOR_ARROW_PLACEMENT_PERCENTAGE as B,RING_THICKNESS as G,DRAG_THRESHOLD_PX as J,RING_RADIUS as K,INNER_INDICATOR_RADIUS as Q,OUTER_INDICATOR_RADIUS as W,RING_HEIGHT as X,ROTATE_INDICATOR_ARROW_TIP_RADIUS as Y,ROTATE_INDICATOR_ARROW_TIP_LENGTH as Z,SCALE_INDICATOR_OFFSET1 as $,SCALE_INDICATOR_OFFSET2 as tt,INDICATOR_THICKNESS as et,GEOMETRY_SEGMENTS as at,ROTATE_INDICATOR_ARC_LENGTH as it,RING_RESET_ANIMATION_SPEED_FACTOR as ot,SCALE_INDICATOR_ARC_LENGTH as st}from"../manipulations/config.js";import{CullFaceOptions as nt}from"../../../webgl-engine/lib/basicInterfaces.js";import{createExtrudedTriangle as rt,transformInPlace as lt,createPathExtrusionGeometry as ct}from"../../../webgl-engine/lib/GeometryUtil.js";import{RenderOccludedFlag as ht}from"../../../webgl-engine/lib/Material.js";import{ColorMaterial as pt}from"../../../webgl-engine/materials/ColorMaterial.js";import{createManipulatorDragEventPipeline as dt}from"../../../../interactive/dragEventPipeline.js";import{ManipulatorStateCustomFlags as ut,ManipulatorStateFlags as gt}from"../../../../interactive/interfaces.js";import{Tooltip as mt}from"../../../../interactive/tooltip/Tooltip.js";import{TransformRotateTooltipInfo as _t,TransformScaleTooltipInfo as ft,TransformAbsoluteTooltipInfo as Dt}from"../../../../interactive/tooltip/TransformTooltipInfos.js";import{unitRGBAFromColor as St}from"../../../../support/colorUtils.js";var Mt,vt;!function(t){t.ScaleIn=ut.Custom2,t.ScaleOut=ut.Custom3,t.RotateLeft=ut.Custom4,t.RotateRight=ut.Custom5,t.Unlocked=ut.Custom7,t.DelayedFocused=ut.Custom8,t.TouchInput=ut.Custom12}(Mt||(Mt={}));class yt{get angle(){return this._adapter.angle}get scale(){return this._adapter.scale}set location(t){this._ringManipulator.location=t}set elevationAlignedLocation(t){this._ringManipulator.elevationAlignedLocation=t}get grabbing(){return this._ringManipulator.grabbing}set interactive(t){this._ringManipulator.interactive=t}constructor({adapter:t,tooltipOptions:i,mode:o,tool:s}){this._mode=null,this._handles=new a,this._scaleRotateDragData=null,this._activeAnimation=null,this._ringIndicatorDelayMs=H,this.events=new e,this.getFocused=()=>this._ringManipulator.focused,this.getScale=()=>"scale"===this._scaleRotateDragData?.mode?this._adapter.scale:1,this.tool=s,this._mode=o,this._adapter=t,this._tooltipOptions=i,this._tooltip=new mt({view:s.view}),this._createManipulator(),this._updateDragState(),this._updateManipulatorTransform(),this._handles.add(l((()=>!this._tooltipOptions.enabled),(()=>this._tooltip.clear()),c))}destroy(){this._activeAnimation?.frameTask.remove(),this._activeAnimation=null,this._handles=s(this._handles),this.tool.manipulators.remove(this._ringManipulator),this._ringManipulator=null,this._tooltip=s(this._tooltip)}startAnimation(t){this.cancelActiveAnimation(),t.start();const e=p({update:({deltaTime:e})=>{t.update(e)&&this.cancelActiveAnimation()}});this._activeAnimation={...t,frameTask:e}}cancelActiveAnimation(){this._activeAnimation?.frameTask.remove(),this._activeAnimation=s(this._activeAnimation)}forEachManipulator(t){t(this._ringManipulator,x.SCALE_ROTATE)}_createManipulator(){const e=this._createRingManipulator();this._ringManipulator=e,this.tool.manipulators.add(e);const a=this.tool.graphicState.graphic,s=dt(e,((e,s,n)=>{this._scaleRotateDragData=null;const r=this._adapter.startInteraction(),l={mode:"none",origin:T(e.renderLocation),initialAngle:this._adapter.angle,angle:0,angleDir:0,scaleDir:0};this._scaleRotateDragData=l,this._updateDragState();const c=F.get();this.tool.view.renderCoordsHelper.worldUpAtPosition(e.renderLocation,c),s.next(z(this.tool.view,j(e.renderLocation,c,O()))).next((e=>{const s=I(e.plane),n=U(e.renderStart,e.renderEnd,l.origin,s),c=t.shortestSignedDiff(l.angle,n);l.angleDir=i(l.angleDir+c,-V,V),l.angle=n;const h=wt(l,e),p=h-this._adapter.scale;if(l.scaleDir=i(l.scaleDir+p,-q,q),this._onScaleChanged(),"none"===l.mode){const t=this._mode||bt(e,e.plane,l.origin,this.tool.view.state.camera);if(null!=t){switch(t){case"rotate":this.tool.emit("graphic-rotate-start",{graphic:a,angle:0}),this.tool.emit("record-undo",{record:this._adapter.createUndoRecord()});break;case"scale":this.tool.emit("graphic-scale-start",{graphic:a,xScale:1,yScale:1}),this.tool.emit("record-undo",{record:this._adapter.createUndoRecord()})}l.mode=t}}switch(l.mode){case"rotate":r.state.angle=l.initialAngle+n;break;case"scale":r.state.scale=h,this._onScaleChanged()}switch(this._updateDragState(),this._updateManipulatorTransform(),e.action){case"start":case"update":switch(l.mode){case"rotate":this.tool.emit("graphic-rotate",{graphic:a,angle:o(l.angle)});break;case"scale":this.tool.emit("graphic-scale",{graphic:a,xScale:h,yScale:h})}break;case"end":switch(l.mode){case"rotate":this.tool.emit("graphic-rotate-stop",{graphic:a,angle:o(l.angle)});break;case"scale":this.tool.emit("graphic-scale-stop",{graphic:a,xScale:h,yScale:h})}}return"end"===e.action&&(this.startAnimation(Rt(this,(()=>this._onScaleChanged()))),this._scaleRotateDragData=null,this._updateDragState(),r.done()),e})).next(this._updateTooltipPipelineStep(l)),n.next((()=>{if(r.cancel(),null!=this._scaleRotateDragData){switch(this._scaleRotateDragData.mode){case"none":break;case"rotate":this.tool.emit("graphic-rotate-stop",{graphic:a,angle:0});break;case"scale":this.tool.emit("graphic-scale-stop",{graphic:a,xScale:1,yScale:1})}this.startAnimation(Rt(this,(()=>this._onScaleChanged()))),this._scaleRotateDragData=null,this._updateDragState()}this._updateFocusTooltip()}))}));this._handles.add([s,e.events.on("focus-changed",(t=>{"focus"===t.action?this.startAnimation(jt(this,(()=>this._updateDelayedFocusedState()),{delayMs:this._ringIndicatorDelayMs})):this._updateDelayedFocusedState()})),e.events.on("immediate-click",(t=>{t.stopPropagation()})),h((()=>this.tool.graphicState?.displaying),(t=>this._ringManipulator.available=t),c)])}_updateTooltipPipelineStep(t){return e=>{const a=this._tooltipOptions;if(!a.enabled)return e;if("end"===e.action)return this._updateFocusTooltip(),e;const i=this._tooltip,o=this._tooltipOptions.visualVariables;switch(t.mode){case"scale":{const{size:t,scale:e}=this._adapter,s=o?.size;i.info=new ft({tooltipOptions:a,scale:{value:e},size:null!=t?r(t,"meters"):void 0,sizePrecision:Ot(s?.valueType),sizeUnit:s?.unit});break}case"rotate":{const{orientationClockwise:t,relativeAngleClockwise:e}=this._adapter,s=o?.rotation,r=Ot(s?.valueType);i.info=new _t({tooltipOptions:a,rotation:null!=e?n(e,"radians","geographic"):void 0,rotationPrecision:r,rotationType:s?.rotationType??"geographic",orientation:null!=t?n(t,"radians","geographic"):void 0,orientationPrecision:r})}}return e}}_updateFocusTooltip(){if(!this._tooltipOptions.enabled)return;if(this.getFocused()){const t=this._tooltipOptions.visualVariables,e=t?.rotation,a=t?.size,i=this._mode,{size:o,orientationClockwise:s}=this._adapter,l=null!=s&&(null==i||"rotate"===i),c=null!=o&&(null==i||"scale"===i);this._tooltip.info=new Dt({tooltipOptions:this._tooltipOptions,orientation:l?n(s,"radians","geographic"):void 0,orientationPrecision:Ot(e?.valueType),rotationType:e?.rotationType??"geographic",size:c?r(o,"meters"):void 0,sizeUnit:a?.unit,sizePrecision:Ot(a?.valueType)})}else this._tooltip.clear()}_onScaleChanged(){this.events.emit("scale-changed"),this._updateManipulatorTransform()}_updateDelayedFocusedState(){this._ringManipulator.updateStateEnabled(Mt.DelayedFocused,this.getFocused()),this._updateFocusTooltip()}_updateDragState(){if(this._ringManipulator.updateStateEnabled(Mt.Unlocked,!(null!=this._scaleRotateDragData&&"none"!==this._scaleRotateDragData?.mode)),null!=this._scaleRotateDragData)switch(this._scaleRotateDragData.mode){case"rotate":this._ringManipulator.updateStateEnabled(Mt.ScaleIn|Mt.ScaleOut,!1),this._ringManipulator.updateStateEnabled(Mt.RotateLeft,this._scaleRotateDragData.angleDir<0),this._ringManipulator.updateStateEnabled(Mt.RotateRight,this._scaleRotateDragData.angleDir>=0);break;case"scale":this._ringManipulator.updateStateEnabled(Mt.RotateLeft|Mt.RotateRight,!1),this._ringManipulator.updateStateEnabled(Mt.ScaleIn,this._scaleRotateDragData.scaleDir<0),this._ringManipulator.updateStateEnabled(Mt.ScaleOut,this._scaleRotateDragData.scaleDir>=0)}else this._ringManipulator.updateStateEnabled(Mt.ScaleIn|Mt.ScaleOut|Mt.RotateLeft|Mt.RotateRight,!1)}_updateManipulatorTransform(){const t=u(P.get(),this._adapter.angle,R(0,0,1));if(null==t)return;const e=this.getScale(),a=g(P.get(),S(F.get(),e,e,e));this._ringManipulator.modelTransform=m(P.get(),a,t)}_createRingManipulator(){const t=(t,e,a)=>{const i=[],o=Math.ceil(at*(e-t)/(2*Math.PI));for(let s=0;s<o+1;s++){const n=t+s*(e-t)/o;i.push(R(a*Math.cos(n),a*Math.sin(n),0))}return i},e=e=>t(0,2*Math.PI,e),a=t=>[[-t/2,0],[t/2,0],[t/2,X/2],[-t/2,X/2]],i=this._createMaterial(1),o=(t,e,o=i)=>ct(o,a(e),t,[],[],!1),s=e(K),n=o(s,G),r={left:new Array,right:new Array},l=[];for(let R=0;R<2;R++){const e=R*Math.PI-Math.PI/4,a=Math.PI/2-it,s=e+a,n=e+Math.PI/2-a,c=t(s,n,Q),h=o(c,et);l.push(c),l.push(t(s,n,W-G/2)),r.left.push(h),r.right.push(h.instantiate());for(let t=0;t<2;t++){const e=0===t,a=D();if(e){_(a,a,[1,-1,1]),f(a,a,-s,[0,0,1]);const t=Math.round(B*(c.length-1));a[12]=c[t][0],a[13]=c[t][1],a[14]=c[t][2]}else{f(a,a,n,[0,0,1]);const t=Math.round((1-B)*(c.length-1));a[12]=c[t][0],a[13]=c[t][1],a[14]=c[t][2]}const o=rt(i,Z,0,Y,X);lt(o,a),(e?r.left:r.right).push(o)}}const c=[];for(let _=0;_<2;_++){const e=_*Math.PI-Math.PI/4,a=Math.PI/2-st,i=e+a,s=e+Math.PI/2-a,n=t(i,s,W);c.push(o(n,et))}const h=this._createMaterial(.66),p=this._createMaterial(.5),d=this._createMaterial(.33),u=e(K+$),g=e(K+tt),m=o(u,et,h),S=o(g,et,d),M=e(K-$),v=e(K-tt),y=o(M,et,h),w=o(v,et,d);let b=[new L(n,Mt.DelayedFocused),new L(n.instantiate({material:p}),gt.None)];this._mode&&"scale"!==this._mode||(b=b.concat([...c.map((t=>new L(t,Mt.DelayedFocused|Mt.Unlocked))),new L(m,Mt.DelayedFocused|Mt.ScaleIn),new L(S,Mt.DelayedFocused|Mt.ScaleIn),new L(y,Mt.DelayedFocused|Mt.ScaleOut),new L(w,Mt.DelayedFocused|Mt.ScaleOut)])),this._mode&&"rotate"!==this._mode||(b=b.concat([...r.right.map((t=>new L(t.instantiate(),Mt.DelayedFocused|Mt.Unlocked))),...r.left.map((t=>new L(t,Mt.DelayedFocused|Mt.RotateLeft))),...r.right.map((t=>new L(t,Mt.DelayedFocused|Mt.RotateRight)))]));const T=[s,...l];return new E({view:this.tool.view,renderObjects:b,autoScaleRenderObjects:!1,worldOriented:!0,radius:G,focusMultiplier:1,touchMultiplier:1.5,elevationInfo:C(this.tool.graphicState.graphic),collisionType:{type:"ribbon",paths:T,direction:R(0,0,1)}})}_createMaterial(t){const e=N(this.tool.view).colors.accent.clone();return e.a=t,new pt({color:St(e),transparent:1!==t,cullFace:nt.Back,renderOccluded:ht.Transparent,isDecoration:!0})}get test(){return{ringManipulator:this._ringManipulator,setRingIndicatorDelayMs:t=>this._ringIndicatorDelayMs=t,tooltip:this._tooltip}}}function wt(t,e){const a=M(F.get(),e.renderStart,t.origin),i=M(F.get(),e.renderEnd,t.origin),o=v(a),s=v(i);return 0===o?0:s/o}function bt(t,e,a,i){const{renderStart:o,renderEnd:s}=t,n=Tt(o,i,F.get()),r=Tt(s,i,F.get());if(y(n,r)<J*J)return null;const l=M(F.get(),o,a),c=w(F.get(),l,I(e)),h=o,p=b(F.get(),h,c),d=Tt(a,i,F.get()),u=n,g=Tt(p,i,F.get()),m=M(F.get(),g,u),_=M(F.get(),n,d),f=k(u,m),D=k(d,_);return A(f,r)<A(D,r)?"rotate":"scale"}function Tt(t,e,a){return e.projectToScreen(t,It),S(a,It[0],It[1],0)}function Rt(t,e){let a=null,i=1;const o=()=>i;return{start:()=>{i=t.getScale(),a=t.getScale,t.getScale=o,e()},update:t=>(i+=((i+1)/2-i)*Math.min(t*ot,1),e(),Math.abs(i-1)<.01?vt.STOP:vt.CONTINUE),destroy:()=>{a&&(t.getScale=a),e()}}}function jt(t,e,a){let i=0,o=null;const s=()=>!1;return{start:()=>{o=t.getFocused,t.getFocused=s,i=0,e()},update:t=>(i+=t,!o?.()||i>=a.delayMs?vt.STOP:vt.CONTINUE),destroy:()=>{o&&(t.getFocused=o),e()}}}function Ot(t){switch(t){case"integer":case"long":return 0;default:return null}}!function(t){t[t.CONTINUE=0]="CONTINUE",t[t.STOP=1]="STOP"}(vt||(vt={}));const It=d();export{yt as GraphicScaleRotateTransform};
5
+ import{unitRGBAFromColor as t}from"../../../../../core/colorUtils.js";import{cyclicalPI as e}from"../../../../../core/Cyclical.js";import a from"../../../../../core/Evented.js";import i from"../../../../../core/Handles.js";import{clamp as o,rad2deg as s}from"../../../../../core/mathUtils.js";import{destroyMaybe as n}from"../../../../../core/maybe.js";import{createAngle as r,createLength as l}from"../../../../../core/quantityUtils.js";import{when as c,initial as h,watch as p}from"../../../../../core/reactiveUtils.js";import{addFrameTask as d}from"../../../../../core/scheduling.js";import{createScreenPointArray as u}from"../../../../../core/screenUtils.js";import{d as g,E as m,m as _,k as f,e as D}from"../../../../../chunks/mat4.js";import{c as S}from"../../../../../chunks/mat4f64.js";import{s as M,b as v,l as y,d as w,f as b,a as T}from"../../../../../chunks/vec3.js";import{a as R,f as j}from"../../../../../chunks/vec3f64.js";import{fromPositionAndNormal as O,create as I,normal as k}from"../../../../../geometry/support/plane.js";import{wrap as A,distance2 as F}from"../../../../../geometry/support/ray.js";import{sv3d as P,sm4d as C}from"../../../../../geometry/support/vectorStacks.js";import{getGraphicEffectiveElevationInfo as E}from"../../../../../support/elevationInfoUtils.js";import{Manipulator3D as U}from"../../Manipulator3D.js";import{calculateInputRotationTransform as L}from"../../manipulatorUtils.js";import{RenderObject as z}from"../../RenderObject.js";import{screenToRenderPlane as x}from"../dragEventPipeline3D.js";import{ManipulatorType as N}from"../ManipulatorType.js";import{getSettings as H}from"../settings.js";import{RING_INDICATOR_DELAY_MS as V,ROTATE_INDICATOR_DIRECTION_BUFFER as q,SCALE_INDICATOR_DIRECTION_BUFFER as B,ROTATE_INDICATOR_ARROW_PLACEMENT_PERCENTAGE as G,RING_THICKNESS as J,DRAG_THRESHOLD_PX as K,RING_RADIUS as Q,INNER_INDICATOR_RADIUS as W,OUTER_INDICATOR_RADIUS as X,RING_HEIGHT as Y,ROTATE_INDICATOR_ARROW_TIP_RADIUS as Z,ROTATE_INDICATOR_ARROW_TIP_LENGTH as $,SCALE_INDICATOR_OFFSET1 as tt,SCALE_INDICATOR_OFFSET2 as et,INDICATOR_THICKNESS as at,GEOMETRY_SEGMENTS as it,ROTATE_INDICATOR_ARC_LENGTH as ot,RING_RESET_ANIMATION_SPEED_FACTOR as st,SCALE_INDICATOR_ARC_LENGTH as nt}from"../manipulations/config.js";import{CullFaceOptions as rt}from"../../../webgl-engine/lib/basicInterfaces.js";import{createExtrudedTriangle as lt,transformInPlace as ct,createPathExtrusionGeometry as ht}from"../../../webgl-engine/lib/GeometryUtil.js";import{RenderOccludedFlag as pt}from"../../../webgl-engine/lib/Material.js";import{ColorMaterial as dt}from"../../../webgl-engine/materials/ColorMaterial.js";import{createManipulatorDragEventPipeline as ut}from"../../../../interactive/dragEventPipeline.js";import{ManipulatorStateCustomFlags as gt,ManipulatorStateFlags as mt}from"../../../../interactive/interfaces.js";import{Tooltip as _t}from"../../../../interactive/tooltip/Tooltip.js";import{TransformRotateTooltipInfo as ft,TransformScaleTooltipInfo as Dt,TransformAbsoluteTooltipInfo as St}from"../../../../interactive/tooltip/TransformTooltipInfos.js";var Mt,vt;!function(t){t.ScaleIn=gt.Custom2,t.ScaleOut=gt.Custom3,t.RotateLeft=gt.Custom4,t.RotateRight=gt.Custom5,t.Unlocked=gt.Custom7,t.DelayedFocused=gt.Custom8,t.TouchInput=gt.Custom12}(Mt||(Mt={}));class yt{get angle(){return this._adapter.angle}get scale(){return this._adapter.scale}set location(t){this._ringManipulator.location=t}set elevationAlignedLocation(t){this._ringManipulator.elevationAlignedLocation=t}get grabbing(){return this._ringManipulator.grabbing}set interactive(t){this._ringManipulator.interactive=t}constructor({adapter:t,tooltipOptions:e,mode:o,tool:s}){this._mode=null,this._handles=new i,this._scaleRotateDragData=null,this._activeAnimation=null,this._ringIndicatorDelayMs=V,this.events=new a,this.getFocused=()=>this._ringManipulator.focused,this.getScale=()=>"scale"===this._scaleRotateDragData?.mode?this._adapter.scale:1,this.tool=s,this._mode=o,this._adapter=t,this._tooltipOptions=e,this._tooltip=new _t({view:s.view}),this._createManipulator(),this._updateDragState(),this._updateManipulatorTransform(),this._handles.add(c((()=>!this._tooltipOptions.enabled),(()=>this._tooltip.clear()),h))}destroy(){this._activeAnimation?.frameTask.remove(),this._activeAnimation=null,this._handles=n(this._handles),this.tool.manipulators.remove(this._ringManipulator),this._ringManipulator=null,this._tooltip=n(this._tooltip)}startAnimation(t){this.cancelActiveAnimation(),t.start();const e=d({update:({deltaTime:e})=>{t.update(e)&&this.cancelActiveAnimation()}});this._activeAnimation={...t,frameTask:e}}cancelActiveAnimation(){this._activeAnimation?.frameTask.remove(),this._activeAnimation=n(this._activeAnimation)}forEachManipulator(t){t(this._ringManipulator,N.SCALE_ROTATE)}_createManipulator(){const t=this._createRingManipulator();this._ringManipulator=t,this.tool.manipulators.add(t);const a=this.tool.graphicState.graphic,i=ut(t,((t,i,n)=>{this._scaleRotateDragData=null;const r=this._adapter.startInteraction(),l={mode:"none",origin:R(t.renderLocation),initialAngle:this._adapter.angle,angle:0,angleDir:0,scaleDir:0};this._scaleRotateDragData=l,this._updateDragState();const c=P.get();this.tool.view.renderCoordsHelper.worldUpAtPosition(t.renderLocation,c),i.next(x(this.tool.view,O(t.renderLocation,c,I()))).next((t=>{const i=k(t.plane),n=L(t.renderStart,t.renderEnd,l.origin,i),c=e.shortestSignedDiff(l.angle,n);l.angleDir=o(l.angleDir+c,-q,q),l.angle=n;const h=wt(l,t),p=h-this._adapter.scale;if(l.scaleDir=o(l.scaleDir+p,-B,B),this._onScaleChanged(),"none"===l.mode){const e=this._mode||bt(t,t.plane,l.origin,this.tool.view.state.camera);if(null!=e){switch(e){case"rotate":this.tool.emit("graphic-rotate-start",{graphic:a,angle:0}),this.tool.emit("record-undo",{record:this._adapter.createUndoRecord()});break;case"scale":this.tool.emit("graphic-scale-start",{graphic:a,xScale:1,yScale:1}),this.tool.emit("record-undo",{record:this._adapter.createUndoRecord()})}l.mode=e}}switch(l.mode){case"rotate":r.state.angle=l.initialAngle+n;break;case"scale":r.state.scale=h,this._onScaleChanged()}switch(this._updateDragState(),this._updateManipulatorTransform(),t.action){case"start":case"update":switch(l.mode){case"rotate":this.tool.emit("graphic-rotate",{graphic:a,angle:s(l.angle)});break;case"scale":this.tool.emit("graphic-scale",{graphic:a,xScale:h,yScale:h})}break;case"end":switch(l.mode){case"rotate":this.tool.emit("graphic-rotate-stop",{graphic:a,angle:s(l.angle)});break;case"scale":this.tool.emit("graphic-scale-stop",{graphic:a,xScale:h,yScale:h})}}return"end"===t.action&&(this.startAnimation(Rt(this,(()=>this._onScaleChanged()))),this._scaleRotateDragData=null,this._updateDragState(),r.done()),t})).next(this._updateTooltipPipelineStep(l)),n.next((()=>{if(r.cancel(),null!=this._scaleRotateDragData){switch(this._scaleRotateDragData.mode){case"none":break;case"rotate":this.tool.emit("graphic-rotate-stop",{graphic:a,angle:0});break;case"scale":this.tool.emit("graphic-scale-stop",{graphic:a,xScale:1,yScale:1})}this.startAnimation(Rt(this,(()=>this._onScaleChanged()))),this._scaleRotateDragData=null,this._updateDragState()}this._updateFocusTooltip()}))}));this._handles.add([i,t.events.on("focus-changed",(t=>{"focus"===t.action?this.startAnimation(jt(this,(()=>this._updateDelayedFocusedState()),{delayMs:this._ringIndicatorDelayMs})):this._updateDelayedFocusedState()})),t.events.on("immediate-click",(t=>{t.stopPropagation()})),p((()=>this.tool.graphicState?.displaying),(t=>this._ringManipulator.available=t),h)])}_updateTooltipPipelineStep(t){return e=>{const a=this._tooltipOptions;if(!a.enabled)return e;if("end"===e.action)return this._updateFocusTooltip(),e;const i=this._tooltip,o=this._tooltipOptions.visualVariables;switch(t.mode){case"scale":{const{size:t,scale:e}=this._adapter,s=o?.size;i.info=new Dt({tooltipOptions:a,scale:{value:e},size:null!=t?l(t,"meters"):void 0,sizePrecision:Ot(s?.valueType),sizeUnit:s?.unit});break}case"rotate":{const{orientationClockwise:t,relativeAngleClockwise:e}=this._adapter,s=o?.rotation,n=Ot(s?.valueType);i.info=new ft({tooltipOptions:a,rotation:null!=e?r(e,"radians","geographic"):void 0,rotationPrecision:n,rotationType:s?.rotationType??"geographic",orientation:null!=t?r(t,"radians","geographic"):void 0,orientationPrecision:n})}}return e}}_updateFocusTooltip(){if(!this._tooltipOptions.enabled)return;if(this.getFocused()){const t=this._tooltipOptions.visualVariables,e=t?.rotation,a=t?.size,i=this._mode,{size:o,orientationClockwise:s}=this._adapter,n=null!=s&&(null==i||"rotate"===i),c=null!=o&&(null==i||"scale"===i);this._tooltip.info=new St({tooltipOptions:this._tooltipOptions,orientation:n?r(s,"radians","geographic"):void 0,orientationPrecision:Ot(e?.valueType),rotationType:e?.rotationType??"geographic",size:c?l(o,"meters"):void 0,sizeUnit:a?.unit,sizePrecision:Ot(a?.valueType)})}else this._tooltip.clear()}_onScaleChanged(){this.events.emit("scale-changed"),this._updateManipulatorTransform()}_updateDelayedFocusedState(){this._ringManipulator.updateStateEnabled(Mt.DelayedFocused,this.getFocused()),this._updateFocusTooltip()}_updateDragState(){if(this._ringManipulator.updateStateEnabled(Mt.Unlocked,!(null!=this._scaleRotateDragData&&"none"!==this._scaleRotateDragData?.mode)),null!=this._scaleRotateDragData)switch(this._scaleRotateDragData.mode){case"rotate":this._ringManipulator.updateStateEnabled(Mt.ScaleIn|Mt.ScaleOut,!1),this._ringManipulator.updateStateEnabled(Mt.RotateLeft,this._scaleRotateDragData.angleDir<0),this._ringManipulator.updateStateEnabled(Mt.RotateRight,this._scaleRotateDragData.angleDir>=0);break;case"scale":this._ringManipulator.updateStateEnabled(Mt.RotateLeft|Mt.RotateRight,!1),this._ringManipulator.updateStateEnabled(Mt.ScaleIn,this._scaleRotateDragData.scaleDir<0),this._ringManipulator.updateStateEnabled(Mt.ScaleOut,this._scaleRotateDragData.scaleDir>=0)}else this._ringManipulator.updateStateEnabled(Mt.ScaleIn|Mt.ScaleOut|Mt.RotateLeft|Mt.RotateRight,!1)}_updateManipulatorTransform(){const t=g(C.get(),this._adapter.angle,j(0,0,1));if(null==t)return;const e=this.getScale(),a=m(C.get(),M(P.get(),e,e,e));this._ringManipulator.modelTransform=_(C.get(),a,t)}_createRingManipulator(){const t=(t,e,a)=>{const i=[],o=Math.ceil(it*(e-t)/(2*Math.PI));for(let s=0;s<o+1;s++){const n=t+s*(e-t)/o;i.push(j(a*Math.cos(n),a*Math.sin(n),0))}return i},e=e=>t(0,2*Math.PI,e),a=t=>[[-t/2,0],[t/2,0],[t/2,Y/2],[-t/2,Y/2]],i=this._createMaterial(1),o=(t,e,o=i)=>ht(o,a(e),t,[],[],!1),s=e(Q),n=o(s,J),r={left:new Array,right:new Array},l=[];for(let R=0;R<2;R++){const e=R*Math.PI-Math.PI/4,a=Math.PI/2-ot,s=e+a,n=e+Math.PI/2-a,c=t(s,n,W),h=o(c,at);l.push(c),l.push(t(s,n,X-J/2)),r.left.push(h),r.right.push(h.instantiate());for(let t=0;t<2;t++){const e=0===t,a=S();if(e){f(a,a,[1,-1,1]),D(a,a,-s,[0,0,1]);const t=Math.round(G*(c.length-1));a[12]=c[t][0],a[13]=c[t][1],a[14]=c[t][2]}else{D(a,a,n,[0,0,1]);const t=Math.round((1-G)*(c.length-1));a[12]=c[t][0],a[13]=c[t][1],a[14]=c[t][2]}const o=lt(i,$,0,Z,Y);ct(o,a),(e?r.left:r.right).push(o)}}const c=[];for(let f=0;f<2;f++){const e=f*Math.PI-Math.PI/4,a=Math.PI/2-nt,i=e+a,s=e+Math.PI/2-a,n=t(i,s,X);c.push(o(n,at))}const h=this._createMaterial(.66),p=this._createMaterial(.5),d=this._createMaterial(.33),u=e(Q+tt),g=e(Q+et),m=o(u,at,h),_=o(g,at,d),M=e(Q-tt),v=e(Q-et),y=o(M,at,h),w=o(v,at,d);let b=[new z(n,Mt.DelayedFocused),new z(n.instantiate({material:p}),mt.None)];this._mode&&"scale"!==this._mode||(b=b.concat([...c.map((t=>new z(t,Mt.DelayedFocused|Mt.Unlocked))),new z(m,Mt.DelayedFocused|Mt.ScaleIn),new z(_,Mt.DelayedFocused|Mt.ScaleIn),new z(y,Mt.DelayedFocused|Mt.ScaleOut),new z(w,Mt.DelayedFocused|Mt.ScaleOut)])),this._mode&&"rotate"!==this._mode||(b=b.concat([...r.right.map((t=>new z(t.instantiate(),Mt.DelayedFocused|Mt.Unlocked))),...r.left.map((t=>new z(t,Mt.DelayedFocused|Mt.RotateLeft))),...r.right.map((t=>new z(t,Mt.DelayedFocused|Mt.RotateRight)))]));const T=[s,...l];return new U({view:this.tool.view,renderObjects:b,autoScaleRenderObjects:!1,worldOriented:!0,radius:J,focusMultiplier:1,touchMultiplier:1.5,elevationInfo:E(this.tool.graphicState.graphic),collisionType:{type:"ribbon",paths:T,direction:j(0,0,1)}})}_createMaterial(e){const a=H(this.tool.view.effectiveTheme).colors.accent.clone();return a.a=e,new dt({color:t(a),transparent:1!==e,cullFace:rt.Back,renderOccluded:pt.Transparent,isDecoration:!0})}get test(){return{ringManipulator:this._ringManipulator,setRingIndicatorDelayMs:t=>this._ringIndicatorDelayMs=t,tooltip:this._tooltip}}}function wt(t,e){const a=v(P.get(),e.renderStart,t.origin),i=v(P.get(),e.renderEnd,t.origin),o=y(a),s=y(i);return 0===o?0:s/o}function bt(t,e,a,i){const{renderStart:o,renderEnd:s}=t,n=Tt(o,i,P.get()),r=Tt(s,i,P.get());if(w(n,r)<K*K)return null;const l=v(P.get(),o,a),c=b(P.get(),l,k(e)),h=o,p=T(P.get(),h,c),d=Tt(a,i,P.get()),u=n,g=Tt(p,i,P.get()),m=v(P.get(),g,u),_=v(P.get(),n,d),f=A(u,m),D=A(d,_);return F(f,r)<F(D,r)?"rotate":"scale"}function Tt(t,e,a){return e.projectToScreen(t,It),M(a,It[0],It[1],0)}function Rt(t,e){let a=null,i=1;const o=()=>i;return{start:()=>{i=t.getScale(),a=t.getScale,t.getScale=o,e()},update:t=>(i+=((i+1)/2-i)*Math.min(t*st,1),e(),Math.abs(i-1)<.01?vt.STOP:vt.CONTINUE),destroy:()=>{a&&(t.getScale=a),e()}}}function jt(t,e,a){let i=0,o=null;const s=()=>!1;return{start:()=>{o=t.getFocused,t.getFocused=s,i=0,e()},update:t=>(i+=t,!o?.()||i>=a.delayMs?vt.STOP:vt.CONTINUE),destroy:()=>{o&&(t.getFocused=o),e()}}}function Ot(t){switch(t){case"integer":case"long":return 0;default:return null}}!function(t){t[t.CONTINUE=0]="CONTINUE",t[t.STOP=1]="STOP"}(vt||(vt={}));const It=u();export{yt as GraphicScaleRotateTransform};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../../../Color.js";import{getAccentColor as e,getContrastColor as i,getOpacity as s}from"../../../../../core/analysisThemeUtils.js";import a from"../../../../../core/Handles.js";import{clone as n}from"../../../../../core/lang.js";import{destroyMaybe as l}from"../../../../../core/maybe.js";import{watch as r,sync as o}from"../../../../../core/reactiveUtils.js";import{screenPointObjectToArray as h}from"../../../../../core/screenUtils.js";import{c as u}from"../../../../../chunks/vec3f64.js";import{createSphereManipulator as d}from"../../manipulatorUtils.js";import{PickResult as _}from"../support/PickRequest.js";import{LaserlineVisualElement as p}from"../../visualElements/LaserlineVisualElement.js";import{newIntersector as c}from"../../../webgl-engine/lib/Intersector.js";import{StoreResults as g}from"../../../webgl-engine/lib/IntersectorInterfaces.js";import{ManipulatorCollection as m}from"../../../../interactive/ManipulatorCollection.js";class w{constructor(a){this.vertexManipulators=[],this._destroyed=!1,this._isManipulatorsOwner=!0,this._visible=!0,this._laserLine=null,this._cursorManipulator=null,this._listenerHandles=null,this._tempHandlePosition=u(),this._defaultStyle={laserLineGlowColor:t.toUnitRGB(e(.75)),laserLineGlowWidth:8,laserLineGlowFalloff:8,laserLineInnerColor:t.toUnitRGB(i(.75)),laserLineInnerWidth:1,laserLineGlobalAlpha:s(.75),laserLineEnabled:!0,handleColor:t.toUnitRGBA(e(.5)),handleRadius:5,handleRadiusHovered:10,handleRadiusMouse:10,handleRadiusTouch:25};const{analysisViewData:l,manipulators:r,toolState:o,view:h,visible:_}=a;this._analysisViewData=l,this._toolState=o,null!=r?(this._manipulators=r,this._isManipulatorsOwner=!1):this._manipulators=new m,this._view=h;const w=this._style={...this._defaultStyle,...n(a.style)};this._intersector=c(h.state.viewingMode),this._intersector.options.store=g.MIN;const y=d(h,w.handleColor);y.available=!1,y.radius=w.handleRadius,y.interactive=!1,this._manipulators.add(y),this._cursorManipulator=y,this._laserLine=new p({view:h,attached:!0,style:{glowColor:w.laserLineGlowColor,glowWidth:w.laserLineGlowWidth,glowFalloff:w.laserLineGlowFalloff,innerColor:w.laserLineInnerColor,innerWidth:w.laserLineInnerWidth,globalAlpha:w.laserLineGlobalAlpha},isDecoration:!0}),this._updateVisibility(_||!0)}destroy(){this._listenerHandles=l(this._listenerHandles),this._isManipulatorsOwner?this._manipulators=l(this._manipulators):this._manipulators=null,this._laserLine=l(this._laserLine),this._destroyed=!0}get destroyed(){return this._destroyed}get visible(){return this._visible}set visible(t){t?this.show():this.hide()}get testData(){const t=this._laserLine.testData;return{laserLineRenderer:null!=t?{heightManifoldEnabled:t.heightManifoldEnabled,heightManifoldTarget:t.heightManifoldTarget,pointDistanceEnabled:t.pointDistanceEnabled,pointDistanceOrigin:t.pointDistanceOrigin,pointDistanceTarget:t.pointDistanceTarget,lineVerticalPlaneEnabled:t.lineVerticalPlaneEnabled}:{heightManifoldEnabled:!1,heightManifoldTarget:null,pointDistanceEnabled:!1,pointDistanceOrigin:null,pointDistanceTarget:null,lineVerticalPlaneEnabled:!1}}}show(){this._setVisibility(!0)}hide(){this._setVisibility(!1)}_setVisibility(t){this._destroyed||this._visible===t||this._updateVisibility(t)}_updateVisibility(t){this._visible=t,this._laserLine.visible=t,t?(this._initializeListeners(),this._updateAll()):(this._destroyListeners(),this.vertexManipulators.forEach((t=>this._removeVertexManipulator(t))),this.vertexManipulators=[],this._view.cursor=null)}vertexHandleAt(t,e){const i=this._manipulators.intersect(t,e);return null!=i?i.metadata:null}pick(t){const e=this._view.spatialReference,i=h(t.screenPoint);this._view.sceneIntersectionHelper.intersectToolIntersectorScreen(i,this._intersector);const s=this._intersector.results.min,a=u();if(!s.getIntersectionPoint(a))return null;const n=this._view.renderCoordsHelper.fromRenderCoords(a,e);return null==n?null:new _(a,n)}_updateAll(){this._visible&&(this._updateVertexManipulators(),this._updateLaserLine())}_createVertexManipulator(){const t=d(this._view,this._style.handleColor);return t.radius=this._style.handleRadius,this._manipulators.add(t),t}_removeVertexManipulator(t){this._manipulators.remove(t)}_updateVertexManipulators(){const{viewData:t}=this._analysisViewData,e=this._analysisViewData.path?this._analysisViewData.path.vertices:[],i=this.vertexManipulators;y(i,e.length,(()=>this._createVertexManipulator()),(t=>this._removeVertexManipulator(t))),i.forEach(((i,s)=>{i.metadata=e[s],i.renderLocation=t.positionsRenderCoords[s],i.cursor=0===s&&"drawing"===this._toolState.polygonState?"crosshair":null})),"drawing"===this._toolState.polygonState&&null!=this._analysisViewData.cursorPoint?(this._cursorManipulator.available=!0,this._cursorManipulator.location=this._analysisViewData.cursorPoint):this._cursorManipulator.available=!1}_getFocusPoint(){const{lastDraggedVertex:t}=this._analysisViewData;switch(this._toolState.polygonState){case"drawing":return null!=this._analysisViewData.cursorPoint?this._analysisViewData.cursorPoint:null!=t?this._analysisViewData.path.getVertexPositionAsPoint(t):this._analysisViewData.path.lastPoint;case"editing":return null!=t?this._analysisViewData.path.getVertexPositionAsPoint(t):null;default:return this._analysisViewData.cursorPoint}}_updateLaserLine(){const t=this._style.laserLineEnabled&&"measured"!==this._toolState.polygonState&&this._toolState.active,e=this._getFocusPoint();if(t&&null!=e){const t=this._tempHandlePosition;this._view.renderCoordsHelper.toRenderCoords(e,t),this._laserLine.heightManifoldTarget=t}else this._laserLine.heightManifoldTarget=null}_initializeListeners(){this._listenerHandles=new a,this._listenerHandles.add([r((()=>this._toolState.polygonState),(()=>this._updateLaserLine())),r((()=>this._analysisViewData.viewData),(()=>this._updateAll()),o),r((()=>({lastDraggedVertex:this._analysisViewData.lastDraggedVertex,cursorPoint:this._analysisViewData.cursorPoint})),(()=>this._updateLaserLine())),r((()=>this._toolState.active),(()=>this._updateAll()))])}_destroyListeners(){this._listenerHandles=l(this._listenerHandles)}}function y(t,e,i,s){for(;t.length<e;)t.push(i());if(s)for(;t.length>e;){s(t.pop())}else t.length=e}export{w as default};
5
+ import t from"../../../../../Color.js";import{multiplyOpacity as e,getContrast as i}from"../../../../../core/colorUtils.js";import s from"../../../../../core/Handles.js";import{clone as a}from"../../../../../core/lang.js";import{destroyMaybe as n}from"../../../../../core/maybe.js";import{watch as l,sync as r}from"../../../../../core/reactiveUtils.js";import{screenPointObjectToArray as o}from"../../../../../core/screenUtils.js";import{c as h}from"../../../../../chunks/vec3f64.js";import{createSphereManipulator as u}from"../../manipulatorUtils.js";import{PickResult as d}from"../support/PickRequest.js";import{LaserlineVisualElement as _}from"../../visualElements/LaserlineVisualElement.js";import{newIntersector as c}from"../../../webgl-engine/lib/Intersector.js";import{StoreResults as p}from"../../../webgl-engine/lib/IntersectorInterfaces.js";import{ManipulatorCollection as g}from"../../../../interactive/ManipulatorCollection.js";class m{constructor(s){this.vertexManipulators=[],this._destroyed=!1,this._isManipulatorsOwner=!0,this._visible=!0,this._laserLine=null,this._cursorManipulator=null,this._listenerHandles=null,this._tempHandlePosition=h();const{analysisViewData:n,manipulators:l,toolState:r,view:o,visible:d}=s;this._analysisViewData=n,this._toolState=r,null!=l?(this._manipulators=l,this._isManipulatorsOwner=!1):this._manipulators=new g,this._view=o;const{effectiveTheme:m}=o,w={laserLineGlowColor:t.toUnitRGB(e(m.accentColor,.75)),laserLineGlowWidth:8,laserLineGlowFalloff:8,laserLineInnerColor:t.toUnitRGB(e(i(m.accentColor),.75)),laserLineInnerWidth:1,laserLineGlobalAlpha:.75*m.accentColor.a,laserLineEnabled:!0,handleColor:t.toUnitRGBA(e(m.accentColor,.5)),handleRadius:5,handleRadiusHovered:10,handleRadiusMouse:10,handleRadiusTouch:25},f=this._style={...w,...a(s.style)};this._intersector=c(o.state.viewingMode),this._intersector.options.store=p.MIN;const v=u(o,f.handleColor);v.available=!1,v.radius=f.handleRadius,v.interactive=!1,this._manipulators.add(v),this._cursorManipulator=v,this._laserLine=new _({view:o,attached:!0,style:{glowColor:f.laserLineGlowColor,glowWidth:f.laserLineGlowWidth,glowFalloff:f.laserLineGlowFalloff,innerColor:f.laserLineInnerColor,innerWidth:f.laserLineInnerWidth,globalAlpha:f.laserLineGlobalAlpha},isDecoration:!0}),this._updateVisibility(d||!0)}destroy(){this._listenerHandles=n(this._listenerHandles),this._isManipulatorsOwner?this._manipulators=n(this._manipulators):this._manipulators=null,this._laserLine=n(this._laserLine),this._destroyed=!0}get destroyed(){return this._destroyed}get visible(){return this._visible}set visible(t){t?this.show():this.hide()}get testData(){const t=this._laserLine.testData;return{laserLineRenderer:null!=t?{heightManifoldEnabled:t.heightManifoldEnabled,heightManifoldTarget:t.heightManifoldTarget,pointDistanceEnabled:t.pointDistanceEnabled,pointDistanceOrigin:t.pointDistanceOrigin,pointDistanceTarget:t.pointDistanceTarget,lineVerticalPlaneEnabled:t.lineVerticalPlaneEnabled}:{heightManifoldEnabled:!1,heightManifoldTarget:null,pointDistanceEnabled:!1,pointDistanceOrigin:null,pointDistanceTarget:null,lineVerticalPlaneEnabled:!1}}}show(){this._setVisibility(!0)}hide(){this._setVisibility(!1)}_setVisibility(t){this._destroyed||this._visible===t||this._updateVisibility(t)}_updateVisibility(t){this._visible=t,this._laserLine.visible=t,t?(this._initializeListeners(),this._updateAll()):(this._destroyListeners(),this.vertexManipulators.forEach((t=>this._removeVertexManipulator(t))),this.vertexManipulators=[],this._view.cursor=null)}vertexHandleAt(t,e){const i=this._manipulators.intersect(t,e);return null!=i?i.metadata:null}pick(t){const e=this._view.spatialReference,i=o(t.screenPoint);this._view.sceneIntersectionHelper.intersectToolIntersectorScreen(i,this._intersector);const s=this._intersector.results.min,a=h();if(!s.getIntersectionPoint(a))return null;const n=this._view.renderCoordsHelper.fromRenderCoords(a,e);return null==n?null:new d(a,n)}_updateAll(){this._visible&&(this._updateVertexManipulators(),this._updateLaserLine())}_createVertexManipulator(){const t=u(this._view,this._style.handleColor);return t.radius=this._style.handleRadius,this._manipulators.add(t),t}_removeVertexManipulator(t){this._manipulators.remove(t)}_updateVertexManipulators(){const{viewData:t}=this._analysisViewData,e=this._analysisViewData.path?this._analysisViewData.path.vertices:[],i=this.vertexManipulators;w(i,e.length,(()=>this._createVertexManipulator()),(t=>this._removeVertexManipulator(t))),i.forEach(((i,s)=>{i.metadata=e[s],i.renderLocation=t.positionsRenderCoords[s],i.cursor=0===s&&"drawing"===this._toolState.polygonState?"crosshair":null})),"drawing"===this._toolState.polygonState&&null!=this._analysisViewData.cursorPoint?(this._cursorManipulator.available=!0,this._cursorManipulator.location=this._analysisViewData.cursorPoint):this._cursorManipulator.available=!1}_getFocusPoint(){const{lastDraggedVertex:t}=this._analysisViewData;switch(this._toolState.polygonState){case"drawing":return null!=this._analysisViewData.cursorPoint?this._analysisViewData.cursorPoint:null!=t?this._analysisViewData.path.getVertexPositionAsPoint(t):this._analysisViewData.path.lastPoint;case"editing":return null!=t?this._analysisViewData.path.getVertexPositionAsPoint(t):null;default:return this._analysisViewData.cursorPoint}}_updateLaserLine(){const t=this._style.laserLineEnabled&&"measured"!==this._toolState.polygonState&&this._toolState.active,e=this._getFocusPoint();if(t&&null!=e){const t=this._tempHandlePosition;this._view.renderCoordsHelper.toRenderCoords(e,t),this._laserLine.heightManifoldTarget=t}else this._laserLine.heightManifoldTarget=null}_initializeListeners(){this._listenerHandles=new s,this._listenerHandles.add([l((()=>this._toolState.polygonState),(()=>this._updateLaserLine())),l((()=>this._analysisViewData.viewData),(()=>this._updateAll()),r),l((()=>({lastDraggedVertex:this._analysisViewData.lastDraggedVertex,cursorPoint:this._analysisViewData.cursorPoint})),(()=>this._updateLaserLine())),l((()=>this._toolState.active),(()=>this._updateAll()))])}_destroyListeners(){this._listenerHandles=n(this._listenerHandles)}}function w(t,e,i,s){for(;t.length<e;)t.push(i());if(s)for(;t.length>e;){s(t.pop())}else t.length=e}export{m 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.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as i}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../Color.js";import e from"../../../../../core/Accessor.js";import{getAccentColor as s,getContrastColor as n,getOpacity as a}from"../../../../../core/analysisThemeUtils.js";import{destroyMaybe as o}from"../../../../../core/maybe.js";import{watch as r,initial as l}from"../../../../../core/reactiveUtils.js";import{property as d}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{c}from"../../../../../chunks/vec3f64.js";import{fromPoints as p}from"../../../../../geometry/support/lineSegment.js";import{MeasurementMode as u}from"../../../analysis/interfaces.js";import{ViewMode as g}from"../../../analysis/DirectLineMeasurement/interfaces.js";import{Manipulator3D as m}from"../../Manipulator3D.js";import{createSphereManipulator as y}from"../../manipulatorUtils.js";import{LaserlineVisualElement as _}from"../../visualElements/LaserlineVisualElement.js";var v;!function(i){i.Manipulators="manipulators",i.AnalysisViewDestroyed="analysis-view-destroyed",i.AnalysisView="analysis-view"}(v||(v={}));let b=class extends e{constructor(i){super(i),this._params={laserLineGlowColor:t.toUnitRGB(s(.75)),laserLineGlowWidth:8,laserLineGlowFalloff:8,laserLineInnerColor:t.toUnitRGB(n(.75)),laserLineInnerWidth:.75,laserLineGlobalAlpha:a(.75),handleColor:t.toUnitRGBA(s(.5)),handleRadius:5},this.cursorPoint=null,this._visible=!1,this._laserLine=null,this.laserLineEnabled=!0,this._lastDraggedHandle=null}initialize(){this._laserLine=new _({view:this.view,attached:!0,isDecoration:!0}),this._updateVisibility(this._visible),this._connectToAnalysisView()}destroy(){this._laserLine=o(this._laserLine)}get visible(){return this._visible}set visible(i){i?this.show():this.hide()}get testData(){const i=this._laserLine.testData,t=this.analysisViewData.testData;return{labels:t?.labels,stripeLength:t?.stripeLength,laserLineRenderer:{heightManifoldEnabled:null!=i&&i.heightManifoldEnabled,heightManifoldTarget:null!=i?i.heightManifoldTarget:null,pointDistanceEnabled:null!=i&&i.pointDistanceEnabled,pointDistanceOrigin:null!=i?i.pointDistanceOrigin:null,pointDistanceTarget:null!=i?i.pointDistanceTarget:null,lineVerticalPlaneEnabled:null!=i&&i.lineVerticalPlaneEnabled}}}get _cursorPosition(){const i=c(),t=this.cursorPoint;return t&&this.view.renderCoordsHelper.toRenderCoords(t,i),i}get _startPosition(){const i=c(),t=this.analysis.startPoint;return t&&this.view.renderCoordsHelper.toRenderCoords(t,i),i}get _endPosition(){const i=c(),t=this.analysis.endPoint;return t&&this.view.renderCoordsHelper.toRenderCoords(t,i),i}get _laserLineParams(){const i=this._focusPosition,{active:t,lineState:e}=this.toolState,s=this.analysisViewData,n=this.laserLineEnabled&&!!i&&"measured"!==e&&t;if(!n||!this.visible||null==s||s.destroyed)return{heightManifoldTarget:null,pointDistanceLine:null,lineVerticalPlaneSegment:null};const a=s.actualVisualizedMeasurement,o="local"!==this.view.viewingMode&&n&&!!this.analysis.startPoint&&"geodesic"===a,r=n&&s.viewMode===g.Triangle;return{heightManifoldTarget:"euclidean"===a?i:null,pointDistanceLine:o?this._pointDistanceLine:null,lineVerticalPlaneSegment:r?p(this._startPosition,this._endPosition):null}}get _focusPosition(){const{lineState:i}=this.toolState,t=this.analysisViewData,e=null!=t&&!t.destroyed&&t.measurementMode===u.Euclidean&&t.viewMode===g.Direct;switch(i){case"drawing":return e?this._startPosition:this.analysis.endPoint?this._endPosition:this._startPosition;case"editing":return e?"start"===this._lastDraggedHandle?this._endPosition:this._startPosition:"start"===this._lastDraggedHandle?this._startPosition:this._endPosition;default:return null!=this.cursorPoint?this._cursorPosition:null}}get _pointDistanceLine(){return{origin:"drawing"===this.toolState.lineState||"end"===this._lastDraggedHandle?this._startPosition:this._endPosition,target:this._focusPosition}}createManipulators(){const i=()=>{const i=y(this.view,this._params.handleColor);return i.available=!1,i.radius=this._params.handleRadius,i},t=i(),e=i(),s=new m({view:this.view});s.available=!1,s.interactive=!1,null!=this.analysis.startPoint&&(t.location=this.analysis.startPoint,t.available=!0),null!=this.analysis.endPoint&&(e.location=this.analysis.endPoint,e.available=!0);const n=()=>{let i=this._lastDraggedHandle;t.grabbing&&!e.grabbing&&(i="start"),e.grabbing&&!t.grabbing&&(i="end"),t.grabbing||e.grabbing||(i=null),this._lastDraggedHandle=i},a=t.events.on("grab-changed",n),o=e.events.on("grab-changed",n);return this.addHandles([a,o],v.Manipulators),{start:t,end:e,cursor:s}}show(){this.destroyed||this._visible||this._updateVisibility(!0)}hide(){!this.destroyed&&this._visible&&this._updateVisibility(!1)}_connectToAnalysisView(){this.removeHandles(v.AnalysisView),this.addHandles([r((()=>this.analysisViewData?.destroyed),(i=>{i&&this.removeHandles(v.AnalysisView)}),l),r((()=>["measured"===this.toolState.lineState,this.analysisViewData]),(([i,t])=>{null==t||t.destroyed||(t.allowVisualElementsOrientationChange=!i)}),l),r((()=>this._laserLineParams),(i=>{const t=this._laserLine;t.heightManifoldTarget=i.heightManifoldTarget,t.pointDistanceLine=i.pointDistanceLine,t.lineVerticalPlaneSegment=i.lineVerticalPlaneSegment}),l)],v.AnalysisView)}_updateVisibility(i){this.initialized&&(this._visible=i,i?this._laserLine.style={innerColor:this._params.laserLineInnerColor,innerWidth:this._params.laserLineInnerWidth,glowColor:this._params.laserLineGlowColor,glowWidth:this._params.laserLineGlowWidth,glowFalloff:this._params.laserLineGlowFalloff,globalAlpha:this._params.laserLineGlobalAlpha}:this.view.cursor=null,this._laserLine.visible=i)}};i([d({constructOnly:!0})],b.prototype,"view",void 0),i([d()],b.prototype,"_params",void 0),i([d({constructOnly:!0})],b.prototype,"analysis",void 0),i([d({constructOnly:!0})],b.prototype,"analysisViewData",void 0),i([d()],b.prototype,"cursorPoint",void 0),i([d()],b.prototype,"toolState",void 0),i([d()],b.prototype,"visible",null),i([d()],b.prototype,"testData",null),i([d()],b.prototype,"_visible",void 0),i([d()],b.prototype,"_laserLine",void 0),i([d({constructOnly:!0})],b.prototype,"laserLineEnabled",void 0),i([d()],b.prototype,"_cursorPosition",null),i([d()],b.prototype,"_startPosition",null),i([d()],b.prototype,"_endPosition",null),i([d()],b.prototype,"_lastDraggedHandle",void 0),i([d()],b.prototype,"_laserLineParams",null),i([d()],b.prototype,"_focusPosition",null),i([d()],b.prototype,"_pointDistanceLine",null),b=i([h("esri.views.3d.interactive.measurementTools.directLineMeasurement3D.DirectLineMeasurement3DView")],b);export{b as DirectLineMeasurement3DView};
5
+ import{_ as e}from"../../../../../chunks/tslib.es6.js";import t from"../../../../../Color.js";import i from"../../../../../core/Accessor.js";import{multiplyOpacity as s,getContrast as n}from"../../../../../core/colorUtils.js";import{destroyMaybe as a}from"../../../../../core/maybe.js";import{watch as o,initial as r}from"../../../../../core/reactiveUtils.js";import{property as l}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{c as d}from"../../../../../chunks/vec3f64.js";import{fromPoints as c}from"../../../../../geometry/support/lineSegment.js";import{MeasurementMode as p}from"../../../analysis/interfaces.js";import{ViewMode as u}from"../../../analysis/DirectLineMeasurement/interfaces.js";import{Manipulator3D as g}from"../../Manipulator3D.js";import{createSphereManipulator as m}from"../../manipulatorUtils.js";import{LaserlineVisualElement as _}from"../../visualElements/LaserlineVisualElement.js";var y;!function(e){e.Manipulators="manipulators",e.AnalysisViewDestroyed="analysis-view-destroyed",e.AnalysisView="analysis-view"}(y||(y={}));let v=class extends i{constructor(e){super(e),this.cursorPoint=null,this._visible=!1,this._laserLine=null,this.laserLineEnabled=!0,this._lastDraggedHandle=null}initialize(){this._laserLine=new _({view:this.view,attached:!0,isDecoration:!0}),this._updateVisibility(this._visible),this._connectToAnalysisView()}destroy(){this._laserLine=a(this._laserLine)}get _params(){return{laserLineGlowColor:t.toUnitRGB(s(this.view.effectiveTheme.accentColor,.75)),laserLineGlowWidth:8,laserLineGlowFalloff:8,laserLineInnerColor:t.toUnitRGB(s(n(this.view.effectiveTheme.accentColor),.75)),laserLineInnerWidth:.75,laserLineGlobalAlpha:.75*this.view.effectiveTheme.accentColor.a,handleColor:t.toUnitRGBA(s(this.view.effectiveTheme.accentColor,.5)),handleRadius:5}}get visible(){return this._visible}set visible(e){e?this.show():this.hide()}get testData(){const e=this._laserLine.testData,t=this.analysisViewData.testData;return{labels:t?.labels,stripeLength:t?.stripeLength,laserLineRenderer:{heightManifoldEnabled:null!=e&&e.heightManifoldEnabled,heightManifoldTarget:null!=e?e.heightManifoldTarget:null,pointDistanceEnabled:null!=e&&e.pointDistanceEnabled,pointDistanceOrigin:null!=e?e.pointDistanceOrigin:null,pointDistanceTarget:null!=e?e.pointDistanceTarget:null,lineVerticalPlaneEnabled:null!=e&&e.lineVerticalPlaneEnabled}}}get _cursorPosition(){const e=d(),t=this.cursorPoint;return t&&this.view.renderCoordsHelper.toRenderCoords(t,e),e}get _startPosition(){const e=d(),t=this.analysis.startPoint;return t&&this.view.renderCoordsHelper.toRenderCoords(t,e),e}get _endPosition(){const e=d(),t=this.analysis.endPoint;return t&&this.view.renderCoordsHelper.toRenderCoords(t,e),e}get _laserLineParams(){const e=this._focusPosition,{active:t,lineState:i}=this.toolState,s=this.analysisViewData,n=this.laserLineEnabled&&!!e&&"measured"!==i&&t;if(!n||!this.visible||null==s||s.destroyed)return{heightManifoldTarget:null,pointDistanceLine:null,lineVerticalPlaneSegment:null};const a=s.actualVisualizedMeasurement,o="local"!==this.view.viewingMode&&n&&!!this.analysis.startPoint&&"geodesic"===a,r=n&&s.viewMode===u.Triangle;return{heightManifoldTarget:"euclidean"===a?e:null,pointDistanceLine:o?this._pointDistanceLine:null,lineVerticalPlaneSegment:r?c(this._startPosition,this._endPosition):null}}get _focusPosition(){const{lineState:e}=this.toolState,t=this.analysisViewData,i=null!=t&&!t.destroyed&&t.measurementMode===p.Euclidean&&t.viewMode===u.Direct;switch(e){case"drawing":return i?this._startPosition:this.analysis.endPoint?this._endPosition:this._startPosition;case"editing":return i?"start"===this._lastDraggedHandle?this._endPosition:this._startPosition:"start"===this._lastDraggedHandle?this._startPosition:this._endPosition;default:return null!=this.cursorPoint?this._cursorPosition:null}}get _pointDistanceLine(){return{origin:"drawing"===this.toolState.lineState||"end"===this._lastDraggedHandle?this._startPosition:this._endPosition,target:this._focusPosition}}createManipulators(){const e=()=>{const e=m(this.view,this._params.handleColor);return e.available=!1,e.radius=this._params.handleRadius,e},t=e(),i=e(),s=new g({view:this.view});s.available=!1,s.interactive=!1,null!=this.analysis.startPoint&&(t.location=this.analysis.startPoint,t.available=!0),null!=this.analysis.endPoint&&(i.location=this.analysis.endPoint,i.available=!0);const n=()=>{let e=this._lastDraggedHandle;t.grabbing&&!i.grabbing&&(e="start"),i.grabbing&&!t.grabbing&&(e="end"),t.grabbing||i.grabbing||(e=null),this._lastDraggedHandle=e},a=t.events.on("grab-changed",n),o=i.events.on("grab-changed",n);return this.addHandles([a,o],y.Manipulators),{start:t,end:i,cursor:s}}show(){this.destroyed||this._visible||this._updateVisibility(!0)}hide(){!this.destroyed&&this._visible&&this._updateVisibility(!1)}_connectToAnalysisView(){this.removeHandles(y.AnalysisView),this.addHandles([o((()=>this.analysisViewData?.destroyed),(e=>{e&&this.removeHandles(y.AnalysisView)}),r),o((()=>["measured"===this.toolState.lineState,this.analysisViewData]),(([e,t])=>{null==t||t.destroyed||(t.allowVisualElementsOrientationChange=!e)}),r),o((()=>this._laserLineParams),(e=>{const t=this._laserLine;t.heightManifoldTarget=e.heightManifoldTarget,t.pointDistanceLine=e.pointDistanceLine,t.lineVerticalPlaneSegment=e.lineVerticalPlaneSegment}),r)],y.AnalysisView)}_updateVisibility(e){this.initialized&&(this._visible=e,e?this._laserLine.style={innerColor:this._params.laserLineInnerColor,innerWidth:this._params.laserLineInnerWidth,glowColor:this._params.laserLineGlowColor,glowWidth:this._params.laserLineGlowWidth,glowFalloff:this._params.laserLineGlowFalloff,globalAlpha:this._params.laserLineGlobalAlpha}:this.view.cursor=null,this._laserLine.visible=e)}};e([l({constructOnly:!0})],v.prototype,"view",void 0),e([l()],v.prototype,"_params",null),e([l({constructOnly:!0})],v.prototype,"analysis",void 0),e([l({constructOnly:!0})],v.prototype,"analysisViewData",void 0),e([l()],v.prototype,"cursorPoint",void 0),e([l()],v.prototype,"toolState",void 0),e([l()],v.prototype,"visible",null),e([l()],v.prototype,"testData",null),e([l()],v.prototype,"_visible",void 0),e([l()],v.prototype,"_laserLine",void 0),e([l({constructOnly:!0})],v.prototype,"laserLineEnabled",void 0),e([l()],v.prototype,"_cursorPosition",null),e([l()],v.prototype,"_startPosition",null),e([l()],v.prototype,"_endPosition",null),e([l()],v.prototype,"_lastDraggedHandle",void 0),e([l()],v.prototype,"_laserLineParams",null),e([l()],v.prototype,"_focusPosition",null),e([l()],v.prototype,"_pointDistanceLine",null),v=e([h("esri.views.3d.interactive.measurementTools.directLineMeasurement3D.DirectLineMeasurement3DView")],v);export{v as DirectLineMeasurement3DView};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import{getAccentColor as r,getContrastColor as t}from"../../../../core/analysisThemeUtils.js";import s from"../../../../core/Handles.js";import{applyOpacity as i}from"../../../../core/mathUtils.js";import{destroyMaybe as o}from"../../../../core/maybe.js";import{watch as a}from"../../../../core/reactiveUtils.js";import{c as n}from"../../../../chunks/mat4f64.js";import{b as h}from"../../../../chunks/vec3.js";import{c as l}from"../../../../chunks/vec3f64.js";import{c as d}from"../../../../chunks/vec4f64.js";import{sv3d as c}from"../../../../geometry/support/vectorStacks.js";import{Object3DVisualElement as p}from"./Object3DVisualElement.js";import{createPolylineGeometry as m}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderOccludedFlag as _}from"../../webgl-engine/lib/Material.js";import{MeasurementArrowMaterial as w}from"../../webgl-engine/materials/MeasurementArrowMaterial.js";class g extends p{constructor(s){super(s),this._parameters={arrowWidth:16,arrowOutlineColor:e.toUnitRGBA(r()),arrowStripeEvenColor:e.toUnitRGBA(t()),arrowStripeOddColor:e.toUnitRGBA(r()),arrowSubdivisions:128},this._origin=l(),this._originTransform=n(),this._arrowCenter=l(),this._renderOccluded=_.OccludeAndTransparent,this._geometry=null,this._stripeLength=1,this._stripesEnabled=!0,this._opacity=1,this.applyProperties(s)}get renderOccluded(){return this._renderOccluded}set renderOccluded(e){e!==this._renderOccluded&&(this._renderOccluded=e,this._arrowMaterial&&this._arrowMaterial.setParameters({renderOccluded:e}))}get geometry(){return this._geometry}set geometry(e){this._geometry=e,this._geometryChanged()}get stripeLength(){return this._stripeLength}set stripeLength(e){this._stripeLength=e,this.attached&&this._arrowMaterial.setParameters({stripeLength:this._stripeLength})}get stripesEnabled(){return this._stripesEnabled}set stripesEnabled(e){if(this._stripesEnabled=e,this.attached){const e=this.opacity,{arrowStripeEvenColor:r,arrowStripeOddColor:t}=this._parameters,s=i(u,this._stripesEnabled?r:t,e);this._arrowMaterial.setParameters({stripeEvenColor:s})}}get opacity(){return this._opacity}set opacity(e){e!==this._opacity&&(this._opacity=e,this._updateArrowOpacity())}createExternalResources(){const{arrowStripeEvenColor:e,arrowStripeOddColor:r,arrowOutlineColor:t}=this._parameters,i=this._stripesEnabled?e:r;this._arrowMaterial=new w({outlineColor:t,stripeEvenColor:i,stripeOddColor:r,renderOccluded:this.renderOccluded,polygonOffset:!0,isDecoration:this.isDecoration}),this._handles=new s,this._handles.add(a((()=>this.view.state.camera),(()=>{this._viewChanged()})))}destroyExternalResources(){this._arrowMaterial=null,this._handles=o(this._handles)}forEachExternalMaterial(e){e(this._arrowMaterial)}createGeometries(e){if(null==this._geometry||null==this._geometry.startRenderSpace||null==this._geometry.endRenderSpace)return;const r=this._createArrowGeometry(this._geometry.startRenderSpace,this._geometry.endRenderSpace,this._origin,this._geometry);r.transformation=this._originTransform,e.addGeometry(r),this._viewChanged()}_createArrowGeometry(e,r,t,s){const i=this.view.renderCoordsHelper,o=[],a=[],n=(e,r)=>{const s=c.get();h(s,e,t),o.push(s),a.push(r)};if("euclidean"===s.type){s.eval(.5,this._arrowCenter);const t=c.get();i.worldUpAtPosition(this._arrowCenter,t),n(e,t),n(r,t)}else{s.eval(.5,this._arrowCenter);const e=this._parameters.arrowSubdivisions+1&-2;for(let r=0;r<e;++r){const t=r/(e-1),o=c.get(),a=c.get();s.eval(t,o),i.worldUpAtPosition(o,a),n(o,a)}}return m(this._arrowMaterial,o,a)}_geometryChanged(){this.recreateGeometry()}_viewChanged(){if(this.view.ready&&this.attached&&null!=this._geometry){const e=this.view.state.camera.computeScreenPixelSizeAt(this._arrowCenter);this._arrowMaterial.setParameters({width:this._parameters.arrowWidth*e})}}_updateArrowOpacity(){const e=this.opacity,{arrowStripeEvenColor:r,arrowStripeOddColor:t,arrowOutlineColor:s}=this._parameters,o=i(u,this._stripesEnabled?r:t,e),a=i(y,s,e),n=i(C,t,e);this._arrowMaterial.setParameters({stripeEvenColor:o,outlineColor:a,stripeOddColor:n})}}const u=d(),y=d(),C=d();export{g as MeasurementArrowVisualElement};
5
+ import e from"../../../../Color.js";import{getContrast as r}from"../../../../core/colorUtils.js";import t from"../../../../core/Handles.js";import{applyOpacity as i}from"../../../../core/mathUtils.js";import{destroyMaybe as s}from"../../../../core/maybe.js";import{watch as o}from"../../../../core/reactiveUtils.js";import{c as a}from"../../../../chunks/mat4f64.js";import{b as n}from"../../../../chunks/vec3.js";import{c as h}from"../../../../chunks/vec3f64.js";import{c as l}from"../../../../chunks/vec4f64.js";import{sv3d as c}from"../../../../geometry/support/vectorStacks.js";import{Object3DVisualElement as d}from"./Object3DVisualElement.js";import{createPolylineGeometry as p}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderOccludedFlag as m}from"../../webgl-engine/lib/Material.js";import{MeasurementArrowMaterial as _}from"../../webgl-engine/materials/MeasurementArrowMaterial.js";class w extends d{constructor(t){super(t),this._parameters={arrowWidth:16,arrowOutlineColor:e.toUnitRGBA(this.view.effectiveTheme.accentColor),arrowStripeEvenColor:e.toUnitRGBA(r(this.view.effectiveTheme.accentColor)),arrowStripeOddColor:e.toUnitRGBA(this.view.effectiveTheme.accentColor),arrowSubdivisions:128},this._origin=h(),this._originTransform=a(),this._arrowCenter=h(),this._renderOccluded=m.OccludeAndTransparent,this._geometry=null,this._stripeLength=1,this._stripesEnabled=!0,this._opacity=1,this.applyProperties(t)}get renderOccluded(){return this._renderOccluded}set renderOccluded(e){e!==this._renderOccluded&&(this._renderOccluded=e,this._arrowMaterial&&this._arrowMaterial.setParameters({renderOccluded:e}))}get geometry(){return this._geometry}set geometry(e){this._geometry=e,this._geometryChanged()}get stripeLength(){return this._stripeLength}set stripeLength(e){this._stripeLength=e,this.attached&&this._arrowMaterial.setParameters({stripeLength:this._stripeLength})}get stripesEnabled(){return this._stripesEnabled}set stripesEnabled(e){if(this._stripesEnabled=e,this.attached){const e=this.opacity,{arrowStripeEvenColor:r,arrowStripeOddColor:t}=this._parameters,s=i(g,this._stripesEnabled?r:t,e);this._arrowMaterial.setParameters({stripeEvenColor:s})}}get opacity(){return this._opacity}set opacity(e){e!==this._opacity&&(this._opacity=e,this._updateArrowOpacity())}createExternalResources(){const{arrowStripeEvenColor:e,arrowStripeOddColor:r,arrowOutlineColor:i}=this._parameters,s=this._stripesEnabled?e:r;this._arrowMaterial=new _({outlineColor:i,stripeEvenColor:s,stripeOddColor:r,renderOccluded:this.renderOccluded,polygonOffset:!0,isDecoration:this.isDecoration}),this._handles=new t,this._handles.add(o((()=>this.view.state.camera),(()=>{this._viewChanged()})))}destroyExternalResources(){this._arrowMaterial=null,this._handles=s(this._handles)}forEachExternalMaterial(e){e(this._arrowMaterial)}createGeometries(e){if(null==this._geometry||null==this._geometry.startRenderSpace||null==this._geometry.endRenderSpace)return;const r=this._createArrowGeometry(this._geometry.startRenderSpace,this._geometry.endRenderSpace,this._origin,this._geometry);r.transformation=this._originTransform,e.addGeometry(r),this._viewChanged()}_createArrowGeometry(e,r,t,i){const s=this.view.renderCoordsHelper,o=[],a=[],h=(e,r)=>{const i=c.get();n(i,e,t),o.push(i),a.push(r)};if("euclidean"===i.type){i.eval(.5,this._arrowCenter);const t=c.get();s.worldUpAtPosition(this._arrowCenter,t),h(e,t),h(r,t)}else{i.eval(.5,this._arrowCenter);const e=this._parameters.arrowSubdivisions+1&-2;for(let r=0;r<e;++r){const t=r/(e-1),o=c.get(),a=c.get();i.eval(t,o),s.worldUpAtPosition(o,a),h(o,a)}}return p(this._arrowMaterial,o,a)}_geometryChanged(){this.recreateGeometry()}_viewChanged(){if(this.view.ready&&this.attached&&null!=this._geometry){const e=this.view.state.camera.computeScreenPixelSizeAt(this._arrowCenter);this._arrowMaterial.setParameters({width:this._parameters.arrowWidth*e})}}_updateArrowOpacity(){const e=this.opacity,{arrowStripeEvenColor:r,arrowStripeOddColor:t,arrowOutlineColor:s}=this._parameters,o=i(g,this._stripesEnabled?r:t,e),a=i(u,s,e),n=i(y,t,e);this._arrowMaterial.setParameters({stripeEvenColor:o,outlineColor:a,stripeOddColor:n})}}const g=l(),u=l(),y=l();export{w as MeasurementArrowVisualElement};