@arcgis/core 5.0.0-next.7 → 5.0.0-next.9

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 (365) hide show
  1. package/applications/KnowledgeStudio/resourceSerializationUtils.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{8f56f298e7c1a283f407.js → 0030d68d9edf42b4af57.js} +1 -1
  4. package/assets/esri/core/workers/chunks/01d460398f3ba6767a37.js +1 -0
  5. package/assets/esri/core/workers/chunks/02e7359162cf974b41b6.js +1 -0
  6. package/assets/esri/core/workers/chunks/{17d5f8dba6ebb1184506.js → 042cd64e1f4eb326c30f.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{66db5f77e09d25e33951.js → 063905fbf9a0c6586949.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{9486032af3e934d85582.js → 0a5d74414dd02a2fb8e1.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{3815ffa13e7b439bca6e.js → 0d5212f59e9b62c16164.js} +1 -1
  10. package/assets/esri/core/workers/chunks/0f735b0dec173142f3b6.js +2 -0
  11. package/assets/esri/core/workers/chunks/{a8f998b8ec8c56150479.js.LICENSE.txt → 0f735b0dec173142f3b6.js.LICENSE.txt} +1 -1
  12. package/assets/esri/core/workers/chunks/{73487b9d85e726e9c012.js → 1257c37bf04d39c27b62.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{398f356b11fd33bd3831.js → 136a7d781dad05a7463b.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{1e4e7aedf4b779241a02.js → 15c7c10ff9ac63f0e792.js} +1 -1
  15. package/assets/esri/core/workers/chunks/17784cf16fa91504b9ea.js +1 -0
  16. package/assets/esri/core/workers/chunks/{a395373e3173e6458a56.js → 1ab37e13947d0e2e4181.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{f03635ddf56e2ef90e4c.js → 1d06fcae4c2f02fb1c95.js} +1 -1
  18. package/assets/esri/core/workers/chunks/1dfca37f95f2b968aa54.js +1 -0
  19. package/assets/esri/core/workers/chunks/{5bd36dbf46c25bd961c8.js → 21293b0c6405a10ec7b6.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{285762ff92d5388b6024.js → 2166238a7ad63a2d43c7.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{620a94b54be3ed78350d.js → 22ca80f491e070b2a5e7.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{88074189fa10c335370b.js → 24cd7b84cd0f3de4bff2.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{ccc0da0e01f023c8aa1f.js → 28d1f2cf6aae547615c3.js} +1 -1
  24. package/assets/esri/core/workers/chunks/292daac70bb828e4923f.js +1 -0
  25. package/assets/esri/core/workers/chunks/{7e43c105f1cfc44b7bd0.js → 2fa01bd3f3608616fd7f.js} +1 -1
  26. package/assets/esri/core/workers/chunks/30e220f4f843681a4cdd.js +1 -0
  27. package/assets/esri/core/workers/chunks/{5d3661d1fe46dd29aae9.js → 311b564e44ae637c960d.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{f4d0ae6be1b3984228d0.js → 31b6406960261da21dd4.js} +1 -1
  29. package/assets/esri/core/workers/chunks/31c7ce65e16f7858400f.js +1 -0
  30. package/assets/esri/core/workers/chunks/31dbe07047dc61303d7d.js +1 -0
  31. package/assets/esri/core/workers/chunks/{8a314b3790313e6dc5db.js → 333b62dad3811cff0f14.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{c8733cd621105afab2ac.js → 35c9b24e4430bd6c2b6b.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{e31192ae920e3e19b6aa.js → 37c1f155da14de91565a.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{c55c096669677321a227.js → 38cd3648932bf2534b0f.js} +1 -1
  35. package/assets/esri/core/workers/chunks/3a457e718a901a45902e.js.LICENSE.txt +1 -1
  36. package/assets/esri/core/workers/chunks/{f5e47eea8720ba84665b.js → 3c07aa2015ab1dff5f7b.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{e9311386f58f3cb95c22.js → 42a1e71d09e8583a7327.js} +1 -1
  38. package/assets/esri/core/workers/chunks/443dfe7029ec208f670c.js +1 -0
  39. package/assets/esri/core/workers/chunks/{b75930d60449eceb0f1c.js → 4baf6f6e7ddedb25f806.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{bb5484b5eeacc9ad2ceb.js → 4d0cbf9584446f411a37.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{17103e6542aae53c7301.js → 4e3e27673d0671fc2b58.js} +1 -1
  42. package/assets/esri/core/workers/chunks/4fb5f1c671892001a4fd.js +1 -0
  43. package/assets/esri/core/workers/chunks/{5fc7b61f467f1d60a284.js → 51ab2acac4ecc1ca9c34.js} +1 -1
  44. package/assets/esri/core/workers/chunks/{fc4417d1260b717a9385.js → 52282f767bd0e99ddca0.js} +1 -1
  45. package/assets/esri/core/workers/chunks/{dedc4583b5f32a278124.js → 5350d50b47b6a4e0e169.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{fc06014fb484fc8c697e.js → 53654edd766d9b4ef750.js} +1 -1
  47. package/assets/esri/core/workers/chunks/{90f8b4bda28af43ea019.js → 538f509d7fc8337d37ac.js} +1 -1
  48. package/assets/esri/core/workers/chunks/{ed8a85efbd90241512bb.js → 588533c3abe876f20f62.js} +1 -1
  49. package/assets/esri/core/workers/chunks/58e59ead33368ce38c8f.js +1 -0
  50. package/assets/esri/core/workers/chunks/5db37547963857295273.js +1 -0
  51. package/assets/esri/core/workers/chunks/{72846fb9c87c6642daf0.js → 5e2ce34def5e053913b2.js} +1 -1
  52. package/assets/esri/core/workers/chunks/{8c056eac35d05d9524b7.js → 5f29422a051311ef9b3c.js} +1 -1
  53. package/assets/esri/core/workers/chunks/{ac26e3e77df4302f47a2.js → 604777417722d4effe06.js} +1 -1
  54. package/assets/esri/core/workers/chunks/{ff35a077ac6776469805.js → 61d970ed75c2c358b1e9.js} +1 -1
  55. package/assets/esri/core/workers/chunks/{7a6a96edc892d7060b7d.js → 629127877042ad784ad2.js} +1 -1
  56. package/assets/esri/core/workers/chunks/{90b2b43b8b54c9a1ec35.js → 664ae441617afe4b17ec.js} +1 -1
  57. package/assets/esri/core/workers/chunks/67f03d042455cd0f7009.js +1 -0
  58. package/assets/esri/core/workers/chunks/{4c5a7249a311070d8f43.js → 6af18d7a0d314d7c1756.js} +1 -1
  59. package/assets/esri/core/workers/chunks/{f35aaa04cca676c2d3f8.js → 6b59f94040c7d2f6728a.js} +1 -1
  60. package/assets/esri/core/workers/chunks/6d9f2b113d6bde936a04.js +1 -0
  61. package/assets/esri/core/workers/chunks/{5132ca68e8c7af111a47.js → 6e22b02a9715c10578d0.js} +1 -1
  62. package/assets/esri/core/workers/chunks/{f0e0a63962784acb4ba1.js → 6f0aec7428021e440ac9.js} +1 -1
  63. package/assets/esri/core/workers/chunks/{deb2854bb7d082a26f52.js → 7005d956c990a04ee8b2.js} +1 -1
  64. package/assets/esri/core/workers/chunks/{a3991ae8caa713d4ddcd.js → 731f7b552dde0fb325cd.js} +1 -1
  65. package/assets/esri/core/workers/chunks/7565b382f6b3d2cb46a3.js +2 -0
  66. package/assets/esri/core/workers/chunks/{b96eb0ea506379182d62.js.LICENSE.txt → 7565b382f6b3d2cb46a3.js.LICENSE.txt} +1 -1
  67. package/assets/esri/core/workers/chunks/{464d42bebb365287808d.js → 773f2c6c9d38db76dfed.js} +1 -1
  68. package/assets/esri/core/workers/chunks/{3f3d492f1093b7832aab.js → 7803495f8862d9025bcd.js} +1 -1
  69. package/assets/esri/core/workers/chunks/7d641f2f5edd95b9bc18.js +1 -0
  70. package/assets/esri/core/workers/chunks/7e4c14d4502e3f06d94b.js +1 -0
  71. package/assets/esri/core/workers/chunks/812f2ccc01f44e3cfd41.js +1 -0
  72. package/assets/esri/core/workers/chunks/826fa0dfb63df77bfd95.js +1 -0
  73. package/assets/esri/core/workers/chunks/{7544316a75dbd981aea6.js → 86cb097deec50b0da3f3.js} +1 -1
  74. package/assets/esri/core/workers/chunks/87921f3fa9001f5801ed.js +1 -0
  75. package/assets/esri/core/workers/chunks/{95c594a87b732f5c4979.js → 89b748e064ca90b4f76a.js} +1 -1
  76. package/assets/esri/core/workers/chunks/8a40ed2ee4b032822c30.js +1 -0
  77. package/assets/esri/core/workers/chunks/{09de8be660174a229efb.js → 8cbb28476151a37ae958.js} +1 -1
  78. package/assets/esri/core/workers/chunks/{fe77ae6cf232a7a3298e.js → 8d9d3797c6d62fdfff9d.js} +1 -1
  79. package/assets/esri/core/workers/chunks/{62a49cfd9a2508950e9f.js → 8fedfd33c37172dba6bf.js} +1 -1
  80. package/assets/esri/core/workers/chunks/91aa1157da32f650983b.js +1 -0
  81. package/assets/esri/core/workers/chunks/{e7638b9ab6674bc8a18f.js → 91dfd29e2dba200eab09.js} +1 -1
  82. package/assets/esri/core/workers/chunks/{794748fd1edc29a621cd.js → 9698f36c143953a975d4.js} +1 -1
  83. package/assets/esri/core/workers/chunks/98584902c9db6faa3e4d.js +1 -0
  84. package/assets/esri/core/workers/chunks/9e5e05d6430712b0b1bc.js +1 -0
  85. package/assets/esri/core/workers/chunks/{e5a06ce0ef6a9a90e100.js → 9f21436016ff7a899e79.js} +1 -1
  86. package/assets/esri/core/workers/chunks/{67d9cfe02613cb73ee37.js → 9ff8ee6ed6b98c03ae7e.js} +2 -2
  87. package/assets/esri/core/workers/chunks/{67d9cfe02613cb73ee37.js.LICENSE.txt → 9ff8ee6ed6b98c03ae7e.js.LICENSE.txt} +1 -1
  88. package/assets/esri/core/workers/chunks/a6ee40dfc471d6612f3c.js +1 -0
  89. package/assets/esri/core/workers/chunks/aa78b69219d9a0ef1c54.js.LICENSE.txt +1 -1
  90. package/assets/esri/core/workers/chunks/{a4db5c9a90107e097df8.js → af47272aaaef0ea57e71.js} +1 -1
  91. package/assets/esri/core/workers/chunks/b05208d56a724a8f1661.js +1 -0
  92. package/assets/esri/core/workers/chunks/{79968c183135281d2a6f.js → b3613a38178cad2ebc82.js} +1 -1
  93. package/assets/esri/core/workers/chunks/{22d6b8102e75bdef204c.js → b7eb486354994dc70855.js} +1 -1
  94. package/assets/esri/core/workers/chunks/bc19a232076d98825eef.js +1 -0
  95. package/assets/esri/core/workers/chunks/c29486c4eeb3e72effff.js +1 -0
  96. package/assets/esri/core/workers/chunks/{2b94623cabc6ae0f86ce.js → c37f7756d48ff9af2656.js} +1 -1
  97. package/assets/esri/core/workers/chunks/{1c52999a6392370844a6.js → c4090a60d149a5962179.js} +1 -1
  98. package/assets/esri/core/workers/chunks/c715fd32f814a0f14f40.js +1 -0
  99. package/assets/esri/core/workers/chunks/{73c1d43070b4fe1e5c1e.js → c8e686efe344a33a0258.js} +1 -1
  100. package/assets/esri/core/workers/chunks/{6bb5158de43c4b59107f.js → c9b16fd41cd59d452522.js} +1 -1
  101. package/assets/esri/core/workers/chunks/ce16489cf7eb0d78c741.js.LICENSE.txt +1 -1
  102. package/assets/esri/core/workers/chunks/cf971e7b1b98d9c502d3.js +1 -0
  103. package/assets/esri/core/workers/chunks/{279366e6b743f9680603.js → cfff044859e6e6dcc75d.js} +1 -1
  104. package/assets/esri/core/workers/chunks/d07f911d40bf05fc0306.js +1 -0
  105. package/assets/esri/core/workers/chunks/{8833c3d168951be4bf20.js → d0d79dd3e88eecf5c314.js} +1 -1
  106. package/assets/esri/core/workers/chunks/d1ca7c3a32ce00ed8b81.js +1 -0
  107. package/assets/esri/core/workers/chunks/{76ae1702fecc7ad7017c.js → d1e97cce5047f1791e22.js} +1 -1
  108. package/assets/esri/core/workers/chunks/{17acde0245ecd956306c.js → d233cc33497a663450f9.js} +1 -1
  109. package/assets/esri/core/workers/chunks/{b017bac40dc8328013e3.js → d391bfbaf0e790cd10d6.js} +2 -2
  110. package/assets/esri/core/workers/chunks/{b017bac40dc8328013e3.js.LICENSE.txt → d391bfbaf0e790cd10d6.js.LICENSE.txt} +1 -1
  111. package/assets/esri/core/workers/chunks/d6e0528eacee7ea4c1ce.js.LICENSE.txt +1 -1
  112. package/assets/esri/core/workers/chunks/{36fe6b8228e622407ec2.js → d8793eead02491136841.js} +1 -1
  113. package/assets/esri/core/workers/chunks/{4d599008e1ea42321b37.js → da24ad57747714ac5eda.js} +1 -1
  114. package/assets/esri/core/workers/chunks/db678a6e352275e507a9.js +1 -0
  115. package/assets/esri/core/workers/chunks/{facb3886714222772ab2.js → ddfd01bb9ba8577c3ffc.js} +1 -1
  116. package/assets/esri/core/workers/chunks/de2ebd9cc3d9e68d435b.js +1 -0
  117. package/assets/esri/core/workers/chunks/{50d9f69d5255af4b29bb.js → df5afa06c6deb6b40109.js} +1 -1
  118. package/assets/esri/core/workers/chunks/e25c4b4a03270d48f408.js +1 -0
  119. package/assets/esri/core/workers/chunks/e3294318daf1192b8319.js +1 -0
  120. package/assets/esri/core/workers/chunks/e599125e746c27de106e.js +1 -0
  121. package/assets/esri/core/workers/chunks/{da573ecc68e6aa8f6da9.js → e767f83f9e2de6650f80.js} +1 -1
  122. package/assets/esri/core/workers/chunks/e9d4cae2144974489d6e.js +1 -0
  123. package/assets/esri/core/workers/chunks/{91df8638b8b904e6d8c5.js → ead8d0cbcebd12dbfad7.js} +1 -1
  124. package/assets/esri/core/workers/chunks/{f9324e88c359c03f35aa.js → eb9c166db0db6fa60e95.js} +1 -1
  125. package/assets/esri/core/workers/chunks/ebcc94234d9d4be1941f.js +316 -0
  126. package/assets/esri/core/workers/chunks/ee5f0fd5384caa11c986.js +1 -0
  127. package/assets/esri/core/workers/chunks/{bc241c7735e4efba734a.js → f34e3fa0c5b28531e289.js} +1 -1
  128. package/assets/esri/core/workers/chunks/f64037a88ab03662dc2a.js +1 -0
  129. package/assets/esri/core/workers/chunks/f651c05604eab83aef5f.js.LICENSE.txt +1 -1
  130. package/assets/esri/core/workers/chunks/{d97fadbc69e055d183a0.js → f77f4bd6a577b92cf66f.js} +1 -1
  131. package/assets/esri/core/workers/chunks/f80f5dbf96c343ac4df6.js +1 -0
  132. package/assets/esri/core/workers/chunks/{16d66770ef841564ee3f.js → f89c90f98c85667b0ebc.js} +1 -1
  133. package/assets/esri/core/workers/chunks/{4c4227b0ea21a5e429ab.js → fb192de7e4fa152342bb.js} +1 -1
  134. package/assets/esri/core/workers/chunks/fbd8d2f61f8a15bcf3db.js +1 -0
  135. package/assets/esri/core/workers/chunks/fccd931f95d81ecc57b2.js +1 -0
  136. package/assets/esri/core/workers/chunks/{2f78861afe0e9037dd8d.js → fe49321dca22dc60d105.js} +1 -1
  137. package/assets/esri/libs/parquet/pkg/bundle_bg.wasm +0 -0
  138. package/assets/esri/themes/base/widgets/_NavigationToggle.scss +1 -1
  139. package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +4 -4
  140. package/assets/esri/themes/base/widgets/_Widget.scss +1 -1
  141. package/assets/esri/themes/dark/main.css +1 -1
  142. package/assets/esri/themes/light/main.css +1 -1
  143. package/assets/esri/themes/light/view.css +1 -1
  144. package/chunks/MultiPathImpl.js +1 -1
  145. package/chunks/Point2D.js +1 -1
  146. package/chunks/UnitFactory.js +1 -1
  147. package/config.js +1 -1
  148. package/core/QueueProcessor.js +1 -1
  149. package/core/SetUtils.js +1 -1
  150. package/core/has.js +1 -1
  151. package/form/FormTemplate.js +1 -1
  152. package/form/elements/Element.js +1 -1
  153. package/form/elements/FieldElement.js +1 -1
  154. package/form/elements/GroupElement.js +1 -1
  155. package/geometry/operators/gx/operatorOffset.js +1 -1
  156. package/geometry/support/meshUtils/loadGLTFMesh.js +1 -1
  157. package/identity/Credential.js +1 -1
  158. package/identity/IdentityManager.js +1 -1
  159. package/identity/IdentityManagerBase.js +1 -1
  160. package/interfaces.d.ts +92 -50
  161. package/kernel.js +1 -1
  162. package/layers/FeatureLayer.js +1 -1
  163. package/layers/SceneLayer.js +1 -1
  164. package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
  165. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  166. package/layers/graphics/sources/connections/GeoEventConnection.js +1 -1
  167. package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
  168. package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
  169. package/layers/knowledgeGraph/layerUtils.js +1 -1
  170. package/layers/orientedImagery/core/ExposurePoint.js +1 -1
  171. package/layers/orientedImagery/transformations/imageToWorld.js +1 -1
  172. package/layers/support/RasterJobHandler.js +1 -1
  173. package/layers/support/RasterWorker.js +1 -1
  174. package/layers/support/fieldConfigUtils.js +1 -1
  175. package/layers/support/rasterDatasets/pixelReader.js +1 -1
  176. package/layers/support/rasterFunctions/pixelTransformUtils.js +5 -0
  177. package/layers/support/rasterFunctions/pixelUtils.js +1 -1
  178. package/layers/support/source/DataLayerSource.js +1 -1
  179. package/package.json +4 -4
  180. package/popup/FieldInfo.js +1 -1
  181. package/processRequest.js +5 -0
  182. package/request.js +1 -1
  183. package/requestConfig.js +5 -0
  184. package/requestQueue.js +5 -0
  185. package/rest/query/executeForCount.js +1 -1
  186. package/rest/query/executeForExtent.js +1 -1
  187. package/rest/query/executeForIds.js +1 -1
  188. package/rest/query/executeQueryJSON.js +1 -1
  189. package/rest/query/executeQueryPBF.js +1 -1
  190. package/rest/query/operations/query.js +1 -1
  191. package/rest/support/BaseImageMeasureResultValue.js +5 -0
  192. package/rest/support/ImageAreaResult.js +1 -1
  193. package/rest/support/ImageDistanceResult.js +1 -1
  194. package/rest/support/ImageHeightResult.js +1 -1
  195. package/rest/support/ImageMeasureResultAngleValue.js +5 -0
  196. package/rest/support/ImageMeasureResultAreaValue.js +5 -0
  197. package/rest/support/ImageMeasureResultLengthValue.js +5 -0
  198. package/rest/support/ImageWithType.js +5 -0
  199. package/rest/support/imageMeasureUtils.js +1 -1
  200. package/smartMapping/renderers/size.js +1 -1
  201. package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
  202. package/smartMapping/support/adapters/InMemoryLayerAdapter.js +1 -1
  203. package/smartMapping/support/adapters/support/histogramUtils.js +1 -1
  204. package/smartMapping/support/adapters/support/utils.js +1 -1
  205. package/support/revision.js +1 -1
  206. package/symbols/support/utils.js +1 -1
  207. package/views/2d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles2D.js +1 -1
  208. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  209. package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
  210. package/views/2d/layers/features/schema/SourceSchema.js +1 -1
  211. package/views/2d/layers/features/sources/FeatureSource.js +1 -1
  212. package/views/2d/layers/features/sources/strategies/AFeatureLoadStrategy.js +1 -1
  213. package/views/2d/layers/features/sources/strategies/ALoadStrategy.js +1 -1
  214. package/views/2d/layers/features/sources/strategies/ParquetSnapshotLoadStrategy.js +1 -1
  215. package/views/2d/layers/features/sources/strategies/ParquetTileLoadStrategy.js +1 -1
  216. package/views/2d/layers/features/sources/strategies/chunks/Overrides.js +1 -1
  217. package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
  218. package/views/{3d/support/ImageWithType.js → 2d/layers/features/sources/strategies/constants.js} +1 -1
  219. package/views/2d/layers/features/sources/strategies/support/queryAdapters.js +1 -1
  220. package/views/3d/GroundView3D.js +1 -1
  221. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  222. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
  223. package/views/3d/analysis/VolumeMeasurement/volumeMeasurementErrors.js +1 -1
  224. package/views/3d/glTF/DefaultLoadingContext.js +1 -1
  225. package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js +1 -1
  226. package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
  227. package/views/3d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles3D.js +1 -1
  228. package/views/3d/layers/ElevationLayerView3D.js +1 -1
  229. package/views/3d/layers/FeatureLayerViewBase3D.js +1 -1
  230. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  231. package/views/3d/layers/graphics/FeatureGraphics3DGraphicsPipeline.js +1 -1
  232. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  233. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  234. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  235. package/views/3d/layers/graphics/Graphics3DSymbolCreationContext.js +1 -1
  236. package/views/3d/layers/graphics/ObjectResourceCache.js +1 -1
  237. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  238. package/views/3d/layers/graphics/pipeline/Feature3DPipeline.js +1 -1
  239. package/views/3d/layers/graphics/pipeline/fetching/Tile3DFetcher.js +1 -1
  240. package/views/3d/layers/graphics/wosrLoader.js +1 -1
  241. package/views/3d/layers/i3s/I3SDataRequester.js +5 -0
  242. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  243. package/views/3d/layers/i3s/I3SNodeLoader.js +1 -1
  244. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  245. package/views/3d/layers/support/FeatureTile.js +1 -1
  246. package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
  247. package/views/3d/layers/support/MediaLayerInteractionOptions.js +1 -1
  248. package/views/3d/layers/support/MediaLayerInteractionReshapeOptions.js +5 -0
  249. package/views/3d/layers/support/SampledGeometryMaxDistanceRatio.js +5 -0
  250. package/views/3d/layers/support/featureTileQuery3D.js +1 -1
  251. package/views/3d/layers/support/fetchTile.js +1 -1
  252. package/views/3d/support/ResourceController.js +1 -1
  253. package/views/3d/support/SharedSymbolResources.js +1 -1
  254. package/views/3d/support/StreamTextureCollection.js +1 -1
  255. package/views/3d/terrain/TerrainSurface.js +1 -1
  256. package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
  257. package/views/3d/webgl-engine/lighting/SceneLighting.js +1 -1
  258. package/views/3d/webgl-engine/shaders/AnimatedLine.glsl.js +6 -0
  259. package/views/SceneView.js +1 -1
  260. package/views/analysis/ElevationProfile/ElevationProfileTool.js +1 -1
  261. package/views/analysis/ElevationProfile/elevationProfileGeometryUtils.js +1 -1
  262. package/views/draw/MultipointDrawAction.js +1 -1
  263. package/views/draw/PointDrawAction.js +1 -1
  264. package/views/draw/PolygonDrawAction.js +1 -1
  265. package/views/draw/PolylineDrawAction.js +1 -1
  266. package/views/draw/SegmentDrawAction.js +1 -1
  267. package/views/draw/input/CursorUpdateEvents.js +5 -0
  268. package/views/draw/input/DrawCompleteEvent.js +5 -0
  269. package/views/draw/input/VertexAddEvent.js +5 -0
  270. package/views/draw/input/VertexRemoveEvent.js +5 -0
  271. package/views/draw/input/VertexUpdateEvent.js +5 -0
  272. package/views/interactive/editGeometry/CheckpointingEditGeometryOperations.js +5 -0
  273. package/views/interactive/editGeometry/EditGeometry.js +1 -1
  274. package/views/interactive/editGeometry/operations/ReplayableAppendVertex.js +5 -0
  275. package/views/interactive/snapping/featureSources/FeatureServiceSnappingSource.js +1 -1
  276. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js +1 -1
  277. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTileStore.js +1 -1
  278. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiledFetcher.js +1 -1
  279. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTilesSimple.js +1 -1
  280. package/views/support/PromiseQueue.js +1 -1
  281. package/views/support/Scheduler.js +1 -1
  282. package/webscene/spec-certification/api.js +1 -1
  283. package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
  284. package/widgets/CoordinateConversion.js +1 -1
  285. package/widgets/Editor/AddAssociationWorkflow.js +1 -1
  286. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  287. package/widgets/Editor/EditorViewModel.js +1 -1
  288. package/widgets/Editor/MergeFeaturesWorkflow.js +1 -1
  289. package/widgets/Editor/SplitFeatureWorkflow.js +1 -1
  290. package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
  291. package/widgets/Editor/UpdateFeaturesWorkflow.js +1 -1
  292. package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
  293. package/widgets/Editor/UpdateRecordWorkflowData.js +1 -1
  294. package/widgets/Editor/UpdateWorkflow.js +1 -1
  295. package/widgets/Editor/UpdateWorkflowData.js +1 -1
  296. package/widgets/Editor/support/SketchController.js +1 -1
  297. package/widgets/Editor/support/errors.js +5 -0
  298. package/widgets/Editor/workflowUtils.js +1 -1
  299. package/widgets/Editor.js +1 -1
  300. package/widgets/Legend/LegendViewModel.js +1 -1
  301. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  302. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  303. package/widgets/OrientedImageryViewer/adapters/sketch/TriangulatedMeasurementAdapter.js +1 -1
  304. package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
  305. package/widgets/OrientedImageryViewer/galleryUtils.js +1 -1
  306. package/widgets/OrientedImageryViewer/services/DepthImageService.js +1 -1
  307. package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
  308. package/widgets/PanoramicViewer/PanoramicZoomManager.js +1 -1
  309. package/widgets/PanoramicViewer/support/PanoramicMeshManager.js +1 -1
  310. package/widgets/PanoramicViewer/support/PanoramicTileNode.js +1 -1
  311. package/widgets/PanoramicViewer/support/PanoramicTilePyramid.js +1 -1
  312. package/widgets/PanoramicViewer/support/getVisibleTiles.js +5 -0
  313. package/widgets/Sketch/CreateToolVisibilityMap.js +5 -0
  314. package/widgets/Sketch/SelectionToolVisibilityMap.js +5 -0
  315. package/widgets/Sketch/VisibleElements.js +1 -1
  316. package/widgets/Sketch.js +1 -1
  317. package/assets/esri/core/workers/chunks/020c8913d8e35d63080b.js +0 -1
  318. package/assets/esri/core/workers/chunks/02e69f0c63d97661da60.js +0 -1
  319. package/assets/esri/core/workers/chunks/05eee334d58a0b9f6316.js +0 -1
  320. package/assets/esri/core/workers/chunks/06ba43843e9c4988049b.js +0 -1
  321. package/assets/esri/core/workers/chunks/087973e7c4fea5fcfa5e.js +0 -1
  322. package/assets/esri/core/workers/chunks/326a76a4e80269d4029d.js +0 -1
  323. package/assets/esri/core/workers/chunks/377a66034e7c1bad5599.js +0 -1
  324. package/assets/esri/core/workers/chunks/4442817beb7a76c95770.js +0 -1
  325. package/assets/esri/core/workers/chunks/459a67928bde4a62b6a4.js +0 -1
  326. package/assets/esri/core/workers/chunks/4eebd74ebc20579dade8.js +0 -1
  327. package/assets/esri/core/workers/chunks/53bd8996e8812f1ad7b2.js +0 -1
  328. package/assets/esri/core/workers/chunks/557960763695abee4a83.js +0 -1
  329. package/assets/esri/core/workers/chunks/6201356f7f91e5c06425.js +0 -1
  330. package/assets/esri/core/workers/chunks/6c3b99209d542efa64d4.js +0 -1
  331. package/assets/esri/core/workers/chunks/6f4bd0ee85e7e5a74340.js +0 -1
  332. package/assets/esri/core/workers/chunks/7413e582bc2b16af6a0f.js +0 -1
  333. package/assets/esri/core/workers/chunks/7461124454bfb4fb6474.js +0 -1
  334. package/assets/esri/core/workers/chunks/75bf27271a31e26e1b21.js +0 -1
  335. package/assets/esri/core/workers/chunks/7aaaebbabee27690283c.js +0 -1
  336. package/assets/esri/core/workers/chunks/7c4a63aeead2505d6f02.js +0 -1
  337. package/assets/esri/core/workers/chunks/811d4c46c75cf6a63e78.js +0 -1
  338. package/assets/esri/core/workers/chunks/8ffd4710d168c2fcfd96.js +0 -1
  339. package/assets/esri/core/workers/chunks/90250e9239c173aace88.js +0 -1
  340. package/assets/esri/core/workers/chunks/9786f91455350eaae493.js +0 -1
  341. package/assets/esri/core/workers/chunks/99859dce1925b406ccd0.js +0 -1
  342. package/assets/esri/core/workers/chunks/9c5cbf8810f37b1a4718.js +0 -1
  343. package/assets/esri/core/workers/chunks/9e8dceef4c961f56940d.js +0 -1
  344. package/assets/esri/core/workers/chunks/9fac5a12e878cd745354.js +0 -1
  345. package/assets/esri/core/workers/chunks/a06bac9b8f9e18874de8.js +0 -316
  346. package/assets/esri/core/workers/chunks/a712cdff78fc826acd8c.js +0 -1
  347. package/assets/esri/core/workers/chunks/a8f998b8ec8c56150479.js +0 -2
  348. package/assets/esri/core/workers/chunks/aa54b6f2aba6952af149.js +0 -1
  349. package/assets/esri/core/workers/chunks/b96eb0ea506379182d62.js +0 -2
  350. package/assets/esri/core/workers/chunks/c476643002387f60ea42.js +0 -1
  351. package/assets/esri/core/workers/chunks/c4e4da69969499a89a2c.js +0 -1
  352. package/assets/esri/core/workers/chunks/cd1930f08e1fc8b30b14.js +0 -1
  353. package/assets/esri/core/workers/chunks/d1fe816b6990918c13c7.js +0 -1
  354. package/assets/esri/core/workers/chunks/d305a21666b1ed5bf33d.js +0 -1
  355. package/assets/esri/core/workers/chunks/d40f57f9fc47f9a9f97c.js +0 -1
  356. package/assets/esri/core/workers/chunks/e0bbfbe1ed39c82f1bd4.js +0 -1
  357. package/assets/esri/core/workers/chunks/e82f5437bd66779c6740.js +0 -1
  358. package/assets/esri/core/workers/chunks/f6c8beb60f6d29945a2e.js +0 -1
  359. package/assets/esri/core/workers/chunks/f746e3f7ebff2bbdf333.js +0 -1
  360. package/assets/esri/core/workers/chunks/fd2efd1d1cf9d95a87e6.js +0 -1
  361. package/views/3d/layers/i3s/I3SStreamDataController.js +0 -5
  362. package/views/3d/support/StreamDataLoader.js +0 -5
  363. package/views/3d/support/StreamDataRequester.js +0 -5
  364. package/views/3d/support/downloadSlots.js +0 -5
  365. package/views/draw/input/DrawEvents.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/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 c}from"../../core/Evented.js";import{makeHandle as l}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 w}from"../../core/promiseUtils.js";import f from"../../core/ReactiveMap.js";import{whenOnce as F,on as _,watch as b,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 A}from"../../core/support/jsonUtils.js";import{UpdatingHandles as C}from"../../core/support/UpdatingHandles.js";import L from"../../geometry/Extent.js";import{union as G}from"../../geometry/geometryEngineAsync.js";import R from"../../geometry/Multipoint.js";import T from"../../geometry/Point.js";import O from"../../geometry/Polygon.js";import j from"../../geometry/Polyline.js";import{projectWithZConversion as B}from"../../geometry/projectionUtils.js";import H from"../../geometry/SpatialReference.js";import{polygonCentroidPoint as x}from"../../geometry/support/centroid.js";import{isClockwise as E}from"../../geometry/support/coordsUtils.js";import{normalizeMapX as D}from"../../geometry/support/normalizeUtils.js";import{geographicToWebMercator as z}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 ce,getUpdateElevationProps as le,isElevationSampler as he,getImageToWorldPanoramicProperties as ue,pointToArray as de,transformGraphicCoordinatesToPixel as me,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 we}from"../../layers/support/floorFilterUtils.js";import fe from"../../layers/support/VideoElement.js";import Fe from"../../views/MapView.js";import _e from"../../views/draw/Draw.js";import{scale as be}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as Me}from"../../views/input/InputManager.js";import Ie from"../PanoramicVideoViewer.js";import Pe from"../PanoramicViewer.js";import{defaultAngleThresholdInDegrees as Ve,videoExtent as Se,invalidCameraHeading as ke,sectorsInOrder as Ae,sampleExtent as Ce,sectorsRadii as Le}from"./constants.js";import{configureSketchTool as Ge,extractFieldsFromDataCaptureLayer as Re,isValidDataCaptureLayer as Te,constructGraphicFromImageGeometry as Oe}from"./dataCaptureUtils.js";import{isFeatureAttachment as je,getImageSourceFromAttachment as Be}from"./galleryUtils.js";import{getModeCorrectedPoint as He,calculateCorrectedPixel as xe,getUnitRateFromSpatialReference as Ee,calculateHeightFromTemporaryDistance as De,computeTriangulatedVector as ze,computeTriangulatedPoint as Ue}from"./imageMeasurementUtils.js";import{crossSymbol as Ne,crossSymbol3D as We,measurementPolygonSymbol as qe,polylineSymbolPanoramic as $e,measurementPolylineSymbol as Je,cameraOverlaySymbol3D as Ze,cameraOverlaySymbol as Ke,diamondSymbol as Qe,diamondSymbol3D as Xe,locationSymbol as Ye,locationSymbol3D as et,activeSourcePointSymbol as tt,sourcePointSymbol as at}from"./symbols.js";import{isNoAttachmentError as it,getContentType as rt,isTifOrMrf as st,filterOILLayerView as ot,assignElevationSampleToFeatures as nt,calculateDirection as ct,calculateSegment as lt,isSceneView as ht,isGraphic as ut}from"./utils.js";import{disableVideoZoomAndPan as dt}from"./videoViewerUtils.js";import mt from"./components/ImageViewer.js";import pt from"./components/NavigationNode.js";import gt from"./components/OrientedImageryVideoViewModel.js";import{NoActiveViewerError as yt,NoFeatureFoundWithObjectIdError as vt}from"./navigation/errors.js";import{queryFeatureByObjectIds as wt}from"./navigation/queries.js";import{ImageMeasurementService as ft}from"./services/ImageMeasurementService.js";import Ft from"../Sketch/SketchViewModel.js";const _t={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"},bt=new Set(["JPG","JPEG","TIFF","TIF","MRF"]),Mt=new Set(["MRF","TIFF","TIF"]),It=/\.(\w+)$/,Pt=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let Vt=class extends(c(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=Ve,this.cameraPitchThreshold=Ve,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.depthImage=null,this.directionMode="Relative",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._loadDepthImage(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 mt,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 f,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||this.mode.includes("video")&&!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 mt,this._initialCurrentCoverageUpdate=!0,this._locationPointOnImage=null,this._measurementService=null,this._correctedLocationPointOnImage=null,this._overlays=new U({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"},title:"OrentedImageryViewerViewModel overlays layer"}),this._panoramicVideoViewer=new Ie,this._panoramicViewer=new Pe,this._panoramicMeasurementViewer=new Pe,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._featureToSector=null,this._updatingHandles=new C,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.filterCapturedFeatures=e=>{const t=this.currentBestFeature?.attributes.objectId,a=this.layer?.imageReferenceField;if(!t||!e||!a)return;const i=this.overlayedMapFeatures.get(e);i?.forEach(e=>{const i=e.attributes??{},r=Object.keys(i).find(e=>e.toLowerCase()===a.toLowerCase());(r?i[r]:null)!==t&&(e.visible=!e.visible)})},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.storePanoramicMeasurementViewer=e=>{this._panoramicMeasurementViewer=e},this.loadImageViewer=e=>{this._imageViewer?.destroy(),this._imageViewer=e},this.loadPanoramicViewer=e=>{this._panoramicViewer?.destroy(),this._panoramicViewer=e},this.loadPanoramicVideoViewer=e=>{this._panoramicVideoViewer?.destroy(),this._panoramicVideoViewer=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.imageToImageTransformPanoramic=async(e,t,a)=>{const{updateElevationProps:i,...r}=t,{updateElevationProps:s,...o}=a,n=await te(e,r,i);return ye(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 yt;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,c=new t({geometry:n,attributes:o.toJSON(),layer:r,sourceLayer:r});v(e),await s.openPopup({features:[c],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(_t.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,Me.WIDGET),_t.click)},this._createImageClickHandle=()=>{this.removeHandles(_t.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 c=l(()=>{this.clickAction=n});let h=null;const u=_(()=>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:B(e,t)});v(a),this.plotReferencePointOnGround(r)})});this.addHandles([u,c],_t.imageClick)},this._createTriangularImageClickHandle=()=>{this.removeHandles(_t.triangularImageClick),this.triangularMeasurementActive&&"none"!==this.mode&&this.currentBestFeature&&this.currentBestFeatureMeasurementImage&&this.activeTriangulatedViewer&&this.addHandles(this.activeTriangulatedViewer.imageRenderer.on("double-click",this._measurementImageClickHandler),_t.triangularImageClick)},this._createTriangularImageLocationHandle=()=>{this.removeHandles(_t.triangularImageClick);const{imageLocationToolState:e,mode:t,activeTriangulatedViewer:a}=this,i=a?.imageSize;if(!e||"none"===t||!i)return;this.clickAction="pixel-location";let s=null;const o=_(()=>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 B(r,s),v(a)),await this._calculateTriangulatedPointFromGroundPoint(r,{signal:a}),v(a)}))});this.addHandles(o,_t.triangularImageClick)},this._createImageLocationHandle=()=>{this.removeHandles(_t.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 c=_(()=>a,"pixel-location",e=>{const{currentBestFeatureMeasurementImage:a,triangularMeasurementActive:s,activeTriangulatedViewer:c}=this;this.pixelCoordinates=e;const l=null!=a&&!c?.state.includes("loading");re(!s,l)&&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 B(r,n),v(a)),this.groundCoordinates=r,s&&r&&l&&await this.triangulatedLocationWorkflow(r,a);const c=await this.calculateLocationAccuracy(e,r,t,a);v(a),c&&(this.groundCoordinatesAccuracy=c)})});this.addHandles(c,_t.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._loadDepthImage=async e=>{const{currentBestFeature:t,layer:a,depthImageNotSupported:i}=this;if(this.depthImage?.destroy(),this.depthImage=null,!a||!t||i)return;const{depthImage:r}=t.attributes;if(!r)return;const s=(await import("./services/DepthImageService.js")).default;v(e),this.depthImage=new s({url:r});try{await this.depthImage.load(e)}catch(o){y(o)||(u.getLogger(this).error("error occurred while loading depth image",o),this.depthImage?.destroy(),this.depthImage=null)}},this._loadImage=async e=>{const{currentBestFeature:t,layer:a,mode:i}=this;if(this.clearGraphics(),!a||!t||"none"===i||"video"===i||"panoramic-video"===i)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:c,cameraPitch:l,objectId:h,cameraOrientation:d,location:m}=r,p=(c??0)+(o??0),g=m.spatialReference.isWGS84&&4!==d?.type?z(m):new T(m);let w=s;if(je(s))try{w=await Be(a,h,e)}catch(f){if(y(f))return;return it(f)?(u.getLogger(this).error(f),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${h}`)):(u.getLogger(this).error(f,{[a.objectIdField]:h,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${h}`))}try{await this.loadImageFromSource(w,{imageRotation:p,options:e,pitch:l,yaw:n,mode:i,cameraLocation:g}),v(e),await this.transformAndPlotSelectedLocation(e)}catch(f){y(f)||this.loadImageError(f)}},this._loadVideo=async e=>{const{currentBestFeature:t,layer:a,mode:i,selectedPoint:r}=this,s=t?.attributes.imagePath;if(!a||!t||"panoramic-video"!==i||!s)return;const{attributes:o}=t,{cameraHeading:n,cameraPitch:c,cameraOrientation:l,location:h}=o,u=h.spatialReference.isWGS84&&4!==l?.type?z(h):new T(h);try{this._panoramicVideoViewer.viewModel.video&&this._panoramicVideoViewer.viewModel.video.pause(),this._panoramicVideoViewer.videoSource=s;let t=n??0;u&&r&&(t=await se(u,r)-t),this._panoramicVideoViewer.pitch=c??0,this._panoramicVideoViewer.yaw=t,await this._panoramicVideoViewer.loadVideo(e),v(e)}catch(d){y(d)||this.loadImageError(d)}},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:c}=new URL(o);let l=s?n.match(It)?.[1]:e.datasetFormat;if(!l)try{l=await rt(o,{...t.options})}catch(h){y(h)||u.getLogger(this).error("#getContentType()",h)}switch(l??="UNKNOWN FORMAT",a){case"default":this.triangularMeasurementActive?await this._setImageSource(this.imageMeasurementViewer,l,o,c,i,r):await this._setImageSource(this._imageViewer,l,o,c,i,r);break;case"panoramic":if(bt.has(l.toUpperCase())){const{selectedPoint:e}=this,{pitch:a,yaw:i,cameraLocation:s,viewAngle:n}=t,c=this.triangularMeasurementActive?this._panoramicMeasurementViewer:this._panoramicViewer;let h=i??0;"number"==typeof n?h=n-h:s&&e&&(h=await se(s,e)-h),c.imageSource=o,c.pitch=a??0,c.yaw=h,Mt.has(l.toUpperCase())?await c.loadImageTiled(o,r):await c.loadImage(r)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:l});break}},this._loadMeasurementViewerImage=async e=>{const{currentBestFeatureMeasurementImage:t,layer:a,mode:i}=this;if(this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearGraphics(),!a||!t||"none"===i||"video"===i||"panoramic-video"===i)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:c,cameraPitch:l,objectId:h,cameraOrientation:d,location:m}=r,p=(c??0)+(o??0),g=m.spatialReference.isWGS84&&4!==d?.type?z(m):new T(m);let w=s;if(je(s))try{w=await Be(a,h,e)}catch(f){if(y(f))return;return it(f)?(u.getLogger(this).error(f),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${h}`)):(u.getLogger(this).error(f,{[a.objectIdField]:h,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${h}`))}try{await this.loadImageFromSource(w,{imageRotation:p,options:e,pitch:l,yaw:n,mode:i,cameraLocation:g}),v(e)}catch(f){y(f)||this.loadImageError(f)}},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=>{if(e.stopPropagation(),e.preventDefault(),e.mapPoint){const t=e.mapPoint;t.x=D(t.x,t.spatialReference),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 w(a),!e)return;const i=new T({...A(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:Ne}),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:We}),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([b(()=>this.view,()=>this.load(),M),b(()=>this.view?.map,(e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)},I),b(()=>this.view?.map?.allLayers?.length,e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)},I),b(()=>[this.state,this.mapImageConversionToolState,this.view],()=>{this._createViewClickHandle(),this._createImageClickHandle()},M),b(()=>[this.triangularMeasurementActive,this.currentBestFeatureMeasurementImage],()=>{this._createTriangularImageClickHandle()},M),b(()=>[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),b(()=>this.measureType,()=>{this.clearPreviousMeasurements(),this._initializeMeasurementService()},M),b(()=>this.bestFeatureAngle,(e,t)=>{this.previousFeatureAngle=t??0},M),b(()=>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}),b(()=>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),b(()=>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._panoramicMeasurementViewer.clearImage(),this._panoramicMeasurementViewer.clearGraphics())}),b(()=>this.mode,e=>{switch(this.removeHandles(_t.interactionHandles),e){case"default":this.addHandles(b(()=>{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)}),_t.interactionHandles);break;case"video":this.addHandles(b(()=>{const{footprintExtent:e}=this;if(e)return Se},e=>{e&&(m(this._updateFootprintTask),this._updateFootprintTask=r(async t=>{await this.updateFootprint(e,{signal:t})}))},{...M,equals:(e,t)=>a(e,t,h)}),_t.interactionHandles);break;case"panoramic":this.addHandles(b(()=>{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)}),_t.interactionHandles);break;case"panoramic-video":this.addHandles(b(()=>{const{currentBestFeature:e,state:t,_panoramicVideoViewer:a}=this,{imageSize:i,vfov:r,hfov:s,pitch:o,yaw:n,viewModel:c}=a,l=c.closestFeature??e;return l&&i&&!t.includes("loading")&&null!=r&&null!=s&&null!=o&&null!=n?[r,s,n,o,l]:null},e=>{if(!e)return;const[t,a,i,s,o]=e;m(this._updateFootprintTask),this._updateFootprintTask=r(async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:a,yaw:i,pitch:s,feature:o},{signal:e}),v(e),this._updateFootprintTask=null})},{equals:(e,t)=>a(e,t,h)}),_t.interactionHandles)}},M),b(()=>[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),b(()=>this.activeViewer?.imageRenderer,()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)}),b(()=>this.activeViewer,e=>{this.removeHandles(_t.hittestHandles),e&&this.addHandles(_(()=>e,"hittest-response",this._handleImageHitTestResponse),_t.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(),this._panoramicMeasurementViewer.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 activeTriangulatedViewer(){switch(this.mode){case"default":return this.imageMeasurementViewer;case"panoramic":return this._panoramicMeasurementViewer;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 depthImageNotSupported(){if(this.currentBestFeature?.attributes.depthImage)return!st(this.currentBestFeature.attributes.depthImage)}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){const{currentBestFeature:e}=this;if(!e)return!1;const t=e.attributes.imagePath?.trim();return st(t)||je(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(ot(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?we(e):null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";const t=e.orientedImageryType;if(t?.includes("video"))return t.includes("360")?"panoramic-video":"video";const{horizontalFieldOfView:a,isSpherical:i}=e;return 360===a||i?"panoramic":"default"}get panoramicVideoLoaded(){const{mode:e,_panoramicVideoViewer:t}=this,{videoLoaded:a}=t.viewModel;return("panoramic-video"===e&&!0===a)??!1}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",d(e,0,1))}get sketchGraphicsLayer(){const{sketch:e}=this;return"graphics"===e?.layer?.type?e.layer:void 0}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 st(r)||je(r)?{url:r,objectId:t,rotation:(a??0)+(i??0)}:null}).filter(i)):null}set view(e){this._set("view",e)}get _defaultGraphicsLayer(){const e={blendMode:"source-atop"};switch(this.mode){case"panoramic":return new U({...e,elevationInfo:{mode:"absolute-height"}});case"default":return new U({...e});default:return}}get _overlaysView(){return this.view?.layerViews.find(({layer:e})=>e===this._overlays)}beforeLoad(e=!0){this.view?.closePopup(),e&&(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){await(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 Pt();Ge(i,e,a),await a.create(e,{...t,defaultZ:0})}digitizeDelete(){if(!this.sketch)throw Pt();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw Pt();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw Pt();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw Pt();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw Pt();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw Pt();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 c;const{polygon:l,frustum:h}=J(n);if(c=l.clone(),n.isInspection&&(c=Z(n)),o&&(c=K(c,o)),a||!t||Q(c,t)){s.push(e);const{geometry:t,objectId:a,cameraHeight:o,cameraHeading:c}=n,u=t.clone();u.z=o,u.imageID=a,this.pointSources.push(u),c!==ke&&(i.push(l),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=ce(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?B(n,H.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&&he(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t}))}getMeasurementPropertiesPanoramic(e=this.currentBestFeature,t=this.activeViewer){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?B(n,H.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&&he(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t}))}async deleteDataCaptureFeatures(e){const{dataCaptureLayer:t}=this;if(!t)throw new n("orientedimageryviewer:missing-featurelayer","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 c=He(e.vertices.at(-1),r,n);if(i.length<1||!c||!a||!t||"none"===r)return;const l=xe(i[0],c,t);if(!l?.length)return;this.heightMeasurementPixels.push(l),"panoramic"===r?this.createPolylineGraphicPano():this.createPolylineGraphic();const h=Ee(o.attributes.location.spatialReference),u=De(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=He(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._defaultGraphicsLayer,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),nt(r,n);const c=this._processSuitableFeatures(r,t);this.updateSuitabilities(c,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=qe(o),this.sketch.polylineSymbol="panoramic"===s?$e:Je(o,2.5))}startHeightMeasurement(){this.heightMeasurementPixels=[],this.displayNewMeasurementButton=!1,this.draw??=new _e({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:Je(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:c}=oe(r,a[0],a[1]),l=[[...ne(s,o)],[...ne(n,c)]];if(this.heightGraphic)this.heightGraphic.geometry=new j({paths:[l],spatialReference:e});else{const a=new j({paths:[l],spatialReference:e});this.heightGraphic=new t({geometry:a,symbol:$e}),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 c=0;c<s.length;c++){const e={x:s[c][0],y:s[c][1]};let a=await this.getMapPoint(e,{feature:t,imageSize:r,mode:i});o&&!a.spatialReference.equals(o)&&(a=await B(a,o)),n.push(a)}return ze(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:c}=this,l=a?.imageSize;if(!l||!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:P(`${s.objectIdField} <> ${i.attributes.objectId}`,P(s.definitionExpression,c)),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:l,mode:o}),n="panoramic"===o?Ze():Ke();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:c,layer:l}=this,h=r?.imageSize;if(!h||!o||"none"===n||"video"===n||"panoramic-video"===n||c.includes("loading")||!l)return;const{polygon:d}=J(o.attributes);try{const{imageGeometryField:t,oiObjectIdField:a}=Re(e,l.imageGeometryField,l.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:c}=i,l=c,{imageGeometryField:d,oiObjectIdField:m}=this;if(d&&m&&Te(e,d,m)&&`${s[m]}`==`${o.attributes.objectId}`)try{return Oe(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(l?.type){case"point":{const i=await this.getPixels(l,{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:c}=l,u=i.map(e=>e.map(([e,t,a])=>new T({x:e,y:t,z:a,spatialReference:c}))),d=await Promise.all(u.map(async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then(e=>e.map(de))));return new t({attributes:s,layer:e,symbol:r,geometry:new O({rings:d,spatialReference:H.WebMercator}),visible:e.visible&&a})}case"polyline":{const{paths:i,spatialReference:c}=l,u=i.map(e=>e.map(([e,t,a])=>new T({x:e,y:t,z:a,spatialReference:c}))),d=await Promise.all(u.map(async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then(e=>e.map(de))));return new t({attributes:s,layer:e,symbol:r,geometry:new j({paths:d,spatialReference:H.WebMercator}),visible:e.visible&&a})}case"multipoint":{const{points:i,spatialReference:c}=l,u=i.map(([e,t,a])=>new T({x:e,y:t,z:a,spatialReference:c})),d=await this.getPixels(u,{feature:o,imageSize:h,mode:n}).then(e=>e.map(de));return new t({attributes:s,layer:e,symbol:r,geometry:new R({points:d,spatialReference:H.WebMercator}),visible:e.visible&&a})}}return null}))).filter(i));this.overlayGraphicsOnImage(`${e.id}`,p)}getDepthAt(e){const{activeViewer:t,currentBestFeature:a,mode:i,state:r,depthImage:s}=this,o=t?.imageSize;if(!o||!a||"none"===i||r.includes("loading"))return u.getLogger(this).warnOnce("oriented-imagery-viewer:get-depth-at","Load an image to use depth"),null;if(!s?.loaded)return u.getLogger(this).error("oriented-imagery-viewer:get-depth-at","Depth image is not loaded"),this.emit("depth-image-service:not-loaded"),null;const n=(Array.isArray(e)?e:[e]).map(e=>s.depthAt(e,{width:o[0],height:o[1]})??null);return Array.isArray(e)?n:n[0]}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:c,cameraHeight:l}=o;let h=c.clone();h.spatialReference.isGeographic&&(h=await B(h,H.WebMercator));const u=await le(c.spatialReference,c.z??0,l,{elevationSample:s,elevationSource:n,extent:this.footprintExtent});let d;"elevationSample"in u&&he(u.elevationSample)&&(a.elevationSample=u.elevationSample);const m=Array.isArray(e)?e:[e];if(this.depthImage?.loaded)for(const p of m){const e=this.getDepthAt(p);null!=e&&(p.depth=e)}if("default"===i){const e=ce(o,r[0],r[1]);d=await ee(m,{...e,cameraLocation:h},u)}else{const e=ue(o,r[0],r[1]);d=await te(m,{...e,cameraLocation:h},u)}return Array.isArray(e)?d:d[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:Qe}),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=A(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:Qe}),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:Xe}),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,t)}}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))}reset(){const{mode:e}=this;"default"===e||"panoramic"===e?this.resetImage():"video"===e?this.resetVideo():"panoramic-video"===e&&this.resetVideoPanoramic(),this.beforeLoad(!1)}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}resetVideoPanoramic(){this.setMessage("onLoadMessage","info"),this._overlays?.removeAll(),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:c}=n;return r?t.error.push(n):(a&&(c[e.objectIdField]=a),i&&e.globalIdField&&(c[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||"panoramic-video"===s)throw new n("orientedimageryviewer:missing-input","Image size, current best feature and mode are required to save data capture features");if(!r)throw new n("orientedimageryviewer:missing-featurelayer","Data capture layer is not available");const c=await Promise.all(e.map(async e=>{const t=e.clone(),{geometry:i}=t;if(!i)return;const n=i.type,c=r.hasZ,l=r.geometryType,h=n!==l,u=h?await import("./transformers.js"):null,d=u?.default[l],m=h?d?.(i):i;if(m)switch(m.type){case"point":return t.geometry=await this.getMapPoint(me(s,m,o),{feature:a,imageSize:o,mode:s}),c||(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])=>me(s,{x:e,y:t,z:a},o)),{feature:a,imageSize:o,mode:s})));return t.geometry=new O({spatialReference:e[0][0].spatialReference,hasZ:c,hasM:!1,rings:e.map(e=>e.map(de))}),t}case"polyline":{const e=await Promise.all(m.paths.map(async e=>this.getMapPoint(e.map(([e,t,a])=>me(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:c,hasM:!1,paths:e.map(e=>e.map(de))}),t}}})),l=c.filter(i);return r.applyEdits({addFeatures:l}).then(e=>{const{addFeatureResults:t}=e;let a=0;const i=c.map(e=>{const i=t[a++];return e?i:{error:new n("orientedimageryviewer:save-unsucccessful","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()??[],c=[],l=[];for(const s of n)`${s.getAttribute(i)}`==`${o}`?c.push(s):l.push(s);this.overlayGraphicsOnImage(e.id,new s(l)),this.collectionId=e.id;const h=await this.loadSketch(t),u=await this.loadDataCaptureAdapter(t);v(t),h.addGraphics(c),u.savedGraphics.addMany(c);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 B(a,o.spatialReference);r=o.contains(e);break}case"mesh":{const e=a.spatialReference.equals(o.spatialReference)?a:await B(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=ze(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=ze(e,a);i&&this.measurementVectors.push(i);const r=await Ue(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 c=n.map(({distance:e})=>e),l=Math.max(...c);n.forEach(e=>{const{distance:t,angle:i,featureIndex:s}=e,n=t/l*Le[2],c=lt(t,l),h=ct(i);if(!this._sectorData)return;const u=Le[3]+n*Math.sin(i*Math.PI/180),d=Le[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-Le[3],t=d-Le[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 w=""===c?h:`${c}_${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}`]=w;const f=this._sectorData[w];f.add({angle:i,featureIndex:s,x:u,y:d,objectID:p.attributes.objectId,sector:w,featureIndexInSector:f.length})})}_handleDestroyedTriangularSketchLayer(){this.sketchTriangularGraphicsLayer&&this.activeTriangulatedViewer&&(this.activeTriangulatedViewer.imageRenderer.map.layers.remove(this.sketchTriangularGraphicsLayer),this.sketchTriangularGraphicsLayer=new U,this.activeTriangulatedViewer.imageRenderer.map.layers.add(this.sketchTriangularGraphicsLayer),this.sketchTriangular&&(this.sketchTriangular.layer=this.sketchTriangularGraphicsLayer,this.sketchTriangular.view=this.activeTriangulatedViewer.imageRenderer))}_initializeMeasurementService(){this._measurementService||(this._measurementService=new ft(this))}_initializeSketchTriangular(){this.activeTriangulatedViewer&&(this.sketchTriangular=new Ft({view:this.activeTriangulatedViewer.imageRenderer,layer:this.sketchTriangularGraphicsLayer,updateOnGraphicClick:!1,defaultUpdateOptions:{toggleToolOnClick:!1}}))}_initializeSketchTriangularGraphicsLayer(){this.activeTriangulatedViewer&&(this.sketchTriangularGraphicsLayer=new U,this.activeTriangulatedViewer.imageRenderer.map.layers.add(this.sketchTriangularGraphicsLayer))}_initializeVideo(){if(this.videoElement||!this.currentBestFeature)return;this.removeHandles(_t.videoPlayerHandles),this.videoElement=new fe({video:this.currentBestFeature.attributes.imagePath,georeference:new ve({extent:new L(Ce)}),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(dt(this.videoMapView),_t.videoPlayerHandles),this.videoViewModel=new gt({oiViewModel:this})}_plotLocationPointOnDefaultImage(e,a=!1){const i=A(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:Ye}),this.imageMeasurementViewer.addGraphic(this._correctedLocationPointOnImage,0)):(this._locationPointOnImage=new t({geometry:new T({spatialReference:H.WebMercator,...i}),symbol:Ye}),this._imageViewer.addGraphic(this._locationPointOnImage,0))}_plotLocationPointOnPanoramicImage(e,a=!1){const i=a?this._panoramicMeasurementViewer:this._panoramicViewer,{imageSize:r}=i;if(!r)return;const[s,o]=r,{heading:n,pitch:c}=oe(e,s,o),l=ne(n,c),h=new t({geometry:new T(l,H.WebMercator),symbol:et});a?this._correctedLocationPointOnImage=h:this._locationPointOnImage=h,i.addGraphic(h,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 G(e);if(this._updateFootprintWithFeatures(t,i),"3d"===this.view?.type)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:ht(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=D(o.x,o.spatialReference);const{layerFloorFilterClause:n}=this,c=e.spatialReference.equals(o.spatialReference)?o:await B(o,e.spatialReference),l=c.spatialReference.isGeographic?z(c):c,h=P("1=1",P(e.definitionExpression,n)),u=l.spatialReference.isGeographic?1:V(l.spatialReference),d={layerInstanceOrURL:e,point:l,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 wt(e,t,a,i);if(v(i),!r?.features?.length)throw new vt(t);const s=J(r.features[0].attributes).polygon,o=T.fromJSON(x(s)),n=Y(o),c=V(n.spatialReference);this.selectedPoint=n;const l={layerInstanceOrURL:e,point:n,queryParams:{where:P(P("1=1",P(e.definitionExpression,a)),`${e.objectIdField} <> ${t}`),maximumDistance:e.maximumDistance?e.maximumDistance/c:void 0}},h=await W(l,i);v(i);const{features:u}=h;return u.push(r.features[0]),await this.processFeatureResponse(h,n,{...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(_t.activeViewerCursorHandles),t&&this.removeHandles(_t.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"),_t.activeViewerCursorHandles),t&&a&&this.addHandles(t.imageRenderer.acquireCursor("crosshair","high"),_t.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 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[c,...l]=await ae([t,...e.map(e=>e.attributes.geometry.clone())],n);v(i),t.elevation=c.z,e.forEach((e,t)=>{e.attributes.elevation=l[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 pt({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])),"panoramic-video"===this.mode&&this._loadVideo()}_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=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:tt,visible:r}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:at,visible:s}));if(("video"===o||"panoramic-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));if("panoramic-video"===this.mode)return void(this.currentBestFeature&&this._panoramicVideoViewer.viewModel.playPanoramicVideoFromSelectedLocation(this.currentBestFeature));const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let a;if(t)a=-90;else{const t=e.x-Le[3],i=e.y-Le[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(),this._panoramicMeasurementViewer.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._panoramicMeasurementViewer.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:c},elevationSample:l}=t;let h=s.clone();const u=await le(s.spatialReference,s.z??0,c,{elevationSample:l,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(ae(e,u));t(e)})));if(s.spatialReference.isGeographic&&(h=await B(h,H.WebMercator,a)),p=await Promise.all(p.map(async e=>h.spatialReference.equals(e.spatialReference)?e:await B(e,h.spatialReference,a))),v(a),"panoramic"===this.mode)m=ye(p,{imageHeight:r[1],imageWidth:r[0],cameraHeading:n,cameraLocation:h});else{const e=pe(t.attributes,r[0],r[1]);m=ge(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:c,_adapter:l,mode:h}=this;if(!r)return;const{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),c){const e=[...a,...i,s].filter(ut);"3d"===c?.type&&d&&l?.updateGroundElevation&&(this._updateGroundElevation&&l.updateGroundElevation(e,d),"panoramic"===h&&l.updateGroundElevation([this.bestFeatureCurrentFootprint],d)),this._updateGroundElevation=!1,n&&(e.splice(-2,0,this.bestFeatureCurrentFootprint),e.push(new t({geometry:n.clone(),symbol:Ne.clone(),attributes:{imageID:u}}))),this._overlays.graphics.addMany(e)}}else if(c){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,"3d"===c?.type&&d&&l?.updateGroundElevation&&"panoramic"===h&&l.updateGroundElevation([e],d),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([S()],Vt.prototype,"activeLayer",null),e([S({readOnly:!0})],Vt.prototype,"activeViewer",null),e([S()],Vt.prototype,"activeTriangulatedViewer",null),e([S()],Vt.prototype,"accuracyParametersMissing",null),e([S()],Vt.prototype,"additionalFeatures",void 0),e([S({type:s.ofType(t)})],Vt.prototype,"additionalCameraLocations",void 0),e([S({type:s.ofType(t)})],Vt.prototype,"additionalFootprints",void 0),e([S()],Vt.prototype,"areaMeasurementResult",void 0),e([S()],Vt.prototype,"areaMeasurementAccuracy",void 0),e([S()],Vt.prototype,"bestFeatureAngle",void 0),e([S()],Vt.prototype,"bestFeatureCurrentFootprint",void 0),e([S({type:t})],Vt.prototype,"bestFeatureFootprint",void 0),e([S({type:Number})],Vt.prototype,"brightness",null),e([S()],Vt.prototype,"cameraHeadingThreshold",void 0),e([S()],Vt.prototype,"cameraPitchThreshold",void 0),e([S()],Vt.prototype,"clickAction",void 0),e([S()],Vt.prototype,"videoViewModel",void 0),e([S()],Vt.prototype,"collectionId",void 0),e([S({type:Number})],Vt.prototype,"contrast",null),e([S()],Vt.prototype,"conversionProps",void 0),e([S()],Vt.prototype,"coverageFrustums",void 0),e([S()],Vt.prototype,"coveragePolygons",void 0),e([S()],Vt.prototype,"currentBestFeature",void 0),e([S()],Vt.prototype,"currentBestFeatureMeasurementImage",void 0),e([S()],Vt.prototype,"currentBestFeatureLocation",void 0),e([S()],Vt.prototype,"currentCoverageVisible",void 0),e([S()],Vt.prototype,"currentNode",null),e([S()],Vt.prototype,"depthImage",void 0),e([S()],Vt.prototype,"depthImageNotSupported",null),e([S()],Vt.prototype,"directionMode",void 0),e([S()],Vt.prototype,"featureCache",void 0),e([S()],Vt.prototype,"navigationNodes",void 0),e([S({json:{write:!1}})],Vt.prototype,"determineWorkflowForFeature",void 0),e([S({json:{write:!1}})],Vt.prototype,"determineWorkflowForTriangularMeasurement",void 0),e([S()],Vt.prototype,"disabled",void 0),e([S()],Vt.prototype,"displayMessage",void 0),e([S()],Vt.prototype,"displayNewMeasurementButton",void 0),e([S()],Vt.prototype,"distanceMeasurementResult",void 0),e([S()],Vt.prototype,"distanceAccuracyArray",void 0),e([S()],Vt.prototype,"dataCaptureLayer",void 0),e([S({readOnly:!0})],Vt.prototype,"featureCount",null),e([S()],Vt.prototype,"features",void 0),e([S()],Vt.prototype,"groundCoordinates",void 0),e([S()],Vt.prototype,"groundCoordinatesAccuracy",void 0),e([S()],Vt.prototype,"heightMeasurementPixels",void 0),e([S()],Vt.prototype,"heightGraphic",void 0),e([S()],Vt.prototype,"heightMeasurementResult",void 0),e([S()],Vt.prototype,"heightMeasurementAccuracy",void 0),e([S()],Vt.prototype,"measurementAngle",void 0),e([S()],Vt.prototype,"tempDistance",void 0),e([S({readOnly:!0})],Vt.prototype,"imageGalleryEnabled",null),e([S()],Vt.prototype,"imageGeometryField",void 0),e([S({readOnly:!0})],Vt.prototype,"imageLoaded",null),e([S()],Vt.prototype,"imageLocationToolState",void 0),e([S({readOnly:!0})],Vt.prototype,"invalidCameraHeading",null),e([S()],Vt.prototype,"imagePointsInView",null),e([S()],Vt.prototype,"imageMeasurementViewer",void 0),e([S()],Vt.prototype,"isAdditionalCoverageVisible",void 0),e([S()],Vt.prototype,"isAdditionalPointSourcesVisible",void 0),e([S()],Vt.prototype,"measurementVectors",void 0),e([S()],Vt.prototype,"layer",void 0),e([S()],Vt.prototype,"layerView",null),e([S({readOnly:!0})],Vt.prototype,"layerFloorFilterClause",null),e([S({type:Number})],Vt.prototype,"localPort",void 0),e([S()],Vt.prototype,"mapImageConversionToolState",void 0),e([S()],Vt.prototype,"measureType",void 0),e([S()],Vt.prototype,"measurementGraphic",void 0),e([S({readOnly:!0,value:"none"})],Vt.prototype,"mode",null),e([S()],Vt.prototype,"navigationMode",void 0),e([S()],Vt.prototype,"navigatorCurrentBestFeature",void 0),e([S()],Vt.prototype,"oiObjectIdField",void 0),e([S({type:s.ofType(t)})],Vt.prototype,"overlayedCameraLocations",void 0),e([S()],Vt.prototype,"overlayedMapFeatures",void 0),e([S()],Vt.prototype,"panoramicVideoLoaded",null),e([S()],Vt.prototype,"pixelCoordinates",void 0),e([S()],Vt.prototype,"preserveAngle",void 0),e([S()],Vt.prototype,"pointSources",void 0),e([S({readOnly:!0})],Vt.prototype,"popupEnabled",null),e([S()],Vt.prototype,"previousFeatureAngle",void 0),e([S()],Vt.prototype,"referencePoint",null),e([S({readOnly:!0})],Vt.prototype,"sectorData",null),e([S()],Vt.prototype,"selectedPoint",void 0),e([S({type:Number})],Vt.prototype,"sharpness",null),e([S()],Vt.prototype,"shouldShowSelectedImage",void 0),e([S()],Vt.prototype,"sketch",void 0),e([S()],Vt.prototype,"sketchTriangular",void 0),e([S()],Vt.prototype,"sketchTriangularGraphicsLayer",void 0),e([S()],Vt.prototype,"draw",void 0),e([S()],Vt.prototype,"sketchAdapter",void 0),e([S({readOnly:!0})],Vt.prototype,"sketchGraphicsLayer",null),e([S({readOnly:!0})],Vt.prototype,"state",null),e([S({readOnly:!0})],Vt.prototype,"thumbnails",null),e([S()],Vt.prototype,"triangularMeasurementActive",void 0),e([S()],Vt.prototype,"triangulatedDistanceMeasurement",void 0),e([S()],Vt.prototype,"triangulatedDistanceAccuracy",void 0),e([S()],Vt.prototype,"triangulatedAreaMeasurement",void 0),e([S()],Vt.prototype,"triangulatedAreaAccuracy",void 0),e([S()],Vt.prototype,"triangulatedMeasurementGraphic",void 0),e([S()],Vt.prototype,"triangulatedPoint",void 0),e([S()],Vt.prototype,"triangulatedMeasurementAdapter",void 0),e([S()],Vt.prototype,"updateFootprint",void 0),e([S()],Vt.prototype,"updateFootprintPanorama",void 0),e([S()],Vt.prototype,"updatingTriangularMeasurementState",void 0),e([S({value:null})],Vt.prototype,"view",null),e([S()],Vt.prototype,"videoElement",void 0),e([S()],Vt.prototype,"videoLayer",void 0),e([S()],Vt.prototype,"videoMapView",void 0),e([S()],Vt.prototype,"_adapter",void 0),e([S()],Vt.prototype,"_defaultGraphicsLayer",null),e([S()],Vt.prototype,"_highlightedFeatureHandle",void 0),e([S()],Vt.prototype,"_imageViewer",void 0),e([S()],Vt.prototype,"_initialCurrentCoverageUpdate",void 0),e([S()],Vt.prototype,"_locationPointOnImage",void 0),e([S()],Vt.prototype,"_measurementService",void 0),e([S()],Vt.prototype,"_correctedLocationPointOnImage",void 0),e([S()],Vt.prototype,"_overlays",void 0),e([S({readOnly:!0})],Vt.prototype,"_overlaysView",null),e([S()],Vt.prototype,"_panoramicVideoViewer",void 0),e([S()],Vt.prototype,"_panoramicViewer",void 0),e([S()],Vt.prototype,"_panoramicMeasurementViewer",void 0),e([S()],Vt.prototype,"_referencePointOnGround",void 0),e([S()],Vt.prototype,"_referencePointOnImage",void 0),e([S()],Vt.prototype,"_sectorData",void 0),e([S()],Vt.prototype,"_featureToSector",void 0),e([S({readOnly:!0})],Vt.prototype,"_updatingHandles",void 0),e([S()],Vt.prototype,"footprintExtent",void 0),e([S()],Vt.prototype,"_featureChangedTask",void 0),Vt=e([k("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],Vt);const St=Vt;export{St 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 c}from"../../core/Evented.js";import{makeHandle as l}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 w}from"../../core/promiseUtils.js";import f from"../../core/ReactiveMap.js";import{whenOnce as F,on as _,watch as b,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 A}from"../../core/support/jsonUtils.js";import{UpdatingHandles as C}from"../../core/support/UpdatingHandles.js";import L from"../../geometry/Extent.js";import{union as G}from"../../geometry/geometryEngineAsync.js";import T from"../../geometry/Multipoint.js";import O from"../../geometry/Point.js";import R from"../../geometry/Polygon.js";import j from"../../geometry/Polyline.js";import{projectWithZConversion as B}from"../../geometry/projectionUtils.js";import H from"../../geometry/SpatialReference.js";import{polygonCentroidPoint as x}from"../../geometry/support/centroid.js";import{isClockwise as E}from"../../geometry/support/coordsUtils.js";import{normalizeMapX as D}from"../../geometry/support/normalizeUtils.js";import{geographicToWebMercator as z}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 ce,getUpdateElevationProps as le,isElevationSampler as he,getImageToWorldPanoramicProperties as ue,pointToArray as de,transformGraphicCoordinatesToPixel as me,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 we}from"../../layers/support/floorFilterUtils.js";import fe from"../../layers/support/VideoElement.js";import Fe from"../../views/MapView.js";import _e from"../../views/draw/Draw.js";import{scale as be}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as Me}from"../../views/input/InputManager.js";import Ie from"../PanoramicVideoViewer.js";import Pe from"../PanoramicViewer.js";import{defaultAngleThresholdInDegrees as Ve,videoExtent as Se,invalidCameraHeading as ke,sectorsInOrder as Ae,sampleExtent as Ce,sectorsRadii as Le}from"./constants.js";import{configureSketchTool as Ge,extractFieldsFromDataCaptureLayer as Te,isValidDataCaptureLayer as Oe,constructGraphicFromImageGeometry as Re}from"./dataCaptureUtils.js";import{isFeatureAttachment as je,getImageSourceFromAttachment as Be}from"./galleryUtils.js";import{getModeCorrectedPoint as He,calculateCorrectedPixel as xe,getUnitRateFromSpatialReference as Ee,calculateHeightFromTemporaryDistance as De,computeTriangulatedVector as ze,computeTriangulatedPoint as Ue}from"./imageMeasurementUtils.js";import{crossSymbol as Ne,crossSymbol3D as We,measurementPolygonSymbol as qe,polylineSymbolPanoramic as $e,measurementPolylineSymbol as Je,cameraOverlaySymbol3D as Ze,cameraOverlaySymbol as Ke,diamondSymbol as Qe,diamondSymbol3D as Xe,locationSymbol as Ye,locationSymbol3D as et,activeSourcePointSymbol as tt,sourcePointSymbol as at}from"./symbols.js";import{isNoAttachmentError as it,getContentType as rt,isTifOrMrf as st,filterOILLayerView as ot,assignElevationSampleToFeatures as nt,calculateDirection as ct,calculateSegment as lt,isSceneView as ht,isGraphic as ut}from"./utils.js";import{disableVideoZoomAndPan as dt}from"./videoViewerUtils.js";import mt from"./components/ImageViewer.js";import pt from"./components/NavigationNode.js";import gt from"./components/OrientedImageryVideoViewModel.js";import{NoActiveViewerError as yt,NoFeatureFoundWithObjectIdError as vt}from"./navigation/errors.js";import{queryFeatureByObjectIds as wt}from"./navigation/queries.js";import{ImageMeasurementService as ft}from"./services/ImageMeasurementService.js";import Ft from"../Sketch/SketchViewModel.js";const _t={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"},bt=new Set(["JPG","JPEG","TIFF","TIF","MRF"]),Mt=new Set(["MRF","TIFF","TIF"]),It=/\.(\w+)$/,Pt=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let Vt=class extends(c(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=Ve,this.cameraPitchThreshold=Ve,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.depthImage=null,this.directionMode="Relative",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._loadDepthImage(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 mt,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 f,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||this.mode.includes("video")&&!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 mt,this._initialCurrentCoverageUpdate=!0,this._locationPointOnImage=null,this._measurementService=null,this._correctedLocationPointOnImage=null,this._overlays=new U({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"},title:"OrentedImageryViewerViewModel overlays layer"}),this._panoramicVideoViewer=new Ie,this._panoramicViewer=new Pe,this._panoramicMeasurementViewer=new Pe,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._featureToSector=null,this._updatingHandles=new C,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.filterCapturedFeatures=e=>{const t=this.currentBestFeature?.attributes.objectId,a=this.layer?.imageReferenceField;if(!t||!e||!a)return;const i=this.overlayedMapFeatures.get(e);i?.forEach(e=>{const i=e.attributes??{},r=Object.keys(i).find(e=>e.toLowerCase()===a.toLowerCase());(r?i[r]:null)!==t&&(e.visible=!e.visible)})},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.storePanoramicMeasurementViewer=e=>{this._panoramicMeasurementViewer=e},this.loadImageViewer=e=>{this._imageViewer?.destroy(),this._imageViewer=e},this.loadPanoramicViewer=e=>{this._panoramicViewer?.destroy(),this._panoramicViewer=e},this.loadPanoramicVideoViewer=e=>{this._panoramicVideoViewer?.destroy(),this._panoramicVideoViewer=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.imageToImageTransformPanoramic=async(e,t,a)=>{const{updateElevationProps:i,...r}=t,{updateElevationProps:s,...o}=a,n=await te(e,r,i);return ye(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 yt;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,c=new t({geometry:n,attributes:o.toJSON(),layer:r,sourceLayer:r});v(e),await s.openPopup({features:[c],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(_t.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,Me.WIDGET),_t.click)},this._createImageClickHandle=()=>{this.removeHandles(_t.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 c=l(()=>{this.clickAction=n});let h=null;const u=_(()=>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:B(e,t)});v(a),this.plotReferencePointOnGround(r)})});this.addHandles([u,c],_t.imageClick)},this._createTriangularImageClickHandle=()=>{this.removeHandles(_t.triangularImageClick),this.triangularMeasurementActive&&"none"!==this.mode&&this.currentBestFeature&&this.currentBestFeatureMeasurementImage&&this.activeTriangulatedViewer&&this.addHandles(this.activeTriangulatedViewer.imageRenderer.on("double-click",this._measurementImageClickHandler),_t.triangularImageClick)},this._createTriangularImageLocationHandle=()=>{this.removeHandles(_t.triangularImageClick);const{imageLocationToolState:e,mode:t,activeTriangulatedViewer:a}=this,i=a?.imageSize;if(!e||"none"===t||!i)return;this.clickAction="pixel-location";let s=null;const o=_(()=>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 B(r,s),v(a)),await this._calculateTriangulatedPointFromGroundPoint(r,{signal:a}),v(a)}))});this.addHandles(o,_t.triangularImageClick)},this._createImageLocationHandle=()=>{this.removeHandles(_t.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 c=_(()=>a,"pixel-location",e=>{const{currentBestFeatureMeasurementImage:a,triangularMeasurementActive:s,activeTriangulatedViewer:c}=this;this.pixelCoordinates=e;const l=null!=a&&!c?.state.includes("loading");re(!s,l)&&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 B(r,n),v(a)),this.groundCoordinates=r,s&&r&&l&&await this.triangulatedLocationWorkflow(r,a);const c=await this.calculateLocationAccuracy(e,r,t,a);v(a),c&&(this.groundCoordinatesAccuracy=c)})});this.addHandles(c,_t.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._loadDepthImage=async e=>{const{currentBestFeature:t,layer:a,depthImageNotSupported:i}=this;if(this.depthImage?.destroy(),this.depthImage=null,!a||!t||i)return;const{depthImage:r}=t.attributes;if(!r)return;const s=(await import("./services/DepthImageService.js")).default;v(e),this.depthImage=new s({url:r});try{await this.depthImage.load(e)}catch(o){y(o)||(u.getLogger(this).error("error occurred while loading depth image",o),this.depthImage?.destroy(),this.depthImage=null)}},this._loadImage=async e=>{const{currentBestFeature:t,layer:a,mode:i}=this;if(this.clearGraphics(),!a||!t||"none"===i||"video"===i||"panoramic-video"===i)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:c,cameraPitch:l,objectId:h,cameraOrientation:d,location:m}=r,p=(c??0)+(o??0),g=m.spatialReference.isWGS84&&4!==d?.type?z(m):new O(m);let w=s;if(je(s))try{w=await Be(a,h,e)}catch(f){if(y(f))return;return it(f)?(u.getLogger(this).error(f),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${h}`)):(u.getLogger(this).error(f,{[a.objectIdField]:h,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${h}`))}try{await this.loadImageFromSource(w,{imageRotation:p,options:e,pitch:l,yaw:n,mode:i,cameraLocation:g}),v(e),await this.transformAndPlotSelectedLocation(e)}catch(f){y(f)||this.loadImageError(f)}},this._loadVideo=async e=>{const{currentBestFeature:t,layer:a,mode:i,selectedPoint:r}=this,s=t?.attributes.imagePath;if(!a||!t||"panoramic-video"!==i||!s)return;const{attributes:o}=t,{cameraHeading:n,cameraPitch:c,cameraOrientation:l,location:h}=o,u=h.spatialReference.isWGS84&&4!==l?.type?z(h):new O(h);try{this._panoramicVideoViewer.viewModel.video&&this._panoramicVideoViewer.viewModel.video.pause(),this._panoramicVideoViewer.videoSource=s;let t=n??0;u&&r&&(t=await se(u,r)-t),this._panoramicVideoViewer.pitch=c??0,this._panoramicVideoViewer.yaw=t,await this._panoramicVideoViewer.loadVideo(e),v(e)}catch(d){y(d)||this.loadImageError(d)}},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:c}=new URL(o);let l=s?n.match(It)?.[1]:e.datasetFormat;if(!l)try{l=await rt(o,{...t.options})}catch(h){y(h)||u.getLogger(this).error("#getContentType()",h)}switch(l??="UNKNOWN FORMAT",a){case"default":this.triangularMeasurementActive?await this._setImageSource(this.imageMeasurementViewer,l,o,c,i,r):await this._setImageSource(this._imageViewer,l,o,c,i,r);break;case"panoramic":if(bt.has(l.toUpperCase())){const{selectedPoint:e}=this,{pitch:a,yaw:i,cameraLocation:s,viewAngle:n}=t,c=this.triangularMeasurementActive?this._panoramicMeasurementViewer:this._panoramicViewer;let h=i??0;"number"==typeof n?h=n-h:s&&e&&(h=await se(s,e)-h),c.imageSource=o,c.pitch=a??0,c.yaw=h,Mt.has(l.toUpperCase())?await c.loadImageTiled(o,r):await c.loadImage(r)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:l});break}},this._loadMeasurementViewerImage=async e=>{const{currentBestFeatureMeasurementImage:t,layer:a,mode:i}=this;if(this.imageMeasurementViewer.clearGraphics(),this._panoramicMeasurementViewer.clearGraphics(),!a||!t||"none"===i||"video"===i||"panoramic-video"===i)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:c,cameraPitch:l,objectId:h,cameraOrientation:d,location:m}=r,p=(c??0)+(o??0),g=m.spatialReference.isWGS84&&4!==d?.type?z(m):new O(m);let w=s;if(je(s))try{w=await Be(a,h,e)}catch(f){if(y(f))return;return it(f)?(u.getLogger(this).error(f),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${h}`)):(u.getLogger(this).error(f,{[a.objectIdField]:h,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${h}`))}try{await this.loadImageFromSource(w,{imageRotation:p,options:e,pitch:l,yaw:n,mode:i,cameraLocation:g}),v(e)}catch(f){y(f)||this.loadImageError(f)}},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=>{if(e.stopPropagation(),e.preventDefault(),e.mapPoint){const t=e.mapPoint;t.x=D(t.x,t.spatialReference),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 w(a),!e)return;const i=new O({...A(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:Ne}),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 O(n,H.WebMercator),symbol:We}),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([b(()=>this.view,()=>this.load(),M),b(()=>this.view?.map,(e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)},I),b(()=>this.view?.map?.allLayers?.length,e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)},I),b(()=>[this.state,this.mapImageConversionToolState,this.view],()=>{this._createViewClickHandle(),this._createImageClickHandle()},M),b(()=>[this.triangularMeasurementActive,this.currentBestFeatureMeasurementImage],()=>{this._createTriangularImageClickHandle()},M),b(()=>[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),b(()=>this.measureType,()=>{this.clearPreviousMeasurements(),this._initializeMeasurementService()},M),b(()=>this.bestFeatureAngle,(e,t)=>{this.previousFeatureAngle=t??0},M),b(()=>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}),b(()=>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),b(()=>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._panoramicMeasurementViewer.clearImage(),this._panoramicMeasurementViewer.clearGraphics())}),b(()=>this.mode,e=>{switch(this.removeHandles(_t.interactionHandles),e){case"default":this.addHandles(b(()=>{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)}),_t.interactionHandles);break;case"video":this.addHandles(b(()=>{const{footprintExtent:e}=this;if(e)return Se},e=>{e&&(m(this._updateFootprintTask),this._updateFootprintTask=r(async t=>{await this.updateFootprint(e,{signal:t})}))},{...M,equals:(e,t)=>a(e,t,h)}),_t.interactionHandles);break;case"panoramic":this.addHandles(b(()=>{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)}),_t.interactionHandles);break;case"panoramic-video":this.addHandles(b(()=>{const{currentBestFeature:e,state:t,_panoramicVideoViewer:a}=this,{imageSize:i,vfov:r,hfov:s,pitch:o,yaw:n,viewModel:c}=a,l=c.closestFeature??e;return l&&i&&!t.includes("loading")&&null!=r&&null!=s&&null!=o&&null!=n?[r,s,n,o,l]:null},e=>{if(!e)return;const[t,a,i,s,o]=e;m(this._updateFootprintTask),this._updateFootprintTask=r(async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:a,yaw:i,pitch:s,feature:o},{signal:e}),v(e),this._updateFootprintTask=null})},{equals:(e,t)=>a(e,t,h)}),_t.interactionHandles)}},M),b(()=>[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),b(()=>this.activeViewer?.imageRenderer,()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)}),b(()=>this.activeViewer,e=>{this.removeHandles(_t.hittestHandles),e&&this.addHandles(_(()=>e,"hittest-response",this._handleImageHitTestResponse),_t.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(),this._panoramicMeasurementViewer.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 activeTriangulatedViewer(){switch(this.mode){case"default":return this.imageMeasurementViewer;case"panoramic":return this._panoramicMeasurementViewer;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 depthImageNotSupported(){if(this.currentBestFeature?.attributes.depthImage)return!st(this.currentBestFeature.attributes.depthImage)}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){const{currentBestFeature:e}=this;if(!e)return!1;const t=e.attributes.imagePath?.trim();return st(t)||je(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(ot(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?we(e):null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";const t=e.orientedImageryType;if(t?.includes("video"))return t.includes("360")?"panoramic-video":"video";const{horizontalFieldOfView:a,isSpherical:i}=e;return 360===a||i?"panoramic":"default"}get panoramicVideoLoaded(){const{mode:e,_panoramicVideoViewer:t}=this,{videoLoaded:a}=t.viewModel;return("panoramic-video"===e&&!0===a)??!1}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",d(e,0,1))}get sketchGraphicsLayer(){const{sketch:e}=this;return"graphics"===e?.layer?.type?e.layer:void 0}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 st(r)||je(r)?{url:r,objectId:t,rotation:(a??0)+(i??0)}:null}).filter(i)):null}set view(e){this._set("view",e)}get _defaultGraphicsLayer(){const e={blendMode:"source-atop"};switch(this.mode){case"panoramic":return new U({...e,elevationInfo:{mode:"absolute-height"}});case"default":return new U({...e});default:return}}get _overlaysView(){return this.view?.layerViews.find(({layer:e})=>e===this._overlays)}beforeLoad(e=!0){this.view?.closePopup(),e&&(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){await(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 Pt();Ge(i,e,a),await a.create(e,{...t,defaultZ:0})}digitizeDelete(){if(!this.sketch)throw Pt();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw Pt();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw Pt();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw Pt();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw Pt();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw Pt();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 c;const{polygon:l,frustum:h}=J(n);if(c=l.clone(),n.isInspection&&(c=Z(n)),o&&(c=K(c,o)),a||!t||Q(c,t)){s.push(e);const{geometry:t,objectId:a,cameraHeight:o,cameraHeading:c}=n,u=t.clone();u.z=o,u.imageID=a,this.pointSources.push(u),c!==ke&&(i.push(l),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=ce(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?B(n,H.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&&he(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t}))}getMeasurementPropertiesPanoramic(e=this.currentBestFeature,t=this.activeViewer){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?B(n,H.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&&he(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t}))}async deleteDataCaptureFeatures(e){const{dataCaptureLayer:t}=this;if(!t)throw new n("orientedimageryviewer:missing-featurelayer","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 c=He(e.vertices.at(-1),r,n);if(i.length<1||!c||!a||!t||"none"===r)return;const l=xe(i[0],c,t);if(!l?.length)return;this.heightMeasurementPixels.push(l),"panoramic"===r?this.createPolylineGraphicPano():this.createPolylineGraphic();const h=Ee(o.attributes.location.spatialReference),u=De(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=He(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._defaultGraphicsLayer,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),nt(r,n);const c=this._processSuitableFeatures(r,t);this.updateSuitabilities(c,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=qe(o),this.sketch.polylineSymbol="panoramic"===s?$e:Je(o,2.5))}startHeightMeasurement(){this.heightMeasurementPixels=[],this.displayNewMeasurementButton=!1,this.draw??=new _e({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:Je(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:c}=oe(r,a[0],a[1]),l=[[...ne(s,o)],[...ne(n,c)]];if(this.heightGraphic)this.heightGraphic.geometry=new j({paths:[l],spatialReference:e});else{const a=new j({paths:[l],spatialReference:e});this.heightGraphic=new t({geometry:a,symbol:$e}),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 c=0;c<s.length;c++){const e={x:s[c][0],y:s[c][1]};let a=await this.getMapPoint(e,{feature:t,imageSize:r,mode:i});o&&!a.spatialReference.equals(o)&&(a=await B(a,o)),n.push(a)}return ze(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:c}=this,l=a?.imageSize;if(!l||!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:P(`${s.objectIdField} <> ${i.attributes.objectId}`,P(s.definitionExpression,c)),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:l,mode:o}),n="panoramic"===o?Ze():Ke();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:c,layer:l}=this,h=r?.imageSize;if(!h||!o||"none"===n||"video"===n||"panoramic-video"===n||c.includes("loading")||!l)return;const{polygon:d}=J(o.attributes);try{const{imageGeometryField:t,oiObjectIdField:a}=Te(e,l.imageGeometryField,l.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:c}=i,l=c,{imageGeometryField:d,oiObjectIdField:m}=this;if(d&&m&&Oe(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(l?.type){case"point":{const i=await this.getPixels(l,{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:c}=l,u=i.map(e=>e.map(([e,t,a])=>new O({x:e,y:t,z:a,spatialReference:c}))),d=await Promise.all(u.map(async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then(e=>e.map(de))));return new t({attributes:s,layer:e,symbol:r,geometry:new R({rings:d,spatialReference:H.WebMercator}),visible:e.visible&&a})}case"polyline":{const{paths:i,spatialReference:c}=l,u=i.map(e=>e.map(([e,t,a])=>new O({x:e,y:t,z:a,spatialReference:c}))),d=await Promise.all(u.map(async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then(e=>e.map(de))));return new t({attributes:s,layer:e,symbol:r,geometry:new j({paths:d,spatialReference:H.WebMercator}),visible:e.visible&&a})}case"multipoint":{const{points:i,spatialReference:c}=l,u=i.map(([e,t,a])=>new O({x:e,y:t,z:a,spatialReference:c})),d=await this.getPixels(u,{feature:o,imageSize:h,mode:n}).then(e=>e.map(de));return new t({attributes:s,layer:e,symbol:r,geometry:new T({points:d,spatialReference:H.WebMercator}),visible:e.visible&&a})}}return null}))).filter(i));this.overlayGraphicsOnImage(`${e.id}`,p)}getDepthAt(e){const{activeViewer:t,currentBestFeature:a,mode:i,state:r,depthImage:s}=this,o=t?.imageSize;if(!o||!a||"none"===i||r.includes("loading"))return u.getLogger(this).warnOnce("oriented-imagery-viewer:get-depth-at","Load an image to use depth"),null;if(!s?.loaded)return u.getLogger(this).error("oriented-imagery-viewer:get-depth-at","Depth image is not loaded"),this.emit("depth-image-service:not-loaded"),null;const n=(Array.isArray(e)?e:[e]).map(e=>s.depthAt(e,{width:o[0],height:o[1]})??null);return Array.isArray(e)?n:n[0]}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:H.WebMercator});const[t,r]=a,{heading:s,pitch:o}=oe(e,t,r),n=ne(s,o);return new O(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:c,cameraHeight:l}=o;let h=c.clone();h.spatialReference.isGeographic&&(h=await B(h,H.WebMercator));const u=await le(c.spatialReference,c.z??0,l,{elevationSample:s,elevationSource:n,extent:this.footprintExtent});let d;"elevationSample"in u&&he(u.elevationSample)&&(a.elevationSample=u.elevationSample);const m=Array.isArray(e)?e:[e];if(this.depthImage?.loaded)for(const p of m){const e=this.getDepthAt(p);null!=e&&(p.depth=e)}if("default"===i){const e=ce(o,r[0],r[1]);d=await ee(m,{...e,cameraLocation:h},u)}else{const e=ue(o,r[0],r[1]);d=await te(m,{...e,cameraLocation:h},u)}return Array.isArray(e)?d:d[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 O({...e.toJSON()}),symbol:Qe}),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=A(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:Qe}),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 O(n,H.WebMercator),symbol:Xe}),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,t)}}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))}reset(){const{mode:e}=this;"default"===e||"panoramic"===e?this.resetImage():"video"===e?this.resetVideo():"panoramic-video"===e&&this.resetVideoPanoramic(),this.beforeLoad(!1)}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}resetVideoPanoramic(){this.setMessage("onLoadMessage","info"),this._overlays?.removeAll(),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:c}=n;return r?t.error.push(n):(a&&(c[e.objectIdField]=a),i&&e.globalIdField&&(c[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||"panoramic-video"===s)throw new n("orientedimageryviewer:missing-input","Image size, current best feature and mode are required to save data capture features");if(!r)throw new n("orientedimageryviewer:missing-featurelayer","Data capture layer is not available");const c=await Promise.all(e.map(async e=>{const t=e.clone(),{geometry:i}=t;if(!i)return;const n=i.type,c=r.hasZ,l=r.geometryType,h=n!==l,u=h?await import("./transformers.js"):null,d=u?.default[l],m=h?d?.(i):i;if(m)switch(m.type){case"point":return t.geometry=await this.getMapPoint(me(s,m,o),{feature:a,imageSize:o,mode:s}),c||(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])=>me(s,{x:e,y:t,z:a},o)),{feature:a,imageSize:o,mode:s})));return t.geometry=new R({spatialReference:e[0][0].spatialReference,hasZ:c,hasM:!1,rings:e.map(e=>e.map(de))}),t}case"polyline":{const e=await Promise.all(m.paths.map(async e=>this.getMapPoint(e.map(([e,t,a])=>me(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:c,hasM:!1,paths:e.map(e=>e.map(de))}),t}}})),l=c.filter(i);return r.applyEdits({addFeatures:l}).then(e=>{const{addFeatureResults:t}=e;let a=0;const i=c.map(e=>{const i=t[a++];return e?i:{error:new n("orientedimageryviewer:save-unsucccessful","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()??[],c=[],l=[];for(const s of n)`${s.getAttribute(i)}`==`${o}`?c.push(s):l.push(s);this.overlayGraphicsOnImage(e.id,new s(l)),this.collectionId=e.id;const h=await this.loadSketch(t),u=await this.loadDataCaptureAdapter(t);v(t),h.addGraphics(c),u.savedGraphics.addMany(c);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 B(a,o.spatialReference);r=o.contains(e);break}case"mesh":{const e=a.spatialReference.equals(o.spatialReference)?a:await B(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=ze(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=ze(e,a);i&&this.measurementVectors.push(i);const r=await Ue(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 c=n.map(({distance:e})=>e),l=Math.max(...c);n.forEach(e=>{const{distance:t,angle:i,featureIndex:s}=e,n=t/l*Le[2],c=lt(t,l),h=ct(i);if(!this._sectorData)return;const u=Le[3]+n*Math.sin(i*Math.PI/180),d=Le[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-Le[3],t=d-Le[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 w=""===c?h:`${c}_${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}`]=w;const f=this._sectorData[w];f.add({angle:i,featureIndex:s,x:u,y:d,objectID:p.attributes.objectId,sector:w,featureIndexInSector:f.length})})}_handleDestroyedTriangularSketchLayer(){this.sketchTriangularGraphicsLayer&&this.activeTriangulatedViewer&&(this.activeTriangulatedViewer.imageRenderer.map.layers.remove(this.sketchTriangularGraphicsLayer),this.sketchTriangularGraphicsLayer=new U,this.activeTriangulatedViewer.imageRenderer.map.layers.add(this.sketchTriangularGraphicsLayer),this.sketchTriangular&&(this.sketchTriangular.layer=this.sketchTriangularGraphicsLayer,this.sketchTriangular.view=this.activeTriangulatedViewer.imageRenderer))}_initializeMeasurementService(){this._measurementService||(this._measurementService=new ft(this))}_initializeSketchTriangular(){if(!this.activeTriangulatedViewer)return;const e="panoramic"===this.mode;this.sketchTriangular=new Ft({view:this.activeTriangulatedViewer.imageRenderer,layer:this.sketchTriangularGraphicsLayer,updateOnGraphicClick:!1,defaultUpdateOptions:{toggleToolOnClick:!1,enableZ:!e}}),e&&(this.sketchTriangular.defaultUpdateOptions.reshapeOptions={edgeOperation:"offset",shapeOperation:"move-xy",vertexOperation:"move-xy"})}_initializeSketchTriangularGraphicsLayer(){this.activeTriangulatedViewer&&(this.sketchTriangularGraphicsLayer=new U,this.activeTriangulatedViewer.imageRenderer.map.layers.add(this.sketchTriangularGraphicsLayer))}_initializeVideo(){if(this.videoElement||!this.currentBestFeature)return;this.removeHandles(_t.videoPlayerHandles),this.videoElement=new fe({video:this.currentBestFeature.attributes.imagePath,georeference:new ve({extent:new L(Ce)}),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(dt(this.videoMapView),_t.videoPlayerHandles),this.videoViewModel=new gt({oiViewModel:this})}_plotLocationPointOnDefaultImage(e,a=!1){const i=A(e)?e.toJSON():e;i.x-=.5,i.y=.5-i.y,a?(this._correctedLocationPointOnImage=new t({geometry:new O({spatialReference:H.WebMercator,...i}),symbol:Ye}),this.imageMeasurementViewer.addGraphic(this._correctedLocationPointOnImage,0)):(this._locationPointOnImage=new t({geometry:new O({spatialReference:H.WebMercator,...i}),symbol:Ye}),this._imageViewer.addGraphic(this._locationPointOnImage,0))}_plotLocationPointOnPanoramicImage(e,a=!1){const i=a?this._panoramicMeasurementViewer:this._panoramicViewer,{imageSize:r}=i;if(!r)return;const[s,o]=r,{heading:n,pitch:c}=oe(e,s,o),l=ne(n,c),h=new t({geometry:new O(l,H.WebMercator),symbol:et});a?this._correctedLocationPointOnImage=h:this._locationPointOnImage=h,i.addGraphic(h,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 G(e);if(this._updateFootprintWithFeatures(t,i),"3d"===this.view?.type)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:ht(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=D(o.x,o.spatialReference);const{layerFloorFilterClause:n}=this,c=e.spatialReference.equals(o.spatialReference)?o:await B(o,e.spatialReference),l=c.spatialReference.isGeographic?z(c):c,h=P("1=1",P(e.definitionExpression,n)),u=l.spatialReference.isGeographic?1:V(l.spatialReference),d={layerInstanceOrURL:e,point:l,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 wt(e,t,a,i);if(v(i),!r?.features?.length)throw new vt(t);const s=J(r.features[0].attributes).polygon,o=O.fromJSON(x(s)),n=Y(o),c=V(n.spatialReference);this.selectedPoint=n;const l={layerInstanceOrURL:e,point:n,queryParams:{where:P(P("1=1",P(e.definitionExpression,a)),`${e.objectIdField} <> ${t}`),maximumDistance:e.maximumDistance?e.maximumDistance/c:void 0}},h=await W(l,i);v(i);const{features:u}=h;return u.push(r.features[0]),await this.processFeatureResponse(h,n,{...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(_t.activeViewerCursorHandles),t&&this.removeHandles(_t.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"),_t.activeViewerCursorHandles),t&&a&&this.addHandles(t.imageRenderer.acquireCursor("crosshair","high"),_t.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 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[c,...l]=await ae([t,...e.map(e=>e.attributes.geometry.clone())],n);v(i),t.elevation=c.z,e.forEach((e,t)=>{e.attributes.elevation=l[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 pt({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])),"panoramic-video"===this.mode&&this._loadVideo()}_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=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:tt,visible:r}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:at,visible:s}));if(("video"===o||"panoramic-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));if("panoramic-video"===this.mode)return void(this.currentBestFeature&&this._panoramicVideoViewer.viewModel.playPanoramicVideoFromSelectedLocation(this.currentBestFeature));const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let a;if(t)a=-90;else{const t=e.x-Le[3],i=e.y-Le[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(),this._panoramicMeasurementViewer.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._panoramicMeasurementViewer.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:c},elevationSample:l}=t;let h=s.clone();const u=await le(s.spatialReference,s.z??0,c,{elevationSample:l,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(ae(e,u));t(e)})));if(s.spatialReference.isGeographic&&(h=await B(h,H.WebMercator,a)),p=await Promise.all(p.map(async e=>h.spatialReference.equals(e.spatialReference)?e:await B(e,h.spatialReference,a))),v(a),"panoramic"===this.mode)m=ye(p,{imageHeight:r[1],imageWidth:r[0],cameraHeading:n,cameraLocation:h});else{const e=pe(t.attributes,r[0],r[1]);m=ge(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:c,_adapter:l,mode:h}=this;if(!r)return;const{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),c){const e=[...a,...i,s].filter(ut);"3d"===c?.type&&d&&l?.updateGroundElevation&&(this._updateGroundElevation&&l.updateGroundElevation(e,d),"panoramic"===h&&l.updateGroundElevation([this.bestFeatureCurrentFootprint],d)),this._updateGroundElevation=!1,n&&(e.splice(-2,0,this.bestFeatureCurrentFootprint),e.push(new t({geometry:n.clone(),symbol:Ne.clone(),attributes:{imageID:u}}))),this._overlays.graphics.addMany(e)}}else if(c){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,"3d"===c?.type&&d&&l?.updateGroundElevation&&"panoramic"===h&&l.updateGroundElevation([e],d),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([S()],Vt.prototype,"activeLayer",null),e([S({readOnly:!0})],Vt.prototype,"activeViewer",null),e([S()],Vt.prototype,"activeTriangulatedViewer",null),e([S()],Vt.prototype,"accuracyParametersMissing",null),e([S()],Vt.prototype,"additionalFeatures",void 0),e([S({type:s.ofType(t)})],Vt.prototype,"additionalCameraLocations",void 0),e([S({type:s.ofType(t)})],Vt.prototype,"additionalFootprints",void 0),e([S()],Vt.prototype,"areaMeasurementResult",void 0),e([S()],Vt.prototype,"areaMeasurementAccuracy",void 0),e([S()],Vt.prototype,"bestFeatureAngle",void 0),e([S()],Vt.prototype,"bestFeatureCurrentFootprint",void 0),e([S({type:t})],Vt.prototype,"bestFeatureFootprint",void 0),e([S({type:Number})],Vt.prototype,"brightness",null),e([S()],Vt.prototype,"cameraHeadingThreshold",void 0),e([S()],Vt.prototype,"cameraPitchThreshold",void 0),e([S()],Vt.prototype,"clickAction",void 0),e([S()],Vt.prototype,"videoViewModel",void 0),e([S()],Vt.prototype,"collectionId",void 0),e([S({type:Number})],Vt.prototype,"contrast",null),e([S()],Vt.prototype,"conversionProps",void 0),e([S()],Vt.prototype,"coverageFrustums",void 0),e([S()],Vt.prototype,"coveragePolygons",void 0),e([S()],Vt.prototype,"currentBestFeature",void 0),e([S()],Vt.prototype,"currentBestFeatureMeasurementImage",void 0),e([S()],Vt.prototype,"currentBestFeatureLocation",void 0),e([S()],Vt.prototype,"currentCoverageVisible",void 0),e([S()],Vt.prototype,"currentNode",null),e([S()],Vt.prototype,"depthImage",void 0),e([S()],Vt.prototype,"depthImageNotSupported",null),e([S()],Vt.prototype,"directionMode",void 0),e([S()],Vt.prototype,"featureCache",void 0),e([S()],Vt.prototype,"navigationNodes",void 0),e([S({json:{write:!1}})],Vt.prototype,"determineWorkflowForFeature",void 0),e([S({json:{write:!1}})],Vt.prototype,"determineWorkflowForTriangularMeasurement",void 0),e([S()],Vt.prototype,"disabled",void 0),e([S()],Vt.prototype,"displayMessage",void 0),e([S()],Vt.prototype,"displayNewMeasurementButton",void 0),e([S()],Vt.prototype,"distanceMeasurementResult",void 0),e([S()],Vt.prototype,"distanceAccuracyArray",void 0),e([S()],Vt.prototype,"dataCaptureLayer",void 0),e([S({readOnly:!0})],Vt.prototype,"featureCount",null),e([S()],Vt.prototype,"features",void 0),e([S()],Vt.prototype,"groundCoordinates",void 0),e([S()],Vt.prototype,"groundCoordinatesAccuracy",void 0),e([S()],Vt.prototype,"heightMeasurementPixels",void 0),e([S()],Vt.prototype,"heightGraphic",void 0),e([S()],Vt.prototype,"heightMeasurementResult",void 0),e([S()],Vt.prototype,"heightMeasurementAccuracy",void 0),e([S()],Vt.prototype,"measurementAngle",void 0),e([S()],Vt.prototype,"tempDistance",void 0),e([S({readOnly:!0})],Vt.prototype,"imageGalleryEnabled",null),e([S()],Vt.prototype,"imageGeometryField",void 0),e([S({readOnly:!0})],Vt.prototype,"imageLoaded",null),e([S()],Vt.prototype,"imageLocationToolState",void 0),e([S({readOnly:!0})],Vt.prototype,"invalidCameraHeading",null),e([S()],Vt.prototype,"imagePointsInView",null),e([S()],Vt.prototype,"imageMeasurementViewer",void 0),e([S()],Vt.prototype,"isAdditionalCoverageVisible",void 0),e([S()],Vt.prototype,"isAdditionalPointSourcesVisible",void 0),e([S()],Vt.prototype,"measurementVectors",void 0),e([S()],Vt.prototype,"layer",void 0),e([S()],Vt.prototype,"layerView",null),e([S({readOnly:!0})],Vt.prototype,"layerFloorFilterClause",null),e([S({type:Number})],Vt.prototype,"localPort",void 0),e([S()],Vt.prototype,"mapImageConversionToolState",void 0),e([S()],Vt.prototype,"measureType",void 0),e([S()],Vt.prototype,"measurementGraphic",void 0),e([S({readOnly:!0,value:"none"})],Vt.prototype,"mode",null),e([S()],Vt.prototype,"navigationMode",void 0),e([S()],Vt.prototype,"navigatorCurrentBestFeature",void 0),e([S()],Vt.prototype,"oiObjectIdField",void 0),e([S({type:s.ofType(t)})],Vt.prototype,"overlayedCameraLocations",void 0),e([S()],Vt.prototype,"overlayedMapFeatures",void 0),e([S()],Vt.prototype,"panoramicVideoLoaded",null),e([S()],Vt.prototype,"pixelCoordinates",void 0),e([S()],Vt.prototype,"preserveAngle",void 0),e([S()],Vt.prototype,"pointSources",void 0),e([S({readOnly:!0})],Vt.prototype,"popupEnabled",null),e([S()],Vt.prototype,"previousFeatureAngle",void 0),e([S()],Vt.prototype,"referencePoint",null),e([S({readOnly:!0})],Vt.prototype,"sectorData",null),e([S()],Vt.prototype,"selectedPoint",void 0),e([S({type:Number})],Vt.prototype,"sharpness",null),e([S()],Vt.prototype,"shouldShowSelectedImage",void 0),e([S()],Vt.prototype,"sketch",void 0),e([S()],Vt.prototype,"sketchTriangular",void 0),e([S()],Vt.prototype,"sketchTriangularGraphicsLayer",void 0),e([S()],Vt.prototype,"draw",void 0),e([S()],Vt.prototype,"sketchAdapter",void 0),e([S({readOnly:!0})],Vt.prototype,"sketchGraphicsLayer",null),e([S({readOnly:!0})],Vt.prototype,"state",null),e([S({readOnly:!0})],Vt.prototype,"thumbnails",null),e([S()],Vt.prototype,"triangularMeasurementActive",void 0),e([S()],Vt.prototype,"triangulatedDistanceMeasurement",void 0),e([S()],Vt.prototype,"triangulatedDistanceAccuracy",void 0),e([S()],Vt.prototype,"triangulatedAreaMeasurement",void 0),e([S()],Vt.prototype,"triangulatedAreaAccuracy",void 0),e([S()],Vt.prototype,"triangulatedMeasurementGraphic",void 0),e([S()],Vt.prototype,"triangulatedPoint",void 0),e([S()],Vt.prototype,"triangulatedMeasurementAdapter",void 0),e([S()],Vt.prototype,"updateFootprint",void 0),e([S()],Vt.prototype,"updateFootprintPanorama",void 0),e([S()],Vt.prototype,"updatingTriangularMeasurementState",void 0),e([S({value:null})],Vt.prototype,"view",null),e([S()],Vt.prototype,"videoElement",void 0),e([S()],Vt.prototype,"videoLayer",void 0),e([S()],Vt.prototype,"videoMapView",void 0),e([S()],Vt.prototype,"_adapter",void 0),e([S()],Vt.prototype,"_defaultGraphicsLayer",null),e([S()],Vt.prototype,"_highlightedFeatureHandle",void 0),e([S()],Vt.prototype,"_imageViewer",void 0),e([S()],Vt.prototype,"_initialCurrentCoverageUpdate",void 0),e([S()],Vt.prototype,"_locationPointOnImage",void 0),e([S()],Vt.prototype,"_measurementService",void 0),e([S()],Vt.prototype,"_correctedLocationPointOnImage",void 0),e([S()],Vt.prototype,"_overlays",void 0),e([S({readOnly:!0})],Vt.prototype,"_overlaysView",null),e([S()],Vt.prototype,"_panoramicVideoViewer",void 0),e([S()],Vt.prototype,"_panoramicViewer",void 0),e([S()],Vt.prototype,"_panoramicMeasurementViewer",void 0),e([S()],Vt.prototype,"_referencePointOnGround",void 0),e([S()],Vt.prototype,"_referencePointOnImage",void 0),e([S()],Vt.prototype,"_sectorData",void 0),e([S()],Vt.prototype,"_featureToSector",void 0),e([S({readOnly:!0})],Vt.prototype,"_updatingHandles",void 0),e([S()],Vt.prototype,"footprintExtent",void 0),e([S()],Vt.prototype,"_featureChangedTask",void 0),Vt=e([k("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],Vt);const St=Vt;export{St 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{EsriPromise as t}from"../../../../core/Promise.js";import{property as a}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as r}from"../../../../core/accessorSupport/decorators/subclass.js";import{projectWithZConversion as s}from"../../../../geometry/projectionUtils.js";import{computeTriangulatedVector as i,computeTriangulatedAreaMeasurement as o,computeTriangulatedDistanceMeasurement as n}from"../../imageMeasurementUtils.js";import{TriangulatedSketchHandlerMixin as c}from"../../mixins/TriangulatedSketchHandlerMixin.js";let m=[],u=class extends(c(t)){constructor(e){super(e),this.type="measurement"}async handleUpdate(e){const{measureType:t,updatingTriangularMeasurementState:a}=this.viewModel;if(this._freezeTriangulatedViewer(),"distance"===t){const t=e.graphics[0].geometry;m=t.paths[0]}else if("area"===t){const t=e.graphics[0].geometry;m=t.rings[0]}"complete"===e.state&&(this.viewModel.triangulatedMeasurementGraphic=e.graphics.at(-1),a?await this._updateTriangularMeasurements(m):await this.viewModel.processMeasurementVectors(m))}async _computeMeasurementVector(e,t){const{activeViewer:a,mode:r,view:o}=this.viewModel,n=a?.imageSize;if(!e||!t||!n)return;const c=e.map(e=>[e[0]-.5,-.5-e[1]]),m=o?.spatialReference,u=[];for(let i=0;i<c.length;i++){const e={x:c[i][0],y:c[i][1]};let a=await this.viewModel.getMapPoint(e,{feature:t,imageSize:n,mode:r});m&&!a.spatialReference.equals(m)&&(a=await s(a,m)),u.push(a)}return i(u,t)}async _updateTriangularMeasurements(e){const{measureType:t,triangularMeasurementActive:a,currentBestFeatureMeasurementImage:r,updatingTriangularMeasurementState:s}=this.viewModel;if(!a||!r||!s||2!==this.viewModel.measurementVectors?.length)return;this.viewModel.measurementVectors.splice(-1);const i=await this._computeMeasurementVector(e,r);if(i&&this.viewModel.measurementVectors.push(i),2===this.viewModel.measurementVectors.length){switch(t){case"distance":{this.viewModel.triangulatedDistanceMeasurement=await n(this.viewModel.measurementVectors);const t=await this.viewModel.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(r?.geometry.spatialReference){const e=await o(this.viewModel.measurementVectors,r.geometry.spatialReference);this.viewModel.triangulatedAreaMeasurement=e}}this.viewModel.updatingTriangularMeasurementState=!1}}_freezeTriangulatedViewer(){const{mode:e,activeTriangulatedViewer:t}=this.viewModel;"panoramic"===e&&t&&t.imageRenderer.on(["key-down","mouse-wheel","drag"],e=>{e.stopPropagation()})}};e([a()],u.prototype,"type",void 0),u=e([r("esri.widgets.OrientedImageryViewer.adapters.sketch.TriangulatedMeasurementAdapter")],u);const l=u;export{l as default};
5
+ import{__decorate as e}from"tslib";import{EsriPromise as t}from"../../../../core/Promise.js";import{throwIfAborted as a}from"../../../../core/promiseUtils.js";import{property as r}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as i}from"../../../../core/accessorSupport/decorators/subclass.js";import{projectWithZConversion as s}from"../../../../geometry/projectionUtils.js";import{convertSphereVertexToPixelLocation as o}from"../../../../layers/orientedImagery/transformations/utils.js";import{computeTriangulatedVector as c,computeTriangulatedAreaMeasurement as n,computeTriangulatedDistanceMeasurement as u}from"../../imageMeasurementUtils.js";import{TriangulatedSketchHandlerMixin as l}from"../../mixins/TriangulatedSketchHandlerMixin.js";let m=[],d=class extends(l(t)){constructor(e){super(e),this.type="measurement"}async handleUpdate(e){const{measureType:t,updatingTriangularMeasurementState:a}=this.viewModel;if(this._preventLeftMouseDrag(),"distance"===t){const t=e.graphics[0].geometry;m=t.paths[0]}else if("area"===t){const t=e.graphics[0].geometry;m=t.rings[0]}"complete"===e.state&&(this.viewModel.triangulatedMeasurementGraphic=e.graphics.at(-1),a?await this._updateTriangularMeasurements(m):await this.viewModel.processMeasurementVectors(m))}async _computeMeasurementVector(e,t){const{activeViewer:a,mode:r,view:i}=this.viewModel,o=a?.imageSize;if(!e||!t||!o)return;const n=e.map(e=>[e[0]-.5,-.5-e[1]]),u=i?.spatialReference,l=[];for(let c=0;c<n.length;c++){const e={x:n[c][0],y:n[c][1]};let a=await this.viewModel.getMapPoint(e,{feature:t,imageSize:o,mode:r});u&&!a.spatialReference.equals(u)&&(a=await s(a,u)),l.push(a)}return c(l,t)}async _updateTriangularMeasurements(e,t){const{measureType:r,mode:i,activeTriangulatedViewer:s,triangularMeasurementActive:c,currentBestFeatureMeasurementImage:l,updatingTriangularMeasurementState:m}=this.viewModel;if(!(c&&l&&m&&s?.imageSize&&2===this.viewModel.measurementVectors?.length))return;const[d,p]=s.imageSize;this.viewModel.measurementVectors.splice(-1);const g=await this._computeMeasurementVector(e,l);if(a(t),g&&this.viewModel.measurementVectors.push(g),2===this.viewModel.measurementVectors.length){switch(r){case"distance":{this.viewModel.triangulatedDistanceMeasurement=await u(this.viewModel.measurementVectors),a(t);const r=e.map(([e,t,a])=>{const{x:r,y:i}=o({x:e,y:t,z:a},d,p);return[r,i]}),s="default"===i?await this.viewModel.calculateAccuracy(e,"distance"):await this.viewModel.calculateAccuracyPanoramic(r,"distance");if(a(t),s&&this.viewModel.triangulatedDistanceMeasurement?.distance){const e=Math.atan(s/this.viewModel.triangulatedDistanceMeasurement.distance);this.viewModel.triangulatedDistanceAccuracy={distanceAccuracy:s,angleAccuracy:e}}break}case"area":if(l?.geometry.spatialReference){const r=await n(this.viewModel.measurementVectors,l.geometry.spatialReference);if(a(t),this.viewModel.triangulatedAreaMeasurement=r,"default"===i)this.viewModel.triangulatedAreaAccuracy=await this.viewModel.calculateAccuracy(e,"area")??this.viewModel.triangulatedAreaAccuracy,a(t);else if("panoramic"===i){const r=e.map(([e,t,a])=>{const{x:r,y:i}=o({x:e,y:t,z:a},d,p);return[r,i]});this.viewModel.triangulatedAreaAccuracy=await this.viewModel.calculateAccuracyPanoramic(r,"area")??this.viewModel.triangulatedAreaAccuracy,a(t)}}}if(this.viewModel.updatingTriangularMeasurementState=!1,"panoramic"===this.viewModel.mode){this.viewModel.activeTriangulatedViewer.viewModel.restoreNavigationHandles()}}}_preventLeftMouseDrag(){const{mode:e,activeTriangulatedViewer:t}=this.viewModel;if("panoramic"!==e||!t)return;let a=null;t.imageRenderer.on("pointer-down",e=>{a=e.button}),t.imageRenderer.on("drag",e=>{0===a&&e.stopPropagation()})}};e([r()],d.prototype,"type",void 0),d=e([i("esri.widgets.OrientedImageryViewer.adapters.sketch.TriangulatedMeasurementAdapter")],d);const p=d;export{p 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Graphic.js";import{isSome as t}from"../../../../core/arrayUtils.js";import{throwIfAborted as i,waitTick as r}from"../../../../core/promiseUtils.js";import o from"../../../../geometry/Mesh.js";import a from"../../../../geometry/Point.js";import{projectWithZConversion as s}from"../../../../geometry/projectionUtils.js";import{MeshVertexAttributes as n}from"../../../../geometry/support/MeshVertexAttributes.js";import{projectVertices as l,updateFrustum as c,createCoveragePolygon as m}from"../../../../layers/orientedImagery/core/coverageUtils.js";import{activeFrustumSymbol as u,additionalFrustumSymbol as p}from"../../symbols.js";class d{constructor(a){this.viewModel=a,this._updateBestFeatureFootprintElevation=!1,this.createFootprints=async r=>{const{coverageFrustums:a,currentBestFeature:c,isAdditionalCoverageVisible:m,view:d}=this.viewModel,f=a.filter(t);for(const t of f){let a=t.clone();if(!d.spatialReference.equals(a.spatialReference)){const{components:e,spatialReference:t,origin:c,vertexAttributes:m,vertexSpace:u}=a;if("local"===u.type){const e=await s(c,d.spatialReference,r);i(r),a.centerAt(e)}else{const s=m.position,c=Float64Array.from(await l([...s],t.clone(),d.spatialReference.clone(),r));i(r),a=new o({vertexAttributes:new n({position:c}),components:e,spatialReference:d.spatialReference.clone()})}}t.imageID===c.attributes.objectId?(this.viewModel.bestFeatureFootprint=new e({attributes:{imageID:t.imageID},geometry:a,symbol:u.clone(),visible:!1}),this._updateBestFeatureFootprintElevation=!0):this.viewModel.additionalFootprints.push(new e({attributes:{imageID:t.imageID},geometry:a,symbol:p.clone(),visible:m}))}},this.updateFootprint=async(r,o)=>{const{bestFeatureFootprint:a,currentBestFeature:n,activeViewer:l,footprintExtent:m,view:p}=this.viewModel,d=l?.imageSize;if(!(n&&a?.geometry&&d&&m))return void this.viewModel.updateCurrentCoveragePolygon(null);const{attributes:{cameraHeight:w,location:v,cameraPitch:g,horizontalFieldOfView:h,verticalFieldOfView:y,cameraRoll:b},elevationSample:F}=n;F&&this._updateBestFeatureFootprintElevation&&(this.updateGroundElevation([a],F),this._updateBestFeatureFootprintElevation=!1);const M=v.toArray(),{vertexAttributes:{position:R},spatialReference:V}=a.geometry,j=await f(R,V,v.spatialReference),A=await this.viewModel.getMapPoint(r,{feature:n,mode:"default",imageSize:d});i(o);let I=A.filter(t);if(!I.length)return;I[0].spatialReference.equals(v.spatialReference)||(I=await Promise.all(I.map(async e=>{const t=await s(e,v.spatialReference,o);return i(o),t})));const P=await c(r.map(({x:e,y:t})=>[e,t]),I.map(e=>e.toArray()),{cameraHeight:w,cameraLocation:M,cameraPitch:g,frustumVertices:j,horizontalFieldOfView:h,imageHeight:d[1],imageWidth:d[0],inSRS:{wkid:v.spatialReference.wkid},outSRS:{wkid:p.spatialReference.wkid},verticalFieldOfView:y,cameraRoll:b??0,options:o});this.viewModel.updateCurrentCoveragePolygon(new e({attributes:{imageID:n.attributes.objectId},geometry:P,symbol:u.clone(),visible:this.viewModel.currentCoverageVisible}))},this.updateFootprintPanorama=async(t,i)=>{await r(i);const{horizontalFieldOfView:o,pitch:a,verticalFieldOfView:s,yaw:n}=t,l=this.viewModel.currentBestFeature?.clone();if(!l)return;const{attributes:c}=l;c.orientedImageryType=null,c.cameraHeading=(n+c.cameraHeading)%360,c.cameraPitch=a,c.horizontalFieldOfView=o,c.verticalFieldOfView=s,c.cameraRoll=0;const{frustum:p}=m(c);p?this.viewModel.updateCurrentCoveragePolygon(new e({attributes:{imageID:c.objectId},geometry:p,symbol:u.clone(),visible:this.viewModel.currentCoverageVisible})):this.viewModel.updateCurrentCoveragePolygon(null)}}updateGroundElevation(e,t){const{geometry:i}=this.viewModel.currentBestFeature,r=t.queryElevation(i);e.forEach(e=>{const{geometry:t}=e;switch(t?.type){case"mesh":{const{vertexAttributes:{position:e}}=t,i=Math.floor(e.length/3);for(let t=0;t<i;t+=1)e[3*t+2]+=r?.z??0;break}case"point":t.z=(t.z??0)+(r?.z??0)}})}}async function f(e,t,i,r){return Float64Array.from((await Promise.all(e.reduce((e,t,i)=>{const r=Math.floor(i/3);return e[r]=e[r]??[],e[r].push(t),e},new Array).map(async e=>(await s(new a(e,t),i,r)).toArray()))).flat())}export{d as default};
5
+ import e from"../../../../Graphic.js";import{isSome as t}from"../../../../core/arrayUtils.js";import{throwIfAborted as i,waitTick as r}from"../../../../core/promiseUtils.js";import o from"../../../../geometry/Mesh.js";import a from"../../../../geometry/Point.js";import{projectWithZConversion as s}from"../../../../geometry/projectionUtils.js";import{MeshVertexAttributes as n}from"../../../../geometry/support/MeshVertexAttributes.js";import{projectVertices as l,updateFrustum as c,createCoveragePolygon as m}from"../../../../layers/orientedImagery/core/coverageUtils.js";import{activeFrustumSymbol as u,additionalFrustumSymbol as p}from"../../symbols.js";class d{constructor(a){this.viewModel=a,this._updateBestFeatureFootprintElevation=!1,this.createFootprints=async r=>{const{coverageFrustums:a,currentBestFeature:c,isAdditionalCoverageVisible:m,view:d}=this.viewModel,f=a.filter(t);for(const t of f){let a=t.clone();if(!d.spatialReference.equals(a.spatialReference)){const{components:e,spatialReference:t,origin:c,vertexAttributes:m,vertexSpace:u}=a;if("local"===u.type){const e=await s(c,d.spatialReference,r);i(r),a.centerAt(e)}else{const s=m.position,c=Float64Array.from(await l([...s],t.clone(),d.spatialReference.clone(),r));i(r),a=new o({vertexAttributes:new n({position:c}),components:e,spatialReference:d.spatialReference.clone()})}}t.imageID===c.attributes.objectId?(this.viewModel.bestFeatureFootprint=new e({attributes:{imageID:t.imageID},geometry:a,symbol:u.clone(),visible:!1}),this._updateBestFeatureFootprintElevation=!0):this.viewModel.additionalFootprints.push(new e({attributes:{imageID:t.imageID},geometry:a,symbol:p.clone(),visible:m}))}},this.updateFootprint=async(r,o)=>{const{bestFeatureFootprint:a,currentBestFeature:n,activeViewer:l,footprintExtent:m,view:p}=this.viewModel,d=l?.imageSize;if(!(n&&a?.geometry&&d&&m))return void this.viewModel.updateCurrentCoveragePolygon(null);const{attributes:{cameraHeight:v,location:w,cameraPitch:g,horizontalFieldOfView:h,verticalFieldOfView:y,cameraRoll:b},elevationSample:F}=n;F&&this._updateBestFeatureFootprintElevation&&(this.updateGroundElevation([a],F),this._updateBestFeatureFootprintElevation=!1);const M=w.toArray(),{vertexAttributes:{position:R},spatialReference:V}=a.geometry,j=await f(R,V,w.spatialReference),A=await this.viewModel.getMapPoint(r,{feature:n,mode:"default",imageSize:d});i(o);let I=A.filter(t);if(!I.length)return;I[0].spatialReference.equals(w.spatialReference)||(I=await Promise.all(I.map(async e=>{const t=await s(e,w.spatialReference,o);return i(o),t})));const P=await c(r.map(({x:e,y:t})=>[e,t]),I.map(e=>e.toArray()),{cameraHeight:v,cameraLocation:M,cameraPitch:g,frustumVertices:j,horizontalFieldOfView:h,imageHeight:d[1],imageWidth:d[0],inSRS:{wkid:w.spatialReference.wkid},outSRS:{wkid:p.spatialReference.wkid},verticalFieldOfView:y,cameraRoll:b??0,options:o});this.viewModel.updateCurrentCoveragePolygon(new e({attributes:{imageID:n.attributes.objectId},geometry:P,symbol:u.clone(),visible:this.viewModel.currentCoverageVisible}))},this.updateFootprintPanorama=async(t,i)=>{await r(i);const{horizontalFieldOfView:o,pitch:a,verticalFieldOfView:s,yaw:n}=t,l=this.viewModel.currentBestFeature?.clone();if(!l)return;const{attributes:c}=l;c.orientedImageryType=null,c.cameraHeading=(n+c.cameraHeading)%360,c.cameraPitch=a,c.horizontalFieldOfView=o,c.verticalFieldOfView=s,c.cameraRoll=0;const{frustum:p}=m(c);p?this.viewModel.updateCurrentCoveragePolygon(new e({attributes:{imageID:c.objectId},geometry:p,symbol:u.clone(),visible:this.viewModel.currentCoverageVisible})):this.viewModel.updateCurrentCoveragePolygon(null)}}updateGroundElevation(e,t){const{geometry:i,attributes:{elevation:r}}=this.viewModel.currentBestFeature,o=r??t.queryElevation(i)?.z??0;e.forEach(e=>{const{geometry:t}=e;switch(t?.type){case"mesh":{const{vertexAttributes:{position:e}}=t,i=Math.floor(e.length/3);for(let t=0;t<i;t+=1)e[3*t+2]+=o;break}case"point":t.z=(t.z??0)+o}})}}async function f(e,t,i,r){return Float64Array.from((await Promise.all(e.reduce((e,t,i)=>{const r=Math.floor(i/3);return e[r]=e[r]??[],e[r].push(t),e},new Array).map(async e=>(await s(new a(e,t),i,r)).toArray()))).flat())}export{d 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../request.js";import e from"../../core/Error.js";import{deg2rad as a}from"../../core/mathUtils.js";import{throwIfAborted as r}from"../../core/promiseUtils.js";import{getPathExtension as o}from"../../core/urlUtils.js";import{rotatePixel as n}from"../../layers/orientedImagery/transformations/utils.js";import{imageGalleryThumbnailSize as s}from"./constants.js";import{validateTifOrMrfExtension as i,getContentType as m}from"./utils.js";const c=t=>"FA"===t,h=async(t,a,r)=>{const o=new(await import("../../rest/support/AttachmentQuery.js").then(t=>t.default))({objectIds:[a]}),n=await t.queryAttachments(o,r),s=n[`${a}`]?.[0],i=s?.url;if(!i)throw new e("NoAttachmentError","no attachments found",{[t.objectIdField]:a,layer:t});return{datasetFormat:s.contentType.split("/")[1].toUpperCase(),url:i}};async function l(t,e){const a="string"==typeof t,r=a?t:t.url,{pathname:n,searchParams:s,origin:i}=new URL(r);let c=a?o(n):t.datasetFormat;c||(c=await m(r));const h=await import("../../layers/support/rasterDatasets/RasterFactory.js").then(t=>t.default),l=await h.open({ioConfig:{customFetchParameters:Object.fromEntries(s),skipMapInfo:!0},datasetFormat:c?.toUpperCase(),url:`${i}${n}`,signal:e?.signal});return l?u(l,{signal:e?.signal}):null}async function u(t,e){const{level:a,offset:o,size:n}=p(t),{pixelBlock:s}=await t.fetchRawPixels(a,o,n,e);return r(e),s}function p(t){const{storageInfo:e,width:a,height:r}=t.rasterInfo,{maximumPyramidLevel:o,pyramidScalingFactor:n}=e,s=n??2;return{level:o,offset:{x:0,y:0},size:{width:Math.ceil(a/s**o),height:Math.ceil(r/s**o)}}}async function d(a,r,o){if(!a)throw new e("NoLayerError","No layer provided, cannot load image from attachment",{layer:a,objectId:r});const{datasetFormat:n,url:m}=await h(a,+r,o);return i(n)?await l({datasetFormat:n,url:m},o):(await t(m,{...o,useRequestQueue:!0,responseType:"image",query:{w:s}})).data}function f(t,e,a=0){const{height:r,width:o}=t;e.width=o,e.height=r;const n=e.getContext("2d");if(!n)return;const s=g(t,e,n);s.getContext("2d")&&(a>0?w(n,s,o,r,a):n.drawImage(s,0,0))}function g(t,e,a){const r=document.createElement("canvas"),o=r.getContext("2d");if(t instanceof HTMLImageElement)r.width=t.width,r.height=t.height,o?.drawImage(t,0,0);else{const n=a.createImageData(e.width,e.height);n&&(n.data.set(t.getAsRGBA()),r.width=n.width,r.height=n.height,o?.putImageData(n,0,0))}return r}function w(t,e,r,o,s){const i=a(s),m=[n(0,0,i),n(r,0,i),n(r,o,i),n(0,o,i)],c=Math.max(...m.map(t=>t[0]))-Math.min(...m.map(t=>t[0])),h=Math.max(...m.map(t=>t[1]))-Math.min(...m.map(t=>t[1])),l=Math.min(r/c,o/h);t.save(),t.clearRect(0,0,r,o),t.translate(r/2,o/2),t.rotate(i),t.scale(l,l),t.drawImage(e,-r/2,-o/2,r,o),t.restore()}export{h as getImageSourceFromAttachment,l as getThumbnailPixelBlock,c as isFeatureAttachment,d as loadImageForAttachment,f as renderImageWithRotation};
5
+ import t from"../../request.js";import e from"../../core/Error.js";import{deg2rad as a}from"../../core/mathUtils.js";import{throwIfAborted as r}from"../../core/promiseUtils.js";import{getPathExtension as o}from"../../core/urlUtils.js";import{rotatePixel as n}from"../../layers/orientedImagery/transformations/utils.js";import{imageGalleryThumbnailSize as s}from"./constants.js";import{validateTifOrMrfExtension as i,getContentType as m}from"./utils.js";const c=t=>"FA"===t,h=async(t,a,r)=>{const o=new(await import("../../rest/support/AttachmentQuery.js").then(t=>t.default))({objectIds:[a]}),n=await t.queryAttachments(o,r),s=n[`${a}`]?.[0],i=s?.url;if(!i)throw new e("NoAttachmentError","no attachments found",{[t.objectIdField]:a,layer:t});return{datasetFormat:s.contentType.split("/")[1].toUpperCase(),url:i}};async function l(t,e){const a="string"==typeof t,r=a?t:t.url,{pathname:n,searchParams:s,origin:i}=new URL(r);let c=a?o(n):t.datasetFormat;c||(c=await m(r));const h=await import("../../layers/support/rasterDatasets/RasterFactory.js").then(t=>t.default),l=await h.open({ioConfig:{customFetchParameters:Object.fromEntries(s),skipMapInfo:!0},datasetFormat:c?.toUpperCase(),url:`${i}${n}`,signal:e?.signal});return l?u(l,{signal:e?.signal}):null}async function u(t,e){const{level:a,offset:o,size:n}=p(t),{pixelBlock:s}=await t.fetchRawPixels(a,o,n,e);return r(e),s}function p(t){const{storageInfo:e,width:a,height:r}=t.rasterInfo,{maximumPyramidLevel:o,pyramidScalingFactor:n}=e,s=n??2;return{level:o,offset:{x:0,y:0},size:{width:Math.ceil(a/s**o),height:Math.ceil(r/s**o)}}}async function d(a,r,o){if(!a)throw new e("NoLayerError","No layer provided, cannot load image from attachment",{layer:a,objectId:r});const{datasetFormat:n,url:m}=await h(a,+r,o);return i(n)?await l({datasetFormat:n,url:m},o):(await t(m,{...o,useQueue:!0,responseType:"image",query:{w:s}})).data}function f(t,e,a=0){const{height:r,width:o}=t;e.width=o,e.height=r;const n=e.getContext("2d");if(!n)return;const s=g(t,e,n);s.getContext("2d")&&(a>0?w(n,s,o,r,a):n.drawImage(s,0,0))}function g(t,e,a){const r=document.createElement("canvas"),o=r.getContext("2d");if(t instanceof HTMLImageElement)r.width=t.width,r.height=t.height,o?.drawImage(t,0,0);else{const n=a.createImageData(e.width,e.height);n&&(n.data.set(t.getAsRGBA()),r.width=n.width,r.height=n.height,o?.putImageData(n,0,0))}return r}function w(t,e,r,o,s){const i=a(s),m=[n(0,0,i),n(r,0,i),n(r,o,i),n(0,o,i)],c=Math.max(...m.map(t=>t[0]))-Math.min(...m.map(t=>t[0])),h=Math.max(...m.map(t=>t[1]))-Math.min(...m.map(t=>t[1])),l=Math.min(r/c,o/h);t.save(),t.clearRect(0,0,r,o),t.translate(r/2,o/2),t.rotate(i),t.scale(l,l),t.drawImage(e,-r/2,-o/2,r,o),t.restore()}export{h as getImageSourceFromAttachment,l as getThumbnailPixelBlock,c as isFeatureAttachment,d as loadImageForAttachment,f as renderImageWithRotation};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import e from"../../../core/Error.js";import{Loadable as r}from"../../../core/Loadable.js";import{throwIfAborted as i}from"../../../core/promiseUtils.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{RasterJobHandlerMixin as h}from"../../../layers/mixins/RasterJobHandlerMixin.js";let a=class extends(h(r)){constructor(t){super(t)}load(t){return this.addResolvingPromise(this._fetchPixels(t)),Promise.resolve(this)}destroy(){this._source=null}get height(){return this._get("height")}get width(){return this._get("width")}async _fetchPixels(t){const r=(await import("../../../layers/support/rasterDatasets/RasterFactory.js")).default,s=await r.open({url:this.url,ioConfig:{skipExtensions:["jgw","aux.xml"],skipMapInfo:!0},signal:t?.signal});if(i(t),null==s)throw new e("depth-image-service:open-error","Failed to open depth image raster.",{url:this.url});const{width:o,height:h}=s.rasterInfo;await this._initJobHandler(),i(t),s.rasterJobHandler=this._rasterJobHandler;const{pixelBlock:a}=await s.fetchPixels(s.rasterInfo.nativeExtent.clone(),o,h,{noClip:!1,signal:t?.signal});if(i(t),null==a)throw new e("depth-image-service:fetch-error","Failed to fetch depth image pixels.");this._set("width",a.width),this._set("height",a.height),this._source=a.pixels[0]}_getDepthValue(t,e){const r=Math.max(1,Math.min(this.width,t)),i=Math.max(1,Math.min(this.height,e));return this._source[(i-1)*this.width+(r-1)]}_interpolateDepth(t,e){const r=Math.floor(e),i=Math.ceil(e),s=Math.floor(t),o=Math.ceil(t),h=e-r,a=t-s;return(this._getDepthValue(r,s)*(1-h)+this._getDepthValue(i,s)*h)*(1-a)+(this._getDepthValue(r,o)*(1-h)+this._getDepthValue(i,o)*h)*a}depthAt(t,r){if(!this.loaded||!this._source)throw new Error("DepthImageService must be loaded before sampling depth.");if(t.x<1||t.y<1||t.x>r.width||t.y>r.height)throw new e("depth-image-service:out-of-bounds","Position is out of image bounds.");const i=t.x/r.width*this.width,s=t.y/r.height*this.height;return this._interpolateDepth(s,i)}};t([s({readOnly:!0,value:0})],a.prototype,"height",null),t([s()],a.prototype,"url",void 0),t([s({readOnly:!0,value:0})],a.prototype,"width",null),a=t([o("esri.widgets.OrientedImageryViewer.services.DepthImageService")],a);const l=a;export{l as default};
5
+ import{__decorate as t}from"tslib";import e from"../../../core/Error.js";import{Loadable as r}from"../../../core/Loadable.js";import{throwIfAborted as i}from"../../../core/promiseUtils.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{RasterJobHandlerMixin as h}from"../../../layers/mixins/RasterJobHandlerMixin.js";let a=class extends(h(r)){constructor(t){super(t)}load(t){return this.addResolvingPromise(this._fetchPixels(t)),Promise.resolve(this)}destroy(){this._source=null}get height(){return this._get("height")}get width(){return this._get("width")}async _fetchPixels(t){const r=(await import("../../../layers/support/rasterDatasets/RasterFactory.js")).default,s=await r.open({url:this.url,ioConfig:{skipExtensions:["jgw","aux.xml"],skipMapInfo:!0},signal:t?.signal});if(i(t),null==s)throw new e("depth-image-service:open-error","Failed to open depth image raster.",{url:this.url});const{width:o,height:h}=s.rasterInfo;await this._initJobHandler(),i(t),s.rasterJobHandler=this._rasterJobHandler;const{pixelBlock:a}=await s.fetchPixels(s.rasterInfo.nativeExtent.clone(),o,h,{noClip:!1,signal:t?.signal});if(i(t),null==a)throw new e("depth-image-service:fetch-error","Failed to fetch depth image pixels.");this._set("width",a.width),this._set("height",a.height),this._source=a.pixels[0]}_getDepthValue(t,e){const r=Math.max(1,Math.min(this.width,t)),i=Math.max(1,Math.min(this.height,e));return this._source[(i-1)*this.width+(r-1)]}_interpolateDepth(t,e){const r=Math.floor(e),i=Math.ceil(e),s=Math.floor(t),o=Math.ceil(t),h=e-r,a=t-s;return(this._getDepthValue(r,s)*(1-h)+this._getDepthValue(i,s)*h)*(1-a)+(this._getDepthValue(r,o)*(1-h)+this._getDepthValue(i,o)*h)*a}depthAt(t,e){if(!this.loaded||!this._source)throw new Error("DepthImageService must be loaded before sampling depth.");const r=t.x/e.width*this.width,i=t.y/e.height*this.height;return this._interpolateDepth(i,r)}};t([s({readOnly:!0,value:0})],a.prototype,"height",null),t([s()],a.prototype,"url",void 0),t([s({readOnly:!0,value:0})],a.prototype,"width",null),a=t([o("esri.widgets.OrientedImageryViewer.services.DepthImageService")],a);const l=a;export{l 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import i from"../../Camera.js";import t from"../../Ground.js";import a from"../../Map.js";import r from"../../request.js";import{createTask as o}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import n from"../../core/Error.js";import{EventedAccessor as h}from"../../core/Evented.js";import{JSONMap as m}from"../../core/jsonMap.js";import{rad2deg as d,deg2rad as l}from"../../core/mathUtils.js";import{throwIfAborted as c,isAbortError as p,waitTick as g}from"../../core/promiseUtils.js";import{watch as u,syncAndInitial as y,when as _,whenOnce as v}from"../../core/reactiveUtils.js";import{property as w}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{enumeration as f}from"../../core/accessorSupport/decorators/enumeration.js";import{subclass as M}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as R}from"../../core/support/UpdatingHandles.js";import P from"../../geometry/SpatialReference.js";import V from"../../layers/GraphicsLayer.js";import{convertSphereVertexToPixelLocation as z}from"../../layers/orientedImagery/transformations/utils.js";import C from"../../views/SceneView.js";import{logAndThrow as H,getMissingPropertyErrorName as k,getMissingPropertyErrorMessage as S}from"../OrientedImageryViewer/utils.js";import{defaultImageSphereCenter as j,defaultImageSphereSize as O,maxPanoramicViewerHFOV as I,minPanoramicViewerHFOV as b,humanBinocularHFOV as G}from"./constants.js";import x from"./PanoramicZoomConditions.js";import F from"./PanoramicZoomViewModel.js";import{meshToGraphic as A,findDiagonalFOV as T,loadRaster as L,loadPyramid as N,loadMeshes as D,createImageSphere as W}from"./utils.js";const E={default:"default",navigation:"navigation",fovConstraint:"fov-constraint",clickAction:"image-click-action"};let Z=class extends h{constructor(e){super(e),this._panTask=null,this._startPosition=null,this._targetPosition=null,this.tileCache=[],this._graphics=new V({elevationInfo:{mode:"relative-to-ground"}}),this._imageGraphic=null,this.currentGraphics=new s,this.imagePyramid=null,this.imagePyramidLevel=-1,this._map=new a({ground:new t({opacity:0,navigationConstraint:null}),layers:new s([this._graphics])}),this._imageRenderer=new C({map:this._map,viewingMode:"local",camera:{position:j},environment:{atmosphereEnabled:!1,starsEnabled:!1,lighting:{type:"virtual"}},popupEnabled:!1,spatialReference:P.WebMercator,ui:{components:["zoom"]}}),this._loadController=null,this.zoomViewModel=new F({panoramicViewerViewModel:this,view:this._imageRenderer,panoramicZoomConditions:new x({})}),this.autoLoad=!1,this.clickAction="none",this.imageMeshDistance=O/2,this.imageSize=null,this.imageSource=null,this.navigationManager=null,this.navigationViewModel=null,this.pitch=90,this.state="ready",this.updatingHandles=new R,this.yaw=0,this._addNavigationHandles=(e=!0)=>{this.imageRenderer.basemapTerrain.suspended=!0,this.removeHandles(E.navigation);const i=[this.imageRenderer.on("mouse-wheel",this._handleWheel),this.imageRenderer.on("drag",this._handleDrag),this.imageRenderer.on("key-down",e=>{const i=["+","-","Shift","_","=","ArrowUp","ArrowDown","ArrowRight","ArrowLeft"],t=e.key;i.includes(t)&&e.stopPropagation()})];e&&i.push(this.imageRenderer.on("double-click",this._handleDoubleClick)),this.addHandles(i,E.navigation)},this._addHFOVHandles=()=>{this.removeHandles(E.fovConstraint),this.addHandles(u(()=>[this.maxHFOV,this.minHFOV],()=>{this.zoomViewModel&&(this.zoomViewModel.panoramicZoomConditions=new x({view:this.imageRenderer,maxFOV:this.maxHFOV,minFOV:this.minHFOV}))},y),E.fovConstraint)},this._addZoomHandles=()=>{this.zoomViewModel=new F({view:this.imageRenderer,panoramicZoomConditions:new x({maxFOV:this.maxHFOV,minFOV:this.minHFOV}),panoramicViewerViewModel:this});const e=this.imageRenderer.ui.find("zoom");e&&(e.viewModel=this.zoomViewModel),this._addHFOVHandles()},this._cancelLoadWithController=()=>{this._loadController?.abort(),this._loadController=null},this._createPanTask=()=>{this._panTask=o(async e=>{if(!this.imagePyramid)return;const{hfov:i,vfov:t,yaw:a,pitch:r}=this,o=this.imagePyramid.getTiles(this.imagePyramidLevel,a,r,i,t).filter(e=>!this.tileCache.includes(`${e.level}/${e.row}/${e.column}`));if(!o?.length)return;const s=await Promise.all(o.map(async i=>await i.loadMeshAtDistance(this.imageMeshDistance,{signal:e})));c(e);const n=s.map(A);n.forEach((e,i)=>{const t=o[i].key;e.attributes={key:t},this.tileCache.push(t)}),this.currentGraphics.addMany(n),this.addManyGraphics(n),this._panTask=null})},this._handleDoubleClick=e=>{e.stopPropagation(),e.native.ctrlKey?this._zoomOut():this._zoomIn()},this._handleDrag=e=>{e.stopPropagation();const{action:i,x:t,y:a}=e;switch(i){case"start":this._startPosition=this._targetPosition={x:t,y:a};break;case"update":this._targetPosition={x:t,y:a},this._updateCameraHeadingAndTilt()}},this._handleImageClick=e=>{if("image-loaded"===this.state&&this.imageRenderer.ready)switch(this.clickAction){case"emit":e.stopPropagation(),this.emit("click",e);break;case"hittest":e.stopPropagation(),e.defer(async()=>{const i=await this.imageRenderer.hitTest(e.screenPoint,{include:this._graphics});i.results=i.results.filter(e=>"graphic"===e.type&&e.graphic!==this._imageGraphic),this.emit("hittest-response",i)});break;case"pixel-location":{if(e.stopPropagation(),!this.imageSize||!e.mapPoint)return void this.emit("pixel-location",null);const i=z(e.mapPoint,this.imageSize[0],this.imageSize[1]);this.emit("pixel-location",{...i,spatialReference:P.WebMercator});break}}},this._handleWheel=e=>{const i=e.deltaX??e.native.deltaX;e.stopPropagation(),i>0||e.deltaY>0?this._zoomOut():this._zoomIn()},this._loadNavigationManager=async()=>{if(!this.navigationManager||this.navigationManager?.destroyed){const e=await import("../OrientedImageryViewer/navigation/NavigationManagerPanoramic.js").then(e=>e.default);this.navigationManager=new e({viewModel:this.navigationViewModel})}return this.navigationManager},this._loadWithController=()=>{this._cancelLoadWithController(),this._loadController=new AbortController,this.loadImage(this._loadController)},this._zoomIn=()=>{this.zoomViewModel?.zoomIn()},this._zoomOut=()=>{this.zoomViewModel?.zoomOut()},this.addGraphic=(e,i)=>"image-loaded"===this.state&&!this._graphics.graphics.includes(e)&&(this._graphics.graphics.add(e,i),!0),this.addManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const i=e.filter(e=>!this._graphics.graphics.includes(e));return this._graphics.graphics.addMany(i),!0},this.clearGraphics=()=>{this._graphics.graphics.removeAll()},this.clearImage=()=>{this.imageSize=null,this._removeImageSphere()},this.navigate=async(e,i)=>this.updatingHandles.addPromise(this.navigateInternal(e,i)),this.navigateInternal=async(e,i)=>{const t=await this._loadNavigationManager();return await t.navigate(e,i)},this.removeGraphic=e=>!("image-loaded"!==this.state||!this._graphics.graphics.includes(e))&&(this._graphics.remove(e),!0),this.removeManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const i=e.filter(e=>this._graphics.graphics.includes(e));return this._graphics.removeMany(i),!0},this.restoreNavigationHandles=()=>{this._addNavigationHandles(!1)}}destroy(){this._imageRenderer.destroy()}initialize(){this.state="initialized",this.addHandles([u(()=>this.imageSource,()=>{this.imageSource&&this.autoLoad&&this._loadWithController()},y),u(()=>this.fov,()=>{this._reloadCamera()},y),u(()=>this.yaw,e=>{this.camera&&(this.camera.heading=e,this._reloadCamera())},y),u(()=>this.pitch,e=>{this.camera&&(this.camera.tilt=e,this._reloadCamera())},y),_(()=>this.imageRenderer.ready,()=>{this._addNavigationHandles(),this._addZoomHandles()},y),u(()=>this.clickAction,e=>{this.removeHandles(E.clickAction),"none"!==e&&this.addHandles(this.imageRenderer.on("click",this._handleImageClick))},y),u(()=>this.camera,(e,i)=>{this._panTask?.abort(),e?i?.tilt===e.tilt&&i.heading===e.heading||this._createPanTask():this._panTask=null})],E.default)}get camera(){return this.imageRenderer.destroying||this.imageRenderer.destroyed?null:this.imageRenderer.camera}set camera(e){!e||this.imageRenderer.destroying||this.imageRenderer.destroyed||(this.imageRenderer.camera=e.clone())}get distanceFactor(){return this.fov?1-5/this.fov:null}get fov(){return this.camera?.fov}set fov(e){Number.isFinite(e)&&this.zoomViewModel?.zoomTo(e)}get hfov(){if(!this.camera||!this.imageRenderer?.ready)return 0;const{fov:e}=this.camera,{size:[i,t]}=this.imageRenderer,a=i/t;return 2*d(Math.atan(Math.tan(l(e/2))*a/Math.sqrt(1+a**2)))}get imageRenderer(){return this._imageRenderer}get maxHFOV(){const{size:[e,i]}=this.imageRenderer;return this.imageRenderer.ready?T(I,e/i):I}get minHFOV(){const{size:[e,i]}=this.imageRenderer;return this.imageRenderer.ready?T(b,e/i):b}get updating(){return this.updatingHandles.updating}get vfov(){if(!this.camera||!this.imageRenderer?.ready)return 0;const{fov:e}=this.camera,{size:[i,t]}=this.imageRenderer,a=i/t;return 2*d(Math.atan(Math.tan(l(e/2))*(1/Math.sqrt(1+a**2))))}_clearImageSphere(){if(!this._imageGraphic)return;const e=Array.isArray(this._imageGraphic)?this._imageGraphic:[this._imageGraphic];this._graphics.removeMany(e),this._imageGraphic=null,e.forEach(e=>e.destroy())}async _loadImageInternal(e,i){let t;this.state="image-loading";try{t=(await r(e,{responseType:"image",...i})).data}catch(a){throw p(a)?this.state="image-load-aborted":this.state="image-load-error",a}return this._updateImageSphere(t,i)}async loadImageTiled(e,i){this.state="image-loading";try{const{clientWidth:t,clientHeight:a}=this.imageRenderer.container;this.fov=T(G,t/a);const r=await L(e,i),o=await N(r,i),s=o.getLowResolutionTiles(),h=await D(s,i),{imageSize:m}=o;if(c(i),!s?.length)throw new n("panoramic-viewer:missing-tiles","No tiles were found in the pyramid",{imageSource:e});this.imagePyramid=o,this.imagePyramidLevel=o.maximumPyramidLevel,this.imageSize=m;const d=h.map(A);d.forEach((e,i)=>{const t=s[i].key;e.attributes={key:t},this.tileCache.push(t)}),this._imageGraphic=d,this._graphics.addMany(this._imageGraphic),this.state="image-loaded"}catch(t){throw this.state=p(t)?"image-load-aborted":"image-load-error",t}}_reloadCamera(){this.camera=this.camera?.clone()}_removeImageSphere(){this._clearImageSphere(),this.state="ready",this.imageSize=null}_updateCameraHeadingAndTilt(){if(!this._startPosition||!this._targetPosition||!this.camera)return;const e=this.camera.heading+(this._startPosition.x-this._targetPosition.x)/this.imageRenderer.width*this.camera.fov;this.yaw=(e+360)%360;const i=this.camera.tilt-(this._startPosition.y-this._targetPosition.y)/this.imageRenderer.height*this.imageRenderer.camera.tilt;this.pitch=Math.min(179.5,Math.max(.5,i)),this._startPosition=this._targetPosition}async _updateImageSphere(e,i){return await g(i),this._imageGraphic=A(W(e)),this._graphics.add(this._imageGraphic),this.state="image-loaded",v(()=>this.imageRenderer.ready,i).then(()=>{const{size:[e,i]}=this.imageRenderer;this.fov=T(G,e/i)}),this.imageSize=[e.width,e.height],this._imageGraphic.geometry}async loadImage(e){return this._removeImageSphere(),this.imageSource?this._loadImageInternal(this.imageSource,e):H(this.declaredClass,new n(k("panoramic-viewer"),S("PanoramicViewerViewModel","imageSource")))}};e([w()],Z.prototype,"_graphics",void 0),e([w()],Z.prototype,"_imageGraphic",void 0),e([w({constructOnly:!0})],Z.prototype,"currentGraphics",void 0),e([w()],Z.prototype,"imagePyramid",void 0),e([w()],Z.prototype,"imagePyramidLevel",void 0),e([w()],Z.prototype,"_map",void 0),e([w()],Z.prototype,"_imageRenderer",void 0),e([w()],Z.prototype,"_loadController",void 0),e([w()],Z.prototype,"zoomViewModel",void 0),e([w({type:Boolean})],Z.prototype,"autoLoad",void 0),e([w({type:i})],Z.prototype,"camera",null),e([f(new m({emit:"emit",hittest:"hittest",none:"none","pixel-location":"pixel-location"}))],Z.prototype,"clickAction",void 0),e([w()],Z.prototype,"distanceFactor",null),e([w({type:Number})],Z.prototype,"fov",null),e([w({readOnly:!0})],Z.prototype,"hfov",null),e([w()],Z.prototype,"imageMeshDistance",void 0),e([w({readOnly:!0})],Z.prototype,"imageRenderer",null),e([w()],Z.prototype,"imageSize",void 0),e([w()],Z.prototype,"imageSource",void 0),e([w({readOnly:!0})],Z.prototype,"maxHFOV",null),e([w({readOnly:!0})],Z.prototype,"minHFOV",null),e([w()],Z.prototype,"navigationViewModel",void 0),e([w({type:Number})],Z.prototype,"pitch",void 0),e([w()],Z.prototype,"state",void 0),e([w()],Z.prototype,"updatingHandles",void 0),e([w()],Z.prototype,"updating",null),e([w({readOnly:!0})],Z.prototype,"vfov",null),e([w({type:Number})],Z.prototype,"yaw",void 0),Z=e([M("esri.widgets.PanoramicViewer.PanoramicViewerViewModel")],Z);const U=Z;export{U as default};
5
+ import{__decorate as e}from"tslib";import i from"../../Camera.js";import t from"../../Ground.js";import a from"../../Map.js";import r from"../../request.js";import{createTask as o}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import n from"../../core/Error.js";import{EventedAccessor as h}from"../../core/Evented.js";import{JSONMap as m}from"../../core/jsonMap.js";import{rad2deg as d,deg2rad as l}from"../../core/mathUtils.js";import{throwIfAborted as c,isAbortError as p,waitTick as g}from"../../core/promiseUtils.js";import{watch as u,syncAndInitial as y,when as _,whenOnce as v}from"../../core/reactiveUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{enumeration as w}from"../../core/accessorSupport/decorators/enumeration.js";import{subclass as M}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as R}from"../../core/support/UpdatingHandles.js";import P from"../../geometry/SpatialReference.js";import V from"../../layers/GraphicsLayer.js";import{convertSphereVertexToPixelLocation as z}from"../../layers/orientedImagery/transformations/utils.js";import{isGraphic as C}from"../../support/guards.js";import H from"../../views/SceneView.js";import{logAndThrow as G,getMissingPropertyErrorName as k,getMissingPropertyErrorMessage as S}from"../OrientedImageryViewer/utils.js";import{defaultImageSphereCenter as j,defaultImageSphereSize as b,maxPanoramicViewerHFOV as I,minPanoramicViewerHFOV as O,humanBinocularHFOV as x}from"./constants.js";import A from"./PanoramicZoomConditions.js";import F from"./PanoramicZoomViewModel.js";import{meshToGraphic as T,findDiagonalFOV as L,loadRaster as N,loadPyramid as E,loadMeshes as W,createImageSphere as D}from"./utils.js";const Z={default:"default",navigation:"navigation",fovConstraint:"fov-constraint",clickAction:"image-click-action"};let U=class extends h{constructor(e){super(e),this._panTask=null,this._startPosition=null,this._targetPosition=null,this.tileCache=[],this._graphics=new V({elevationInfo:{mode:"relative-to-ground"}}),this._imageGraphic=null,this.currentGraphics=new s,this.imagePyramid=null,this.imagePyramidLevel=-1,this._map=new a({ground:new t({opacity:0,navigationConstraint:null}),layers:new s([this._graphics])}),this._imageRenderer=new H({map:this._map,viewingMode:"local",camera:{position:j},environment:{atmosphereEnabled:!1,starsEnabled:!1,lighting:{type:"virtual"}},popupEnabled:!1,spatialReference:P.WebMercator,ui:{components:["zoom"]}}),this._loadController=null,this.zoomViewModel=new F({panoramicViewerViewModel:this,view:this._imageRenderer,panoramicZoomConditions:new A({})}),this.autoLoad=!1,this.clickAction="none",this.imageMeshDistance=b/2,this.imageSize=null,this.imageSource=null,this.navigationManager=null,this.navigationViewModel=null,this.pitch=90,this.state="ready",this.updatingHandles=new R,this.yaw=0,this._addNavigationHandles=(e=!0)=>{this.imageRenderer.basemapTerrain.suspended=!0,this.removeHandles(Z.navigation);const i=[this.imageRenderer.on("mouse-wheel",this._handleWheel),this.imageRenderer.on("drag",this._handleDrag),this.imageRenderer.on("key-down",e=>{const i=["+","-","Shift","_","=","ArrowUp","ArrowDown","ArrowRight","ArrowLeft"],t=e.key;i.includes(t)&&e.stopPropagation()})];e&&i.push(this.imageRenderer.on("double-click",this._handleDoubleClick)),this.addHandles(i,Z.navigation)},this._addHFOVHandles=()=>{this.removeHandles(Z.fovConstraint),this.addHandles(u(()=>[this.maxHFOV,this.minHFOV],()=>{this.zoomViewModel&&(this.zoomViewModel.panoramicZoomConditions=new A({view:this.imageRenderer,maxFOV:this.maxHFOV,minFOV:this.minHFOV}))},y),Z.fovConstraint)},this._addZoomHandles=()=>{this.zoomViewModel=new F({view:this.imageRenderer,panoramicZoomConditions:new A({maxFOV:this.maxHFOV,minFOV:this.minHFOV}),panoramicViewerViewModel:this});const e=this.imageRenderer.ui.find("zoom");e&&(e.viewModel=this.zoomViewModel),this._addHFOVHandles()},this._cancelLoadWithController=()=>{this._loadController?.abort(),this._loadController=null},this._createPanTask=()=>{this._panTask?.abort(),this._panTask=o(async e=>{if(!this.imagePyramid)return;const{hfov:i,vfov:t,yaw:a,pitch:r}=this,o=this.imagePyramid.getTiles(this.imagePyramidLevel,a,r,i,t).filter(e=>!this.tileCache.includes(`${e.level}/${e.row}/${e.column}`));if(!o?.length)return;const s=await Promise.all(o.map(async i=>await i.loadMesh({signal:e})));c(e);const n=s.map(T);n.forEach((e,i)=>{const t=o[i].key;e.attributes={key:t},this.tileCache.push(t)}),this.addManyGraphics(n),this.currentGraphics.addMany(n),this._panTask=null})},this._handleDoubleClick=e=>{e.stopPropagation(),e.native.ctrlKey?this._zoomOut():this._zoomIn()},this._handleDrag=e=>{e.stopPropagation();const{action:i,x:t,y:a}=e;switch(i){case"start":this._startPosition=this._targetPosition={x:t,y:a};break;case"update":this._targetPosition={x:t,y:a},this._updateCameraHeadingAndTilt()}},this._handleImageClick=e=>{if("image-loaded"===this.state&&this.imageRenderer.ready)switch(this.clickAction){case"emit":e.stopPropagation(),this.emit("click",e);break;case"hittest":e.stopPropagation(),e.defer(async()=>{const i=await this.imageRenderer.hitTest(e.screenPoint,{include:this._graphics}),t=Array.isArray(this._imageGraphic)?this._imageGraphic:[this._imageGraphic].filter(C);i.results=i.results.filter(e=>"graphic"===e.type&&!t.includes(e.graphic)),this.emit("hittest-response",i)});break;case"pixel-location":{if(e.stopPropagation(),!this.imageSize||!e.mapPoint)return void this.emit("pixel-location",null);const i=z(e.mapPoint,this.imageSize[0],this.imageSize[1]);this.emit("pixel-location",{...i,spatialReference:P.WebMercator});break}}},this._handleWheel=e=>{const i=e.deltaX??e.native.deltaX;e.stopPropagation(),i>0||e.deltaY>0?this._zoomOut():this._zoomIn()},this._loadNavigationManager=async()=>{if(!this.navigationManager||this.navigationManager?.destroyed){const e=await import("../OrientedImageryViewer/navigation/NavigationManagerPanoramic.js").then(e=>e.default);this.navigationManager=new e({viewModel:this.navigationViewModel})}return this.navigationManager},this._loadWithController=()=>{this._cancelLoadWithController(),this._loadController=new AbortController,this.loadImage(this._loadController)},this._zoomIn=()=>{this.zoomViewModel?.zoomIn()},this._zoomOut=()=>{this.zoomViewModel?.zoomOut()},this.addGraphic=(e,i)=>"image-loaded"===this.state&&!this._graphics.graphics.includes(e)&&(this._graphics.graphics.add(e,i),!0),this.addManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const i=e.filter(e=>!this._graphics.graphics.includes(e));return this._graphics.graphics.addMany(i),!0},this.clearGraphics=()=>{this._graphics.graphics.removeAll()},this.clearImage=()=>{this.imageSize=null,this._removeImageSphere()},this.navigate=async(e,i)=>this.updatingHandles.addPromise(this.navigateInternal(e,i)),this.navigateInternal=async(e,i)=>{const t=await this._loadNavigationManager();return await t.navigate(e,i)},this.removeGraphic=e=>!("image-loaded"!==this.state||!this._graphics.graphics.includes(e))&&(this._graphics.remove(e),!0),this.removeManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const i=e.filter(e=>this._graphics.graphics.includes(e));return this._graphics.removeMany(i),!0},this.restoreNavigationHandles=()=>{this._addNavigationHandles(!1)}}destroy(){this._imageRenderer.destroy()}initialize(){this.state="initialized",this.addHandles([u(()=>this.imageSource,()=>{this.imageSource&&this.autoLoad&&this._loadWithController()},y),u(()=>this.fov,()=>{this._reloadCamera()},y),u(()=>this.yaw,e=>{this.camera&&(this.camera.heading=e,this._reloadCamera())},y),u(()=>this.pitch,e=>{this.camera&&(this.camera.tilt=e,this._reloadCamera())},y),_(()=>this.imageRenderer.ready,()=>{this._addNavigationHandles(),this._addZoomHandles()},y),u(()=>this.clickAction,e=>{this.removeHandles(Z.clickAction),"none"!==e&&this.addHandles(this.imageRenderer.on("click",this._handleImageClick))},y),u(()=>this.camera,(e,i)=>{this._panTask?.abort(),e?i?.tilt===e.tilt&&i.heading===e.heading||this._createPanTask():this._panTask=null}),this.currentGraphics.on("change",()=>{const e=Array.isArray(this._imageGraphic)?this._imageGraphic:[this._imageGraphic].filter(C),i=this.currentGraphics.map(e=>e.geometry.extent);e.forEach(e=>{e.visible=!0!==i.some(i=>i.intersects(e.geometry.extent))})})],Z.default)}get camera(){return this.imageRenderer.destroying||this.imageRenderer.destroyed?null:this.imageRenderer.camera}set camera(e){!e||this.imageRenderer.destroying||this.imageRenderer.destroyed||(this.imageRenderer.camera=e.clone())}get distanceFactor(){return this.fov?1-5/this.fov:null}get fov(){return this.camera?.fov}set fov(e){Number.isFinite(e)&&this.zoomViewModel?.zoomTo(e)}get hfov(){if(!this.camera||!this.imageRenderer?.ready)return 0;const{fov:e}=this.camera,{size:[i,t]}=this.imageRenderer,a=i/t;return 2*d(Math.atan(Math.tan(l(e/2))*a/Math.sqrt(1+a**2)))}get imageRenderer(){return this._imageRenderer}get maxHFOV(){const{size:[e,i]}=this.imageRenderer;return this.imageRenderer.ready?L(I,e/i):I}get minHFOV(){const{size:[e,i]}=this.imageRenderer;return this.imageRenderer.ready?L(O,e/i):O}get updating(){return this.updatingHandles.updating}get vfov(){if(!this.camera||!this.imageRenderer?.ready)return 0;const{fov:e}=this.camera,{size:[i,t]}=this.imageRenderer,a=i/t;return 2*d(Math.atan(Math.tan(l(e/2))*(1/Math.sqrt(1+a**2))))}_clearImageSphere(){if(!this._imageGraphic)return;const e=Array.isArray(this._imageGraphic)?this._imageGraphic:[this._imageGraphic];this._graphics.removeMany(e),this._imageGraphic=null,e.forEach(e=>e.destroy()),this._graphics.removeMany(this.currentGraphics.toArray()),this.imagePyramid=null,this.imagePyramidLevel=-1,this.tileCache=[]}async _loadImageInternal(e,i){let t;this.state="image-loading";try{t=(await r(e,{responseType:"image",...i})).data}catch(a){throw p(a)?this.state="image-load-aborted":this.state="image-load-error",a}return this._updateImageSphere(t,i)}async loadImageTiled(e,i){this._removeImageSphere(),this.state="image-loading";try{const t=await N(e,i),a=await E(t,i),r=a.getLowResolutionTiles(),o=await W(r,i),{imageSize:s}=a;if(c(i),!r?.length)throw new n("panoramic-viewer:missing-tiles","No tiles were found in the pyramid",{imageSource:e});this.imagePyramid=a,this.imagePyramidLevel=a.maximumPyramidLevel;const h=o.map(T);h.forEach((e,i)=>{const t=r[i].key;e.attributes={key:t},this.tileCache.push(t)}),this._imageGraphic=h,this._graphics.addMany(this._imageGraphic),this.state="image-loaded",v(()=>this.imageRenderer.ready,i).then(()=>{const{size:[e,i]}=this.imageRenderer;this.fov=L(x,e/i)}),this.imageSize=s}catch(t){throw this.state=p(t)?"image-load-aborted":"image-load-error",t}}_reloadCamera(){this.camera=this.camera?.clone()}_removeImageSphere(){this._clearImageSphere(),this.state="ready",this.imageSize=null}_updateCameraHeadingAndTilt(){if(!this._startPosition||!this._targetPosition||!this.camera)return;const e=this.camera.heading+(this._startPosition.x-this._targetPosition.x)/this.imageRenderer.width*this.camera.fov;this.yaw=(e+360)%360;const i=this.camera.tilt-(this._startPosition.y-this._targetPosition.y)/this.imageRenderer.height*this.imageRenderer.camera.tilt;this.pitch=Math.min(179.5,Math.max(.5,i)),this._startPosition=this._targetPosition}async _updateImageSphere(e,i){return await g(i),this._imageGraphic=T(D(e)),this._graphics.add(this._imageGraphic),this.state="image-loaded",v(()=>this.imageRenderer.ready,i).then(()=>{const{size:[e,i]}=this.imageRenderer;this.fov=L(x,e/i)}),this.imageSize=[e.width,e.height],this._imageGraphic.geometry}async loadImage(e){return this._removeImageSphere(),this.imageSource?this._loadImageInternal(this.imageSource,e):G(this.declaredClass,new n(k("panoramic-viewer"),S("PanoramicViewerViewModel","imageSource")))}};e([f()],U.prototype,"_graphics",void 0),e([f()],U.prototype,"_imageGraphic",void 0),e([f({constructOnly:!0})],U.prototype,"currentGraphics",void 0),e([f()],U.prototype,"imagePyramid",void 0),e([f()],U.prototype,"imagePyramidLevel",void 0),e([f()],U.prototype,"_map",void 0),e([f()],U.prototype,"_imageRenderer",void 0),e([f()],U.prototype,"_loadController",void 0),e([f()],U.prototype,"zoomViewModel",void 0),e([f({type:Boolean})],U.prototype,"autoLoad",void 0),e([f({type:i})],U.prototype,"camera",null),e([w(new m({emit:"emit",hittest:"hittest",none:"none","pixel-location":"pixel-location"}))],U.prototype,"clickAction",void 0),e([f()],U.prototype,"distanceFactor",null),e([f({type:Number})],U.prototype,"fov",null),e([f({readOnly:!0})],U.prototype,"hfov",null),e([f()],U.prototype,"imageMeshDistance",void 0),e([f({readOnly:!0})],U.prototype,"imageRenderer",null),e([f()],U.prototype,"imageSize",void 0),e([f()],U.prototype,"imageSource",void 0),e([f({readOnly:!0})],U.prototype,"maxHFOV",null),e([f({readOnly:!0})],U.prototype,"minHFOV",null),e([f()],U.prototype,"navigationViewModel",void 0),e([f({type:Number})],U.prototype,"pitch",void 0),e([f()],U.prototype,"state",void 0),e([f()],U.prototype,"updatingHandles",void 0),e([f()],U.prototype,"updating",null),e([f({readOnly:!0})],U.prototype,"vfov",null),e([f({type:Number})],U.prototype,"yaw",void 0),U=e([M("esri.widgets.PanoramicViewer.PanoramicViewerViewModel")],U);const q=U;export{q as default};