@arcgis/core 4.34.0-next.50 → 4.34.0-next.52

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 (263) hide show
  1. package/analysis/ElevationProfile/GroundLine.d.ts +4 -0
  2. package/analysis/ElevationProfile/GroundLine.js +5 -0
  3. package/analysis/ElevationProfile/InputLine.d.ts +4 -0
  4. package/analysis/ElevationProfile/InputLine.js +5 -0
  5. package/analysis/ElevationProfile/Line.d.ts +4 -0
  6. package/analysis/ElevationProfile/Line.js +5 -0
  7. package/analysis/ElevationProfile/LineChartOptions.d.ts +4 -0
  8. package/analysis/ElevationProfile/LineChartOptions.js +5 -0
  9. package/analysis/ElevationProfile/LineViewOptions.d.ts +4 -0
  10. package/analysis/ElevationProfile/LineViewOptions.js +5 -0
  11. package/analysis/ElevationProfile/QueryLine.d.ts +4 -0
  12. package/analysis/ElevationProfile/QueryLine.js +5 -0
  13. package/analysis/ElevationProfile/SceneLine.d.ts +4 -0
  14. package/analysis/ElevationProfile/SceneLine.js +5 -0
  15. package/analysis/ElevationProfile/Units.d.ts +4 -0
  16. package/analysis/ElevationProfile/Units.js +5 -0
  17. package/analysis/ElevationProfile/ViewOptions.d.ts +4 -0
  18. package/analysis/ElevationProfile/ViewOptions.js +5 -0
  19. package/analysis/ElevationProfile/elevationProfileLineTypes.js +5 -0
  20. package/analysis/ElevationProfileAnalysis.js +1 -1
  21. package/assets/esri/core/workers/RemoteClient.js +1 -1
  22. package/assets/esri/core/workers/chunks/{7bd672e534cde0d5787d.js → 0021118bafefd1e47ff7.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{beb77cdae0b1b6ad73da.js → 0445de3a8968c0734c91.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{0b52c0ca432761076076.js → 081b22fa73ef7b696409.js} +2 -2
  25. package/assets/esri/core/workers/chunks/0a6d33d013628f671aea.js +1 -0
  26. package/assets/esri/core/workers/chunks/0ce671588de2858516d2.js +1 -0
  27. package/assets/esri/core/workers/chunks/14c6ae4feb4859cfa7c5.js +1 -0
  28. package/assets/esri/core/workers/chunks/20a2b3d1f826e9059884.js +1 -0
  29. package/assets/esri/core/workers/chunks/{c4651243525026e6ddde.js → 2da12a64d3baef4aaaa1.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{5b0c42bb95d81085061d.js → 35fc8a64674005b1d1d7.js} +1 -1
  31. package/assets/esri/core/workers/chunks/37a97e690786814bf0b3.js +1 -0
  32. package/assets/esri/core/workers/chunks/38f84294fb2fb4663ba5.js +1 -0
  33. package/assets/esri/core/workers/chunks/3eb3af0b6cf3c2f28131.js +1 -0
  34. package/assets/esri/core/workers/chunks/48e64f99720907017778.js +1 -0
  35. package/assets/esri/core/workers/chunks/4bd92232928b832dea76.js +1 -0
  36. package/assets/esri/core/workers/chunks/50e9eafb118d2a221f10.js +1 -0
  37. package/assets/esri/core/workers/chunks/55588e668b6acb6aa390.js +1 -0
  38. package/assets/esri/core/workers/chunks/5b112471dca94b2e8462.js +1 -0
  39. package/assets/esri/core/workers/chunks/5dfe1aed10095385c066.js +1 -0
  40. package/assets/esri/core/workers/chunks/7389841fabe0f319f1e5.js +1 -0
  41. package/assets/esri/core/workers/chunks/77493aa2118d462612a0.js +1 -0
  42. package/assets/esri/core/workers/chunks/7a8d740d1226719a578a.js +1 -0
  43. package/assets/esri/core/workers/chunks/81e518dd62bd95611d00.js +1 -0
  44. package/assets/esri/core/workers/chunks/8e0559cc6295008fcdf7.js +1 -0
  45. package/assets/esri/core/workers/chunks/{69e37365c17e7cc4168f.js → 93af38d29d066f27ed28.js} +1 -1
  46. package/assets/esri/core/workers/chunks/944fa8261aad94ae0542.js +1 -0
  47. package/assets/esri/core/workers/chunks/{6775d2ab5faf1fa161db.js → 97a38d700f2cb8807d51.js} +1 -1
  48. package/assets/esri/core/workers/chunks/{45121b7258333c8ebbdb.js → 98ea12c7a000a30f3dc0.js} +1 -1
  49. package/assets/esri/core/workers/chunks/9e479e7e2e51476c3d27.js +1 -0
  50. package/assets/esri/core/workers/chunks/a1e179dd6de9c8769b02.js +1 -0
  51. package/assets/esri/core/workers/chunks/a829969ed44cdb814f27.js +1 -0
  52. package/assets/esri/core/workers/chunks/ac41b882f9cbf8d56f0c.js +1 -0
  53. package/assets/esri/core/workers/chunks/b0ee061747bef6729bb9.js +1 -0
  54. package/assets/esri/core/workers/chunks/b2a035befeeff1a55ad8.js +1 -0
  55. package/assets/esri/core/workers/chunks/ba45dccb4dab5a74d224.js +1 -0
  56. package/assets/esri/core/workers/chunks/c5b2a261d8c216ca4a10.js +1 -0
  57. package/assets/esri/core/workers/chunks/{edc4f230a5bdf928f9fd.js → d1aeb9fe9eb573beefcc.js} +2 -2
  58. package/assets/esri/core/workers/chunks/e3f68f7b408a08d7cd5d.js +1 -0
  59. package/assets/esri/core/workers/chunks/e9716995ce0c3683eafc.js +1 -0
  60. package/assets/esri/core/workers/chunks/{4cc982c99d84e896d535.js → ed25bf087f52e5d3e71b.js} +1 -1
  61. package/assets/esri/core/workers/chunks/f92e608931b1c168cb45.js +1 -0
  62. package/assets/esri/core/workers/chunks/f9f94b5efa9a64cdb407.js +1 -0
  63. package/assets/esri/core/workers/chunks/fb4950995f6780f6c22a.js +1 -0
  64. package/assets/esri/themes/base/widgets/_Search.scss +12 -0
  65. package/assets/esri/themes/base/widgets/_VideoPlayer.scss +16 -2
  66. package/assets/esri/themes/dark/main.css +1 -1
  67. package/assets/esri/themes/light/main.css +1 -1
  68. package/assets/esri/themes/light/view.css +1 -1
  69. package/chunks/Laserlines.glsl.js +12 -12
  70. package/chunks/sphere.js +1 -1
  71. package/chunks/vec42.js +1 -1
  72. package/config.js +1 -1
  73. package/core/libs/gl-matrix-2/math/quat.js +1 -1
  74. package/core/libs/gl-matrix-2/math/vec4.js +1 -1
  75. package/geometry/projection/projectBoundingSphere.js +1 -1
  76. package/geometry/support/DoubleArray.js +1 -1
  77. package/geometry/support/aaBoundingRect.js +1 -1
  78. package/geometry/support/curves/bezierCurveUtils.js +1 -1
  79. package/geometry/support/curves/circleUtils.js +1 -1
  80. package/geometry/support/curves/ellipticArc4Utils.js +1 -1
  81. package/geometry/support/curves/ellipticArc7Utils.js +1 -1
  82. package/geometry/support/curves/mathUtils.js +1 -1
  83. package/geometry/support/sphere.js +1 -1
  84. package/identity/OAuthCredential.js +1 -1
  85. package/interfaces.d.ts +272 -279
  86. package/kernel.js +1 -1
  87. package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
  88. package/layers/mixins/ArcGISImageService.js +1 -1
  89. package/layers/support/rasterFunctions/pixelUtils.js +1 -1
  90. package/package.json +1 -1
  91. package/request.js +1 -1
  92. package/support/revision.js +1 -1
  93. package/views/2d/engine/imagery/RasterBitmap.js +1 -1
  94. package/views/2d/engine/imagery/RasterTileContainer.js +1 -1
  95. package/views/2d/engine/webgl/shaderGraph/techniques/raster/RasterColorizerTechnique.js +1 -1
  96. package/views/2d/engine/webgl/shaderGraph/techniques/raster/RasterHighlightTechnique.js +5 -0
  97. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/AspectTechnique.js +1 -1
  98. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/BandArithmeticTechnique.js +1 -1
  99. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/BaseRasterProcessorTechnique.js +1 -1
  100. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/ColormapToRGBTechnique.js +1 -1
  101. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/CompositeBandTechnique.js +1 -1
  102. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/ComputeChangeTechnique.js +1 -1
  103. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/ContrastBrightnessTechnique.js +1 -1
  104. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/ConvolutionTechnique.js +1 -1
  105. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/CurvatureTechnique.js +1 -1
  106. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/ExtractBandTechnique.js +1 -1
  107. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/FocalStatisticsTechnique.js +1 -1
  108. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/GrayscaleTechnique.js +1 -1
  109. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/HillshadeTechnique.js +1 -1
  110. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/LocalTechnique.js +1 -1
  111. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/MaskTechnique.js +1 -1
  112. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/NDVITechnique.js +1 -1
  113. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/RemapTechnique.js +1 -1
  114. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/ReprojectTechnique.js +1 -1
  115. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/ShadedReliefTechnique.js +1 -1
  116. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/SlopeTechnique.js +1 -1
  117. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/StretchTechnique.js +1 -1
  118. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/textureUtils.js +1 -1
  119. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/BaseRasterColorizerShader.js +1 -1
  120. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/RasterRangeHighlightShader.js +5 -0
  121. package/views/2d/layers/ImageryLayerView2D.js +1 -1
  122. package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
  123. package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
  124. package/views/2d/layers/imagery/ImageryView2D.js +1 -1
  125. package/views/3d/analysis/ElevationProfile/ProfileLinesVisualization.js +1 -1
  126. package/views/3d/analysis/ElevationProfile/SceneLineComputation.js +5 -0
  127. package/views/3d/analysis/ElevationProfileAnalysisView3D.js +1 -1
  128. package/views/3d/analysis/VolumeMeasurement/CutFillVolumeMeasurementController.js +1 -1
  129. package/views/3d/analysis/support/measurementUtils.js +1 -1
  130. package/views/3d/camera/constraintUtils/distance.js +1 -1
  131. package/views/3d/camera/constraintUtils/tilt.js +1 -1
  132. package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
  133. package/views/3d/interactive/visualElements/MeasurementAreaVisualElement.js +1 -1
  134. package/views/3d/interactive/visualElements/MeasurementArrowVisualElement.js +1 -1
  135. package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
  136. package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
  137. package/views/3d/interactive/visualElements/PointVisualElement.js +1 -1
  138. package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
  139. package/views/3d/interactive/visualElements/SlicePlaneVisualElement.js +1 -1
  140. package/views/3d/interactive/visualElements/VerticesVisualElement.js +1 -1
  141. package/views/3d/layers/I3SMeshView3D.js +1 -1
  142. package/views/3d/layers/SceneLayerWorker.js +1 -1
  143. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  144. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  145. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  146. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  147. package/views/3d/layers/graphics/graphicUtils.js +1 -1
  148. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  149. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  150. package/views/3d/layers/i3s/I3SProjectionUtil.js +1 -1
  151. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  152. package/views/3d/layers/support/FastSymbolUpdates.js +1 -1
  153. package/views/3d/state/NearFarHeuristic.js +1 -1
  154. package/views/3d/state/ViewStateManager.js +1 -1
  155. package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
  156. package/views/3d/state/utils/navigationUtils.js +1 -1
  157. package/views/3d/support/flow/FlowSubViewTiles3D.js +1 -1
  158. package/views/3d/support/orientedBoundingBox.js +1 -1
  159. package/views/3d/terrain/OverlayManager.js +1 -1
  160. package/views/3d/terrain/ScaleRangeQueries.js +1 -1
  161. package/views/3d/terrain/SphericalPatch.js +1 -1
  162. package/views/3d/terrain/TerrainSurface.js +1 -1
  163. package/views/3d/terrain/Tile.js +1 -1
  164. package/views/3d/webgl/RenderCamera.js +1 -1
  165. package/views/3d/webgl-engine/Stage.js +1 -1
  166. package/views/3d/webgl-engine/lib/MainFramebuffer.js +1 -1
  167. package/views/3d/webgl-engine/lib/Object3D.js +1 -1
  168. package/views/3d/webgl-engine/lib/Octree.js +1 -1
  169. package/views/3d/webgl-engine/lib/PathGeometryData.js +1 -1
  170. package/views/3d/webgl-engine/lib/RenderGeometry.js +1 -1
  171. package/views/3d/webgl-engine/lib/ShadowCastRenderer.js +1 -1
  172. package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
  173. package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
  174. package/views/3d/webgl-engine/lib/lodRendering/InstanceOctree.js +1 -1
  175. package/views/3d/webgl-engine/lib/screenSizePerspectiveUtils.js +1 -1
  176. package/views/3d/webgl-engine/lib/verticalOffsetUtils.js +1 -1
  177. package/views/analysis/ElevationProfile/Controller.js +5 -0
  178. package/views/analysis/ElevationProfile/GroundLineComputation.js +5 -0
  179. package/views/analysis/ElevationProfile/InputLineComputation.js +5 -0
  180. package/views/analysis/ElevationProfile/LineComputation.js +5 -0
  181. package/views/analysis/ElevationProfile/QueryLineComputation.js +5 -0
  182. package/views/analysis/ElevationProfile/Result.d.ts +4 -0
  183. package/views/analysis/{ElevationProfileResult.js → ElevationProfile/Result.js} +1 -1
  184. package/views/interactive/coordinateHelper.js +1 -1
  185. package/views/interactive/editGeometry/operations/curveOperationUtils.js +1 -1
  186. package/views/interactive/sketch/constraints.js +1 -1
  187. package/views/interactive/snapping/featureSources/sceneLayerSource/SceneLayerSnappingSourceWorker.js +1 -1
  188. package/views/interactive/snapping/featureSources/sceneLayerSource/sceneLayerSnappingUtils.js +1 -1
  189. package/views/support/LayerLayerViewInfo.js +1 -1
  190. package/views/support/LayerViewManager.js +1 -1
  191. package/widgets/ElevationProfile/ElevationProfileLine.d.ts +2 -2
  192. package/widgets/ElevationProfile/ElevationProfileLineGround.d.ts +2 -2
  193. package/widgets/ElevationProfile/ElevationProfileLineInput.d.ts +2 -2
  194. package/widgets/ElevationProfile/ElevationProfileLineQuery.d.ts +2 -2
  195. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  196. package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
  197. package/widgets/OrientedImageryViewer/services/ImageMeasurementService.js +5 -0
  198. package/widgets/Search/css.js +1 -1
  199. package/widgets/Search.js +1 -1
  200. package/widgets/VideoPlayer/components/PlayerActionsGroup.js +1 -1
  201. package/widgets/VideoPlayer/css.js +1 -1
  202. package/widgets/VideoPlayer.js +1 -1
  203. package/analysis/ElevationProfileLine.d.ts +0 -4
  204. package/analysis/ElevationProfileLine.js +0 -5
  205. package/analysis/ElevationProfileLineChartOptions.d.ts +0 -4
  206. package/analysis/ElevationProfileLineChartOptions.js +0 -5
  207. package/analysis/ElevationProfileLineGround.d.ts +0 -4
  208. package/analysis/ElevationProfileLineGround.js +0 -5
  209. package/analysis/ElevationProfileLineInput.d.ts +0 -4
  210. package/analysis/ElevationProfileLineInput.js +0 -5
  211. package/analysis/ElevationProfileLineQuery.d.ts +0 -4
  212. package/analysis/ElevationProfileLineQuery.js +0 -5
  213. package/analysis/ElevationProfileLineScene.d.ts +0 -4
  214. package/analysis/ElevationProfileLineScene.js +0 -5
  215. package/analysis/ElevationProfileLineViewOptions.d.ts +0 -4
  216. package/analysis/ElevationProfileLineViewOptions.js +0 -5
  217. package/analysis/ElevationProfileUnits.d.ts +0 -4
  218. package/analysis/ElevationProfileUnits.js +0 -5
  219. package/analysis/ElevationProfileViewOptions.d.ts +0 -4
  220. package/analysis/ElevationProfileViewOptions.js +0 -5
  221. package/analysis/support/elevationProfileLineTypes.js +0 -5
  222. package/assets/esri/core/workers/chunks/21a90083f29e44ccd735.js +0 -1
  223. package/assets/esri/core/workers/chunks/224872bfd923cf4c9d78.js +0 -1
  224. package/assets/esri/core/workers/chunks/237c96d946efa5ed0386.js +0 -1
  225. package/assets/esri/core/workers/chunks/2942ab268f24cea2e722.js +0 -1
  226. package/assets/esri/core/workers/chunks/32789077e37d5c8191e7.js +0 -1
  227. package/assets/esri/core/workers/chunks/3610357c8fa9bec9e0dc.js +0 -1
  228. package/assets/esri/core/workers/chunks/3e3886a51c0f8c86df75.js +0 -1
  229. package/assets/esri/core/workers/chunks/6d786fac4bb5efcb7acc.js +0 -1
  230. package/assets/esri/core/workers/chunks/7b95da70d39ba316b051.js +0 -1
  231. package/assets/esri/core/workers/chunks/7df8c78e36b04ad657d2.js +0 -1
  232. package/assets/esri/core/workers/chunks/838c7fd37b2e78b1d582.js +0 -1
  233. package/assets/esri/core/workers/chunks/8c6119dde0eead8d90d9.js +0 -1
  234. package/assets/esri/core/workers/chunks/8c8c8f1058a4b58a3181.js +0 -1
  235. package/assets/esri/core/workers/chunks/8f70650aba8e55eb7a96.js +0 -1
  236. package/assets/esri/core/workers/chunks/96a34b240d17147902f4.js +0 -1
  237. package/assets/esri/core/workers/chunks/9af47a4da3a0b84f1add.js +0 -1
  238. package/assets/esri/core/workers/chunks/9affcf990ea810fa426b.js +0 -1
  239. package/assets/esri/core/workers/chunks/a3dce23ca98c9b0f945f.js +0 -1
  240. package/assets/esri/core/workers/chunks/a50026e567b1edff87c6.js +0 -1
  241. package/assets/esri/core/workers/chunks/a7ff44157b8cf19de37e.js +0 -1
  242. package/assets/esri/core/workers/chunks/b884bd2f50aaccfa24c5.js +0 -1
  243. package/assets/esri/core/workers/chunks/c483d2149d9d0099bfdb.js +0 -1
  244. package/assets/esri/core/workers/chunks/cfc3f202e7313ca56823.js +0 -1
  245. package/assets/esri/core/workers/chunks/d1c97fdcba6eb443cb1c.js +0 -1
  246. package/assets/esri/core/workers/chunks/d7c679374aa2d256becf.js +0 -1
  247. package/assets/esri/core/workers/chunks/d8d17e3ecccec7e99f0b.js +0 -1
  248. package/assets/esri/core/workers/chunks/e4069352d5d1104749ae.js +0 -1
  249. package/assets/esri/core/workers/chunks/e408ccee12bfe089c913.js +0 -1
  250. package/assets/esri/core/workers/chunks/e5522c85ca4f0efab8ea.js +0 -1
  251. package/assets/esri/core/workers/chunks/e59e09766b130a05c617.js +0 -1
  252. package/assets/esri/core/workers/chunks/ef02e33ea53b46b566cb.js +0 -1
  253. package/assets/esri/core/workers/chunks/ff79a8df1b1941ae350d.js +0 -1
  254. package/views/3d/analysis/ElevationProfile/ElevationProfileLineSceneComputation.js +0 -5
  255. package/views/analysis/ElevationProfile/ElevationProfileController.js +0 -5
  256. package/views/analysis/ElevationProfile/ElevationProfileLineComputation.js +0 -5
  257. package/views/analysis/ElevationProfile/ElevationProfileLineGroundComputation.js +0 -5
  258. package/views/analysis/ElevationProfile/ElevationProfileLineInputComputation.js +0 -5
  259. package/views/analysis/ElevationProfile/ElevationProfileLineQueryComputation.js +0 -5
  260. package/views/analysis/ElevationProfileResult.d.ts +0 -4
  261. package/views/support/PixelHighlightOptions.js +0 -5
  262. /package/assets/esri/core/workers/chunks/{edc4f230a5bdf928f9fd.js.LICENSE.txt → d1aeb9fe9eb573beefcc.js.LICENSE.txt} +0 -0
  263. /package/views/analysis/ElevationProfile/{profileUtils.js → profileGenerationUtils.js} +0 -0
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{equals as a,isSome as i}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as o}from"../../core/deprecate.js";import n from"../../core/Error.js";import{EventedMixin as l}from"../../core/Evented.js";import{makeHandle as c}from"../../core/handleUtils.js";import{equalsShallow as h}from"../../core/lang.js";import u from"../../core/Logger.js";import{clamp as m}from"../../core/mathUtils.js";import{abortMaybe as d,destroyMaybe as p}from"../../core/maybe.js";import{EsriPromise as g}from"../../core/Promise.js";import{isAbortError as y,throwIfAborted as v,waitTick as f}from"../../core/promiseUtils.js";import w from"../../core/ReactiveMap.js";import{whenOnce as F,on as b,watch as M,syncAndInitial as _,initial as P}from"../../core/reactiveUtils.js";import{sqlAnd as I}from"../../core/sql.js";import{getMetersPerUnitForSR as V}from"../../core/unitUtils.js";import{property as k}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as A}from"../../core/accessorSupport/decorators/subclass.js";import{distance as S}from"../../core/libs/gl-matrix-2/math/vec2.js";import{isSerializable as C}from"../../core/support/jsonUtils.js";import{UpdatingHandles as G}from"../../core/support/UpdatingHandles.js";import L from"../../geometry/Extent.js";import{union as R}from"../../geometry/geometryEngineAsync.js";import O from"../../geometry/Multipoint.js";import T from"../../geometry/Point.js";import j from"../../geometry/Polygon.js";import B from"../../geometry/Polyline.js";import{projectWithZConversion as x}from"../../geometry/projectionUtils.js";import H from"../../geometry/SpatialReference.js";import{isClockwise as E}from"../../geometry/support/coordsUtils.js";import{normalizeMapX as z}from"../../geometry/support/normalizeUtils.js";import{geographicToWebMercator as D}from"../../geometry/support/webMercatorUtils.js";import U from"../../layers/GraphicsLayer.js";import N from"../../layers/MediaLayer.js";import{searchImages as W,getSortedLayerFeatures as q}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as $}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as J,computePolygonForInspection as Z,resizePolygon as K,checkIfPolygonContainsSelectedPoint as Q}from"../../layers/orientedImagery/core/coverageUtils.js";import{isElevationSource as X}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{convertGeographicToWebMercator as Y}from"../../layers/orientedImagery/core/utils.js";import{imageToWorld as ee,imageToWorldPanoramic as te}from"../../layers/orientedImagery/transformations/imageToWorld.js";import ae from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as ie}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{or as re,getInitialAngle as se,convertPixelToHeadingPitch as oe,convertHeadingPitchToSphereVertex as ne,getImageToWorldProperties as le,getUpdateElevationProps as ce,isElevationSampler as he,getImageToWorldPanoramicProperties as ue,pointToArray as me,transformGraphicCoordinatesToPixel as de,getWorldToImageProperties as pe}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImage as ge,worldToImagePanoramic as ye}from"../../layers/orientedImagery/transformations/worldToImage.js";import ve from"../../layers/support/ExtentAndRotationGeoreference.js";import{getFloorFilterClause as fe}from"../../layers/support/floorFilterUtils.js";import we from"../../layers/support/VideoElement.js";import Fe from"../../views/MapView.js";import be from"../../views/draw/Draw.js";import{scale as Me}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as _e}from"../../views/input/InputManager.js";import Pe from"../PanoramicViewer.js";import{defaultAngleThresholdInDegrees as Ie,videoExtent as Ve,invalidCameraHeading as ke,sectorsInOrder as Ae,sampleExtent as Se,sectorsRadii as Ce}from"./constants.js";import{configureSketchTool as Ge,extractFieldsFromDataCaptureLayer as Le,isValidDataCaptureLayer as Re,constructGraphicFromImageGeometry as Oe}from"./dataCaptureUtils.js";import{isFeatureAttachment as Te,getImageSourceFromAttachment as je}from"./galleryUtils.js";import{formatPixels as Be,heightMeasurementPanoramic as xe,heightMeasurement2D as He,calculateHeightAccuracyPanoramic as Ee,calculateHeightAccuracy as ze,pixelAreaMeasurement2D as De,pixelAreaMeasurementPanoramic as Ue,pixelDistanceMeasurement2D as Ne,pixelDistanceMeasurementPanoramic as We,generateCombinations as qe,getRootOfSumOfSquaredErrors as $e,generateCombinationsPanoramic as Je,calculateLocationAccuracyFromDeviations as Ze,calculateReferenceImagePointPanoramic as Ke,calculateAnglePano as Qe,calculateTempImagePoint as Xe,calculateAngle as Ye,computeTriangulatedAreaMeasurement as et,computeTriangulatedDistanceMeasurement as tt,getModeCorrectedPoint as at,calculateCorrectedPixel as it,getUnitRateFromSpatialReference as rt,calculateHeightFromTemporaryDistance as st,computeTriangulatedVector as ot,computeTriangulatedPoint as nt}from"./imageMeasurementUtils.js";import{crossSymbol as lt,crossSymbol3D as ct,measurementPolygonSymbol as ht,polylineSymbolPanoramic as ut,measurementPolylineSymbol as mt,cameraOverlaySymbol3D as dt,cameraOverlaySymbol as pt,diamondSymbol as gt,diamondSymbol3D as yt,locationSymbol as vt,locationSymbol3D as ft,activeSourcePointSymbol as wt,sourcePointSymbol as Ft}from"./symbols.js";import{isNoAttachmentError as bt,getContentType as Mt,isTifOrMrf as _t,filterOILLayerView as Pt,assignElevationSampleToFeatures as It,calculateDirection as Vt,calculateSegment as kt,isSceneView as At,isGraphic as St}from"./utils.js";import{disableVideoZoomAndPan as Ct}from"./videoViewerUtils.js";import Gt from"./components/ImageViewer.js";import Lt from"./components/NavigationNode.js";import Rt from"./components/OrientedImageryVideoViewModel.js";import{NoActiveViewerError as Ot,NoFeatureFoundWithObjectIdError as Tt}from"./navigation/errors.js";import{queryFeatureByObjectIds as jt}from"./navigation/queries.js";import Bt from"../Sketch/SketchViewModel.js";const xt={click:"view-click",imageClick:"image-click",triangularImageClick:"triangular-click",interactionHandles:"interaction-handles",hittestHandles:"hittest-handles",videoPlayerHandles:"video-handles",activeViewerCursorHandles:"active-viewer-cursor-handles",imageViewerCursorHandles:"image-viewer-cursor-handles"},Ht=new Set(["JPG","JPEG"]),Et=/\.(\w+)$/,zt=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let Dt=class extends(l(g)){constructor(e){super(e),this.additionalFeatures=new s,this.additionalCameraLocations=new s,this.additionalFootprints=new s,this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.bestFeatureAngle=0,this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null,this.cameraHeadingThreshold=Ie,this.cameraPitchThreshold=Ie,this.clickAction="hittest",this.videoViewModel=null,this.collectionId=null,this.conversionProps=null,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentBestFeatureMeasurementImage=null,this.currentBestFeatureLocation=null,this.currentCoverageVisible=!0,this.featureCache=[],this.navigationNodes=new s,this.determineWorkflowForFeature=async(e,t,a)=>{const{currentBestFeature:i,selectedPoint:r,view:s}=this;if(s?.closePopup(),i&&r){this._initialCurrentCoverageUpdate=!0,this._updateGroundElevation=!0;try{await this._updatePointsAndPolygons(a),await this._loadImage(a)}catch(o){y(o)||(this.loadImageError(o),u.getLogger(this).error("#loadIImage()","error occured while loading image",o))}}},this.determineWorkflowForTriangularMeasurement=async(e,t,a)=>{if(this.view?.closePopup(),this.currentBestFeatureMeasurementImage&&this.selectedPoint)try{await this._loadMeasurementViewerImage(a)}catch(i){y(i)||(this.loadImageError(i),u.getLogger(this).error("#loadIImage()","error occured while loading image",i))}},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.displayNewMeasurementButton=!0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.dataCaptureLayer=null,this.features=new s,this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.heightMeasurementPixels=[],this.heightGraphic=null,this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.measurementAngle=null,this.tempDistance=null,this.imageGeometryField=null,this.imageLocationToolState=!1,this.imageMeasurementViewer=new Gt,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.measurementVectors=[],this.layer=null,this.localPort=null,this.mapImageConversionToolState=!1,this.measureType=null,this.measurementGraphic=null,this.navigatorCurrentBestFeature=null,this.oiObjectIdField=null,this.overlayedCameraLocations=new s,this.overlayedMapFeatures=new w,this.pixelCoordinates=null,this.preserveAngle="none",this.pointSources=new s,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.sketch=null,this.sketchTriangular=null,this.sketchTriangularGraphicsLayer=null,this.draw=null,this.sketchAdapter=null,this.triangularMeasurementActive=!1,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedAreaAccuracy=0,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.triangulatedMeasurementAdapter=null,this.updateFootprint=async(e,t)=>{"default"===this.mode&&"image-loaded"!==this.state||"video"===this.mode&&!this.videoElement?.content||await(this._adapter?.updateFootprint(e,t))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this.updatingTriangularMeasurementState=!1,this.videoElement=null,this.videoLayer=null,this.videoMapView=new Fe({map:new Map}),this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new Gt,this._initialCurrentCoverageUpdate=!0,this._locationPointOnImage=null,this._correctedLocationPointOnImage=null,this._overlays=new U({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"},title:"OrentedImageryViewerViewModel overlays layer"}),this._panoramicViewer=new Pe,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._featureToSector=null,this._updatingHandles=new G,this._clickTask=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._openPopupTask=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this._updateGroundElevation=!1,this.addUpdatingPromise=e=>this._updatingHandles.addPromise(e),this.hideImageGeometry=e=>{},this.highlight=e=>{if(!this._overlaysView)return;this.removeHighlight();const t=this.additionalFootprints.find(({attributes:{imageID:t}})=>t===Number(e));this._highlightedFeatureHandle=t?this._overlaysView?.highlight(t):null},this.loadDataCaptureAdapter=async e=>{await this.loadSketch(e);const t=import("./adapters/sketch/DataCaptureAdapter.js"),{default:a}=await t;return v(e),this.sketchAdapter=new a({viewModel:this}),this.sketchAdapter},this.loadImageFromSource=async(e,t)=>this._updatingHandles.addPromise(this._loadImageFromSourceInternal(e,t)),this.storeImageMeasurementViewer=e=>{this.imageMeasurementViewer=e},this.loadImageViewer=e=>{this._imageViewer?.destroy(),this._imageViewer=e},this.loadPanoramicViewer=e=>{this._panoramicViewer?.destroy(),this._panoramicViewer=e},this.loadVideoViewer=e=>{this.videoMapView.container=e},this.showImageByObjectId=async(e,t)=>{const a=this.additionalFeatures.find(({attributes:t})=>t.objectId===e);if(a)this.currentBestFeature=a;else{const{layer:a,layerFloorFilterClause:r}=this;if(!a)return void this.setMessage("noLayerSelected","info");this.beforeLoad();const s=this._updatingHandles.addPromise(this._queryAndLoadByObjectId(a,e,r,t));try{await s,await this.selectBestFeature(e,t)}catch(i){y(i)||(u.getLogger(this).error("oriented-imagery-viewer:show-image",i),"NoFeatureFoundWithObjectIdError"===i.name?this.setMessage("noFeatureFoundWithObjectId","error","",{objectId:e}):this.setMessage("imageLoadError","error",i.message))}}},this.imageToImageTransform=async(e,t,a)=>{const{updateElevationProps:i,...r}=t,{updateElevationProps:s,...o}=a,n=await ee(e,r,i);return ge(n,o)},this.getSectorFeatureById=e=>this._suitabilities?.find(({feature:{attributes:{objectId:t}}})=>t===e),this.getFeatureSectorById=e=>this._featureToSector?.[`${e}`],this.navigate=async(e,t)=>{const{activeViewer:a}=this;if(!a)throw new Ot;return await a.navigate(e,t)},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.revealImageGeometry=e=>{},this.selectBestFeature=async(e,t)=>(v(t),this.currentBestFeature=this.features?.find(({attributes:t})=>`${t.objectId}`==`${e}`),F(()=>"image-loaded"===this.state,t)),this.toggleImageAttributes=()=>{d(this._openPopupTask),this._openPopupTask=r(async e=>{const{currentBestFeature:a,popupEnabled:i,layer:r,view:s}=this;if(s?.closePopup(),!(s&&a&&i&&r))return;const{attributes:o,geometry:n}=a,l=new t({geometry:n,attributes:o.toJSON(),layer:r,sourceLayer:r});v(e),await s.openPopup({features:[l],location:o.location.clone()})})},this.updateSuitabilities=(e,t=!0)=>{e.sort((e,t)=>e.suitability-t.suitability),this._suitabilities=e;const a=this._suitabilities.map(({feature:e})=>e);this._initialCurrentCoverageUpdate=!0,this._updateFeatures(a,t),this._groupFeaturesBySectors()},this._createViewClickHandle=()=>{if(this.removeHandles(xt.click),"disabled"===this.state||null==this.view)return;const e=this.mapImageConversionToolState&&"image-loaded"===this.state?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,_e.WIDGET),xt.click)},this._createImageClickHandle=()=>{this.removeHandles(xt.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:a,currentBestFeature:i,footprintExtent:s}=this,o=a?.imageSize;if(!(e&&"none"!==t&&o&&s&&i))return;const n=a.clickAction;this.clickAction="pixel-location";const l=c(()=>{this.clickAction=n});let h=null;const u=b(()=>a,"pixel-location",e=>{this.plotReferencePointOnImage(e),h?.abort(),h=r(async a=>{if(!e)return;const r=await this.getMapPoint(e,{feature:i,imageSize:o,mode:t}).then(e=>{const t=this.view?.spatialReference;return re(!t,e.spatialReference.equals(t))?e:x(e,t)});v(a),this.plotReferencePointOnGround(r)})});this.addHandles([u,l],xt.imageClick)},this._createTriangularImageClickHandle=()=>{this.removeHandles(xt.triangularImageClick);const e=this.imageMeasurementViewer?.imageSize;this.triangularMeasurementActive&&"none"!==this.mode&&e&&this.currentBestFeature&&this.addHandles(this.imageMeasurementViewer.imageRenderer.on("double-click",this._measurementImageClickHandler),xt.triangularImageClick)},this._createTriangularImageLocationHandle=()=>{this.removeHandles(xt.triangularImageClick);const{imageLocationToolState:e,mode:t,imageMeasurementViewer:a}=this,i=a?.imageSize;if(!e||"none"===t||!i)return;this.clickAction="pixel-location";let s=null;const o=b(()=>a,"pixel-location",e=>{1===this.measurementVectors.length&&(this.plotLocationPointOnImage(e,!0),s?.abort(),s=r(async a=>{if(!e||this.triangulatedPoint||2===this.measurementVectors?.length||!this.currentBestFeatureMeasurementImage)return;let r=await this.getMapPoint(e,{feature:this.currentBestFeatureMeasurementImage,imageSize:i,mode:t});v(a);const s=this.currentBestFeatureMeasurementImage.geometry.spatialReference;s&&!r.spatialReference.equals(s)&&(r=await x(r,s),v(a)),await this._calculateTriangulatedPointFromGroundPoint(r,{signal:a}),v(a)}))});this.addHandles(o,xt.triangularImageClick)},this._createImageLocationHandle=()=>{this.removeHandles(xt.imageClick);const{imageLocationToolState:e,mode:t,activeViewer:a,currentBestFeature:i,footprintExtent:s}=this,o=a?.imageSize;if(!(e&&"none"!==t&&o&&s&&i))return;this.clickAction="pixel-location";let n=null;const l=b(()=>a,"pixel-location",e=>{const{currentBestFeatureMeasurementImage:a,triangularMeasurementActive:s,imageMeasurementViewer:l}=this;this.pixelCoordinates=e;const c=null!=a&&!l.state.includes("loading");re(!s,c)&&this.plotLocationPointOnImage(e),n?.abort(),n=r(async a=>{if(!e)return;let r=await this.getMapPoint(e,{feature:i,imageSize:o,mode:t});v(a);const n=this.view?.spatialReference;n&&!r.spatialReference.equals(n)&&(r=await x(r,n),v(a)),this.groundCoordinates=r,s&&r&&c&&await this.triangulatedLocationWorkflow(r,a);const l=await this.calculateLocationAccuracy(e,r,t,a);v(a),l&&(this.groundCoordinatesAccuracy=l)})});this.addHandles(l,xt.imageClick)},this._handleImageHitTestResponse=async e=>{const{layer:t,overlayedCameraLocations:a}=this;if(!t)return;const i=e.results.find(({graphic:e,graphic:{attributes:i}})=>a.includes(e)&&i&&!i[t.imageReferenceField]&&!i[t.imageGeometryField]);if(!i)return;const r=i.graphic.attributes[t.objectIdField];await this.showImageByObjectId(r)},this._loadImage=async e=>{const{currentBestFeature:t,layer:a,mode:i}=this;if(this.clearGraphics(),!a||!t||"none"===i||"video"===i)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:l,cameraPitch:c,objectId:h,cameraOrientation:m,location:d}=r,p=(l??0)+(o??0),g=d.spatialReference.isWGS84&&4!==m?.type?D(d):new T(d);let f=s;if(Te(s))try{f=await je(a,h,e)}catch(w){if(y(w))return;return bt(w)?(u.getLogger(this).error(w),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${h}`)):(u.getLogger(this).error(w,{[a.objectIdField]:h,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${h}`))}try{await this.loadImageFromSource(f,{imageRotation:p,options:e,pitch:c,yaw:n,mode:i,cameraLocation:g}),v(e),await this.transformAndPlotSelectedLocation(e)}catch(w){y(w)||this.loadImageError(w)}},this._loadImageFromSourceInternal=async(e,t)=>{const{mode:a,imageRotation:i,options:r}=t,s="string"==typeof e,o=s?e:e.url,{pathname:n,searchParams:l}=new URL(o);let c=s?n.match(Et)?.[1]:e.datasetFormat;if(!c)try{c=await Mt(o,{...t.options})}catch(h){y(h)||u.getLogger(this).error("#getContentType()",h)}switch(c??="UNKNOWN FORMAT",a){case"default":this.triangularMeasurementActive?await this._setImageSource(this.imageMeasurementViewer,c,o,l,i,r):await this._setImageSource(this._imageViewer,c,o,l,i,r);break;case"panoramic":if(Ht.has(c.toUpperCase())){const{selectedPoint:e}=this,{pitch:a,yaw:i,cameraLocation:s,viewAngle:n}=t;this._panoramicViewer.imageSource=o;let l=i??0;"number"==typeof n?l=n-l:s&&e&&(l=await se(s,e)-l),this._panoramicViewer.pitch=a??0,this._panoramicViewer.yaw=l,await this._panoramicViewer.loadImage(r)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:c});break}},this._loadMeasurementViewerImage=async e=>{const{currentBestFeatureMeasurementImage:t,layer:a,mode:i}=this;if(this.imageMeasurementViewer.clearGraphics(),!a||!t||"none"===i||"video"===i)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:l,cameraPitch:c,objectId:h,cameraOrientation:m,location:d}=r,p=(l??0)+(o??0),g=d.spatialReference.isWGS84&&4!==m?.type?D(d):new T(d);let f=s;if(Te(s))try{f=await je(a,h,e)}catch(w){if(y(w))return;return bt(w)?(u.getLogger(this).error(w),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${h}`)):(u.getLogger(this).error(w,{[a.objectIdField]:h,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${h}`))}try{await this.loadImageFromSource(f,{imageRotation:p,options:e,pitch:c,yaw:n,mode:i,cameraLocation:g}),v(e)}catch(w){y(w)||this.loadImageError(w)}},this._loadViewAdapter=async e=>{const{view:t}=this;if(t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/view/MapViewAdapter.js");v(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/view/SceneViewAdapter.js");v(e),this._adapter=new t(this);break}}else this._adapter=null},this._mapImageConversionToolViewClickHandler=e=>{e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.plotMapPoint(e.mapPoint)},this._measurementImageClickHandler=e=>{e.stopPropagation(),e.preventDefault();const{sketchTriangular:t,triangularMeasurementActive:a,currentBestFeatureMeasurementImage:i,triangulatedMeasurementGraphic:r}=this;t&&a&&i&&r&&"active"!==t.state&&(t.update([r],{tool:"reshape"}),this.updatingTriangularMeasurementState=!0)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=r(async t=>{const{pointerType:a,button:i,mapPoint:r}=e;if(("mouse"!==a||0===i)&&r)return e.stopPropagation(),e.preventDefault(),this._updatingHandles.addPromise(this.loadBestImage(r,{signal:t}))})},this.plotSelectedPointOnImage=async(e,a)=>{if(await f(a),!e)return;const i=new T({...C(e)?e.toJSON():e});if("default"===this.mode)i.x-=.5,i.y=.5-i.y,i.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:i,symbol:lt}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=oe(e,i,r),n=ne(s,o);this._crossSymbol=new t({geometry:new T(n,H.WebMercator),symbol:ct}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this)}initialize(){this.addHandles([M(()=>this.view,()=>this.load(),_),M(()=>this.view?.map,(e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)},P),M(()=>this.view?.map?.allLayers?.length,e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)},P),M(()=>[this.state,this.mapImageConversionToolState,this.view],()=>{this._createViewClickHandle(),this._createImageClickHandle()},_),M(()=>[this.triangularMeasurementActive,this.currentBestFeatureMeasurementImage],()=>{this._createTriangularImageClickHandle()},_),M(()=>[this.state,this.imageLocationToolState,this.view],(e,t)=>{if(this._createImageLocationHandle(),!this.imageLocationToolState)return this.clearPreviousGroundLocation(),void this._resetCursor();e[1]!==t?.[1]&&this._setMeasurementCursor()},_),M(()=>this.measureType,()=>{this.clearPreviousMeasurements()},_),M(()=>this.bestFeatureAngle,(e,t)=>{this.previousFeatureAngle=t??0},_),M(()=>this.currentBestFeature,async(e,t)=>{d(this._featureChangedTask),this._featureChangedTask=r(async a=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:a}])),await this._featureChangedTask.promise},{sync:!0}),M(()=>this.currentBestFeatureMeasurementImage,(e,t)=>{d(this._featureChangedTask),t&&e!==t&&(this.measurementVectors=[],this.triangulatedPoint=null,this.sketchTriangularGraphicsLayer?.graphics.destroyAll()),this._featureChangedTask=r(async a=>{await this.determineWorkflowForTriangularMeasurement(e,t,{signal:a}),v(a),this._reorderTriangularSketchLayer()})},_),M(()=>this.triangularMeasurementActive,(e,t)=>{t&&!e&&(this.measurementVectors=[],this.currentBestFeatureMeasurementImage=null,this.triangulatedDistanceMeasurement=null,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaAccuracy=0,this.sketchTriangularGraphicsLayer?.graphics.destroyAll(),this.clearReferencePointOnImage(),this.imageMeasurementViewer.clearImage(),this.imageMeasurementViewer.clearGraphics())}),M(()=>this.mode,e=>{switch(this.removeHandles(xt.interactionHandles),e){case"default":this.addHandles(M(()=>{const{state:e}=this;return"image-loaded"===e?this._imageViewer.imagePointsInView:null},e=>{e&&(d(this._updateFootprintTask),this._updateFootprintTask=r(async t=>{await this.updateFootprint(e,{signal:t})}))},{..._,equals:(e,t)=>a(e,t,h)}),xt.interactionHandles);break;case"video":this.addHandles(M(()=>{const{footprintExtent:e}=this;if(e)return Ve},e=>{e&&(d(this._updateFootprintTask),this._updateFootprintTask=r(async t=>{await this.updateFootprint(e,{signal:t})}))},{..._,equals:(e,t)=>a(e,t,h)}),xt.interactionHandles);break;case"panoramic":this.addHandles(M(()=>{const{currentBestFeature:e,state:t,_panoramicViewer:a}=this,{imageSize:i,vfov:r,hfov:s,pitch:o,yaw:n}=a;return e&&i&&!t.includes("loading")&&null!=r&&null!=s&&null!=o&&null!=n?[r,s,n,o]:null},e=>{if(!e||this.state.includes("loading"))return;const[t,a,i,s]=e;this.currentNode&&(this.currentNode.currentHeading=i+(this.currentNode.heading??0),this.currentNode.currentPitch=s+(this.currentNode.pitch??0)),d(this._updateFootprintTask),this._updateFootprintTask=r(async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:a,yaw:i,pitch:s},{signal:e}),this._updateFootprintTask=null})},{equals:(e,t)=>a(e,t,h)}),xt.interactionHandles)}},_),M(()=>[this.brightness,this.contrast,this.sharpness],()=>{const{_imageViewer:e,brightness:t,contrast:a,mode:i,sharpness:r}=this;"default"===i&&(e.brightness=t,e.contrast=a,e.sharpness=r)},_),M(()=>this.activeViewer?.imageRenderer,()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)}),M(()=>this.activeViewer,e=>{this.removeHandles(xt.hittestHandles),e&&this.addHandles(b(()=>e,"hittest-response",this._handleImageHitTestResponse),xt.hittestHandles)})]),this.when().finally(()=>{this.notifyChange("state")})}destroy(){this.currentBestFeature=null,this._updateFootprintTask=d(this._updateFootprintTask),this._clickTask=d(this._clickTask),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=p(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),this.videoViewModel=p(this.videoViewModel),this._crossSymbol=p(this._crossSymbol),this._referencePointOnGround=p(this._referencePointOnGround),this._referencePointOnImage=p(this._referencePointOnImage),this._locationPointOnImage=p(this._locationPointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy(),this._imageViewer.destroy(),this.imageMeasurementViewer.destroy(),this._panoramicViewer.destroy()}get activeLayer(){return o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:a}=this;switch(a){case"default":return e;case"panoramic":return t;default:return null}}get accuracyParametersMissing(){return this.layer?.orientationAccuracy?.every(e=>0===e)??!0}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",m(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",m(e,-10,10))}get currentNode(){const{currentBestFeature:e,navigationNodes:t}=this;return t.find(t=>t.id===e?.attributes.objectId)}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){const{currentBestFeature:e}=this;if(!e)return!1;const t=e.attributes.imagePath?.trim();return _t(t)||Te(t)}get imageLoaded(){return o(u.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get invalidCameraHeading(){return this.currentBestFeature?.attributes?.cameraHeading===ke}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get layerView(){const{layer:e,view:t}=this;if(e&&t)return t.allLayerViews.find(Pt(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?fe(e):null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";if(e.orientedImageryType?.includes("video"))return"video";const{horizontalFieldOfView:t,isSpherical:a}=e;return 360===t||a?"panoramic":"default"}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?Ae.map(t=>e[t]):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",m(e,0,1))}get sketchGraphicsLayer(){return this.sketch?.layer}get state(){const{mode:e,disabled:t,_updatingHandles:{updating:a},_featureChangedTask:i}=this;if(t)return"disabled";if(!this.isFulfilled()||a||!1===i?.finished)return"loading";if(this.isRejected())return"error";if("error"===this.displayMessage?.type)return"image-load-error";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state;case"video":return this.videoElement?.loaded?"video-loaded":"video-not-loaded"}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map(({attributes:{imagePath:e,objectId:t,cameraRoll:a,imageRotation:i}})=>{const r=e?.trim();return _t(r)||Te(r)?{url:r,objectId:t,rotation:(a??0)+(i??0)}:null}).filter(i)):null}set view(e){this._set("view",e)}get _sketchGraphicsLayer(){const{mode:e}=this;switch(e){case"panoramic":return new U({elevationInfo:{mode:"absolute-height"}});case"default":return new U;default:return}}get _overlaysView(){return this.view?.layerViews.find(({layer:e})=>e===this._overlays)}beforeLoad(){this.view?.closePopup(),this.displayMessage=null,this.clearPreviousGroundLocation(),this.triangularMeasurementActive=!1,this.currentBestFeatureMeasurementImage=null,this.measureType=null,this.imageLocationToolState=!1,this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),this._overlays?.removeAll()}async computeHeight(e,t,a=!0){const{currentBestFeature:i,activeViewer:r,layer:s,footprintExtent:o}=this,n=r?.imageSize,l=i?.attributes,c=s?.orientationAccuracy;if(!l||!n||!e||e.length<2||!c)return;const h="panoramic"===t?await this.getMeasurementPropertiesPanoramic():le(l,n[0],n[1]),u=e.at(0),m=e.at(-1);if(!(h&&u&&m&&c&&o))return;const d=[m,u],p=Be(d,!1),g="panoramic"===t?await xe(d,h,c,i,!0,!1):await He(d,h,c,!0,a);if(!g)return;const y="panoramic"===t?await Ee(c,p,h,g,i,!0):await ze(c,p,h,g,!0);return y?{value:g,accuracy:y}:{value:g}}async calculateAreaMeasurement(e,t,a){if(e.length<3||!this.currentBestFeature||!this.activeViewer?.imageSize||"none"===t)return null;const i="default"===t?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();return v(a),i?"default"===t?await De(e,i,!0):await Ue(e,i,!0,a):null}async calculateDistanceMeasurement(e,t,a){const{currentBestFeature:i,activeViewer:r}=this;if(e.length<2||!i||!r?.imageSize||"none"===t)return null;const s="default"===t?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();return v(a),s?"default"===t?await Ne([e.at(0),e.at(-1)],s,!0):await We([e.at(0),e.at(-1)],s,!0):null}async calculateAccuracy(e,t,a){const{layer:i,currentBestFeature:r,activeViewer:s}=this,o=i?.orientationAccuracy,n=o?.every(e=>0===e)||!o?.length;if("area"===t&&e.length<3||"distance"===t&&e.length<2||!r||!s?.imageSize||n)return null;let l=null;if(this.triangularMeasurementActive&&this.currentBestFeatureMeasurementImage&&this.imageMeasurementViewer?l=await this.getMeasurementProperties(this.currentBestFeatureMeasurementImage,this.imageMeasurementViewer):(l=await this.getMeasurementProperties(),v(a)),!l)return null;const c="area"===t?await De(e,l,!0):await Ne([e.at(0),e.at(-1)],l,!0);v(a);const{updateElevationProps:h,...u}=l,m=qe(u,o);if(!m?.length)return null;const d=m.map(e=>({...e,updateElevationProps:h})).map(async i=>{const r="area"===t?await De(e,i,!0):await Ne([e.at(0),e.at(-1)],i,!0);if(v(a),r&&c){if("area"===t){const e="number"!=typeof r?r.area:null;return e?Math.abs(e-c.area):null}return Math.abs(r-c)}return null}),p=await Promise.all(d);v(a);const g=p.filter(e=>null!==e);return 0===g.length?null:$e(g)}async calculateLocationAccuracy(e,t,a="default",i){const{layer:r,currentBestFeature:s}=this,o=r?.orientationAccuracy,n=this.view?.spatialReference,l=o?.every(e=>0===e)||!o?.length;if(!s||l)return null;const c="default"===a?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();if(v(i),!c)return null;const{updateElevationProps:h,...u}=c,m="default"===a?qe(u,o):Je(u,o);if(!m?.length)return null;const d=m.map(e=>({...e,updateElevationProps:h})).map(async r=>{const{updateElevationProps:s,...o}=r;let l="default"===a?await ee(e,o,s):await te(e,o,s);return v(i),n&&!l.spatialReference.equals(n)&&(l=await x(l,n),v(i)),l&&t?[Math.abs(l.x-t.x),Math.abs(l.y-t.y),l.z&&t.z?Math.abs(l.z-t.z):0]:null}),p=await Promise.all(d);if(v(i),!p?.length)return null;const g=p.map(e=>[e?.[0]??0,e?.[1]??0,e?.[2]??0]),[y,f,w]=Ze(g);return{x:y,y:f,z:w}}async calculateAccuracyPanoramic(e,t,a){const{layer:i,currentBestFeature:r,activeViewer:s,mode:o}=this,n=i?.orientationAccuracy,l=n?.every(e=>0===e)||!n?.length;if("area"===t&&e.length<3||"distance"===t&&e.length<2||!r||!s?.imageSize||l||"panoramic"!==o)return null;const c=await this.getMeasurementPropertiesPanoramic();if(v(a),!c)return null;const h="area"===t?await Ue(e,c,!0):await We([e.at(0),e.at(-1)],c,!0);v(a);const{updateElevationProps:u,...m}=c,d=Je(m,n);if(!d?.length)return null;const p=d.map(e=>({...e,updateElevationProps:u})).map(async i=>{const r="area"===t?await Ue(e,i,!0):await We([e.at(0),e.at(-1)],i,!0);if(v(a),r&&h){if("area"===t){const e="number"!=typeof r?r.area:null;return e?Math.abs(e-h.area):null}return Math.abs(r-h)}return null}),g=await Promise.all(p);v(a);const y=g.filter(e=>null!==e);return 0===y.length?null:$e(y)}async calculateHeightMeasurementInfo(e,t,a){const{currentBestFeature:i,activeViewer:r}=this,s=r?.imageSize;if(!i||!r||!s?.length||"none"===t)return;const{attributes:o}=i,[n]=Be([e],"panoramic"!==t),l="panoramic"===t?await this.getMeasurementPropertiesPanoramic():le(o,s[0],s[1]);if("panoramic"===t){if(!l)return;const e=await Ke(n,l,i,a);if(!e)return;e?.heading>180&&(e.heading-=360);const t=Qe(n,e),r=S([n.x,n.y],[e.x,e.y]);if(!t||!r)return;return{measurementAngle:t,tempDistance:r}}const c=await Xe(n,l,a);if(!c)return;const h=Ye(n,c),u=S([n.x,n.y],[c.x,c.y]);return h&&u?{measurementAngle:h,tempDistance:u}:void 0}async calculateTriangulatedMeasurements(e){switch(this.measureType){case"distance":{this.triangulatedDistanceMeasurement=await tt(this.measurementVectors);const t=await this.calculateAccuracy(e,"distance");if(t&&this.triangulatedDistanceMeasurement?.distance){const e=Math.atan(t/this.triangulatedDistanceMeasurement.distance);this.triangulatedDistanceAccuracy={distanceAccuracy:t,angleAccuracy:e}}break}case"area":if(this.currentBestFeatureMeasurementImage?.geometry.spatialReference){const t=await et(this.measurementVectors,this.currentBestFeatureMeasurementImage.geometry.spatialReference);this.triangulatedAreaMeasurement=t,this.triangulatedAreaAccuracy=await this.calculateAccuracy(e,"area")??this.triangulatedAreaAccuracy}}}clearPreviousMeasurements(){this.clearMeasurementGraphics(),this.resetMeasurementData(),this.stopMeasurement()}clearPreviousGroundLocation(){this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.pixelCoordinates=null,this.clearLocationPointOnImage()}clearMeasurementGraphics(){this.measurementGraphic&&(this.activeViewer?.removeGraphic(this.measurementGraphic),this.measurementGraphic=null),this.heightGraphic&&(this.activeViewer?.removeGraphic(this.heightGraphic),this.heightGraphic=null),this.triangularMeasurementActive&&this.sketchTriangularGraphicsLayer?.graphics.destroyAll()}digitizeCancel(){return this.sketch?.cancel()}digitizeCanRedo(){return this.sketch?.canRedo()??!1}digitizeCanUndo(){return this.sketch?.canUndo()??!1}digitizeComplete(){return this.sketch?.complete()}async digitizeCreate(e,t){const{sketch:a,dataCaptureLayer:i}=this;if(!a)throw zt();Ge(i,e,a),await a.create(e,{...t,defaultZ:0})}digitizeDelete(){if(!this.sketch)throw zt();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw zt();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw zt();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw zt();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw zt();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw zt();return this.sketch.update(e,t)}async displayHeightResults(){const{currentBestFeature:e,activeViewer:t,heightMeasurementPixels:a,mode:i}=this,r=t?.imageSize,s=e?.attributes;if(!s||!r)return;const o=await this.computeHeight(a,i);o?.value&&o?.accuracy&&(this.heightMeasurementResult=o.value,this.heightMeasurementAccuracy=o.accuracy)}filterByFootprints(e,t,a=!1){const i=[],r=[],s=[];return e.forEach(e=>{const{layer:{coveragePercent:o},attributes:n}=e;let l;const{polygon:c,frustum:h}=J(n);if(l=c.clone(),n.isInspection&&(l=Z(n)),o&&(l=K(l,o)),a||!t||Q(l,t)){s.push(e);const{geometry:t,objectId:a,cameraHeight:o,cameraHeading:l}=n,u=t.clone();u.z=o,u.imageID=a,this.pointSources.push(u),l!==ke&&(i.push(c),h&&r.push(h))}}),{features:s,polygons:i,frustums:r}}getMeasurementProperties(e=this.currentBestFeature,t=this.activeViewer){if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:i}=e,{elevationSource:r,cameraHeight:s}=i,o=le(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?x(n,H.WebMercator):Promise.resolve(n)).then(e=>(n=e,ce(n.spatialReference,n.z??0,s,{elevationSample:a,elevationSource:r,extent:this.footprintExtent}))).then(t=>("elevationSample"in t&&he(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t}))}getMeasurementPropertiesPanoramic(){const{currentBestFeature:e,activeViewer:t}=this;if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:i}=e,{elevationSource:r,cameraHeight:s}=i,o=ue(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?x(n,H.WebMercator):Promise.resolve(n)).then(e=>(n=e,ce(n.spatialReference,n.z??0,s,{elevationSample:a,elevationSource:r,extent:this.footprintExtent}))).then(t=>("elevationSample"in t&&he(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t}))}async deleteDataCaptureFeatures(e){const{dataCaptureLayer:t}=this;if(!t)throw new n("orientedimagery","Data capture layer is not available");return t.queryFeatures({objectIds:e}).then(({features:e})=>t.applyEdits({deleteFeatures:e}))}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[Ae[e]],a=t?.at(0);a&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(a):this._updateCurrentBestFeature(a))}handleFeatureClick(e){const{sector:t,featureIndexInSector:a}=e;if(isNaN(a))return;const i=this._sectorData?.[t],r=i?.at(a);r&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(r):this._updateCurrentBestFeature(r))}handleDrawCursorUpdateEvents(e){const{measurementAngle:t,tempDistance:a,heightMeasurementPixels:i,mode:r,activeViewer:s,currentBestFeature:o}=this,n=s?.imageSize;if(!e.vertices||!n||!o)return;const l=at(e.vertices.at(-1),r,n);if(i.length<1||!l||!a||!t||"none"===r)return;const c=it(i[0],l,t);if(!c?.length)return;this.heightMeasurementPixels.push(c),"panoramic"===r?this.createPolylineGraphicPano():this.createPolylineGraphic();const h=rt(o.attributes.location.spatialReference),u=st(this.heightMeasurementPixels,a,h);u&&(this.heightMeasurementResult=u)}async handleDrawVertexAddEvents(e,t){const{currentBestFeature:a,activeViewer:i,heightMeasurementPixels:r,mode:s}=this;if(!a||!i||!e.vertices?.length||"none"===s)return;const o=i?.imageSize;if(!r.length&&o){const a=at(e.vertices.at(-1),s,o);this.heightMeasurementPixels.push(a);const i=await this.calculateHeightMeasurementInfo(a,s,t);if(!i?.measurementAngle||!i?.tempDistance)return;this.measurementAngle=i.measurementAngle,this.tempDistance=i.tempDistance}}load(e){return this.addResolvingPromise(this._loadViewAdapter(e).catch(e=>{if(!y(e))throw e})),this}async loadBestImage(e,t){return this.selectedPoint=Y(e),this.beforeLoad(),this._fetchFeaturesWithController(e,t)}loadImageError(e){u.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async loadSketch(e){if(!this.sketch){const t=import("../Sketch/SketchViewModel.js"),{default:a}=await t;v(e),this.sketch=new a({layer:this._sketchGraphicsLayer,view:this.activeViewer?.imageRenderer,updateOnGraphicClick:!1,defaultUpdateOptions:{reshapeOptions:{edgeOperation:"none",shapeOperation:"none",vertexOperation:void 0},enableMoveAllGraphics:!1,enableRotation:!1,enableScaling:!1,multipleSelectionEnabled:!1,toggleToolOnClick:!1,tool:"transform"}})}return this.sketch}async loadMeasurementAdapter(e){if(!this.sketchAdapter){const t=import("./adapters/sketch/MeasurementAdapter.js"),{default:a}=await t;if(v(e),this.sketchAdapter=new a({viewModel:this}),!this.sketchAdapter.viewModel.isResolved())return}return this.sketchAdapter}async loadTriangulatedMeasurementAdapter(e){if(!this.triangulatedMeasurementAdapter){const t=import("./adapters/sketch/TriangulatedMeasurementAdapter.js"),{default:a}=await t;if(v(e),this.triangulatedMeasurementAdapter=new a({viewModel:this}),!this.triangulatedMeasurementAdapter.viewModel.isResolved())return}return this.triangulatedMeasurementAdapter}async processFeatureResponse(e,t,a){const{features:i}=e;if(this._clearFeatureGeometries(),!this._checkFeatures(i))return;const{features:r,polygons:s,frustums:o}=this.filterByFootprints(i,t,a?.skipFilter);if(!this._checkFeatures(r))return;this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(o);const n=await this.processElevationSample(s,r,a);v(a),await this._updateElevationOfSelectedPointAndLocations(r,t,n),v(a),It(r,n);const l=this._processSuitableFeatures(r,t);this.updateSuitabilities(l,a?.loadBestImage)}async startMeasurement(e,t){this.sketch||await this.loadSketch(t),await this.loadMeasurementAdapter(t);const{sketch:a,sketchAdapter:i,activeViewer:r,mode:s}=this;if(!a||!i||!r||"none"===s)return;if(this.displayNewMeasurementButton=!1,"panoramic"===s&&(a.defaultCreateOptions.defaultZ=0),await a.create(e),"panoramic"===s){const{drawOperation:e}=a.view.activeTool;e.constraintsEnabled=!1,e._set("elevationDrawSurface",null)}const o=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;o&&this.sketch&&(this.sketch.polygonSymbol=ht(o),this.sketch.polylineSymbol="panoramic"===s?ut:mt(o,2.5))}startHeightMeasurement(){this.heightMeasurementPixels=[],this.displayNewMeasurementButton=!1,this.draw??=new be({view:this.activeViewer?.imageRenderer});this.draw.create("polyline").on(["cursor-update","vertex-add","draw-complete"],e=>this.handleDrawEvents(e))}createPolylineGraphic(){const e=[this.heightMeasurementPixels[0],this.heightMeasurementPixels.at(-1)],a=this.activeViewer?.imageRenderer.spatialReference;if(this.heightGraphic)this.heightGraphic.geometry=new B({paths:[e],spatialReference:a});else{const i=new B({paths:[e],spatialReference:a}),r=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;this.heightGraphic=new t({geometry:i,symbol:mt(r,2.5)}),this.activeViewer?.addGraphic(this.heightGraphic)}}createPolylineGraphicPano(){const e=this.activeViewer?.imageRenderer.spatialReference,a=this.activeViewer?.imageSize;if(!a)return;const i={x:this.heightMeasurementPixels[0][0],y:this.heightMeasurementPixels[0][1]},r={x:this.heightMeasurementPixels.at(-1)[0],y:this.heightMeasurementPixels.at(-1)[1]},{heading:s,pitch:o}=oe(i,a[0],a[1]),{heading:n,pitch:l}=oe(r,a[0],a[1]),c=[[...ne(s,o)],[...ne(n,l)]];if(this.heightGraphic)this.heightGraphic.geometry=new B({paths:[c],spatialReference:e});else{const a=new B({paths:[c],spatialReference:e});this.heightGraphic=new t({geometry:a,symbol:ut}),this._panoramicViewer.addGraphic(this.heightGraphic,0)}}async editOverlayedGraphics(e){this.sketchTriangularGraphicsLayer||this._initializeSketchTriangularGraphicsLayer(),this.sketchTriangularGraphicsLayer?.destroyed&&this._handleDestroyedTriangularSketchLayer(),this.sketchTriangularGraphicsLayer.add(e),this.sketchTriangular||(this._initializeSketchTriangular(),await this.loadTriangulatedMeasurementAdapter()),this.updateOverlayedGeometry(e)}updateOverlayedGeometry(e){this.sketchTriangular?.update([e],{tool:"reshape"})}async processMeasurementVectors(e){this.triangularMeasurementActive&&this.currentBestFeature&&(this.measurementVectors?.length<2&&await this.updateMeasurementVectorsArray(e),2===this.measurementVectors.length&&await this.calculateTriangulatedMeasurements(e))}async updateMeasurementVectorsArray(e){const t=this.measurementVectors.length?this.currentBestFeatureMeasurementImage:this.currentBestFeature;if(t){const a=await this.computeMeasurementVector(e,t);a&&this.measurementVectors.push(a)}}async computeMeasurementVector(e,t){const{activeViewer:a,mode:i}=this,r=a?.imageSize;if(!e||!t||!r)return;const s=e.map(e=>[e[0]-.5,-.5-e[1]]),o=this.view?.spatialReference,n=[];for(let l=0;l<s.length;l++){const e={x:s[l][0],y:s[l][1]};let a=await this.getMapPoint(e,{feature:t,imageSize:r,mode:i});o&&!a.spatialReference.equals(o)&&(a=await x(a,o)),n.push(a)}return ot(n,t)}async handleDrawEvents(e,t){if(this.draw)switch(e.type){case"cursor-update":this.handleDrawCursorUpdateEvents(e);break;case"vertex-add":await this.handleDrawVertexAddEvents(e,t);break;case"draw-complete":await this.displayHeightResults()}}initializeMeasurement(e){switch(this.clearMeasurementGraphics(),this.resetMeasurementData(),e){case"distance":this.startMeasurement("polyline");break;case"area":this.startMeasurement("polygon");break;case"height":this.startHeightMeasurement()}}async overlayCameraLocations(e){const{activeViewer:a,currentBestFeature:i,overlayedCameraLocations:r,layer:s,mode:o,state:n,layerFloorFilterClause:l}=this,c=a?.imageSize;if(!c||!i||!s||"none"===o||n.includes("loading"))return;const{polygon:h}=J(i.attributes);if(a.removeManyGraphics(r.toArray()),r.removeAll(),e){const{features:e}=await s.queryFeatures({where:I(`${s.objectIdField} <> ${i.attributes.objectId}`,I(s.definitionExpression,l)),geometry:h,returnGeometry:!0,outFields:[s.objectIdField]}),n=await Promise.all(e.map(async e=>{const{attributes:a,geometry:r}=e,s=await this.getPixels(r,{feature:i,imageSize:c,mode:o}),n="panoramic"===o?dt():pt();return new t({attributes:a,symbol:n,geometry:s})}));r.addMany(n),a.addManyGraphics(r.toArray())}}overlayGraphicsOnImage(e,t){this.removeOverlayedGraphicsOnImage(e),this.overlayedMapFeatures.set(e,t),this.activeViewer?.addManyGraphics(t.toArray())}async overlayMapFeatures(e,a=!1){const{activeViewer:r,currentBestFeature:o,mode:n,state:l,layer:c}=this,h=r?.imageSize;if(!h||!o||"none"===n||"video"===n||l.includes("loading")||!c)return;const{polygon:m}=J(o.attributes);try{const{imageGeometryField:t,oiObjectIdField:a}=Le(e,c.imageGeometryField,c.imageReferenceField);this.imageGeometryField=t.name,this.oiObjectIdField=a.name}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",g)}const{features:d}=await e.queryFeatures({geometry:m,returnGeometry:!0,outFields:["*"]}),p=new s((await Promise.all(d.map(async i=>{const r=i.symbol?.clone()??e.renderer?.getSymbol(i)?.clone(),{attributes:s,geometry:l}=i,c=l,{imageGeometryField:m,oiObjectIdField:d}=this;if(m&&d&&Re(e,m,d)&&`${s[d]}`==`${o.attributes.objectId}`)try{return Oe(s,m,e,a,h,n,r)}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features","couldn't create graphic from attributes, geometry will be used",{error:g,feature:i,layer:e,imageGeometryField:this.imageGeometryField,imageReferenceField:this.oiObjectIdField})}switch(c?.type){case"point":{const i=await this.getPixels(c,{feature:o,imageSize:h,mode:n});return new t({attributes:s,layer:e,symbol:r,geometry:i,visible:e.visible&&a})}case"polygon":{const{rings:i,spatialReference:l}=c,u=i.map(e=>e.map(([e,t,a])=>new T({x:e,y:t,z:a,spatialReference:l}))),m=await Promise.all(u.map(async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then(e=>e.map(me))));return new t({attributes:s,layer:e,symbol:r,geometry:new j({rings:m,spatialReference:H.WebMercator}),visible:e.visible&&a})}case"polyline":{const{paths:i,spatialReference:l}=c,u=i.map(e=>e.map(([e,t,a])=>new T({x:e,y:t,z:a,spatialReference:l}))),m=await Promise.all(u.map(async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then(e=>e.map(me))));return new t({attributes:s,layer:e,symbol:r,geometry:new B({paths:m,spatialReference:H.WebMercator}),visible:e.visible&&a})}case"multipoint":{const{points:i,spatialReference:l}=c,u=i.map(([e,t,a])=>new T({x:e,y:t,z:a,spatialReference:l})),m=await this.getPixels(u,{feature:o,imageSize:h,mode:n}).then(e=>e.map(me));return new t({attributes:s,layer:e,symbol:r,geometry:new O({points:m,spatialReference:H.WebMercator}),visible:e.visible&&a})}}return null}))).filter(i));this.overlayGraphicsOnImage(`${e.id}`,p)}async getPixels(e,t){const{imageSize:a,mode:i,feature:r}=t,s=(await this.worldToImage(Array.isArray(e)?e:[e],r)).map(e=>{if("default"===i)return new T({x:e.x-.5,y:.5-e.y,spatialReference:H.WebMercator});const[t,r]=a,{heading:s,pitch:o}=oe(e,t,r),n=ne(s,o);return new T(n,H.WebMercator)});return Array.isArray(e)?s:s[0]}async getMapPoint(e,t){const{feature:a,mode:i,imageSize:r}=t,{elevationSample:s,attributes:o}=a,{elevationSource:n,location:l,cameraHeight:c}=o;let h=l.clone();h.spatialReference.isGeographic&&(h=await x(h,H.WebMercator));const u=await ce(l.spatialReference,l.z??0,c,{elevationSample:s,elevationSource:n,extent:this.footprintExtent});let m;if("elevationSample"in u&&he(u.elevationSample)&&(a.elevationSample=u.elevationSample),"default"===i){const t=le(o,r[0],r[1]);m=await ee(Array.isArray(e)?e:[e],{...t,cameraLocation:h},u)}else{const t=ue(o,r[0],r[1]);m=await te(Array.isArray(e)?e:[e],{...t,cameraLocation:h},u)}return Array.isArray(e)?m:m[0]}getActiveSectors(){return Ae.filter(e=>this._sectorData?.[e]?.length)}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new T({...e.toJSON()}),symbol:gt}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){if("image-loaded"===this.state)switch(this.clearReferencePointOnImage(),this.mode){case"default":{const a=C(e)?e.toJSON():e;a.x-=.5,a.y=.5-a.y,this._referencePointOnImage=new t({geometry:new T({spatialReference:this._imageViewer.imageRenderer.spatialReference,...a}),symbol:gt}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=oe(e,i,r),n=ne(s,o);this._referencePointOnImage=new t({geometry:new T(n,H.WebMercator),symbol:yt}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}plotLocationPointOnImage(e,t=!1){if("image-loaded"===this.state)switch(this.clearLocationPointOnImage(t),this.mode){case"default":this._plotLocationPointOnDefaultImage(e,t);break;case"panoramic":this._plotLocationPointOnPanoramicImage(e)}}removeAllOverlayMapFeatures(){this.overlayedMapFeatures.forEach(e=>{this._imageViewer.removeManyGraphics(e.toArray())}),this.overlayedMapFeatures.clear()}removeOverlayedGraphicsOnImage(e){const t=this.overlayedMapFeatures.get(e);t?.length&&(this.activeViewer?.removeManyGraphics(t.toArray()),this.overlayedMapFeatures.delete(e))}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._clickTask=d(this._clickTask)}resetVideo(){this.setMessage("onLoadMessage","info"),this.videoViewModel?.resetVideoHandler(),this._overlays?.removeAll(),this.videoViewModel=null,this.featureCache=[],this.currentBestFeature=null}resetMeasurementData(){this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.heightMeasurementPixels=[],this.measurementVectors=[],this.heightMeasurementResult=0,this.tempDistance=null,this.measurementAngle=null,this.heightMeasurementAccuracy=0,this.heightGraphic=null,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedMeasurementGraphic=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaAccuracy=0}async saveDrawing(){const{dataCaptureLayer:e,sketchAdapter:t}=this;if(!e||"data-capture"!==t?.type)return;const{pendingGraphics:a,savedGraphics:i}=t,r=a.get(e.id),s=r?.toArray();if(!r||!s?.length)return;const{addFeatureResults:o}=await this.saveDataCaptureFeatures(s),n=o.reduce((t,{objectId:a,globalId:i,error:r},o)=>{const n=s[o],{attributes:l}=n;return r?t.error.push(n):(a&&(l[e.objectIdField]=a),i&&e.globalIdField&&(l[e.globalIdField]=i),t.success.push(n)),t},{success:[],error:[]});i.addMany(n.success),r.removeAll(),r.addMany(n.error)}async saveDataCaptureFeatures(e){const{activeViewer:t,currentBestFeature:a,dataCaptureLayer:r,mode:s}=this,o=t?.imageSize;if(!o||!a||"none"===s||"video"===s)throw new n("orientedimagery","Image size, current best feature and mode are required to save data capture features");if(!r)throw new n("orientedimagery","Data capture layer is not available");const l=await Promise.all(e.map(async e=>{const t=e.clone(),{geometry:i}=t;if(!i)return;const n=i.type,l=r.hasZ,c=r.geometryType,h=n!==c,u=h?await import("./transformers.js"):null,m=u?.default[c],d=h?m?.(i):i;if(d)switch(d.type){case"point":return t.geometry=await this.getMapPoint(de(s,d,o),{feature:a,imageSize:o,mode:s}),l||(delete t.geometry.z,t.geometry.hasZ=!1),t.geometry.hasM=!1,t;case"polygon":{const e=await Promise.all(d.rings.map(async e=>this.getMapPoint(e.map(([e,t,a])=>de(s,{x:e,y:t,z:a},o)),{feature:a,imageSize:o,mode:s})));return t.geometry=new j({spatialReference:e[0][0].spatialReference,hasZ:l,hasM:!1,rings:e.map(e=>e.map(me))}),t}case"polyline":{const e=await Promise.all(d.paths.map(async e=>this.getMapPoint(e.map(([e,t,a])=>de(s,{x:e,y:t,z:a},o)),{feature:a,imageSize:o,mode:s})));return t.geometry=new B({spatialReference:e[0][0].spatialReference,hasZ:l,hasM:!1,paths:e.map(e=>e.map(me))}),t}}})),c=l.filter(i);return r.applyEdits({addFeatures:c}).then(e=>{const{addFeatureResults:t}=e;let a=0;const i=l.map(e=>{const i=t[a++];return e?i:{error:new n("orientedimagery","Error in saving data capture features"),objectId:null,globalId:null}});return{...e,addFeatureResults:i}})}async searchBestImage(e,t){try{const a=await W(e,t);a&&await this.processFeatureResponse(a,e.point,t)}catch(a){y(a)||(this.setMessage("imageLoadError","error",a.message),u.getLogger(this).error("error occurred while finding best image",a))}}selectTriangularMeasurementFeature(e){this.currentBestFeatureMeasurementImage=this.features?.find(({attributes:t})=>t.objectId===Number(e))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach(t=>{t.visible=e})}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach(t=>{t.visible=e})}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}setCurrentPanoramaView(e,t){this._panoramicViewer?.set({yaw:e,pitch:t})}async startDataCapture(e,t){const a=this.activeViewer?.imageRenderer,{oiObjectIdField:i,currentBestFeature:r}=this;if(!a||!r||!i)return;const{attributes:{objectId:o}}=r,n=this.overlayedMapFeatures.get(e.id)?.toArray()??[],l=[],c=[];for(const s of n)`${s.getAttribute(i)}`==`${o}`?l.push(s):c.push(s);this.overlayGraphicsOnImage(e.id,new s(c)),this.collectionId=e.id;const h=await this.loadSketch(t),u=await this.loadDataCaptureAdapter(t);v(t),h.layer.addMany(l),h.layer.blendMode="source-atop",u.savedGraphics.addMany(l);a.ui.find("zoom").visible=!1,a.map.layers.add(this.sketchGraphicsLayer)}async stopDataCapture(e=!1){this.sketch?.cancel(),this.sketchGraphicsLayer?.removeAll(),this.sketchAdapter=p(this.sketchAdapter),this.sketch=p(this.sketch),this.collectionId=null;const{dataCaptureLayer:t}=this,a=this.activeViewer?.imageRenderer;if(!a||a.destroyed)return;a.map.layers.remove(this.sketchGraphicsLayer),e&&t&&await this.overlayMapFeatures(t,!0);const i=a.ui.find("zoom");i&&(i.visible=!0)}stopMeasurement(){this.heightMeasurementPixels=[],this.draw?.reset(),this.sketch?.cancel()}toggleAllOverlayMapFeatures(e){this.overlayedMapFeatures.forEach(t=>{this._toggleVisiblity(t,e)})}toggleOverlayMapFeatures(e,t,a){const i=this.overlayedMapFeatures.get(e);i&&a&&this._toggleVisiblity(i,t)}toggleSelection(e){const{sketch:t}=this;t&&(t.updateOnGraphicClick=e,t.cancel())}async transformAndPlotReferencePointOnImage(e){const{feature:t,selectedLocation:a,options:i}=e;let r=!1,s=!1;const o=this.bestFeatureFootprint?.geometry;switch(o?.type){case"polygon":{const e=a.spatialReference.equals(o.spatialReference)?a:await x(a,o.spatialReference);r=o.contains(e);break}case"mesh":{const e=a.spatialReference.equals(o.spatialReference)?a:await x(a,o.spatialReference);s=o.extent.contains(e);break}}if(!r&&!s)return void this.clearReferencePointOnImage();const n=await this.worldToImage(a,t,i);if(n)return v(i),this.plotReferencePointOnImage(n),{x:n.x,y:n.y};this.clearReferencePointOnImage()}async triangulatedLocationWorkflow(e,t){if(this.currentBestFeature&&e){const{currentBestFeature:a}=this;this.triangulatedPoint&&(this.measurementVectors=[],this.triangulatedPoint=null,this.clearLocationPointOnImage(!0));const i=ot(e,a);if(!i)return;this.measurementVectors.push(i),await this.plotReferenceLocationPoint(e,t),v(t),this._createTriangularImageLocationHandle()}}async _calculateTriangulatedPointFromGroundPoint(e,t){if(this.currentBestFeatureMeasurementImage&&e){const{currentBestFeatureMeasurementImage:a}=this,i=ot(e,a);i&&this.measurementVectors.push(i);const r=await nt(this.measurementVectors);v(t),this.triangulatedPoint=r??this.triangulatedPoint}}async _fetchFeatures(e,t){if(!this.view)return;const a=this.layer;if(a){const i={include:a},r=this.view.toScreen(e);if(!r)return;const s=await this.view.hitTest(r,i);return this._processHitTestResults(a,s,t)}}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(a){if(y(a))return;this.setMessage("imageLoadError","error"),u.getLogger(this).error("error occurred while fetching features",a)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,features:a,invalidCameraHeading:i}=this,r=a.at(0);if(!e||!t||!r||!a||i)return void(this._sectorData=null);this._sectorData={};const o={};this._featureToSector=o;for(const h of Ae)this._sectorData[h]=new s;const n=e.map((e,t)=>({...e,featureIndex:t}));n.sort((e,t)=>e.trueSuitability-t.trueSuitability);const l=n.map(({distance:e})=>e),c=Math.max(...l);n.forEach(e=>{const{distance:t,angle:i,featureIndex:s}=e,n=t/c*Ce[2],l=kt(t,c),h=Vt(i);if(!this._sectorData)return;const u=Ce[3]+n*Math.sin(i*Math.PI/180),m=Ce[3]+n*Math.cos(i*Math.PI/180);let d;const p=a.at(s),g=p===r,{cameraPitch:y}=p.attributes,v=y<5;if(g&&v)d=-90;else{const e=u-Ce[3],t=m-Ce[3],a=t/Math.sqrt(e**2+t**2);let i=180*Math.acos(a)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(i*=-1),d=i}const f=""===l?h:`${l}_${h}`;g&&(d===this.bestFeatureAngle?this.previousFeatureAngle=d:this.bestFeatureAngle=d,this.navigatorCurrentBestFeature=v?null:{x:u,y:m,direction:h}),o[`${p.attributes.objectId}`]=f;const w=this._sectorData[f];w.add({angle:i,featureIndex:s,x:u,y:m,objectID:p.attributes.objectId,sector:f,featureIndexInSector:w.length})})}_handleDestroyedTriangularSketchLayer(){this.sketchTriangularGraphicsLayer&&(this.imageMeasurementViewer.imageRenderer.map.layers.remove(this.sketchTriangularGraphicsLayer),this.sketchTriangularGraphicsLayer=new U,this.imageMeasurementViewer.imageRenderer.map.layers.add(this.sketchTriangularGraphicsLayer),this.sketchTriangular&&(this.sketchTriangular.layer=this.sketchTriangularGraphicsLayer,this.sketchTriangular.view=this.imageMeasurementViewer.imageRenderer))}_initializeSketchTriangular(){this.sketchTriangular=new Bt({view:this.imageMeasurementViewer.imageRenderer,layer:this.sketchTriangularGraphicsLayer,updateOnGraphicClick:!1,defaultUpdateOptions:{toggleToolOnClick:!1}})}_initializeSketchTriangularGraphicsLayer(){this.sketchTriangularGraphicsLayer=new U,this.imageMeasurementViewer.imageRenderer.map.layers.add(this.sketchTriangularGraphicsLayer)}_initializeVideo(){if(this.videoElement||!this.currentBestFeature)return;this.removeHandles(xt.videoPlayerHandles),this.videoElement=new we({video:this.currentBestFeature.attributes.imagePath,georeference:new ve({extent:new L(Se)}),autoplay:!1}),this.videoElement.content?.loop&&(this.videoElement.content.loop=!1);const e=new N({source:this.videoElement,title:this.layer?.title,copyright:this.layer?.copyright});this.videoLayer=e,e&&this.videoMapView.map.layers.add(e),this.addHandles(Ct(this.videoMapView),xt.videoPlayerHandles),this.videoViewModel=new Rt({oiViewModel:this})}_plotLocationPointOnDefaultImage(e,a=!1){const i=C(e)?e.toJSON():e;i.x-=.5,i.y=.5-i.y,a?(this._correctedLocationPointOnImage=new t({geometry:new T({spatialReference:H.WebMercator,...i}),symbol:vt}),this.imageMeasurementViewer.addGraphic(this._correctedLocationPointOnImage,0)):(this._locationPointOnImage=new t({geometry:new T({spatialReference:H.WebMercator,...i}),symbol:vt}),this._imageViewer.addGraphic(this._locationPointOnImage,0))}_plotLocationPointOnPanoramicImage(e){const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=oe(e,i,r),n=ne(s,o);this._locationPointOnImage=new t({geometry:new T(n,H.WebMercator),symbol:ft}),this._panoramicViewer.addGraphic(this._locationPointOnImage,0)}_clearFeatureGeometries(){this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll()}_checkFeatures(e){return!!e?.length||(this.setMessage("noImageError","error"),this.currentBestFeature=null,!1)}async _getElevationSampleFromGround(e,t,a){if(!e[0])return;const i=await R(e);if(this._updateFootprintWithFeatures(t,i),this.view?.supportsGround)try{return await this.view.map.ground.createElevationSampler(this.footprintExtent,a)}catch(r){y(r)||u.getLogger(this).error(r)}}async processElevationSample(e,t,a){const{elevationSource:i}=t[0].attributes,r=await this._getElevationSampleFromGround(e,t,a);return r||(i&&this.footprintExtent&&X(i)?await ie({extent:this.footprintExtent,lod:i.lod,url:i.url,rasterFunction:i.rasterFunction}):void 0)}_processSuitableFeatures(e,t){return $({features:e,selectedPoint:t,camera:At(this.view)?this.view.camera:null,currentImage:this.currentBestFeature})}async _processHitTestResults(e,t,a){const{screenPoint:i,results:[r]}=t,s="graphic"===r?.type&&this.shouldShowSelectedImage,o=r?.mapPoint??this.view?.toMap(i);if(!o)return;o.x=z(o.x,o.spatialReference);const{layerFloorFilterClause:n}=this,l=e.spatialReference.equals(o.spatialReference)?o:await x(o,e.spatialReference),c=l.spatialReference.isGeographic?D(l):l,h=I("1=1",I(e.definitionExpression,n)),u=c.spatialReference.isGeographic?1:V(c.spatialReference),m={layerInstanceOrURL:e,point:c,queryParams:{where:h,maximumDistance:e.maximumDistance?e.maximumDistance/u:void 0,objectIds:s?[r.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(m,a)}async _queryAndLoadByObjectId(e,t,a,i){this.displayMessage=null;const{response:r}=await jt(e,t,a,i);if(v(i),!r?.features?.length)throw new Tt(t);const s=Y(J(r.features[0].attributes).polygon.centroid),o=V(s.spatialReference);this.selectedPoint=s;const n={layerInstanceOrURL:e,point:s,queryParams:{where:I(I("1=1",I(e.definitionExpression,a)),`${e.objectIdField} <> ${t}`),maximumDistance:e.maximumDistance?e.maximumDistance/o:void 0}},l=await W(n,i);v(i);const{features:c}=l;return c.push(r.features[0]),await this.processFeatureResponse(l,s,{...i,loadBestImage:!1})}_reorderTriangularSketchLayer(){const e=this.imageMeasurementViewer.imageRenderer.map.layers?.length;this.sketchTriangularGraphicsLayer&&e&&this.imageMeasurementViewer.imageRenderer.map.layers.reorder(this.sketchTriangularGraphicsLayer,e-1)}_resetCursor(){const{activeViewer:e,imageMeasurementViewer:t}=this;e&&this.removeHandles(xt.activeViewerCursorHandles),t&&this.removeHandles(xt.imageViewerCursorHandles)}async _setImageSource(e,t,a,i,r,s){e.imageSource={datasetFormat:t.toUpperCase(),url:a.split("?")[0]},e.customParameters=Object.fromEntries(i),e.imageRotation=r??0,await e.loadImage(s)}_setMeasurementCursor(){const{activeViewer:e,imageMeasurementViewer:t,triangularMeasurementActive:a}=this;e&&this.addHandles(e.imageRenderer.acquireCursor("crosshair","high"),xt.activeViewerCursorHandles),t&&a&&this.addHandles(t.imageRenderer.acquireCursor("crosshair","high"),xt.activeViewerCursorHandles)}_toggleVisiblity(e,t){e.forEach(e=>{e.visible=t})}async _updateElevationOfSelectedPointAndLocations(e,t,a,i){const r=he(a),{location:s,cameraHeight:o}=e[0].attributes,n=await ce(s.spatialReference,s.z,o,{elevationSample:r?a:void 0,elevationSource:r?void 0:e[0].attributes.elevationSource,extent:this.footprintExtent},i);v(i);const[l,...c]=await ae([t,...e.map(e=>e.attributes.geometry.clone())],n);v(i),t.elevation=l.z,e.forEach((e,t)=>{e.attributes.elevation=c[t].z})}_updateFeatures(e,t=!0){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),this.navigationNodes.removeAll(),this.navigationNodes.addMany(e.map(e=>{const{geometry:t,attributes:a}=e,{isSpherical:i,cameraHeading:r,cameraPitch:s}=a;return new Lt({geometry:t,attributes:a,currentHeading:i?0:r,currentPitch:i?0:s})})),e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll(),this._updateGroundElevation=!0,t&&(this.currentBestFeature=e[0]),"video"===this.mode&&(this._initializeVideo(),this.videoElement?.loaded&&this.videoViewModel?.playVideoFromSelectedLocation(e[0]))}_updateFootprintWithFeatures(e,t){const a=[];for(const{attributes:{geometry:i}}of e)t.contains(i)||a.push([i.x,i.y]);a.sort((e,t)=>+E([e,t])),t.addRing(a),this.footprintExtent=Me(t.extent,2,2)}async _updatePointsAndPolygons(e){const{pointSources:a,currentBestFeature:i,currentCoverageVisible:r,isAdditionalPointSourcesVisible:s,mode:o,layer:n}=this;if(i&&(this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),!this.invalidCameraHeading)){await(this._adapter?.createFootprints(e)),v(e);for(const e of a)e.imageID===i.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:wt,visible:r}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:Ft,visible:s}));if("video"===o&&n&&!this.featureCache.length){const e=await q(n,i.geometry.spatialReference);e.features?.length&&(this.featureCache=e.features)}}}_updateCurrentBestFeature(e){if(!e)return;if(this.currentBestFeature=this.features?.at(e.featureIndex),"video"===this.mode)return void(this.currentBestFeature&&this.videoViewModel?.playVideoFromSelectedLocation(this.currentBestFeature));const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let a;if(t)a=-90;else{const t=e.x-Ce[3],i=e.y-Ce[3],r=i/Math.sqrt(t**2+i**2);let s=180*Math.acos(r)/Math.PI;(t<0&&i<0||t<0&&i>0)&&(s*=-1),a=s}a===this.bestFeatureAngle?this.previousFeatureAngle=a:this.bestFeatureAngle=a,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}_updateImageMeasurementBestFeature(e){e&&(this.currentBestFeatureMeasurementImage=this.features?.at(e.featureIndex))}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics(),this.imageMeasurementViewer.clearGraphics()}clearReferencePointOnImage(){this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage=p(this._referencePointOnImage))}clearLocationPointOnImage(e=!1){this._locationPointOnImage&&!e&&(this._imageViewer.removeGraphic(this._locationPointOnImage),this._panoramicViewer.removeGraphic(this._locationPointOnImage),this._locationPointOnImage=p(this._locationPointOnImage)),this._correctedLocationPointOnImage&&(this.imageMeasurementViewer.removeGraphic(this._correctedLocationPointOnImage),this._correctedLocationPointOnImage=p(this._correctedLocationPointOnImage))}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}async plotReferenceLocationPoint(e,t){if(this.currentBestFeatureMeasurementImage){const a=await this.worldToImage(e,this.currentBestFeatureMeasurementImage,{signal:t});v(t),a&&this.plotLocationPointOnImage(a,!0)}}setMessage(e,t,a,i){this.displayMessage={key:e,type:t,data:a,map:i}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,invalidCameraHeading:a,selectedPoint:i,activeViewer:r}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=p(this._crossSymbol)),!i||!t||"image-loaded"!==r?.state||a)return;let s;try{s=await this.worldToImage(i,t,e),v(e),await this.plotSelectedPointOnImage(s,e)}catch(o){y(o)||u.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:o,selectedPoint:i,feature:t})}}async worldToImage(e,t,a){const{footprintExtent:i}=this,{imageSize:r}=this.activeViewer;if("none"===this.mode||!t||!r||!i)return;const{attributes:{location:s,elevationSource:o,cameraHeading:n,cameraHeight:l},elevationSample:c}=t;let h=s.clone();const u=await ce(s.spatialReference,s.z??0,l,{elevationSample:c,elevationSource:o});t.elevationSample=u.elevationSample;const m=Array.isArray(e)?e:[e];let d,p=await Promise.all(m.map(e=>new Promise(t=>{if(!e.hasZ)return t(ae(e,u));t(e)})));if(s.spatialReference.isGeographic&&(h=await x(h,H.WebMercator,a)),p=await Promise.all(p.map(async e=>h.spatialReference.equals(e.spatialReference)?e:await x(e,h.spatialReference,a))),v(a),"panoramic"===this.mode)d=ye(p,{imageHeight:r[1],imageWidth:r[0],cameraHeading:n,cameraLocation:h});else{const e=pe(t.attributes,r[0],r[1]);d=ge(p,{...e,cameraLocation:h})}return Array.isArray(e)?d:d[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:a,additionalCameraLocations:i,currentBestFeature:r,currentBestFeatureLocation:s,currentCoverageVisible:o,selectedPoint:n,view:l,_adapter:c,mode:h}=this,{attributes:{objectId:u},elevationSample:m}=r;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),e&&!this.invalidCameraHeading&&(e.visible=o,this.bestFeatureCurrentFootprint=e),l){const e=[...a,...i,s].filter(St);l.supportsGround&&m&&c?.updateGroundElevation&&(this._updateGroundElevation&&c.updateGroundElevation(e,m),"panoramic"===h&&c.updateGroundElevation([this.bestFeatureCurrentFootprint],m)),this._updateGroundElevation=!1,n&&(e.splice(-2,0,this.bestFeatureCurrentFootprint),e.push(new t({geometry:n.clone(),symbol:lt.clone(),attributes:{imageID:u}}))),this._overlays.graphics.addMany(e)}}else if(l){if(this.invalidCameraHeading)return;this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,l?.supportsGround&&m&&c?.updateGroundElevation&&"panoramic"===h&&c.updateGroundElevation([e],m),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([k()],Dt.prototype,"activeLayer",null),e([k({readOnly:!0})],Dt.prototype,"activeViewer",null),e([k()],Dt.prototype,"accuracyParametersMissing",null),e([k()],Dt.prototype,"additionalFeatures",void 0),e([k({type:s.ofType(t)})],Dt.prototype,"additionalCameraLocations",void 0),e([k({type:s.ofType(t)})],Dt.prototype,"additionalFootprints",void 0),e([k()],Dt.prototype,"areaMeasurementResult",void 0),e([k()],Dt.prototype,"areaMeasurementAccuracy",void 0),e([k()],Dt.prototype,"bestFeatureAngle",void 0),e([k()],Dt.prototype,"bestFeatureCurrentFootprint",void 0),e([k({type:t})],Dt.prototype,"bestFeatureFootprint",void 0),e([k({type:Number})],Dt.prototype,"brightness",null),e([k()],Dt.prototype,"cameraHeadingThreshold",void 0),e([k()],Dt.prototype,"cameraPitchThreshold",void 0),e([k()],Dt.prototype,"clickAction",void 0),e([k()],Dt.prototype,"videoViewModel",void 0),e([k()],Dt.prototype,"collectionId",void 0),e([k({type:Number})],Dt.prototype,"contrast",null),e([k()],Dt.prototype,"conversionProps",void 0),e([k()],Dt.prototype,"coverageFrustums",void 0),e([k()],Dt.prototype,"coveragePolygons",void 0),e([k()],Dt.prototype,"currentBestFeature",void 0),e([k()],Dt.prototype,"currentBestFeatureMeasurementImage",void 0),e([k()],Dt.prototype,"currentBestFeatureLocation",void 0),e([k()],Dt.prototype,"currentCoverageVisible",void 0),e([k()],Dt.prototype,"currentNode",null),e([k()],Dt.prototype,"featureCache",void 0),e([k()],Dt.prototype,"navigationNodes",void 0),e([k({json:{write:!1}})],Dt.prototype,"determineWorkflowForFeature",void 0),e([k({json:{write:!1}})],Dt.prototype,"determineWorkflowForTriangularMeasurement",void 0),e([k()],Dt.prototype,"disabled",void 0),e([k()],Dt.prototype,"displayMessage",void 0),e([k()],Dt.prototype,"displayNewMeasurementButton",void 0),e([k()],Dt.prototype,"distanceMeasurementResult",void 0),e([k()],Dt.prototype,"distanceAccuracyArray",void 0),e([k()],Dt.prototype,"dataCaptureLayer",void 0),e([k({readOnly:!0})],Dt.prototype,"featureCount",null),e([k()],Dt.prototype,"features",void 0),e([k()],Dt.prototype,"groundCoordinates",void 0),e([k()],Dt.prototype,"groundCoordinatesAccuracy",void 0),e([k()],Dt.prototype,"heightMeasurementPixels",void 0),e([k()],Dt.prototype,"heightGraphic",void 0),e([k()],Dt.prototype,"heightMeasurementResult",void 0),e([k()],Dt.prototype,"heightMeasurementAccuracy",void 0),e([k()],Dt.prototype,"measurementAngle",void 0),e([k()],Dt.prototype,"tempDistance",void 0),e([k({readOnly:!0})],Dt.prototype,"imageGalleryEnabled",null),e([k()],Dt.prototype,"imageGeometryField",void 0),e([k({readOnly:!0})],Dt.prototype,"imageLoaded",null),e([k()],Dt.prototype,"imageLocationToolState",void 0),e([k({readOnly:!0})],Dt.prototype,"invalidCameraHeading",null),e([k()],Dt.prototype,"imagePointsInView",null),e([k()],Dt.prototype,"imageMeasurementViewer",void 0),e([k()],Dt.prototype,"isAdditionalCoverageVisible",void 0),e([k()],Dt.prototype,"isAdditionalPointSourcesVisible",void 0),e([k()],Dt.prototype,"measurementVectors",void 0),e([k()],Dt.prototype,"layer",void 0),e([k()],Dt.prototype,"layerView",null),e([k({readOnly:!0})],Dt.prototype,"layerFloorFilterClause",null),e([k({type:Number})],Dt.prototype,"localPort",void 0),e([k()],Dt.prototype,"mapImageConversionToolState",void 0),e([k()],Dt.prototype,"measureType",void 0),e([k()],Dt.prototype,"measurementGraphic",void 0),e([k({readOnly:!0,value:"none"})],Dt.prototype,"mode",null),e([k()],Dt.prototype,"navigationMode",void 0),e([k()],Dt.prototype,"navigatorCurrentBestFeature",void 0),e([k()],Dt.prototype,"oiObjectIdField",void 0),e([k({type:s.ofType(t)})],Dt.prototype,"overlayedCameraLocations",void 0),e([k()],Dt.prototype,"overlayedMapFeatures",void 0),e([k()],Dt.prototype,"pixelCoordinates",void 0),e([k()],Dt.prototype,"preserveAngle",void 0),e([k()],Dt.prototype,"pointSources",void 0),e([k({readOnly:!0})],Dt.prototype,"popupEnabled",null),e([k()],Dt.prototype,"previousFeatureAngle",void 0),e([k()],Dt.prototype,"referencePoint",null),e([k({readOnly:!0})],Dt.prototype,"sectorData",null),e([k()],Dt.prototype,"selectedPoint",void 0),e([k({type:Number})],Dt.prototype,"sharpness",null),e([k()],Dt.prototype,"shouldShowSelectedImage",void 0),e([k()],Dt.prototype,"sketch",void 0),e([k()],Dt.prototype,"sketchTriangular",void 0),e([k()],Dt.prototype,"sketchTriangularGraphicsLayer",void 0),e([k()],Dt.prototype,"draw",void 0),e([k()],Dt.prototype,"sketchAdapter",void 0),e([k({readOnly:!0})],Dt.prototype,"sketchGraphicsLayer",null),e([k({readOnly:!0})],Dt.prototype,"state",null),e([k({readOnly:!0})],Dt.prototype,"thumbnails",null),e([k()],Dt.prototype,"triangularMeasurementActive",void 0),e([k()],Dt.prototype,"triangulatedDistanceMeasurement",void 0),e([k()],Dt.prototype,"triangulatedDistanceAccuracy",void 0),e([k()],Dt.prototype,"triangulatedAreaMeasurement",void 0),e([k()],Dt.prototype,"triangulatedAreaAccuracy",void 0),e([k()],Dt.prototype,"triangulatedMeasurementGraphic",void 0),e([k()],Dt.prototype,"triangulatedPoint",void 0),e([k()],Dt.prototype,"triangulatedMeasurementAdapter",void 0),e([k()],Dt.prototype,"updateFootprint",void 0),e([k()],Dt.prototype,"updateFootprintPanorama",void 0),e([k()],Dt.prototype,"updatingTriangularMeasurementState",void 0),e([k({value:null})],Dt.prototype,"view",null),e([k()],Dt.prototype,"videoElement",void 0),e([k()],Dt.prototype,"videoLayer",void 0),e([k()],Dt.prototype,"videoMapView",void 0),e([k()],Dt.prototype,"_adapter",void 0),e([k()],Dt.prototype,"_sketchGraphicsLayer",null),e([k()],Dt.prototype,"_highlightedFeatureHandle",void 0),e([k()],Dt.prototype,"_imageViewer",void 0),e([k()],Dt.prototype,"_initialCurrentCoverageUpdate",void 0),e([k()],Dt.prototype,"_locationPointOnImage",void 0),e([k()],Dt.prototype,"_correctedLocationPointOnImage",void 0),e([k()],Dt.prototype,"_overlays",void 0),e([k({readOnly:!0})],Dt.prototype,"_overlaysView",null),e([k()],Dt.prototype,"_panoramicViewer",void 0),e([k()],Dt.prototype,"_referencePointOnGround",void 0),e([k()],Dt.prototype,"_referencePointOnImage",void 0),e([k()],Dt.prototype,"_sectorData",void 0),e([k()],Dt.prototype,"_featureToSector",void 0),e([k({readOnly:!0})],Dt.prototype,"_updatingHandles",void 0),e([k()],Dt.prototype,"footprintExtent",void 0),e([k()],Dt.prototype,"_featureChangedTask",void 0),Dt=e([A("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],Dt);const Ut=Dt;export{Ut as default};
5
+ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import{equals as a,isSome as i}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as o}from"../../core/deprecate.js";import n from"../../core/Error.js";import{EventedMixin as l}from"../../core/Evented.js";import{makeHandle as c}from"../../core/handleUtils.js";import{equalsShallow as h}from"../../core/lang.js";import u from"../../core/Logger.js";import{clamp as d}from"../../core/mathUtils.js";import{abortMaybe as m,destroyMaybe as p}from"../../core/maybe.js";import{EsriPromise as g}from"../../core/Promise.js";import{isAbortError as y,throwIfAborted as v,waitTick as f}from"../../core/promiseUtils.js";import w from"../../core/ReactiveMap.js";import{whenOnce as F,on as b,watch as _,syncAndInitial as M,initial as I}from"../../core/reactiveUtils.js";import{sqlAnd as P}from"../../core/sql.js";import{getMetersPerUnitForSR as V}from"../../core/unitUtils.js";import{property as S}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as k}from"../../core/accessorSupport/decorators/subclass.js";import{isSerializable as C}from"../../core/support/jsonUtils.js";import{UpdatingHandles as A}from"../../core/support/UpdatingHandles.js";import G from"../../geometry/Extent.js";import{union as L}from"../../geometry/geometryEngineAsync.js";import R from"../../geometry/Multipoint.js";import O from"../../geometry/Point.js";import T from"../../geometry/Polygon.js";import j from"../../geometry/Polyline.js";import{projectWithZConversion as H}from"../../geometry/projectionUtils.js";import B from"../../geometry/SpatialReference.js";import{isClockwise as x}from"../../geometry/support/coordsUtils.js";import{normalizeMapX as E}from"../../geometry/support/normalizeUtils.js";import{geographicToWebMercator as z}from"../../geometry/support/webMercatorUtils.js";import D from"../../layers/GraphicsLayer.js";import U from"../../layers/MediaLayer.js";import{searchImages as N,getSortedLayerFeatures as W}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as q}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as $,computePolygonForInspection as J,resizePolygon as Z,checkIfPolygonContainsSelectedPoint as K}from"../../layers/orientedImagery/core/coverageUtils.js";import{isElevationSource as Q}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{convertGeographicToWebMercator as X}from"../../layers/orientedImagery/core/utils.js";import{imageToWorld as Y,imageToWorldPanoramic as ee}from"../../layers/orientedImagery/transformations/imageToWorld.js";import te from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as ae}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{or as ie,getInitialAngle as re,convertPixelToHeadingPitch as se,convertHeadingPitchToSphereVertex as oe,getImageToWorldProperties as ne,getUpdateElevationProps as le,isElevationSampler as ce,getImageToWorldPanoramicProperties as he,pointToArray as ue,transformGraphicCoordinatesToPixel as de,getWorldToImageProperties as me}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImage as pe,worldToImagePanoramic as ge}from"../../layers/orientedImagery/transformations/worldToImage.js";import ye from"../../layers/support/ExtentAndRotationGeoreference.js";import{getFloorFilterClause as ve}from"../../layers/support/floorFilterUtils.js";import fe from"../../layers/support/VideoElement.js";import we from"../../views/MapView.js";import Fe from"../../views/draw/Draw.js";import{scale as be}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as _e}from"../../views/input/InputManager.js";import Me from"../PanoramicViewer.js";import{defaultAngleThresholdInDegrees as Ie,videoExtent as Pe,invalidCameraHeading as Ve,sectorsInOrder as Se,sampleExtent as ke,sectorsRadii as Ce}from"./constants.js";import{configureSketchTool as Ae,extractFieldsFromDataCaptureLayer as Ge,isValidDataCaptureLayer as Le,constructGraphicFromImageGeometry as Re}from"./dataCaptureUtils.js";import{isFeatureAttachment as Oe,getImageSourceFromAttachment as Te}from"./galleryUtils.js";import{getModeCorrectedPoint as je,calculateCorrectedPixel as He,getUnitRateFromSpatialReference as Be,calculateHeightFromTemporaryDistance as xe,computeTriangulatedVector as Ee,computeTriangulatedPoint as ze}from"./imageMeasurementUtils.js";import{crossSymbol as De,crossSymbol3D as Ue,measurementPolygonSymbol as Ne,polylineSymbolPanoramic as We,measurementPolylineSymbol as qe,cameraOverlaySymbol3D as $e,cameraOverlaySymbol as Je,diamondSymbol as Ze,diamondSymbol3D as Ke,locationSymbol as Qe,locationSymbol3D as Xe,activeSourcePointSymbol as Ye,sourcePointSymbol as et}from"./symbols.js";import{isNoAttachmentError as tt,getContentType as at,isTifOrMrf as it,filterOILLayerView as rt,assignElevationSampleToFeatures as st,calculateDirection as ot,calculateSegment as nt,isSceneView as lt,isGraphic as ct}from"./utils.js";import{disableVideoZoomAndPan as ht}from"./videoViewerUtils.js";import ut from"./components/ImageViewer.js";import dt from"./components/NavigationNode.js";import mt from"./components/OrientedImageryVideoViewModel.js";import{NoActiveViewerError as pt,NoFeatureFoundWithObjectIdError as gt}from"./navigation/errors.js";import{queryFeatureByObjectIds as yt}from"./navigation/queries.js";import{ImageMeasurementService as vt}from"./services/ImageMeasurementService.js";import ft from"../Sketch/SketchViewModel.js";const wt={click:"view-click",imageClick:"image-click",triangularImageClick:"triangular-click",interactionHandles:"interaction-handles",hittestHandles:"hittest-handles",videoPlayerHandles:"video-handles",activeViewerCursorHandles:"active-viewer-cursor-handles",imageViewerCursorHandles:"image-viewer-cursor-handles"},Ft=new Set(["JPG","JPEG"]),bt=/\.(\w+)$/,_t=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let Mt=class extends(l(g)){constructor(e){super(e),this.additionalFeatures=new s,this.additionalCameraLocations=new s,this.additionalFootprints=new s,this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.bestFeatureAngle=0,this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null,this.cameraHeadingThreshold=Ie,this.cameraPitchThreshold=Ie,this.clickAction="hittest",this.videoViewModel=null,this.collectionId=null,this.conversionProps=null,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentBestFeatureMeasurementImage=null,this.currentBestFeatureLocation=null,this.currentCoverageVisible=!0,this.featureCache=[],this.navigationNodes=new s,this.determineWorkflowForFeature=async(e,t,a)=>{const{currentBestFeature:i,selectedPoint:r,view:s}=this;if(s?.closePopup(),i&&r){this._initialCurrentCoverageUpdate=!0,this._updateGroundElevation=!0;try{await this._updatePointsAndPolygons(a),await this._loadImage(a)}catch(o){y(o)||(this.loadImageError(o),u.getLogger(this).error("#loadIImage()","error occured while loading image",o))}}},this.determineWorkflowForTriangularMeasurement=async(e,t,a)=>{if(this.view?.closePopup(),this.currentBestFeatureMeasurementImage&&this.selectedPoint)try{await this._loadMeasurementViewerImage(a)}catch(i){y(i)||(this.loadImageError(i),u.getLogger(this).error("#loadIImage()","error occured while loading image",i))}},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.displayNewMeasurementButton=!0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.dataCaptureLayer=null,this.features=new s,this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.heightMeasurementPixels=[],this.heightGraphic=null,this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.measurementAngle=null,this.tempDistance=null,this.imageGeometryField=null,this.imageLocationToolState=!1,this.imageMeasurementViewer=new ut,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.measurementVectors=[],this.layer=null,this.localPort=null,this.mapImageConversionToolState=!1,this.measureType=null,this.measurementGraphic=null,this.navigatorCurrentBestFeature=null,this.oiObjectIdField=null,this.overlayedCameraLocations=new s,this.overlayedMapFeatures=new w,this.pixelCoordinates=null,this.preserveAngle="none",this.pointSources=new s,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.sketch=null,this.sketchTriangular=null,this.sketchTriangularGraphicsLayer=null,this.draw=null,this.sketchAdapter=null,this.triangularMeasurementActive=!1,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedAreaAccuracy=0,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.triangulatedMeasurementAdapter=null,this.updateFootprint=async(e,t)=>{"default"===this.mode&&"image-loaded"!==this.state||"video"===this.mode&&!this.videoElement?.content||await(this._adapter?.updateFootprint(e,t))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this.updatingTriangularMeasurementState=!1,this.videoElement=null,this.videoLayer=null,this.videoMapView=new we({map:new Map}),this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new ut,this._initialCurrentCoverageUpdate=!0,this._locationPointOnImage=null,this._measurementService=null,this._correctedLocationPointOnImage=null,this._overlays=new D({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"},title:"OrentedImageryViewerViewModel overlays layer"}),this._panoramicViewer=new Me,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._featureToSector=null,this._updatingHandles=new A,this._clickTask=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._openPopupTask=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this._updateGroundElevation=!1,this.addUpdatingPromise=e=>this._updatingHandles.addPromise(e),this.hideImageGeometry=e=>{},this.highlight=e=>{if(!this._overlaysView)return;this.removeHighlight();const t=this.additionalFootprints.find(({attributes:{imageID:t}})=>t===Number(e));this._highlightedFeatureHandle=t?this._overlaysView?.highlight(t):null},this.loadDataCaptureAdapter=async e=>{await this.loadSketch(e);const t=import("./adapters/sketch/DataCaptureAdapter.js"),{default:a}=await t;return v(e),this.sketchAdapter=new a({viewModel:this}),this.sketchAdapter},this.loadImageFromSource=async(e,t)=>this._updatingHandles.addPromise(this._loadImageFromSourceInternal(e,t)),this.storeImageMeasurementViewer=e=>{this.imageMeasurementViewer=e},this.loadImageViewer=e=>{this._imageViewer?.destroy(),this._imageViewer=e},this.loadPanoramicViewer=e=>{this._panoramicViewer?.destroy(),this._panoramicViewer=e},this.loadVideoViewer=e=>{this.videoMapView.container=e},this.showImageByObjectId=async(e,t)=>{const a=this.additionalFeatures.find(({attributes:t})=>t.objectId===e);if(a)this.currentBestFeature=a;else{const{layer:a,layerFloorFilterClause:r}=this;if(!a)return void this.setMessage("noLayerSelected","info");this.beforeLoad();const s=this._updatingHandles.addPromise(this._queryAndLoadByObjectId(a,e,r,t));try{await s,await this.selectBestFeature(e,t)}catch(i){y(i)||(u.getLogger(this).error("oriented-imagery-viewer:show-image",i),"NoFeatureFoundWithObjectIdError"===i.name?this.setMessage("noFeatureFoundWithObjectId","error","",{objectId:e}):this.setMessage("imageLoadError","error",i.message))}}},this.imageToImageTransform=async(e,t,a)=>{const{updateElevationProps:i,...r}=t,{updateElevationProps:s,...o}=a,n=await Y(e,r,i);return pe(n,o)},this.getSectorFeatureById=e=>this._suitabilities?.find(({feature:{attributes:{objectId:t}}})=>t===e),this.getFeatureSectorById=e=>this._featureToSector?.[`${e}`],this.navigate=async(e,t)=>{const{activeViewer:a}=this;if(!a)throw new pt;return await a.navigate(e,t)},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.revealImageGeometry=e=>{},this.selectBestFeature=async(e,t)=>(v(t),this.currentBestFeature=this.features?.find(({attributes:t})=>`${t.objectId}`==`${e}`),F(()=>"image-loaded"===this.state,t)),this.toggleImageAttributes=()=>{m(this._openPopupTask),this._openPopupTask=r(async e=>{const{currentBestFeature:a,popupEnabled:i,layer:r,view:s}=this;if(s?.closePopup(),!(s&&a&&i&&r))return;const{attributes:o,geometry:n}=a,l=new t({geometry:n,attributes:o.toJSON(),layer:r,sourceLayer:r});v(e),await s.openPopup({features:[l],location:o.location.clone()})})},this.updateSuitabilities=(e,t=!0)=>{e.sort((e,t)=>e.suitability-t.suitability),this._suitabilities=e;const a=this._suitabilities.map(({feature:e})=>e);this._initialCurrentCoverageUpdate=!0,this._updateFeatures(a,t),this._groupFeaturesBySectors()},this._createViewClickHandle=()=>{if(this.removeHandles(wt.click),"disabled"===this.state||null==this.view)return;const e=this.mapImageConversionToolState&&"image-loaded"===this.state?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,_e.WIDGET),wt.click)},this._createImageClickHandle=()=>{this.removeHandles(wt.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:a,currentBestFeature:i,footprintExtent:s}=this,o=a?.imageSize;if(!(e&&"none"!==t&&o&&s&&i))return;const n=a.clickAction;this.clickAction="pixel-location";const l=c(()=>{this.clickAction=n});let h=null;const u=b(()=>a,"pixel-location",e=>{this.plotReferencePointOnImage(e),h?.abort(),h=r(async a=>{if(!e)return;const r=await this.getMapPoint(e,{feature:i,imageSize:o,mode:t}).then(e=>{const t=this.view?.spatialReference;return ie(!t,e.spatialReference.equals(t))?e:H(e,t)});v(a),this.plotReferencePointOnGround(r)})});this.addHandles([u,l],wt.imageClick)},this._createTriangularImageClickHandle=()=>{this.removeHandles(wt.triangularImageClick);const e=this.imageMeasurementViewer?.imageSize;this.triangularMeasurementActive&&"none"!==this.mode&&e&&this.currentBestFeature&&this.addHandles(this.imageMeasurementViewer.imageRenderer.on("double-click",this._measurementImageClickHandler),wt.triangularImageClick)},this._createTriangularImageLocationHandle=()=>{this.removeHandles(wt.triangularImageClick);const{imageLocationToolState:e,mode:t,imageMeasurementViewer:a}=this,i=a?.imageSize;if(!e||"none"===t||!i)return;this.clickAction="pixel-location";let s=null;const o=b(()=>a,"pixel-location",e=>{1===this.measurementVectors.length&&(this.plotLocationPointOnImage(e,!0),s?.abort(),s=r(async a=>{if(!e||this.triangulatedPoint||2===this.measurementVectors?.length||!this.currentBestFeatureMeasurementImage)return;let r=await this.getMapPoint(e,{feature:this.currentBestFeatureMeasurementImage,imageSize:i,mode:t});v(a);const s=this.currentBestFeatureMeasurementImage.geometry.spatialReference;s&&!r.spatialReference.equals(s)&&(r=await H(r,s),v(a)),await this._calculateTriangulatedPointFromGroundPoint(r,{signal:a}),v(a)}))});this.addHandles(o,wt.triangularImageClick)},this._createImageLocationHandle=()=>{this.removeHandles(wt.imageClick);const{imageLocationToolState:e,mode:t,activeViewer:a,currentBestFeature:i,footprintExtent:s}=this,o=a?.imageSize;if(!(e&&"none"!==t&&o&&s&&i))return;this.clickAction="pixel-location";let n=null;const l=b(()=>a,"pixel-location",e=>{const{currentBestFeatureMeasurementImage:a,triangularMeasurementActive:s,imageMeasurementViewer:l}=this;this.pixelCoordinates=e;const c=null!=a&&!l.state.includes("loading");ie(!s,c)&&this.plotLocationPointOnImage(e),n?.abort(),n=r(async a=>{if(!e)return;let r=await this.getMapPoint(e,{feature:i,imageSize:o,mode:t});v(a);const n=this.view?.spatialReference;n&&!r.spatialReference.equals(n)&&(r=await H(r,n),v(a)),this.groundCoordinates=r,s&&r&&c&&await this.triangulatedLocationWorkflow(r,a);const l=await this.calculateLocationAccuracy(e,r,t,a);v(a),l&&(this.groundCoordinatesAccuracy=l)})});this.addHandles(l,wt.imageClick)},this._handleImageHitTestResponse=async e=>{const{layer:t,overlayedCameraLocations:a}=this;if(!t)return;const i=e.results.find(({graphic:e,graphic:{attributes:i}})=>a.includes(e)&&i&&!i[t.imageReferenceField]&&!i[t.imageGeometryField]);if(!i)return;const r=i.graphic.attributes[t.objectIdField];await this.showImageByObjectId(r)},this._loadImage=async e=>{const{currentBestFeature:t,layer:a,mode:i}=this;if(this.clearGraphics(),!a||!t||"none"===i||"video"===i)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:l,cameraPitch:c,objectId:h,cameraOrientation:d,location:m}=r,p=(l??0)+(o??0),g=m.spatialReference.isWGS84&&4!==d?.type?z(m):new O(m);let f=s;if(Oe(s))try{f=await Te(a,h,e)}catch(w){if(y(w))return;return tt(w)?(u.getLogger(this).error(w),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${h}`)):(u.getLogger(this).error(w,{[a.objectIdField]:h,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${h}`))}try{await this.loadImageFromSource(f,{imageRotation:p,options:e,pitch:c,yaw:n,mode:i,cameraLocation:g}),v(e),await this.transformAndPlotSelectedLocation(e)}catch(w){y(w)||this.loadImageError(w)}},this._loadImageFromSourceInternal=async(e,t)=>{const{mode:a,imageRotation:i,options:r}=t,s="string"==typeof e,o=s?e:e.url,{pathname:n,searchParams:l}=new URL(o);let c=s?n.match(bt)?.[1]:e.datasetFormat;if(!c)try{c=await at(o,{...t.options})}catch(h){y(h)||u.getLogger(this).error("#getContentType()",h)}switch(c??="UNKNOWN FORMAT",a){case"default":this.triangularMeasurementActive?await this._setImageSource(this.imageMeasurementViewer,c,o,l,i,r):await this._setImageSource(this._imageViewer,c,o,l,i,r);break;case"panoramic":if(Ft.has(c.toUpperCase())){const{selectedPoint:e}=this,{pitch:a,yaw:i,cameraLocation:s,viewAngle:n}=t;this._panoramicViewer.imageSource=o;let l=i??0;"number"==typeof n?l=n-l:s&&e&&(l=await re(s,e)-l),this._panoramicViewer.pitch=a??0,this._panoramicViewer.yaw=l,await this._panoramicViewer.loadImage(r)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:c});break}},this._loadMeasurementViewerImage=async e=>{const{currentBestFeatureMeasurementImage:t,layer:a,mode:i}=this;if(this.imageMeasurementViewer.clearGraphics(),!a||!t||"none"===i||"video"===i)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:l,cameraPitch:c,objectId:h,cameraOrientation:d,location:m}=r,p=(l??0)+(o??0),g=m.spatialReference.isWGS84&&4!==d?.type?z(m):new O(m);let f=s;if(Oe(s))try{f=await Te(a,h,e)}catch(w){if(y(w))return;return tt(w)?(u.getLogger(this).error(w),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${h}`)):(u.getLogger(this).error(w,{[a.objectIdField]:h,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${h}`))}try{await this.loadImageFromSource(f,{imageRotation:p,options:e,pitch:c,yaw:n,mode:i,cameraLocation:g}),v(e)}catch(w){y(w)||this.loadImageError(w)}},this._loadViewAdapter=async e=>{const{view:t}=this;if(t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/view/MapViewAdapter.js");v(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/view/SceneViewAdapter.js");v(e),this._adapter=new t(this);break}}else this._adapter=null},this._mapImageConversionToolViewClickHandler=e=>{e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.plotMapPoint(e.mapPoint)},this._measurementImageClickHandler=e=>{e.stopPropagation(),e.preventDefault();const{sketchTriangular:t,triangularMeasurementActive:a,currentBestFeatureMeasurementImage:i,triangulatedMeasurementGraphic:r}=this;t&&a&&i&&r&&"active"!==t.state&&(t.update([r],{tool:"reshape"}),this.updatingTriangularMeasurementState=!0)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=r(async t=>{const{pointerType:a,button:i,mapPoint:r}=e;if(("mouse"!==a||0===i)&&r)return e.stopPropagation(),e.preventDefault(),this._updatingHandles.addPromise(this.loadBestImage(r,{signal:t}))})},this.plotSelectedPointOnImage=async(e,a)=>{if(await f(a),!e)return;const i=new O({...C(e)?e.toJSON():e});if("default"===this.mode)i.x-=.5,i.y=.5-i.y,i.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:i,symbol:De}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=se(e,i,r),n=oe(s,o);this._crossSymbol=new t({geometry:new O(n,B.WebMercator),symbol:Ue}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this)}initialize(){this.addHandles([_(()=>this.view,()=>this.load(),M),_(()=>this.view?.map,(e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)},I),_(()=>this.view?.map?.allLayers?.length,e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)},I),_(()=>[this.state,this.mapImageConversionToolState,this.view],()=>{this._createViewClickHandle(),this._createImageClickHandle()},M),_(()=>[this.triangularMeasurementActive,this.currentBestFeatureMeasurementImage],()=>{this._createTriangularImageClickHandle()},M),_(()=>[this.state,this.imageLocationToolState,this.view],(e,t)=>{if(this._initializeMeasurementService(),this._createImageLocationHandle(),!this.imageLocationToolState)return this.clearPreviousGroundLocation(),void this._resetCursor();e[1]!==t?.[1]&&this._setMeasurementCursor()},M),_(()=>this.measureType,()=>{this.clearPreviousMeasurements(),this._initializeMeasurementService()},M),_(()=>this.bestFeatureAngle,(e,t)=>{this.previousFeatureAngle=t??0},M),_(()=>this.currentBestFeature,async(e,t)=>{m(this._featureChangedTask),this._featureChangedTask=r(async a=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:a}])),await this._featureChangedTask.promise},{sync:!0}),_(()=>this.currentBestFeatureMeasurementImage,(e,t)=>{m(this._featureChangedTask),t&&e!==t&&(this.measurementVectors=[],this.triangulatedPoint=null,this.sketchTriangularGraphicsLayer?.graphics.destroyAll()),this._featureChangedTask=r(async a=>{await this.determineWorkflowForTriangularMeasurement(e,t,{signal:a}),v(a),this._reorderTriangularSketchLayer()})},M),_(()=>this.triangularMeasurementActive,(e,t)=>{t&&!e&&(this.measurementVectors=[],this.currentBestFeatureMeasurementImage=null,this.triangulatedDistanceMeasurement=null,this.triangulatedMeasurementGraphic=null,this.triangulatedPoint=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaAccuracy=0,this.sketchTriangularGraphicsLayer?.graphics.destroyAll(),this.clearReferencePointOnImage(),this.imageMeasurementViewer.clearImage(),this.imageMeasurementViewer.clearGraphics())}),_(()=>this.mode,e=>{switch(this.removeHandles(wt.interactionHandles),e){case"default":this.addHandles(_(()=>{const{state:e}=this;return"image-loaded"===e?this._imageViewer.imagePointsInView:null},e=>{e&&(m(this._updateFootprintTask),this._updateFootprintTask=r(async t=>{await this.updateFootprint(e,{signal:t})}))},{...M,equals:(e,t)=>a(e,t,h)}),wt.interactionHandles);break;case"video":this.addHandles(_(()=>{const{footprintExtent:e}=this;if(e)return Pe},e=>{e&&(m(this._updateFootprintTask),this._updateFootprintTask=r(async t=>{await this.updateFootprint(e,{signal:t})}))},{...M,equals:(e,t)=>a(e,t,h)}),wt.interactionHandles);break;case"panoramic":this.addHandles(_(()=>{const{currentBestFeature:e,state:t,_panoramicViewer:a}=this,{imageSize:i,vfov:r,hfov:s,pitch:o,yaw:n}=a;return e&&i&&!t.includes("loading")&&null!=r&&null!=s&&null!=o&&null!=n?[r,s,n,o]:null},e=>{if(!e||this.state.includes("loading"))return;const[t,a,i,s]=e;this.currentNode&&(this.currentNode.currentHeading=i+(this.currentNode.heading??0),this.currentNode.currentPitch=s+(this.currentNode.pitch??0)),m(this._updateFootprintTask),this._updateFootprintTask=r(async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:a,yaw:i,pitch:s},{signal:e}),this._updateFootprintTask=null})},{equals:(e,t)=>a(e,t,h)}),wt.interactionHandles)}},M),_(()=>[this.brightness,this.contrast,this.sharpness],()=>{const{_imageViewer:e,brightness:t,contrast:a,mode:i,sharpness:r}=this;"default"===i&&(e.brightness=t,e.contrast=a,e.sharpness=r)},M),_(()=>this.activeViewer?.imageRenderer,()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)}),_(()=>this.activeViewer,e=>{this.removeHandles(wt.hittestHandles),e&&this.addHandles(b(()=>e,"hittest-response",this._handleImageHitTestResponse),wt.hittestHandles)})]),this.when().finally(()=>{this.notifyChange("state")})}destroy(){this.currentBestFeature=null,this._updateFootprintTask=m(this._updateFootprintTask),this._clickTask=m(this._clickTask),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=p(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),this.videoViewModel=p(this.videoViewModel),this._crossSymbol=p(this._crossSymbol),this._referencePointOnGround=p(this._referencePointOnGround),this._referencePointOnImage=p(this._referencePointOnImage),this._locationPointOnImage=p(this._locationPointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy(),this._imageViewer.destroy(),this.imageMeasurementViewer.destroy(),this._panoramicViewer.destroy()}get activeLayer(){return o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:a}=this;switch(a){case"default":return e;case"panoramic":return t;default:return null}}get accuracyParametersMissing(){return this.layer?.orientationAccuracy?.every(e=>0===e)??!0}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",d(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",d(e,-10,10))}get currentNode(){const{currentBestFeature:e,navigationNodes:t}=this;return t.find(t=>t.id===e?.attributes.objectId)}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){const{currentBestFeature:e}=this;if(!e)return!1;const t=e.attributes.imagePath?.trim();return it(t)||Oe(t)}get imageLoaded(){return o(u.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get invalidCameraHeading(){return this.currentBestFeature?.attributes?.cameraHeading===Ve}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get layerView(){const{layer:e,view:t}=this;if(e&&t)return t.allLayerViews.find(rt(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?ve(e):null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";if(e.orientedImageryType?.includes("video"))return"video";const{horizontalFieldOfView:t,isSpherical:a}=e;return 360===t||a?"panoramic":"default"}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?Se.map(t=>e[t]):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",d(e,0,1))}get sketchGraphicsLayer(){return this.sketch?.layer}get state(){const{mode:e,disabled:t,_updatingHandles:{updating:a},_featureChangedTask:i}=this;if(t)return"disabled";if(!this.isFulfilled()||a||!1===i?.finished)return"loading";if(this.isRejected())return"error";if("error"===this.displayMessage?.type)return"image-load-error";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state;case"video":return this.videoElement?.loaded?"video-loaded":"video-not-loaded"}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map(({attributes:{imagePath:e,objectId:t,cameraRoll:a,imageRotation:i}})=>{const r=e?.trim();return it(r)||Oe(r)?{url:r,objectId:t,rotation:(a??0)+(i??0)}:null}).filter(i)):null}set view(e){this._set("view",e)}get _sketchGraphicsLayer(){const{mode:e}=this;switch(e){case"panoramic":return new D({elevationInfo:{mode:"absolute-height"}});case"default":return new D;default:return}}get _overlaysView(){return this.view?.layerViews.find(({layer:e})=>e===this._overlays)}beforeLoad(){this.view?.closePopup(),this.displayMessage=null,this.clearPreviousGroundLocation(),this.triangularMeasurementActive=!1,this.currentBestFeatureMeasurementImage=null,this.measureType=null,this.imageLocationToolState=!1,this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),this._overlays?.removeAll()}async computeHeight(e,t,a=!0){return this._measurementService?.computeHeight(e,t,a)}async calculateAreaMeasurement(e,t,a){return this._measurementService?.calculateAreaMeasurement(e,t,a)}async calculateDistanceMeasurement(e,t,a){return this._measurementService?.calculateDistanceMeasurement(e,t,a)}async calculateAccuracy(e,t,a){return this._measurementService?.calculateAccuracy(e,t,a)}async calculateLocationAccuracy(e,t,a="default",i){return this._measurementService?.calculateLocationAccuracy(e,t,a,i)}async calculateAccuracyPanoramic(e,t,a){return this._measurementService?.calculateAccuracyPanoramic(e,t,a)}async calculateHeightMeasurementInfo(e,t,a){return this._measurementService?.calculateHeightMeasurementInfo(e,t,a)}async calculateTriangulatedMeasurements(e){return this._measurementService?.calculateTriangulatedMeasurements(e)}clearPreviousMeasurements(){this.clearMeasurementGraphics(),this.resetMeasurementData(),this.stopMeasurement()}clearPreviousGroundLocation(){this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.pixelCoordinates=null,this.clearLocationPointOnImage()}clearMeasurementGraphics(){this.measurementGraphic&&(this.activeViewer?.removeGraphic(this.measurementGraphic),this.measurementGraphic=null),this.heightGraphic&&(this.activeViewer?.removeGraphic(this.heightGraphic),this.heightGraphic=null),this.triangularMeasurementActive&&this.sketchTriangularGraphicsLayer?.graphics.destroyAll()}digitizeCancel(){return this.sketch?.cancel()}digitizeCanRedo(){return this.sketch?.canRedo()??!1}digitizeCanUndo(){return this.sketch?.canUndo()??!1}digitizeComplete(){return this.sketch?.complete()}async digitizeCreate(e,t){const{sketch:a,dataCaptureLayer:i}=this;if(!a)throw _t();Ae(i,e,a),await a.create(e,{...t,defaultZ:0})}digitizeDelete(){if(!this.sketch)throw _t();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw _t();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw _t();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw _t();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw _t();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw _t();return this.sketch.update(e,t)}async displayHeightResults(){const{currentBestFeature:e,activeViewer:t,heightMeasurementPixels:a,mode:i}=this,r=t?.imageSize,s=e?.attributes;if(!s||!r)return;const o=await this.computeHeight(a,i);o?.value&&o?.accuracy&&(this.heightMeasurementResult=o.value,this.heightMeasurementAccuracy=o.accuracy)}filterByFootprints(e,t,a=!1){const i=[],r=[],s=[];return e.forEach(e=>{const{layer:{coveragePercent:o},attributes:n}=e;let l;const{polygon:c,frustum:h}=$(n);if(l=c.clone(),n.isInspection&&(l=J(n)),o&&(l=Z(l,o)),a||!t||K(l,t)){s.push(e);const{geometry:t,objectId:a,cameraHeight:o,cameraHeading:l}=n,u=t.clone();u.z=o,u.imageID=a,this.pointSources.push(u),l!==Ve&&(i.push(c),h&&r.push(h))}}),{features:s,polygons:i,frustums:r}}getMeasurementProperties(e=this.currentBestFeature,t=this.activeViewer){if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:i}=e,{elevationSource:r,cameraHeight:s}=i,o=ne(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?H(n,B.WebMercator):Promise.resolve(n)).then(e=>(n=e,le(n.spatialReference,n.z??0,s,{elevationSample:a,elevationSource:r,extent:this.footprintExtent}))).then(t=>("elevationSample"in t&&ce(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t}))}getMeasurementPropertiesPanoramic(){const{currentBestFeature:e,activeViewer:t}=this;if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:i}=e,{elevationSource:r,cameraHeight:s}=i,o=he(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?H(n,B.WebMercator):Promise.resolve(n)).then(e=>(n=e,le(n.spatialReference,n.z??0,s,{elevationSample:a,elevationSource:r,extent:this.footprintExtent}))).then(t=>("elevationSample"in t&&ce(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t}))}async deleteDataCaptureFeatures(e){const{dataCaptureLayer:t}=this;if(!t)throw new n("orientedimagery","Data capture layer is not available");return t.queryFeatures({objectIds:e}).then(({features:e})=>t.applyEdits({deleteFeatures:e}))}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[Se[e]],a=t?.at(0);a&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(a):this._updateCurrentBestFeature(a))}handleFeatureClick(e){const{sector:t,featureIndexInSector:a}=e;if(isNaN(a))return;const i=this._sectorData?.[t],r=i?.at(a);r&&(this.triangularMeasurementActive&&this.currentBestFeature?this._updateImageMeasurementBestFeature(r):this._updateCurrentBestFeature(r))}handleDrawCursorUpdateEvents(e){const{measurementAngle:t,tempDistance:a,heightMeasurementPixels:i,mode:r,activeViewer:s,currentBestFeature:o}=this,n=s?.imageSize;if(!e.vertices||!n||!o)return;const l=je(e.vertices.at(-1),r,n);if(i.length<1||!l||!a||!t||"none"===r)return;const c=He(i[0],l,t);if(!c?.length)return;this.heightMeasurementPixels.push(c),"panoramic"===r?this.createPolylineGraphicPano():this.createPolylineGraphic();const h=Be(o.attributes.location.spatialReference),u=xe(this.heightMeasurementPixels,a,h);u&&(this.heightMeasurementResult=u)}async handleDrawVertexAddEvents(e,t){const{currentBestFeature:a,activeViewer:i,heightMeasurementPixels:r,mode:s}=this;if(!a||!i||!e.vertices?.length||"none"===s)return;const o=i?.imageSize;if(!r.length&&o){const a=je(e.vertices.at(-1),s,o);this.heightMeasurementPixels.push(a);const i=await this.calculateHeightMeasurementInfo(a,s,t);if(!i?.measurementAngle||!i?.tempDistance)return;this.measurementAngle=i.measurementAngle,this.tempDistance=i.tempDistance}}load(e){return this.addResolvingPromise(this._loadViewAdapter(e).catch(e=>{if(!y(e))throw e})),this}async loadBestImage(e,t){return this.selectedPoint=X(e),this.beforeLoad(),this._fetchFeaturesWithController(e,t)}loadImageError(e){u.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async loadSketch(e){if(!this.sketch){const t=import("../Sketch/SketchViewModel.js"),{default:a}=await t;v(e),this.sketch=new a({layer:this._sketchGraphicsLayer,view:this.activeViewer?.imageRenderer,updateOnGraphicClick:!1,defaultUpdateOptions:{reshapeOptions:{edgeOperation:"none",shapeOperation:"none",vertexOperation:void 0},enableMoveAllGraphics:!1,enableRotation:!1,enableScaling:!1,multipleSelectionEnabled:!1,toggleToolOnClick:!1,tool:"transform"}})}return this.sketch}async loadMeasurementAdapter(e){if(!this.sketchAdapter){const t=import("./adapters/sketch/MeasurementAdapter.js"),{default:a}=await t;if(v(e),this.sketchAdapter=new a({viewModel:this}),!this.sketchAdapter.viewModel.isResolved())return}return this.sketchAdapter}async loadTriangulatedMeasurementAdapter(e){if(!this.triangulatedMeasurementAdapter){const t=import("./adapters/sketch/TriangulatedMeasurementAdapter.js"),{default:a}=await t;if(v(e),this.triangulatedMeasurementAdapter=new a({viewModel:this}),!this.triangulatedMeasurementAdapter.viewModel.isResolved())return}return this.triangulatedMeasurementAdapter}async processFeatureResponse(e,t,a){const{features:i}=e;if(this._clearFeatureGeometries(),!this._checkFeatures(i))return;const{features:r,polygons:s,frustums:o}=this.filterByFootprints(i,t,a?.skipFilter);if(!this._checkFeatures(r))return;this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(o);const n=await this.processElevationSample(s,r,a);v(a),await this._updateElevationOfSelectedPointAndLocations(r,t,n),v(a),st(r,n);const l=this._processSuitableFeatures(r,t);this.updateSuitabilities(l,a?.loadBestImage)}async startMeasurement(e,t){this.sketch||await this.loadSketch(t),await this.loadMeasurementAdapter(t);const{sketch:a,sketchAdapter:i,activeViewer:r,mode:s}=this;if(!a||!i||!r||"none"===s)return;if(this.displayNewMeasurementButton=!1,"panoramic"===s&&(a.defaultCreateOptions.defaultZ=0),await a.create(e),"panoramic"===s){const{drawOperation:e}=a.view.activeTool;e.constraintsEnabled=!1,e._set("elevationDrawSurface",null)}const o=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;o&&this.sketch&&(this.sketch.polygonSymbol=Ne(o),this.sketch.polylineSymbol="panoramic"===s?We:qe(o,2.5))}startHeightMeasurement(){this.heightMeasurementPixels=[],this.displayNewMeasurementButton=!1,this.draw??=new Fe({view:this.activeViewer?.imageRenderer});this.draw.create("polyline").on(["cursor-update","vertex-add","draw-complete"],e=>this.handleDrawEvents(e))}createPolylineGraphic(){const e=[this.heightMeasurementPixels[0],this.heightMeasurementPixels.at(-1)],a=this.activeViewer?.imageRenderer.spatialReference;if(this.heightGraphic)this.heightGraphic.geometry=new j({paths:[e],spatialReference:a});else{const i=new j({paths:[e],spatialReference:a}),r=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;this.heightGraphic=new t({geometry:i,symbol:qe(r,2.5)}),this.activeViewer?.addGraphic(this.heightGraphic)}}createPolylineGraphicPano(){const e=this.activeViewer?.imageRenderer.spatialReference,a=this.activeViewer?.imageSize;if(!a)return;const i={x:this.heightMeasurementPixels[0][0],y:this.heightMeasurementPixels[0][1]},r={x:this.heightMeasurementPixels.at(-1)[0],y:this.heightMeasurementPixels.at(-1)[1]},{heading:s,pitch:o}=se(i,a[0],a[1]),{heading:n,pitch:l}=se(r,a[0],a[1]),c=[[...oe(s,o)],[...oe(n,l)]];if(this.heightGraphic)this.heightGraphic.geometry=new j({paths:[c],spatialReference:e});else{const a=new j({paths:[c],spatialReference:e});this.heightGraphic=new t({geometry:a,symbol:We}),this._panoramicViewer.addGraphic(this.heightGraphic,0)}}async editOverlayedGraphics(e){this.sketchTriangularGraphicsLayer||this._initializeSketchTriangularGraphicsLayer(),this.sketchTriangularGraphicsLayer?.destroyed&&this._handleDestroyedTriangularSketchLayer(),this.sketchTriangularGraphicsLayer.add(e),this.sketchTriangular||(this._initializeSketchTriangular(),await this.loadTriangulatedMeasurementAdapter()),this.updateOverlayedGeometry(e)}updateOverlayedGeometry(e){this.sketchTriangular?.update([e],{tool:"reshape"})}async processMeasurementVectors(e){this.triangularMeasurementActive&&this.currentBestFeature&&(this.measurementVectors?.length<2&&await this.updateMeasurementVectorsArray(e),2===this.measurementVectors.length&&await this.calculateTriangulatedMeasurements(e))}async updateMeasurementVectorsArray(e){const t=this.measurementVectors.length?this.currentBestFeatureMeasurementImage:this.currentBestFeature;if(t){const a=await this.computeMeasurementVector(e,t);a&&this.measurementVectors.push(a)}}async computeMeasurementVector(e,t){const{activeViewer:a,mode:i}=this,r=a?.imageSize;if(!e||!t||!r)return;const s=e.map(e=>[e[0]-.5,-.5-e[1]]),o=this.view?.spatialReference,n=[];for(let l=0;l<s.length;l++){const e={x:s[l][0],y:s[l][1]};let a=await this.getMapPoint(e,{feature:t,imageSize:r,mode:i});o&&!a.spatialReference.equals(o)&&(a=await H(a,o)),n.push(a)}return Ee(n,t)}async handleDrawEvents(e,t){if(this.draw)switch(e.type){case"cursor-update":this.handleDrawCursorUpdateEvents(e);break;case"vertex-add":await this.handleDrawVertexAddEvents(e,t);break;case"draw-complete":await this.displayHeightResults()}}initializeMeasurement(e){switch(this.clearMeasurementGraphics(),this.resetMeasurementData(),e){case"distance":this.startMeasurement("polyline");break;case"area":this.startMeasurement("polygon");break;case"height":this.startHeightMeasurement()}}async overlayCameraLocations(e){const{activeViewer:a,currentBestFeature:i,overlayedCameraLocations:r,layer:s,mode:o,state:n,layerFloorFilterClause:l}=this,c=a?.imageSize;if(!c||!i||!s||"none"===o||n.includes("loading"))return;const{polygon:h}=$(i.attributes);if(a.removeManyGraphics(r.toArray()),r.removeAll(),e){const{features:e}=await s.queryFeatures({where:P(`${s.objectIdField} <> ${i.attributes.objectId}`,P(s.definitionExpression,l)),geometry:h,returnGeometry:!0,outFields:[s.objectIdField]}),n=await Promise.all(e.map(async e=>{const{attributes:a,geometry:r}=e,s=await this.getPixels(r,{feature:i,imageSize:c,mode:o}),n="panoramic"===o?$e():Je();return new t({attributes:a,symbol:n,geometry:s})}));r.addMany(n),a.addManyGraphics(r.toArray())}}overlayGraphicsOnImage(e,t){this.removeOverlayedGraphicsOnImage(e),this.overlayedMapFeatures.set(e,t),this.activeViewer?.addManyGraphics(t.toArray())}async overlayMapFeatures(e,a=!1){const{activeViewer:r,currentBestFeature:o,mode:n,state:l,layer:c}=this,h=r?.imageSize;if(!h||!o||"none"===n||"video"===n||l.includes("loading")||!c)return;const{polygon:d}=$(o.attributes);try{const{imageGeometryField:t,oiObjectIdField:a}=Ge(e,c.imageGeometryField,c.imageReferenceField);this.imageGeometryField=t.name,this.oiObjectIdField=a.name}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",g)}const{features:m}=await e.queryFeatures({geometry:d,returnGeometry:!0,outFields:["*"]}),p=new s((await Promise.all(m.map(async i=>{const r=i.symbol?.clone()??e.renderer?.getSymbol(i)?.clone(),{attributes:s,geometry:l}=i,c=l,{imageGeometryField:d,oiObjectIdField:m}=this;if(d&&m&&Le(e,d,m)&&`${s[m]}`==`${o.attributes.objectId}`)try{return Re(s,d,e,a,h,n,r)}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features","couldn't create graphic from attributes, geometry will be used",{error:g,feature:i,layer:e,imageGeometryField:this.imageGeometryField,imageReferenceField:this.oiObjectIdField})}switch(c?.type){case"point":{const i=await this.getPixels(c,{feature:o,imageSize:h,mode:n});return new t({attributes:s,layer:e,symbol:r,geometry:i,visible:e.visible&&a})}case"polygon":{const{rings:i,spatialReference:l}=c,u=i.map(e=>e.map(([e,t,a])=>new O({x:e,y:t,z:a,spatialReference:l}))),d=await Promise.all(u.map(async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then(e=>e.map(ue))));return new t({attributes:s,layer:e,symbol:r,geometry:new T({rings:d,spatialReference:B.WebMercator}),visible:e.visible&&a})}case"polyline":{const{paths:i,spatialReference:l}=c,u=i.map(e=>e.map(([e,t,a])=>new O({x:e,y:t,z:a,spatialReference:l}))),d=await Promise.all(u.map(async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then(e=>e.map(ue))));return new t({attributes:s,layer:e,symbol:r,geometry:new j({paths:d,spatialReference:B.WebMercator}),visible:e.visible&&a})}case"multipoint":{const{points:i,spatialReference:l}=c,u=i.map(([e,t,a])=>new O({x:e,y:t,z:a,spatialReference:l})),d=await this.getPixels(u,{feature:o,imageSize:h,mode:n}).then(e=>e.map(ue));return new t({attributes:s,layer:e,symbol:r,geometry:new R({points:d,spatialReference:B.WebMercator}),visible:e.visible&&a})}}return null}))).filter(i));this.overlayGraphicsOnImage(`${e.id}`,p)}async getPixels(e,t){const{imageSize:a,mode:i,feature:r}=t,s=(await this.worldToImage(Array.isArray(e)?e:[e],r)).map(e=>{if("default"===i)return new O({x:e.x-.5,y:.5-e.y,spatialReference:B.WebMercator});const[t,r]=a,{heading:s,pitch:o}=se(e,t,r),n=oe(s,o);return new O(n,B.WebMercator)});return Array.isArray(e)?s:s[0]}async getMapPoint(e,t){const{feature:a,mode:i,imageSize:r}=t,{elevationSample:s,attributes:o}=a,{elevationSource:n,location:l,cameraHeight:c}=o;let h=l.clone();h.spatialReference.isGeographic&&(h=await H(h,B.WebMercator));const u=await le(l.spatialReference,l.z??0,c,{elevationSample:s,elevationSource:n,extent:this.footprintExtent});let d;if("elevationSample"in u&&ce(u.elevationSample)&&(a.elevationSample=u.elevationSample),"default"===i){const t=ne(o,r[0],r[1]);d=await Y(Array.isArray(e)?e:[e],{...t,cameraLocation:h},u)}else{const t=he(o,r[0],r[1]);d=await ee(Array.isArray(e)?e:[e],{...t,cameraLocation:h},u)}return Array.isArray(e)?d:d[0]}getActiveSectors(){return Se.filter(e=>this._sectorData?.[e]?.length)}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new O({...e.toJSON()}),symbol:Ze}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){if("image-loaded"===this.state)switch(this.clearReferencePointOnImage(),this.mode){case"default":{const a=C(e)?e.toJSON():e;a.x-=.5,a.y=.5-a.y,this._referencePointOnImage=new t({geometry:new O({spatialReference:this._imageViewer.imageRenderer.spatialReference,...a}),symbol:Ze}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=se(e,i,r),n=oe(s,o);this._referencePointOnImage=new t({geometry:new O(n,B.WebMercator),symbol:Ke}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}plotLocationPointOnImage(e,t=!1){if("image-loaded"===this.state)switch(this.clearLocationPointOnImage(t),this.mode){case"default":this._plotLocationPointOnDefaultImage(e,t);break;case"panoramic":this._plotLocationPointOnPanoramicImage(e)}}removeAllOverlayMapFeatures(){this.overlayedMapFeatures.forEach(e=>{this._imageViewer.removeManyGraphics(e.toArray())}),this.overlayedMapFeatures.clear()}removeOverlayedGraphicsOnImage(e){const t=this.overlayedMapFeatures.get(e);t?.length&&(this.activeViewer?.removeManyGraphics(t.toArray()),this.overlayedMapFeatures.delete(e))}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._clickTask=m(this._clickTask)}resetVideo(){this.setMessage("onLoadMessage","info"),this.videoViewModel?.resetVideoHandler(),this._overlays?.removeAll(),this.videoViewModel=null,this.featureCache=[],this.currentBestFeature=null}resetMeasurementData(){this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.heightMeasurementPixels=[],this.measurementVectors=[],this.heightMeasurementResult=0,this.tempDistance=null,this.measurementAngle=null,this.heightMeasurementAccuracy=0,this.heightGraphic=null,this.triangulatedDistanceMeasurement=null,this.triangulatedDistanceAccuracy=null,this.triangulatedAreaMeasurement=null,this.triangulatedMeasurementGraphic=null,this.updatingTriangularMeasurementState=!1,this.triangulatedAreaAccuracy=0}async saveDrawing(){const{dataCaptureLayer:e,sketchAdapter:t}=this;if(!e||"data-capture"!==t?.type)return;const{pendingGraphics:a,savedGraphics:i}=t,r=a.get(e.id),s=r?.toArray();if(!r||!s?.length)return;const{addFeatureResults:o}=await this.saveDataCaptureFeatures(s),n=o.reduce((t,{objectId:a,globalId:i,error:r},o)=>{const n=s[o],{attributes:l}=n;return r?t.error.push(n):(a&&(l[e.objectIdField]=a),i&&e.globalIdField&&(l[e.globalIdField]=i),t.success.push(n)),t},{success:[],error:[]});i.addMany(n.success),r.removeAll(),r.addMany(n.error)}async saveDataCaptureFeatures(e){const{activeViewer:t,currentBestFeature:a,dataCaptureLayer:r,mode:s}=this,o=t?.imageSize;if(!o||!a||"none"===s||"video"===s)throw new n("orientedimagery","Image size, current best feature and mode are required to save data capture features");if(!r)throw new n("orientedimagery","Data capture layer is not available");const l=await Promise.all(e.map(async e=>{const t=e.clone(),{geometry:i}=t;if(!i)return;const n=i.type,l=r.hasZ,c=r.geometryType,h=n!==c,u=h?await import("./transformers.js"):null,d=u?.default[c],m=h?d?.(i):i;if(m)switch(m.type){case"point":return t.geometry=await this.getMapPoint(de(s,m,o),{feature:a,imageSize:o,mode:s}),l||(delete t.geometry.z,t.geometry.hasZ=!1),t.geometry.hasM=!1,t;case"polygon":{const e=await Promise.all(m.rings.map(async e=>this.getMapPoint(e.map(([e,t,a])=>de(s,{x:e,y:t,z:a},o)),{feature:a,imageSize:o,mode:s})));return t.geometry=new T({spatialReference:e[0][0].spatialReference,hasZ:l,hasM:!1,rings:e.map(e=>e.map(ue))}),t}case"polyline":{const e=await Promise.all(m.paths.map(async e=>this.getMapPoint(e.map(([e,t,a])=>de(s,{x:e,y:t,z:a},o)),{feature:a,imageSize:o,mode:s})));return t.geometry=new j({spatialReference:e[0][0].spatialReference,hasZ:l,hasM:!1,paths:e.map(e=>e.map(ue))}),t}}})),c=l.filter(i);return r.applyEdits({addFeatures:c}).then(e=>{const{addFeatureResults:t}=e;let a=0;const i=l.map(e=>{const i=t[a++];return e?i:{error:new n("orientedimagery","Error in saving data capture features"),objectId:null,globalId:null}});return{...e,addFeatureResults:i}})}async searchBestImage(e,t){try{const a=await N(e,t);a&&await this.processFeatureResponse(a,e.point,t)}catch(a){y(a)||(this.setMessage("imageLoadError","error",a.message),u.getLogger(this).error("error occurred while finding best image",a))}}selectTriangularMeasurementFeature(e){this.currentBestFeatureMeasurementImage=this.features?.find(({attributes:t})=>t.objectId===Number(e))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach(t=>{t.visible=e})}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach(t=>{t.visible=e})}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}setCurrentPanoramaView(e,t){this._panoramicViewer?.set({yaw:e,pitch:t})}async startDataCapture(e,t){const a=this.activeViewer?.imageRenderer,{oiObjectIdField:i,currentBestFeature:r}=this;if(!a||!r||!i)return;const{attributes:{objectId:o}}=r,n=this.overlayedMapFeatures.get(e.id)?.toArray()??[],l=[],c=[];for(const s of n)`${s.getAttribute(i)}`==`${o}`?l.push(s):c.push(s);this.overlayGraphicsOnImage(e.id,new s(c)),this.collectionId=e.id;const h=await this.loadSketch(t),u=await this.loadDataCaptureAdapter(t);v(t),h.layer.addMany(l),h.layer.blendMode="source-atop",u.savedGraphics.addMany(l);a.ui.find("zoom").visible=!1,a.map.layers.add(this.sketchGraphicsLayer)}async stopDataCapture(e=!1){this.sketch?.cancel(),this.sketchGraphicsLayer?.removeAll(),this.sketchAdapter=p(this.sketchAdapter),this.sketch=p(this.sketch),this.collectionId=null;const{dataCaptureLayer:t}=this,a=this.activeViewer?.imageRenderer;if(!a||a.destroyed)return;a.map.layers.remove(this.sketchGraphicsLayer),e&&t&&await this.overlayMapFeatures(t,!0);const i=a.ui.find("zoom");i&&(i.visible=!0)}stopMeasurement(){this.heightMeasurementPixels=[],this.draw?.reset(),this.sketch?.cancel()}toggleAllOverlayMapFeatures(e){this.overlayedMapFeatures.forEach(t=>{this._toggleVisiblity(t,e)})}toggleOverlayMapFeatures(e,t,a){const i=this.overlayedMapFeatures.get(e);i&&a&&this._toggleVisiblity(i,t)}toggleSelection(e){const{sketch:t}=this;t&&(t.updateOnGraphicClick=e,t.cancel())}async transformAndPlotReferencePointOnImage(e){const{feature:t,selectedLocation:a,options:i}=e;let r=!1,s=!1;const o=this.bestFeatureFootprint?.geometry;switch(o?.type){case"polygon":{const e=a.spatialReference.equals(o.spatialReference)?a:await H(a,o.spatialReference);r=o.contains(e);break}case"mesh":{const e=a.spatialReference.equals(o.spatialReference)?a:await H(a,o.spatialReference);s=o.extent.contains(e);break}}if(!r&&!s)return void this.clearReferencePointOnImage();const n=await this.worldToImage(a,t,i);if(n)return v(i),this.plotReferencePointOnImage(n),{x:n.x,y:n.y};this.clearReferencePointOnImage()}async triangulatedLocationWorkflow(e,t){if(this.currentBestFeature&&e){const{currentBestFeature:a}=this;this.triangulatedPoint&&(this.measurementVectors=[],this.triangulatedPoint=null,this.clearLocationPointOnImage(!0));const i=Ee(e,a);if(!i)return;this.measurementVectors.push(i),await this.plotReferenceLocationPoint(e,t),v(t),this._createTriangularImageLocationHandle()}}async _calculateTriangulatedPointFromGroundPoint(e,t){if(this.currentBestFeatureMeasurementImage&&e){const{currentBestFeatureMeasurementImage:a}=this,i=Ee(e,a);i&&this.measurementVectors.push(i);const r=await ze(this.measurementVectors);v(t),this.triangulatedPoint=r??this.triangulatedPoint}}async _fetchFeatures(e,t){if(!this.view)return;const a=this.layer;if(a){const i={include:a},r=this.view.toScreen(e);if(!r)return;const s=await this.view.hitTest(r,i);return this._processHitTestResults(a,s,t)}}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(a){if(y(a))return;this.setMessage("imageLoadError","error"),u.getLogger(this).error("error occurred while fetching features",a)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,features:a,invalidCameraHeading:i}=this,r=a.at(0);if(!e||!t||!r||!a||i)return void(this._sectorData=null);this._sectorData={};const o={};this._featureToSector=o;for(const h of Se)this._sectorData[h]=new s;const n=e.map((e,t)=>({...e,featureIndex:t}));n.sort((e,t)=>e.trueSuitability-t.trueSuitability);const l=n.map(({distance:e})=>e),c=Math.max(...l);n.forEach(e=>{const{distance:t,angle:i,featureIndex:s}=e,n=t/c*Ce[2],l=nt(t,c),h=ot(i);if(!this._sectorData)return;const u=Ce[3]+n*Math.sin(i*Math.PI/180),d=Ce[3]+n*Math.cos(i*Math.PI/180);let m;const p=a.at(s),g=p===r,{cameraPitch:y}=p.attributes,v=y<5;if(g&&v)m=-90;else{const e=u-Ce[3],t=d-Ce[3],a=t/Math.sqrt(e**2+t**2);let i=180*Math.acos(a)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(i*=-1),m=i}const f=""===l?h:`${l}_${h}`;g&&(m===this.bestFeatureAngle?this.previousFeatureAngle=m:this.bestFeatureAngle=m,this.navigatorCurrentBestFeature=v?null:{x:u,y:d,direction:h}),o[`${p.attributes.objectId}`]=f;const w=this._sectorData[f];w.add({angle:i,featureIndex:s,x:u,y:d,objectID:p.attributes.objectId,sector:f,featureIndexInSector:w.length})})}_handleDestroyedTriangularSketchLayer(){this.sketchTriangularGraphicsLayer&&(this.imageMeasurementViewer.imageRenderer.map.layers.remove(this.sketchTriangularGraphicsLayer),this.sketchTriangularGraphicsLayer=new D,this.imageMeasurementViewer.imageRenderer.map.layers.add(this.sketchTriangularGraphicsLayer),this.sketchTriangular&&(this.sketchTriangular.layer=this.sketchTriangularGraphicsLayer,this.sketchTriangular.view=this.imageMeasurementViewer.imageRenderer))}_initializeMeasurementService(){this._measurementService||(this._measurementService=new vt(this))}_initializeSketchTriangular(){this.sketchTriangular=new ft({view:this.imageMeasurementViewer.imageRenderer,layer:this.sketchTriangularGraphicsLayer,updateOnGraphicClick:!1,defaultUpdateOptions:{toggleToolOnClick:!1}})}_initializeSketchTriangularGraphicsLayer(){this.sketchTriangularGraphicsLayer=new D,this.imageMeasurementViewer.imageRenderer.map.layers.add(this.sketchTriangularGraphicsLayer)}_initializeVideo(){if(this.videoElement||!this.currentBestFeature)return;this.removeHandles(wt.videoPlayerHandles),this.videoElement=new fe({video:this.currentBestFeature.attributes.imagePath,georeference:new ye({extent:new G(ke)}),autoplay:!1}),this.videoElement.content?.loop&&(this.videoElement.content.loop=!1);const e=new U({source:this.videoElement,title:this.layer?.title,copyright:this.layer?.copyright});this.videoLayer=e,e&&this.videoMapView.map.layers.add(e),this.addHandles(ht(this.videoMapView),wt.videoPlayerHandles),this.videoViewModel=new mt({oiViewModel:this})}_plotLocationPointOnDefaultImage(e,a=!1){const i=C(e)?e.toJSON():e;i.x-=.5,i.y=.5-i.y,a?(this._correctedLocationPointOnImage=new t({geometry:new O({spatialReference:B.WebMercator,...i}),symbol:Qe}),this.imageMeasurementViewer.addGraphic(this._correctedLocationPointOnImage,0)):(this._locationPointOnImage=new t({geometry:new O({spatialReference:B.WebMercator,...i}),symbol:Qe}),this._imageViewer.addGraphic(this._locationPointOnImage,0))}_plotLocationPointOnPanoramicImage(e){const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=se(e,i,r),n=oe(s,o);this._locationPointOnImage=new t({geometry:new O(n,B.WebMercator),symbol:Xe}),this._panoramicViewer.addGraphic(this._locationPointOnImage,0)}_clearFeatureGeometries(){this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll()}_checkFeatures(e){return!!e?.length||(this.setMessage("noImageError","error"),this.currentBestFeature=null,!1)}async _getElevationSampleFromGround(e,t,a){if(!e[0])return;const i=await L(e);if(this._updateFootprintWithFeatures(t,i),this.view?.supportsGround)try{return await this.view.map.ground.createElevationSampler(this.footprintExtent,a)}catch(r){y(r)||u.getLogger(this).error(r)}}async processElevationSample(e,t,a){const{elevationSource:i}=t[0].attributes,r=await this._getElevationSampleFromGround(e,t,a);return r||(i&&this.footprintExtent&&Q(i)?await ae({extent:this.footprintExtent,lod:i.lod,url:i.url,rasterFunction:i.rasterFunction}):void 0)}_processSuitableFeatures(e,t){return q({features:e,selectedPoint:t,camera:lt(this.view)?this.view.camera:null,currentImage:this.currentBestFeature})}async _processHitTestResults(e,t,a){const{screenPoint:i,results:[r]}=t,s="graphic"===r?.type&&this.shouldShowSelectedImage,o=r?.mapPoint??this.view?.toMap(i);if(!o)return;o.x=E(o.x,o.spatialReference);const{layerFloorFilterClause:n}=this,l=e.spatialReference.equals(o.spatialReference)?o:await H(o,e.spatialReference),c=l.spatialReference.isGeographic?z(l):l,h=P("1=1",P(e.definitionExpression,n)),u=c.spatialReference.isGeographic?1:V(c.spatialReference),d={layerInstanceOrURL:e,point:c,queryParams:{where:h,maximumDistance:e.maximumDistance?e.maximumDistance/u:void 0,objectIds:s?[r.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(d,a)}async _queryAndLoadByObjectId(e,t,a,i){this.displayMessage=null;const{response:r}=await yt(e,t,a,i);if(v(i),!r?.features?.length)throw new gt(t);const s=X($(r.features[0].attributes).polygon.centroid),o=V(s.spatialReference);this.selectedPoint=s;const n={layerInstanceOrURL:e,point:s,queryParams:{where:P(P("1=1",P(e.definitionExpression,a)),`${e.objectIdField} <> ${t}`),maximumDistance:e.maximumDistance?e.maximumDistance/o:void 0}},l=await N(n,i);v(i);const{features:c}=l;return c.push(r.features[0]),await this.processFeatureResponse(l,s,{...i,loadBestImage:!1})}_reorderTriangularSketchLayer(){const e=this.imageMeasurementViewer.imageRenderer.map.layers?.length;this.sketchTriangularGraphicsLayer&&e&&this.imageMeasurementViewer.imageRenderer.map.layers.reorder(this.sketchTriangularGraphicsLayer,e-1)}_resetCursor(){const{activeViewer:e,imageMeasurementViewer:t}=this;e&&this.removeHandles(wt.activeViewerCursorHandles),t&&this.removeHandles(wt.imageViewerCursorHandles)}async _setImageSource(e,t,a,i,r,s){e.imageSource={datasetFormat:t.toUpperCase(),url:a.split("?")[0]},e.customParameters=Object.fromEntries(i),e.imageRotation=r??0,await e.loadImage(s)}_setMeasurementCursor(){const{activeViewer:e,imageMeasurementViewer:t,triangularMeasurementActive:a}=this;e&&this.addHandles(e.imageRenderer.acquireCursor("crosshair","high"),wt.activeViewerCursorHandles),t&&a&&this.addHandles(t.imageRenderer.acquireCursor("crosshair","high"),wt.activeViewerCursorHandles)}_toggleVisiblity(e,t){e.forEach(e=>{e.visible=t})}async _updateElevationOfSelectedPointAndLocations(e,t,a,i){const r=ce(a),{location:s,cameraHeight:o}=e[0].attributes,n=await le(s.spatialReference,s.z,o,{elevationSample:r?a:void 0,elevationSource:r?void 0:e[0].attributes.elevationSource,extent:this.footprintExtent},i);v(i);const[l,...c]=await te([t,...e.map(e=>e.attributes.geometry.clone())],n);v(i),t.elevation=l.z,e.forEach((e,t)=>{e.attributes.elevation=c[t].z})}_updateFeatures(e,t=!0){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),this.navigationNodes.removeAll(),this.navigationNodes.addMany(e.map(e=>{const{geometry:t,attributes:a}=e,{isSpherical:i,cameraHeading:r,cameraPitch:s}=a;return new dt({geometry:t,attributes:a,currentHeading:i?0:r,currentPitch:i?0:s})})),e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll(),this._updateGroundElevation=!0,t&&(this.currentBestFeature=e[0]),"video"===this.mode&&(this._initializeVideo(),this.videoElement?.loaded&&this.videoViewModel?.playVideoFromSelectedLocation(e[0]))}_updateFootprintWithFeatures(e,t){const a=[];for(const{attributes:{geometry:i}}of e)t.contains(i)||a.push([i.x,i.y]);a.sort((e,t)=>+x([e,t])),t.addRing(a),this.footprintExtent=be(t.extent,2,2)}async _updatePointsAndPolygons(e){const{pointSources:a,currentBestFeature:i,currentCoverageVisible:r,isAdditionalPointSourcesVisible:s,mode:o,layer:n}=this;if(i&&(this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),!this.invalidCameraHeading)){await(this._adapter?.createFootprints(e)),v(e);for(const e of a)e.imageID===i.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:Ye,visible:r}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:et,visible:s}));if("video"===o&&n&&!this.featureCache.length){const e=await W(n,i.geometry.spatialReference);e.features?.length&&(this.featureCache=e.features)}}}_updateCurrentBestFeature(e){if(!e)return;if(this.currentBestFeature=this.features?.at(e.featureIndex),"video"===this.mode)return void(this.currentBestFeature&&this.videoViewModel?.playVideoFromSelectedLocation(this.currentBestFeature));const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let a;if(t)a=-90;else{const t=e.x-Ce[3],i=e.y-Ce[3],r=i/Math.sqrt(t**2+i**2);let s=180*Math.acos(r)/Math.PI;(t<0&&i<0||t<0&&i>0)&&(s*=-1),a=s}a===this.bestFeatureAngle?this.previousFeatureAngle=a:this.bestFeatureAngle=a,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}_updateImageMeasurementBestFeature(e){e&&(this.currentBestFeatureMeasurementImage=this.features?.at(e.featureIndex))}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics(),this.imageMeasurementViewer.clearGraphics()}clearReferencePointOnImage(){this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage=p(this._referencePointOnImage))}clearLocationPointOnImage(e=!1){this._locationPointOnImage&&!e&&(this._imageViewer.removeGraphic(this._locationPointOnImage),this._panoramicViewer.removeGraphic(this._locationPointOnImage),this._locationPointOnImage=p(this._locationPointOnImage)),this._correctedLocationPointOnImage&&(this.imageMeasurementViewer.removeGraphic(this._correctedLocationPointOnImage),this._correctedLocationPointOnImage=p(this._correctedLocationPointOnImage))}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}async plotReferenceLocationPoint(e,t){if(this.currentBestFeatureMeasurementImage){const a=await this.worldToImage(e,this.currentBestFeatureMeasurementImage,{signal:t});v(t),a&&this.plotLocationPointOnImage(a,!0)}}setMessage(e,t,a,i){this.displayMessage={key:e,type:t,data:a,map:i}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,invalidCameraHeading:a,selectedPoint:i,activeViewer:r}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=p(this._crossSymbol)),!i||!t||"image-loaded"!==r?.state||a)return;let s;try{s=await this.worldToImage(i,t,e),v(e),await this.plotSelectedPointOnImage(s,e)}catch(o){y(o)||u.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:o,selectedPoint:i,feature:t})}}async worldToImage(e,t,a){const{footprintExtent:i}=this,{imageSize:r}=this.activeViewer;if("none"===this.mode||!t||!r||!i)return;const{attributes:{location:s,elevationSource:o,cameraHeading:n,cameraHeight:l},elevationSample:c}=t;let h=s.clone();const u=await le(s.spatialReference,s.z??0,l,{elevationSample:c,elevationSource:o});t.elevationSample=u.elevationSample;const d=Array.isArray(e)?e:[e];let m,p=await Promise.all(d.map(e=>new Promise(t=>{if(!e.hasZ)return t(te(e,u));t(e)})));if(s.spatialReference.isGeographic&&(h=await H(h,B.WebMercator,a)),p=await Promise.all(p.map(async e=>h.spatialReference.equals(e.spatialReference)?e:await H(e,h.spatialReference,a))),v(a),"panoramic"===this.mode)m=ge(p,{imageHeight:r[1],imageWidth:r[0],cameraHeading:n,cameraLocation:h});else{const e=me(t.attributes,r[0],r[1]);m=pe(p,{...e,cameraLocation:h})}return Array.isArray(e)?m:m[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:a,additionalCameraLocations:i,currentBestFeature:r,currentBestFeatureLocation:s,currentCoverageVisible:o,selectedPoint:n,view:l,_adapter:c,mode:h}=this,{attributes:{objectId:u},elevationSample:d}=r;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint),e&&!this.invalidCameraHeading&&(e.visible=o,this.bestFeatureCurrentFootprint=e),l){const e=[...a,...i,s].filter(ct);l.supportsGround&&d&&c?.updateGroundElevation&&(this._updateGroundElevation&&c.updateGroundElevation(e,d),"panoramic"===h&&c.updateGroundElevation([this.bestFeatureCurrentFootprint],d)),this._updateGroundElevation=!1,n&&(e.splice(-2,0,this.bestFeatureCurrentFootprint),e.push(new t({geometry:n.clone(),symbol:De.clone(),attributes:{imageID:u}}))),this._overlays.graphics.addMany(e)}}else if(l){if(this.invalidCameraHeading)return;this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=p(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,l?.supportsGround&&d&&c?.updateGroundElevation&&"panoramic"===h&&c.updateGroundElevation([e],d),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([S()],Mt.prototype,"activeLayer",null),e([S({readOnly:!0})],Mt.prototype,"activeViewer",null),e([S()],Mt.prototype,"accuracyParametersMissing",null),e([S()],Mt.prototype,"additionalFeatures",void 0),e([S({type:s.ofType(t)})],Mt.prototype,"additionalCameraLocations",void 0),e([S({type:s.ofType(t)})],Mt.prototype,"additionalFootprints",void 0),e([S()],Mt.prototype,"areaMeasurementResult",void 0),e([S()],Mt.prototype,"areaMeasurementAccuracy",void 0),e([S()],Mt.prototype,"bestFeatureAngle",void 0),e([S()],Mt.prototype,"bestFeatureCurrentFootprint",void 0),e([S({type:t})],Mt.prototype,"bestFeatureFootprint",void 0),e([S({type:Number})],Mt.prototype,"brightness",null),e([S()],Mt.prototype,"cameraHeadingThreshold",void 0),e([S()],Mt.prototype,"cameraPitchThreshold",void 0),e([S()],Mt.prototype,"clickAction",void 0),e([S()],Mt.prototype,"videoViewModel",void 0),e([S()],Mt.prototype,"collectionId",void 0),e([S({type:Number})],Mt.prototype,"contrast",null),e([S()],Mt.prototype,"conversionProps",void 0),e([S()],Mt.prototype,"coverageFrustums",void 0),e([S()],Mt.prototype,"coveragePolygons",void 0),e([S()],Mt.prototype,"currentBestFeature",void 0),e([S()],Mt.prototype,"currentBestFeatureMeasurementImage",void 0),e([S()],Mt.prototype,"currentBestFeatureLocation",void 0),e([S()],Mt.prototype,"currentCoverageVisible",void 0),e([S()],Mt.prototype,"currentNode",null),e([S()],Mt.prototype,"featureCache",void 0),e([S()],Mt.prototype,"navigationNodes",void 0),e([S({json:{write:!1}})],Mt.prototype,"determineWorkflowForFeature",void 0),e([S({json:{write:!1}})],Mt.prototype,"determineWorkflowForTriangularMeasurement",void 0),e([S()],Mt.prototype,"disabled",void 0),e([S()],Mt.prototype,"displayMessage",void 0),e([S()],Mt.prototype,"displayNewMeasurementButton",void 0),e([S()],Mt.prototype,"distanceMeasurementResult",void 0),e([S()],Mt.prototype,"distanceAccuracyArray",void 0),e([S()],Mt.prototype,"dataCaptureLayer",void 0),e([S({readOnly:!0})],Mt.prototype,"featureCount",null),e([S()],Mt.prototype,"features",void 0),e([S()],Mt.prototype,"groundCoordinates",void 0),e([S()],Mt.prototype,"groundCoordinatesAccuracy",void 0),e([S()],Mt.prototype,"heightMeasurementPixels",void 0),e([S()],Mt.prototype,"heightGraphic",void 0),e([S()],Mt.prototype,"heightMeasurementResult",void 0),e([S()],Mt.prototype,"heightMeasurementAccuracy",void 0),e([S()],Mt.prototype,"measurementAngle",void 0),e([S()],Mt.prototype,"tempDistance",void 0),e([S({readOnly:!0})],Mt.prototype,"imageGalleryEnabled",null),e([S()],Mt.prototype,"imageGeometryField",void 0),e([S({readOnly:!0})],Mt.prototype,"imageLoaded",null),e([S()],Mt.prototype,"imageLocationToolState",void 0),e([S({readOnly:!0})],Mt.prototype,"invalidCameraHeading",null),e([S()],Mt.prototype,"imagePointsInView",null),e([S()],Mt.prototype,"imageMeasurementViewer",void 0),e([S()],Mt.prototype,"isAdditionalCoverageVisible",void 0),e([S()],Mt.prototype,"isAdditionalPointSourcesVisible",void 0),e([S()],Mt.prototype,"measurementVectors",void 0),e([S()],Mt.prototype,"layer",void 0),e([S()],Mt.prototype,"layerView",null),e([S({readOnly:!0})],Mt.prototype,"layerFloorFilterClause",null),e([S({type:Number})],Mt.prototype,"localPort",void 0),e([S()],Mt.prototype,"mapImageConversionToolState",void 0),e([S()],Mt.prototype,"measureType",void 0),e([S()],Mt.prototype,"measurementGraphic",void 0),e([S({readOnly:!0,value:"none"})],Mt.prototype,"mode",null),e([S()],Mt.prototype,"navigationMode",void 0),e([S()],Mt.prototype,"navigatorCurrentBestFeature",void 0),e([S()],Mt.prototype,"oiObjectIdField",void 0),e([S({type:s.ofType(t)})],Mt.prototype,"overlayedCameraLocations",void 0),e([S()],Mt.prototype,"overlayedMapFeatures",void 0),e([S()],Mt.prototype,"pixelCoordinates",void 0),e([S()],Mt.prototype,"preserveAngle",void 0),e([S()],Mt.prototype,"pointSources",void 0),e([S({readOnly:!0})],Mt.prototype,"popupEnabled",null),e([S()],Mt.prototype,"previousFeatureAngle",void 0),e([S()],Mt.prototype,"referencePoint",null),e([S({readOnly:!0})],Mt.prototype,"sectorData",null),e([S()],Mt.prototype,"selectedPoint",void 0),e([S({type:Number})],Mt.prototype,"sharpness",null),e([S()],Mt.prototype,"shouldShowSelectedImage",void 0),e([S()],Mt.prototype,"sketch",void 0),e([S()],Mt.prototype,"sketchTriangular",void 0),e([S()],Mt.prototype,"sketchTriangularGraphicsLayer",void 0),e([S()],Mt.prototype,"draw",void 0),e([S()],Mt.prototype,"sketchAdapter",void 0),e([S({readOnly:!0})],Mt.prototype,"sketchGraphicsLayer",null),e([S({readOnly:!0})],Mt.prototype,"state",null),e([S({readOnly:!0})],Mt.prototype,"thumbnails",null),e([S()],Mt.prototype,"triangularMeasurementActive",void 0),e([S()],Mt.prototype,"triangulatedDistanceMeasurement",void 0),e([S()],Mt.prototype,"triangulatedDistanceAccuracy",void 0),e([S()],Mt.prototype,"triangulatedAreaMeasurement",void 0),e([S()],Mt.prototype,"triangulatedAreaAccuracy",void 0),e([S()],Mt.prototype,"triangulatedMeasurementGraphic",void 0),e([S()],Mt.prototype,"triangulatedPoint",void 0),e([S()],Mt.prototype,"triangulatedMeasurementAdapter",void 0),e([S()],Mt.prototype,"updateFootprint",void 0),e([S()],Mt.prototype,"updateFootprintPanorama",void 0),e([S()],Mt.prototype,"updatingTriangularMeasurementState",void 0),e([S({value:null})],Mt.prototype,"view",null),e([S()],Mt.prototype,"videoElement",void 0),e([S()],Mt.prototype,"videoLayer",void 0),e([S()],Mt.prototype,"videoMapView",void 0),e([S()],Mt.prototype,"_adapter",void 0),e([S()],Mt.prototype,"_sketchGraphicsLayer",null),e([S()],Mt.prototype,"_highlightedFeatureHandle",void 0),e([S()],Mt.prototype,"_imageViewer",void 0),e([S()],Mt.prototype,"_initialCurrentCoverageUpdate",void 0),e([S()],Mt.prototype,"_locationPointOnImage",void 0),e([S()],Mt.prototype,"_measurementService",void 0),e([S()],Mt.prototype,"_correctedLocationPointOnImage",void 0),e([S()],Mt.prototype,"_overlays",void 0),e([S({readOnly:!0})],Mt.prototype,"_overlaysView",null),e([S()],Mt.prototype,"_panoramicViewer",void 0),e([S()],Mt.prototype,"_referencePointOnGround",void 0),e([S()],Mt.prototype,"_referencePointOnImage",void 0),e([S()],Mt.prototype,"_sectorData",void 0),e([S()],Mt.prototype,"_featureToSector",void 0),e([S({readOnly:!0})],Mt.prototype,"_updatingHandles",void 0),e([S()],Mt.prototype,"footprintExtent",void 0),e([S()],Mt.prototype,"_featureChangedTask",void 0),Mt=e([k("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],Mt);const It=Mt;export{It 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.34/esri/copyright.txt for details.
4
4
  */
5
- import{rad2deg as t}from"../../core/mathUtils.js";import{throwIfAborted as e}from"../../core/promiseUtils.js";import{formatArea as n,formatLength as r}from"../../core/quantityFormatUtils.js";import{createArea as a,createLength as o}from"../../core/quantityUtils.js";import{set as s,determinant as i}from"../../core/libs/gl-matrix-2/math/mat3.js";import{create as c}from"../../core/libs/gl-matrix-2/factories/mat3f64.js";import{zeros as u,fromValues as l}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{distance as f}from"../../core/libs/gl-matrix-2/math/vec2.js";import{i as m,h as p,a as h}from"../../chunks/vec32.js";import y from"../../geometry/Point.js";import g from"../../geometry/Polygon.js";import x from"../../geometry/Polyline.js";import{projectWithZConversion as w,project as M}from"../../geometry/projectionUtils.js";import R from"../../geometry/SpatialReference.js";import{e as z}from"../../chunks/areaOperator.js";import{l as d,e as P}from"../../chunks/geodeticAreaOperator.js";import{l as v,e as j}from"../../chunks/geodeticDensifyOperator.js";import{l as b,e as O}from"../../chunks/geodeticLengthOperator.js";import{e as E}from"../../chunks/lengthOperator.js";import{execute as q}from"../../geometry/operators/projectOperator.js";import{e as W}from"../../chunks/simplifyOperator.js";import{isSupported as k,geodesicLengths as L,geodesicAreas as I}from"../../geometry/support/geodesicUtils.js";import{imageToWorldPanoramic as G,imageToWorld as A}from"../../layers/orientedImagery/transformations/imageToWorld.js";import{convertSphereVertexToPixelLocation as D,scaleWithFactor as U}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImagePanoramic as S,worldToImage as B}from"../../layers/orientedImagery/transformations/worldToImage.js";const F=1e5;function T(t,e){let n=180*Math.atan2(-t.y+e.y,t.x-e.x)/Math.PI;return n<0&&(n+=180),n*Math.PI/180}function H(t,e){let n=180*Math.atan2(-t.y+e.y,t.x-e.x)/Math.PI;return n<0&&(n+=180),n*Math.PI/180}function V(t,e,n){if(!t?.length||!e?.length||!n)return;const[r,a]=t,[,o]=e,s=o-a;return[r+s*Math.cos(n),a+s*Math.sin(n)]}async function C(t,e,n){if(await v(),k(t)){const t=L([e],"meters")[0];return{area:I([n],"square-meters")[0],perimeter:t}}const r=R.WGS84,a=M(e,r),o=M(n,r);let s=j(o,F);if(s=s?W(s):null,!s)return null;const i=L([a],"meters")[0];return{area:I([s],"square-meters")[0],perimeter:i}}async function J(t,n,r,a,o=!1,s){if(n.length<2||!a||!r||!t)return null;const i=dt(r,t);if(!i)return null;const c=n.map(t=>[t.x,t.y]),u=c.at(0),l=c.at(-1);if(!u||!l)return null;const f=i.map(e=>qt([u,l],e,t,o,!1)),m=await Promise.all(f);e(s);let p=0;for(const e of m){if(!e)return null;const t=Math.abs(e-a);p=Math.max(t,p)}return p}async function K(t,n,r,a,o,s=!1,i){if(n.length<2||!a||!r||!t)throw new Error("Missing parameters");const c=Pt(r,t),u=n.map(t=>[t.x,t.y]),l=u.at(0),f=u.at(-1),m=c.map(e=>Wt([l,f],e,t,o,s,!1)),p=await Promise.all(m);e(i);let h=0;for(const e of p){if(!e)return 0;const t=Math.abs(e-a);h=Math.max(t,h)}return h}function N(t,e,n=1){const r=Rt(t,!1);if(!r?.length)return;return 20*f([r[0].x,r[0].y],[r.at(-1).x,r.at(-1).y])*n/e}async function Q(t){await b();const e=t.spatialReference;if(e.isGeographic){if(k(e))return L([t],"meters")[0];const n=M(t,R.WGS84);return L([n],"meters")[0]}return e.isWebMercator?O(t):E(t)}function X(t){if(!t?.length)throw new Error("Invalid deviations array");const[e,n,r]=[0,1,2].map(e=>t.map(t=>t[e]).filter(t=>null!==t)).map(t=>t.length?bt(t):0);return[e,n,r]}function Y(t,e){const n=W(e);if(!n)return null;const r=E(t);return{area:z(n),perimeter:r}}function Z(t,e){return[(t[1][0]-t[0][0])/e,(t[1][1]-t[0][1])/e,(t[1][2]-t[0][2])/e]}async function $(t,e){await Promise.all([d(),v(),b()]);let n=j(e,F);if(n=n?W(n):null,!n)return null;const r=O(t);return{area:P(n),perimeter:r}}async function _(t,n,r){if(!n||!t)throw new Error("Missing required parameters");const a=await A(t,n);e(r);const o=a.clone();o.z?o.z+=20:o.z=20;const{averageElevation:s,cameraPitch:i,cameraRoll:c,farDistance:u,...l}=n;return B(o,l)}async function tt(t,n,r,a){const{attributes:o}=r,{location:s}=o,{updateElevationProps:i,...c}=n;if(!t||!n)throw new Error("Missing parameters");let u=s.clone();u.spatialReference.isGeographic&&(u=await w(u,R.WebMercator));const l=await G(t,{...c,cameraLocation:u},i);e(a);const f=l.clone();return f.z?f.z+=20:f.z=20,S(f,c)}function et(t,e,n,r,a=0,o=1,s){const{averageElevation:i,cameraPitch:c,cameraRoll:u,farDistance:l,...m}=r;if(a>=5||o<=.1){return{value:t*Et(r.cameraLocation.spatialReference)}}const p=new y({x:e.x,y:e.y,z:e.z?e.z+t:t,spatialReference:r.cameraLocation.spatialReference}),h=B(p,m),g=f([n[0].x,n[0].y],[h.x,h.y]),x=n.at(0),w=n.at(-1);if(!x||!w)return null;const M=f([x.x,x.y],[w.x,w.y])*t/g;return et(M,e,n,r,a+1,Math.abs(t-M))}function nt(t,e,n,r,a=0,o=1,s){const{averageElevation:i,horizontalFieldOfView:c,verticalFieldOfView:u,farDistance:l,...m}=r;if(a>=5||o<=.1){return{value:t*Et(r.cameraLocation.spatialReference)}}const p=new y({x:e.x,y:e.y,z:e.z?e.z+t:t,spatialReference:r.cameraLocation.spatialReference}),h=S(p,m),g=f([n[0].x,n[0].y],[h.x,h.y]),x=n.at(0),w=n.at(-1);if(!x||!w)return null;const M=f([x.x,x.y],[w.x,w.y])*t/g;return nt(M,e,n,r,a+1,Math.abs(t-M))}function rt(t,e,n){return new x({paths:[[[t.x,t.y,t.z??0],[e.x,e.y,e.z??0]]],spatialReference:n})}function at(t){return 1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*t/6378137)))}function ot(t,e){return Math.sqrt((Math.sqrt((t[0][0]-t[1][0])**2+(t[0][1]-t[1][1])**2)/e)**2+(t[0][2]-t[1][2])**2)}function st(t,e,n){return Math.sqrt((t.z??0-(e.z??0))**2+(Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2)/n)**2)*n}function it(t,e,n,r){return Bt(St([t.x,t.y,t.z??0],[e.x,e.y,e.z??0]),1/n,1/r)}function ct(t,e){return Math.sqrt((t[0][0]-t[1][0])**2+(t[0][1]-t[1][1])**2)/e}function ut(e){return t(Math.atan((e[1][2]-e[0][2])/Math.sqrt((e[1][0]-e[0][0])**2+(e[1][1]-e[0][1])**2)))}function lt(e){let n=90-t(Math.atan2(e[1][1]-e[0][1],e[1][0]-e[0][0]));return n<0&&(n+=360),n}function ft(t,e){return new y({x:(t.pointOnA[0]+t.pointOnB[0])/2,y:(t.pointOnA[1]+t.pointOnB[1])/2,z:(t.pointOnA[2]+t.pointOnB[2])/2,spatialReference:e})}async function mt(t){if(2===t?.length){const e=[];let n=1;const[r,a]=t,o=r.camera.spatialReference,{measurePoints:s}=r;for(let t=0;t<s.length;t++){const s=rt(r.camera,r.measurePoints[t],o),i=rt(a.camera,a.measurePoints[t],o),c=await At(s,i);if(!c)return null;const u=ft(c,o);u.spatialReference.isWebMercator&&(n=at(u.y)),e.push([u.x,u.y,u.z??0])}if(e?.length>1){return{distance:ot(e,n),horizontalDistance:ct(e,n),verticalDistance:Math.abs(e[0][2]-e[1][2]),slope:ut(e),aspect:lt(e)}}}return null}async function pt(t){const e=t[0].camera.spatialReference;if(2!==t?.length)return null;const[n,r]=t,{camera:a,measurePoints:o}=n,{camera:s,measurePoints:i}=r,c=rt(a,o[0],e),u=rt(s,i[0],e),l=await At(c,u);return l?ft(l,e)??null:null}async function ht(t,e){if(!t?.length)return null;const n=[],r=t[0],a=t[1],o=r.camera.spatialReference,{measurePoints:s}=r;for(let l=0;l<s.length;l++){const t=rt(r.camera,r.measurePoints[l],o),e=rt(a.camera,a.measurePoints[l],o),s=await At(t,e);if(!s)return null;const i=ft(s,o);n.push([i.x,i.y,i.z??0])}if(n?.length<2)return null;const i=new x({paths:[n],spatialReference:e}),c=new g({rings:[n],spatialReference:e});if(e.isGeographic){const t=await C(e,i,c);return t?.area??null}if(e.isWebMercator){const t=await $(i,c);return t?.area??null}const u=Y(i,c);return u?.area??null}function yt(t,e){if(!t)return null;const n=e.geometry.clone(),r=Array.isArray(t)?t:[t],a=[];return r.forEach(t=>{let e=!1;t.spatialReference.isWGS84&&(t=q(t,new R({wkid:3857})),e=!0);const r=t.spatialReference.isWebMercator?at(t.y):1,o=st(t,n,r),s=it(t,n,o,r),i=((t.z??0)-(n.z??0))/s[2]*r;let c=new y({spatialReference:t.spatialReference,x:n.x+i*s[0],y:n.y+i*s[1],z:(n.z??0)+i*s[2]/r});e&&(c=q(c,new R({wkid:4326}))),a.push(c)}),{camera:n,measurePoints:r,tempMeasurePoints:a}}async function gt(t,e){const{updateElevationProps:n,...r}=e;return await A(t,r,n)}async function xt(t,e){const{updateElevationProps:n,...r}=e;return G(t,r,n)}function wt(t){navigator.clipboard.writeText(t).catch(t=>{throw t})}function Mt(t){const e=t.map(t=>[t.x,t.y]),n=t[0].spatialReference;return new x({paths:[e],spatialReference:n})}function Rt(t,e){return t.map(t=>({x:e?.5+t[0]:t[0],y:e?.5-t[1]:t[1]}))}function zt(t,e,n,a,s){const i="measurement"===t?e:n;if(s&&i)return r(a,o(i,"meters"),s,3)||null}function dt(t,e){const{cameraPitch:n,cameraRoll:r,cameraLocation:a}=t,{x:o,y:s,z:i,spatialReference:c}=a;if(e.every(t=>0===t)||!e||!e.length)return null;const[u,l,,f,m]=e,p=[-f,0,f],h=[-m,0,m],g=[-u,0,u],x=[-l,0,l],w=[];for(const M of p)for(const e of h)for(const a of g)for(const u of g)for(const l of x){const f={...t};f.cameraPitch=n+M,f.cameraRoll=r+e,f.cameraLocation=new y({x:o+a,y:s+u,z:i?i+l:0,spatialReference:{wkid:c.wkid}}),w.push(f)}return w}function Pt(t,e){const{cameraHeading:n,cameraLocation:r}=t,{x:a,y:o,z:s,spatialReference:i}=r;if(e.every(t=>0===t)||!e||!e.length)throw new Error("Invalid parameters");const[c,u,l]=e,f=l>0?[-l,0,l]:[],m=c>0?[-c,0,c]:[],p=u>0?[-u,0,u]:[],h=[];for(const g of f)for(const e of m)for(const r of m)for(const c of p){const u={...t};u.cameraHeading=n+g,u.cameraLocation=new y({x:a+e,y:o+r,z:s?s+c:0,spatialReference:{wkid:i.wkid}}),h.push(u)}return h}function vt(t,e,n,a,s){const i="measurement"===t?e:bt(n);if(s&&i)return r(a,o(i,"meters"),s,3)||null}function jt(t,e,r,o,s){const i="measurement"===t?e:r;if(s&&i)return n(o,a(i,"square-meters"),s,3)||null}function bt(t){return Math.sqrt(t.reduce((t,e)=>t+e**2,0))}function Ot(t,e,n){if("default"===e)return t;const r={x:t[0],y:t[1],z:t[2]},a=D(r,n[0],n[1]);return[a.x,a.y]}function Et(t){return t.metersPerUnit}async function qt(t,n,r,a=!1,o=!1,s){if(!t||!n||t.length<2)return null;const i=Rt(t,a);if(!i||i.length<2)return null;const[c,u]=[i[0],i.at(-1)];if(!u)return null;const l=[c],m=await A(c,n);e(s);const p=m.clone();p.z?p.z+=20:p.z=20;const{averageElevation:h,cameraPitch:y,cameraRoll:g,farDistance:x,...w}=n,M=B(p,w),R=f([c.x,c.y],[M.x,M.y]),z=T(c,M);if(!z)return;const d=V([c.x,c.y],[u.x,u.y],z);if(!d?.length)return;l.push({x:d[0],y:d[1]});const P=20*f([l[0].x,l[0].y],[l[1].x,l[1].y])*Et(n.cameraLocation.spatialReference)/R;if(!o)return P;const v=et(P,m,l,n,0,1);return v?.value}async function Wt(t,n,r,a,o=!1,s=!1,i){const{attributes:c}=a,{location:u}=c,{updateElevationProps:l,...m}=n;if(!t||!n||t.length<2)throw new Error("Invalid parameters");const p=Rt(t,o),[h,y]=[p[0],p.at(-1)],g=[h];let x=u.clone();x.spatialReference.isGeographic&&(x=await w(x,R.WebMercator));const M=await G(h,{...m,cameraLocation:x},l);e(i);const z=M.clone();z.z?z.z+=20:z.z=20;const d=S(z,m),P=f([h.x,h.y],[d.x,d.y]),v=T(h,d);if(!v)return;const j=V([h.x,h.y],[y.x,y.y],v);if(!j?.length)return;g.push({x:j[0],y:j[1]});const b=20*f([g[0].x,g[0].y],[g[1].x,g[1].y])*Et(n.cameraLocation.spatialReference)/P;if(!s)return b;const O=nt(b,M,g,n,0,1);return O?.value}async function kt(t,e,n=!1){if(t.length<3)return null;const r=Rt(t,n),a=await gt(r,e),o=a.map(({x:t,y:e})=>[t,e]);t.push(t[0]),o.push(o[0]);const s=a[0].spatialReference,i=new x({paths:[o],spatialReference:s}),c=new g({rings:[o],spatialReference:s});return s.isGeographic?C(s,i,c):s.isWebMercator?$(i,c):Y(i,c)}async function Lt(t,n,r=!1,a){if(t.length<3)return null;const o=Rt(t,r),s=await xt(o,n);e(a);const i=s.map(({x:t,y:e})=>[t,e]);t.push(t[0]),i.push(i[0]);const c=s[0].spatialReference,u=new x({paths:[i],spatialReference:c}),l=new g({rings:[i],spatialReference:c});return c.isGeographic?C(c,u,l):c.isWebMercator?$(u,l):Y(u,l)}async function It(t,e,n=!1){const r=Rt(t,n);return Q(Mt(await gt(r,e)))}async function Gt(t,n,r=!1,a){const o=Rt(t,r),s=await xt(o,n);e(a);return Q(Mt(s))}async function At(t,e){const n=c(),r=t.paths[0][0],a=e.paths[0][0];let o,u;t.spatialReference.isWGS84||t.spatialReference.isWebMercator?(await b(),o=O(t),u=O(e)):(o=E(t),u=E(e));const l=Z(t.paths[0],o),f=Z(e.paths[0],u),m=Dt(l,f),[p,h,y]=l,[g,x,w]=f.map(t=>-t),[M,R,z]=m,[d,P,v]=[a[0]-r[0],a[1]-r[1],a[2]-r[2]];s(n,p,g,M,h,x,R,y,w,z);const j=i(n);if(0===j)return null;s(n,d,g,M,P,x,R,v,w,z);const q=i(n);s(n,p,d,M,h,P,R,y,v,z);const W=i(n);s(n,p,g,d,h,x,P,y,w,v);const k=q/j,L=W/j,I=i(n)/j;return{distance:Math.abs(I/Math.sqrt(m[0]*m[0]+m[1]*m[1]+m[2]*m[2])),pointOnA:Ut(r,k,l),pointOnB:Ut(a,L,f)}}function Dt(t,e){const n=u(),r=m(u(),t[0],t[1],t[2]),a=m(u(),e[0],e[1],e[2]),o=p(n,r,a);return[o[0],o[1],o[2]]}function Ut(t,e,n){return[t[0]+e*n[0],t[1]+e*n[1],t[2]+e*n[2]]}function St(t,e){const n=l(t[0],t[1],t[2]),r=l(e[0],e[1],e[2]);return h(u(),n,r)}function Bt(t,e,n){const r=U(t,e,n);return[r[0],r[1],r[2]]}export{T as calculateAngle,H as calculateAnglePano,V as calculateCorrectedPixel,J as calculateHeightAccuracy,K as calculateHeightAccuracyPanoramic,N as calculateHeightFromTemporaryDistance,X as calculateLocationAccuracyFromDeviations,tt as calculateReferenceImagePointPanoramic,_ as calculateTempImagePoint,et as computeHeightIteratively,nt as computeHeightIterativelyPanoramic,ht as computeTriangulatedAreaMeasurement,mt as computeTriangulatedDistanceMeasurement,pt as computeTriangulatedPoint,yt as computeTriangulatedVector,wt as copyToClipboard,Rt as formatPixels,dt as generateCombinations,Pt as generateCombinationsPanoramic,jt as getConvertedArea,vt as getConvertedDistance,zt as getConvertedHeight,Ot as getModeCorrectedPoint,bt as getRootOfSumOfSquaredErrors,Et as getUnitRateFromSpatialReference,qt as heightMeasurement2D,Wt as heightMeasurementPanoramic,kt as pixelAreaMeasurement2D,Lt as pixelAreaMeasurementPanoramic,It as pixelDistanceMeasurement2D,Gt as pixelDistanceMeasurementPanoramic,Bt as scale,At as solveSkewLinesIntersection,St as subtract};
5
+ import{rad2deg as t}from"../../core/mathUtils.js";import{throwIfAborted as e}from"../../core/promiseUtils.js";import{formatArea as n,formatLength as r}from"../../core/quantityFormatUtils.js";import{createArea as a,createLength as o}from"../../core/quantityUtils.js";import{set as s,determinant as i}from"../../core/libs/gl-matrix-2/math/mat3.js";import{create as c}from"../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromValues as u,zeros as l}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{distance as f}from"../../core/libs/gl-matrix-2/math/vec2.js";import{a as m,i as p,h}from"../../chunks/vec32.js";import y from"../../geometry/Point.js";import g from"../../geometry/Polygon.js";import x from"../../geometry/Polyline.js";import{projectWithZConversion as w,project as M}from"../../geometry/projectionUtils.js";import R from"../../geometry/SpatialReference.js";import{e as z}from"../../chunks/areaOperator.js";import{l as d,e as P}from"../../chunks/geodeticAreaOperator.js";import{l as v,e as j}from"../../chunks/geodeticDensifyOperator.js";import{l as b,e as O}from"../../chunks/geodeticLengthOperator.js";import{e as E}from"../../chunks/lengthOperator.js";import{execute as q}from"../../geometry/operators/projectOperator.js";import{e as W}from"../../chunks/simplifyOperator.js";import{isSupported as k,geodesicLengths as L,geodesicAreas as I}from"../../geometry/support/geodesicUtils.js";import{imageToWorldPanoramic as G,imageToWorld as A}from"../../layers/orientedImagery/transformations/imageToWorld.js";import{convertSphereVertexToPixelLocation as D,scaleWithFactor as U}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImagePanoramic as S,worldToImage as B}from"../../layers/orientedImagery/transformations/worldToImage.js";const F=1e5;function T(t,e){let n=180*Math.atan2(-t.y+e.y,t.x-e.x)/Math.PI;return n<0&&(n+=180),n*Math.PI/180}function H(t,e){let n=180*Math.atan2(-t.y+e.y,t.x-e.x)/Math.PI;return n<0&&(n+=180),n*Math.PI/180}function V(t,e,n){if(!t?.length||!e?.length||!n)return;const[r,a]=t,[,o]=e,s=o-a;return[r+s*Math.cos(n),a+s*Math.sin(n)]}async function C(t,e,n){if(await v(),k(t)){const t=L([e],"meters")[0];return{area:I([n],"square-meters")[0],perimeter:t}}const r=R.WGS84,a=M(e,r),o=M(n,r);let s=j(o,F);if(s=s?W(s):null,!s)return null;const i=L([a],"meters")[0];return{area:I([s],"square-meters")[0],perimeter:i}}async function J(t,n,r,a,o=!1,s){if(n.length<2||!a||!r||!t)return null;const i=dt(r,t);if(!i)return null;const c=n.map(t=>[t.x,t.y]),u=c.at(0),l=c.at(-1);if(!u||!l)return null;const f=i.map(e=>qt([u,l],e,t,o,!1)),m=await Promise.all(f);e(s);let p=0;for(const e of m){if(!e)return null;const t=Math.abs(e-a);p=Math.max(t,p)}return p}async function K(t,n,r,a,o,s=!1,i){if(n.length<2||!a||!r||!t)throw new Error("Missing parameters");const c=Pt(r,t),u=n.map(t=>[t.x,t.y]),l=u.at(0),f=u.at(-1),m=c.map(e=>Wt([l,f],e,t,o,s,!1)),p=await Promise.all(m);e(i);let h=0;for(const e of p){if(!e)return 0;const t=Math.abs(e-a);h=Math.max(t,h)}return h}function N(t,e,n=1){const r=Rt(t,!1);if(!r?.length)return;return 20*f([r[0].x,r[0].y],[r.at(-1).x,r.at(-1).y])*n/e}async function Q(t){await b();const e=t.spatialReference;if(e.isGeographic){if(k(e))return L([t],"meters")[0];const n=M(t,R.WGS84);return L([n],"meters")[0]}return e.isWebMercator?O(t):E(t)}function X(t){if(!t?.length)throw new Error("Invalid deviations array");const[e,n,r]=[0,1,2].map(e=>t.map(t=>t[e]).filter(t=>null!==t)).map(t=>t.length?bt(t):0);return[e,n,r]}function Y(t,e){const n=W(e);if(!n)return null;const r=E(t);return{area:z(n),perimeter:r}}function Z(t,e){return[(t[1][0]-t[0][0])/e,(t[1][1]-t[0][1])/e,(t[1][2]-t[0][2])/e]}async function $(t,e){await Promise.all([d(),v(),b()]);let n=j(e,F);if(n=n?W(n):null,!n)return null;const r=O(t);return{area:P(n),perimeter:r}}async function _(t,n,r){if(!n||!t)throw new Error("Missing required parameters");const a=await A(t,n);e(r);const o=a.clone();o.z?o.z+=20:o.z=20;const{averageElevation:s,cameraPitch:i,cameraRoll:c,farDistance:u,...l}=n;return B(o,l)}async function tt(t,n,r,a){const{attributes:o}=r,{location:s}=o,{updateElevationProps:i,...c}=n;if(!t||!n)throw new Error("Missing parameters");let u=s.clone();u.spatialReference.isGeographic&&(u=await w(u,R.WebMercator));const l=await G(t,{...c,cameraLocation:u},i);e(a);const f=l.clone();return f.z?f.z+=20:f.z=20,S(f,c)}function et(t,e,n,r,a=0,o=1,s){const{averageElevation:i,cameraPitch:c,cameraRoll:u,farDistance:l,...m}=r;if(a>=5||o<=.1){return{value:t*Et(r.cameraLocation.spatialReference)}}const p=new y({x:e.x,y:e.y,z:e.z?e.z+t:t,spatialReference:r.cameraLocation.spatialReference}),h=B(p,m),g=f([n[0].x,n[0].y],[h.x,h.y]),x=n.at(0),w=n.at(-1);if(!x||!w)return null;const M=f([x.x,x.y],[w.x,w.y])*t/g;return et(M,e,n,r,a+1,Math.abs(t-M))}function nt(t,e,n,r,a=0,o=1,s){const{averageElevation:i,horizontalFieldOfView:c,verticalFieldOfView:u,farDistance:l,...m}=r;if(a>=5||o<=.1){return{value:t*Et(r.cameraLocation.spatialReference)}}const p=new y({x:e.x,y:e.y,z:e.z?e.z+t:t,spatialReference:r.cameraLocation.spatialReference}),h=S(p,m),g=f([n[0].x,n[0].y],[h.x,h.y]),x=n.at(0),w=n.at(-1);if(!x||!w)return null;const M=f([x.x,x.y],[w.x,w.y])*t/g;return nt(M,e,n,r,a+1,Math.abs(t-M))}function rt(t,e,n){return new x({paths:[[[t.x,t.y,t.z??0],[e.x,e.y,e.z??0]]],spatialReference:n})}function at(t){return 1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*t/6378137)))}function ot(t,e){return Math.sqrt((Math.sqrt((t[0][0]-t[1][0])**2+(t[0][1]-t[1][1])**2)/e)**2+(t[0][2]-t[1][2])**2)}function st(t,e,n){return Math.sqrt((t.z??0-(e.z??0))**2+(Math.sqrt((t.x-e.x)**2+(t.y-e.y)**2)/n)**2)*n}function it(t,e,n,r){return Bt(St([t.x,t.y,t.z??0],[e.x,e.y,e.z??0]),1/n,1/r)}function ct(t,e){return Math.sqrt((t[0][0]-t[1][0])**2+(t[0][1]-t[1][1])**2)/e}function ut(e){return t(Math.atan((e[1][2]-e[0][2])/Math.sqrt((e[1][0]-e[0][0])**2+(e[1][1]-e[0][1])**2)))}function lt(e){let n=90-t(Math.atan2(e[1][1]-e[0][1],e[1][0]-e[0][0]));return n<0&&(n+=360),n}function ft(t,e){return new y({x:(t.pointOnA[0]+t.pointOnB[0])/2,y:(t.pointOnA[1]+t.pointOnB[1])/2,z:(t.pointOnA[2]+t.pointOnB[2])/2,spatialReference:e})}async function mt(t){if(2===t?.length){const e=[];let n=1;const[r,a]=t,o=r.camera.spatialReference,{measurePoints:s}=r;for(let t=0;t<s.length;t++){const s=rt(r.camera,r.measurePoints[t],o),i=rt(a.camera,a.measurePoints[t],o),c=await At(s,i);if(!c)return null;const u=ft(c,o);u.spatialReference.isWebMercator&&(n=at(u.y)),e.push([u.x,u.y,u.z??0])}if(e?.length>1){return{distance:ot(e,n),horizontalDistance:ct(e,n),verticalDistance:Math.abs(e[0][2]-e[1][2]),slope:ut(e),aspect:lt(e)}}}return null}async function pt(t){const e=t[0].camera.spatialReference;if(2!==t?.length)return null;const[n,r]=t,{camera:a,measurePoints:o}=n,{camera:s,measurePoints:i}=r,c=rt(a,o[0],e),u=rt(s,i[0],e),l=await At(c,u);return l?ft(l,e)??null:null}async function ht(t,e){if(!t?.length)return null;const n=[],r=t[0],a=t[1],o=r.camera.spatialReference,{measurePoints:s}=r;for(let l=0;l<s.length;l++){const t=rt(r.camera,r.measurePoints[l],o),e=rt(a.camera,a.measurePoints[l],o),s=await At(t,e);if(!s)return null;const i=ft(s,o);n.push([i.x,i.y,i.z??0])}if(n?.length<2)return null;const i=new x({paths:[n],spatialReference:e}),c=new g({rings:[n],spatialReference:e});if(e.isGeographic){const t=await C(e,i,c);return t?.area??null}if(e.isWebMercator){const t=await $(i,c);return t?.area??null}const u=Y(i,c);return u?.area??null}function yt(t,e){if(!t)return null;const n=e.geometry.clone(),r=Array.isArray(t)?t:[t],a=[];return r.forEach(t=>{let e=!1;t.spatialReference.isWGS84&&(t=q(t,new R({wkid:3857})),e=!0);const r=t.spatialReference.isWebMercator?at(t.y):1,o=st(t,n,r),s=it(t,n,o,r),i=((t.z??0)-(n.z??0))/s[2]*r;let c=new y({spatialReference:t.spatialReference,x:n.x+i*s[0],y:n.y+i*s[1],z:(n.z??0)+i*s[2]/r});e&&(c=q(c,new R({wkid:4326}))),a.push(c)}),{camera:n,measurePoints:r,tempMeasurePoints:a}}async function gt(t,e){const{updateElevationProps:n,...r}=e;return await A(t,r,n)}async function xt(t,e){const{updateElevationProps:n,...r}=e;return G(t,r,n)}function wt(t){navigator.clipboard.writeText(t).catch(t=>{throw t})}function Mt(t){const e=t.map(t=>[t.x,t.y]),n=t[0].spatialReference;return new x({paths:[e],spatialReference:n})}function Rt(t,e){return t.map(t=>({x:e?.5+t[0]:t[0],y:e?.5-t[1]:t[1]}))}function zt(t,e,n,a,s){const i="measurement"===t?e:n;if(s&&i)return r(a,o(i,"meters"),s,3)||null}function dt(t,e){const{cameraPitch:n,cameraRoll:r,cameraLocation:a}=t,{x:o,y:s,z:i,spatialReference:c}=a;if(e.every(t=>0===t)||!e||!e.length)return null;const[u,l,,f,m]=e,p=[-f,0,f],h=[-m,0,m],g=[-u,0,u],x=[-l,0,l],w=[];for(const M of p)for(const e of h)for(const a of g)for(const u of g)for(const l of x){const f={...t};f.cameraPitch=n+M,f.cameraRoll=r+e,f.cameraLocation=new y({x:o+a,y:s+u,z:i?i+l:0,spatialReference:{wkid:c.wkid}}),w.push(f)}return w}function Pt(t,e){const{cameraHeading:n,cameraLocation:r}=t,{x:a,y:o,z:s,spatialReference:i}=r;if(e.every(t=>0===t)||!e||!e.length)throw new Error("Invalid parameters");const[c,u,l]=e,f=l>0?[-l,0,l]:[],m=c>0?[-c,0,c]:[],p=u>0?[-u,0,u]:[],h=[];for(const g of f)for(const e of m)for(const r of m)for(const c of p){const u={...t};u.cameraHeading=n+g,u.cameraLocation=new y({x:a+e,y:o+r,z:s?s+c:0,spatialReference:{wkid:i.wkid}}),h.push(u)}return h}function vt(t,e,n,a,s){const i="measurement"===t?e:bt(n);if(s&&i)return r(a,o(i,"meters"),s,3)||null}function jt(t,e,r,o,s){const i="measurement"===t?e:r;if(s&&i)return n(o,a(i,"square-meters"),s,3)||null}function bt(t){return Math.sqrt(t.reduce((t,e)=>t+e**2,0))}function Ot(t,e,n){if("default"===e)return t;const r={x:t[0],y:t[1],z:t[2]},a=D(r,n[0],n[1]);return[a.x,a.y]}function Et(t){return t.metersPerUnit}async function qt(t,n,r,a=!1,o=!1,s){if(!t||!n||t.length<2)return null;const i=Rt(t,a);if(!i||i.length<2)return null;const[c,u]=[i[0],i.at(-1)];if(!u)return null;const l=[c],m=await A(c,n);e(s);const p=m.clone();p.z?p.z+=20:p.z=20;const{averageElevation:h,cameraPitch:y,cameraRoll:g,farDistance:x,...w}=n,M=B(p,w),R=f([c.x,c.y],[M.x,M.y]),z=T(c,M);if(!z)return;const d=V([c.x,c.y],[u.x,u.y],z);if(!d?.length)return;l.push({x:d[0],y:d[1]});const P=20*f([l[0].x,l[0].y],[l[1].x,l[1].y])*Et(n.cameraLocation.spatialReference)/R;if(!o)return P;const v=et(P,m,l,n,0,1);return v?.value}async function Wt(t,n,r,a,o=!1,s=!1,i){const{attributes:c}=a,{location:u}=c,{updateElevationProps:l,...m}=n;if(!t||!n||t.length<2)throw new Error("Invalid parameters");const p=Rt(t,o),[h,y]=[p[0],p.at(-1)],g=[h];let x=u.clone();x.spatialReference.isGeographic&&(x=await w(x,R.WebMercator));const M=await G(h,{...m,cameraLocation:x},l);e(i);const z=M.clone();z.z?z.z+=20:z.z=20;const d=S(z,m),P=f([h.x,h.y],[d.x,d.y]),v=T(h,d);if(!v)return;const j=V([h.x,h.y],[y.x,y.y],v);if(!j?.length)return;g.push({x:j[0],y:j[1]});const b=20*f([g[0].x,g[0].y],[g[1].x,g[1].y])*Et(n.cameraLocation.spatialReference)/P;if(!s)return b;const O=nt(b,M,g,n,0,1);return O?.value}async function kt(t,e,n=!1){if(t.length<3)return null;const r=Rt(t,n),a=await gt(r,e),o=a.map(({x:t,y:e})=>[t,e]);t.push(t[0]),o.push(o[0]);const s=a[0].spatialReference,i=new x({paths:[o],spatialReference:s}),c=new g({rings:[o],spatialReference:s});return s.isGeographic?C(s,i,c):s.isWebMercator?$(i,c):Y(i,c)}async function Lt(t,n,r=!1,a){if(t.length<3)return null;const o=Rt(t,r),s=await xt(o,n);e(a);const i=s.map(({x:t,y:e})=>[t,e]);t.push(t[0]),i.push(i[0]);const c=s[0].spatialReference,u=new x({paths:[i],spatialReference:c}),l=new g({rings:[i],spatialReference:c});return c.isGeographic?C(c,u,l):c.isWebMercator?$(u,l):Y(u,l)}async function It(t,e,n=!1){const r=Rt(t,n);return Q(Mt(await gt(r,e)))}async function Gt(t,n,r=!1,a){const o=Rt(t,r),s=await xt(o,n);e(a);return Q(Mt(s))}async function At(t,e){const n=c(),r=t.paths[0][0],a=e.paths[0][0];let o,u;t.spatialReference.isWGS84||t.spatialReference.isWebMercator?(await b(),o=O(t),u=O(e)):(o=E(t),u=E(e));const l=Z(t.paths[0],o),f=Z(e.paths[0],u),m=Dt(l,f),[p,h,y]=l,[g,x,w]=f.map(t=>-t),[M,R,z]=m,[d,P,v]=[a[0]-r[0],a[1]-r[1],a[2]-r[2]];s(n,p,g,M,h,x,R,y,w,z);const j=i(n);if(0===j)return null;s(n,d,g,M,P,x,R,v,w,z);const q=i(n);s(n,p,d,M,h,P,R,y,v,z);const W=i(n);s(n,p,g,d,h,x,P,y,w,v);const k=q/j,L=W/j,I=i(n)/j;return{distance:Math.abs(I/Math.sqrt(m[0]*m[0]+m[1]*m[1]+m[2]*m[2])),pointOnA:Ut(r,k,l),pointOnB:Ut(a,L,f)}}function Dt(t,e){const n=l(),r=p(l(),t[0],t[1],t[2]),a=p(l(),e[0],e[1],e[2]),o=h(n,r,a);return[o[0],o[1],o[2]]}function Ut(t,e,n){return[t[0]+e*n[0],t[1]+e*n[1],t[2]+e*n[2]]}function St(t,e){const n=u(t[0],t[1],t[2]),r=u(e[0],e[1],e[2]);return m(l(),n,r)}function Bt(t,e,n){const r=U(t,e,n);return[r[0],r[1],r[2]]}export{T as calculateAngle,H as calculateAnglePano,V as calculateCorrectedPixel,J as calculateHeightAccuracy,K as calculateHeightAccuracyPanoramic,N as calculateHeightFromTemporaryDistance,X as calculateLocationAccuracyFromDeviations,tt as calculateReferenceImagePointPanoramic,_ as calculateTempImagePoint,et as computeHeightIteratively,nt as computeHeightIterativelyPanoramic,ht as computeTriangulatedAreaMeasurement,mt as computeTriangulatedDistanceMeasurement,pt as computeTriangulatedPoint,yt as computeTriangulatedVector,wt as copyToClipboard,Rt as formatPixels,dt as generateCombinations,Pt as generateCombinationsPanoramic,jt as getConvertedArea,vt as getConvertedDistance,zt as getConvertedHeight,Ot as getModeCorrectedPoint,bt as getRootOfSumOfSquaredErrors,Et as getUnitRateFromSpatialReference,qt as heightMeasurement2D,Wt as heightMeasurementPanoramic,kt as pixelAreaMeasurement2D,Lt as pixelAreaMeasurementPanoramic,It as pixelDistanceMeasurement2D,Gt as pixelDistanceMeasurementPanoramic,Bt as scale,At as solveSkewLinesIntersection,St as subtract};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
+ */
5
+ import{throwIfAborted as e}from"../../../core/promiseUtils.js";import{distance as t}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{projectWithZConversion as a}from"../../../geometry/projectionUtils.js";import{imageToWorld as r,imageToWorldPanoramic as i}from"../../../layers/orientedImagery/transformations/imageToWorld.js";import{getImageToWorldProperties as n}from"../../../layers/orientedImagery/transformations/utils.js";import{formatPixels as s,heightMeasurementPanoramic as l,heightMeasurement2D as c,calculateHeightAccuracyPanoramic as u,calculateHeightAccuracy as o,pixelAreaMeasurement2D as m,pixelAreaMeasurementPanoramic as w,pixelDistanceMeasurement2D as d,pixelDistanceMeasurementPanoramic as h,generateCombinations as M,getRootOfSumOfSquaredErrors as g,generateCombinationsPanoramic as p,calculateLocationAccuracyFromDeviations as v,calculateReferenceImagePointPanoramic as f,calculateAnglePano as y,calculateTempImagePoint as _,calculateAngle as P,computeTriangulatedAreaMeasurement as A,computeTriangulatedDistanceMeasurement as b}from"../imageMeasurementUtils.js";class z{constructor(e){this._viewModel=e}async computeHeight(e,t,a=!0){const{currentBestFeature:r,activeViewer:i,layer:m,footprintExtent:w}=this._viewModel,d=i?.imageSize,h=r?.attributes,M=m?.orientationAccuracy;if(!h||!d||!e||e.length<2||!M)return;const g="panoramic"===t?await this._viewModel.getMeasurementPropertiesPanoramic():n(h,d[0],d[1]),p=e.at(0),v=e.at(-1);if(!(g&&p&&v&&M&&w))return;const f=[v,p],y=s(f,!1),_="panoramic"===t?await l(f,g,M,r,!0,!1):await c(f,g,M,!0,a);if(!_)return;const P="panoramic"===t?await u(M,y,g,_,r,!0):await o(M,y,g,_,!0);return P?{value:_,accuracy:P}:{value:_}}async calculateAreaMeasurement(t,a,r){if(t.length<3||!this._viewModel.currentBestFeature||!this._viewModel.activeViewer?.imageSize||"none"===this._viewModel.mode)return null;const i="default"===a?await this._viewModel.getMeasurementProperties():await this._viewModel.getMeasurementPropertiesPanoramic();return e(r),i?"default"===a?await m(t,i,!0):await w(t,i,!0,r):null}async calculateDistanceMeasurement(t,a,r){const{currentBestFeature:i,activeViewer:n}=this._viewModel;if(t.length<2||!i||!n?.imageSize||"none"===a)return null;const s="default"===a?await this._viewModel.getMeasurementProperties():await this._viewModel.getMeasurementPropertiesPanoramic();return e(r),s?"default"===a?await d([t.at(0),t.at(-1)],s,!0):await h([t.at(0),t.at(-1)],s,!0):null}async calculateAccuracy(t,a,r){const{layer:i,currentBestFeature:n,activeViewer:s,currentBestFeatureMeasurementImage:l,triangularMeasurementActive:c,imageMeasurementViewer:u}=this._viewModel,o=i?.orientationAccuracy,w=o?.every(e=>0===e)||!o?.length;if("area"===a&&t.length<3||"distance"===a&&t.length<2||!n||!s?.imageSize||w)return null;let h=null;if(c&&l&&u?h=await this._viewModel.getMeasurementProperties(l,u):(h=await this._viewModel.getMeasurementProperties(),e(r)),!h)return null;const p="area"===a?await m(t,h,!0):await d([t.at(0),t.at(-1)],h,!0);e(r);const{updateElevationProps:v,...f}=h,y=M(f,o);if(!y?.length)return null;const _=y.map(e=>({...e,updateElevationProps:v})).map(async i=>{const n="area"===a?await m(t,i,!0):await d([t.at(0),t.at(-1)],i,!0);if(e(r),n&&p){if("area"===a){const e="number"!=typeof n?n.area:null;return e?Math.abs(e-p.area):null}return Math.abs(n-p)}return null}),P=await Promise.all(_);e(r);const A=P.filter(e=>null!==e);return 0===A.length?null:g(A)}async calculateLocationAccuracy(t,n,s="default",l){const{layer:c,currentBestFeature:u}=this._viewModel,o=c?.orientationAccuracy,m=this._viewModel.view?.spatialReference,w=o?.every(e=>0===e)||!o?.length;if(!u||w)return null;const d="default"===s?await this._viewModel.getMeasurementProperties():await this._viewModel.getMeasurementPropertiesPanoramic();if(e(l),!d)return null;const{updateElevationProps:h,...g}=d,f="default"===s?M(g,o):p(g,o);if(!f?.length)return null;const y=f.map(e=>({...e,updateElevationProps:h})).map(async c=>{const{updateElevationProps:u,...o}=c;let w="default"===s?await r(t,o,u):await i(t,o,u);return e(l),m&&!w.spatialReference.equals(m)&&(w=await a(w,m),e(l)),w&&n?[Math.abs(w.x-n.x),Math.abs(w.y-n.y),w.z&&n.z?Math.abs(w.z-n.z):0]:null}),_=await Promise.all(y);if(e(l),!_?.length)return null;const P=_.map(e=>[e?.[0]??0,e?.[1]??0,e?.[2]??0]),[A,b,z]=v(P);return{x:A,y:b,z}}async calculateAccuracyPanoramic(t,a,r){const{layer:i,currentBestFeature:n,activeViewer:s,mode:l}=this._viewModel,c=i?.orientationAccuracy,u=c?.every(e=>0===e)||!c?.length;if("area"===a&&t.length<3||"distance"===a&&t.length<2||!n||!s?.imageSize||u||"panoramic"!==l)return null;const o=await this._viewModel.getMeasurementPropertiesPanoramic();if(e(r),!o)return null;const m="area"===a?await w(t,o,!0):await h([t.at(0),t.at(-1)],o,!0);e(r);const{updateElevationProps:d,...M}=o,v=p(M,c);if(!v?.length)return null;const f=v.map(e=>({...e,updateElevationProps:d})).map(async i=>{const n="area"===a?await w(t,i,!0):await h([t.at(0),t.at(-1)],i,!0);if(e(r),n&&m){if("area"===a){const e="number"!=typeof n?n.area:null;return e?Math.abs(e-m.area):null}return Math.abs(n-m)}return null}),y=await Promise.all(f);e(r);const _=y.filter(e=>null!==e);return 0===_.length?null:g(_)}async calculateHeightMeasurementInfo(e,a,r){const{currentBestFeature:i,activeViewer:l}=this._viewModel,c=l?.imageSize;if(!i||!l||!c?.length||"none"===a)return;const{attributes:u}=i,[o]=s([e],"panoramic"!==a),m="panoramic"===a?await this._viewModel.getMeasurementPropertiesPanoramic():n(u,c[0],c[1]);if("panoramic"===a){if(!m)return;const e=await f(o,m,i,r);if(!e)return;e?.heading>180&&(e.heading-=360);const a=y(o,e),n=t([o.x,o.y],[e.x,e.y]);if(!a||!n)return;return{measurementAngle:a,tempDistance:n}}const w=await _(o,m,r);if(!w)return;const d=P(o,w),h=t([o.x,o.y],[w.x,w.y]);return d&&h?{measurementAngle:d,tempDistance:h}:void 0}async calculateTriangulatedMeasurements(e){switch(this._viewModel.measureType){case"distance":{this._viewModel.triangulatedDistanceMeasurement=await b(this._viewModel.measurementVectors);const t=await this.calculateAccuracy(e,"distance");if(t&&this._viewModel.triangulatedDistanceMeasurement?.distance){const e=Math.atan(t/this._viewModel.triangulatedDistanceMeasurement.distance);this._viewModel.triangulatedDistanceAccuracy={distanceAccuracy:t,angleAccuracy:e}}break}case"area":if(this._viewModel.currentBestFeatureMeasurementImage?.geometry.spatialReference){const t=await A(this._viewModel.measurementVectors,this._viewModel.currentBestFeatureMeasurementImage.geometry.spatialReference);this._viewModel.triangulatedAreaMeasurement=t,this._viewModel.triangulatedAreaAccuracy=await this.calculateAccuracy(e,"area")??this._viewModel.triangulatedAreaAccuracy}}}}export{z as ImageMeasurementService};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- const o="esri-search",e={base:o,autocomplete:`${o}__autocomplete`,dropdown:`${o}__dropdown`,container:`${o}__container`,form:`${o}__form`};export{e as css};
5
+ const o="esri-search",t={base:o,autocomplete:`${o}__autocomplete`,dropdown:`${o}__dropdown`,container:`${o}__container`,form:`${o}__form`,submitButton:`${o}__submit-button`};export{t as css};
package/widgets/Search.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import"../intl.js";import{deprecateWidget as t,deprecatedPropertyValue as o}from"../core/deprecate.js";import s from"../core/Logger.js";import{destroyMaybe as r,abortMaybe as i}from"../core/maybe.js";import{ignoreAbortErrors as l,isAbortError as n}from"../core/promiseUtils.js";import{watch as a,initial as c}from"../core/reactiveUtils.js";import{waitAnimationFrame as u}from"../core/scheduling.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import p from"./Widget.js";import{css as g}from"./Search/css.js";import m from"./Search/SearchResultRenderer.js";import v from"./Search/SearchViewModel.js";import{loadCalciteComponents as _}from"./support/componentsUtils.js";import{globalCss as w}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as S}from"./support/decorators/messageBundle.js";import{vmEvent as M}from"./support/decorators/vmEvent.js";import{tsx as b}from"./support/jsxFactory.js";import{substitute as y}from"../intl/substitute.js";let C=class extends p{constructor(e,o){super(e,o),this._currentLocationValue=`${this.id}-search-use-current-location`,this._autocompleteNode=null,this._focusAbortController=null,this._searchResultRenderer=new m,this._suggestController=null,this._searchController=null,this._lastSearchTerm="",this._locateFailed=!1,this._showNoResults=!1,this.disabled=!1,this.messages=null,this.messagesCommon=null,this.viewModel=new v,this._renderSearchResultsContent=()=>this._searchResultRenderer,t(s.getLogger(this),"Search","arcgis-search",{version:"4.33"}),this.addHandles([a(()=>this.viewModel,e=>this._searchResultRenderer.viewModel=e,c),a(()=>this.viewModel.results,()=>this._searchResultRenderer.showMoreResultsOpen=!1),a(()=>this.viewModel?.defaultPopupTemplate,e=>{e&&(e.content=this._renderSearchResultsContent)},c)])}loadDependencies(){return _({autocomplete:()=>import("@esri/calcite-components/dist/components/calcite-autocomplete"),"autocomplete-item-group":()=>import("@esri/calcite-components/dist/components/calcite-autocomplete-item-group"),"autocomplete-item":()=>import("@esri/calcite-components/dist/components/calcite-autocomplete-item"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice")})}destroy(){this._cancelQueries(),this._searchResultRenderer=r(this._searchResultRenderer),this._focusAbortController?.abort()}get _isDisabled(){const{state:e}=this.viewModel;return"disabled"===e||"loading"===e||this.disabled}get _showCurrentLocation(){return this.locationEnabled&&!this.searchTerm?.trim()}get _effectiveActiveMenu(){const{activeMenu:e}=this;return this._isDisabled?"none":"warning"===e?"suggestion":e}get activeMenu(){return"none"}set activeMenu(e){"warning"===e&&o(s.getLogger(this),"activeMenu","warning",{replacement:"Use the value 'suggestion' instead",version:"4.32",warnOnce:!0}),this._overrideIfSome("activeMenu",e)}get activeSource(){return this.viewModel?.activeSource}get activeSourceIndex(){return this.viewModel.activeSourceIndex}set activeSourceIndex(e){this.viewModel.activeSourceIndex=e}get allPlaceholder(){return this.viewModel.allPlaceholder}set allPlaceholder(e){this.viewModel.allPlaceholder=e}get allSources(){return this.viewModel.allSources}get autoNavigate(){return this.viewModel.autoNavigate}set autoNavigate(e){this.viewModel.autoNavigate=e}get autoSelect(){return this.viewModel.autoSelect}set autoSelect(e){this.viewModel.autoSelect=e}get defaultSources(){return this.viewModel.defaultSources}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get icon(){return"search"}set icon(e){this._overrideIfSome("icon",e)}get includeDefaultSources(){return this.viewModel.includeDefaultSources}set includeDefaultSources(e){this.viewModel.includeDefaultSources=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get locationEnabled(){return this.viewModel.locationEnabled}set locationEnabled(e){this.viewModel.locationEnabled=e}get maxResults(){return this.viewModel.maxResults}set maxResults(e){this.viewModel.maxResults=e}get maxSuggestions(){return this.viewModel.maxSuggestions}set maxSuggestions(e){this.viewModel.maxSuggestions=e}get minSuggestCharacters(){return this.viewModel.minSuggestCharacters}set minSuggestCharacters(e){this.viewModel.minSuggestCharacters=e}get popupEnabled(){return this.viewModel.popupEnabled}set popupEnabled(e){this.viewModel.popupEnabled=e}get popupTemplate(){return this.viewModel.popupTemplate}set popupTemplate(e){this.viewModel.popupTemplate=e}get portal(){return this.viewModel?.portal}set portal(e){this.viewModel&&(this.viewModel.portal=e)}get resultGraphic(){return this.viewModel.resultGraphic}set resultGraphic(e){this.viewModel.resultGraphic=e}get resultGraphicEnabled(){return this.viewModel.resultGraphicEnabled}set resultGraphicEnabled(e){this.viewModel.resultGraphicEnabled=e}get results(){return this.viewModel.results}get searchAllEnabled(){return this.viewModel.searchAllEnabled}set searchAllEnabled(e){this.viewModel.searchAllEnabled=e}get searchTerm(){return this.viewModel.searchTerm}set searchTerm(e){this.viewModel.searchTerm=e}get selectedResult(){return this.viewModel.selectedResult}get sources(){return this.viewModel.sources}set sources(e){this.viewModel.sources=e}get suggestions(){return this.viewModel.suggestions}get suggestionsEnabled(){return this.viewModel.suggestionsEnabled}set suggestionsEnabled(e){this.viewModel.suggestionsEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}clear(){this._locateFailed=!1,this.viewModel.clear()}focus(){this._handleFocus(),this._emitFocus()}blur(){this._autocompleteNode?.blur(),this._emitBlur()}async search(e){this._cancelQueries();const t=new AbortController,{signal:o}=t;this._searchController=t;try{const s=await this.viewModel.search(e,{signal:o});if(this._searchController!==t)return;return s?.numResults||(this._showNoResults=!0,this.activeMenu="suggestion"),this._searchController=null,s}catch(s){if(this._searchController!==t)return;return void(this._searchController=null)}}async suggest(e){this._cancelSuggest();const t=new AbortController,{signal:o}=t;this._suggestController=t;try{const s=await this.viewModel.suggest(e,null,{signal:o});if(this._suggestController!==t)return;return this._suggestController=null,s?.numResults&&(this.activeMenu="suggestion",this._scrollToTopSuggestion()),s}catch(s){return this._suggestController!==t||(this._suggestController=null),null}}render(){return b("div",{class:this.classes(g.base,w.widget)},b("div",{class:g.container},this._renderSourcesMenu(),this._renderForm()))}_handleInputKeydown(e){"Tab"===e.key&&this._cancelSuggest()}_emitFocus(){this.emit("search-focus")}_emitBlur(){this.emit("search-blur")}async _handleFocus(){this._focusAbortController?.abort(),this._focusAbortController=new AbortController;const e=this._focusAbortController.signal;await l(u(e)),this._autocompleteNode?.setFocus()}_renderSourcesMenu(){const{messages:e,_isDisabled:t,_effectiveActiveMenu:o}=this,{allSources:s,searchAllEnabled:r}=this.viewModel;return s.length>1?b("calcite-dropdown",{bind:this,class:g.dropdown,disabled:t,open:"source"===o,overlayPositioning:"fixed",onCalciteDropdownClose:this._handleSourceClose,onCalciteDropdownOpen:this._handleSourceOpen,onCalciteDropdownSelect:this._handleSourceSelect},b("calcite-button",{appearance:"outline-fill",iconStart:"caret-down",kind:"neutral",label:e.searchIn,slot:"trigger"}),b("calcite-dropdown-group",{groupTitle:e.searchIn},r?this._renderSource(v.ALL_INDEX):null,s.map((e,t)=>this._renderSource(t)).toArray())):null}_renderUseCurrentLocation(){const{_currentLocationValue:e}=this;return b("calcite-autocomplete-item",{heading:this.messages.useCurrentLocation,iconStart:"gps-on",key:e,value:e})}_handleAutocompleteCreate(e){this._autocompleteNode=e}_handleCalciteAutocompleteTextInput(e){const t=e.target.inputValue;t!==this.viewModel.searchTerm&&(this.viewModel.searchTerm=t,t||this.clear(),this.suggest())}_handleAutocompleteOpen(){this.activeMenu="suggestion"}_handleAutocompleteClose(){"suggestion"===this.activeMenu&&(this.activeMenu="none")}_handleCalciteAutocompleteChange(e){const t=e.target.value;if(t===this._currentLocationValue)return void this._useCurrentLocation();const o=JSON.parse(t),s=this.viewModel.suggestions?.find(({sourceIndex:e})=>e===o.sourceIndex)?.results?.find(({key:e})=>`${e}`==`${o.key}`);s&&this.search(s)}_renderAutocomplete(){const{_effectiveActiveMenu:e,messages:t,_isDisabled:o}=this,{maxInputLength:s,placeholder:r,searchTerm:i,state:l}=this.viewModel,n=this.label??t.searchButtonTitle??"";return b("calcite-autocomplete",{afterCreate:this._handleAutocompleteCreate,autocomplete:"off",bind:this,class:g.autocomplete,disabled:o,icon:this.icon||!1,inputValue:i,label:n,loading:"searching"===l,maxLength:s,name:this.id,onblur:this._emitBlur,onfocus:this._emitFocus,onkeydown:this._handleInputKeydown,open:"suggestion"===e,overlayPositioning:"fixed",placeholder:r,title:i?"":r,onCalciteAutocompleteChange:this._handleCalciteAutocompleteChange,onCalciteAutocompleteClose:this._handleAutocompleteClose,onCalciteAutocompleteOpen:this._handleAutocompleteOpen,onCalciteAutocompleteTextChange:this._handleCalciteAutocompleteTextInput,onCalciteAutocompleteTextInput:this._handleCalciteAutocompleteTextInput},this._renderSuggestions(),this._renderNotices())}_renderForm(){return b("form",{bind:this,class:g.form,disabled:this._isDisabled,key:g.form,onsubmit:this._formSubmit,role:"search"},this._renderAutocomplete())}_renderSuggestGroup(e){return e.results?.map(e=>this._renderSuggestion(e))}_renderSuggestions(){const{suggestions:e}=this.viewModel;return this._showNoResults?null:this._showCurrentLocation?this._renderUseCurrentLocation():e?.map(e=>this._renderSuggestResults(e))}_renderSuggestResults(e){const{allSources:t,activeSourceIndex:o}=this.viewModel,{sourceIndex:s}=e,r=e.results?.length,i=t.length>1&&o===v.ALL_INDEX,l=this._getSourceName(s);return r&&i?b("calcite-autocomplete-item-group",{heading:l,key:`suggestion-group-${l}-${s}`},this._renderSuggestGroup(e)):this._renderSuggestGroup(e)}_renderSuggestion({key:e,sourceIndex:t,text:o}){const s={key:e,sourceIndex:t};return b("calcite-autocomplete-item",{heading:o??this.messages.untitledResult,key:`suggestion_${e}`,value:JSON.stringify(s)})}_renderSource(e){const t=this._getSourceName(e);return b("calcite-dropdown-item",{"data-source-index":`${e}`,key:`source-${t}-${e}`,selected:e===this.viewModel.activeSourceIndex},t)}_renderNoResultsWarning(e){const{messages:t}=this,o=e?y(t.noResultsFoundForValue,{value:`"${e}"`}):t.noResultsFound;return b("calcite-notice",{icon:"exclamation-mark-triangle",key:"no-results-warning",kind:"warning",open:!0,slot:"content-bottom"},b("div",{slot:"title"},t.noResults),b("div",{slot:"message"},o))}_renderLocateError(){return b("calcite-notice",{icon:"exclamation-mark-circle",key:"locate-warning",kind:"danger",open:!0,slot:"content-bottom"},b("div",{slot:"message"},this.messages.locateError))}_renderNotices(){return this._locateFailed?this._renderLocateError():this._showNoResults?this._renderNoResultsWarning(this._lastSearchTerm??this.viewModel.searchTerm):null}async _useCurrentLocation(){this._cancelQueries();const e=new AbortController,{signal:t}=e;this._searchController=e;try{await this.viewModel.searchNearby({signal:t})}catch(o){n(o)||(this._locateFailed=!0,this.activeMenu="suggestion")}finally{this._searchController=null}}_handleSourceOpen(){this.activeMenu="source"}_handleSourceClose(){"source"===this.activeMenu&&(this.activeMenu="none")}_handleSourceSelect(e){const t=e.target.selectedItems[0].getAttribute("data-source-index");t&&(this.viewModel.activeSourceIndex=parseInt(t,10))}_cancelSuggest(){this.activeMenu="none",this._locateFailed=!1,this._showNoResults=!1,this._suggestController=i(this._suggestController)}_cancelQueries(){this._cancelSuggest(),this._searchController=i(this._searchController)}_scrollToTopSuggestion(){this._autocompleteNode?.scrollContentTo({top:0})}_formSubmit(e){e.preventDefault(),this.activeMenu="none",this._lastSearchTerm=this.searchTerm,this.searchTerm&&this.search()}_getSourceName(e){const{messages:t}=this,{allSources:o}=this.viewModel,s=o.at(e);return e===v.ALL_INDEX?t.all:s?.name||t.untitledSource}};e([h()],C.prototype,"_locateFailed",void 0),e([h()],C.prototype,"_showNoResults",void 0),e([h()],C.prototype,"_isDisabled",null),e([h()],C.prototype,"_showCurrentLocation",null),e([h()],C.prototype,"_effectiveActiveMenu",null),e([h()],C.prototype,"activeMenu",null),e([h({readOnly:!0})],C.prototype,"activeSource",null),e([h()],C.prototype,"activeSourceIndex",null),e([h()],C.prototype,"allPlaceholder",null),e([h({readOnly:!0})],C.prototype,"allSources",null),e([h()],C.prototype,"autoNavigate",null),e([h()],C.prototype,"autoSelect",null),e([h({readOnly:!0})],C.prototype,"defaultSources",null),e([h()],C.prototype,"disabled",void 0),e([h()],C.prototype,"goToOverride",null),e([h()],C.prototype,"icon",null),e([h()],C.prototype,"includeDefaultSources",null),e([h()],C.prototype,"label",null),e([h()],C.prototype,"locationEnabled",null),e([h()],C.prototype,"maxResults",null),e([h()],C.prototype,"maxSuggestions",null),e([h(),S("esri/widgets/Search/t9n/Search")],C.prototype,"messages",void 0),e([h(),S("esri/t9n/common")],C.prototype,"messagesCommon",void 0),e([h()],C.prototype,"minSuggestCharacters",null),e([h()],C.prototype,"popupEnabled",null),e([h()],C.prototype,"popupTemplate",null),e([h()],C.prototype,"portal",null),e([h()],C.prototype,"resultGraphic",null),e([h()],C.prototype,"resultGraphicEnabled",null),e([h({readOnly:!0})],C.prototype,"results",null),e([h()],C.prototype,"searchAllEnabled",null),e([h()],C.prototype,"searchTerm",null),e([h({readOnly:!0})],C.prototype,"selectedResult",null),e([h()],C.prototype,"sources",null),e([h({readOnly:!0})],C.prototype,"suggestions",null),e([h()],C.prototype,"suggestionsEnabled",null),e([h()],C.prototype,"view",null),e([M(["search-complete","search-clear","search-start","select-result","suggest-start","suggest-complete"]),h({type:v})],C.prototype,"viewModel",void 0),C=e([d("esri.widgets.Search")],C);const f=C;export{f as default};
5
+ import{__decorate as e}from"tslib";import"../intl.js";import{deprecateWidget as t,deprecatedPropertyValue as o}from"../core/deprecate.js";import s from"../core/Logger.js";import{destroyMaybe as r,abortMaybe as i}from"../core/maybe.js";import{ignoreAbortErrors as l,isAbortError as n}from"../core/promiseUtils.js";import{watch as a,initial as c}from"../core/reactiveUtils.js";import{waitAnimationFrame as u}from"../core/scheduling.js";import{property as h}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import p from"./Widget.js";import{css as g}from"./Search/css.js";import m from"./Search/SearchResultRenderer.js";import v from"./Search/SearchViewModel.js";import{loadCalciteComponents as _}from"./support/componentsUtils.js";import{globalCss as w}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as S}from"./support/decorators/messageBundle.js";import{vmEvent as M}from"./support/decorators/vmEvent.js";import{tsx as b}from"./support/jsxFactory.js";import{substitute as y}from"../intl/substitute.js";let C=class extends p{constructor(e,o){super(e,o),this._currentLocationValue=`${this.id}-search-use-current-location`,this._autocompleteNode=null,this._focusAbortController=null,this._searchResultRenderer=new m,this._suggestController=null,this._searchController=null,this._lastSearchTerm="",this._locateFailed=!1,this._showNoResults=!1,this.disabled=!1,this.messages=null,this.messagesCommon=null,this.viewModel=new v,this._renderSearchResultsContent=()=>this._searchResultRenderer,t(s.getLogger(this),"Search","arcgis-search",{version:"4.33"}),this.addHandles([a(()=>this.viewModel,e=>this._searchResultRenderer.viewModel=e,c),a(()=>this.viewModel.results,()=>this._searchResultRenderer.showMoreResultsOpen=!1),a(()=>this.viewModel?.defaultPopupTemplate,e=>{e&&(e.content=this._renderSearchResultsContent)},c)])}loadDependencies(){return _({autocomplete:()=>import("@esri/calcite-components/dist/components/calcite-autocomplete"),"autocomplete-item-group":()=>import("@esri/calcite-components/dist/components/calcite-autocomplete-item-group"),"autocomplete-item":()=>import("@esri/calcite-components/dist/components/calcite-autocomplete-item"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice")})}destroy(){this._cancelQueries(),this._searchResultRenderer=r(this._searchResultRenderer),this._focusAbortController?.abort()}get _isDisabled(){const{state:e}=this.viewModel;return"disabled"===e||"loading"===e||this.disabled}get _showCurrentLocation(){return this.locationEnabled&&!this.searchTerm?.trim()}get _effectiveActiveMenu(){const{activeMenu:e}=this;return this._isDisabled?"none":"warning"===e?"suggestion":e}get activeMenu(){return"none"}set activeMenu(e){"warning"===e&&o(s.getLogger(this),"activeMenu","warning",{replacement:"Use the value 'suggestion' instead",version:"4.32",warnOnce:!0}),this._overrideIfSome("activeMenu",e)}get activeSource(){return this.viewModel?.activeSource}get activeSourceIndex(){return this.viewModel.activeSourceIndex}set activeSourceIndex(e){this.viewModel.activeSourceIndex=e}get allPlaceholder(){return this.viewModel.allPlaceholder}set allPlaceholder(e){this.viewModel.allPlaceholder=e}get allSources(){return this.viewModel.allSources}get autoNavigate(){return this.viewModel.autoNavigate}set autoNavigate(e){this.viewModel.autoNavigate=e}get autoSelect(){return this.viewModel.autoSelect}set autoSelect(e){this.viewModel.autoSelect=e}get defaultSources(){return this.viewModel.defaultSources}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get icon(){return"search"}set icon(e){this._overrideIfSome("icon",e)}get includeDefaultSources(){return this.viewModel.includeDefaultSources}set includeDefaultSources(e){this.viewModel.includeDefaultSources=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get locationEnabled(){return this.viewModel.locationEnabled}set locationEnabled(e){this.viewModel.locationEnabled=e}get maxResults(){return this.viewModel.maxResults}set maxResults(e){this.viewModel.maxResults=e}get maxSuggestions(){return this.viewModel.maxSuggestions}set maxSuggestions(e){this.viewModel.maxSuggestions=e}get minSuggestCharacters(){return this.viewModel.minSuggestCharacters}set minSuggestCharacters(e){this.viewModel.minSuggestCharacters=e}get popupEnabled(){return this.viewModel.popupEnabled}set popupEnabled(e){this.viewModel.popupEnabled=e}get popupTemplate(){return this.viewModel.popupTemplate}set popupTemplate(e){this.viewModel.popupTemplate=e}get portal(){return this.viewModel?.portal}set portal(e){this.viewModel&&(this.viewModel.portal=e)}get resultGraphic(){return this.viewModel.resultGraphic}set resultGraphic(e){this.viewModel.resultGraphic=e}get resultGraphicEnabled(){return this.viewModel.resultGraphicEnabled}set resultGraphicEnabled(e){this.viewModel.resultGraphicEnabled=e}get results(){return this.viewModel.results}get searchAllEnabled(){return this.viewModel.searchAllEnabled}set searchAllEnabled(e){this.viewModel.searchAllEnabled=e}get searchTerm(){return this.viewModel.searchTerm}set searchTerm(e){this.viewModel.searchTerm=e}get selectedResult(){return this.viewModel.selectedResult}get sources(){return this.viewModel.sources}set sources(e){this.viewModel.sources=e}get suggestions(){return this.viewModel.suggestions}get suggestionsEnabled(){return this.viewModel.suggestionsEnabled}set suggestionsEnabled(e){this.viewModel.suggestionsEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}clear(){this._locateFailed=!1,this.viewModel.clear()}focus(){this._handleFocus(),this._emitFocus()}blur(){this._autocompleteNode?.blur(),this._emitBlur()}async search(e){this._cancelQueries();const t=new AbortController,{signal:o}=t;this._searchController=t;try{const s=await this.viewModel.search(e,{signal:o});if(this._searchController!==t)return;return s?.numResults||(this._showNoResults=!0,this.activeMenu="suggestion"),this._searchController=null,s}catch(s){if(this._searchController!==t)return;return void(this._searchController=null)}}async suggest(e){this._cancelSuggest();const t=new AbortController,{signal:o}=t;this._suggestController=t;try{const s=await this.viewModel.suggest(e,null,{signal:o});if(this._suggestController!==t)return;return this._suggestController=null,s?.numResults&&(this.activeMenu="suggestion",this._scrollToTopSuggestion()),s}catch(s){return this._suggestController!==t||(this._suggestController=null),null}}render(){return b("div",{class:this.classes(g.base,w.widget)},b("div",{class:g.container},this._renderSourcesMenu(),this._renderForm()))}_handleInputKeydown(e){"Tab"===e.key&&this._cancelSuggest()}_emitFocus(){this.emit("search-focus")}_emitBlur(){this.emit("search-blur")}async _handleFocus(){this._focusAbortController?.abort(),this._focusAbortController=new AbortController;const e=this._focusAbortController.signal;await l(u(e)),this._autocompleteNode?.setFocus()}_renderSourcesMenu(){const{messages:e,_isDisabled:t,_effectiveActiveMenu:o}=this,{allSources:s,searchAllEnabled:r}=this.viewModel;return s.length>1?b("calcite-dropdown",{bind:this,class:g.dropdown,disabled:t,open:"source"===o,overlayPositioning:"fixed",onCalciteDropdownClose:this._handleSourceClose,onCalciteDropdownOpen:this._handleSourceOpen,onCalciteDropdownSelect:this._handleSourceSelect},b("calcite-button",{appearance:"outline-fill",iconStart:"caret-down",kind:"neutral",label:e.searchIn,slot:"trigger"}),b("calcite-dropdown-group",{groupTitle:e.searchIn},r?this._renderSource(v.ALL_INDEX):null,s.map((e,t)=>this._renderSource(t)).toArray())):null}_renderUseCurrentLocation(){const{_currentLocationValue:e}=this;return b("calcite-autocomplete-item",{heading:this.messages.useCurrentLocation,iconStart:"gps-on",key:e,value:e})}_handleAutocompleteCreate(e){this._autocompleteNode=e}_handleCalciteAutocompleteTextInput(e){const t=e.target.inputValue;t!==this.viewModel.searchTerm&&(this.viewModel.searchTerm=t,t||this.clear(),this.suggest())}_handleAutocompleteOpen(){this.activeMenu="suggestion"}_handleAutocompleteClose(){"suggestion"===this.activeMenu&&(this.activeMenu="none")}_handleCalciteAutocompleteChange(e){const t=e.target.value;if(t===this._currentLocationValue)return void this._useCurrentLocation();const o=JSON.parse(t),s=this.viewModel.suggestions?.find(({sourceIndex:e})=>e===o.sourceIndex)?.results?.find(({key:e})=>`${e}`==`${o.key}`);s&&this.search(s)}_renderAutocomplete(){const{_effectiveActiveMenu:e,messages:t,_isDisabled:o}=this,{maxInputLength:s,placeholder:r,searchTerm:i,state:l}=this.viewModel,n=this.label??t.searchButtonTitle??"";return b("calcite-autocomplete",{afterCreate:this._handleAutocompleteCreate,autocomplete:"off",bind:this,class:g.autocomplete,disabled:o,icon:this.icon||!1,inputValue:i,label:n,loading:"searching"===l,maxLength:s,name:this.id,onblur:this._emitBlur,onfocus:this._emitFocus,onkeydown:this._handleInputKeydown,open:"suggestion"===e,overlayPositioning:"fixed",placeholder:r,title:i?"":r,onCalciteAutocompleteChange:this._handleCalciteAutocompleteChange,onCalciteAutocompleteClose:this._handleAutocompleteClose,onCalciteAutocompleteOpen:this._handleAutocompleteOpen,onCalciteAutocompleteTextChange:this._handleCalciteAutocompleteTextInput,onCalciteAutocompleteTextInput:this._handleCalciteAutocompleteTextInput},this._renderSuggestions(),this._renderNotices())}_renderForm(){return b("form",{bind:this,class:g.form,disabled:this._isDisabled,key:g.form,onsubmit:this._formSubmit,role:"search"},this._renderAutocomplete(),b("button",{class:g.submitButton,type:"submit"},this.label??this.messages.searchButtonTitle??""))}_renderSuggestGroup(e){return e.results?.map(e=>this._renderSuggestion(e))}_renderSuggestions(){const{suggestions:e}=this.viewModel;return this._showNoResults?null:this._showCurrentLocation?this._renderUseCurrentLocation():e?.map(e=>this._renderSuggestResults(e))}_renderSuggestResults(e){const{allSources:t,activeSourceIndex:o}=this.viewModel,{sourceIndex:s}=e,r=e.results?.length,i=t.length>1&&o===v.ALL_INDEX,l=this._getSourceName(s);return r&&i?b("calcite-autocomplete-item-group",{heading:l,key:`suggestion-group-${l}-${s}`},this._renderSuggestGroup(e)):this._renderSuggestGroup(e)}_renderSuggestion({key:e,sourceIndex:t,text:o}){const s={key:e,sourceIndex:t};return b("calcite-autocomplete-item",{heading:o??this.messages.untitledResult,key:`suggestion_${e}`,value:JSON.stringify(s)})}_renderSource(e){const t=this._getSourceName(e);return b("calcite-dropdown-item",{"data-source-index":`${e}`,key:`source-${t}-${e}`,selected:e===this.viewModel.activeSourceIndex},t)}_renderNoResultsWarning(e){const{messages:t}=this,o=e?y(t.noResultsFoundForValue,{value:`"${e}"`}):t.noResultsFound;return b("calcite-notice",{icon:"exclamation-mark-triangle",key:"no-results-warning",kind:"warning",open:!0,slot:"content-bottom"},b("div",{slot:"title"},t.noResults),b("div",{slot:"message"},o))}_renderLocateError(){return b("calcite-notice",{icon:"exclamation-mark-circle",key:"locate-warning",kind:"danger",open:!0,slot:"content-bottom"},b("div",{slot:"message"},this.messages.locateError))}_renderNotices(){return this._locateFailed?this._renderLocateError():this._showNoResults?this._renderNoResultsWarning(this._lastSearchTerm??this.viewModel.searchTerm):null}async _useCurrentLocation(){this._cancelQueries();const e=new AbortController,{signal:t}=e;this._searchController=e;try{await this.viewModel.searchNearby({signal:t})}catch(o){n(o)||(this._locateFailed=!0,this.activeMenu="suggestion")}finally{this._searchController=null}}_handleSourceOpen(){this.activeMenu="source"}_handleSourceClose(){"source"===this.activeMenu&&(this.activeMenu="none")}_handleSourceSelect(e){const t=e.target.selectedItems[0].getAttribute("data-source-index");t&&(this.viewModel.activeSourceIndex=parseInt(t,10))}_cancelSuggest(){this.activeMenu="none",this._locateFailed=!1,this._showNoResults=!1,this._suggestController=i(this._suggestController)}_cancelQueries(){this._cancelSuggest(),this._searchController=i(this._searchController)}_scrollToTopSuggestion(){this._autocompleteNode?.scrollContentTo({top:0})}_formSubmit(e){e.preventDefault(),this.activeMenu="none",this._lastSearchTerm=this.searchTerm,this.searchTerm&&this.search()}_getSourceName(e){const{messages:t}=this,{allSources:o}=this.viewModel,s=o.at(e);return e===v.ALL_INDEX?t.all:s?.name||t.untitledSource}};e([h()],C.prototype,"_locateFailed",void 0),e([h()],C.prototype,"_showNoResults",void 0),e([h()],C.prototype,"_isDisabled",null),e([h()],C.prototype,"_showCurrentLocation",null),e([h()],C.prototype,"_effectiveActiveMenu",null),e([h()],C.prototype,"activeMenu",null),e([h({readOnly:!0})],C.prototype,"activeSource",null),e([h()],C.prototype,"activeSourceIndex",null),e([h()],C.prototype,"allPlaceholder",null),e([h({readOnly:!0})],C.prototype,"allSources",null),e([h()],C.prototype,"autoNavigate",null),e([h()],C.prototype,"autoSelect",null),e([h({readOnly:!0})],C.prototype,"defaultSources",null),e([h()],C.prototype,"disabled",void 0),e([h()],C.prototype,"goToOverride",null),e([h()],C.prototype,"icon",null),e([h()],C.prototype,"includeDefaultSources",null),e([h()],C.prototype,"label",null),e([h()],C.prototype,"locationEnabled",null),e([h()],C.prototype,"maxResults",null),e([h()],C.prototype,"maxSuggestions",null),e([h(),S("esri/widgets/Search/t9n/Search")],C.prototype,"messages",void 0),e([h(),S("esri/t9n/common")],C.prototype,"messagesCommon",void 0),e([h()],C.prototype,"minSuggestCharacters",null),e([h()],C.prototype,"popupEnabled",null),e([h()],C.prototype,"popupTemplate",null),e([h()],C.prototype,"portal",null),e([h()],C.prototype,"resultGraphic",null),e([h()],C.prototype,"resultGraphicEnabled",null),e([h({readOnly:!0})],C.prototype,"results",null),e([h()],C.prototype,"searchAllEnabled",null),e([h()],C.prototype,"searchTerm",null),e([h({readOnly:!0})],C.prototype,"selectedResult",null),e([h()],C.prototype,"sources",null),e([h({readOnly:!0})],C.prototype,"suggestions",null),e([h()],C.prototype,"suggestionsEnabled",null),e([h()],C.prototype,"view",null),e([M(["search-complete","search-clear","search-start","select-result","suggest-start","suggest-complete"]),h({type:v})],C.prototype,"viewModel",void 0),C=e([d("esri.widgets.Search")],C);const f=C;export{f as default};