@arcgis/core 5.0.0-next.121 → 5.0.0-next.123

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 (241) hide show
  1. package/applications/Components/SketchTooltipControls.d.ts +3 -2
  2. package/applications/Components/SketchTooltipControls.js +1 -1
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/0184b4c0c92c76c60ab2.js +1 -0
  5. package/assets/esri/core/workers/chunks/{56a296cb5c1ae1ea5ab2.js → 08616877b58b518e7461.js} +1 -1
  6. package/assets/esri/core/workers/chunks/089cef7124173a5cd5f9.js +1 -0
  7. package/assets/esri/core/workers/chunks/{4d438627dd3509f65d5a.js → 0baa0d66003d23cc76a7.js} +1 -1
  8. package/assets/esri/core/workers/chunks/0e216f0075fd531c3a2b.js +1 -0
  9. package/assets/esri/core/workers/chunks/{d5314786df52b6be5307.js → 0e6ffb02a929130ddb50.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{4cb702d574c100483226.js → 0e8b4543e895b615c254.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{ae0a555b047b11aa68eb.js → 1219b588f983b4f35033.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{41fe4d8fe97388498f73.js → 13512a23655258fa77f4.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{ee34f14bbfe619b85a80.js → 13e913aa5f5113fceb16.js} +1 -1
  14. package/assets/esri/core/workers/chunks/1458ef3857be3b76be95.js +1 -0
  15. package/assets/esri/core/workers/chunks/{d621cdd0aef6d77986f0.js → 1469e6d1d0d4e310b8f8.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{b9e90875943703486227.js → 15ba0296403dd4152b88.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{7595c52b1647f092c61a.js → 16abc548724e428c325a.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{dddcae86e434d93b10c0.js → 189e22df73414a1a3989.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{90aeef17af12cfbecb36.js → 1d124a55f6804be19e09.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{63831996ad82bd3b1ca9.js → 1e29a114c1cfe21121c4.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{153a9d087e0fe7072af4.js → 1ede5fa7a16839ed9444.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{6b1e1fb4e9010873c171.js → 1f30558e3ad6ac68bdb8.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{9c06b803912fcafa7f52.js → 24dd404612c35f6a3fc3.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{b6e155b42a4a423139e7.js → 27d1f8279df34d8b15b5.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{401af6d07c9f458ae067.js → 2c69d8bb1c950b95278d.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{22d12c309af9c19a1a48.js → 2c7e5b78d94e5850537b.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{120a5fa9b46084cd0c45.js → 2d376f82cdf020e1fca9.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{8c321c6bc344544ebb51.js → 2d52b137ee64469a46b2.js} +1 -1
  29. package/assets/esri/core/workers/chunks/2d67ab4927a968d5c8d4.js +1 -0
  30. package/assets/esri/core/workers/chunks/{5b3f2bad61a0d993bf16.js → 2e63e18df96e5a2461de.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{d4da3abbd3d88cd63cb9.js → 454150571b5b664b576a.js} +1 -1
  32. package/assets/esri/core/workers/chunks/4740d319f233b7f528fe.js +1 -0
  33. package/assets/esri/core/workers/chunks/{78ce6fcb72e97d3dc087.js → 499d594dc0d282dfe777.js} +1 -1
  34. package/assets/esri/core/workers/chunks/49d58bacb5b397246978.js +1 -0
  35. package/assets/esri/core/workers/chunks/4ba4aa6c75e3f8950e65.js +1 -0
  36. package/assets/esri/core/workers/chunks/{61ce373f00a0cad113ed.js → 4f2c29168c9de0b08741.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{5789898948cc0da78b8b.js → 552e5c413828e181f89a.js} +1 -1
  38. package/assets/esri/core/workers/chunks/{5210bde0a05ab172ab28.js → 59f955c7d6b0589e7cc6.js} +1 -1
  39. package/assets/esri/core/workers/chunks/{5fe0bed2a0a9f8eadb28.js → 5a347b1d87eb6f710136.js} +1 -1
  40. package/assets/esri/core/workers/chunks/5b97cdeb5949822fbef3.js +1 -0
  41. package/assets/esri/core/workers/chunks/{178c91fabf4a87bbb50b.js → 620d7cd0b0885122aa0f.js} +1 -1
  42. package/assets/esri/core/workers/chunks/6321680c8070dffa3b6c.js +1 -0
  43. package/assets/esri/core/workers/chunks/6997b4d5bcc9c4755375.js +1 -0
  44. package/assets/esri/core/workers/chunks/{b79cceeee3ed46f218a0.js → 69ab42b965bccc3bad4f.js} +1 -1
  45. package/assets/esri/core/workers/chunks/{bb4c75479cfea67cf8a2.js → 6af14a0217077d9ab47f.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{672542d0435fbfd0647c.js → 6b3d8280a24f7a3aac40.js} +1 -1
  47. package/assets/esri/core/workers/chunks/6e0cfb76f9c2a9ec6530.js +1 -0
  48. package/assets/esri/core/workers/chunks/6e8989d61204b0b5ff52.js +1 -0
  49. package/assets/esri/core/workers/chunks/{3d78e9b3c97c0ce21d16.js → 7017c2e621236c7a7da4.js} +1 -1
  50. package/assets/esri/core/workers/chunks/7407a1e0cef508116a0b.js +1 -0
  51. package/assets/esri/core/workers/chunks/{da188d0e22ba1639928e.js → 75907e5d009b71ce723b.js} +1 -1
  52. package/assets/esri/core/workers/chunks/{1ab4289195f5e46c6fe8.js → 78936c591fd49ff955a9.js} +1 -1
  53. package/assets/esri/core/workers/chunks/{f0b8de5b3cfbe9223df6.js → 796f5265747ce8be910e.js} +1 -1
  54. package/assets/esri/core/workers/chunks/{ac62411b9b4cf85a4722.js → 7a037fbfd91dd22e3bf0.js} +1 -1
  55. package/assets/esri/core/workers/chunks/{50661f65a9c191f528bc.js → 7ee7529fcbd0d169047c.js} +1 -1
  56. package/assets/esri/core/workers/chunks/7f9b0ef7f9b3f3fd3df9.js +1 -0
  57. package/assets/esri/core/workers/chunks/804c31973f7d116523cb.js +1 -0
  58. package/assets/esri/core/workers/chunks/{82a446e8befe9d29c8f0.js → 822a115c7d718e4e3d2b.js} +1 -1
  59. package/assets/esri/core/workers/chunks/{6789ddaa61e6d8f20d04.js → 8eea620f770576d18809.js} +1 -1
  60. package/assets/esri/core/workers/chunks/{10c4f5afe14c0addc418.js → 9332db133a0925d522fe.js} +1 -1
  61. package/assets/esri/core/workers/chunks/{bc87890d00d6dba979b2.js → 99c9f35a29f9f6c9e4ce.js} +1 -1
  62. package/assets/esri/core/workers/chunks/a4b422dbb6d3cb2505e1.js +1 -0
  63. package/assets/esri/core/workers/chunks/{455fbddd814e4681f0c0.js → a5e91cf150f6cf6a5d2a.js} +1 -1
  64. package/assets/esri/core/workers/chunks/{eb4a2dc5efdb873a7f25.js → aef2832902b270f1a594.js} +1 -1
  65. package/assets/esri/core/workers/chunks/{b5fc0a2480a229e8891a.js → b5f291e8ed7f7cac158d.js} +1 -1
  66. package/assets/esri/core/workers/chunks/bc32a4baeb0ecabb68cc.js +1 -0
  67. package/assets/esri/core/workers/chunks/bd05e68b00b9878d0266.js +1 -0
  68. package/assets/esri/core/workers/chunks/{9a43065e51df9c21c9fa.js → bdb4f216ae8881b98604.js} +1 -1
  69. package/assets/esri/core/workers/chunks/{bf9b2aa2e67ca746ec7c.js → c15f0769a64863cccef0.js} +1 -1
  70. package/assets/esri/core/workers/chunks/c6e0ada6f2ad74fddfec.js +1 -0
  71. package/assets/esri/core/workers/chunks/cf09408cb7729126caae.js +1 -0
  72. package/assets/esri/core/workers/chunks/e0565849281ffbe8269e.js +1 -0
  73. package/assets/esri/core/workers/chunks/{4ef60a76eeca20bcafb1.js → e4f1e584f89ffb86206b.js} +1 -1
  74. package/assets/esri/core/workers/chunks/{2889e782ed81bb05b9e5.js → e508f8e707eb3207cfcc.js} +1 -1
  75. package/assets/esri/core/workers/chunks/{2216264b22a605a0f1ce.js → e60684918100666bb892.js} +1 -1
  76. package/assets/esri/core/workers/chunks/{4550b7620932cd6de20e.js → e94448b371cd17d7a472.js} +1 -1
  77. package/assets/esri/core/workers/chunks/{bb8530ade7c40a1ed7c4.js → eb9e913fe0dfcc71cf92.js} +1 -1
  78. package/assets/esri/core/workers/chunks/{8f26e93eb539ee66c5ac.js → ec2dfd89e4ce6fda4971.js} +1 -1
  79. package/assets/esri/core/workers/chunks/ede1d1cc2f315a34f4ca.js +1 -0
  80. package/assets/esri/core/workers/chunks/{a5bd7e5d71cffde68f89.js → ee89564d11c077169b31.js} +1 -1
  81. package/assets/esri/core/workers/chunks/{b3cc7f6d953bfbc3a70d.js → f62e37863a549f72093c.js} +1 -1
  82. package/assets/esri/core/workers/chunks/fc98b8351be567d3eb62.js +1 -0
  83. package/assets/esri/core/workers/chunks/{554f389f99db430b309c.js → ff961bb6d29ab3fe129d.js} +1 -1
  84. package/assets/esri/themes/base/widgets/_Attribution.scss +4 -2
  85. package/assets/esri/themes/dark/main.css +1 -1
  86. package/assets/esri/themes/light/main.css +1 -1
  87. package/assets/esri/themes/light/view.css +1 -1
  88. package/config.js +1 -1
  89. package/core/Logger.js +1 -1
  90. package/core/deprecate.js +1 -1
  91. package/core/has.js +1 -1
  92. package/core/types.d.ts +5 -0
  93. package/core/workers/workerFactory.js +1 -1
  94. package/editing/sharedTemplates/executor/builders/radialLines.js +1 -1
  95. package/editing/sharedTemplates/executor/builders/support/shapeUtils.js +1 -1
  96. package/geometry/projectionUtils.js +1 -1
  97. package/geometry/support/curves/curveUtils.js +1 -1
  98. package/kernel.js +1 -1
  99. package/layers/ImageryLayer.d.ts +1 -1
  100. package/layers/MapImageLayer.d.ts +1 -1
  101. package/layers/TileLayer.d.ts +1 -1
  102. package/layers/WebTileLayer.d.ts +1 -1
  103. package/layers/graphics/data/QueryEngineResult.js +1 -1
  104. package/layers/graphics/data/SnappingCandidate.js +1 -1
  105. package/layers/orientedImagery/transformations/imageToWorld.js +1 -1
  106. package/layers/orientedImagery/transformations/utils.js +1 -1
  107. package/layers/orientedImagery/transformations/worldToImage.js +1 -1
  108. package/layers/support/ControlPointsGeoreference.d.ts +2 -2
  109. package/layers/support/ControlPointsGeoreference.js +1 -1
  110. package/layers/support/CornersGeoreference.d.ts +2 -2
  111. package/layers/support/CornersGeoreference.js +1 -1
  112. package/layers/support/ExtentAndRotationGeoreference.d.ts +2 -2
  113. package/layers/support/ExtentAndRotationGeoreference.js +1 -1
  114. package/layers/support/GeoreferenceBaseMixin.js +2 -0
  115. package/layers/support/mediaUtils.js +1 -1
  116. package/layers/support/relativeTimeQueryUtils.js +1 -1
  117. package/layers/support/serviceCapabilitiesUtils.js +1 -1
  118. package/package.json +1 -1
  119. package/renderers/DotDensityRenderer.d.ts +43 -0
  120. package/renderers/DotDensityRenderer.js +1 -1
  121. package/rest/featureService/FeatureService.js +1 -1
  122. package/rest/print.js +1 -1
  123. package/rest/query/operations/pbfFlatFeatureSet.js +1 -1
  124. package/support/basemapUtils.js +1 -1
  125. package/support/revision.js +1 -1
  126. package/symbols/ExtrudeSymbol3DLayer.d.ts +20 -10
  127. package/symbols/FillSymbol3DLayer.d.ts +36 -16
  128. package/symbols/ObjectSymbol3DLayer.d.ts +28 -6
  129. package/symbols/PathSymbol3DLayer.d.ts +18 -6
  130. package/symbols/cim/CIMSymbolHelper.js +1 -1
  131. package/symbols/cim/rasterizingUtils.js +1 -1
  132. package/symbols/support/Symbol3DEmissive.d.ts +9 -9
  133. package/symbols/support/Symbol3DMaterial.d.ts +8 -8
  134. package/time/TimeExtent.d.ts +1 -1
  135. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  136. package/views/2d/interactive/SnappingVisualizer2D.js +1 -1
  137. package/views/2d/layers/features/layerAdapters/CatalogFootprintLayerAdapter.js +1 -1
  138. package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +1 -1
  139. package/views/2d/layers/features/layerAdapters/InMemoryLayerAdapter.js +1 -1
  140. package/views/2d/layers/features/layerAdapters/KnowledgeGraphSublayerAdapter.js +1 -1
  141. package/views/2d/layers/features/layerAdapters/OGCFeatureLayerAdapter.js +1 -1
  142. package/views/2d/layers/features/layerAdapters/OrientedImageryLayerAdapter.js +1 -1
  143. package/views/2d/layers/features/layerAdapters/SubtypeGroupLayerAdapter.js +1 -1
  144. package/views/2d/layers/features/sources/FeatureSourceQueryInfo.js +1 -1
  145. package/views/2d/layers/features/sources/strategies/FeaturePagedTileLoadStrategy.js +1 -1
  146. package/views/2d/layers/features/sources/strategies/FeatureSnapshotLoadStrategy.js +1 -1
  147. package/views/2d/layers/features/support/FeatureSetReaderPBF.js +1 -1
  148. package/views/2d/layers/features/support/FeatureSetReaderPBFHeader.js +1 -1
  149. package/views/2d/layers/support/RouteLayerWaypointVisualization.js +1 -1
  150. package/views/3d/analysis/ShadowCast/ShadowCastTooltip.js +1 -1
  151. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
  152. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillVisualization.js +1 -1
  153. package/views/3d/layers/support/featureTileQuery3D.js +1 -1
  154. package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
  155. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  156. package/views/3d/webgl-engine/materials/renderers/VaoWriter.js +1 -1
  157. package/views/Attribution.js +1 -1
  158. package/views/DOMContainer.js +1 -1
  159. package/views/LinkChartView.d.ts +1 -1
  160. package/views/MapView.d.ts +1 -1
  161. package/views/SceneView.d.ts +1 -1
  162. package/views/View.d.ts +1 -1
  163. package/views/input/types.d.ts +1 -1
  164. package/views/interactive/keybindings.js +1 -1
  165. package/views/interactive/snapping/candidates/EdgeSnappingCandidate.js +1 -1
  166. package/views/interactive/snapping/featureSources/GraphicsSnappingSource.js +1 -1
  167. package/views/interactive/snapping/featureSources/queryEngineUtils.js +1 -1
  168. package/views/interactive/snapping/featureSources/snappingCandidateElevationAlignment.js +1 -1
  169. package/views/interactive/snapping/featureSources/snappingCandidateElevationFilter.js +1 -1
  170. package/views/interactive/snapping/hints/LineSnappingHint.js +1 -1
  171. package/views/layers/FeatureLikeLayerView.js +1 -1
  172. package/views/layers/support/WhereClauseVisitor.js +1 -1
  173. package/views/ui/DefaultUI.d.ts +5 -12
  174. package/views/ui/DefaultUI.js +1 -1
  175. package/views/ui/types.d.ts +1 -1
  176. package/webscene/Glow.d.ts +5 -0
  177. package/webscene/SunLighting.d.ts +20 -2
  178. package/webscene/VirtualLighting.d.ts +20 -2
  179. package/widgets/Attribution/AttributionViewModel.d.ts +1 -1
  180. package/widgets/Attribution.d.ts +1 -1
  181. package/widgets/BatchAttributeForm/expressions/ExpressionsManager.js +1 -1
  182. package/widgets/BatchAttributeForm/expressions/ExpressionsModel.js +1 -1
  183. package/widgets/BatchAttributeForm/inputs/FieldInput.d.ts +1 -1
  184. package/widgets/BatchAttributeForm/inputs/InputBase.js +1 -1
  185. package/widgets/BatchAttributeForm/inputs/TextElementInput.d.ts +2 -11
  186. package/widgets/BatchAttributeForm/inputs/TextElementInput.js +1 -1
  187. package/widgets/BatchAttributeForm/inputs/support/inputUtils.js +1 -1
  188. package/widgets/BatchAttributeForm/inputs/support/textElementInputUtils.js +2 -0
  189. package/widgets/BatchAttributeForm/templates/TextElementTemplate.js +1 -1
  190. package/widgets/BatchAttributeForm/templates/support/constants.js +2 -0
  191. package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
  192. package/widgets/BatchAttributeForm/templates/support/hashElementTemplate.js +1 -1
  193. package/widgets/BatchAttributeForm/templates/support/textElementTemplateUtils.js +2 -0
  194. package/widgets/Editor/components/Settings.js +1 -1
  195. package/widgets/Features/FeaturesViewModel.js +1 -1
  196. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  197. package/widgets/OrientedImageryViewer/adapters/sketch/DataCaptureAdapter.js +1 -1
  198. package/widgets/OrientedImageryViewer/adapters/view/MapViewAdapter.js +1 -1
  199. package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
  200. package/widgets/OrientedImageryViewer/services/TransformationService.js +1 -1
  201. package/widgets/OrientedImageryViewer/support/dataCaptureUtils.js +1 -1
  202. package/widgets/OrientedImageryViewer/support/geometryUtils.js +1 -1
  203. package/widgets/OrientedImageryViewer/support/urlUtils.js +1 -1
  204. package/widgets/OrientedImageryViewer/utils.js +1 -1
  205. package/widgets/OrientedImageryViewer.js +1 -1
  206. package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
  207. package/widgets/PanoramicViewer/support/PanoramicMedia.js +1 -1
  208. package/widgets/Print/PrintViewModel.js +1 -1
  209. package/widgets/Sketch.js +1 -1
  210. package/widgets/TimeSlider/TimeSliderViewModel.d.ts +1 -2
  211. package/widgets/TimeSlider.d.ts +5 -6
  212. package/widgets/support/SketchTooltipControls.js +1 -1
  213. package/assets/esri/core/workers/chunks/00112f984698b31909d3.js +0 -1
  214. package/assets/esri/core/workers/chunks/0c8a676599821b9871c2.js +0 -1
  215. package/assets/esri/core/workers/chunks/2b7615cccbaeda1649f3.js +0 -1
  216. package/assets/esri/core/workers/chunks/2f0ea91afc9aa8ee9cad.js +0 -1
  217. package/assets/esri/core/workers/chunks/3a850b5e847b6b0ea53f.js +0 -1
  218. package/assets/esri/core/workers/chunks/449cf6ae6b6e6c2795e5.js +0 -1
  219. package/assets/esri/core/workers/chunks/4dcd5d5ea5875a08a7c7.js +0 -1
  220. package/assets/esri/core/workers/chunks/5058715f32ff026053a9.js +0 -1
  221. package/assets/esri/core/workers/chunks/529dbf16ffbbd39f3fa2.js +0 -1
  222. package/assets/esri/core/workers/chunks/58cf3d35771b87bd74e5.js +0 -1
  223. package/assets/esri/core/workers/chunks/652bb1b53782cdd3103c.js +0 -1
  224. package/assets/esri/core/workers/chunks/6acab23acf3b044f5215.js +0 -1
  225. package/assets/esri/core/workers/chunks/6c2a7bac3f8e32c83292.js +0 -1
  226. package/assets/esri/core/workers/chunks/6d26e5368e8952003669.js +0 -1
  227. package/assets/esri/core/workers/chunks/7cb6ccee9bcef449caea.js +0 -1
  228. package/assets/esri/core/workers/chunks/879e8439a513cb333b61.js +0 -1
  229. package/assets/esri/core/workers/chunks/98c3b7d8db53f0b12642.js +0 -1
  230. package/assets/esri/core/workers/chunks/a027da22acdaa6d6baa3.js +0 -1
  231. package/assets/esri/core/workers/chunks/a6006718fe22d9f2fa87.js +0 -1
  232. package/assets/esri/core/workers/chunks/b60337c471e2b855d02a.js +0 -1
  233. package/assets/esri/core/workers/chunks/bd1bbf1820e12d7a27f6.js +0 -1
  234. package/assets/esri/core/workers/chunks/c88101cb8301f095d037.js +0 -1
  235. package/assets/esri/core/workers/chunks/c9067667290e93407dd7.js +0 -1
  236. package/assets/esri/core/workers/chunks/e59c5bcf91984aa5be6d.js +0 -1
  237. package/assets/esri/core/workers/chunks/e71d08c6f545c2c70174.js +0 -1
  238. package/assets/esri/core/workers/chunks/f347dee99faa9ee5eef1.js +0 -1
  239. package/layers/support/GeoreferenceBase.d.ts +0 -4
  240. package/layers/support/GeoreferenceBase.js +0 -2
  241. package/widgets/BatchAttributeForm/inputs/support/textInputElementUtils.js +0 -2
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import{prefersReducedMotion as i}from"../core/a11yUtils.js";import{createTask as a}from"../core/asyncUtils.js";import s from"../core/Collection.js";import{deprecateWidget as o,deprecatedProperty as n}from"../core/deprecate.js";import r from"../core/Logger.js";import{isAbortError as l}from"../core/promiseUtils.js";import{watch as c,initial as d,syncAndInitial as g,whenOnce as h,on as m,sync as u}from"../core/reactiveUtils.js";import{throttle as v}from"../core/throttle.js";import{property as p,subclass as y}from"../core/accessorSupport/decorators.js";import{or as w}from"../layers/orientedImagery/transformations/utils.js";import _ from"./Expand.js";import T from"./PanoramicVideoViewer.js";import M from"./PanoramicViewer.js";import b from"./Widget.js";import{getAllArcPath as C}from"./OrientedImageryViewer/arcUtils.js";import{getDelegatedEvents as I,defaultImageGeometryField as A,defaultOIObjectIDField as S,segmentArcs as k,featureCircleRadius as f,navigationToolDimensionLength as L,sectorsRadii as V}from"./OrientedImageryViewer/constants.js";import{css as O,navigation as E,navigationToolRotationFrom as F,navigationToolRotationTo as x,root as P}from"./OrientedImageryViewer/css.js";import{isFeatureAttachment as N,loadImageForAttachment as G,getThumbnailPixelBlock as H,renderImageWithRotation as D}from"./OrientedImageryViewer/galleryUtils.js";import j from"./OrientedImageryViewer/OrientedImageryViewerViewModel.js";import $ from"./OrientedImageryViewer/OrientedImageryViewerVisibleElements.js";import{loadAlertComponents as B,Alert as q}from"./OrientedImageryViewer/components/Alert.js";import U from"./OrientedImageryViewer/components/ImageLocationWidget.js";import W from"./OrientedImageryViewer/components/ImageViewer.js";import R from"./OrientedImageryViewer/components/NavigationUI.js";import z from"./OrientedImageryViewer/components/NavigationUI360.js";import{SequentialNavigationUI as Z}from"./OrientedImageryViewer/components/SequentialNavigationUI.js";import{loadVideoEnhancementComponents as J,renderEnhancementSlider as K,VideoEnhancementTools as Q}from"./OrientedImageryViewer/components/VideoEnhancementTools.js";import{NoImageLoadedError as X}from"./OrientedImageryViewer/navigation/errors.js";import{loadCalciteComponents as Y}from"./support/componentsUtils.js";import{globalCss as ee}from"./support/globalCss.js";import{vmEvent as te,messageBundle as ie,tsx as ae}from"./support/widget.js";const se={overlayed:"overlayed"};let oe=class extends b{constructor(e,t){super(e,t),this.dataCaptureEnabled=!1,this.galleryOpened=!1,this.imageEnhancementToolActive=!1,this.videoEnhancementToolActive=!1,this.imageOverlaysOpened=!1,this.navigationToolActive=!1,this.viewModel=new j,this.messagesCommon=null,this.messagesSketch=null,this.pixelMeasurementUnit="meters",this.pixelAreaMeasurementUnit="square-meters",this.selectedGroup=null,this.showCameraLocations=!1,this.showMapFeatures=!1,this.visibleElements=new $,this._imageOverlaysLoaderTask=null,this._imageMeasurementToolsLoaderTask=null,this._navigationSettingsLoaderTask=null,this._navigationTask=null,this._clearMeasurements=()=>{this.viewModel.measureType=null,this.viewModel.triangularMeasurementActive=!1,this.viewModel.clearPreviousMeasurements()},this._clearImageLocation=()=>{this.imageLocationToolActive=!1,this.triangularMeasurementActive=!1},this._createNavigationTask=async e=>(this._navigationTask?.abort(),this._navigationTask=a(async t=>await this.navigate({...e,signal:t})),this._navigationTask.promise),this._navigateNext=async()=>await this._createNavigationTask({step:1}),this._navigatePrevious=async()=>await this._createNavigationTask({step:-1}),this._navigationToolExpanded=!1,this._navigationTool=null,this._galleryController=new AbortController,this._galleryObserver=new IntersectionObserver(this._lazyLoadImage.bind(this)),this._overlayedLayers=new s,this._previousAction=null,this._closeImageSequenceAlert=()=>{this._set("noImageInSequenceError",!1)},this._handleDataCaptureLayerChange=async e=>{if(this.dataCaptureLayer&&await this.stopDataCapture(!0),this.dataCaptureLayer=this.dataCaptureLayer===e?null:e,this.dataCaptureLayer)return this.startDataCapture(this.dataCaptureLayer)},this._handleNavigationSettingsInputChange=(e,t)=>{this.set(`${e}Threshold`,t)},this._handleNavigationSettingsToggle=e=>{this.viewModel.preserveAngle=e},this._handleOverlayLayerDeselect=e=>{const t=e.layer;t===this.dataCaptureLayer&&(this.stopDataCapture(),this.dataCaptureLayer=null),this.removeOverlayedGraphicsOnImage(`${t.id}`)},this._handleOverlayLayerSelect=e=>{const t=e.layer;this.viewModel.overlayMapFeatures(t,this.showMapFeatures),this.addHandles(c(()=>t.visible,()=>{this.viewModel.toggleOverlayMapFeatures(t.id,t.visible,this.showMapFeatures)}),`${se.overlayed}-${t.id}`)},this._highlight=e=>{const t=e.target?.dataset.objectid;t&&this.viewModel.highlight(t)},this._onAction=e=>{const{target:t}=e,{dataset:{action:i}}=t,{_previousAction:a}=this,s=a?.dataset.action,o=s?.includes("draw")??!1,n="select-feature"===s,r=s!==i;switch(i){case"draw-point":case"draw-polygon":case"draw-polyline":{a&&w(n,o&&r)&&(a.active=!1),t.active=!t.active;const e=i.replace("draw-","");this.viewModel.digitizeCreate(e),this._previousAction=t.active?t:null;break}case"save":this.viewModel.saveDrawing();break;case"select-feature":o&&(this._previousAction.active=!1),t.active=!t.active,this.viewModel.toggleSelection(t.active),this._previousAction=t.active?t:null;break;case"delete-feature":this.viewModel.digitizeDelete()}},this._onImageOverlayClosed=()=>{this.imageOverlaysOpened=!1},this._onShowCameraLocationsChanged=e=>{this.showCameraLocations=e},this._onShowMapFeaturesChanged=e=>{this.showMapFeatures=e},this._removeHighlight=()=>this.viewModel.removeHighlight(),this._restoreOverlays=async()=>Promise.all(this._overlayedLayers.map(e=>this.viewModel.overlayMapFeatures(e,this.showMapFeatures))),this._scaleNavigationTool=()=>{this._navigationToolExpanded=!this._navigationToolExpanded},this._sketchLoaderTask=null,this._settingsToggle=null,this._toggleImageNavigation=async e=>{const t=this.navigationMode;this._closeAllImageTools(),this.navigationMode=t!==e?e:null;const{activeViewer:i}=this.viewModel;if(!i)return;const{mode:a,preserveAngle:s}=this.viewModel;if("default"===a)if("directional"===this.navigationMode){const e=await this._loadNavigationSettings(),t="heading"===s||"both"===s,i="pitch"===s||"both"===s,{messages:a,messagesCommon:o}=this,n=new e({cameraHeadingThreshold:this.cameraHeadingThreshold,cameraPitchThreshold:this.cameraPitchThreshold,uiStrings:{configureNavigation:a.configureNavigation,preserveHeading:a.preserveHeading,preserveHeadingDescription:a.preserveHeadingDescription,preservePitch:a.preservePitch,preservePitchDescription:a.preservePitchDescription,settings:o.settings,thresholdLabel:a.thresholdLabel},onInputChange:this._handleNavigationSettingsInputChange,onToggle:this._handleNavigationSettingsToggle,preserveHeading:t,preservePitch:i});this._settingsToggle=new _({content:n,expandIcon:"configure"}),this.viewModel.activeViewer?.ui.add(this._settingsToggle,{position:"top-left"})}else this._settingsToggle&&(this._settingsToggle.expanded=!1,this.viewModel.activeViewer?.ui.remove(this._settingsToggle))},this._toggleImageAttributes=v(this.viewModel.toggleImageAttributes.bind(this.viewModel)),this.navigate=async e=>{let t=null;try{const{currentNode:i}=this.viewModel;if(!i)throw new X;t=await this.viewModel.navigate(i,e)}catch(i){l(i)||r.getLogger(this).error("Error occurred while navigating",i),["NoImageInSequenceError","NoSequenceFoundError"].includes(i.name)&&this._set("noImageInSequenceError",!0)}return t},this.reset=()=>{this._closeAllImageTools(),this.viewModel.reset()},this._loadImageFromGallery=this._loadImageFromGallery.bind(this),this._registerGalleryItem=this._registerGalleryItem.bind(this),this._unregisterGalleryItem=this._unregisterGalleryItem.bind(this),this.loadImageFromSource=this.loadImageFromSource.bind(this),this.updateSuitabilities=this.updateSuitabilities.bind(this),this._handleVideoBrightnessChange=this._handleVideoBrightnessChange.bind(this),this._handleVideoContrastChange=this._handleVideoContrastChange.bind(this),this._handleBrightnessChange=this._handleBrightnessChange.bind(this),this._handleContrastChange=this._handleContrastChange.bind(this),this._handleSharpnessChange=this._handleSharpnessChange.bind(this),this._resetVideoTools=this._resetVideoTools.bind(this),this._toggleEnhancementToolState=this._toggleEnhancementToolState.bind(this),this.announceDeprecation=()=>{o(r.getLogger(this),"Oriented Imagery Viewer","arcgis-oriented-imagery-viewer",{version:"5.0"})}}initialize(){this.addHandles([c(()=>[this.viewModel?.bestFeatureAngle,this._navigationTool],([e,t])=>{t&&this._updateNavigationTool(t)},d),c(()=>this.currentCoverageVisible,e=>this._onCurrentCoverageVisibilityChange(e)),c(()=>this.isAdditionalCoverageVisible,e=>this._onAdditionalCoverageVisibilityChange(e)),c(()=>this.isAdditionalPointSourcesVisible,e=>this._onAdditionalCameraLocationsVisibility(e)),c(()=>({features:this.currentBestFeature,showCameraLocations:this.showCameraLocations,state:this.viewModel.state}),({showCameraLocations:e,state:t})=>{"image-loaded"===t&&this.viewModel.overlayCameraLocations(e)},g),c(()=>({feature:this.currentBestFeature,showMapFeatures:this.showMapFeatures,state:this.viewModel.state}),async(e,t)=>{if(e.showMapFeatures!==t?.showMapFeatures&&await this.viewModel.toggleAllOverlayMapFeatures(e.showMapFeatures),null!=e.feature&&e.feature!==t?.feature){if(this.viewModel.removeAllOverlayMapFeatures(),await h(()=>"image-loaded"===this.viewModel.state),this.dataCaptureLayer&&this.stopDataCapture(),await this._restoreOverlays(),!this.dataCaptureLayer)return;await this.startDataCapture(this.dataCaptureLayer),this._previousAction?.active&&(this._previousAction.active=!1,this._previousAction=null)}},d),m(()=>this.viewModel,"popup-open",async e=>{await(this.view?.openPopup(e))},u),m(()=>this.viewModel,"popup-close",()=>{this.view?.closePopup()},u),this._toggleImageAttributes])}loadDependencies(){return Promise.all([J(),Y({"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group"),action:()=>import("@esri/calcite-components/dist/components/calcite-action"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),shell:()=>import("@esri/calcite-components/dist/components/calcite-shell"),dialog:()=>import("@esri/calcite-components/dist/components/calcite-dialog"),slider:()=>import("@esri/calcite-components/dist/components/calcite-slider")}),B()])}destroy(){this._galleryController.abort(),this._galleryObserver.disconnect(),this.currentBestFeature=null}get accuracyParametersMissing(){return this.viewModel.accuracyParametersMissing}get activeLayer(){return n(r.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){n(r.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeVideoIcon(){const{videoElement:e,videoViewModel:t}=this.viewModel;return e?.loaded&&t?t.videoPaused?"play":"pause":"play"}get activeAudioIcon(){const{videoElement:e,videoViewModel:t}=this.viewModel;return e?.loaded&&t?.videoMuted?"sound-off":"sound"}get cameraHeadingThreshold(){return this.viewModel.cameraHeadingThreshold}set cameraHeadingThreshold(e){this.viewModel.cameraHeadingThreshold=e}get cameraPitchThreshold(){return this.viewModel.cameraPitchThreshold}set cameraPitchThreshold(e){this.viewModel.cameraPitchThreshold=e}get canNavigateSequentially(){const{layer:e}=this;if(!e)return!1;const{fields:t,sequenceOrderField:i}=e;return t.some(({name:e})=>e.toLowerCase()===`${i??"sequenceorder"}`.toLowerCase())}get currentBestFeature(){return this.viewModel.currentBestFeature}set currentBestFeature(e){this.viewModel.currentBestFeature=e}get currentCoverageVisible(){return this.viewModel.currentCoverageVisible}set currentCoverageVisible(e){this.viewModel.currentCoverageVisible=e}get dataCaptureLayer(){return this.viewModel.dataCaptureLayer}set dataCaptureLayer(e){this.viewModel.dataCaptureLayer=e}get depthImageNotSupported(){return this.viewModel.depthImageNotSupported}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get displayMessage(){return this.viewModel.displayMessage}get enhancementToolActive(){return"video"===this.viewModel.mode?this.videoEnhancementToolActive:this.imageEnhancementToolActive}set enhancementToolActive(e){"video"===this.viewModel.mode?this.videoEnhancementToolActive=e:this.imageEnhancementToolActive=e}get features(){return this.viewModel.features}get imagePointsInView(){return this.viewModel.imagePointsInView}get icon(){return"oriented-imagery-widget"}set icon(e){this._overrideIfSome("icon",e)}get imageGalleryEnabled(){return this.viewModel.imageGalleryEnabled}get imageLocationToolActive(){return this.viewModel.imageLocationToolState}set imageLocationToolActive(e){this.viewModel.imageLocationToolState=e}get invalidCameraHeading(){return this.viewModel.invalidCameraHeading}get isAdditionalCoverageVisible(){return this.viewModel.isAdditionalCoverageVisible}set isAdditionalCoverageVisible(e){this.viewModel.isAdditionalCoverageVisible=e}get isAdditionalPointSourcesVisible(){return this.viewModel.isAdditionalPointSourcesVisible}set isAdditionalPointSourcesVisible(e){this.viewModel.isAdditionalPointSourcesVisible=e}get mapImageConversionToolState(){return this.viewModel.mapImageConversionToolState}set mapImageConversionToolState(e){this.viewModel.mapImageConversionToolState=e}get measureType(){return this.viewModel.measureType}set measureType(e){this.viewModel.measureType=e}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get navigationMode(){return this.viewModel.navigationMode}set navigationMode(e){this.viewModel.navigationMode=e}get popupEnabled(){const{popupEnabled:e,state:t}=this.viewModel;return("image-loaded"===t||this.videoLoaded)&&e}get preloadMedia(){return this.viewModel.preloadMedia}set preloadMedia(e){this.viewModel.preloadMedia=e}get referencePoint(){return this.viewModel.referencePoint??null}get sketchViewModel(){return this.viewModel.sketch}get triangularMeasurementActive(){return this.viewModel.triangularMeasurementActive}set triangularMeasurementActive(e){this.viewModel.triangularMeasurementActive=e}get videoLoaded(){const{mode:e,videoElement:t,panoramicVideoLoaded:i}=this.viewModel;return("video"===e&&!0===t?.loaded||i)??!1}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}set determineWorkflowForFeature(e){this.viewModel.determineWorkflowForFeature=e}get determineWorkflowForFeature(){return this.viewModel.determineWorkflowForFeature}get shouldShowSelectedImage(){return this.viewModel.shouldShowSelectedImage}set shouldShowSelectedImage(e){this.viewModel.shouldShowSelectedImage=e}set updateFootprint(e){this.viewModel.updateFootprint=e}get updateFootprint(){return this.viewModel.updateFootprint}get verticalFilterEnabled(){return this.viewModel.verticalFilterEnabled}set verticalFilterEnabled(e){this.viewModel.verticalFilterEnabled=e}_renderActionBar(){const{selectedGroup:e}=this;return ae("calcite-action-bar",{expandDisabled:!0,layout:"horizontal",slot:"action-bar"},!e&&ae("calcite-action-group",null,this._searchGroupToggle(),this._overlaysGroupToggle(),this._navigationGroupToggle(),this._measurementsGroupToggle(),this._utilitiesGroupToggle()),e?ae("calcite-action",{bind:this,icon:"arrow-left",key:"arrow-left",onclick:()=>this._toggleGroupSelection(null),text:this.messages.previous,title:this.messages.previous}):null,"overlays"===e&&ae("calcite-action-group",null,this._currentFootprintToggle(),this._additionalFootprintToggle(),this._additionalPointSourcesToggle(),this._mapImageConversionToggle(),this._imageOverlaysToggle()),"navigation"===e&&ae("calcite-action-group",null,this._directionToolsToggle(),this._navigationToolToggle(),this._imageGalleryToggle()),"measurements"===e&&ae("calcite-action-group",null,this._measurementToolToggle()),"utilities"===e&&ae("calcite-action-group",null,this._imageEnhancementsToggle(),this._videoEnhancementsToggle(),this._openPopupAction()),"search"===e&&ae("calcite-action-group",null,this._exploreImagesToggle(),this._exploreImages3DToggle(),this._showSelectedImageToggle()))}get _activeMeasurementHeading(){const{measureType:e,messages:t,triangularMeasurementActive:i}=this,{groundArea:a,heightAboveGround:s,groundDistance:o,triangulatedAreaHeading:n,triangulatedDistanceHeading:r}=t;if(i)return"area"===e?n:r;switch(e){case"area":return a;case"height":return s;default:return o}}_additionalFootprintToggle(){const{isAdditionalCoverageVisible:e,invalidCameraHeading:t,visibleElements:{additionalFootprintToggle:i}}=this;return i?ae("calcite-action",{active:e,bind:this,class:O.addCoverage,disabled:t,icon:"trapezoid-area",onclick:this._toggleAdditionalCoverage,text:this.messages.additionalFootprints,title:this.messages.additionalFootprints}):null}_additionalPointSourcesToggle(){const{isAdditionalPointSourcesVisible:e,invalidCameraHeading:t,visibleElements:{additionalCameraLocationsToggle:i}}=this;return i?ae("calcite-action",{active:e,bind:this,class:O.addExpPoints,disabled:t,icon:"circle-area",onclick:this._toggleAdditionalCameraLocations,text:this.messages.additionalCameraLocations,title:this.messages.additionalCameraLocations}):null}get _measurementToggle(){const{viewModel:{state:e,measureType:t,currentBestFeatureMeasurementImage:i},triangularMeasurementActive:a,id:s}=this;if("image-loaded"!==e||!t||a&&!i)return;this._imageMeasurementToolsLoaderTask||this._loadImageMeasurementResources();const o=this._imageMeasurementToolsLoaderTask?.value;return o?ae("calcite-dialog",{bind:this,dragEnabled:!0,escapeDisabled:!0,heading:this._activeMeasurementHeading,id:`${s}-${t}-measurement`,open:!0,placement:"bottom-start",resizable:!0,scale:"s",slot:"dialogs",width:"s",onCalciteDialogBeforeClose:this._clearMeasurements},ae(o,{measurementType:t,measurementUnitMessages:this.measurementUnitMessages,messages:this.messages,oiViewModel:this.viewModel})):null}get _renderRoot(){const{viewModel:{state:e},triangularMeasurementActive:t}=this;return ae("calcite-panel",{bind:this,class:t?O.viewerContainerMeasurement:O.viewerContainer,heading:this.visibleElements.title?this.messages.title:void 0,loading:e.includes("loading")&&!t},this.visibleElements.menu?this._renderActionBar():null,ae("calcite-shell",null,ae("calcite-panel",null,this._imageViewer,this._panoramicViewer,this._panoramicVideoViewer,this._videoViewer,this._messageBox,this.invalidCameraHeading?null:[this._imageGalleryPanel,this._renderNavigation,this._imageOverlaysPanel()],this._imageEnhancementTools,this._videoEnhancementTools,this._renderSketch(),this._navigationUI),this._imageViewerTriangular,this._measurementToggle,this._locationToggle,this.invalidCameraHeading?this._renderWarning(this.messages.invalidCameraHeadingWarningTitle,this.messages.invalidCameraHeadingWarningDescription):null,this.depthImageNotSupported?this._renderWarning(this.messages.depthImageNotSupportedTitle,this.messages.depthImageNotSupportedDescription):null,this.noImageInSequenceError?this._renderWarning(this.messages.sequentialNavigationWarning,this.messages.sequentialNavigationWarning,this._closeImageSequenceAlert):null))}_currentFootprintToggle(){const{currentCoverageVisible:e,invalidCameraHeading:t}=this,{currentFootprintToggle:i}=this.visibleElements;return i?ae("calcite-action",{active:e,bind:this,class:O.currentCoverage,disabled:t,icon:"trapezoid-area",onclick:this._toggleCurrentCoverage,text:this.messages.currentFootprint,title:this.messages.currentFootprint}):null}_exploreImagesToggle(){const{exploreImages:e}=this.messages;return this.visibleElements.exploreImages?ae("calcite-action",{active:!this.disabled,bind:this,icon:"oriented-imagery-widget",onclick:this._toggleExploreImages,text:e,title:e}):null}get _imageEnhancementTools(){const{enhancementToolActive:e,viewModel:{brightness:t,contrast:i,sharpness:a,state:s}}=this;return e&&"image-loaded"===s?ae("calcite-panel",{bind:this,class:O.imageEnhancementWrapper,closable:!0,closed:!e,heading:this.messages.imageEnhancement,key:this.messages.imageEnhancement,onCalcitePanelClose:this._toggleEnhancementToolState},ae("div",{class:O.imageEnhancementTools},K({title:this.messages.brightness,value:t,max:10,min:-10,ticks:5,handleChange:this._handleBrightnessChange}),K({title:this.messages.contrast,value:i,max:10,min:-10,ticks:5,handleChange:this._handleContrastChange}),K({title:this.messages.sharpness,value:a,max:1,min:0,ticks:.5,step:.1,handleChange:this._handleSharpnessChange})),ae("calcite-action",{bind:this,icon:"reset",onclick:this._resetImageTools,slot:"header-actions-end",text:this.messagesCommon.reset,title:this.messagesCommon.reset})):null}get _videoEnhancementTools(){const{enhancementToolActive:e,viewModel:{videoViewModel:t,mode:i},messages:{videoEnhancement:a,brightness:s,contrast:o},messagesCommon:{reset:n}}=this;return e&&"video"===i&&t?ae(Q,{brightness:t.videoBrightness,constrast:t.videoContrast,handleBrightnessChange:this._handleVideoBrightnessChange,handleContrastChange:this._handleVideoContrastChange,resetTools:this._resetVideoTools,uiStrings:{videoEnhancement:a,brightness:s,contrast:o,reset:n},videoEnhancementToolActive:e,onClose:this._toggleEnhancementToolState}):null}_imageEnhancementsToggle(){const{state:e,mode:t}=this.viewModel,{enhancementTool:i}=this.visibleElements;return i&&"video"!==t?ae("calcite-action",{active:this.enhancementToolActive,bind:this,disabled:"default"!==t||"image-loaded"!==e,icon:"sliders-horizontal",onclick:this._toggleEnhancementToolState,text:this.messages.imageEnhancement,title:this.messages.imageEnhancement}):null}_exploreImages3DToggle(){const{exploreImages3D:e}=this.messages,t="3d"!==this.view?.type||!this.layer?.verticalSearchRange;return this.visibleElements.exploreImages3D?ae("calcite-action",{active:this.verticalFilterEnabled,bind:this,disabled:t,icon:"surface",onclick:this._toggleVerticalSearchFilter,text:e,title:e}):null}_showSelectedImageToggle(){const{displayImages:e}=this.messages,t=this.viewModel.mode.includes("video");return this.visibleElements.showSelectedImage?ae("calcite-action",{active:this.shouldShowSelectedImage,bind:this,disabled:t,icon:"image",onclick:this._toggleShowSelectedImage,text:e,title:e}):null}_videoEnhancementsToggle(){const{mode:e}=this.viewModel,{videoEnhancement:t}=this.messages,{enhancementTool:i}=this.visibleElements;return i&&"video"===e?ae("calcite-action",{active:this.enhancementToolActive,bind:this,disabled:"video"!==e,icon:"sliders-horizontal",onclick:this._toggleEnhancementToolState,text:t,title:t}):null}get _imageGalleryPanel(){const{container:e,galleryOpened:t,imageGalleryEnabled:i}=this;return i&&t&&e?this._imageGalleryContext:null}get _imageGalleryContext(){const{galleryOpened:e,invalidCameraHeading:t}=this;return ae("calcite-panel",{bind:this,class:O.carousel,closable:!0,closed:!e,disabled:t,heading:this.messages.imageGallery,key:this.messages.imageGallery,onCalcitePanelClose:this._toggleImageGallery},ae("div",{class:O.carouselContainer},this._renderThumbnails))}_imageGalleryToggle(){const{imageGalleryEnabled:e,invalidCameraHeading:t,visibleElements:{imageGallery:i}}=this;return i?ae("calcite-action",{active:this.galleryOpened,bind:this,disabled:!e||t,icon:"images",onclick:this._toggleImageGallery,text:this.messages.imageGallery,title:this.messages.imageGallery}):null}get _imageOverlaysComponent(){const{_imageOverlayMessages:e,_imageOverlaysLoaderTask:t,_overlayedLayers:i,dataCaptureEnabled:s,dataCaptureLayer:o,imageOverlaysOpened:n,showCameraLocations:r,showMapFeatures:l,view:c,layer:d}=this;if(!d)return null;const g=d.imageGeometryField?.length?d.imageGeometryField:A,h=d.imageReferenceField?.length?d.imageReferenceField:S;t||(this._imageOverlaysLoaderTask=a(async()=>(await import("./OrientedImageryViewer/components/ImageOverlays.js")).default));const m=this._imageOverlaysLoaderTask?.value;return m?ae(m,{closed:!n,dataCaptureEnabled:s,dataCaptureLayer:o,imageGeometryField:g,imageReferenceField:h,messages:e,overlayedLayers:i,showCameraLocations:r,showMapFeatures:l,view:c,onDataCaptureLayerChanged:this._handleDataCaptureLayerChange,onFilterCapturedFeatures:this.viewModel.filterCapturedFeatures,onImageOverlaysClosed:this._onImageOverlayClosed,onLayerDeselected:this._handleOverlayLayerDeselect,onLayerSelected:this._handleOverlayLayerSelect,onShowCameraLocationsChanged:this._onShowCameraLocationsChanged,onShowMapFeaturesChanged:this._onShowMapFeaturesChanged}):null}get _navigationUI(){const{navigationMode:e,viewModel:t}=this,{mode:i,state:a}=t;if(e&&("default"===i||"panoramic"===i)&&"image-loaded"===a)return"directional"===e?"default"===i?ae(R,{cameraHeadingThreshold:this.cameraHeadingThreshold,cameraPitchThreshold:this.cameraPitchThreshold,currentNode:this.viewModel.currentNode,navigate:this._createNavigationTask,nodes:this.viewModel.navigationNodes,preserveAngle:this.viewModel.preserveAngle}):ae(z,{currentNode:this.viewModel.currentNode,navigate:this._createNavigationTask,nodes:this.viewModel.navigationNodes}):ae(Z,{layout:"horizontal",uiStrings:{end:this.messages.end,next:this.messages.next,previous:this.messages.previous,start:this.messages.start},onNext:this._navigateNext,onPrev:this._navigatePrevious})}get _imageOverlayMessages(){return{...this.messages,...this.messagesSketch}}get _imageSketchToolsMessages(){return{...this.messagesSketch,...this.messagesCommon}}_imageOverlaysPanel(){const{imageOverlaysOpened:e,viewModel:{state:t}}=this,i=this.classes({[O.imageOverlaysContainer]:!0,[ee.hidden]:!e||"image-loaded"!==t});return ae("div",{class:i,key:this.messages.imageOverlays},this._imageOverlaysComponent)}_imageOverlaysToggle(){const{viewModel:{state:e},imageOverlaysOpened:t,invalidCameraHeading:i,visibleElements:{imageOverlays:a}}=this;return a?ae("calcite-action",{active:t,bind:this,disabled:"image-loaded"!==e||i,icon:"layers",onclick:this._toggleImageOverlays,text:this.messages.imageOverlays,title:this.messages.imageOverlays}):null}get _imageViewer(){const{displayMessage:e,loadImageViewer:t,mode:i,clickAction:a,state:s}=this.viewModel,o=null!=e||"default"!==i||s.includes("loading");return ae(W,{afterCreate:t,clickAction:a,visible:!o})}get _imageViewerTriangular(){const{messages:e,triangularMeasurementActive:t}=this,{displayMessage:i,storeImageMeasurementViewer:a,storePanoramicMeasurementViewer:s,mode:o,state:n,clickAction:r}=this.viewModel,l=null!=i||"none"===o||"video"===o,c=this.classes({[O.viewer]:!l,[O.viewerHidden]:l});return t?ae("calcite-panel",{class:O.viewerContainerMeasurement,heading:e.measurementViewerHeading,loading:n.includes("loading")},ae("calcite-panel",{bind:this,class:c},"default"===o?ae(W,{afterCreate:a,clickAction:r,uiStrings:e}):ae(M,{afterCreate:s,clickAction:r,uiStrings:e}))):null}_utilitiesGroupToggle(){const{utilityTools:e}=this.messages;return this.visibleElements.utilityTools?ae("calcite-action",{bind:this,icon:"gear",key:"utilities-group-toggle",onclick:()=>this._toggleGroupSelection("utilities"),text:e,title:e}):null}_searchGroupToggle(){const{searchTools:e}=this.messages;return this.visibleElements.searchTools?ae("calcite-action",{bind:this,icon:"search",key:"search-group-toggle",onclick:()=>this._toggleGroupSelection("search"),text:e,title:e}):null}get _videoViewer(){const{mode:e,loadVideoViewer:t,videoViewModel:i}=this.viewModel,{control:a,reset:s}=this.messagesCommon,{mute:o,unmute:n}=this.messages,r="video"!==e,l=this.classes({[O.viewer]:!r,[O.viewerHidden]:r}),c="esri-image-viewer";return ae("calcite-panel",{bind:this,class:l},ae("calcite-panel",{afterCreate:t,class:this.classes(ee.widget,c)}),ae("calcite-slider",{bind:this,labelHandles:!0,labelTicks:!0,max:i?.videoDuration,minLabel:"0",value:i?.currentTime??0,onCalciteSliderChange:this._handleVideoSeek}),ae("calcite-action-bar",{expandDisabled:!0,layout:"horizontal"},ae("calcite-action-group",null,ae("calcite-action",{bind:this,icon:this.activeVideoIcon,onclick:()=>i?.playVideoHandler(),text:"Play",title:i?.videoPaused?a.play:a.pause})),ae("calcite-action-group",null,ae("calcite-action",{bind:this,icon:"refresh",onclick:()=>i?.rewindVideoHandler(),text:"Rewind",title:s})),ae("calcite-action-group",null,ae("calcite-action",{bind:this,icon:this.activeAudioIcon,onclick:()=>i?.toggleAudio(),text:"Audio",title:i?.videoMuted?o:n}))))}get _locationToggle(){const{viewModel:{state:e,groundCoordinates:t,groundCoordinatesAccuracy:i,triangulatedPoint:a},imageLocationToolActive:s,triangularMeasurementActive:o,messages:{groundLocation:n,triangulatedLocationHeading:r}}=this;if("image-loaded"!==e||!t||!s)return;let l=t;if(o){if(!a)return;l=a}return ae("calcite-dialog",{bind:this,dragEnabled:!0,escapeDisabled:!0,heading:o?r:n,id:n,open:!0,placement:"bottom-start",resizable:!0,scale:"s",slot:"dialogs",width:"s",onCalciteDialogBeforeClose:this._clearImageLocation},ae(U,{accuracy:i,groundCoordinates:l,messages:this.messages}))}_mapImageConversionToggle(){const{mapImageConversionToolState:e,viewModel:{state:t,disabled:i},invalidCameraHeading:a,visibleElements:{mapImageConversionTool:s}}=this;return s?ae("calcite-action",{active:e,bind:this,disabled:"image-loaded"!==t||a||i,icon:"image-pin",onclick:this._toggleMapImageConversionToolState,text:this.messages.mapImageConversionTool,title:this.messages.mapImageConversionTool}):null}_measurementToolToggle(){const{measureType:e,viewModel:t,accuracyParametersMissing:i,messages:a,triangularMeasurementActive:s}=this,{state:o}=t,{groundDistance:n,groundArea:r,heightAboveGround:l,groundLocation:c,triangulatedDistanceHeading:d,triangulatedAreaHeading:g,triangulatedLocationHeading:h}=a,m="image-loaded"!==o||i;return ae("calcite-action-group",{key:"measurement-tools",scale:"m"},ae("calcite-action",{active:"distance"===e&&!s,bind:this,disabled:m,icon:"measure-line",key:"distance-measurement",onclick:e=>this._toggleMeasurementSketch(e,"distance"),text:n,title:n}),ae("calcite-action",{active:"area"===e&&!s,bind:this,disabled:m,icon:"measure-area",key:"area-measurement",onclick:e=>this._toggleMeasurementSketch(e,"area"),text:r,title:r}),ae("calcite-action",{active:"height"===e,bind:this,disabled:m,icon:"measure-building-height-top-base",key:"height-measurement",onclick:e=>this._toggleMeasurementSketch(e,"height"),text:l,title:l}),ae("calcite-action",{active:!!this.imageLocationToolActive&&!s,bind:this,disabled:m,icon:"pin-tear",key:"surface-location",onclick:this._toggleLocationTool,text:c,title:c}),ae("calcite-action",{active:!!s&&this.imageLocationToolActive,bind:this,disabled:m,icon:"dual-image-location",key:"triangular-location",onclick:this._toggleTriangularLocation,text:h,title:h}),ae("calcite-action",{active:!!s&&"distance"===this.measureType,bind:this,disabled:m,icon:"dual-image-distance",key:"triangular-distance",onclick:this._toggleTriangularDistanceMeasurements,text:d,title:d}),ae("calcite-action",{active:!!s&&"area"===this.measureType,bind:this,disabled:m,icon:"dual-image-area",key:"triangular-area",onclick:this._toggleTriangularAreaMeasurements,text:g,title:g}))}get _messageBox(){const{messages:e,viewModel:{displayMessage:i,mode:a}}=this;if(!i||"video"===a)return null;const{data:s,key:o,map:n}=i,r=`${n?t(e[o],n):e[o]}`;return ae("span",{class:O.messageBox},s?`${r} ${s}`:r)}async _loadNavigationSettings(){return this._navigationSettingsLoaderTask||(this._navigationSettingsLoaderTask=a(async()=>(await import("./OrientedImageryViewer/components/NavigationSettings.js")).default)),await this._navigationSettingsLoaderTask.promise}_measurementsGroupToggle(){const{measurementTools:e}=this.messages,{state:t,accuracyParametersMissing:i}=this.viewModel,a="image-loaded"!==t||i;return this.visibleElements.measurementTools?ae("calcite-action",{bind:this,disabled:a,icon:"measure-line",key:"measurements-group-toggle",onclick:()=>this._toggleGroupSelection("measurements"),text:e,title:e}):null}_navigationGroupToggle(){const{imageNavigation:e}=this.messages;return this.visibleElements.imageNavigationTools?ae("calcite-action",{bind:this,icon:"absolute-direction",key:"navigation-group-toggle",onclick:()=>this._toggleGroupSelection("navigation"),text:e,title:e}):null}_navigationToolToggle(){const{state:e}=this.viewModel,{visibleElements:{navigationTool:t},videoLoaded:i}=this;return t?ae("calcite-action",{active:this.navigationToolActive,bind:this,disabled:"image-loaded"!==e&&!i||this.invalidCameraHeading,icon:"explore",onclick:this._toggleNavigationTool,text:this.messages.navigationTool,title:this.messages.navigationTool}):null}_directionToolsToggle(){const{messages:e,viewModel:t,visibleElements:i}=this,{directionalNavigation:a,sequentialNavigation:s}=i,{state:o}=t,{directionalNavigation:n,directionalNavigationDescription:r,sequentialNavigation:l,sequentialNavigationDescription:c}=e;return ae("calcite-action-group",{key:"navigation-tools",scale:"m"},a?ae("calcite-action",{active:"directional"===this.navigationMode,bind:this,disabled:"image-loaded"!==o||this.invalidCameraHeading,icon:"directional-navigation",onclick:()=>{this._toggleImageNavigation("directional")},text:r,title:n}):null,s?ae("calcite-action",{active:"sequential"===this.navigationMode,bind:this,disabled:"image-loaded"!==o||this.invalidCameraHeading||!this.canNavigateSequentially,icon:"sequential-navigation",onclick:()=>{this._toggleImageNavigation("sequential")},text:c,title:l}):null)}_overlaysGroupToggle(){const{overlays:e}=this.messages;return this.visibleElements.overlays?ae("calcite-action",{bind:this,icon:"trapezoid-area",key:"overlays-group-toggle",onclick:()=>this._toggleGroupSelection("overlays"),text:e,title:e}):null}_openPopupAction(){const{showPopupsAction:e}=this.visibleElements;return e?ae("calcite-action",{bind:this,disabled:!this.popupEnabled,icon:"popup",onclick:this._toggleImageAttributes,text:this.messages.showPopups,title:this.messages.showPopups}):null}get _panoramicVideoViewer(){const{displayMessage:e,loadPanoramicVideoViewer:t,mode:i,clickAction:a,state:s,currentBestFeature:o}=this.viewModel,n=o?.attributes.imagePath,r=null!=e||"panoramic-video"!==i||s.includes("loading")||!n;return ae(T,{afterCreate:t,clickAction:a,oiViewModel:this.viewModel,videoSource:n,visible:!r})}get _panoramicViewer(){const{displayMessage:e,loadPanoramicViewer:t,mode:i,clickAction:a,state:s}=this.viewModel,o=null!=e||"panoramic"!==i||s.includes("loading");return ae(M,{afterCreate:t,clickAction:a,visible:!o})}get noImageInSequenceError(){return this._get("noImageInSequenceError")??!1}_activateTriangulatedImageLocationTool(){this.navigationToolActive=!0,this.imageLocationToolActive=!0}_activateTriangulatedImageLocationWorkflow(e,t){this._closeAllImageTools(),this.imageLocationToolActive=!0,this.triangularMeasurementActive=!e,this.navigationToolActive=!!t||!t}_closeImageToolsAndToggleNavigation(e,t){this._closeAllImageTools(),this.triangularMeasurementActive=!e,this.navigationToolActive=!t}_resetMeasureTypeAndActivateImageLocationTool(){this.measureType=null,this.imageLocationToolActive=!0}_closeAllImageTools(){this.enhancementToolActive=!1,this.navigationToolActive=!1,this.imageOverlaysOpened=!1,this.galleryOpened=!1,this.measureType=null,this.imageLocationToolActive=!1,this.navigationMode=null,this.triangularMeasurementActive=!1,this._settingsToggle&&(this._settingsToggle.expanded=!1,this.viewModel.activeViewer?.ui.remove(this._settingsToggle))}_handleBrightnessChange(e){this.viewModel.brightness=e.currentTarget.value??0}_handleVideoBrightnessChange(e){this.viewModel.videoViewModel?.handleVideoBrightnessChange(e.target.value)}_handleContrastChange(e){this.viewModel.contrast=e.currentTarget.value??0}_handleVideoContrastChange(e){this.viewModel.videoViewModel?.handleVideoContrastChange(e.target.value)}_handleVideoSeek(e){const t=this.viewModel?.videoElement?.content;t&&(t.currentTime=e.target.value,t.play())}_handleSharpnessChange(e){this.viewModel.sharpness=e.currentTarget.value??0}_lazyLoadImage(e,t){e.forEach(async e=>{if(e.isIntersecting){const a=e.target,s=a.getAttribute("data-src"),o=a.getAttribute("data-rotation"),n=a.getAttribute("data-objectid"),c=o?parseFloat(o)%360:0,{layer:d,_galleryController:{signal:g}}=this;if(!s||!n)return;let h;try{h=N(s)?await G(d,n,{signal:g}):await H(s,{signal:g})}catch(i){l(i)||r.getLogger("esri.widgets.OrientedImageryViewer").error("#lazyLoadImage()",i)}finally{t.unobserve(a)}if(!h)return;D(h,a,c)}})}_loadImageFromGallery(e){const{target:t}=e;if(!t)return;const i=t.getAttribute("data-objectid");i&&this.viewModel.currentBestFeature?.attributes.objectId!==Number(i)&&this.viewModel.selectBestFeature(i)}_loadImageMeasurementResources(){this._imageMeasurementToolsLoaderTask=a(async()=>{const{default:e}=await import("./OrientedImageryViewer/components/ImageMeasurementWidget.js");return e})}_loadSketchResources(){this._sketchLoaderTask=a(async()=>(await import("./OrientedImageryViewer/components/SketchTools.js")).default)}_onAdditionalCoverageVisibilityChange(e){this.viewModel.setAdditionalCoverageVisibility(e)}_onAdditionalCameraLocationsVisibility(e){this.viewModel.setAdditionalCameraLocationsVisibility(e)}_onCurrentCoverageVisibilityChange(e){this.viewModel.setCurrentCoverageVisibility(e)}_registerGalleryItem(e){this._galleryObserver.observe(e)}_renderWarning(e,t,i){const{viewModel:{state:a}}=this;return"image-loaded"===a?ae(q,{icon:"exclamation-mark-triangle-f",kind:"warning",message:t,open:!0,title:e,tooltip:t,topLayerDisabled:this.topLayerDisabled,onClose:i}):null}get _renderNavigation(){const{viewModel:{sectorData:e,navigatorCurrentBestFeature:t,currentBestFeature:a,state:s}}=this;if(!this.container||!a)return null;let o,n,r,l,c;if(t){const{x:e,y:i,direction:a}=t,[s,d,g,h]=k[a];o=`M ${e} ${i} L ${s} ${d} A ${V[2]} ${V[2]} 0 0 1 ${g} ${h} Z`,n=e,l=i,r=k[a][4],c=k[a][5]}const d=e=>{const t=e.target.dataset?.sector;t&&this.viewModel.handleSectorClick(+t)},g=e=>{const t=e.target.dataset;if(!t)return;const{featureIndexInSector:i,sector:a}=t;i&&a&&this.viewModel.handleFeatureClick({sector:a,featureIndexInSector:+i})},h=e=>{e.removeEventListener("click",g)},m=a.attributes.objectId,u=e?.map(e=>e?.items).filter(Boolean).flatMap(e=>e?.map(({x:e,y:t,objectID:i,featureIndexInSector:a,sector:s})=>ae("circle",{afterRemoved:h,class:this.classes(O.feature,{selected:m===i}),cx:e,cy:t,"data-feature-index-in-sector":a,"data-sector":s,key:`${O.feature}-${i}`,onclick:g,r:f}))),v=e=>{e.removeEventListener("click",d)},p=this.classes({[O.navigationWrapper]:!0,[O.navigationZoomed]:this._navigationToolExpanded});return this.navigationToolActive&&("image-loaded"===s||this.videoLoaded)?ae("div",{bind:this,class:p,key:this.messages.navigationTool},ae("svg",{afterCreate:e=>this._storeNavigationToolReference(e),class:i()?E:O.rotateWithAnimation,focusable:"false",height:L,role:"img",width:L,xmlns:"http://www.w3.org/2000/svg"},ae("defs",null,ae("linearGradient",{gradientUnits:"userSpaceOnUse",id:`${this.id}-coverage-fill`,x1:n,x2:r,y1:l,y2:c},ae("stop",{class:O.navigationPathOffset0,offset:0}),ae("stop",{class:O.navigationPathOffset1,offset:1}))),ae("g",null,ae("circle",{class:this.classes(O.sector,O.outerSector),cx:V[3],cy:V[3],onclick:this._scaleNavigationTool,r:V[3]}),ae("circle",{class:O.sector,cx:V[3],cy:V[3],r:V[2]}),ae("circle",{class:O.sector,cx:V[3],cy:V[3],r:V[1]}),ae("circle",{class:O.sector,cx:V[3],cy:V[3],r:V[0]}),ae("path",{class:O.pointer,d:"M 56.5 6.06217782649107 L 60 0 L 63.5 6.06217782649107 Z",key:`${O.pointer}-west`}),ae("path",{class:this.classes(O.pointer,O.north),d:"M 113.93782217350893 56.5 L 120 60 L 113.93782217350893 63.5 Z",key:`${O.pointer}-north`}),ae("path",{class:O.pointer,d:"M 56.5 113.93782217350893 L 60 120 L 63.5 113.93782217350893 Z",key:`${O.pointer}-east`}),ae("path",{class:O.pointer,d:"M 6.06217782649107 56.5 L 0 60 L 6.06217782649107 63.5 Z",key:`${O.pointer}-south`}),ae("path",{class:this.classes(O.sector,O.sectorSeparator),d:"M 23.937554159486076 23.937554159486076 L 96.06244584051393 96.06244584051393 M 23.937554159486076 96.06244584051393 L 96.06244584051393 23.937554159486076",key:O.sectorSeparator}),C([V[2],V[1],V[0]],V[3],V[3]).map((t,i)=>ae("path",{afterRemoved:v,class:this.classes(O.sector,e?.[i]?.length?O.sectorEnabled:O.sectorDisabled),d:t,"data-sector":`${i}`,key:`${O.sector}-${i}`,onclick:d})),ae("path",{class:this.classes(O.sector,O.sectorCross),d:"M 56.4 56.4 L 63.53 63.53 M 63.53 56.4 L 56.4 63.53",key:O.sectorCross}),u,a.attributes.cameraPitch>=5&&o?ae("path",{class:O.selectedFeaturePath,d:o,fill:`url(#${this.id}-coverage-fill)`,key:O.selectedFeaturePath}):null))):null}_renderSketch(){const{dataCaptureLayer:e,imageOverlaysOpened:t}=this;if(!e||t)return null;if(this._sketchLoaderTask||this._loadSketchResources(),!this._sketchLoaderTask?.value)return null;const{geometryType:i}=e,a="point"===i?"pin":"polyline"===i?"line":"polygon",s=this._sketchLoaderTask.value;return ae("div",{class:O.sketchTools},ae(s,{icon:a,messages:this._imageSketchToolsMessages,type:i,onAction:this._onAction}))}get _renderThumbnails(){const{currentBestFeature:e,thumbnails:t}=this.viewModel;return e?ae("div",{class:O.carouselContent},t?.items.map(({url:t,objectId:i,rotation:a},s)=>ae("div",{class:`${O.carouselItemWrapper}${e.attributes.objectId===i?"--selected":""}`,key:`${O.carouselItemWrapper}-${s}`},ae("canvas",{afterCreate:this._registerGalleryItem,afterRemoved:this._unregisterGalleryItem,alt:`thumbnail-${i}`,class:O.carouselItem,"data-objectid":`${i}`,"data-rotation":`${a}`,"data-src":t,onclick:this._loadImageFromGallery,onmouseenter:this._highlight,onmouseleave:this._removeHighlight})))):null}_resetImageTools(){this.viewModel.sharpness=this.viewModel.brightness=this.viewModel.contrast=0}_resetVideoTools(){this.viewModel.videoViewModel?.resetVideoEnhancementTools()}_storeNavigationToolReference(e){this._navigationTool=e}_toggleAdditionalCameraLocations(){this.isAdditionalPointSourcesVisible=!this.isAdditionalPointSourcesVisible}_toggleAdditionalCoverage(){this.isAdditionalCoverageVisible=!this.isAdditionalCoverageVisible}_toggleCurrentCoverage(){this.currentCoverageVisible=!this.currentCoverageVisible}_toggleShowSelectedImage(){this.shouldShowSelectedImage=!this.shouldShowSelectedImage,this._toggleDisabledViewer(this.shouldShowSelectedImage)}_toggleVerticalSearchFilter(){this.verticalFilterEnabled=!this.verticalFilterEnabled,this._toggleDisabledViewer(this.verticalFilterEnabled)}_toggleDisabledViewer(e){e&&(this.disabled=!1)}_toggleEnhancementToolState(e){e.stopPropagation();const t=this.enhancementToolActive;this._closeAllImageTools(),this.enhancementToolActive=!t}_toggleExploreImages(){this.disabled=!this.disabled,this.disabled&&(this.shouldShowSelectedImage=!1,this.verticalFilterEnabled=!1)}_toggleGroupSelection(e){this.selectedGroup=e}_toggleImageOverlays(e){e.stopPropagation();const t=this.imageOverlaysOpened;this._closeAllImageTools(),this.imageOverlaysOpened=!t}_toggleImageGallery(e){e.stopPropagation();const t=this.galleryOpened;this._closeAllImageTools(),this.galleryOpened=!!this.imageGalleryEnabled&&!t}_toggleLocationTool(e){const t=this.imageLocationToolActive,i=this.triangularMeasurementActive&&t;this._closeAllImageTools(),this.imageLocationToolActive=i||!t,e.stopPropagation()}_toggleMeasurementSketch(e,t){e.stopPropagation();const i=this.measureType,a=this.triangularMeasurementActive;this._closeAllImageTools(),this.measureType=i!==t||a?t:null,this.measureType===t&&(this.viewModel.displayNewMeasurementButton=!0)}_toggleNavigationTool(){const e=this.navigationToolActive;this._closeAllImageTools(),this.navigationToolActive=!e}_toggleMapImageConversionToolState(){this.mapImageConversionToolState=!this.mapImageConversionToolState}_toggleTriangularAreaMeasurements(){this._toggleTriangularMeasurements("area")}_toggleTriangularDistanceMeasurements(){this._toggleTriangularMeasurements("distance")}_toggleTriangularLocation(){const e=this.triangularMeasurementActive,t=this.navigationToolActive;e?null===this.measureType?this.imageLocationToolActive?this._closeImageToolsAndToggleNavigation(e,t):this._activateTriangulatedImageLocationTool():this._resetMeasureTypeAndActivateImageLocationTool():this._activateTriangulatedImageLocationWorkflow(e,t)}_toggleTriangularMeasurements(e){const t=this.triangularMeasurementActive,i=this.viewModel.measureType,a=this.navigationToolActive;t?e===i?(this._closeAllImageTools(),this.triangularMeasurementActive=!t,this.navigationToolActive=!a):(this.imageLocationToolActive=!1,this.measureType=e):(this._closeAllImageTools(),this.measureType=e,this.triangularMeasurementActive=!t,this.navigationToolActive=!!a||!a)}_unregisterGalleryItem(e){this._galleryObserver.unobserve(e)}_updateNavigationTool(e){const{previousFeatureAngle:t,bestFeatureAngle:i}=this.viewModel,a=(i-t+540)%360-180;e.style.setProperty(F,`${t}deg`),e.style.setProperty(x,`${t+a}deg`)}async loadBestImage(e){return this.viewModel.loadBestImage(e)}loadImageFromSource(e,t,i){return"default"===e?this.viewModel.loadMediaSource(t,i):this.viewModel.loadPanoramicMediaSource(t,i)}async overlayMapFeatures(e,t){return this.removeHandles(`${se.overlayed}-${e.id}`),this.addHandles(c(()=>e.visible,()=>{this.viewModel.toggleOverlayMapFeatures(e.id,e.visible,this.showMapFeatures)}),`${se.overlayed}-${e.id}`),this._overlayedLayers.add(e),this.viewModel.overlayMapFeatures(e,t&&this.showMapFeatures)}async plotMapPoint(e){return this.viewModel.plotMapPoint(e)}plotReferencePointOnGround(e){this.viewModel.plotReferencePointOnGround(e)}plotReferencePointOnImage(e){this.viewModel.plotReferencePointOnImage(e)}removeOverlayedGraphicsOnImage(e){this.removeHandles(`${se.overlayed}-${e}`),this._overlayedLayers.remove(this._overlayedLayers.find(t=>t.id===e)),this.viewModel.removeOverlayedGraphicsOnImage(e)}resetImage(){this.viewModel.resetImage()}render(){return ae("div",{class:this.classes(ee.widget,P)},this._renderRoot)}async showImageByObjectId(e,t){return this.viewModel.showImageByObjectId(e,t)}async startDataCapture(e){return this.viewModel.startDataCapture(e)}async stopDataCapture(e){return this.viewModel.stopDataCapture(e)}updateSuitabilities(e){this.viewModel.updateSuitabilities(e)}};e([p({readOnly:!0})],oe.prototype,"accuracyParametersMissing",null),e([p()],oe.prototype,"activeLayer",null),e([p()],oe.prototype,"activeVideoIcon",null),e([p()],oe.prototype,"activeAudioIcon",null),e([p()],oe.prototype,"cameraHeadingThreshold",null),e([p()],oe.prototype,"cameraPitchThreshold",null),e([p()],oe.prototype,"canNavigateSequentially",null),e([p()],oe.prototype,"currentBestFeature",null),e([p()],oe.prototype,"currentCoverageVisible",null),e([p()],oe.prototype,"dataCaptureEnabled",void 0),e([p()],oe.prototype,"dataCaptureLayer",null),e([p()],oe.prototype,"depthImageNotSupported",null),e([p()],oe.prototype,"disabled",null),e([p()],oe.prototype,"enhancementToolActive",null),e([p()],oe.prototype,"features",null),e([p()],oe.prototype,"imagePointsInView",null),e([p()],oe.prototype,"galleryOpened",void 0),e([p()],oe.prototype,"icon",null),e([p()],oe.prototype,"imageEnhancementToolActive",void 0),e([p()],oe.prototype,"videoEnhancementToolActive",void 0),e([p({readOnly:!0})],oe.prototype,"imageGalleryEnabled",null),e([p()],oe.prototype,"imageLocationToolActive",null),e([p()],oe.prototype,"imageOverlaysOpened",void 0),e([p({readOnly:!0})],oe.prototype,"invalidCameraHeading",null),e([p()],oe.prototype,"isAdditionalCoverageVisible",null),e([p()],oe.prototype,"isAdditionalPointSourcesVisible",null),e([p()],oe.prototype,"mapImageConversionToolState",null),e([p()],oe.prototype,"measureType",null),e([p()],oe.prototype,"layer",null),e([p()],oe.prototype,"navigationToolActive",void 0),e([p()],oe.prototype,"navigationMode",null),e([te(I()),p({type:j})],oe.prototype,"viewModel",void 0),e([p(),ie("esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer")],oe.prototype,"messages",void 0),e([p(),ie("esri/core/t9n/Units")],oe.prototype,"measurementUnitMessages",void 0),e([p(),ie("esri/t9n/common")],oe.prototype,"messagesCommon",void 0),e([p(),ie("esri/widgets/Sketch/t9n/Sketch")],oe.prototype,"messagesSketch",void 0),e([p()],oe.prototype,"pixelMeasurementUnit",void 0),e([p()],oe.prototype,"pixelAreaMeasurementUnit",void 0),e([p({readOnly:!0})],oe.prototype,"popupEnabled",null),e([p()],oe.prototype,"preloadMedia",null),e([p()],oe.prototype,"referencePoint",null),e([p()],oe.prototype,"selectedGroup",void 0),e([p()],oe.prototype,"showCameraLocations",void 0),e([p()],oe.prototype,"showMapFeatures",void 0),e([te(["create","delete","redo","undo","update"]),p({readOnly:!0})],oe.prototype,"sketchViewModel",null),e([p()],oe.prototype,"triangularMeasurementActive",null),e([p()],oe.prototype,"videoLoaded",null),e([p()],oe.prototype,"view",null),e([p({type:$,nonNullable:!0})],oe.prototype,"visibleElements",void 0),e([p()],oe.prototype,"determineWorkflowForFeature",null),e([p()],oe.prototype,"shouldShowSelectedImage",null),e([p()],oe.prototype,"updateFootprint",null),e([p()],oe.prototype,"verticalFilterEnabled",null),e([p()],oe.prototype,"_activeMeasurementHeading",null),e([p()],oe.prototype,"_imageOverlaysLoaderTask",void 0),e([p()],oe.prototype,"_imageMeasurementToolsLoaderTask",void 0),e([p()],oe.prototype,"_navigationSettingsLoaderTask",void 0),e([p()],oe.prototype,"_navigationTask",void 0),e([p()],oe.prototype,"_measurementToggle",null),e([p()],oe.prototype,"_renderRoot",null),e([p()],oe.prototype,"_imageEnhancementTools",null),e([p()],oe.prototype,"_videoEnhancementTools",null),e([p()],oe.prototype,"_imageGalleryPanel",null),e([p()],oe.prototype,"_imageGalleryContext",null),e([p()],oe.prototype,"_imageOverlaysComponent",null),e([p()],oe.prototype,"_navigationUI",null),e([p()],oe.prototype,"_imageOverlayMessages",null),e([p()],oe.prototype,"_imageSketchToolsMessages",null),e([p()],oe.prototype,"_imageViewer",null),e([p()],oe.prototype,"_imageViewerTriangular",null),e([p()],oe.prototype,"_videoViewer",null),e([p()],oe.prototype,"_locationToggle",null),e([p()],oe.prototype,"_messageBox",null),e([p()],oe.prototype,"_navigationToolExpanded",void 0),e([p()],oe.prototype,"_navigationTool",void 0),e([p()],oe.prototype,"_panoramicVideoViewer",null),e([p()],oe.prototype,"_panoramicViewer",null),e([p({readOnly:!0})],oe.prototype,"noImageInSequenceError",null),e([p()],oe.prototype,"_renderNavigation",null),e([p()],oe.prototype,"_renderThumbnails",null),e([p()],oe.prototype,"_sketchLoaderTask",void 0),oe=e([y("esri.widgets.OrientedImageryViewer")],oe);const ne=oe;export{ne as default};
2
+ import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import{prefersReducedMotion as i}from"../core/a11yUtils.js";import{createTask as a}from"../core/asyncUtils.js";import s from"../core/Collection.js";import{deprecateWidget as o,deprecatedProperty as n}from"../core/deprecate.js";import r from"../core/Logger.js";import{isAbortError as l}from"../core/promiseUtils.js";import{watch as c,initial as d,syncAndInitial as g,whenOnce as h,on as m,sync as u}from"../core/reactiveUtils.js";import{throttle as v}from"../core/throttle.js";import{property as p,subclass as y}from"../core/accessorSupport/decorators.js";import{or as w}from"../layers/orientedImagery/transformations/utils.js";import _ from"./Expand.js";import T from"./PanoramicVideoViewer.js";import M from"./PanoramicViewer.js";import b from"./Widget.js";import{getAllArcPath as C}from"./OrientedImageryViewer/arcUtils.js";import{getDelegatedEvents as I,defaultImageGeometryField as A,defaultOIObjectIDField as S,segmentArcs as k,featureCircleRadius as f,navigationToolDimensionLength as L,sectorsRadii as V}from"./OrientedImageryViewer/constants.js";import{css as O,navigation as E,navigationToolRotationFrom as F,navigationToolRotationTo as x,root as P}from"./OrientedImageryViewer/css.js";import{isFeatureAttachment as N,loadImageForAttachment as G,getThumbnailPixelBlock as H,renderImageWithRotation as D}from"./OrientedImageryViewer/galleryUtils.js";import j from"./OrientedImageryViewer/OrientedImageryViewerViewModel.js";import $ from"./OrientedImageryViewer/OrientedImageryViewerVisibleElements.js";import{loadAlertComponents as B,Alert as q}from"./OrientedImageryViewer/components/Alert.js";import U from"./OrientedImageryViewer/components/ImageLocationWidget.js";import W from"./OrientedImageryViewer/components/ImageViewer.js";import R from"./OrientedImageryViewer/components/NavigationUI.js";import z from"./OrientedImageryViewer/components/NavigationUI360.js";import{SequentialNavigationUI as Z}from"./OrientedImageryViewer/components/SequentialNavigationUI.js";import{loadVideoEnhancementComponents as J,renderEnhancementSlider as K,VideoEnhancementTools as Q}from"./OrientedImageryViewer/components/VideoEnhancementTools.js";import{NoImageLoadedError as X}from"./OrientedImageryViewer/navigation/errors.js";import{loadCalciteComponents as Y}from"./support/componentsUtils.js";import{globalCss as ee}from"./support/globalCss.js";import{vmEvent as te,messageBundle as ie,tsx as ae}from"./support/widget.js";const se={overlayed:"overlayed"};let oe=class extends b{constructor(e,t){super(e,t),this.dataCaptureEnabled=!1,this.galleryOpened=!1,this.imageEnhancementToolActive=!1,this.videoEnhancementToolActive=!1,this.imageOverlaysOpened=!1,this.navigationToolActive=!1,this.viewModel=new j,this.messagesCommon=null,this.messagesSketch=null,this.pixelMeasurementUnit="meters",this.pixelAreaMeasurementUnit="square-meters",this.selectedGroup=null,this.showCameraLocations=!1,this.showMapFeatures=!1,this.visibleElements=new $,this._imageOverlaysLoaderTask=null,this._imageMeasurementToolsLoaderTask=null,this._navigationSettingsLoaderTask=null,this._navigationTask=null,this._clearMeasurements=()=>{this.viewModel.measureType=null,this.viewModel.triangularMeasurementActive=!1,this.viewModel.clearPreviousMeasurements()},this._clearImageLocation=()=>{this.imageLocationToolActive=!1,this.triangularMeasurementActive=!1},this._createNavigationTask=async e=>(this._navigationTask?.abort(),this._navigationTask=a(async t=>await this.navigate({...e,signal:t})),this._navigationTask.promise),this._navigateNext=async()=>await this._createNavigationTask({step:1}),this._navigatePrevious=async()=>await this._createNavigationTask({step:-1}),this._navigationToolExpanded=!1,this._navigationTool=null,this._galleryController=new AbortController,this._galleryObserver=new IntersectionObserver(this._lazyLoadImage.bind(this)),this._overlayedLayers=new s,this._previousAction=null,this._closeImageSequenceAlert=()=>{this._set("noImageInSequenceError",!1)},this._handleDataCaptureLayerChange=async e=>{if(this.dataCaptureLayer&&await this.stopDataCapture(!0),this.dataCaptureLayer=this.dataCaptureLayer===e?null:e,this.dataCaptureLayer)return this.startDataCapture(this.dataCaptureLayer)},this._handleNavigationSettingsInputChange=(e,t)=>{this.set(`${e}Threshold`,t)},this._handleNavigationSettingsToggle=e=>{this.viewModel.preserveAngle=e},this._handleOverlayLayerDeselect=e=>{const t=e.layer;t===this.dataCaptureLayer&&(this.stopDataCapture(),this.dataCaptureLayer=null),this.removeOverlayedGraphicsOnImage(`${t.id}`)},this._handleOverlayLayerSelect=e=>{const t=e.layer;this.viewModel.overlayMapFeatures(t,this.showMapFeatures),this.addHandles(c(()=>t.visible,()=>{this.viewModel.toggleOverlayMapFeatures(t.id,t.visible,this.showMapFeatures)}),`${se.overlayed}-${t.id}`)},this._highlight=e=>{const t=e.target?.dataset.objectid;t&&this.viewModel.highlight(t)},this._onAction=e=>{const{target:t}=e,{dataset:{action:i}}=t,{_previousAction:a}=this,s=a?.dataset.action,o=s?.includes("draw")??!1,n="select-feature"===s,r=s!==i;switch(i){case"draw-point":case"draw-polygon":case"draw-polyline":{a&&w(n,o&&r)&&(a.active=!1),t.active=!t.active;const e=i.replace("draw-","");this.viewModel.digitizeCreate(e),this._previousAction=t.active?t:null;break}case"save":this.viewModel.saveDrawing();break;case"select-feature":o&&(this._previousAction.active=!1),t.active=!t.active,this.viewModel.toggleSelection(t.active),this._previousAction=t.active?t:null;break;case"delete-feature":this.viewModel.digitizeDelete()}},this._onImageOverlayClosed=e=>{e.stopPropagation(),this.imageOverlaysOpened=!1},this._onShowCameraLocationsChanged=e=>{this.showCameraLocations=e},this._onShowMapFeaturesChanged=e=>{this.showMapFeatures=e},this._removeHighlight=()=>this.viewModel.removeHighlight(),this._restoreOverlays=async()=>Promise.all(this._overlayedLayers.map(e=>this.viewModel.overlayMapFeatures(e,this.showMapFeatures))),this._scaleNavigationTool=()=>{this._navigationToolExpanded=!this._navigationToolExpanded},this._sketchLoaderTask=null,this._settingsToggle=null,this._toggleImageNavigation=async e=>{const t=this.navigationMode;this._closeAllImageTools(),this.navigationMode=t!==e?e:null;const{activeViewer:i}=this.viewModel;if(!i)return;const{mode:a,preserveAngle:s}=this.viewModel;if("default"===a)if("directional"===this.navigationMode){const e=await this._loadNavigationSettings(),t="heading"===s||"both"===s,i="pitch"===s||"both"===s,{messages:a,messagesCommon:o}=this,n=new e({cameraHeadingThreshold:this.cameraHeadingThreshold,cameraPitchThreshold:this.cameraPitchThreshold,uiStrings:{configureNavigation:a.configureNavigation,preserveHeading:a.preserveHeading,preserveHeadingDescription:a.preserveHeadingDescription,preservePitch:a.preservePitch,preservePitchDescription:a.preservePitchDescription,settings:o.settings,thresholdLabel:a.thresholdLabel},onInputChange:this._handleNavigationSettingsInputChange,onToggle:this._handleNavigationSettingsToggle,preserveHeading:t,preservePitch:i});this._settingsToggle=new _({content:n,expandIcon:"configure"}),this.viewModel.activeViewer?.ui.add(this._settingsToggle,{position:"top-left"})}else this._settingsToggle&&(this._settingsToggle.expanded=!1,this.viewModel.activeViewer?.ui.remove(this._settingsToggle))},this._toggleImageAttributes=v(this.viewModel.toggleImageAttributes.bind(this.viewModel)),this.navigate=async e=>{let t=null;try{const{currentNode:i}=this.viewModel;if(!i)throw new X;t=await this.viewModel.navigate(i,e)}catch(i){l(i)||r.getLogger(this).error("Error occurred while navigating",i),["NoImageInSequenceError","NoSequenceFoundError"].includes(i.name)&&this._set("noImageInSequenceError",!0)}return t},this.reset=()=>{this._closeAllImageTools(),this.viewModel.reset()},this._loadImageFromGallery=this._loadImageFromGallery.bind(this),this._registerGalleryItem=this._registerGalleryItem.bind(this),this._unregisterGalleryItem=this._unregisterGalleryItem.bind(this),this.loadImageFromSource=this.loadImageFromSource.bind(this),this.updateSuitabilities=this.updateSuitabilities.bind(this),this._handleVideoBrightnessChange=this._handleVideoBrightnessChange.bind(this),this._handleVideoContrastChange=this._handleVideoContrastChange.bind(this),this._handleBrightnessChange=this._handleBrightnessChange.bind(this),this._handleContrastChange=this._handleContrastChange.bind(this),this._handleSharpnessChange=this._handleSharpnessChange.bind(this),this._resetVideoTools=this._resetVideoTools.bind(this),this._toggleEnhancementToolState=this._toggleEnhancementToolState.bind(this),this.announceDeprecation=()=>{o(r.getLogger(this),"Oriented Imagery Viewer","arcgis-oriented-imagery-viewer",{version:"5.0"})}}initialize(){this.addHandles([c(()=>[this.viewModel?.bestFeatureAngle,this._navigationTool],([e,t])=>{t&&this._updateNavigationTool(t)},d),c(()=>this.currentCoverageVisible,e=>this._onCurrentCoverageVisibilityChange(e)),c(()=>this.isAdditionalCoverageVisible,e=>this._onAdditionalCoverageVisibilityChange(e)),c(()=>this.isAdditionalPointSourcesVisible,e=>this._onAdditionalCameraLocationsVisibility(e)),c(()=>({features:this.currentBestFeature,showCameraLocations:this.showCameraLocations,state:this.viewModel.state}),({showCameraLocations:e,state:t})=>{"image-loaded"===t&&this.viewModel.overlayCameraLocations(e)},g),c(()=>({feature:this.currentBestFeature,showMapFeatures:this.showMapFeatures,state:this.viewModel.state}),async(e,t)=>{if(e.showMapFeatures!==t?.showMapFeatures&&await this.viewModel.toggleAllOverlayMapFeatures(e.showMapFeatures),null!=e.feature&&e.feature!==t?.feature){if(this.viewModel.removeAllOverlayMapFeatures(),await h(()=>"image-loaded"===this.viewModel.state),this.dataCaptureLayer&&this.stopDataCapture(),await this._restoreOverlays(),!this.dataCaptureLayer)return;await this.startDataCapture(this.dataCaptureLayer),this._previousAction?.active&&(this._previousAction.active=!1,this._previousAction=null)}},d),m(()=>this.viewModel,"popup-open",async e=>{await(this.view?.openPopup(e))},u),m(()=>this.viewModel,"popup-close",()=>{this.view?.closePopup()},u),this._toggleImageAttributes])}loadDependencies(){return Promise.all([J(),Y({"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar"),"action-group":()=>import("@esri/calcite-components/dist/components/calcite-action-group"),action:()=>import("@esri/calcite-components/dist/components/calcite-action"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),shell:()=>import("@esri/calcite-components/dist/components/calcite-shell"),dialog:()=>import("@esri/calcite-components/dist/components/calcite-dialog"),slider:()=>import("@esri/calcite-components/dist/components/calcite-slider")}),B()])}destroy(){this._galleryController.abort(),this._galleryObserver.disconnect(),this.currentBestFeature=null}get accuracyParametersMissing(){return this.viewModel.accuracyParametersMissing}get activeLayer(){return n(r.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){n(r.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeVideoIcon(){const{videoElement:e,videoViewModel:t}=this.viewModel;return e?.loaded&&t?t.videoPaused?"play":"pause":"play"}get activeAudioIcon(){const{videoElement:e,videoViewModel:t}=this.viewModel;return e?.loaded&&t?.videoMuted?"sound-off":"sound"}get cameraHeadingThreshold(){return this.viewModel.cameraHeadingThreshold}set cameraHeadingThreshold(e){this.viewModel.cameraHeadingThreshold=e}get cameraPitchThreshold(){return this.viewModel.cameraPitchThreshold}set cameraPitchThreshold(e){this.viewModel.cameraPitchThreshold=e}get canNavigateSequentially(){const{layer:e}=this;if(!e)return!1;const{fields:t,sequenceOrderField:i}=e;return t.some(({name:e})=>e.toLowerCase()===`${i??"sequenceorder"}`.toLowerCase())}get currentBestFeature(){return this.viewModel.currentBestFeature}set currentBestFeature(e){this.viewModel.currentBestFeature=e}get currentCoverageVisible(){return this.viewModel.currentCoverageVisible}set currentCoverageVisible(e){this.viewModel.currentCoverageVisible=e}get dataCaptureLayer(){return this.viewModel.dataCaptureLayer}set dataCaptureLayer(e){this.viewModel.dataCaptureLayer=e}get depthImageNotSupported(){return this.viewModel.depthImageNotSupported}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get displayMessage(){return this.viewModel.displayMessage}get enhancementToolActive(){return"video"===this.viewModel.mode?this.videoEnhancementToolActive:this.imageEnhancementToolActive}set enhancementToolActive(e){"video"===this.viewModel.mode?this.videoEnhancementToolActive=e:this.imageEnhancementToolActive=e}get features(){return this.viewModel.features}get imagePointsInView(){return this.viewModel.imagePointsInView}get icon(){return"oriented-imagery-widget"}set icon(e){this._overrideIfSome("icon",e)}get imageGalleryEnabled(){return this.viewModel.imageGalleryEnabled}get imageLocationToolActive(){return this.viewModel.imageLocationToolState}set imageLocationToolActive(e){this.viewModel.imageLocationToolState=e}get invalidCameraHeading(){return this.viewModel.invalidCameraHeading}get isAdditionalCoverageVisible(){return this.viewModel.isAdditionalCoverageVisible}set isAdditionalCoverageVisible(e){this.viewModel.isAdditionalCoverageVisible=e}get isAdditionalPointSourcesVisible(){return this.viewModel.isAdditionalPointSourcesVisible}set isAdditionalPointSourcesVisible(e){this.viewModel.isAdditionalPointSourcesVisible=e}get mapImageConversionToolState(){return this.viewModel.mapImageConversionToolState}set mapImageConversionToolState(e){this.viewModel.mapImageConversionToolState=e}get measureType(){return this.viewModel.measureType}set measureType(e){this.viewModel.measureType=e}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get navigationMode(){return this.viewModel.navigationMode}set navigationMode(e){this.viewModel.navigationMode=e}get popupEnabled(){const{popupEnabled:e,state:t}=this.viewModel;return("image-loaded"===t||this.videoLoaded)&&e}get preloadMedia(){return this.viewModel.preloadMedia}set preloadMedia(e){this.viewModel.preloadMedia=e}get referencePoint(){return this.viewModel.referencePoint??null}get sketchViewModel(){return this.viewModel.sketch}get triangularMeasurementActive(){return this.viewModel.triangularMeasurementActive}set triangularMeasurementActive(e){this.viewModel.triangularMeasurementActive=e}get videoLoaded(){const{mode:e,videoElement:t,panoramicVideoLoaded:i}=this.viewModel;return("video"===e&&!0===t?.loaded||i)??!1}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}set determineWorkflowForFeature(e){this.viewModel.determineWorkflowForFeature=e}get determineWorkflowForFeature(){return this.viewModel.determineWorkflowForFeature}get shouldShowSelectedImage(){return this.viewModel.shouldShowSelectedImage}set shouldShowSelectedImage(e){this.viewModel.shouldShowSelectedImage=e}set updateFootprint(e){this.viewModel.updateFootprint=e}get updateFootprint(){return this.viewModel.updateFootprint}get verticalFilterEnabled(){return this.viewModel.verticalFilterEnabled}set verticalFilterEnabled(e){this.viewModel.verticalFilterEnabled=e}_renderActionBar(){const{selectedGroup:e}=this;return ae("calcite-action-bar",{expandDisabled:!0,layout:"horizontal",slot:"action-bar"},!e&&ae("calcite-action-group",null,this._searchGroupToggle(),this._overlaysGroupToggle(),this._navigationGroupToggle(),this._measurementsGroupToggle(),this._utilitiesGroupToggle()),e?ae("calcite-action",{bind:this,icon:"arrow-left",key:"arrow-left",onclick:()=>this._toggleGroupSelection(null),text:this.messages.previous,title:this.messages.previous}):null,"overlays"===e&&ae("calcite-action-group",null,this._currentFootprintToggle(),this._additionalFootprintToggle(),this._additionalPointSourcesToggle(),this._mapImageConversionToggle(),this._imageOverlaysToggle()),"navigation"===e&&ae("calcite-action-group",null,this._directionToolsToggle(),this._navigationToolToggle(),this._imageGalleryToggle()),"measurements"===e&&ae("calcite-action-group",null,this._measurementToolToggle()),"utilities"===e&&ae("calcite-action-group",null,this._imageEnhancementsToggle(),this._videoEnhancementsToggle(),this._openPopupAction()),"search"===e&&ae("calcite-action-group",null,this._exploreImagesToggle(),this._exploreImages3DToggle(),this._showSelectedImageToggle()))}get _activeMeasurementHeading(){const{measureType:e,messages:t,triangularMeasurementActive:i}=this,{groundArea:a,heightAboveGround:s,groundDistance:o,triangulatedAreaHeading:n,triangulatedDistanceHeading:r}=t;if(i)return"area"===e?n:r;switch(e){case"area":return a;case"height":return s;default:return o}}_additionalFootprintToggle(){const{isAdditionalCoverageVisible:e,invalidCameraHeading:t,visibleElements:{additionalFootprintToggle:i}}=this;return i?ae("calcite-action",{active:e,bind:this,class:O.addCoverage,disabled:t,icon:"trapezoid-area",onclick:this._toggleAdditionalCoverage,text:this.messages.additionalFootprints,title:this.messages.additionalFootprints}):null}_additionalPointSourcesToggle(){const{isAdditionalPointSourcesVisible:e,invalidCameraHeading:t,visibleElements:{additionalCameraLocationsToggle:i}}=this;return i?ae("calcite-action",{active:e,bind:this,class:O.addExpPoints,disabled:t,icon:"circle-area",onclick:this._toggleAdditionalCameraLocations,text:this.messages.additionalCameraLocations,title:this.messages.additionalCameraLocations}):null}get _measurementToggle(){const{viewModel:{state:e,measureType:t,currentBestFeatureMeasurementImage:i},triangularMeasurementActive:a,id:s}=this;if("image-loaded"!==e||!t||a&&!i)return;this._imageMeasurementToolsLoaderTask||this._loadImageMeasurementResources();const o=this._imageMeasurementToolsLoaderTask?.value;return o?ae("calcite-dialog",{bind:this,dragEnabled:!0,escapeDisabled:!0,heading:this._activeMeasurementHeading,id:`${s}-${t}-measurement`,open:!0,placement:"bottom-start",resizable:!0,scale:"s",slot:"dialogs",width:"s",onCalciteDialogBeforeClose:this._clearMeasurements},ae(o,{measurementType:t,measurementUnitMessages:this.measurementUnitMessages,messages:this.messages,oiViewModel:this.viewModel})):null}get _renderRoot(){const{viewModel:{state:e},triangularMeasurementActive:t}=this;return ae("calcite-panel",{bind:this,class:t?O.viewerContainerMeasurement:O.viewerContainer,heading:this.visibleElements.title?this.messages.title:void 0,loading:e.includes("loading")&&!t},this.visibleElements.menu?this._renderActionBar():null,ae("calcite-shell",null,ae("calcite-panel",null,this._imageViewer,this._panoramicViewer,this._panoramicVideoViewer,this._videoViewer,this._messageBox,this.invalidCameraHeading?null:[this._imageGalleryPanel,this._renderNavigation,this._imageOverlaysPanel()],this._imageEnhancementTools,this._videoEnhancementTools,this._renderSketch(),this._navigationUI),this._imageViewerTriangular,this._measurementToggle,this._locationToggle,this.invalidCameraHeading?this._renderWarning(this.messages.invalidCameraHeadingWarningTitle,this.messages.invalidCameraHeadingWarningDescription):null,this.depthImageNotSupported?this._renderWarning(this.messages.depthImageNotSupportedTitle,this.messages.depthImageNotSupportedDescription):null,this.noImageInSequenceError?this._renderWarning(this.messages.sequentialNavigationWarning,this.messages.sequentialNavigationWarning,this._closeImageSequenceAlert):null))}_currentFootprintToggle(){const{currentCoverageVisible:e,invalidCameraHeading:t}=this,{currentFootprintToggle:i}=this.visibleElements;return i?ae("calcite-action",{active:e,bind:this,class:O.currentCoverage,disabled:t,icon:"trapezoid-area",onclick:this._toggleCurrentCoverage,text:this.messages.currentFootprint,title:this.messages.currentFootprint}):null}_exploreImagesToggle(){const{exploreImages:e}=this.messages;return this.visibleElements.exploreImages?ae("calcite-action",{active:!this.disabled,bind:this,icon:"oriented-imagery-widget",onclick:this._toggleExploreImages,text:e,title:e}):null}get _imageEnhancementTools(){const{enhancementToolActive:e,viewModel:{brightness:t,contrast:i,sharpness:a,state:s}}=this;return e&&"image-loaded"===s?ae("calcite-panel",{bind:this,class:O.imageEnhancementWrapper,closable:!0,closed:!e,heading:this.messages.imageEnhancement,key:this.messages.imageEnhancement,onCalcitePanelClose:this._toggleEnhancementToolState},ae("div",{class:O.imageEnhancementTools},K({title:this.messages.brightness,value:t,max:10,min:-10,ticks:5,handleChange:this._handleBrightnessChange}),K({title:this.messages.contrast,value:i,max:10,min:-10,ticks:5,handleChange:this._handleContrastChange}),K({title:this.messages.sharpness,value:a,max:1,min:0,ticks:.5,step:.1,handleChange:this._handleSharpnessChange})),ae("calcite-action",{bind:this,icon:"reset",onclick:this._resetImageTools,slot:"header-actions-end",text:this.messagesCommon.reset,title:this.messagesCommon.reset})):null}get _videoEnhancementTools(){const{enhancementToolActive:e,viewModel:{videoViewModel:t,mode:i},messages:{videoEnhancement:a,brightness:s,contrast:o},messagesCommon:{reset:n}}=this;return e&&"video"===i&&t?ae(Q,{brightness:t.videoBrightness,constrast:t.videoContrast,handleBrightnessChange:this._handleVideoBrightnessChange,handleContrastChange:this._handleVideoContrastChange,resetTools:this._resetVideoTools,uiStrings:{videoEnhancement:a,brightness:s,contrast:o,reset:n},videoEnhancementToolActive:e,onClose:this._toggleEnhancementToolState}):null}_imageEnhancementsToggle(){const{state:e,mode:t}=this.viewModel,{enhancementTool:i}=this.visibleElements;return i&&"video"!==t?ae("calcite-action",{active:this.enhancementToolActive,bind:this,disabled:"default"!==t||"image-loaded"!==e,icon:"sliders-horizontal",onclick:this._toggleEnhancementToolState,text:this.messages.imageEnhancement,title:this.messages.imageEnhancement}):null}_exploreImages3DToggle(){const{exploreImages3D:e}=this.messages,t="3d"!==this.view?.type||!this.layer?.verticalSearchRange;return this.visibleElements.exploreImages3D?ae("calcite-action",{active:this.verticalFilterEnabled,bind:this,disabled:t,icon:"surface",onclick:this._toggleVerticalSearchFilter,text:e,title:e}):null}_showSelectedImageToggle(){const{displayImages:e}=this.messages,t=this.viewModel.mode.includes("video");return this.visibleElements.showSelectedImage?ae("calcite-action",{active:this.shouldShowSelectedImage,bind:this,disabled:t,icon:"image",onclick:this._toggleShowSelectedImage,text:e,title:e}):null}_videoEnhancementsToggle(){const{mode:e}=this.viewModel,{videoEnhancement:t}=this.messages,{enhancementTool:i}=this.visibleElements;return i&&"video"===e?ae("calcite-action",{active:this.enhancementToolActive,bind:this,disabled:"video"!==e,icon:"sliders-horizontal",onclick:this._toggleEnhancementToolState,text:t,title:t}):null}get _imageGalleryPanel(){const{container:e,galleryOpened:t,imageGalleryEnabled:i}=this;return i&&t&&e?this._imageGalleryContext:null}get _imageGalleryContext(){const{galleryOpened:e,invalidCameraHeading:t}=this;return ae("calcite-panel",{bind:this,class:O.carousel,closable:!0,closed:!e,disabled:t,heading:this.messages.imageGallery,key:this.messages.imageGallery,onCalcitePanelClose:this._toggleImageGallery},ae("div",{class:O.carouselContainer},this._renderThumbnails))}_imageGalleryToggle(){const{imageGalleryEnabled:e,invalidCameraHeading:t,visibleElements:{imageGallery:i}}=this;return i?ae("calcite-action",{active:this.galleryOpened,bind:this,disabled:!e||t,icon:"images",onclick:this._toggleImageGallery,text:this.messages.imageGallery,title:this.messages.imageGallery}):null}get _imageOverlaysComponent(){const{_imageOverlayMessages:e,_imageOverlaysLoaderTask:t,_overlayedLayers:i,dataCaptureEnabled:s,dataCaptureLayer:o,imageOverlaysOpened:n,showCameraLocations:r,showMapFeatures:l,view:c,layer:d}=this;if(!d)return null;const g=d.imageGeometryField?.length?d.imageGeometryField:A,h=d.imageReferenceField?.length?d.imageReferenceField:S;t||(this._imageOverlaysLoaderTask=a(async()=>(await import("./OrientedImageryViewer/components/ImageOverlays.js")).default));const m=this._imageOverlaysLoaderTask?.value;return m?ae(m,{closed:!n,dataCaptureEnabled:s,dataCaptureLayer:o,imageGeometryField:g,imageReferenceField:h,messages:e,overlayedLayers:i,showCameraLocations:r,showMapFeatures:l,view:c,onDataCaptureLayerChanged:this._handleDataCaptureLayerChange,onFilterCapturedFeatures:this.viewModel.filterCapturedFeatures,onImageOverlaysClosed:this._onImageOverlayClosed,onLayerDeselected:this._handleOverlayLayerDeselect,onLayerSelected:this._handleOverlayLayerSelect,onShowCameraLocationsChanged:this._onShowCameraLocationsChanged,onShowMapFeaturesChanged:this._onShowMapFeaturesChanged}):null}get _navigationUI(){const{navigationMode:e,viewModel:t}=this,{mode:i,state:a}=t;if(e&&("default"===i||"panoramic"===i)&&"image-loaded"===a)return"directional"===e?"default"===i?ae(R,{cameraHeadingThreshold:this.cameraHeadingThreshold,cameraPitchThreshold:this.cameraPitchThreshold,currentNode:this.viewModel.currentNode,navigate:this._createNavigationTask,nodes:this.viewModel.navigationNodes,preserveAngle:this.viewModel.preserveAngle}):ae(z,{currentNode:this.viewModel.currentNode,navigate:this._createNavigationTask,nodes:this.viewModel.navigationNodes}):ae(Z,{layout:"horizontal",uiStrings:{end:this.messages.end,next:this.messages.next,previous:this.messages.previous,start:this.messages.start},onNext:this._navigateNext,onPrev:this._navigatePrevious})}get _imageOverlayMessages(){return{...this.messages,...this.messagesSketch}}get _imageSketchToolsMessages(){return{...this.messagesSketch,...this.messagesCommon}}_imageOverlaysPanel(){const{imageOverlaysOpened:e,viewModel:{state:t}}=this,i=this.classes({[O.imageOverlaysContainer]:!0,[ee.hidden]:!e||"image-loaded"!==t});return ae("div",{class:i,key:this.messages.imageOverlays},this._imageOverlaysComponent)}_imageOverlaysToggle(){const{viewModel:{state:e},imageOverlaysOpened:t,invalidCameraHeading:i,visibleElements:{imageOverlays:a}}=this;return a?ae("calcite-action",{active:t,bind:this,disabled:"image-loaded"!==e||i,icon:"layers",onclick:this._toggleImageOverlays,text:this.messages.imageOverlays,title:this.messages.imageOverlays}):null}get _imageViewer(){const{displayMessage:e,loadImageViewer:t,mode:i,clickAction:a,state:s}=this.viewModel,o=null!=e||"default"!==i||s.includes("loading");return ae(W,{afterCreate:t,clickAction:a,visible:!o})}get _imageViewerTriangular(){const{messages:e,triangularMeasurementActive:t}=this,{displayMessage:i,storeImageMeasurementViewer:a,storePanoramicMeasurementViewer:s,mode:o,state:n,clickAction:r}=this.viewModel,l=null!=i||"none"===o||"video"===o,c=this.classes({[O.viewer]:!l,[O.viewerHidden]:l});return t?ae("calcite-panel",{class:O.viewerContainerMeasurement,heading:e.measurementViewerHeading,loading:n.includes("loading")},ae("calcite-panel",{bind:this,class:c},"default"===o?ae(W,{afterCreate:a,clickAction:r,uiStrings:e}):ae(M,{afterCreate:s,clickAction:r,uiStrings:e}))):null}_utilitiesGroupToggle(){const{utilityTools:e}=this.messages;return this.visibleElements.utilityTools?ae("calcite-action",{bind:this,icon:"gear",key:"utilities-group-toggle",onclick:()=>this._toggleGroupSelection("utilities"),text:e,title:e}):null}_searchGroupToggle(){const{searchTools:e}=this.messages;return this.visibleElements.searchTools?ae("calcite-action",{bind:this,icon:"search",key:"search-group-toggle",onclick:()=>this._toggleGroupSelection("search"),text:e,title:e}):null}get _videoViewer(){const{mode:e,loadVideoViewer:t,videoViewModel:i}=this.viewModel,{control:a,reset:s}=this.messagesCommon,{mute:o,unmute:n}=this.messages,r="video"!==e,l=this.classes({[O.viewer]:!r,[O.viewerHidden]:r}),c="esri-image-viewer";return ae("calcite-panel",{bind:this,class:l},ae("calcite-panel",{afterCreate:t,class:this.classes(ee.widget,c)}),ae("calcite-slider",{bind:this,labelHandles:!0,labelTicks:!0,max:i?.videoDuration,minLabel:"0",value:i?.currentTime??0,onCalciteSliderChange:this._handleVideoSeek}),ae("calcite-action-bar",{expandDisabled:!0,layout:"horizontal"},ae("calcite-action-group",null,ae("calcite-action",{bind:this,icon:this.activeVideoIcon,onclick:()=>i?.playVideoHandler(),text:"Play",title:i?.videoPaused?a.play:a.pause})),ae("calcite-action-group",null,ae("calcite-action",{bind:this,icon:"refresh",onclick:()=>i?.rewindVideoHandler(),text:"Rewind",title:s})),ae("calcite-action-group",null,ae("calcite-action",{bind:this,icon:this.activeAudioIcon,onclick:()=>i?.toggleAudio(),text:"Audio",title:i?.videoMuted?o:n}))))}get _locationToggle(){const{viewModel:{state:e,groundCoordinates:t,groundCoordinatesAccuracy:i,triangulatedPoint:a},imageLocationToolActive:s,triangularMeasurementActive:o,messages:{groundLocation:n,triangulatedLocationHeading:r}}=this;if("image-loaded"!==e||!t||!s)return;let l=t;if(o){if(!a)return;l=a}return ae("calcite-dialog",{bind:this,dragEnabled:!0,escapeDisabled:!0,heading:o?r:n,id:n,open:!0,placement:"bottom-start",resizable:!0,scale:"s",slot:"dialogs",width:"s",onCalciteDialogBeforeClose:this._clearImageLocation},ae(U,{accuracy:i,groundCoordinates:l,messages:this.messages}))}_mapImageConversionToggle(){const{mapImageConversionToolState:e,viewModel:{state:t,disabled:i},invalidCameraHeading:a,visibleElements:{mapImageConversionTool:s}}=this;return s?ae("calcite-action",{active:e,bind:this,disabled:"image-loaded"!==t||a||i,icon:"image-pin",onclick:this._toggleMapImageConversionToolState,text:this.messages.mapImageConversionTool,title:this.messages.mapImageConversionTool}):null}_measurementToolToggle(){const{measureType:e,viewModel:t,accuracyParametersMissing:i,messages:a,triangularMeasurementActive:s}=this,{state:o}=t,{groundDistance:n,groundArea:r,heightAboveGround:l,groundLocation:c,triangulatedDistanceHeading:d,triangulatedAreaHeading:g,triangulatedLocationHeading:h}=a,m="image-loaded"!==o||i;return ae("calcite-action-group",{key:"measurement-tools",scale:"m"},ae("calcite-action",{active:"distance"===e&&!s,bind:this,disabled:m,icon:"measure-line",key:"distance-measurement",onclick:e=>this._toggleMeasurementSketch(e,"distance"),text:n,title:n}),ae("calcite-action",{active:"area"===e&&!s,bind:this,disabled:m,icon:"measure-area",key:"area-measurement",onclick:e=>this._toggleMeasurementSketch(e,"area"),text:r,title:r}),ae("calcite-action",{active:"height"===e,bind:this,disabled:m,icon:"measure-building-height-top-base",key:"height-measurement",onclick:e=>this._toggleMeasurementSketch(e,"height"),text:l,title:l}),ae("calcite-action",{active:!!this.imageLocationToolActive&&!s,bind:this,disabled:m,icon:"pin-tear",key:"surface-location",onclick:this._toggleLocationTool,text:c,title:c}),ae("calcite-action",{active:!!s&&this.imageLocationToolActive,bind:this,disabled:m,icon:"dual-image-location",key:"triangular-location",onclick:this._toggleTriangularLocation,text:h,title:h}),ae("calcite-action",{active:!!s&&"distance"===this.measureType,bind:this,disabled:m,icon:"dual-image-distance",key:"triangular-distance",onclick:this._toggleTriangularDistanceMeasurements,text:d,title:d}),ae("calcite-action",{active:!!s&&"area"===this.measureType,bind:this,disabled:m,icon:"dual-image-area",key:"triangular-area",onclick:this._toggleTriangularAreaMeasurements,text:g,title:g}))}get _messageBox(){const{messages:e,viewModel:{displayMessage:i,mode:a}}=this;if(!i||"video"===a)return null;const{data:s,key:o,map:n}=i,r=`${n?t(e[o],n):e[o]}`;return ae("span",{class:O.messageBox},s?`${r} ${s}`:r)}async _loadNavigationSettings(){return this._navigationSettingsLoaderTask||(this._navigationSettingsLoaderTask=a(async()=>(await import("./OrientedImageryViewer/components/NavigationSettings.js")).default)),await this._navigationSettingsLoaderTask.promise}_measurementsGroupToggle(){const{measurementTools:e}=this.messages,{state:t,accuracyParametersMissing:i}=this.viewModel,a="image-loaded"!==t||i;return this.visibleElements.measurementTools?ae("calcite-action",{bind:this,disabled:a,icon:"measure-line",key:"measurements-group-toggle",onclick:()=>this._toggleGroupSelection("measurements"),text:e,title:e}):null}_navigationGroupToggle(){const{imageNavigation:e}=this.messages;return this.visibleElements.imageNavigationTools?ae("calcite-action",{bind:this,icon:"absolute-direction",key:"navigation-group-toggle",onclick:()=>this._toggleGroupSelection("navigation"),text:e,title:e}):null}_navigationToolToggle(){const{state:e}=this.viewModel,{visibleElements:{navigationTool:t},videoLoaded:i}=this;return t?ae("calcite-action",{active:this.navigationToolActive,bind:this,disabled:"image-loaded"!==e&&!i||this.invalidCameraHeading,icon:"explore",onclick:this._toggleNavigationTool,text:this.messages.navigationTool,title:this.messages.navigationTool}):null}_directionToolsToggle(){const{messages:e,viewModel:t,visibleElements:i}=this,{directionalNavigation:a,sequentialNavigation:s}=i,{state:o}=t,{directionalNavigation:n,directionalNavigationDescription:r,sequentialNavigation:l,sequentialNavigationDescription:c}=e;return ae("calcite-action-group",{key:"navigation-tools",scale:"m"},a?ae("calcite-action",{active:"directional"===this.navigationMode,bind:this,disabled:"image-loaded"!==o||this.invalidCameraHeading,icon:"directional-navigation",onclick:()=>{this._toggleImageNavigation("directional")},text:r,title:n}):null,s?ae("calcite-action",{active:"sequential"===this.navigationMode,bind:this,disabled:"image-loaded"!==o||this.invalidCameraHeading||!this.canNavigateSequentially,icon:"sequential-navigation",onclick:()=>{this._toggleImageNavigation("sequential")},text:c,title:l}):null)}_overlaysGroupToggle(){const{overlays:e}=this.messages;return this.visibleElements.overlays?ae("calcite-action",{bind:this,icon:"trapezoid-area",key:"overlays-group-toggle",onclick:()=>this._toggleGroupSelection("overlays"),text:e,title:e}):null}_openPopupAction(){const{showPopupsAction:e}=this.visibleElements;return e?ae("calcite-action",{bind:this,disabled:!this.popupEnabled,icon:"popup",onclick:this._toggleImageAttributes,text:this.messages.showPopups,title:this.messages.showPopups}):null}get _panoramicVideoViewer(){const{displayMessage:e,loadPanoramicVideoViewer:t,mode:i,clickAction:a,state:s,currentBestFeature:o}=this.viewModel,n=o?.attributes.imagePath,r=null!=e||"panoramic-video"!==i||s.includes("loading")||!n;return ae(T,{afterCreate:t,clickAction:a,oiViewModel:this.viewModel,videoSource:n,visible:!r})}get _panoramicViewer(){const{displayMessage:e,loadPanoramicViewer:t,mode:i,clickAction:a,state:s}=this.viewModel,o=null!=e||"panoramic"!==i||s.includes("loading");return ae(M,{afterCreate:t,clickAction:a,visible:!o})}get noImageInSequenceError(){return this._get("noImageInSequenceError")??!1}_activateTriangulatedImageLocationTool(){this.navigationToolActive=!0,this.imageLocationToolActive=!0}_activateTriangulatedImageLocationWorkflow(e,t){this._closeAllImageTools(),this.imageLocationToolActive=!0,this.triangularMeasurementActive=!e,this.navigationToolActive=!!t||!t}_closeImageToolsAndToggleNavigation(e,t){this._closeAllImageTools(),this.triangularMeasurementActive=!e,this.navigationToolActive=!t}_resetMeasureTypeAndActivateImageLocationTool(){this.measureType=null,this.imageLocationToolActive=!0}_closeAllImageTools(){this.enhancementToolActive=!1,this.navigationToolActive=!1,this.imageOverlaysOpened=!1,this.galleryOpened=!1,this.measureType=null,this.imageLocationToolActive=!1,this.navigationMode=null,this.triangularMeasurementActive=!1,this._settingsToggle&&(this._settingsToggle.expanded=!1,this.viewModel.activeViewer?.ui.remove(this._settingsToggle))}_handleBrightnessChange(e){this.viewModel.brightness=e.currentTarget.value??0}_handleVideoBrightnessChange(e){this.viewModel.videoViewModel?.handleVideoBrightnessChange(e.target.value)}_handleContrastChange(e){this.viewModel.contrast=e.currentTarget.value??0}_handleVideoContrastChange(e){this.viewModel.videoViewModel?.handleVideoContrastChange(e.target.value)}_handleVideoSeek(e){const t=this.viewModel?.videoElement?.content;t&&(t.currentTime=e.target.value,t.play())}_handleSharpnessChange(e){this.viewModel.sharpness=e.currentTarget.value??0}_lazyLoadImage(e,t){e.forEach(async e=>{if(e.isIntersecting){const a=e.target,s=a.getAttribute("data-src"),o=a.getAttribute("data-rotation"),n=a.getAttribute("data-objectid"),c=o?parseFloat(o)%360:0,{layer:d,_galleryController:{signal:g}}=this;if(!s||!n)return;let h;try{h=N(s)?await G(d,n,{signal:g}):await H(s,{signal:g})}catch(i){l(i)||r.getLogger("esri.widgets.OrientedImageryViewer").error("#lazyLoadImage()",i)}finally{t.unobserve(a)}if(!h)return;D(h,a,c)}})}_loadImageFromGallery(e){const{target:t}=e;if(!t)return;const i=t.getAttribute("data-objectid");i&&this.viewModel.currentBestFeature?.attributes.objectId!==Number(i)&&this.viewModel.selectBestFeature(i)}_loadImageMeasurementResources(){this._imageMeasurementToolsLoaderTask=a(async()=>{const{default:e}=await import("./OrientedImageryViewer/components/ImageMeasurementWidget.js");return e})}_loadSketchResources(){this._sketchLoaderTask=a(async()=>(await import("./OrientedImageryViewer/components/SketchTools.js")).default)}_onAdditionalCoverageVisibilityChange(e){this.viewModel.setAdditionalCoverageVisibility(e)}_onAdditionalCameraLocationsVisibility(e){this.viewModel.setAdditionalCameraLocationsVisibility(e)}_onCurrentCoverageVisibilityChange(e){this.viewModel.setCurrentCoverageVisibility(e)}_registerGalleryItem(e){this._galleryObserver.observe(e)}_renderWarning(e,t,i){const{viewModel:{state:a}}=this;return"image-loaded"===a?ae(q,{icon:"exclamation-mark-triangle-f",kind:"warning",message:t,open:!0,title:e,tooltip:t,topLayerDisabled:this.topLayerDisabled,onClose:i}):null}get _renderNavigation(){const{viewModel:{sectorData:e,navigatorCurrentBestFeature:t,currentBestFeature:a,state:s}}=this;if(!this.container||!a)return null;let o,n,r,l,c;if(t){const{x:e,y:i,direction:a}=t,[s,d,g,h]=k[a];o=`M ${e} ${i} L ${s} ${d} A ${V[2]} ${V[2]} 0 0 1 ${g} ${h} Z`,n=e,l=i,r=k[a][4],c=k[a][5]}const d=e=>{const t=e.target.dataset?.sector;t&&this.viewModel.handleSectorClick(+t)},g=e=>{const t=e.target.dataset;if(!t)return;const{featureIndexInSector:i,sector:a}=t;i&&a&&this.viewModel.handleFeatureClick({sector:a,featureIndexInSector:+i})},h=e=>{e.removeEventListener("click",g)},m=a.attributes.objectId,u=e?.map(e=>e?.items).filter(Boolean).flatMap(e=>e?.map(({x:e,y:t,objectID:i,featureIndexInSector:a,sector:s})=>ae("circle",{afterRemoved:h,class:this.classes(O.feature,{selected:m===i}),cx:e,cy:t,"data-feature-index-in-sector":a,"data-sector":s,key:`${O.feature}-${i}`,onclick:g,r:f}))),v=e=>{e.removeEventListener("click",d)},p=this.classes({[O.navigationWrapper]:!0,[O.navigationZoomed]:this._navigationToolExpanded});return this.navigationToolActive&&("image-loaded"===s||this.videoLoaded)?ae("div",{bind:this,class:p,key:this.messages.navigationTool},ae("svg",{afterCreate:e=>this._storeNavigationToolReference(e),class:i()?E:O.rotateWithAnimation,focusable:"false",height:L,role:"img",width:L,xmlns:"http://www.w3.org/2000/svg"},ae("defs",null,ae("linearGradient",{gradientUnits:"userSpaceOnUse",id:`${this.id}-coverage-fill`,x1:n,x2:r,y1:l,y2:c},ae("stop",{class:O.navigationPathOffset0,offset:0}),ae("stop",{class:O.navigationPathOffset1,offset:1}))),ae("g",null,ae("circle",{class:this.classes(O.sector,O.outerSector),cx:V[3],cy:V[3],onclick:this._scaleNavigationTool,r:V[3]}),ae("circle",{class:O.sector,cx:V[3],cy:V[3],r:V[2]}),ae("circle",{class:O.sector,cx:V[3],cy:V[3],r:V[1]}),ae("circle",{class:O.sector,cx:V[3],cy:V[3],r:V[0]}),ae("path",{class:O.pointer,d:"M 56.5 6.06217782649107 L 60 0 L 63.5 6.06217782649107 Z",key:`${O.pointer}-west`}),ae("path",{class:this.classes(O.pointer,O.north),d:"M 113.93782217350893 56.5 L 120 60 L 113.93782217350893 63.5 Z",key:`${O.pointer}-north`}),ae("path",{class:O.pointer,d:"M 56.5 113.93782217350893 L 60 120 L 63.5 113.93782217350893 Z",key:`${O.pointer}-east`}),ae("path",{class:O.pointer,d:"M 6.06217782649107 56.5 L 0 60 L 6.06217782649107 63.5 Z",key:`${O.pointer}-south`}),ae("path",{class:this.classes(O.sector,O.sectorSeparator),d:"M 23.937554159486076 23.937554159486076 L 96.06244584051393 96.06244584051393 M 23.937554159486076 96.06244584051393 L 96.06244584051393 23.937554159486076",key:O.sectorSeparator}),C([V[2],V[1],V[0]],V[3],V[3]).map((t,i)=>ae("path",{afterRemoved:v,class:this.classes(O.sector,e?.[i]?.length?O.sectorEnabled:O.sectorDisabled),d:t,"data-sector":`${i}`,key:`${O.sector}-${i}`,onclick:d})),ae("path",{class:this.classes(O.sector,O.sectorCross),d:"M 56.4 56.4 L 63.53 63.53 M 63.53 56.4 L 56.4 63.53",key:O.sectorCross}),u,a.attributes.cameraPitch>=5&&o?ae("path",{class:O.selectedFeaturePath,d:o,fill:`url(#${this.id}-coverage-fill)`,key:O.selectedFeaturePath}):null))):null}_renderSketch(){const{dataCaptureLayer:e,imageOverlaysOpened:t}=this;if(!e||t)return null;if(this._sketchLoaderTask||this._loadSketchResources(),!this._sketchLoaderTask?.value)return null;const{geometryType:i}=e,a="point"===i?"pin":"polyline"===i?"line":"polygon",s=this._sketchLoaderTask.value;return ae("div",{class:O.sketchTools},ae(s,{icon:a,messages:this._imageSketchToolsMessages,type:i,onAction:this._onAction}))}get _renderThumbnails(){const{currentBestFeature:e,thumbnails:t}=this.viewModel;return e?ae("div",{class:O.carouselContent},t?.items.map(({url:t,objectId:i,rotation:a},s)=>ae("div",{class:`${O.carouselItemWrapper}${e.attributes.objectId===i?"--selected":""}`,key:`${O.carouselItemWrapper}-${s}`},ae("canvas",{afterCreate:this._registerGalleryItem,afterRemoved:this._unregisterGalleryItem,alt:`thumbnail-${i}`,class:O.carouselItem,"data-objectid":`${i}`,"data-rotation":`${a}`,"data-src":t,onclick:this._loadImageFromGallery,onmouseenter:this._highlight,onmouseleave:this._removeHighlight})))):null}_resetImageTools(){this.viewModel.sharpness=this.viewModel.brightness=this.viewModel.contrast=0}_resetVideoTools(){this.viewModel.videoViewModel?.resetVideoEnhancementTools()}_storeNavigationToolReference(e){this._navigationTool=e}_toggleAdditionalCameraLocations(){this.isAdditionalPointSourcesVisible=!this.isAdditionalPointSourcesVisible}_toggleAdditionalCoverage(){this.isAdditionalCoverageVisible=!this.isAdditionalCoverageVisible}_toggleCurrentCoverage(){this.currentCoverageVisible=!this.currentCoverageVisible}_toggleShowSelectedImage(){this.shouldShowSelectedImage=!this.shouldShowSelectedImage,this._toggleDisabledViewer(this.shouldShowSelectedImage)}_toggleVerticalSearchFilter(){this.verticalFilterEnabled=!this.verticalFilterEnabled,this._toggleDisabledViewer(this.verticalFilterEnabled)}_toggleDisabledViewer(e){e&&(this.disabled=!1)}_toggleEnhancementToolState(e){e.stopPropagation();const t=this.enhancementToolActive;this._closeAllImageTools(),this.enhancementToolActive=!t}_toggleExploreImages(){this.disabled=!this.disabled,this.disabled&&(this.shouldShowSelectedImage=!1,this.verticalFilterEnabled=!1)}_toggleGroupSelection(e){this.selectedGroup=e}_toggleImageOverlays(e){e.stopPropagation();const t=this.imageOverlaysOpened;this._closeAllImageTools(),this.imageOverlaysOpened=!t}_toggleImageGallery(e){e.stopPropagation();const t=this.galleryOpened;this._closeAllImageTools(),this.galleryOpened=!!this.imageGalleryEnabled&&!t}_toggleLocationTool(e){const t=this.imageLocationToolActive,i=this.triangularMeasurementActive&&t;this._closeAllImageTools(),this.imageLocationToolActive=i||!t,e.stopPropagation()}_toggleMeasurementSketch(e,t){e.stopPropagation();const i=this.measureType,a=this.triangularMeasurementActive;this._closeAllImageTools(),this.measureType=i!==t||a?t:null,this.measureType===t&&(this.viewModel.displayNewMeasurementButton=!0)}_toggleNavigationTool(){const e=this.navigationToolActive;this._closeAllImageTools(),this.navigationToolActive=!e}_toggleMapImageConversionToolState(){this.mapImageConversionToolState=!this.mapImageConversionToolState}_toggleTriangularAreaMeasurements(){this._toggleTriangularMeasurements("area")}_toggleTriangularDistanceMeasurements(){this._toggleTriangularMeasurements("distance")}_toggleTriangularLocation(){const e=this.triangularMeasurementActive,t=this.navigationToolActive;e?null===this.measureType?this.imageLocationToolActive?this._closeImageToolsAndToggleNavigation(e,t):this._activateTriangulatedImageLocationTool():this._resetMeasureTypeAndActivateImageLocationTool():this._activateTriangulatedImageLocationWorkflow(e,t)}_toggleTriangularMeasurements(e){const t=this.triangularMeasurementActive,i=this.viewModel.measureType,a=this.navigationToolActive;t?e===i?(this._closeAllImageTools(),this.triangularMeasurementActive=!t,this.navigationToolActive=!a):(this.imageLocationToolActive=!1,this.measureType=e):(this._closeAllImageTools(),this.measureType=e,this.triangularMeasurementActive=!t,this.navigationToolActive=!!a||!a)}_unregisterGalleryItem(e){this._galleryObserver.unobserve(e)}_updateNavigationTool(e){const{previousFeatureAngle:t,bestFeatureAngle:i}=this.viewModel,a=(i-t+540)%360-180;e.style.setProperty(F,`${t}deg`),e.style.setProperty(x,`${t+a}deg`)}async loadBestImage(e){return this.viewModel.loadBestImage(e)}loadImageFromSource(e,t,i){return"default"===e?this.viewModel.loadMediaSource(t,i):this.viewModel.loadPanoramicMediaSource(t,i)}async overlayMapFeatures(e,t){return this.removeHandles(`${se.overlayed}-${e.id}`),this.addHandles(c(()=>e.visible,()=>{this.viewModel.toggleOverlayMapFeatures(e.id,e.visible,this.showMapFeatures)}),`${se.overlayed}-${e.id}`),this._overlayedLayers.add(e),this.viewModel.overlayMapFeatures(e,t&&this.showMapFeatures)}async plotMapPoint(e){return this.viewModel.plotMapPoint(e)}plotReferencePointOnGround(e){this.viewModel.plotReferencePointOnGround(e)}plotReferencePointOnImage(e){this.viewModel.plotReferencePointOnImage(e)}removeOverlayedGraphicsOnImage(e){this.removeHandles(`${se.overlayed}-${e}`),this._overlayedLayers.remove(this._overlayedLayers.find(t=>t.id===e)),this.viewModel.removeOverlayedGraphicsOnImage(e)}resetImage(){this.viewModel.resetImage()}render(){return ae("div",{class:this.classes(ee.widget,P)},this._renderRoot)}async showImageByObjectId(e,t){return this.viewModel.showImageByObjectId(e,t)}async startDataCapture(e){return this.viewModel.startDataCapture(e)}async stopDataCapture(e){return this.viewModel.stopDataCapture(e)}updateSuitabilities(e){this.viewModel.updateSuitabilities(e)}};e([p({readOnly:!0})],oe.prototype,"accuracyParametersMissing",null),e([p()],oe.prototype,"activeLayer",null),e([p()],oe.prototype,"activeVideoIcon",null),e([p()],oe.prototype,"activeAudioIcon",null),e([p()],oe.prototype,"cameraHeadingThreshold",null),e([p()],oe.prototype,"cameraPitchThreshold",null),e([p()],oe.prototype,"canNavigateSequentially",null),e([p()],oe.prototype,"currentBestFeature",null),e([p()],oe.prototype,"currentCoverageVisible",null),e([p()],oe.prototype,"dataCaptureEnabled",void 0),e([p()],oe.prototype,"dataCaptureLayer",null),e([p()],oe.prototype,"depthImageNotSupported",null),e([p()],oe.prototype,"disabled",null),e([p()],oe.prototype,"enhancementToolActive",null),e([p()],oe.prototype,"features",null),e([p()],oe.prototype,"imagePointsInView",null),e([p()],oe.prototype,"galleryOpened",void 0),e([p()],oe.prototype,"icon",null),e([p()],oe.prototype,"imageEnhancementToolActive",void 0),e([p()],oe.prototype,"videoEnhancementToolActive",void 0),e([p({readOnly:!0})],oe.prototype,"imageGalleryEnabled",null),e([p()],oe.prototype,"imageLocationToolActive",null),e([p()],oe.prototype,"imageOverlaysOpened",void 0),e([p({readOnly:!0})],oe.prototype,"invalidCameraHeading",null),e([p()],oe.prototype,"isAdditionalCoverageVisible",null),e([p()],oe.prototype,"isAdditionalPointSourcesVisible",null),e([p()],oe.prototype,"mapImageConversionToolState",null),e([p()],oe.prototype,"measureType",null),e([p()],oe.prototype,"layer",null),e([p()],oe.prototype,"navigationToolActive",void 0),e([p()],oe.prototype,"navigationMode",null),e([te(I()),p({type:j})],oe.prototype,"viewModel",void 0),e([p(),ie("esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer")],oe.prototype,"messages",void 0),e([p(),ie("esri/core/t9n/Units")],oe.prototype,"measurementUnitMessages",void 0),e([p(),ie("esri/t9n/common")],oe.prototype,"messagesCommon",void 0),e([p(),ie("esri/widgets/Sketch/t9n/Sketch")],oe.prototype,"messagesSketch",void 0),e([p()],oe.prototype,"pixelMeasurementUnit",void 0),e([p()],oe.prototype,"pixelAreaMeasurementUnit",void 0),e([p({readOnly:!0})],oe.prototype,"popupEnabled",null),e([p()],oe.prototype,"preloadMedia",null),e([p()],oe.prototype,"referencePoint",null),e([p()],oe.prototype,"selectedGroup",void 0),e([p()],oe.prototype,"showCameraLocations",void 0),e([p()],oe.prototype,"showMapFeatures",void 0),e([te(["create","delete","redo","undo","update"]),p({readOnly:!0})],oe.prototype,"sketchViewModel",null),e([p()],oe.prototype,"triangularMeasurementActive",null),e([p()],oe.prototype,"videoLoaded",null),e([p()],oe.prototype,"view",null),e([p({type:$,nonNullable:!0})],oe.prototype,"visibleElements",void 0),e([p()],oe.prototype,"determineWorkflowForFeature",null),e([p()],oe.prototype,"shouldShowSelectedImage",null),e([p()],oe.prototype,"updateFootprint",null),e([p()],oe.prototype,"verticalFilterEnabled",null),e([p()],oe.prototype,"_activeMeasurementHeading",null),e([p()],oe.prototype,"_imageOverlaysLoaderTask",void 0),e([p()],oe.prototype,"_imageMeasurementToolsLoaderTask",void 0),e([p()],oe.prototype,"_navigationSettingsLoaderTask",void 0),e([p()],oe.prototype,"_navigationTask",void 0),e([p()],oe.prototype,"_measurementToggle",null),e([p()],oe.prototype,"_renderRoot",null),e([p()],oe.prototype,"_imageEnhancementTools",null),e([p()],oe.prototype,"_videoEnhancementTools",null),e([p()],oe.prototype,"_imageGalleryPanel",null),e([p()],oe.prototype,"_imageGalleryContext",null),e([p()],oe.prototype,"_imageOverlaysComponent",null),e([p()],oe.prototype,"_navigationUI",null),e([p()],oe.prototype,"_imageOverlayMessages",null),e([p()],oe.prototype,"_imageSketchToolsMessages",null),e([p()],oe.prototype,"_imageViewer",null),e([p()],oe.prototype,"_imageViewerTriangular",null),e([p()],oe.prototype,"_videoViewer",null),e([p()],oe.prototype,"_locationToggle",null),e([p()],oe.prototype,"_messageBox",null),e([p()],oe.prototype,"_navigationToolExpanded",void 0),e([p()],oe.prototype,"_navigationTool",void 0),e([p()],oe.prototype,"_panoramicVideoViewer",null),e([p()],oe.prototype,"_panoramicViewer",null),e([p({readOnly:!0})],oe.prototype,"noImageInSequenceError",null),e([p()],oe.prototype,"_renderNavigation",null),e([p()],oe.prototype,"_renderThumbnails",null),e([p()],oe.prototype,"_sketchLoaderTask",void 0),oe=e([y("esri.widgets.OrientedImageryViewer")],oe);const ne=oe;export{ne as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import i from"../../Camera.js";import t from"../../Ground.js";import a from"../../Map.js";import{createTask as r}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import o from"../../core/Error.js";import{EventedAccessor as n}from"../../core/Evented.js";import{JSONMap as h}from"../../core/jsonMap.js";import{rad2deg as m,deg2rad as d}from"../../core/mathUtils.js";import{abortMaybe as l}from"../../core/maybe.js";import{throwIfAborted as c}from"../../core/promiseUtils.js";import{watch as p,syncAndInitial as g,when as u,whenOnce as y}from"../../core/reactiveUtils.js";import{property as _,subclass as v}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as f}from"../../core/support/UpdatingHandles.js";import w from"../../geometry/SpatialReference.js";import M from"../../layers/GraphicsLayer.js";import{convertSphereVertexToPixelLocation as P}from"../../layers/orientedImagery/transformations/utils.js";import{isGraphic as R}from"../../support/graphicInstanceUtils.js";import C from"../../views/SceneView.js";import{defaultImageSphereCenter as z,defaultImageSphereSize as V,maxPanoramicViewerHFOV as H,minPanoramicViewerHFOV as k,humanBinocularHFOV as G}from"./constants.js";import b from"./PanoramicZoomConditions.js";import O from"./PanoramicZoomViewModel.js";import{meshToGraphic as j,findDiagonalFOV as x}from"./utils.js";import A from"./support/PanoramicMedia.js";import{enumeration as I}from"../../core/accessorSupport/decorators/enumeration.js";const S={default:"default",navigation:"navigation",fovConstraint:"fov-constraint",clickAction:"image-click-action"};let F=class extends n{constructor(e){super(e),this._panTask=null,this._startPosition=null,this._targetPosition=null,this.tileCache=new Set,this._graphics=new M({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:z},environment:{atmosphereEnabled:!1,starsEnabled:!1,lighting:{type:"virtual"}},popupEnabled:!1,spatialReference:w.WebMercator,attributionVisible:!1,ui:{components:["zoom"]}}),this._loadController=null,this.zoomViewModel=new O({panoramicViewerViewModel:this,view:this._imageRenderer,panoramicZoomConditions:new b({})}),this.autoLoad=!1,this.clickAction="none",this.imageMeshDistance=V/2,this.imageSize=null,this.pitch=90,this.state="ready",this.updatingHandles=new f,this.yaw=0,this._addNavigationHandles=(e=!0)=>{this.imageRenderer.basemapTerrain.suspended=!0,this.removeHandles(S.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,S.navigation)},this._addHFOVHandles=()=>{this.removeHandles(S.fovConstraint),this.addHandles(p(()=>[this.maxHFOV,this.minHFOV],()=>{this.zoomViewModel&&(this.zoomViewModel.panoramicZoomConditions=new b({view:this.imageRenderer,maxFOV:this.maxHFOV,minFOV:this.minHFOV}))},g),S.fovConstraint)},this._addZoomHandles=()=>{this.zoomViewModel=new O({view:this.imageRenderer,panoramicZoomConditions:new b({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=l(this._loadController)},this._createPanTask=()=>{this._panTask?.abort(),this._panTask=r(async e=>{if(!this.imagePyramid)return;const{hfov:i,vfov:t,yaw:a,pitch:r}=this,s=this.imagePyramid.getTiles(this.imagePyramidLevel,a,r,i,t).filter(e=>!this.tileCache.has(`${e.level}/${e.row}/${e.column}`));if(!s?.length)return;const o=await Promise.all(s.map(async i=>await i.loadMesh({signal:e})));c(e);const n=o.map(j);n.forEach((e,i)=>{const t=s[i].key;e.attributes={key:t},this.tileCache.add(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(R);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=P(e.mapPoint,this.imageSize[0],this.imageSize[1]);this.emit("pixel-location",{...i,spatialReference:w.WebMercator});break}}},this._handleWheel=e=>{const i=e.deltaX??e.native.deltaX;e.stopPropagation(),i>0||e.deltaY>0?this._zoomOut():this._zoomIn()},this._loadWithController=()=>{this._cancelLoadWithController(),this.media&&(this._loadController=new AbortController,this._loadMediaInternal(this.media,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.media=null,this._removeImageSphere()},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._cancelLoadWithController(),this.clearImage(),this._imageRenderer.destroy()}initialize(){this.state="initialized",this.addHandles([u(()=>null!=this.media&&this.autoLoad,this._loadWithController,g),p(()=>this.fov,()=>{this._reloadCamera()},g),p(()=>this.yaw,e=>{this.camera&&(this.camera.heading=e,this._reloadCamera())},g),p(()=>this.pitch,e=>{this.camera&&(this.camera.tilt=e,this._reloadCamera())},g),u(()=>this.imageRenderer.ready,()=>{this._addNavigationHandles(),this._addZoomHandles()},g),p(()=>this.clickAction,e=>{this.removeHandles(S.clickAction),"none"!==e&&this.addHandles(this.imageRenderer.on("click",this._handleImageClick))},g),p(()=>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(R),i=this.currentGraphics.map(e=>e.geometry.extent);e.forEach(e=>{e.visible=!0!==i.some(i=>i.intersects(e.geometry.extent))})})],S.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*m(Math.atan(Math.tan(d(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?x(H,e/i):H}get minHFOV(){const{size:[e,i]}=this.imageRenderer;return this.imageRenderer.ready?x(k,e/i):k}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*m(Math.atan(Math.tan(d(e/2))*(1/Math.sqrt(1+a**2))))}_clearImageSphere(){if(this.imagePyramid=null,this.imagePyramidLevel=-1,this.tileCache.clear(),!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())}async _loadMediaInternal(e,i){if(this.state="image-loading",this._removeImageSphere(),!e)throw this.state="ready",new o("panoramic-viewer:missing-media","No media provided to load.");try{const{meshOrMeshes:t,size:a,tileKeys:r}=await e.load(i),s=e.imagePyramid;if(c(i),s){this.imagePyramid=s,this.imagePyramidLevel=s.maximumPyramidLevel;const i=t;if(!i?.length)throw this.state="image-load-error",new o("panoramic-viewer:missing-tiles","No tiles were found in the pyramid",e.url);const a=i.map(j);a.forEach((e,i)=>{const t=r?.[i];e.attributes={key:t},this.tileCache.add(t)}),this._imageGraphic=a,this._graphics.addMany(this._imageGraphic)}else{const e=t;this._imageGraphic=j(e),this._graphics.add(this._imageGraphic)}return this.state="image-loaded",y(()=>this.imageRenderer.ready,i).then(()=>{const{size:[e,i]}=this.imageRenderer;this.fov=x(G,e/i)}),this.imageSize=a,this.media=e,t}catch(t){throw this._clearImageSphere(),this.state="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 loadMedia(e,i){this.state="image-loading";const t=this.autoLoad;this.autoLoad=!1;return await this._loadMediaInternal(e,i).finally(()=>{this.autoLoad=t})}};e([_()],F.prototype,"_graphics",void 0),e([_()],F.prototype,"_imageGraphic",void 0),e([_({constructOnly:!0})],F.prototype,"currentGraphics",void 0),e([_()],F.prototype,"imagePyramid",void 0),e([_()],F.prototype,"imagePyramidLevel",void 0),e([_()],F.prototype,"_map",void 0),e([_()],F.prototype,"_imageRenderer",void 0),e([_()],F.prototype,"_loadController",void 0),e([_()],F.prototype,"zoomViewModel",void 0),e([_({type:Boolean})],F.prototype,"autoLoad",void 0),e([_({type:i})],F.prototype,"camera",null),e([I(new h({emit:"emit",hittest:"hittest",none:"none","pixel-location":"pixel-location"}))],F.prototype,"clickAction",void 0),e([_()],F.prototype,"distanceFactor",null),e([_({type:Number})],F.prototype,"fov",null),e([_({readOnly:!0})],F.prototype,"hfov",null),e([_({type:A})],F.prototype,"media",void 0),e([_()],F.prototype,"imageMeshDistance",void 0),e([_({readOnly:!0})],F.prototype,"imageRenderer",null),e([_()],F.prototype,"imageSize",void 0),e([_({readOnly:!0})],F.prototype,"maxHFOV",null),e([_({readOnly:!0})],F.prototype,"minHFOV",null),e([_({type:Number})],F.prototype,"pitch",void 0),e([_()],F.prototype,"state",void 0),e([_()],F.prototype,"updatingHandles",void 0),e([_()],F.prototype,"updating",null),e([_({readOnly:!0})],F.prototype,"vfov",null),e([_({type:Number})],F.prototype,"yaw",void 0),F=e([v("esri.widgets.PanoramicViewer.PanoramicViewerViewModel")],F);const L=F;export{L as default};
2
+ import{__decorate as e}from"tslib";import i from"../../Camera.js";import t from"../../Ground.js";import a from"../../Map.js";import{createTask as r}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import o from"../../core/Error.js";import{EventedAccessor as n}from"../../core/Evented.js";import{JSONMap as h}from"../../core/jsonMap.js";import{rad2deg as m,deg2rad as d}from"../../core/mathUtils.js";import{abortMaybe as l}from"../../core/maybe.js";import{throwIfAborted as c}from"../../core/promiseUtils.js";import{watch as p,syncAndInitial as g,when as u,whenOnce as y}from"../../core/reactiveUtils.js";import{property as _,subclass as v}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as f}from"../../core/support/UpdatingHandles.js";import w from"../../geometry/SpatialReference.js";import M from"../../layers/GraphicsLayer.js";import{convertSphereVertexToPixelLocation as P}from"../../layers/orientedImagery/transformations/utils.js";import{isGraphic as R}from"../../support/graphicInstanceUtils.js";import C from"../../views/SceneView.js";import{extractHorizonAnglesFromMedia as z}from"../OrientedImageryViewer/utils.js";import{defaultImageSphereCenter as V,defaultImageSphereSize as H,maxPanoramicViewerHFOV as k,minPanoramicViewerHFOV as G,humanBinocularHFOV as O}from"./constants.js";import b from"./PanoramicZoomConditions.js";import j from"./PanoramicZoomViewModel.js";import{meshToGraphic as x,findDiagonalFOV as A}from"./utils.js";import I from"./support/PanoramicMedia.js";import{enumeration as S}from"../../core/accessorSupport/decorators/enumeration.js";const F={default:"default",navigation:"navigation",fovConstraint:"fov-constraint",clickAction:"image-click-action"};let L=class extends n{constructor(e){super(e),this._panTask=null,this._startPosition=null,this._targetPosition=null,this.tileCache=new Set,this._graphics=new M({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:V},environment:{atmosphereEnabled:!1,starsEnabled:!1,lighting:{type:"virtual"}},popupEnabled:!1,spatialReference:w.WebMercator,attributionVisible:!1,ui:{components:["zoom"]}}),this._loadController=null,this.zoomViewModel=new j({panoramicViewerViewModel:this,view:this._imageRenderer,panoramicZoomConditions:new b({})}),this.autoLoad=!1,this.clickAction="none",this.imageMeshDistance=H/2,this.imageSize=null,this.pitch=90,this.state="ready",this.updatingHandles=new f,this.yaw=0,this._addNavigationHandles=(e=!0)=>{this.imageRenderer.basemapTerrain.suspended=!0,this.removeHandles(F.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,F.navigation)},this._addHFOVHandles=()=>{this.removeHandles(F.fovConstraint),this.addHandles(p(()=>[this.maxHFOV,this.minHFOV],()=>{this.zoomViewModel&&(this.zoomViewModel.panoramicZoomConditions=new b({view:this.imageRenderer,maxFOV:this.maxHFOV,minFOV:this.minHFOV}))},g),F.fovConstraint)},this._addZoomHandles=()=>{this.zoomViewModel=new j({view:this.imageRenderer,panoramicZoomConditions:new b({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=l(this._loadController)},this._createPanTask=()=>{this._panTask?.abort(),this._panTask=r(async e=>{if(!this.imagePyramid)return;const{hfov:i,vfov:t,yaw:a,pitch:r}=this,s=this.imagePyramid.getTiles(this.imagePyramidLevel,a,r,i,t).filter(e=>!this.tileCache.has(`${e.level}/${e.row}/${e.column}`));if(!s?.length)return;const o=await Promise.all(s.map(async i=>await i.loadMesh({signal:e})));c(e);const n=o.map(x);n.forEach((e,i)=>{const t=s[i].key;e.attributes={key:t},this.tileCache.add(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(R);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||!this.media)return void this.emit("pixel-location",null);const i=z(this.media),t=P(e.mapPoint,this.imageSize[0],this.imageSize[1],i);this.emit("pixel-location",{...t,spatialReference:w.WebMercator});break}}},this._handleWheel=e=>{const i=e.deltaX??e.native.deltaX;e.stopPropagation(),i>0||e.deltaY>0?this._zoomOut():this._zoomIn()},this._loadWithController=()=>{this._cancelLoadWithController(),this.media&&(this._loadController=new AbortController,this._loadMediaInternal(this.media,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.media=null,this._removeImageSphere()},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._cancelLoadWithController(),this.clearImage(),this._imageRenderer.destroy()}initialize(){this.state="initialized",this.addHandles([u(()=>null!=this.media&&this.autoLoad,this._loadWithController,g),p(()=>this.fov,()=>{this._reloadCamera()},g),p(()=>this.yaw,e=>{this.camera&&(this.camera.heading=e,this._reloadCamera())},g),p(()=>this.pitch,e=>{this.camera&&(this.camera.tilt=e,this._reloadCamera())},g),u(()=>this.imageRenderer.ready,()=>{this._addNavigationHandles(),this._addZoomHandles()},g),p(()=>this.clickAction,e=>{this.removeHandles(F.clickAction),"none"!==e&&this.addHandles(this.imageRenderer.on("click",this._handleImageClick))},g),p(()=>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(R),i=this.currentGraphics.map(e=>e.geometry.extent);e.forEach(e=>{e.visible=!0!==i.some(i=>i.intersects(e.geometry.extent))})})],F.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*m(Math.atan(Math.tan(d(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?A(k,e/i):k}get minHFOV(){const{size:[e,i]}=this.imageRenderer;return this.imageRenderer.ready?A(G,e/i):G}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*m(Math.atan(Math.tan(d(e/2))*(1/Math.sqrt(1+a**2))))}_clearImageSphere(){if(this.imagePyramid=null,this.imagePyramidLevel=-1,this.tileCache.clear(),!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())}async _loadMediaInternal(e,i){if(this.state="image-loading",this._removeImageSphere(),!e)throw this.state="ready",new o("panoramic-viewer:missing-media","No media provided to load.");try{const{meshOrMeshes:t,size:a,tileKeys:r}=await e.load(i),s=e.imagePyramid;if(c(i),s){this.imagePyramid=s,this.imagePyramidLevel=s.maximumPyramidLevel;const i=t;if(!i?.length)throw this.state="image-load-error",new o("panoramic-viewer:missing-tiles","No tiles were found in the pyramid",e.url);const a=i.map(x);a.forEach((e,i)=>{const t=r?.[i];e.attributes={key:t},this.tileCache.add(t)}),this._imageGraphic=a,this._graphics.addMany(this._imageGraphic)}else{const e=t;this._imageGraphic=x(e),this._graphics.add(this._imageGraphic)}return this.state="image-loaded",y(()=>this.imageRenderer.ready,i).then(()=>{const{size:[e,i]}=this.imageRenderer;this.fov=A(O,e/i)}),this.imageSize=a,this.media=e,t}catch(t){throw this._clearImageSphere(),this.state="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 loadMedia(e,i){this.state="image-loading";const t=this.autoLoad;this.autoLoad=!1;return await this._loadMediaInternal(e,i).finally(()=>{this.autoLoad=t})}};e([_()],L.prototype,"_graphics",void 0),e([_()],L.prototype,"_imageGraphic",void 0),e([_({constructOnly:!0})],L.prototype,"currentGraphics",void 0),e([_()],L.prototype,"imagePyramid",void 0),e([_()],L.prototype,"imagePyramidLevel",void 0),e([_()],L.prototype,"_map",void 0),e([_()],L.prototype,"_imageRenderer",void 0),e([_()],L.prototype,"_loadController",void 0),e([_()],L.prototype,"zoomViewModel",void 0),e([_({type:Boolean})],L.prototype,"autoLoad",void 0),e([_({type:i})],L.prototype,"camera",null),e([S(new h({emit:"emit",hittest:"hittest",none:"none","pixel-location":"pixel-location"}))],L.prototype,"clickAction",void 0),e([_()],L.prototype,"distanceFactor",null),e([_({type:Number})],L.prototype,"fov",null),e([_({readOnly:!0})],L.prototype,"hfov",null),e([_({type:I})],L.prototype,"media",void 0),e([_()],L.prototype,"imageMeshDistance",void 0),e([_({readOnly:!0})],L.prototype,"imageRenderer",null),e([_()],L.prototype,"imageSize",void 0),e([_({readOnly:!0})],L.prototype,"maxHFOV",null),e([_({readOnly:!0})],L.prototype,"minHFOV",null),e([_({type:Number})],L.prototype,"pitch",void 0),e([_()],L.prototype,"state",void 0),e([_()],L.prototype,"updatingHandles",void 0),e([_()],L.prototype,"updating",null),e([_({readOnly:!0})],L.prototype,"vfov",null),e([_({type:Number})],L.prototype,"yaw",void 0),L=e([v("esri.widgets.PanoramicViewer.PanoramicViewerViewModel")],L);const T=L;export{T as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
2
- import{__decorate as i}from"tslib";import{on as t}from"../../../core/events.js";import{rad2deg as o}from"../../../core/mathUtils.js";import{EsriPromise as e}from"../../../core/Promise.js";import{throwIfAborted as s,createResolver as r,onAbort as a}from"../../../core/promiseUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{whenVideoPlayable as l}from"../../../layers/support/videoUtils.js";import{fixedImageSize as m}from"../../OrientedImageryViewer/constants.js";import c from"./PanoramicMediaError.js";const d=0,p=0,u=0,z=new Set(["JPG","JPEG","TIFF","TIF","MRF"]),y=new Set(["MRF","TIFF","TIF"]);let w=class extends e{constructor(i){super(i),this._size=[0,0],this._cache=null,this.autoLoad=!1,this.cameraHeading=null,this.extension=null,this.imagePyramid=null,this.type="image",this.uiStrings={}}destroy(){this._cache=null}get horizonPitch(){const{matrix:i}=this;return i?o(Math.asin(-i[6])):d}get horizonRoll(){const{matrix:i}=this;return i?o(Math.atan(i[7]/i[8])):u}get horizonYaw(){const{matrix:i,cameraHeading:t}=this;return i?o(Math.atan2(i[3],i[0])):t?-t:p}get size(){return this._size}async load(i){const{guessExtensionFromURI:t}=await import("../../OrientedImageryViewer/support/urlUtils.js");if(s(i),"video"===this.type)return this.loadVideoMesh(i);let o=this.extension;if(o||(o=t(this.url)),!o||!z.has(o))throw new c("unsupported-format",this.uiStrings["unsupported-format"]??"Unsupported image format: {extension}",{extension:o});return y.has(o)?this.loadOptimizedImageMesh(i):this.loadImageMesh(i)}async loadOptimizedImageMesh(i){const{loadMeshes:t,loadPyramid:o,loadRaster:e}=await import("../utils.js"),r=await e(this.url,i);s(i),this.imagePyramid=await o(r,i),s(i);const a=this.imagePyramid.getLowResolutionTiles(),h=await t(a,i);return s(i),this._size=this.imagePyramid.imageSize,{meshOrMeshes:h,size:this._size,tileKeys:a?.map(i=>i.key)}}async loadVideoMesh(i){const{createImageSphere:t}=await import("../utils.js");if(s(i),this._cache){const o=await t({data:this._cache,horizonPitch:this.horizonPitch,horizonRoll:this.horizonRoll,horizonYaw:this.horizonYaw}).load(i);return s(i),{meshOrMeshes:o,size:this._size}}const o=await this._resolveMedia(i);s(i),this._cache=o.media,this._size=[...m];const e=await t({data:this._cache,horizonPitch:this.horizonPitch,horizonRoll:this.horizonRoll,horizonYaw:this.horizonYaw}).load(i);return s(i),{meshOrMeshes:e,size:this._size}}async loadImageMesh(i){const{createImageSphere:t}=await import("../utils.js");if(s(i),this._cache){const o=await t({data:this._cache,horizonPitch:this.horizonPitch,horizonRoll:this.horizonRoll,horizonYaw:this.horizonYaw}).load(i);return s(i),{meshOrMeshes:o,size:this._size}}const o=await this._resolveMedia(i);s(i),this._cache=o.media;const e=o.mesh;return this._size=[o.media.width,o.media.height],{meshOrMeshes:e,size:this._size}}async _resolveMedia(i){const o=r(),e=a(i?.signal,o.resolve),h="video"===this.type?document.createElement("video"):document.createElement("img");h.crossOrigin="anonymous",h.src=this.url;let n=null;const m="video"===this.type?l(h,this.addHandles):await new Promise((i,o)=>{n=[t(h,"error",i=>{o(i)}),t(h,"load",i)]}).finally(()=>{n?.forEach(i=>i.remove()),n=null}),d=Promise.race([m,o.promise]);this.addResolvingPromise(d);try{await d}finally{e?.remove()}s(i);const p=h;if(!p)throw new c("unknown","Could not load media",{url:this.url});const{createImageSphere:u}=await import("../utils.js");s(i);const z=await u({data:h,horizonPitch:this.horizonPitch,horizonRoll:this.horizonRoll,horizonYaw:this.horizonYaw}).load(i);return s(i),{media:p,mesh:z}}};i([h()],w.prototype,"_size",void 0),i([h()],w.prototype,"autoLoad",void 0),i([h()],w.prototype,"cameraHeading",void 0),i([h()],w.prototype,"extension",void 0),i([h()],w.prototype,"horizonPitch",null),i([h()],w.prototype,"horizonRoll",null),i([h()],w.prototype,"horizonYaw",null),i([h()],w.prototype,"id",void 0),i([h()],w.prototype,"imagePyramid",void 0),i([h()],w.prototype,"matrix",void 0),i([h()],w.prototype,"size",null),i([h()],w.prototype,"type",void 0),i([h()],w.prototype,"uiStrings",void 0),i([h()],w.prototype,"url",void 0),w=i([n("esri.widgets.PanoramicViewer.support.PanoramicMedia")],w);const g=w;export{g as default};
2
+ import{__decorate as t}from"tslib";import{on as i}from"../../../core/events.js";import{rad2deg as o}from"../../../core/mathUtils.js";import{EsriPromise as e}from"../../../core/Promise.js";import{throwIfAborted as s,createResolver as r,onAbort as a}from"../../../core/promiseUtils.js";import{property as h}from"../../../core/accessorSupport/decorators/property.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{whenVideoPlayable as l}from"../../../layers/support/videoUtils.js";import{fixedImageSize as m}from"../../OrientedImageryViewer/constants.js";import c from"./PanoramicMediaError.js";const d=0,p=0,u=0,z=new Set(["JPG","JPEG","TIFF","TIF","MRF"]),y=new Set(["MRF","TIFF","TIF"]);let w=class extends e{constructor(t){super(t),this._size=[0,0],this._cache=null,this.autoLoad=!1,this.cameraHeading=null,this.extension=null,this.imagePyramid=null,this.type="image",this.uiStrings={}}destroy(){this._cache=null}get horizonPitch(){const{matrix:t}=this;return t?o(Math.asin(-t[6])):d}get horizonRoll(){const{matrix:t}=this;return t?o(Math.atan(t[7]/t[8])):u}get horizonYaw(){const{matrix:t,cameraHeading:i}=this;return t?o(Math.atan2(t[3],t[0])):i?-i:p}get size(){return this._size}async load(t){const{guessExtensionFromURI:i}=await import("../../OrientedImageryViewer/support/urlUtils.js");if(s(t),"video"===this.type)return this.loadVideoMesh(t);let o=this.extension;if(o||(o=i(this.url)),!o||!z.has(o))throw new c("unsupported-format",this.uiStrings["unsupported-format"]??"Unsupported image format: {extension}",{datasetFormat:o??"UNKNOWN FORMAT"});return y.has(o)?this.loadOptimizedImageMesh(t):this.loadImageMesh(t)}async loadOptimizedImageMesh(t){const{loadMeshes:i,loadPyramid:o,loadRaster:e}=await import("../utils.js"),r=await e(this.url,t);s(t),this.imagePyramid=await o(r,t),s(t);const a=this.imagePyramid.getLowResolutionTiles(),h=await i(a,t);return s(t),this._size=this.imagePyramid.imageSize,{meshOrMeshes:h,size:this._size,tileKeys:a?.map(t=>t.key)}}async loadVideoMesh(t){const{createImageSphere:i}=await import("../utils.js");if(s(t),this._cache){const o=await i({data:this._cache,horizonPitch:this.horizonPitch,horizonRoll:this.horizonRoll,horizonYaw:this.horizonYaw}).load(t);return s(t),{meshOrMeshes:o,size:this._size}}const o=await this._resolveMedia(t);s(t),this._cache=o.media,this._size=[...m];const e=await i({data:this._cache,horizonPitch:this.horizonPitch,horizonRoll:this.horizonRoll,horizonYaw:this.horizonYaw}).load(t);return s(t),{meshOrMeshes:e,size:this._size}}async loadImageMesh(t){const{createImageSphere:i}=await import("../utils.js");if(s(t),this._cache){const o=await i({data:this._cache,horizonPitch:this.horizonPitch,horizonRoll:this.horizonRoll,horizonYaw:this.horizonYaw}).load(t);return s(t),{meshOrMeshes:o,size:this._size}}const o=await this._resolveMedia(t);s(t),this._cache=o.media;const e=o.mesh;return this._size=[o.media.width,o.media.height],{meshOrMeshes:e,size:this._size}}async _resolveMedia(t){const o=r(),e=a(t?.signal,o.resolve),h="video"===this.type?document.createElement("video"):document.createElement("img");h.crossOrigin="anonymous",h.src=this.url;let n=null;const m="video"===this.type?l(h,this.addHandles):await new Promise((t,o)=>{n=[i(h,"error",t=>{o(t)}),i(h,"load",t)]}).finally(()=>{n?.forEach(t=>t.remove()),n=null}),d=Promise.race([m,o.promise]);this.addResolvingPromise(d);try{await d}finally{e?.remove()}s(t);const p=h;if(!p)throw new c("unknown","Could not load media",{url:this.url});const{createImageSphere:u}=await import("../utils.js");s(t);const z=await u({data:h,horizonPitch:this.horizonPitch,horizonRoll:this.horizonRoll,horizonYaw:this.horizonYaw}).load(t);return s(t),{media:p,mesh:z}}};t([h()],w.prototype,"_size",void 0),t([h()],w.prototype,"autoLoad",void 0),t([h()],w.prototype,"cameraHeading",void 0),t([h()],w.prototype,"extension",void 0),t([h()],w.prototype,"horizonPitch",null),t([h()],w.prototype,"horizonRoll",null),t([h()],w.prototype,"horizonYaw",null),t([h()],w.prototype,"id",void 0),t([h()],w.prototype,"imagePyramid",void 0),t([h()],w.prototype,"matrix",void 0),t([h()],w.prototype,"size",null),t([h()],w.prototype,"type",void 0),t([h()],w.prototype,"uiStrings",void 0),t([h()],w.prototype,"url",void 0),w=t([n("esri.widgets.PanoramicViewer.support.PanoramicMedia")],w);const g=w;export{g as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
2
- import{__decorate as t}from"tslib";import{isSome as e}from"../../core/arrayUtils.js";import i from"../../core/Collection.js";import s from"../../core/Error.js";import{EventedAccessor as o}from"../../core/Evented.js";import{JSONMap as a}from"../../core/jsonMap.js";import{clone as r}from"../../core/lang.js";import{LoadableMixin as l}from"../../core/Loadable.js";import{EsriPromiseMixin as n}from"../../core/Promise.js";import p from"../../core/ReactiveMap.js";import{watch as m,initial as h,whenOnce as d}from"../../core/reactiveUtils.js";import{createScreenPoint as u}from"../../core/screenUtils.js";import{unitType as c,convertUnit as f,getMetersPerUnitForSR as y,inchesPerMeter as v}from"../../core/units.js";import{property as T,subclass as w}from"../../core/accessorSupport/decorators.js";import _ from"../../geometry/Extent.js";import I from"../../geometry/SpatialReference.js";import{formatDate as g,convertDateFormatToIntlOptions as x}from"../../intl/date.js";import{getLocaleLanguage as O}from"../../intl/locale.js";import b from"../../portal/Portal.js";import E from"../../portal/PortalQueryParams.js";import{reArcGISOnlineDomain as L}from"../../portal/support/urlUtils.js";import{execute as P,getTaskInfo as S}from"../../rest/print.js";import{formatJsonMap as U}from"../../rest/support/fileFormat.js";import{fromJSON as k}from"../../rest/support/layoutTemplate.js";import C from"../../rest/support/LegendLayer.js";import j from"../../rest/support/PrintParameters.js";import{getVisibleLayerViews as F}from"../../rest/support/printTaskUtils.js";import M from"../../rest/support/PrintTemplate.js";import{getExtent as H}from"../../views/2d/viewpointUtils.js";import{ViewEventPriorities as D}from"../../views/input/InputManager.js";import A from"../../views/overlay/BoxOverlayItem.js";import W from"./CustomTemplate.js";import N from"./FileLink.js";import R from"./TemplateOptions.js";import{fetchLayoutTemplateInfos as V,valueUnitKebabDict as z}from"./utils.js";const B=[30,144,255,255],G=[237,211,23,255],q=[216,48,32,255],$=new Set(["GISProfessionalStdUT","GISProfessionalAdvUT"]),J=/(\/GPServer\/).+/i,Q=96,K=i.ofType(W),X=i.ofType(N),Y=new a({Feet:"feet",Miles:"miles",Meters:"meters",Kilometers:"kilometers"});function Z(t){t.layoutOptions??={},t.layoutOptions.customTextElements??=[];const e="date";if(!t.layoutOptions.customTextElements.find(t=>e in t)){const{customTextElements:e}=t.layoutOptions;let i=g(Date.now(),x("short-date"));"ar"===O()&&(i="‏"+i),e.push({date:i})}}function tt(t,e,i,s){if(!e.layoutOptions)return;if(!i)return void(e.layoutOptions.legendLayers=[]);if(!t)return;const o=F(t),a=[];for(const r of o)r.legendEnabled&&a.push(new C({layerId:r.layer.id,title:r.layer.title||void 0,dynamicLegend:s}));e.layoutOptions.legendLayers=a}function et(t,e,i){if(!e)return;!(e.visible===i)&&t.layoutOptions&&(t.layoutOptions.elementOverrides?t.layoutOptions.elementOverrides[e.name]={visible:i}:t.layoutOptions.elementOverrides={[e.name]:{visible:i}})}let it=class extends(l(n(o))){constructor(t){super(t),this._serviceTemplateCustomTextElements=null,this._templateIdToCustomTemplate=new p,this._isFreeHand=!1,this._freeHandWidth=0,this._freehandHeight=0,this._asyncPrintTaskUrl=null,this._layoutInfoTaskUrl=null,this._portalLayoutInfoTaskUrl=null,this._customLayoutOptions=null,this._exportedFileNameMap={},this._layoutTemplateInfosCache=new Map,this._tasksInfoCache=new Map,this.allowedFormats="all",this.allowedLayouts="all",this.browseTemplates=new K,this.defaultTemplates=new K,this.error=null,this.exportedLinks=new X,this.extraParameters=null,this.includeDefaultTemplates=!0,this.outSpatialReference=null,this.portal=b.getDefault(),this.portalTemplateIds=[],this.printServiceTemplates=new K,this.defaultTemplate=null,this.showPrintAreaEnabled=!1,this.printServiceUrl=null,this.printTimeout=12e4,this.saveExportEnabled=!1,this.templatesInfo=null,this.updateDelay=1e3,this.view=null,this.templateCustomTextElements=null,this.templateOptions=new R}initialize(){this.addHandles([m(()=>[this.showPrintAreaEnabled,this.view],()=>{this.showPrintAreaEnabled?this._enablePrintPreview():(this.removeHandles("overlay-handler"),this.view?.overlay?.removeItem(this._getOverlayItem()))}),m(()=>[this.templateOptions.layout,this.templateOptions.layoutItem],()=>{this.loaded&&this._processTemplateOptions()}),m(()=>[this.allowedFormats,this.allowedLayouts],()=>{this.loaded&&this._loadTemplateInfos()}),m(()=>this.exportedLinks,()=>{for(const{name:t,extension:e}of this.exportedLinks)t&&e&&this._updateExportedFileNameMap(`${t}${e}`)},h)])}destroy(){this.removeHandles("overlay-handler"),this.view&&(this._overlayItem&&(this.view.overlay?.removeItem(this._overlayItem),this._overlayItem.destroy(),this._overlayItem=null),this.view=null)}get effectivePrintServiceUrl(){return this.printServiceUrl??null}get effectiveTemplateCustomTextElements(){if(!this._serviceTemplateCustomTextElements)return{};const t=r(this._serviceTemplateCustomTextElements);return this.templateCustomTextElements&&Object.keys(this.templateCustomTextElements).forEach(e=>{const i=t[e];if(i){const t=this.templateCustomTextElements?.[e];i.forEach(e=>{const[i]=Object.entries(e)[0];t?.forEach(t=>{const[s,o]=Object.entries(t)[0];i===s&&(e[i]=o)})})}}),Object.freeze(t)}get state(){return"loading"===this.loadStatus?"initializing":"failed"===this.loadStatus||this.error?"error":"loaded"===this.loadStatus&&this.view?.ready?"ready":"disabled"}async print(t){const{view:e,extraParameters:i,updateDelay:o,outSpatialReference:a}=this;if(!e)throw new s("print:view-required","view is not set");Z(t);const r=this._getOverlayItem(),l=t.scalePreserved||!this.showPrintAreaEnabled?void 0:H(new _,e.viewpoint,"map-only"===t.layout?[t.exportOptions.width,t.exportOptions.height]:[r.boxWidth,r.boxHeight]),n=new j({view:e,template:t,extent:l,extraParameters:i,updateDelay:o,outSpatialReference:a});try{const e=!!t.layoutItem?.id&&(this.defaultTemplates.some(e=>e.layoutItem?.id===t.layoutItem?.id)||this.browseTemplates.some(e=>e.layoutItem?.id===t.layoutItem?.id));return await P(e&&this._asyncPrintTaskUrl?this._asyncPrintTaskUrl:this.effectivePrintServiceUrl,n,{timeout:this.printTimeout})}catch(p){throw new s("print:export-error","An error occurred while exporting the web map.",{error:p})}}async load(t){return this.addResolvingPromise(this._loadResources(t).catch(t=>this.error=t)),this}toPrintTemplate({attributionEnabled:t,author:e,copyright:i,customTextElements:o,dpi:a,forceFeatureAttributes:r,format:l,height:n,id:p,includeTables:m,layout:h,layoutItem:d,legendEnabled:u,dynamicLegendEnabled:c,northArrowEnabled:f,scale:y,scaleBarEnabled:v,scaleBarUnit:T,scaleEnabled:w,title:_,width:I}){if(!h&&!d)throw new s("print:layout-required","layout is not set");const g=new M({attributionVisible:t,forceFeatureAttributes:r,format:l,includeTables:m,layout:h,layoutItem:d,layoutOptions:{authorText:e||"",copyrightText:i||"",customTextElements:o,titleText:_||"",scalebarUnit:v&&T?Y.toJSON(T):void 0},outScale:y??0,scalePreserved:w});if(I&&(g.exportOptions.width=I),n&&(g.exportOptions.height=n),a&&(g.exportOptions.dpi=a),g.layoutOptions){tt(this.view,g,u,c);const t=this.getLayoutTemplateById(p)?.mapSurroundInfoOptions;if(t){const e=t.northArrow;for(const t of e)et(g,t,f);const i=t.scaleBar;for(const t of i)et(g,t,v);const s=t.legend;for(const t of s)et(g,t,u)}}return g}getLayoutTemplateById(t){return t?this._templateIdToCustomTemplate.get(t):null}async addPortalTemplate(t){if(!this.portal||!t?.id)return;try{if("loading"===this.loadStatus&&await d(()=>this.loaded),!this.loaded)throw new s("print:load-required","PrintViewModel must be loaded before adding portal templates.");t.loaded||await t.load()}catch{return void this.applyTemplate(this.defaultTemplate)}const e=new W({type:"browse-template",layoutInfoTaskUrl:this._portalLayoutInfoTaskUrl,label:t.title,layoutItem:t});this._templateIdToCustomTemplate.set(e.id,e),this.browseTemplates.add(e)}removePortalTemplate(t){t.layoutItem&&this.templateOptions.id===t.layoutItem.id&&(this.defaultTemplate?this.applyTemplate(this.defaultTemplate):this.templateOptions.reset()),this.browseTemplates.remove(t),this._templateIdToCustomTemplate.delete(t.id)}async applyTemplate(t){if(t&&t===this.getLayoutTemplateById(this.templateOptions.id))return;if(this.templateOptions.reset(),!t)return;if("map-only"===t)return void(this.templateOptions.layout="map-only");!t.layout||!this.templatesInfo||this.templatesInfo.layout.choiceList.includes(t.layout)||(this.defaultTemplate?t=this.defaultTemplate:this.templateOptions.reset());const e=t.layout||t.layoutItem?.id,i=e?this.templateCustomTextElements?.[e]:void 0;if(await this.templateOptions.applyTemplate(t,{customTextElements:i,customLayoutOptions:this._customLayoutOptions}),e&&this._serviceTemplateCustomTextElements&&!this._serviceTemplateCustomTextElements[e]&&t.layoutTemplateInfo?.layoutOptions?.customTextElements){const i=r(this._serviceTemplateCustomTextElements);i[e]=t.layoutTemplateInfo.layoutOptions.customTextElements,this._serviceTemplateCustomTextElements=Object.freeze(i)}}createExportedFileLink(t){const e=this.toPrintTemplate(this.templateOptions).format.toLowerCase(),i=e.includes("png")?"png":e,s=t+i;return this._updateExportedFileNameMap(s),new N({name:t,extension:i,count:this._exportedFileNameMap[s]})}export(t){const e=this.createExportedFileLink(t);this.exportedLinks.add(e);const i=this.print(this.toPrintTemplate(this.templateOptions)).then(t=>e.set({url:t?.url,state:"ready"})).catch(t=>e.set({error:t,state:"error"}));return this.emit("submit",{link:e,saveExportEnabled:this.saveExportEnabled}),i.then(t=>this.emit("complete",{link:t,saveExportEnabled:this.saveExportEnabled})),{link:e,promise:i}}async _loadResources(t){this.destroyed||(await this._loadUrls(t),await this._loadTemplateInfos(t),this._updateOverLayItem())}async _loadTemplateInfos(t){const e=[...this.defaultTemplates,...this.printServiceTemplates];for(const{id:o}of e)this._templateIdToCustomTemplate.delete(o);this.defaultTemplates.removeAll(),this.printServiceTemplates.removeAll();const[i,s]=await Promise.all([this._getLayoutToLayoutTemplateInfos(t),this._getPrintServiceTemplatesInfo(t)]);await this._loadAllTemplates(i,s,t),this._processPrintServiceTemplatesInfo(s),await this._processTemplateOptions()}_updateExportedFileNameMap(t){void 0!==this._exportedFileNameMap[t]?this._exportedFileNameMap[t]++:this._exportedFileNameMap[t]=0}async _processTemplateOptions(){const{layout:t,layoutItem:e}=this.templateOptions;if("map-only"!==t)if(this._customLayoutOptions={legend:this.templateOptions.legendEnabled,northArrow:this.templateOptions.northArrowEnabled,scaleBar:this.templateOptions.scaleBarEnabled},e?.id){try{e.loaded||await e.load()}catch{return void this.applyTemplate(this.defaultTemplate)}let t=this._templateIdToCustomTemplate.get(e.id);t||(t=new W({label:e.title,layoutItem:e,layoutInfoTaskUrl:this._portalLayoutInfoTaskUrl}),this._templateIdToCustomTemplate.set(t.id,t)),await this.applyTemplate(t)}else if(t){const t=this.defaultTemplates.find(t=>t.layout===this.templateOptions.layout)??this.printServiceTemplates.find(t=>t.layout===this.templateOptions.layout);await this.applyTemplate(t??this.defaultTemplate)}}async _loadPortal(t){try{await this.portal.load(t)}catch(e){throw new s("print:could-not-load-portal","Cannot load print resource information from portal",{error:e,url:this.effectivePrintServiceUrl})}}async _loadUrls(t){if(this.printServiceUrl)this._set("effectivePrintServiceUrl",this.printServiceUrl),this._layoutInfoTaskUrl=await this._getLayoutInfoTaskUrl(this.effectivePrintServiceUrl,t);else{await this._loadPortal(t);const{printTask:e,asyncPrintTask:i,layoutInfoTask:s}=this.portal?.helperServices??{};this._set("effectivePrintServiceUrl",e?.url),this._asyncPrintTaskUrl=i?.url,this._layoutInfoTaskUrl=await this._getLayoutInfoTaskUrl(this.effectivePrintServiceUrl,t),s?.url&&this.effectivePrintServiceUrl!==s.url?this._portalLayoutInfoTaskUrl=await this._getLayoutInfoTaskUrl(s.url,t):this._portalLayoutInfoTaskUrl=this._layoutInfoTaskUrl}const e=this.effectivePrintServiceUrl?.toLowerCase().split("/");if(!e?.includes("gpserver"))throw new s("print:invalid-print-service-url","Can't fetch print templates information from provided URL",{url:this.effectivePrintServiceUrl})}async _getLayoutInfoTaskUrl(t,e){if(!t)return null;const i=await S(t,"GetLayoutTemplatesInfo",e);return i?t.replace(J,`$1${encodeURI(i.displayName)}`):null}_getPortalDefaultTemplates(t,e){return this.portal?.helperServices?.printTask?.templates?.filter(t=>"map_only"!==t.layout.toLowerCase()&&(!e||e.includes(k(t.layout))))?.map(e=>{const i=W.fromJSON(e);if(i.type="default-template",i.layoutInfoTaskUrl=this._layoutInfoTaskUrl,i.layout){const e=t.get(i.layout);e&&i.setLayoutTemplateInfo(e)}return i})??[]}async _getPortalCustomTemplates(t){if(this.printServiceUrl||!this.portal)return[];const{layoutGroupQuery:e,user:i}=this.portal,s=L.test(this.portal.url),o=i?.userLicenseTypeId,a=o&&$.has(o);if(!e||s&&!a)return[];const r=new E({query:e,disableExtraQuery:!0}),l=await this.portal.queryGroups(r,t);if(!l.total)return[];const n=l.results[0],p=new E({num:100,query:"type:Layout",sortField:n.sortField,sortOrder:n.sortOrder??void 0}),m=(await n.queryItems(p,t)).results;if(!m.length)return[];return m.map(t=>(this.portalTemplateIds.push(t.id),new W({type:"default-template",label:t.title,layoutItem:t,layoutInfoTaskUrl:this._portalLayoutInfoTaskUrl})))}async _loadAllTemplates(t,e,i){let s=!1;const o=e?.layout?.choiceList;if(this.includeDefaultTemplates&&this.portal&&!this.printServiceUrl){const e=this._getPortalDefaultTemplates(t,o);s=!!e.length,this.defaultTemplates.addMany(e);const a=await this._getPortalCustomTemplates(i);this.defaultTemplates.addMany(a);for(const t of this.defaultTemplates)this._templateIdToCustomTemplate.set(t.id,t)}s||t.forEach((t,e)=>{if(!o||o.includes(e)){const i=new W({type:"print-service-template",layout:e,layoutInfoTaskUrl:this._layoutInfoTaskUrl});i.setLayoutTemplateInfo(t),this.printServiceTemplates.add(i),this._templateIdToCustomTemplate.set(i.id,i)}})}_processPrintServiceTemplatesInfo(t){this._set("templatesInfo",t);const e=t?.layout?.defaultValue;if(e&&"map-only"!==e){const t=this.defaultTemplates.find(t=>t.layout===e)??this.printServiceTemplates.find(t=>t.layout===e)??this.defaultTemplates.at(0)??this.printServiceTemplates.at(0);this._set("defaultTemplate",t)}}async _getLayoutToLayoutTemplateInfos(t){const e=this._layoutInfoTaskUrl,i=e?this._layoutTemplateInfosCache.get(e):void 0,s=i??await V(e,void 0,t);i||this._layoutTemplateInfosCache.set(e,s);const o=new Map,a={};for(const r of s){const t=k(r.layoutTemplate);o.set(t,r),a[t]=r.layoutOptions.customTextElements}return this._serviceTemplateCustomTextElements=Object.freeze(a),o}async _getPrintServiceTemplatesInfo(t){const e=this.effectivePrintServiceUrl?this._tasksInfoCache.get(this.effectivePrintServiceUrl):void 0,i=e??await S(this.effectivePrintServiceUrl,"ExportWebMap",t);if(!i)throw new s("print:unavailable-service-info","Can't fetch templates info from service");e||this._tasksInfoCache.set(this.effectivePrintServiceUrl,i);const{parameters:o}=i,a=o.find(({name:t})=>"Format"===t),r=o.find(({name:t})=>"Layout_Template"===t);return{format:this._getFormat(a),layout:this._getLayout(r)}}_getFormat(t){const i="all"===this.allowedFormats?t.choiceList:t.choiceList.filter(t=>"string"!=typeof this.allowedFormats&&this.allowedFormats.some(e=>new RegExp(`\\b${e}\\b`,"i").test(t))),s=(i.length?i:t.choiceList).map(t=>U.fromJSON(t)).filter(e),o=U.fromJSON(t.defaultValue),a=s.some(t=>new RegExp(`\\b${o}\\b`,"i").test(t))?o:s[0];return{choiceList:s,defaultValue:a}}_getLayout(t){const i=t.choiceList.filter(t=>"map_only"!==t.toLowerCase()),s="all"===this.allowedLayouts?i:i.filter(t=>this.allowedLayouts.includes(k(t))),o=(s.length?s:i).map(k).filter(e),a=k(t.defaultValue),r=o.includes(a)?a:o.find(t=>/(?=.*letter)(?=.*landscape)/i.test(t))??o.find(t=>/(?=.*a4)(?=.*landscape)/i.test(t))??o[0];return{choiceList:o,defaultValue:r}}_getOverlayItem(){return this._overlayItem||(this._overlayItem=new A({strokeDash:[5],strokeWidth:2,strokeColor:[30,144,255,255]})),this._overlayItem}_enablePrintPreview(){if(!this.view?.overlay)return;const t=this.templateOptions,e=this._getOverlayItem();this.addHandles([m(()=>[t.width,t.height,t.scaleEnabled,t.scale,t.layout,t.layoutItem,t.id,t.state,t.dpi,this.view?.scale,this.view?.size,this.view?.state.paddedViewState.size,this.view?.state.padding,this.loaded],()=>this._updateOverLayItem(),h),this.view?.on("drag",["Shift"],t=>this._handleDrag(t),D.WIDGET),this.view?.on("key-down",["Escape"],()=>this._resetDrag(),D.WIDGET)],"overlay-handler"),this.view.overlay.addItem(e)}_updateOverLayItem(){if(!this.view)return;const t=this.templateOptions,e=this._getOverlayItem(),i=t.layoutItem?.id??t.layout,s=this.view,o=s.spatialReference,[a,r]=s.state.paddedViewState.size,l=s.state.padding;let n=0,p=0;if("map-only"===i)null!=t.width&&null!=t.height&&(n=t.width,p=t.height);else if(i){const e=t.id?this._templateIdToCustomTemplate.get(t.id):null,{webMapFrameSize:i,pageUnits:s}=e?.layoutTemplateInfo??{};let l=!1;if(i&&s)if(this._isFreeHand){const t=i[0]/i[1];n=this._freeHandWidth,p=this._freehandHeight,n>p?p=n/t:n=p*t}else{const t=z.fromJSON(s.toLowerCase()),e=o.unit;c(t)===c(e)?(n=f(i[0],t,e),p=f(i[1],t,e)):(l=!0,n=i[0],p=i[1])}if(!this._isFreeHand)if(t.scaleEnabled&&t.scale){const t=l?Math.min(a/n,r/p):y(o)*v*Q;n*=t,p*=t}else if(0===n||0===p)n=a,p=r;else{const t=(a-.1*a)/n,e=(r-.1*r)/p,i=Math.min(t,e);n*=i,p*=i}}const{scaleEnabled:m,scale:h}=t,d=m&&h?h/this.view.scale:1;if(e.boxWidth=n*d||a,e.boxHeight=p*d||r,l&&(e.padding=l),e.backgroundWidth=a??0,e.backgroundHeight=r??0,"loading"===this.loadStatus)e.strokeColor=G;else if("loaded"===this.loadStatus)switch(this.templateOptions.state){case"pending":e.strokeColor=G;break;case"ready":e.strokeColor=B;break;case"error":e.strokeColor=q}}_resetDrag(){this._isFreeHand=!1,this._updateOverLayItem()}_handleDrag(t){switch(t.action){case"start":this._start();break;case"update":this._update(t);break;case"end":this._end()}t.stopPropagation()}_start(){this._isFreeHand=!0}_update(t){const e=this._getOverlayItem(),{x:i,y:s}=t,{x:o,y:a}=t.origin;i>o?(e.x=o,e.boxWidth=i-o):(e.x=i,e.boxWidth=o-i),s>a?(e.y=a,e.boxHeight=s-a):(e.y=s,e.boxHeight=a-s)}_end(){const t=this._getOverlayItem();if(!this.view||null==t.x||null==t.y)return;const e=this.view,i=e.toMap(u(t.x+.5*t.boxWidth,t.y+.5*t.boxHeight));t.x=null,t.y=null,e.goTo({center:i}),this._freeHandWidth=t.boxWidth,this._freehandHeight=t.boxHeight,"map-only"===this.templateOptions.layout&&(this.templateOptions.width=this._freeHandWidth,this.templateOptions.height=this._freehandHeight),this.templateOptions.scale=this.view.scale,this._updateOverLayItem()}};t([T()],it.prototype,"_serviceTemplateCustomTextElements",void 0),t([T()],it.prototype,"_templateIdToCustomTemplate",void 0),t([T()],it.prototype,"allowedFormats",void 0),t([T()],it.prototype,"allowedLayouts",void 0),t([T({type:K})],it.prototype,"browseTemplates",void 0),t([T({type:K})],it.prototype,"defaultTemplates",void 0),t([T()],it.prototype,"error",void 0),t([T({type:X})],it.prototype,"exportedLinks",void 0),t([T()],it.prototype,"extraParameters",void 0),t([T()],it.prototype,"includeDefaultTemplates",void 0),t([T({readOnly:!0})],it.prototype,"effectivePrintServiceUrl",null),t([T()],it.prototype,"effectiveTemplateCustomTextElements",null),t([T({type:I})],it.prototype,"outSpatialReference",void 0),t([T({type:b})],it.prototype,"portal",void 0),t([T()],it.prototype,"portalTemplateIds",void 0),t([T({type:K})],it.prototype,"printServiceTemplates",void 0),t([T({readOnly:!0})],it.prototype,"defaultTemplate",void 0),t([T()],it.prototype,"showPrintAreaEnabled",void 0),t([T()],it.prototype,"printServiceUrl",void 0),t([T()],it.prototype,"printTimeout",void 0),t([T()],it.prototype,"saveExportEnabled",void 0),t([T({readOnly:!0})],it.prototype,"state",null),t([T({readOnly:!0})],it.prototype,"templatesInfo",void 0),t([T()],it.prototype,"updateDelay",void 0),t([T()],it.prototype,"view",void 0),t([T()],it.prototype,"templateCustomTextElements",void 0),t([T({type:R})],it.prototype,"templateOptions",void 0),it=t([w("esri.widgets.Print.PrintViewModel")],it);const st=it;export{st as default};
2
+ import{__decorate as t}from"tslib";import{isSome as e}from"../../core/arrayUtils.js";import s from"../../core/Collection.js";import i from"../../core/Error.js";import{EventedAccessor as o}from"../../core/Evented.js";import{JSONMap as a}from"../../core/jsonMap.js";import{clone as r}from"../../core/lang.js";import{LoadableMixin as l}from"../../core/Loadable.js";import{EsriPromiseMixin as n}from"../../core/Promise.js";import p from"../../core/ReactiveMap.js";import{watch as m,initial as h,whenOnce as d}from"../../core/reactiveUtils.js";import{createScreenPoint as u}from"../../core/screenUtils.js";import{unitType as c,convertUnit as f,getMetersPerUnitForSR as y,inchesPerMeter as v}from"../../core/units.js";import{property as T,subclass as w}from"../../core/accessorSupport/decorators.js";import _ from"../../geometry/Extent.js";import I from"../../geometry/SpatialReference.js";import{formatDate as g,convertDateFormatToIntlOptions as x}from"../../intl/date.js";import{getLocaleLanguage as b}from"../../intl/locale.js";import O from"../../portal/Portal.js";import E from"../../portal/PortalQueryParams.js";import{reArcGISOnlineDomain as L}from"../../portal/support/urlUtils.js";import{execute as S,getTaskInfo as P}from"../../rest/print.js";import{formatJsonMap as U}from"../../rest/support/fileFormat.js";import{fromJSON as k}from"../../rest/support/layoutTemplate.js";import C from"../../rest/support/LegendLayer.js";import j from"../../rest/support/PrintParameters.js";import{getVisibleLayerViews as F}from"../../rest/support/printTaskUtils.js";import M from"../../rest/support/PrintTemplate.js";import{getExtent as H}from"../../views/2d/viewpointUtils.js";import{ViewEventPriorities as A}from"../../views/input/InputManager.js";import D from"../../views/overlay/BoxOverlayItem.js";import W from"./CustomTemplate.js";import N from"./FileLink.js";import R from"./TemplateOptions.js";import{fetchLayoutTemplateInfos as V,valueUnitKebabDict as z}from"./utils.js";const B=[30,144,255,255],G=[237,211,23,255],q=[216,48,32,255],$=new Set(["GISProfessionalStdUT","GISProfessionalAdvUT"]),J=/(\/GPServer\/).+/i,Q=96,K=s.ofType(W),X=s.ofType(N),Y=new a({Feet:"feet",Miles:"miles",Meters:"meters",Kilometers:"kilometers"});function Z(t){t.layoutOptions??={},t.layoutOptions.customTextElements??=[];const e="date";if(!t.layoutOptions.customTextElements.find(t=>e in t)){const{customTextElements:e}=t.layoutOptions;let s=g(Date.now(),x("short-date"));"ar"===b()&&(s="‏"+s),e.push({date:s})}}function tt(t,e,s){const i=t.visible??!0,o=t.legendEnabled??!0;if(!i||!o)return;const a=0===e,r=t.minScale??0,l=t.maxScale??0;if(!(a||(0===r||e<=r)&&(0===l||e>=l)))return;const n=t.sublayers?.toArray();if(n)for(const p of n)tt(p,e,s);else t.id&&s.push(String(t.id))}function et(t,e,s,i){if(!e.layoutOptions)return;if(!s)return void(e.layoutOptions.legendLayers=[]);if(!t)return;let o=0;e.scalePreserved&&(o=e.outScale||t.scale);const a=F(t),r=[];for(const l of a)if(l.legendEnabled){const t="sublayers"in l.layer&&l.layer.sublayers?l.layer.sublayers.toArray():void 0,e=[];for(const s of t??[])tt(s,o,e);r.push(new C({layerId:l.layer.id,title:l.layer.title||void 0,subLayerIds:t?e:void 0,dynamicLegend:i}))}e.layoutOptions.legendLayers=r}function st(t,e,s){if(!e)return;!(e.visible===s)&&t.layoutOptions&&(t.layoutOptions.elementOverrides?t.layoutOptions.elementOverrides[e.name]={visible:s}:t.layoutOptions.elementOverrides={[e.name]:{visible:s}})}let it=class extends(l(n(o))){constructor(t){super(t),this._serviceTemplateCustomTextElements=null,this._templateIdToCustomTemplate=new p,this._isFreeHand=!1,this._freeHandWidth=0,this._freehandHeight=0,this._asyncPrintTaskUrl=null,this._layoutInfoTaskUrl=null,this._portalLayoutInfoTaskUrl=null,this._customLayoutOptions=null,this._exportedFileNameMap={},this._layoutTemplateInfosCache=new Map,this._tasksInfoCache=new Map,this.allowedFormats="all",this.allowedLayouts="all",this.browseTemplates=new K,this.defaultTemplates=new K,this.error=null,this.exportedLinks=new X,this.extraParameters=null,this.includeDefaultTemplates=!0,this.outSpatialReference=null,this.portal=O.getDefault(),this.portalTemplateIds=[],this.printServiceTemplates=new K,this.defaultTemplate=null,this.showPrintAreaEnabled=!1,this.printServiceUrl=null,this.printTimeout=12e4,this.saveExportEnabled=!1,this.templatesInfo=null,this.updateDelay=1e3,this.view=null,this.templateCustomTextElements=null,this.templateOptions=new R}initialize(){this.addHandles([m(()=>[this.showPrintAreaEnabled,this.view],()=>{this.showPrintAreaEnabled?this._enablePrintPreview():(this.removeHandles("overlay-handler"),this.view?.overlay?.removeItem(this._getOverlayItem()))}),m(()=>[this.templateOptions.layout,this.templateOptions.layoutItem],()=>{this.loaded&&this._processTemplateOptions()}),m(()=>[this.allowedFormats,this.allowedLayouts],()=>{this.loaded&&this._loadTemplateInfos()}),m(()=>this.exportedLinks,()=>{for(const{name:t,extension:e}of this.exportedLinks)t&&e&&this._updateExportedFileNameMap(`${t}${e}`)},h)])}destroy(){this.removeHandles("overlay-handler"),this.view&&(this._overlayItem&&(this.view.overlay?.removeItem(this._overlayItem),this._overlayItem.destroy(),this._overlayItem=null),this.view=null)}get effectivePrintServiceUrl(){return this.printServiceUrl??null}get effectiveTemplateCustomTextElements(){if(!this._serviceTemplateCustomTextElements)return{};const t=r(this._serviceTemplateCustomTextElements);return this.templateCustomTextElements&&Object.keys(this.templateCustomTextElements).forEach(e=>{const s=t[e];if(s){const t=this.templateCustomTextElements?.[e];s.forEach(e=>{const[s]=Object.entries(e)[0];t?.forEach(t=>{const[i,o]=Object.entries(t)[0];s===i&&(e[s]=o)})})}}),Object.freeze(t)}get state(){return"loading"===this.loadStatus?"initializing":"failed"===this.loadStatus||this.error?"error":"loaded"===this.loadStatus&&this.view?.ready?"ready":"disabled"}async print(t){const{view:e,extraParameters:s,updateDelay:o,outSpatialReference:a}=this;if(!e)throw new i("print:view-required","view is not set");Z(t);const r=this._getOverlayItem(),l=t.scalePreserved||!this.showPrintAreaEnabled?void 0:H(new _,e.viewpoint,"map-only"===t.layout?[t.exportOptions.width,t.exportOptions.height]:[r.boxWidth,r.boxHeight]),n=new j({view:e,template:t,extent:l,extraParameters:s,updateDelay:o,outSpatialReference:a});try{const e=!!t.layoutItem?.id&&(this.defaultTemplates.some(e=>e.layoutItem?.id===t.layoutItem?.id)||this.browseTemplates.some(e=>e.layoutItem?.id===t.layoutItem?.id));return await S(e&&this._asyncPrintTaskUrl?this._asyncPrintTaskUrl:this.effectivePrintServiceUrl,n,{timeout:this.printTimeout})}catch(p){throw new i("print:export-error","An error occurred while exporting the web map.",{error:p})}}async load(t){return this.addResolvingPromise(this._loadResources(t).catch(t=>this.error=t)),this}toPrintTemplate({attributionEnabled:t,author:e,copyright:s,customTextElements:o,dpi:a,forceFeatureAttributes:r,format:l,height:n,id:p,includeTables:m,layout:h,layoutItem:d,legendEnabled:u,dynamicLegendEnabled:c,northArrowEnabled:f,scale:y,scaleBarEnabled:v,scaleBarUnit:T,scaleEnabled:w,title:_,width:I}){if(!h&&!d)throw new i("print:layout-required","layout is not set");const g=new M({attributionVisible:t,forceFeatureAttributes:r,format:l,includeTables:m,layout:h,layoutItem:d,layoutOptions:{authorText:e||"",copyrightText:s||"",customTextElements:o,titleText:_||"",scalebarUnit:v&&T?Y.toJSON(T):void 0},outScale:y??0,scalePreserved:w});if(I&&(g.exportOptions.width=I),n&&(g.exportOptions.height=n),a&&(g.exportOptions.dpi=a),g.layoutOptions){et(this.view,g,u,c);const t=this.getLayoutTemplateById(p)?.mapSurroundInfoOptions;if(t){const e=t.northArrow;for(const t of e)st(g,t,f);const s=t.scaleBar;for(const t of s)st(g,t,v);const i=t.legend;for(const t of i)st(g,t,u)}}return g}getLayoutTemplateById(t){return t?this._templateIdToCustomTemplate.get(t):null}async addPortalTemplate(t){if(!this.portal||!t?.id)return;try{if("loading"===this.loadStatus&&await d(()=>this.loaded),!this.loaded)throw new i("print:load-required","PrintViewModel must be loaded before adding portal templates.");t.loaded||await t.load()}catch{return void this.applyTemplate(this.defaultTemplate)}const e=new W({type:"browse-template",layoutInfoTaskUrl:this._portalLayoutInfoTaskUrl,label:t.title,layoutItem:t});this._templateIdToCustomTemplate.set(e.id,e),this.browseTemplates.add(e)}removePortalTemplate(t){t.layoutItem&&this.templateOptions.id===t.layoutItem.id&&(this.defaultTemplate?this.applyTemplate(this.defaultTemplate):this.templateOptions.reset()),this.browseTemplates.remove(t),this._templateIdToCustomTemplate.delete(t.id)}async applyTemplate(t){if(t&&t===this.getLayoutTemplateById(this.templateOptions.id))return;if(this.templateOptions.reset(),!t)return;if("map-only"===t)return void(this.templateOptions.layout="map-only");!t.layout||!this.templatesInfo||this.templatesInfo.layout.choiceList.includes(t.layout)||(this.defaultTemplate?t=this.defaultTemplate:this.templateOptions.reset());const e=t.layout||t.layoutItem?.id,s=e?this.templateCustomTextElements?.[e]:void 0;if(await this.templateOptions.applyTemplate(t,{customTextElements:s,customLayoutOptions:this._customLayoutOptions}),e&&this._serviceTemplateCustomTextElements&&!this._serviceTemplateCustomTextElements[e]&&t.layoutTemplateInfo?.layoutOptions?.customTextElements){const s=r(this._serviceTemplateCustomTextElements);s[e]=t.layoutTemplateInfo.layoutOptions.customTextElements,this._serviceTemplateCustomTextElements=Object.freeze(s)}}createExportedFileLink(t){const e=this.toPrintTemplate(this.templateOptions).format.toLowerCase(),s=e.includes("png")?"png":e,i=t+s;return this._updateExportedFileNameMap(i),new N({name:t,extension:s,count:this._exportedFileNameMap[i]})}export(t){const e=this.createExportedFileLink(t);this.exportedLinks.add(e);const s=this.print(this.toPrintTemplate(this.templateOptions)).then(t=>e.set({url:t?.url,state:"ready"})).catch(t=>e.set({error:t,state:"error"}));return this.emit("submit",{link:e,saveExportEnabled:this.saveExportEnabled}),s.then(t=>this.emit("complete",{link:t,saveExportEnabled:this.saveExportEnabled})),{link:e,promise:s}}async _loadResources(t){this.destroyed||(await this._loadUrls(t),await this._loadTemplateInfos(t),this._updateOverLayItem())}async _loadTemplateInfos(t){const e=[...this.defaultTemplates,...this.printServiceTemplates];for(const{id:o}of e)this._templateIdToCustomTemplate.delete(o);this.defaultTemplates.removeAll(),this.printServiceTemplates.removeAll();const[s,i]=await Promise.all([this._getLayoutToLayoutTemplateInfos(t),this._getPrintServiceTemplatesInfo(t)]);await this._loadAllTemplates(s,i,t),this._processPrintServiceTemplatesInfo(i),await this._processTemplateOptions()}_updateExportedFileNameMap(t){void 0!==this._exportedFileNameMap[t]?this._exportedFileNameMap[t]++:this._exportedFileNameMap[t]=0}async _processTemplateOptions(){const{layout:t,layoutItem:e}=this.templateOptions;if("map-only"!==t)if(this._customLayoutOptions={legend:this.templateOptions.legendEnabled,northArrow:this.templateOptions.northArrowEnabled,scaleBar:this.templateOptions.scaleBarEnabled},e?.id){try{e.loaded||await e.load()}catch{return void this.applyTemplate(this.defaultTemplate)}let t=this._templateIdToCustomTemplate.get(e.id);t||(t=new W({label:e.title,layoutItem:e,layoutInfoTaskUrl:this._portalLayoutInfoTaskUrl}),this._templateIdToCustomTemplate.set(t.id,t)),await this.applyTemplate(t)}else if(t){const t=this.defaultTemplates.find(t=>t.layout===this.templateOptions.layout)??this.printServiceTemplates.find(t=>t.layout===this.templateOptions.layout);await this.applyTemplate(t??this.defaultTemplate)}}async _loadPortal(t){try{await this.portal.load(t)}catch(e){throw new i("print:could-not-load-portal","Cannot load print resource information from portal",{error:e,url:this.effectivePrintServiceUrl})}}async _loadUrls(t){if(this.printServiceUrl)this._set("effectivePrintServiceUrl",this.printServiceUrl),this._layoutInfoTaskUrl=await this._getLayoutInfoTaskUrl(this.effectivePrintServiceUrl,t);else{await this._loadPortal(t);const{printTask:e,asyncPrintTask:s,layoutInfoTask:i}=this.portal?.helperServices??{};this._set("effectivePrintServiceUrl",e?.url),this._asyncPrintTaskUrl=s?.url,this._layoutInfoTaskUrl=await this._getLayoutInfoTaskUrl(this.effectivePrintServiceUrl,t),i?.url&&this.effectivePrintServiceUrl!==i.url?this._portalLayoutInfoTaskUrl=await this._getLayoutInfoTaskUrl(i.url,t):this._portalLayoutInfoTaskUrl=this._layoutInfoTaskUrl}const e=this.effectivePrintServiceUrl?.toLowerCase().split("/");if(!e?.includes("gpserver"))throw new i("print:invalid-print-service-url","Can't fetch print templates information from provided URL",{url:this.effectivePrintServiceUrl})}async _getLayoutInfoTaskUrl(t,e){if(!t)return null;const s=await P(t,"GetLayoutTemplatesInfo",e);return s?t.replace(J,`$1${encodeURI(s.displayName)}`):null}_getPortalDefaultTemplates(t,e){return this.portal?.helperServices?.printTask?.templates?.filter(t=>"map_only"!==t.layout.toLowerCase()&&(!e||e.includes(k(t.layout))))?.map(e=>{const s=W.fromJSON(e);if(s.type="default-template",s.layoutInfoTaskUrl=this._layoutInfoTaskUrl,s.layout){const e=t.get(s.layout);e&&s.setLayoutTemplateInfo(e)}return s})??[]}async _getPortalCustomTemplates(t){if(this.printServiceUrl||!this.portal)return[];const{layoutGroupQuery:e,user:s}=this.portal,i=L.test(this.portal.url),o=s?.userLicenseTypeId,a=o&&$.has(o);if(!e||i&&!a)return[];const r=new E({query:e,disableExtraQuery:!0}),l=await this.portal.queryGroups(r,t);if(!l.total)return[];const n=l.results[0],p=new E({num:100,query:"type:Layout",sortField:n.sortField,sortOrder:n.sortOrder??void 0}),m=(await n.queryItems(p,t)).results;if(!m.length)return[];return m.map(t=>(this.portalTemplateIds.push(t.id),new W({type:"default-template",label:t.title,layoutItem:t,layoutInfoTaskUrl:this._portalLayoutInfoTaskUrl})))}async _loadAllTemplates(t,e,s){let i=!1;const o=e?.layout?.choiceList;if(this.includeDefaultTemplates&&this.portal&&!this.printServiceUrl){const e=this._getPortalDefaultTemplates(t,o);i=!!e.length,this.defaultTemplates.addMany(e);const a=await this._getPortalCustomTemplates(s);this.defaultTemplates.addMany(a);for(const t of this.defaultTemplates)this._templateIdToCustomTemplate.set(t.id,t)}i||t.forEach((t,e)=>{if(!o||o.includes(e)){const s=new W({type:"print-service-template",layout:e,layoutInfoTaskUrl:this._layoutInfoTaskUrl});s.setLayoutTemplateInfo(t),this.printServiceTemplates.add(s),this._templateIdToCustomTemplate.set(s.id,s)}})}_processPrintServiceTemplatesInfo(t){this._set("templatesInfo",t);const e=t?.layout?.defaultValue;if(e&&"map-only"!==e){const t=this.defaultTemplates.find(t=>t.layout===e)??this.printServiceTemplates.find(t=>t.layout===e)??this.defaultTemplates.at(0)??this.printServiceTemplates.at(0);this._set("defaultTemplate",t)}}async _getLayoutToLayoutTemplateInfos(t){const e=this._layoutInfoTaskUrl,s=e?this._layoutTemplateInfosCache.get(e):void 0,i=s??await V(e,void 0,t);s||this._layoutTemplateInfosCache.set(e,i);const o=new Map,a={};for(const r of i){const t=k(r.layoutTemplate);o.set(t,r),a[t]=r.layoutOptions.customTextElements}return this._serviceTemplateCustomTextElements=Object.freeze(a),o}async _getPrintServiceTemplatesInfo(t){const e=this.effectivePrintServiceUrl?this._tasksInfoCache.get(this.effectivePrintServiceUrl):void 0,s=e??await P(this.effectivePrintServiceUrl,"ExportWebMap",t);if(!s)throw new i("print:unavailable-service-info","Can't fetch templates info from service");e||this._tasksInfoCache.set(this.effectivePrintServiceUrl,s);const{parameters:o}=s,a=o.find(({name:t})=>"Format"===t),r=o.find(({name:t})=>"Layout_Template"===t);return{format:this._getFormat(a),layout:this._getLayout(r)}}_getFormat(t){const s="all"===this.allowedFormats?t.choiceList:t.choiceList.filter(t=>"string"!=typeof this.allowedFormats&&this.allowedFormats.some(e=>new RegExp(`\\b${e}\\b`,"i").test(t))),i=(s.length?s:t.choiceList).map(t=>U.fromJSON(t)).filter(e),o=U.fromJSON(t.defaultValue),a=i.some(t=>new RegExp(`\\b${o}\\b`,"i").test(t))?o:i[0];return{choiceList:i,defaultValue:a}}_getLayout(t){const s=t.choiceList.filter(t=>"map_only"!==t.toLowerCase()),i="all"===this.allowedLayouts?s:s.filter(t=>this.allowedLayouts.includes(k(t))),o=(i.length?i:s).map(k).filter(e),a=k(t.defaultValue),r=o.includes(a)?a:o.find(t=>/(?=.*letter)(?=.*landscape)/i.test(t))??o.find(t=>/(?=.*a4)(?=.*landscape)/i.test(t))??o[0];return{choiceList:o,defaultValue:r}}_getOverlayItem(){return this._overlayItem||(this._overlayItem=new D({strokeDash:[5],strokeWidth:2,strokeColor:[30,144,255,255]})),this._overlayItem}_enablePrintPreview(){if(!this.view?.overlay)return;const t=this.templateOptions,e=this._getOverlayItem();this.addHandles([m(()=>[t.width,t.height,t.scaleEnabled,t.scale,t.layout,t.layoutItem,t.id,t.state,t.dpi,this.view?.scale,this.view?.size,this.view?.state.paddedViewState.size,this.view?.state.padding,this.loaded],()=>this._updateOverLayItem(),h),this.view?.on("drag",["Shift"],t=>this._handleDrag(t),A.WIDGET),this.view?.on("key-down",["Escape"],()=>this._resetDrag(),A.WIDGET)],"overlay-handler"),this.view.overlay.addItem(e)}_updateOverLayItem(){if(!this.view)return;const t=this.templateOptions,e=this._getOverlayItem(),s=t.layoutItem?.id??t.layout,i=this.view,o=i.spatialReference,[a,r]=i.state.paddedViewState.size,l=i.state.padding;let n=0,p=0;if("map-only"===s)null!=t.width&&null!=t.height&&(n=t.width,p=t.height);else if(s){const e=t.id?this._templateIdToCustomTemplate.get(t.id):null,{webMapFrameSize:s,pageUnits:i}=e?.layoutTemplateInfo??{};let l=!1;if(s&&i)if(this._isFreeHand){const t=s[0]/s[1];n=this._freeHandWidth,p=this._freehandHeight,n>p?p=n/t:n=p*t}else{const t=z.fromJSON(i.toLowerCase()),e=o.unit;c(t)===c(e)?(n=f(s[0],t,e),p=f(s[1],t,e)):(l=!0,n=s[0],p=s[1])}if(!this._isFreeHand)if(t.scaleEnabled&&t.scale){const t=l?Math.min(a/n,r/p):y(o)*v*Q;n*=t,p*=t}else if(0===n||0===p)n=a,p=r;else{const t=(a-.1*a)/n,e=(r-.1*r)/p,s=Math.min(t,e);n*=s,p*=s}}const{scaleEnabled:m,scale:h}=t,d=m&&h?h/this.view.scale:1;if(e.boxWidth=n*d||a,e.boxHeight=p*d||r,l&&(e.padding=l),e.backgroundWidth=a??0,e.backgroundHeight=r??0,"loading"===this.loadStatus)e.strokeColor=G;else if("loaded"===this.loadStatus)switch(this.templateOptions.state){case"pending":e.strokeColor=G;break;case"ready":e.strokeColor=B;break;case"error":e.strokeColor=q}}_resetDrag(){this._isFreeHand=!1,this._updateOverLayItem()}_handleDrag(t){switch(t.action){case"start":this._start();break;case"update":this._update(t);break;case"end":this._end()}t.stopPropagation()}_start(){this._isFreeHand=!0}_update(t){const e=this._getOverlayItem(),{x:s,y:i}=t,{x:o,y:a}=t.origin;s>o?(e.x=o,e.boxWidth=s-o):(e.x=s,e.boxWidth=o-s),i>a?(e.y=a,e.boxHeight=i-a):(e.y=i,e.boxHeight=a-i)}_end(){const t=this._getOverlayItem();if(!this.view||null==t.x||null==t.y)return;const e=this.view,s=e.toMap(u(t.x+.5*t.boxWidth,t.y+.5*t.boxHeight));t.x=null,t.y=null,e.goTo({center:s}),this._freeHandWidth=t.boxWidth,this._freehandHeight=t.boxHeight,"map-only"===this.templateOptions.layout&&(this.templateOptions.width=this._freeHandWidth,this.templateOptions.height=this._freehandHeight),this.templateOptions.scale=this.view.scale,this._updateOverLayItem()}};t([T()],it.prototype,"_serviceTemplateCustomTextElements",void 0),t([T()],it.prototype,"_templateIdToCustomTemplate",void 0),t([T()],it.prototype,"allowedFormats",void 0),t([T()],it.prototype,"allowedLayouts",void 0),t([T({type:K})],it.prototype,"browseTemplates",void 0),t([T({type:K})],it.prototype,"defaultTemplates",void 0),t([T()],it.prototype,"error",void 0),t([T({type:X})],it.prototype,"exportedLinks",void 0),t([T()],it.prototype,"extraParameters",void 0),t([T()],it.prototype,"includeDefaultTemplates",void 0),t([T({readOnly:!0})],it.prototype,"effectivePrintServiceUrl",null),t([T()],it.prototype,"effectiveTemplateCustomTextElements",null),t([T({type:I})],it.prototype,"outSpatialReference",void 0),t([T({type:O})],it.prototype,"portal",void 0),t([T()],it.prototype,"portalTemplateIds",void 0),t([T({type:K})],it.prototype,"printServiceTemplates",void 0),t([T({readOnly:!0})],it.prototype,"defaultTemplate",void 0),t([T()],it.prototype,"showPrintAreaEnabled",void 0),t([T()],it.prototype,"printServiceUrl",void 0),t([T()],it.prototype,"printTimeout",void 0),t([T()],it.prototype,"saveExportEnabled",void 0),t([T({readOnly:!0})],it.prototype,"state",null),t([T({readOnly:!0})],it.prototype,"templatesInfo",void 0),t([T()],it.prototype,"updateDelay",void 0),t([T()],it.prototype,"view",void 0),t([T()],it.prototype,"templateCustomTextElements",void 0),t([T({type:R})],it.prototype,"templateOptions",void 0),it=t([w("esri.widgets.Print.PrintViewModel")],it);const ot=it;export{ot as default};
package/widgets/Sketch.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import{isSome as o}from"../core/arrayUtils.js";import{deprecateWidget as i}from"../core/deprecate.js";import{handlesGroup as l}from"../core/handleUtils.js";import s from"../core/Logger.js";import{removeMaybe as n,destroyMaybe as r}from"../core/maybe.js";import{ignoreAbortErrors as a}from"../core/promiseUtils.js";import{watch as p,syncAndInitial as c,when as d}from"../core/reactiveUtils.js";import{property as u,subclass as h}from"../core/accessorSupport/decorators.js";import{symbolTypes as v}from"../symbols/support/typeUtils.js";import m from"../views/interactive/sketch/SketchLabelOptions.js";import g from"../views/interactive/sketch/SketchTooltipOptions.js";import y from"../views/interactive/sketch/SketchValueOptions.js";import f from"./Widget.js";import b from"./Sketch/SketchViewModel.js";import _ from"./Sketch/VisibleElements.js";import w from"./Sketch/support/ResponsiveToolbar/ResponsiveToolbar.js";import{loadCalciteComponents as T}from"./support/componentsUtils.js";import M from"./support/SelectionToolbar.js";import C from"./support/SketchTooltipControls.js";import S from"./support/SnappingControls.js";import{tsx as O,messageBundle as k,vmEvent as P}from"./support/widget.js";import I from"./support/SelectionToolbar/VisibleElements.js";import L from"./support/SketchTooltipControls/VisibleElements.js";const x="esri-sketch",E={base:x,vertical:`${x}--vertical`,docked:`${x}-bar`,floating:`${x}-pad`,chipHorizontal:`${x}__selection-count-chip--horizontal`,chipVertical:`${x}__selection-count-chip--vertical`,chipVerticalSmall:`${x}__selection-count-chip--vertical--s`,popoverWrapper:`${x}__popover-wrapper`},R={point:"pin",polyline:"line",polygon:"polygon",rectangle:"rectangle",circle:"circle",multipoint:"pins",mesh:"i3d-building",freehandPolygon:"freehand-area",freehandPolyline:"freehand",text:"add-text"};let G=class extends f{constructor(e,t){super(e,t),this._selectionToolbar=null,this._viewModelHandlesGroup=null,this._popoverElement=null,this.availableCreateTools=["point","polyline","polygon","rectangle","circle"],this.customToolOptions=null,this.customActions=null,this.toolbarKind="floating",this.contextualToolLocation="separate",this.groupCollapsePriorities=null,this.groupAllowCollapseOptions=null,this.messages=null,this.messagesCommon=null,this.visibleElements=new _,this._defaultViewModel=null,this._activeCustomToolOptions=null,this._calcitePopoverReferenceElement=null,this._relativeLocation="top",this._popoverOpen=!1,!0!==e?.suppressDeprecationWarning&&(this.announceDeprecation=()=>{i(s.getLogger(this),"Sketch","arcgis-sketch",{version:"5.0"})}),this._activateCreateTool=this._activateCreateTool.bind(this),this.viewModel=e?.viewModel||(this._defaultViewModel=new b({creationMode:e?.creationMode??"continuous",useLegacyCreateTools:e?.useLegacyCreateTools??"2d"!==e?.view?.type}))}normalizeCtorArgs(e={}){const{suppressDeprecationWarning:t,...o}=e;return o}initialize(){const{layer:e,view:t}=this,o="2d"===t?.type,i=new M({persistSelection:!1,visibleElements:new I({chip:!1,lassoTool:o,operationTypeControls:!1,pan:!1,pointTool:!1,rectangleTool:o}),view:t,sources:e?[e]:null,scale:this.scale});this.addHandles([p(()=>this.viewModel,e=>{this._viewModelHandlesGroup=n(this._viewModelHandlesGroup),e&&(this._viewModelHandlesGroup=l([e.on("create",()=>this.scheduleRender()),e.on("update",()=>this.scheduleRender()),e.on("delete",e=>this.emit("delete",e)),e.on("undo",()=>this.scheduleRender()),e.on("redo",()=>this.scheduleRender()),p(()=>e.layer,e=>{this._selectionToolbar&&(this._selectionToolbar.sources=e?[e]:null)}),p(()=>e.view,e=>{this._selectionToolbar&&(this._selectionToolbar.view=e)}),p(()=>e.state,()=>this.notifyChange("state"))]))},c),d(()=>i.activeOperation,()=>{this.viewModel.cancel(),this._activeCustomToolOptions=null}),i.on("complete",e=>this._onSelectionOperationComplete(e)),p(()=>{const{view:e,visibleElements:{selectionTools:t}}=this;return{lassoTool:"3d"!==e?.type&&!!t?.["lasso-selection"],rectangleTool:"3d"!==e?.type&&!!t?.["rectangle-selection"]}},e=>{Object.assign(i.visibleElements,e)},c)]),this._selectionToolbar=i}loadDependencies(){return T({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover")})}destroy(){this._selectionToolbar?.destroy(),this._viewModelHandlesGroup=n(this._viewModelHandlesGroup)}get activeTool(){const e=this._selectionToolbar?.activeOperation;if(e)switch(e.toolName){case"lasso":return"lasso-selection";case"rectangle":return"rectangle-selection";case"default":return"custom-selection"}const{availableCreateTools:t}=this,{activeTool:o,activeCreateToolDrawMode:i}=this.viewModel;return"polygon"===o&&"freehand"===i&&t?.includes("freehandPolygon")?"freehandPolygon":"polyline"===o&&"freehand"===i&&t?.includes("freehandPolyline")?"freehandPolyline":this.viewModel.activeTool}get activeTooltip(){return this.viewModel.activeTooltip}get createGraphic(){return this.viewModel.createGraphic}get creationMode(){return this.viewModel.creationMode}set creationMode(e){this.viewModel.creationMode=e}get defaultCreateOptions(){return this.viewModel.defaultCreateOptions}set defaultCreateOptions(e){this.viewModel.defaultCreateOptions=e}get defaultUpdateOptions(){return this.viewModel.defaultUpdateOptions}set defaultUpdateOptions(e){this.viewModel.defaultUpdateOptions=e}get icon(){return"pencil"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}set layout(e){this._set("layout",e),this._selectionToolbar&&(this._selectionToolbar.layout=e)}get pointSymbol(){return this.viewModel.pointSymbol}set pointSymbol(e){this.viewModel.pointSymbol=e}get polygonSymbol(){return this.viewModel.polygonSymbol}set polygonSymbol(e){this.viewModel.polygonSymbol=e}get polylineSymbol(){return this.viewModel.polylineSymbol}set polylineSymbol(e){this.viewModel.polylineSymbol=e}get textSymbol(){return this.viewModel.textSymbol}set textSymbol(e){this.viewModel.textSymbol=e}set scale(e){this._set("scale",e),this._selectionToolbar&&(this._selectionToolbar.scale=e)}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get state(){return this._selectionToolbar?.activeOperation?"active":this.viewModel.state}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get updateGraphics(){return this.viewModel.updateGraphics}get valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}set viewModel(e){const t=this._get("viewModel");e!==t&&(t&&t===this._defaultViewModel&&r(t),t?.pluginManager?.sketch===this&&(t.pluginManager.sketch=null),this._set("viewModel",e),e.addHandles(p(()=>e.pluginManager,e=>{e&&(e.sketch=this)},c)))}get useLegacyCreateTools(){return this.viewModel.useLegacyCreateTools}set useLegacyCreateTools(e){this._set("useLegacyCreateTools",e)}get isUsingLegacyCreateTools(){return this.viewModel.isUsingLegacyCreateTools}get _effectiveAvailableCreateTools(){if(this.viewModel.effectiveAvailablePlugins?.length)return this.viewModel.effectiveAvailablePlugins;const{availableCreateTools:e,view:t,visibleElements:o}=this,i=e?.filter(e=>!!o.createTools?.[e]);return"3d"===t?.type?i?.filter(e=>"multipoint"!==e):i}create(e,t,o){const i=o?.createOptions??t;return this._activeCustomToolOptions=o,a(this.viewModel.create(e,i))}update(e,t){return a(this.viewModel.update(e,t))}complete(){this.viewModel.complete()}cancel(){this._selectionToolbar?.cancel(),this.viewModel.cancel(),this._activeCustomToolOptions=null}undo(){this.viewModel.undo(),this.view?.focus()}redo(){this.viewModel.redo(),this.view?.focus()}delete(){this.viewModel.delete()}duplicate(){return this.viewModel.duplicate()}dismissFloatingElements(){this._popoverOpen=!1}render(){const{toolbarKind:e,layout:t,scale:o}=this;return O("div",null,O("div",{classes:{[E.base]:!0,[E.floating]:"floating"===e,[E.docked]:"docked"===e,[E.vertical]:"vertical"===t}},O(w,{barStyle:e,layout:t,scale:o},this._renderSelectionSetItemGroupInline(),this._renderSelectionToolsOrBack(),this._renderCreateToolActionGroup(),this._renderUndoRedoMenuItemGroup(),this._renderSettingsMenuItemGroup()),this._renderSelectionSetToolbar(),this._renderSettingsMenuPopover()))}_renderSelectionToolsOrBack(){if(!this.viewModel.isUsingLegacyCreateTools&&this.viewModel.firstPluginWithSwappableLeaf)return this._renderBackButton();const e=this.customActions?.filter(e=>"selection-toolbar"===e.position);return O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("selectionTools")??!0,"group-kind":"split-button",key:"selection-split-button",priority:this.groupCollapsePriorities?.get("selectionTools")??0},this._renderDefaultSelectionButton(),this._selectionToolbar?.render(),e?.map(e=>this._renderToolbarItem(e)))}_renderSettingsMenuPopover(){const{messagesCommon:e,snappingOptions:t,view:o,viewModel:i,visibleElements:l}=this;if(!this._calcitePopoverReferenceElement)return;const s={directionModePicker:l.directionModePicker,labelsToggle:l.labelsToggle,tooltipsToggle:l.tooltipsToggle},n="horizontal"===this.layout?"top"===this._relativeLocation?"bottom-end":"top-end":"right-end";return O("calcite-popover",{afterCreate:e=>this._popoverElement=e,closable:!0,heading:e.settings,label:e.settings,open:this._popoverOpen,overlayPositioning:"fixed",placement:n,referenceElement:this._calcitePopoverReferenceElement,scale:this.scale,topLayerDisabled:this.topLayerDisabled,onCalcitePopoverBeforeClose:e=>this._beforePopoverClose(e.target),onCalcitePopoverBeforeOpen:e=>this._remeasurePopoverSizes(e.currentTarget),onCalcitePopoverClose:e=>this._refocusOnView(e.target)},O("div",{class:E.popoverWrapper},Object.values(s).includes(!0)?O(C,{sketchOptions:i.sketchOptions,visibleElements:new L(s)}):void 0,l.snappingControls&&o&&t?O(S,{snappingManager:this.viewModel.snappingManager,snappingOptions:t,view:o,visibleElements:l.snappingControlsElements}):void 0))}_beforePopoverClose(e){e===this._popoverElement&&(this._popoverOpen=!1)}_renderSelectionSetToolbar(){if("separate"!==this.contextualToolLocation)return;const e=this._renderSelectionSetItemGroup();return e?.length?O(w,{barStyle:this.toolbarKind,layout:this.layout,scale:this.scale},e):void 0}_renderSelectionSetItemGroupInline(){return"separate"===this.contextualToolLocation?[]:this._renderSelectionSetItemGroup()}_renderUndoRedoMenuItemGroup(){return O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("undoRedo")??!0,"group-kind":"split-button",key:"undo-redo-menu",priority:this.groupCollapsePriorities?.get("undoRedo")??10,slot:"actions-end"},this._renderUndoButton(),this._renderRedoButton())}_renderSettingsMenuItemGroup(){const e=[],t=[];this.customActions?.forEach(o=>{"settings-before"===o.position?t.push(o):"settings-after"===o.position&&e.push(o)});const i=[...t.map(e=>this._renderToolbarItem(e)),this._renderSettingsMenuButton(),...e.map(e=>this._renderToolbarItem(e))].filter(o);if(i.length)return O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("settings")??!1,"group-kind":"overflow-group",key:"settings-menu",priority:this.groupCollapsePriorities?.get("settings")??1e3,slot:"actions-end"},i)}_renderSelectionSetItemGroup(){if(!this.updateGraphics.length)return[];const e="inline-end"===this.contextualToolLocation?"actions-end":void 0,t=this.customActions?.filter(e=>"before-selection-set"===e.position),o=this.customActions?.filter(e=>"after-selection-set"===e.position),i=this.groupCollapsePriorities?.get("selectionSet")??100;return[O("div",{"group-kind":"measured-content",key:"selection-count-chip-group",priority:i,slot:e},this._renderFeatureCountChip()),O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("selectionSet")??!1,"group-kind":"overflow-group",key:"selection-set-tool-group",priority:i,slot:e},t?.map(e=>this._renderToolbarItem(e)),this._renderDuplicateButton(),this._renderDeleteButton(),o?.map(e=>this._renderToolbarItem(e)))]}_renderDefaultSelectionButton(){if(!this.viewModel.updateOnGraphicClick)return[];const{messages:e,state:t}=this;return this._renderToolbarItem({id:"pointer-select",text:e.selectFeature,icon:"cursor",onclick:this._activateDefaultSelectTool,active:"ready"===t})}_renderBackButton(){const{viewModel:e,isUsingLegacyCreateTools:t}=this;if(!t&&e.multiplePluginsActive&&e.firstPluginWithSwappableLeaf&&e.rootPlugins&&!(e.rootPlugins.length<2&&e.rootPlugins.includes(e.firstPluginWithSwappableLeaf)))return O("div",{"allow-collapse":!1,"group-kind":"overflow-group",key:"back-button-group"},O("calcite-action",{icon:"chevron-left",onclick:()=>{this.viewModel?.cancel()},scale:this.scale,text:this.messagesCommon.back}))}_renderCreateToolActionGroup(){const e=this.customToolOptions?.flatMap(e=>this._renderCustomToolItem(e))??[],t=this._effectiveAvailableCreateTools,o=t?.filter(e=>"string"==typeof e),i=o?.map(e=>this._renderCreateToolItem(e)),l=t?.filter(e=>"string"!=typeof e).map(e=>this._renderCreateToolItem(e));return[i?.length||e?.length||l?.length?O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("createTools")??!0,"group-kind":"overflow-group",key:"create-tools-group",priority:this.groupCollapsePriorities?.get("createTools")??100},i,e,l):void 0]}_renderCreateToolItem(e){return"string"==typeof e?this._renderBuiltInCreateToolItem(e):this._renderDrawToolPluginItem(e)}_renderDrawToolPluginItem(e){const{icon:t,localizationKey:o,uniqueId:i,hidden:l}=e;if(l)return[];const s=this.messages.digitizers,n=s?.[o]??o,r=this.viewModel.drawTool?.pluginStack.some(e=>!e.configuration?.hidden&&e.configuration?.uniqueId===i);return this._renderToolbarItem({id:`${o}-button`,text:n,icon:t,onclick:()=>this._activatePlugin([e]),active:r})}_renderBuiltInCreateToolItem(e){return this._renderToolbarItem({id:`${e}-button`,text:this.messages.draw[e],icon:R[e],onclick:()=>this._activateCreateTool(e),active:this.activeTool===e&&!this._activeCustomToolOptions})}_renderCustomToolItem(e){const{toolKey:t}=e;return this._renderToolbarItem({id:`custom-${e.toolKey}`,text:e.label,icon:e.icon,onclick:()=>this._activateCreateTool(e.toolName,null,e),active:this._activeCustomToolOptions?.toolKey===t})}_renderUndoButton(){return this.visibleElements.undoRedoMenu?this._renderToolbarItem({id:"undo-button",text:this.messages.undo,icon:"undo",disabled:!this.viewModel.canUndo(),onclick:this.undo,flipRTL:!0}):[]}_renderRedoButton(){return this.visibleElements.undoRedoMenu?this._renderToolbarItem({id:"redo-button",text:this.messages.redo,icon:"redo",disabled:!this.viewModel.canRedo(),onclick:this.redo,flipRTL:!0}):[]}_renderSettingsMenuButton(){return this.visibleElements.settingsMenu?this._renderToolbarItem({id:"settings-menu-action",text:this.messagesCommon.settings,icon:"gear",active:this._popoverOpen,onclick:()=>this._popoverOpen=!this._popoverOpen,afterCreate:e=>this._calcitePopoverReferenceElement=e,afterUpdate:e=>this._calcitePopoverReferenceElement=e,afterRemoved:()=>this._calcitePopoverReferenceElement=null}):[]}_renderFeatureCountChip(){if(!this.visibleElements.selectionCountLabel)return[];const{layout:e,messages:o,scale:i,id:l,updateGraphics:{length:s}}=this,n=t(o.selectedCount,{count:s}),r="l"===i?999:99,a=s>r?t(o.selectedCountTruncated,{truncated:r}):s,p="l"!==i&&"vertical"===e,c=p?`${l}-selection-chip-small`:`${l}-selection-chip`;return[p?O("span",{classes:{[E.chipVertical]:!0,[E.chipVerticalSmall]:"s"===this.scale},id:c,tabIndex:0,title:n},a):O("calcite-chip",{appearance:"outline",class:"horizontal"===e?E.chipHorizontal:E.chipVertical,id:c,kind:"brand",label:n,scale:"l"===i?"m":"s",tabIndex:0,title:"vertical"===e?n:void 0},"vertical"===e?a:n)]}_renderDuplicateButton(){if(!this.visibleElements.duplicateButton)return[];const{messages:e}=this;return this._renderToolbarItem({id:"duplicate",text:this.updateGraphics.length>1?e.duplicateFeatures:e.duplicateFeature,icon:"copy",onclick:this._onDuplicateSelect})}_renderDeleteButton(){if(!this.visibleElements.deleteButton)return[];const{messages:e}=this,t=this.updateGraphics.length>1?e.deleteFeatures:e.deleteFeature;return this._renderToolbarItem({id:"delete",text:t,icon:"trash",onclick:this.delete})}_renderToolbarItem({id:e,text:t,icon:o,disabled:i,onclick:l,active:s,flipRTL:n,afterCreate:r,afterUpdate:a,afterRemoved:p}){const c=`${this.id}-${e}`;return[O("calcite-action",{active:s,afterCreate:r,afterRemoved:p,afterUpdate:a,bind:this,"data-testid":e,disabled:i||"disabled"===this.state,icon:o,iconFlipRtl:n??!1,id:c,key:e,onclick:l,scale:this.scale,text:t,title:t})]}_remeasurePopoverSizes(e){try{const t=e.parentElement,o=this?.view?.container?.getBoundingClientRect(),i=t?.style;if(!(t&&o&&i&&this.view?.container?.contains(t)))return;const l=this._calcitePopoverReferenceElement;if(!l)return;const{bottom:s,top:n}=l.getBoundingClientRect();if("horizontal"===this.layout){const e=s<o.height/2;e!==("top"===this._relativeLocation)&&(this._relativeLocation=e?"top":"bottom"),e?(i?.setProperty("--sketch-view-height-offset",s-o.top+"px"),i?.setProperty("--sketch-view-margin-offset","30px")):(i?.setProperty("--sketch-view-height-offset",o.bottom-n+"px"),i?.setProperty("--sketch-view-margin-offset","15px"))}else"vertical"===this.layout&&(i.setProperty("--sketch-view-height-offset","15px"),i.setProperty("--sketch-view-margin-offset","15px"));const r=e.shadowRoot?.querySelector("div.header")?.getBoundingClientRect().height;i.setProperty("--sketch-popover-header-offset",`${r}px`)}catch(t){s.getLogger(this.declaredClass).warnOnce("Sketch failed to lay out settings menu.",t)}}_activateCreateTool(e,t,o){const i=this._activeCustomToolOptions;if(o||i){if(o?.toolKey===i?.toolKey)return void this.cancel()}else if(this.activeTool===e)return void this.cancel();this._selectionToolbar?.cancel(),this.create(e,t,o)}_activatePlugin(e){this._selectionToolbar?.cancel(),this.viewModel.firstPluginWithSwappableLeaf?(this.viewModel.drawTool?.replaceLeaf(e),this.view?.ready&&this.view.focus()):this._activateCreateTool(e)}_onDuplicateSelect(){const e=this.duplicate(),t=this.viewModel.activeTool;"transform"!==t&&"reshape"!==t||this.update(e,{tool:t})}_onSelectionOperationComplete(e){const{viewModel:{defaultUpdateOptions:t}}=this,{selection:o}=e;if(!e.aborted&&o.length){const e=t.tool,i=o.length>1&&"reshape"===e?"transform":e;this.update(o,{...t,tool:i})}this.notifyChange("state")}_activateDefaultSelectTool(){this.cancel(),this.view?.focus()}_refocusOnView(e){this.activeTool&&e===this._popoverElement&&this.view?.focus()}};e([u()],G.prototype,"activeTool",null),e([u({readOnly:!0})],G.prototype,"activeTooltip",null),e([u({cast:e=>{if(!e?.length)return null;const t=new Set(["point","polyline","polygon","rectangle","circle","multipoint","freehandPolyline","freehandPolygon","mesh","text"]);return e.filter(e=>t.has(e))}})],G.prototype,"availableCreateTools",void 0),e([u({readOnly:!0})],G.prototype,"createGraphic",null),e([u()],G.prototype,"creationMode",null),e([u()],G.prototype,"customToolOptions",void 0),e([u()],G.prototype,"customActions",void 0),e([u()],G.prototype,"defaultCreateOptions",null),e([u()],G.prototype,"defaultUpdateOptions",null),e([u()],G.prototype,"icon",null),e([u()],G.prototype,"label",null),e([u({type:m})],G.prototype,"labelOptions",null),e([u()],G.prototype,"layer",null),e([u({type:["horizontal","vertical"],value:"horizontal"})],G.prototype,"layout",null),e([u({types:v})],G.prototype,"pointSymbol",null),e([u({types:v})],G.prototype,"polygonSymbol",null),e([u({types:v})],G.prototype,"polylineSymbol",null),e([u()],G.prototype,"textSymbol",null),e([u({value:"m"})],G.prototype,"scale",null),e([u()],G.prototype,"toolbarKind",void 0),e([u()],G.prototype,"contextualToolLocation",void 0),e([u()],G.prototype,"groupCollapsePriorities",void 0),e([u()],G.prototype,"groupAllowCollapseOptions",void 0),e([u(),k("esri/widgets/Sketch/t9n/Sketch")],G.prototype,"messages",void 0),e([u(),k("esri/t9n/common")],G.prototype,"messagesCommon",void 0),e([u()],G.prototype,"snappingOptions",null),e([u()],G.prototype,"state",null),e([u({type:g})],G.prototype,"tooltipOptions",null),e([u({readOnly:!0})],G.prototype,"updateGraphics",null),e([u({type:y,nonNullable:!0})],G.prototype,"valueOptions",null),e([u()],G.prototype,"view",null),e([u({type:b}),P(["create","update","undo","redo"])],G.prototype,"viewModel",null),e([u({type:_,nonNullable:!0})],G.prototype,"visibleElements",void 0),e([u({constructOnly:!0,value:!1})],G.prototype,"useLegacyCreateTools",null),e([u()],G.prototype,"isUsingLegacyCreateTools",null),e([u()],G.prototype,"_effectiveAvailableCreateTools",null),e([u()],G.prototype,"_defaultViewModel",void 0),e([u()],G.prototype,"_activeCustomToolOptions",void 0),e([u()],G.prototype,"_calcitePopoverReferenceElement",void 0),e([u()],G.prototype,"_relativeLocation",void 0),e([u()],G.prototype,"_popoverOpen",void 0),G=e([h("esri.widgets.Sketch")],G);const B=G;export{B as default};
2
+ import{__decorate as e}from"tslib";import{substitute as t}from"../intl.js";import{isSome as o}from"../core/arrayUtils.js";import{deprecateWidget as i}from"../core/deprecate.js";import{handlesGroup as l}from"../core/handleUtils.js";import s from"../core/Logger.js";import{removeMaybe as n,destroyMaybe as r}from"../core/maybe.js";import{ignoreAbortErrors as a}from"../core/promiseUtils.js";import{watch as p,syncAndInitial as c,when as d}from"../core/reactiveUtils.js";import{property as u,subclass as h}from"../core/accessorSupport/decorators.js";import{symbolTypes as v}from"../symbols/support/typeUtils.js";import m from"../views/interactive/sketch/SketchLabelOptions.js";import g from"../views/interactive/sketch/SketchTooltipOptions.js";import y from"../views/interactive/sketch/SketchValueOptions.js";import f from"./Widget.js";import b from"./Sketch/SketchViewModel.js";import _ from"./Sketch/VisibleElements.js";import w from"./Sketch/support/ResponsiveToolbar/ResponsiveToolbar.js";import{loadCalciteComponents as T}from"./support/componentsUtils.js";import M from"./support/SelectionToolbar.js";import C from"./support/SketchTooltipControls.js";import S from"./support/SnappingControls.js";import{tsx as O,messageBundle as k,vmEvent as P}from"./support/widget.js";import I from"./support/SelectionToolbar/VisibleElements.js";import L from"./support/SketchTooltipControls/VisibleElements.js";const x="esri-sketch",E={base:x,vertical:`${x}--vertical`,docked:`${x}-bar`,floating:`${x}-pad`,chipHorizontal:`${x}__selection-count-chip--horizontal`,chipVertical:`${x}__selection-count-chip--vertical`,chipVerticalSmall:`${x}__selection-count-chip--vertical--s`,popoverWrapper:`${x}__popover-wrapper`},R={point:"pin",polyline:"line",polygon:"polygon",rectangle:"rectangle",circle:"circle",multipoint:"pins",mesh:"i3d-building",freehandPolygon:"freehand-area",freehandPolyline:"freehand",text:"add-text"};let G=class extends f{constructor(e,t){super(e,t),this._selectionToolbar=null,this._viewModelHandlesGroup=null,this._popoverElement=null,this.availableCreateTools=["point","polyline","polygon","rectangle","circle"],this.customToolOptions=null,this.customActions=null,this.toolbarKind="floating",this.contextualToolLocation="separate",this.groupCollapsePriorities=null,this.groupAllowCollapseOptions=null,this.messages=null,this.messagesCommon=null,this.visibleElements=new _,this._defaultViewModel=null,this._activeCustomToolOptions=null,this._calcitePopoverReferenceElement=null,this._relativeLocation="top",this._popoverOpen=!1,!0!==e?.suppressDeprecationWarning&&(this.announceDeprecation=()=>{i(s.getLogger(this),"Sketch","arcgis-sketch",{version:"5.0"})}),this._activateCreateTool=this._activateCreateTool.bind(this),this.viewModel=e?.viewModel||(this._defaultViewModel=new b({creationMode:e?.creationMode??"continuous",useLegacyCreateTools:e?.useLegacyCreateTools??"2d"!==e?.view?.type}))}normalizeCtorArgs(e={}){const{suppressDeprecationWarning:t,...o}=e;return o}initialize(){const{layer:e,view:t}=this,o="2d"===t?.type,i=new M({persistSelection:!1,visibleElements:new I({chip:!1,lassoTool:o,operationTypeControls:!1,pan:!1,pointTool:!1,rectangleTool:o}),view:t,sources:e?[e]:null,scale:this.scale});this.addHandles([p(()=>this.viewModel,e=>{this._viewModelHandlesGroup=n(this._viewModelHandlesGroup),e&&(this._viewModelHandlesGroup=l([e.on("create",()=>this.scheduleRender()),e.on("update",()=>this.scheduleRender()),e.on("delete",e=>this.emit("delete",e)),e.on("undo",()=>this.scheduleRender()),e.on("redo",()=>this.scheduleRender()),p(()=>e.layer,e=>{this._selectionToolbar&&(this._selectionToolbar.sources=e?[e]:null)}),p(()=>e.view,e=>{this._selectionToolbar&&(this._selectionToolbar.view=e)}),p(()=>e.state,()=>this.notifyChange("state"))]))},c),d(()=>i.activeOperation,()=>{this.viewModel.cancel(),this._activeCustomToolOptions=null}),i.on("complete",e=>this._onSelectionOperationComplete(e)),p(()=>{const{view:e,visibleElements:{selectionTools:t}}=this;return{lassoTool:"3d"!==e?.type&&!!t?.["lasso-selection"],rectangleTool:"3d"!==e?.type&&!!t?.["rectangle-selection"]}},e=>{Object.assign(i.visibleElements,e)},c)]),this._selectionToolbar=i}loadDependencies(){return T({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),popover:()=>import("@esri/calcite-components/dist/components/calcite-popover")})}destroy(){this._selectionToolbar?.destroy(),this._viewModelHandlesGroup=n(this._viewModelHandlesGroup)}get activeTool(){const e=this._selectionToolbar?.activeOperation;if(e)switch(e.toolName){case"lasso":return"lasso-selection";case"rectangle":return"rectangle-selection";case"default":return"custom-selection"}const{availableCreateTools:t}=this,{activeTool:o,activeCreateToolDrawMode:i}=this.viewModel;return"polygon"===o&&"freehand"===i&&t?.includes("freehandPolygon")?"freehandPolygon":"polyline"===o&&"freehand"===i&&t?.includes("freehandPolyline")?"freehandPolyline":this.viewModel.activeTool}get activeTooltip(){return this.viewModel.activeTooltip}get createGraphic(){return this.viewModel.createGraphic}get creationMode(){return this.viewModel.creationMode}set creationMode(e){this.viewModel.creationMode=e}get defaultCreateOptions(){return this.viewModel.defaultCreateOptions}set defaultCreateOptions(e){this.viewModel.defaultCreateOptions=e}get defaultUpdateOptions(){return this.viewModel.defaultUpdateOptions}set defaultUpdateOptions(e){this.viewModel.defaultUpdateOptions=e}get icon(){return"pencil"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}set layout(e){this._set("layout",e),this._selectionToolbar&&(this._selectionToolbar.layout=e)}get pointSymbol(){return this.viewModel.pointSymbol}set pointSymbol(e){this.viewModel.pointSymbol=e}get polygonSymbol(){return this.viewModel.polygonSymbol}set polygonSymbol(e){this.viewModel.polygonSymbol=e}get polylineSymbol(){return this.viewModel.polylineSymbol}set polylineSymbol(e){this.viewModel.polylineSymbol=e}get textSymbol(){return this.viewModel.textSymbol}set textSymbol(e){this.viewModel.textSymbol=e}set scale(e){this._set("scale",e),this._selectionToolbar&&(this._selectionToolbar.scale=e)}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get state(){return this._selectionToolbar?.activeOperation?"active":this.viewModel.state}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get updateGraphics(){return this.viewModel.updateGraphics}get valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}set viewModel(e){const t=this._get("viewModel");e!==t&&(t&&t===this._defaultViewModel&&r(t),t?.pluginManager?.sketch===this&&(t.pluginManager.sketch=null),this._set("viewModel",e),e.addHandles(p(()=>e.pluginManager,e=>{e&&(e.sketch=this)},c)))}get useLegacyCreateTools(){return this.viewModel.useLegacyCreateTools}set useLegacyCreateTools(e){this._set("useLegacyCreateTools",e)}get isUsingLegacyCreateTools(){return this.viewModel.isUsingLegacyCreateTools}get _effectiveAvailableCreateTools(){if(this.viewModel.effectiveAvailablePlugins?.length)return this.viewModel.effectiveAvailablePlugins;const{availableCreateTools:e,view:t,visibleElements:o}=this,i=e?.filter(e=>!!o.createTools?.[e]);return"3d"===t?.type?i?.filter(e=>"multipoint"!==e):i}create(e,t,o){const i=o?.createOptions??t;return this._activeCustomToolOptions=o,a(this.viewModel.create(e,i))}update(e,t){return a(this.viewModel.update(e,t))}complete(){this.viewModel.complete()}cancel(){this._selectionToolbar?.cancel(),this.viewModel.cancel(),this._activeCustomToolOptions=null}undo(){this.viewModel.undo(),this.view?.focus()}redo(){this.viewModel.redo(),this.view?.focus()}delete(){this.viewModel.delete()}duplicate(){return this.viewModel.duplicate()}dismissFloatingElements(){this._popoverOpen=!1}render(){const{toolbarKind:e,layout:t,scale:o}=this;return O("div",null,O("div",{classes:{[E.base]:!0,[E.floating]:"floating"===e,[E.docked]:"docked"===e,[E.vertical]:"vertical"===t}},O(w,{barStyle:e,layout:t,scale:o},this._renderSelectionSetItemGroupInline(),this._renderSelectionToolsOrBack(),this._renderCreateToolActionGroup(),this._renderUndoRedoMenuItemGroup(),this._renderSettingsMenuItemGroup()),this._renderSelectionSetToolbar(),this._renderSettingsMenuPopover()))}_renderSelectionToolsOrBack(){if(!this.viewModel.isUsingLegacyCreateTools&&this.viewModel.firstPluginWithSwappableLeaf)return this._renderBackButton();const e=this.customActions?.filter(e=>"selection-toolbar"===e.position);return O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("selectionTools")??!0,"group-kind":"split-button",key:"selection-split-button",priority:this.groupCollapsePriorities?.get("selectionTools")??0},this._renderDefaultSelectionButton(),this._selectionToolbar?.render(),e?.map(e=>this._renderToolbarItem(e)))}_renderSettingsMenuPopover(){const{messagesCommon:e,snappingOptions:t,view:o,viewModel:i,visibleElements:l}=this;if(!this._calcitePopoverReferenceElement)return;const s={directionModePicker:l.directionModePicker,labelsToggle:l.labelsToggle,tooltipsToggle:l.tooltipsToggle},n="horizontal"===this.layout?"top"===this._relativeLocation?"bottom-end":"top-end":"right-end";return O("calcite-popover",{afterCreate:e=>this._popoverElement=e,closable:!0,heading:e.settings,label:e.settings,open:this._popoverOpen,overlayPositioning:"fixed",placement:n,referenceElement:this._calcitePopoverReferenceElement,scale:this.scale,topLayerDisabled:this.topLayerDisabled,onCalcitePopoverBeforeClose:e=>this._beforePopoverClose(e.target),onCalcitePopoverBeforeOpen:e=>this._remeasurePopoverSizes(e.currentTarget),onCalcitePopoverClose:e=>this._refocusOnView(e.target)},O("div",{class:E.popoverWrapper},Object.values(s).includes(!0)?O(C,{sketchOptions:i.sketchOptions,viewType:o?.type,visibleElements:new L(s)}):void 0,l.snappingControls&&o&&t?O(S,{snappingManager:this.viewModel.snappingManager,snappingOptions:t,view:o,visibleElements:l.snappingControlsElements}):void 0))}_beforePopoverClose(e){e===this._popoverElement&&(this._popoverOpen=!1)}_renderSelectionSetToolbar(){if("separate"!==this.contextualToolLocation)return;const e=this._renderSelectionSetItemGroup();return e?.length?O(w,{barStyle:this.toolbarKind,layout:this.layout,scale:this.scale},e):void 0}_renderSelectionSetItemGroupInline(){return"separate"===this.contextualToolLocation?[]:this._renderSelectionSetItemGroup()}_renderUndoRedoMenuItemGroup(){return O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("undoRedo")??!0,"group-kind":"split-button",key:"undo-redo-menu",priority:this.groupCollapsePriorities?.get("undoRedo")??10,slot:"actions-end"},this._renderUndoButton(),this._renderRedoButton())}_renderSettingsMenuItemGroup(){const e=[],t=[];this.customActions?.forEach(o=>{"settings-before"===o.position?t.push(o):"settings-after"===o.position&&e.push(o)});const i=[...t.map(e=>this._renderToolbarItem(e)),this._renderSettingsMenuButton(),...e.map(e=>this._renderToolbarItem(e))].filter(o);if(i.length)return O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("settings")??!1,"group-kind":"overflow-group",key:"settings-menu",priority:this.groupCollapsePriorities?.get("settings")??1e3,slot:"actions-end"},i)}_renderSelectionSetItemGroup(){if(!this.updateGraphics.length)return[];const e="inline-end"===this.contextualToolLocation?"actions-end":void 0,t=this.customActions?.filter(e=>"before-selection-set"===e.position),o=this.customActions?.filter(e=>"after-selection-set"===e.position),i=this.groupCollapsePriorities?.get("selectionSet")??100;return[O("div",{"group-kind":"measured-content",key:"selection-count-chip-group",priority:i,slot:e},this._renderFeatureCountChip()),O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("selectionSet")??!1,"group-kind":"overflow-group",key:"selection-set-tool-group",priority:i,slot:e},t?.map(e=>this._renderToolbarItem(e)),this._renderDuplicateButton(),this._renderDeleteButton(),o?.map(e=>this._renderToolbarItem(e)))]}_renderDefaultSelectionButton(){if(!this.viewModel.updateOnGraphicClick)return[];const{messages:e,state:t}=this;return this._renderToolbarItem({id:"pointer-select",text:e.selectFeature,icon:"cursor",onclick:this._activateDefaultSelectTool,active:"ready"===t})}_renderBackButton(){const{viewModel:e,isUsingLegacyCreateTools:t}=this;if(!t&&e.multiplePluginsActive&&e.firstPluginWithSwappableLeaf&&e.rootPlugins&&!(e.rootPlugins.length<2&&e.rootPlugins.includes(e.firstPluginWithSwappableLeaf)))return O("div",{"allow-collapse":!1,"group-kind":"overflow-group",key:"back-button-group"},O("calcite-action",{icon:"chevron-left",onclick:()=>{this.viewModel?.cancel()},scale:this.scale,text:this.messagesCommon.back}))}_renderCreateToolActionGroup(){const e=this.customToolOptions?.flatMap(e=>this._renderCustomToolItem(e))??[],t=this._effectiveAvailableCreateTools,o=t?.filter(e=>"string"==typeof e),i=o?.map(e=>this._renderCreateToolItem(e)),l=t?.filter(e=>"string"!=typeof e).map(e=>this._renderCreateToolItem(e));return[i?.length||e?.length||l?.length?O("div",{"allow-collapse":this.groupAllowCollapseOptions?.get("createTools")??!0,"group-kind":"overflow-group",key:"create-tools-group",priority:this.groupCollapsePriorities?.get("createTools")??100},i,e,l):void 0]}_renderCreateToolItem(e){return"string"==typeof e?this._renderBuiltInCreateToolItem(e):this._renderDrawToolPluginItem(e)}_renderDrawToolPluginItem(e){const{icon:t,localizationKey:o,uniqueId:i,hidden:l}=e;if(l)return[];const s=this.messages.digitizers,n=s?.[o]??o,r=this.viewModel.drawTool?.pluginStack.some(e=>!e.configuration?.hidden&&e.configuration?.uniqueId===i);return this._renderToolbarItem({id:`${o}-button`,text:n,icon:t,onclick:()=>this._activatePlugin([e]),active:r})}_renderBuiltInCreateToolItem(e){return this._renderToolbarItem({id:`${e}-button`,text:this.messages.draw[e],icon:R[e],onclick:()=>this._activateCreateTool(e),active:this.activeTool===e&&!this._activeCustomToolOptions})}_renderCustomToolItem(e){const{toolKey:t}=e;return this._renderToolbarItem({id:`custom-${e.toolKey}`,text:e.label,icon:e.icon,onclick:()=>this._activateCreateTool(e.toolName,null,e),active:this._activeCustomToolOptions?.toolKey===t})}_renderUndoButton(){return this.visibleElements.undoRedoMenu?this._renderToolbarItem({id:"undo-button",text:this.messages.undo,icon:"undo",disabled:!this.viewModel.canUndo(),onclick:this.undo,flipRTL:!0}):[]}_renderRedoButton(){return this.visibleElements.undoRedoMenu?this._renderToolbarItem({id:"redo-button",text:this.messages.redo,icon:"redo",disabled:!this.viewModel.canRedo(),onclick:this.redo,flipRTL:!0}):[]}_renderSettingsMenuButton(){return this.visibleElements.settingsMenu?this._renderToolbarItem({id:"settings-menu-action",text:this.messagesCommon.settings,icon:"gear",active:this._popoverOpen,onclick:()=>this._popoverOpen=!this._popoverOpen,afterCreate:e=>this._calcitePopoverReferenceElement=e,afterUpdate:e=>this._calcitePopoverReferenceElement=e,afterRemoved:()=>this._calcitePopoverReferenceElement=null}):[]}_renderFeatureCountChip(){if(!this.visibleElements.selectionCountLabel)return[];const{layout:e,messages:o,scale:i,id:l,updateGraphics:{length:s}}=this,n=t(o.selectedCount,{count:s}),r="l"===i?999:99,a=s>r?t(o.selectedCountTruncated,{truncated:r}):s,p="l"!==i&&"vertical"===e,c=p?`${l}-selection-chip-small`:`${l}-selection-chip`;return[p?O("span",{classes:{[E.chipVertical]:!0,[E.chipVerticalSmall]:"s"===this.scale},id:c,tabIndex:0,title:n},a):O("calcite-chip",{appearance:"outline",class:"horizontal"===e?E.chipHorizontal:E.chipVertical,id:c,kind:"brand",label:n,scale:"l"===i?"m":"s",tabIndex:0,title:"vertical"===e?n:void 0},"vertical"===e?a:n)]}_renderDuplicateButton(){if(!this.visibleElements.duplicateButton)return[];const{messages:e}=this;return this._renderToolbarItem({id:"duplicate",text:this.updateGraphics.length>1?e.duplicateFeatures:e.duplicateFeature,icon:"copy",onclick:this._onDuplicateSelect})}_renderDeleteButton(){if(!this.visibleElements.deleteButton)return[];const{messages:e}=this,t=this.updateGraphics.length>1?e.deleteFeatures:e.deleteFeature;return this._renderToolbarItem({id:"delete",text:t,icon:"trash",onclick:this.delete})}_renderToolbarItem({id:e,text:t,icon:o,disabled:i,onclick:l,active:s,flipRTL:n,afterCreate:r,afterUpdate:a,afterRemoved:p}){const c=`${this.id}-${e}`;return[O("calcite-action",{active:s,afterCreate:r,afterRemoved:p,afterUpdate:a,bind:this,"data-testid":e,disabled:i||"disabled"===this.state,icon:o,iconFlipRtl:n??!1,id:c,key:e,onclick:l,scale:this.scale,text:t,title:t})]}_remeasurePopoverSizes(e){try{const t=e.parentElement,o=this?.view?.container?.getBoundingClientRect(),i=t?.style;if(!(t&&o&&i&&this.view?.container?.contains(t)))return;const l=this._calcitePopoverReferenceElement;if(!l)return;const{bottom:s,top:n}=l.getBoundingClientRect();if("horizontal"===this.layout){const e=s<o.height/2;e!==("top"===this._relativeLocation)&&(this._relativeLocation=e?"top":"bottom"),e?(i?.setProperty("--sketch-view-height-offset",s-o.top+"px"),i?.setProperty("--sketch-view-margin-offset","30px")):(i?.setProperty("--sketch-view-height-offset",o.bottom-n+"px"),i?.setProperty("--sketch-view-margin-offset","15px"))}else"vertical"===this.layout&&(i.setProperty("--sketch-view-height-offset","15px"),i.setProperty("--sketch-view-margin-offset","15px"));const r=e.shadowRoot?.querySelector("div.header")?.getBoundingClientRect().height;i.setProperty("--sketch-popover-header-offset",`${r}px`)}catch(t){s.getLogger(this.declaredClass).warnOnce("Sketch failed to lay out settings menu.",t)}}_activateCreateTool(e,t,o){const i=this._activeCustomToolOptions;if(o||i){if(o?.toolKey===i?.toolKey)return void this.cancel()}else if(this.activeTool===e)return void this.cancel();this._selectionToolbar?.cancel(),this.create(e,t,o)}_activatePlugin(e){this._selectionToolbar?.cancel(),this.viewModel.firstPluginWithSwappableLeaf?(this.viewModel.drawTool?.replaceLeaf(e),this.view?.ready&&this.view.focus()):this._activateCreateTool(e)}_onDuplicateSelect(){const e=this.duplicate(),t=this.viewModel.activeTool;"transform"!==t&&"reshape"!==t||this.update(e,{tool:t})}_onSelectionOperationComplete(e){const{viewModel:{defaultUpdateOptions:t}}=this,{selection:o}=e;if(!e.aborted&&o.length){const e=t.tool,i=o.length>1&&"reshape"===e?"transform":e;this.update(o,{...t,tool:i})}this.notifyChange("state")}_activateDefaultSelectTool(){this.cancel(),this.view?.focus()}_refocusOnView(e){this.activeTool&&e===this._popoverElement&&this.view?.focus()}};e([u()],G.prototype,"activeTool",null),e([u({readOnly:!0})],G.prototype,"activeTooltip",null),e([u({cast:e=>{if(!e?.length)return null;const t=new Set(["point","polyline","polygon","rectangle","circle","multipoint","freehandPolyline","freehandPolygon","mesh","text"]);return e.filter(e=>t.has(e))}})],G.prototype,"availableCreateTools",void 0),e([u({readOnly:!0})],G.prototype,"createGraphic",null),e([u()],G.prototype,"creationMode",null),e([u()],G.prototype,"customToolOptions",void 0),e([u()],G.prototype,"customActions",void 0),e([u()],G.prototype,"defaultCreateOptions",null),e([u()],G.prototype,"defaultUpdateOptions",null),e([u()],G.prototype,"icon",null),e([u()],G.prototype,"label",null),e([u({type:m})],G.prototype,"labelOptions",null),e([u()],G.prototype,"layer",null),e([u({type:["horizontal","vertical"],value:"horizontal"})],G.prototype,"layout",null),e([u({types:v})],G.prototype,"pointSymbol",null),e([u({types:v})],G.prototype,"polygonSymbol",null),e([u({types:v})],G.prototype,"polylineSymbol",null),e([u()],G.prototype,"textSymbol",null),e([u({value:"m"})],G.prototype,"scale",null),e([u()],G.prototype,"toolbarKind",void 0),e([u()],G.prototype,"contextualToolLocation",void 0),e([u()],G.prototype,"groupCollapsePriorities",void 0),e([u()],G.prototype,"groupAllowCollapseOptions",void 0),e([u(),k("esri/widgets/Sketch/t9n/Sketch")],G.prototype,"messages",void 0),e([u(),k("esri/t9n/common")],G.prototype,"messagesCommon",void 0),e([u()],G.prototype,"snappingOptions",null),e([u()],G.prototype,"state",null),e([u({type:g})],G.prototype,"tooltipOptions",null),e([u({readOnly:!0})],G.prototype,"updateGraphics",null),e([u({type:y,nonNullable:!0})],G.prototype,"valueOptions",null),e([u()],G.prototype,"view",null),e([u({type:b}),P(["create","update","undo","redo"])],G.prototype,"viewModel",null),e([u({type:_,nonNullable:!0})],G.prototype,"visibleElements",void 0),e([u({constructOnly:!0,value:!1})],G.prototype,"useLegacyCreateTools",null),e([u()],G.prototype,"isUsingLegacyCreateTools",null),e([u()],G.prototype,"_effectiveAvailableCreateTools",null),e([u()],G.prototype,"_defaultViewModel",void 0),e([u()],G.prototype,"_activeCustomToolOptions",void 0),e([u()],G.prototype,"_calcitePopoverReferenceElement",void 0),e([u()],G.prototype,"_relativeLocation",void 0),e([u()],G.prototype,"_popoverOpen",void 0),G=e([h("esri.widgets.Sketch")],G);const B=G;export{B as default};