@arcgis/core 5.2.0-next.27 → 5.2.0-next.29

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 (418) hide show
  1. package/WebLinkChart.js +1 -1
  2. package/WebMap.js +1 -1
  3. package/applications/KnowledgeStudio/generalSharedKgUtils.d.ts +40 -2
  4. package/applications/KnowledgeStudio/generalSharedKgUtils.js +1 -1
  5. package/arcade/Dictionary.js +1 -1
  6. package/arcade/Feature.js +1 -1
  7. package/arcade/Pixel.js +1 -1
  8. package/arcade/deepClone.js +1 -1
  9. package/arcade/featureset/support/FeatureSet.js +1 -1
  10. package/arcade/functions/geometry.js +1 -1
  11. package/arcade/languageUtils.js +1 -1
  12. package/assets/esri/core/libs/libtess/libtess-f32.wasm +0 -0
  13. package/assets/esri/core/libs/libtess/libtess-f64.wasm +0 -0
  14. package/assets/esri/core/workers/RemoteClient.js +1 -1
  15. package/assets/esri/core/workers/chunks/0197e459fdb04dfb28ef.js +1 -0
  16. package/assets/esri/core/workers/chunks/{f7344d855f1092383abe.js → 15aa9b85976069acf4f3.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{5ee887fc6e1e0e70e02f.js → 1664434dc7a67c8ce453.js} +1 -1
  18. package/assets/esri/core/workers/chunks/17b98787a0698f584882.js +1 -0
  19. package/assets/esri/core/workers/chunks/1837f97f720d255a1694.js +1 -0
  20. package/assets/esri/core/workers/chunks/1b9c68e8431bb4608209.js +1 -0
  21. package/assets/esri/core/workers/chunks/1bbf5f5da5842b93f638.js +1 -0
  22. package/assets/esri/core/workers/chunks/1bd7b7f4ee7ea6cb7ef9.js +1 -0
  23. package/assets/esri/core/workers/chunks/1e386475937e02b3f523.js +1 -0
  24. package/assets/esri/core/workers/chunks/209460f8aae3f9f8c9b8.js +1 -0
  25. package/assets/esri/core/workers/chunks/{316a3d5c7842b445e29e.js → 20ffeb09bb30400de110.js} +1 -1
  26. package/assets/esri/core/workers/chunks/21122f3f3e19a7fd7d33.js +1 -0
  27. package/assets/esri/core/workers/chunks/{25fd4d5d3af887536b3b.js → 2628136bf9f47d238a24.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{bf9eca7dd107bdb06614.js → 2665337e1b665e7e2b70.js} +1 -1
  29. package/assets/esri/core/workers/chunks/2b044c8fab2055a8818d.js +1 -0
  30. package/assets/esri/core/workers/chunks/2b2b042a6d6949b06127.js +1 -0
  31. package/assets/esri/core/workers/chunks/2c15c227d057292d4fa8.js +1 -0
  32. package/assets/esri/core/workers/chunks/2f02880a7f081eb210cd.js +1 -0
  33. package/assets/esri/core/workers/chunks/2fc3e43b64300014dddc.js +1 -0
  34. package/assets/esri/core/workers/chunks/{31c4128b23968575feca.js → 31d92ba9089617aa59ab.js} +1 -1
  35. package/assets/esri/core/workers/chunks/32740b075d7a890d7888.js +1 -0
  36. package/assets/esri/core/workers/chunks/38b69fba9ae4ccbae6b7.js +1 -0
  37. package/assets/esri/core/workers/chunks/390f2beee8e3f2a302e4.js +1 -0
  38. package/assets/esri/core/workers/chunks/3c342e662c13a05f4caf.js +1 -0
  39. package/assets/esri/core/workers/chunks/{d670e134348954ce465d.js → 3d1e5bfd88771d4a0bf6.js} +1 -1
  40. package/assets/esri/core/workers/chunks/3eee32db0e9a5086b9a8.js +1 -0
  41. package/assets/esri/core/workers/chunks/43847d66726fd0bcbbb7.js +1 -0
  42. package/assets/esri/core/workers/chunks/4545cf12ad0824ce6b41.js +1 -0
  43. package/assets/esri/core/workers/chunks/45e4b9069263adeae394.js +1 -0
  44. package/assets/esri/core/workers/chunks/47290f27375c76bcc9c7.js +1 -0
  45. package/assets/esri/core/workers/chunks/{4e16d7fa2e6f11d082b5.js → 4ba4fd8fa31169760fee.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{268ee59800e64baa9682.js → 4be0c64bbf2449d57ea5.js} +1 -1
  47. package/assets/esri/core/workers/chunks/5115059b012ef84407cf.js +1 -0
  48. package/assets/esri/core/workers/chunks/{e8e7cd26c43f231cdea2.js → 5189413a83faf3480e29.js} +1 -1
  49. package/assets/esri/core/workers/chunks/5c63b38160c7d063b8af.js +1 -0
  50. package/assets/esri/core/workers/chunks/5cccb8b06014ccef30f8.js +1 -0
  51. package/assets/esri/core/workers/chunks/{0098544169e429dd98d2.js → 689673173ca1c0e098fe.js} +1 -1
  52. package/assets/esri/core/workers/chunks/697e0ce10d77b90d4fee.js +1 -0
  53. package/assets/esri/core/workers/chunks/6991ba1b204668e7d4da.js +1 -0
  54. package/assets/esri/core/workers/chunks/{ccffaba50674adba7a0f.js → 6b56971783bf4c31a563.js} +1 -1
  55. package/assets/esri/core/workers/chunks/70c94bcfa20453134037.js +1 -0
  56. package/assets/esri/core/workers/chunks/{8f93e6fc11a158d4f1ee.js → 7335a762412bc8c15a2f.js} +1 -1
  57. package/assets/esri/core/workers/chunks/759686b896f51f0fe6a9.js +1 -0
  58. package/assets/esri/core/workers/chunks/7656900713e55036c3c1.js +1 -0
  59. package/assets/esri/core/workers/chunks/{b2b342b06d502fc61ea5.js → 76789f46b2c65d219cf9.js} +1 -1
  60. package/assets/esri/core/workers/chunks/774615303c1cc9a77e20.js +1 -0
  61. package/assets/esri/core/workers/chunks/7b290ac2e8a567ecae4a.js +1 -0
  62. package/assets/esri/core/workers/chunks/7ff37a4f315f7621462b.js +1 -0
  63. package/assets/esri/core/workers/chunks/8ad5e80e911419c1685a.js +1 -0
  64. package/assets/esri/core/workers/chunks/{a3ecde3794a7db3cf283.js → 8d90bef1091204fba0f1.js} +1 -1
  65. package/assets/esri/core/workers/chunks/8f16a358ed83d2264415.js +1 -0
  66. package/assets/esri/core/workers/chunks/{a454df829a72ab02c860.js → 8fd63cb38036f331a803.js} +1 -1
  67. package/assets/esri/core/workers/chunks/{bbcad2fde838819ffc7b.js → 906f4c0fa8135e6c2f03.js} +1 -1
  68. package/assets/esri/core/workers/chunks/989937c120bdd676ec1e.js +1 -0
  69. package/assets/esri/core/workers/chunks/9ba705a6ddabca0f77b1.js +1 -0
  70. package/assets/esri/core/workers/chunks/{87011d2fe14c54e296af.js → 9fe71d49c888fd871312.js} +1 -1
  71. package/assets/esri/core/workers/chunks/a14e5607c5c091c77e3d.js +1 -0
  72. package/assets/esri/core/workers/chunks/a2be8784f2cfdbb42681.js +1 -0
  73. package/assets/esri/core/workers/chunks/a6379a8df8c08b729b9c.js +1 -0
  74. package/assets/esri/core/workers/chunks/a988fd54912969b812ce.js +1 -0
  75. package/assets/esri/core/workers/chunks/a9db775210ebeee41738.js +1 -0
  76. package/assets/esri/core/workers/chunks/acbc14395c31f6da509e.js +1 -0
  77. package/assets/esri/core/workers/chunks/{11d1af758e2140095b10.js → aec82b94787821153d2b.js} +1 -1
  78. package/assets/esri/core/workers/chunks/b18b6bb85e52b03b85e3.js +680 -0
  79. package/assets/esri/core/workers/chunks/b624796ff4a9d4c406bf.js +1 -0
  80. package/assets/esri/core/workers/chunks/b7458bd3a2f590f32111.js +1 -0
  81. package/assets/esri/core/workers/chunks/bb1fad01d9f070e7d795.js +1 -0
  82. package/assets/esri/core/workers/chunks/{a9d477f90e5046400dd5.js → bcb2092c87d8d21c6458.js} +1 -1
  83. package/assets/esri/core/workers/chunks/{3e94ed4d57ee7d870cba.js → c6f5688074ae89c37add.js} +1 -1
  84. package/assets/esri/core/workers/chunks/caf150028aeac91b8d80.js +1 -0
  85. package/assets/esri/core/workers/chunks/cb30e8a66d6dcfebd439.js +1 -0
  86. package/assets/esri/core/workers/chunks/d7c0ab622caf495dbcef.js +1 -0
  87. package/assets/esri/core/workers/chunks/e181d0f5562878b3dc01.js +1 -0
  88. package/assets/esri/core/workers/chunks/{fd629872b5c07853f695.js → e4015870412edd69453c.js} +1 -1
  89. package/assets/esri/core/workers/chunks/{d07068c44d560e4ce02e.js → e5d2fab228d54b18a8a8.js} +1 -1
  90. package/assets/esri/core/workers/chunks/e774303efefee31952d0.js +1 -0
  91. package/assets/esri/core/workers/chunks/e98a8f80023c6023e72c.js +1 -0
  92. package/assets/esri/core/workers/chunks/f10a339b16d84b650012.js +2 -0
  93. package/assets/esri/core/workers/chunks/f1d211904d5a1de93cb3.js +1 -0
  94. package/assets/esri/core/workers/chunks/f847a4846c427f671455.js +1 -0
  95. package/assets/esri/core/workers/chunks/fe42fa2144691b9186fd.js +1 -0
  96. package/assets/esri/images/portal/gaussiansplatlayer16.png +0 -0
  97. package/assets/esri/images/portal/knowledgegraphlayer16.png +0 -0
  98. package/assets/esri/images/portal/propresentation16.png +0 -0
  99. package/assets/esri/images/portal/urbanproject16.png +0 -0
  100. package/assets/esri/images/support/loading-throb.gif +0 -0
  101. package/assets/esri/layers/raster/formats/lerc-wasm.wasm +0 -0
  102. package/assets/esri/libs/basisu/basis_encoder.wasm +0 -0
  103. package/assets/esri/libs/dxtEncoder/dxt_encoder.wasm +0 -0
  104. package/assets/esri/themes/base/icons/style.scss +0 -0
  105. package/assets/esri/themes/base/icons/variables.scss +0 -0
  106. package/assets/esri/themes/base/images/files/archive-32.svg +0 -0
  107. package/assets/esri/themes/base/images/files/cad-32.svg +0 -0
  108. package/assets/esri/themes/base/images/files/code-32.svg +0 -0
  109. package/assets/esri/themes/base/images/files/csv-32.svg +0 -0
  110. package/assets/esri/themes/base/images/files/excel-32.svg +0 -0
  111. package/assets/esri/themes/base/images/files/generic-32.svg +0 -0
  112. package/assets/esri/themes/base/images/files/gpx-32.svg +0 -0
  113. package/assets/esri/themes/base/images/files/image-32.svg +0 -0
  114. package/assets/esri/themes/base/images/files/pdf-32.svg +0 -0
  115. package/assets/esri/themes/base/images/files/report-32.svg +0 -0
  116. package/assets/esri/themes/base/images/files/sound-32.svg +0 -0
  117. package/assets/esri/themes/base/images/files/text-32.svg +0 -0
  118. package/assets/esri/themes/base/images/files/video-32.svg +0 -0
  119. package/assets/esri/themes/base/images/files/word-32.svg +0 -0
  120. package/assets/esri/themes/base/images/files/zip-32.svg +0 -0
  121. package/assets/esri/themes/base/images/loading-throb.gif +0 -0
  122. package/assets/esri/themes/base/widgets/_BatchAttributeForm.scss +24 -0
  123. package/assets/esri/themes/base/widgets/_Bookmarks.scss +0 -0
  124. package/assets/esri/themes/dark/main.css +1 -1
  125. package/assets/esri/themes/light/main.css +1 -1
  126. package/assets/esri/themes/light/view.css +1 -1
  127. package/chunks/GlowComposition.glsl.js +5 -5
  128. package/chunks/OITBlend.glsl.js +1 -1
  129. package/chunks/languageUtils.js +1 -1
  130. package/config.js +1 -1
  131. package/core/AsyncUpdate.js +1 -1
  132. package/core/Loadable.js +1 -1
  133. package/core/colorUtils.js +1 -1
  134. package/core/date.js +1 -1
  135. package/core/has.js +1 -1
  136. package/core/workers/WorkerHandle.js +1 -1
  137. package/core/workers/workerFactory.js +1 -1
  138. package/editing/sharedTemplates/SharedTemplateProvider.js +1 -1
  139. package/form/elements/AttachmentElement.d.ts +4 -1
  140. package/form/elements/inputs/attachments/AttachmentInput.d.ts +1 -0
  141. package/form/elements/inputs/attachments/AudioInput.d.ts +1 -0
  142. package/form/elements/inputs/attachments/DocumentInput.d.ts +3 -0
  143. package/form/elements/inputs/attachments/ImageInput.d.ts +1 -0
  144. package/form/elements/inputs/attachments/VideoInput.d.ts +1 -0
  145. package/geometry/Mesh.js +1 -1
  146. package/geometry/support/meshUtils/loadExternal.js +1 -1
  147. package/identity/OAuthCredential.js +1 -1
  148. package/kernel.js +1 -1
  149. package/layers/AnnotationFeatureLayer.d.ts +2 -4
  150. package/layers/AnnotationFeatureLayer.js +1 -1
  151. package/layers/DimensionFeatureLayer.d.ts +0 -2
  152. package/layers/DimensionFeatureLayer.js +1 -1
  153. package/layers/LinkChartLayer.js +1 -1
  154. package/layers/ParquetLayer.js +1 -1
  155. package/layers/PointCloudLayer.js +1 -1
  156. package/layers/SceneLayer.js +1 -1
  157. package/layers/buildingSublayers/BuildingComponentSublayer.js +1 -1
  158. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  159. package/layers/graphics/editingSupport.js +1 -1
  160. package/layers/graphics/sources/MemorySource.js +1 -1
  161. package/layers/graphics/sources/ParquetSource.js +1 -1
  162. package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
  163. package/layers/mixins/EditBusLayer.js +1 -1
  164. package/layers/mixins/SceneService.js +1 -1
  165. package/layers/support/KMLSublayer.js +1 -1
  166. package/layers/support/ParquetFilesData.js +1 -1
  167. package/layers/support/TitleCreator.js +1 -1
  168. package/layers/support/featureLayerUtils.js +1 -1
  169. package/layers/support/parquetUtils.js +1 -1
  170. package/linkChart/guards.js +2 -0
  171. package/linkChart/utils.js +1 -1
  172. package/networks/CircuitManager.d.ts +44 -0
  173. package/networks/support/CircuitExportJobInfo.d.ts +1 -1
  174. package/networks/support/CircuitVerifyJobInfo.d.ts +1 -1
  175. package/networks/support/jsonTypes.d.ts +2 -0
  176. package/package.json +5 -5
  177. package/rest/featureService/types.d.ts +4 -7
  178. package/rest/knowledgeGraph/ReplicaDefinition.d.ts +62 -6
  179. package/rest/networks/circuits/support/CircuitVerifyResult.d.ts +1 -1
  180. package/rest/networks/circuits/support/ExportCircuitsParameters.d.ts +1 -1
  181. package/rest/networks/circuits/support/VerifyCircuitsParameters.d.ts +17 -3
  182. package/rest/networks/unitIdentifiers/support/UnitQueryResult.d.ts +1 -1
  183. package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
  184. package/smartMapping/support/adapters/FeatureLayerBinningAdapter.js +1 -1
  185. package/support/ArcadeExpression.js +1 -1
  186. package/support/basemapUtils.js +1 -1
  187. package/support/revision.js +1 -1
  188. package/symbols/cim/CIMOperators.js +1 -1
  189. package/symbols/cim/utils.js +1 -1
  190. package/symbols/support/cimSymbolUtils.js +1 -1
  191. package/versionManagement/VersionManagementService.js +1 -1
  192. package/versionManagement/VersionManager.js +1 -1
  193. package/views/2d/analysis/AreaMeasurement/AreaMeasurementTool.js +1 -1
  194. package/views/2d/analysis/DistanceMeasurement/DistanceMeasurementTool.js +1 -1
  195. package/views/2d/engine/ParentChildStage.js +1 -1
  196. package/views/2d/engine/Stage.js +1 -1
  197. package/views/2d/engine/ThrottledCanvas.js +2 -0
  198. package/views/2d/engine/webgl/Profiler.js +1 -1
  199. package/views/2d/engine/webgl/mesh/factories/FeatureMeshFactory.js +1 -1
  200. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js +1 -1
  201. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  202. package/views/2d/engine/webgl/util/AnnotationMatcher.js +1 -1
  203. package/views/2d/engine/webgl/util/DictionaryMatcher.js +1 -1
  204. package/views/2d/engine/webgl/util/DimensionMatcher.js +1 -1
  205. package/views/2d/engine/webgl/util/IntervalMatcher.js +1 -1
  206. package/views/2d/engine/webgl/util/LabelMatcher.js +1 -1
  207. package/views/2d/engine/webgl/util/MapMatcher.js +1 -1
  208. package/views/2d/engine/webgl/util/Matcher.js +1 -1
  209. package/views/2d/engine/webgl/util/createMatcher.js +1 -1
  210. package/views/2d/layers/FeatureLikeLayerView2D.js +1 -1
  211. package/views/2d/layers/ImageryLayerView2D.js +1 -1
  212. package/views/2d/layers/LayerView2D.js +1 -1
  213. package/views/2d/layers/MediaLayerView2D.js +1 -1
  214. package/views/2d/layers/TileLayerView2D.js +1 -1
  215. package/views/2d/layers/features/Processor.js +1 -1
  216. package/views/2d/layers/features/layerAdapters/AnnotationLayerAdapter.js +1 -1
  217. package/views/2d/layers/features/layerAdapters/CatalogFootprintLayerAdapter.js +1 -1
  218. package/views/2d/layers/features/layerAdapters/DimensionLayerAdapter.js +1 -1
  219. package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +1 -1
  220. package/views/2d/layers/features/layerAdapters/InMemoryLayerAdapter.js +1 -1
  221. package/views/2d/layers/features/layerAdapters/KnowledgeGraphSublayerAdapter.js +1 -1
  222. package/views/2d/layers/features/layerAdapters/OGCFeatureLayerAdapter.js +1 -1
  223. package/views/2d/layers/features/layerAdapters/OrientedImageryLayerAdapter.js +1 -1
  224. package/views/2d/layers/features/layerAdapters/ParquetLayerAdapter.js +1 -1
  225. package/views/2d/layers/features/layerAdapters/StreamLayerAdapter.js +1 -1
  226. package/views/2d/layers/features/layerAdapters/SubtypeGroupLayerAdapter.js +1 -1
  227. package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
  228. package/views/2d/layers/features/processor/ClusterStrategy.js +1 -1
  229. package/views/2d/layers/features/processor/TrackStrategy.js +1 -1
  230. package/views/2d/layers/features/sources/strategies/support/queryAdapters.js +1 -1
  231. package/views/2d/layers/features/support/FeatureMetadata.js +1 -1
  232. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  233. package/views/2d/layers/features/support/FeatureSetReaderIndirect.js +1 -1
  234. package/views/2d/layers/support/annodime/DimensionInfo.js +1 -1
  235. package/views/2d/layers/support/annodime/MatcherGeometryOverride.js +2 -0
  236. package/views/2d/layers/support/annodime/PrivateDimensionEffect.js +1 -1
  237. package/views/2d/layers/support/annodime/PrivateMatcherGeometryOverrideEffect.js +2 -0
  238. package/views/2d/layers/support/annodime/TileObjectId.js +2 -0
  239. package/views/2d/layers/support/annodime/annotationGraphic.js +1 -1
  240. package/views/2d/layers/support/annodime/debugUtils.js +2 -0
  241. package/views/2d/layers/support/annodime/dimensionStyleDefaults.js +2 -0
  242. package/views/2d/layers/support/annodime/dimensionSymbols.js +1 -1
  243. package/views/2d/layers/support/annodime/dimensionUtils.js +1 -1
  244. package/views/2d/layers/support/annodime/utils.js +1 -1
  245. package/views/3d/analysis/Viewshed/ViewshedPlacementController.js +1 -1
  246. package/views/3d/analysis/Viewshed/ViewshedPlacementPointPlugin.js +1 -1
  247. package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
  248. package/views/3d/camera/constraintUtils/surfaceCollision.js +1 -1
  249. package/views/3d/camera/constraintUtils.js +1 -1
  250. package/views/3d/glTF/internal/Resource.js +1 -1
  251. package/views/3d/glTF/loader.js +1 -1
  252. package/views/3d/layers/BuildingSceneLayerView3D.js +1 -1
  253. package/views/3d/layers/I3SMeshView3D.js +1 -1
  254. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  255. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  256. package/views/3d/layers/SceneLayerWorkerHandle.js +1 -1
  257. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  258. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  259. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  260. package/views/3d/layers/graphics/tessellationUtils.js +1 -1
  261. package/views/3d/layers/i3s/I3SOverrides.js +1 -1
  262. package/views/3d/state/GoToOperation.js +1 -1
  263. package/views/3d/state/SurfaceCollisionConstraint.js +1 -1
  264. package/views/3d/state/ViewState.js +1 -1
  265. package/views/3d/state/ViewStateManager.js +1 -1
  266. package/views/3d/state/controllers/PointToPointAnimationController.js +1 -1
  267. package/views/3d/state/controllers/ZoomControllerGlobal.js +1 -1
  268. package/views/3d/state/controllers/ZoomStepControllerGlobal.js +1 -1
  269. package/views/3d/support/renderInfoUtils/polygon.js +1 -1
  270. package/views/3d/webgl/ManagedFBO.js +1 -1
  271. package/views/3d/webgl/RenderCamera.js +1 -1
  272. package/views/3d/webgl/RenderNode.js +1 -1
  273. package/views/3d/webgl-engine/effects/RenderNodes.js +1 -1
  274. package/views/3d/webgl-engine/effects/atmosphere/ChapmanAtmosphere.js +1 -1
  275. package/views/3d/webgl-engine/effects/clouds/CloudsComposition.js +1 -1
  276. package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
  277. package/views/3d/webgl-engine/effects/focusArea/FocusAreaColorNode.js +1 -1
  278. package/views/3d/webgl-engine/effects/fog/Fog.js +1 -1
  279. package/views/3d/webgl-engine/effects/geometry/RenderOccludedRenderNode.js +1 -1
  280. package/views/3d/webgl-engine/effects/glow/Glow.js +1 -1
  281. package/views/3d/webgl-engine/effects/haze/Haze.js +1 -1
  282. package/views/3d/webgl-engine/effects/laserlines/LaserLineRenderer.js +1 -1
  283. package/views/3d/webgl-engine/effects/magnifier/Magnifier.js +1 -1
  284. package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
  285. package/views/3d/webgl-engine/effects/transparency/OITBlend.js +1 -1
  286. package/views/3d/webgl-engine/effects/transparency/OITBlendTechniqueConfiguration.js +1 -1
  287. package/views/3d/webgl-engine/lib/CutFillComputationRenderNode.js +1 -1
  288. package/views/3d/webgl-engine/lib/CutFillVisualizationRenderNode.js +1 -1
  289. package/views/3d/webgl-engine/lib/GPUPointOcclusionQuery.js +1 -1
  290. package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
  291. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  292. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  293. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  294. package/views/3d/webgl-engine/materials/renderers/VaoWriter.js +1 -1
  295. package/views/3d/webgl.js +1 -1
  296. package/views/VideoView.js +1 -1
  297. package/views/View2D.js +1 -1
  298. package/views/Viewport2DBaseMixin.js +1 -1
  299. package/views/analysis/ElevationProfile/ElevationProfileLineGroundComputation.js +1 -1
  300. package/views/draw/DrawTool.js +1 -1
  301. package/views/draw/support/editingSessionUtils.js +1 -1
  302. package/views/interactive/sketch/SketchLabelOptions.d.ts +0 -6
  303. package/views/layers/AnnotationFeatureLayerView.d.ts +0 -7
  304. package/views/layers/DimensionFeatureLayerView.d.ts +0 -7
  305. package/views/popupAdapter.js +1 -1
  306. package/views/support/LayerViewManager.js +1 -1
  307. package/views/webgl/BufferObject.js +1 -1
  308. package/webdoc/support/webdocSaveUtils.js +1 -1
  309. package/widgets/BasemapGallery/BasemapGalleryViewModel.js +1 -1
  310. package/widgets/BasemapGallery/support/PortalBasemapsSource.js +1 -1
  311. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
  312. package/widgets/BatchAttributeForm/batchAttributeFormUtils.js +1 -1
  313. package/widgets/BatchAttributeForm/css.js +1 -1
  314. package/widgets/BatchAttributeForm/inputs/AttachmentElementInput.js +1 -1
  315. package/widgets/BatchAttributeForm/interfaceUtils.js +1 -1
  316. package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
  317. package/widgets/BatchAttributeForm.js +1 -1
  318. package/widgets/Directions/DirectionsViewModel.js +1 -1
  319. package/widgets/Directions.js +1 -1
  320. package/widgets/Editor/EditorViewModel.d.ts +1 -13
  321. package/widgets/Editor.d.ts +11 -13
  322. package/widgets/Editor.js +1 -1
  323. package/widgets/Feature/FeatureViewModel.js +1 -1
  324. package/widgets/Feature.js +1 -1
  325. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  326. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  327. package/widgets/FeatureTable/support/FeatureStore.js +1 -1
  328. package/widgets/FeatureTable.js +1 -1
  329. package/widgets/Features/FeaturesViewModel.js +1 -1
  330. package/widgets/Features.js +1 -1
  331. package/widgets/LayerList/LayerListViewModel.js +1 -1
  332. package/widgets/LinkChartLayoutSwitcher/LinkChartLayoutSwitcherViewModel.js +1 -1
  333. package/widgets/Locate/LocateViewModel.js +1 -1
  334. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  335. package/widgets/OrientedImageryViewer/adapters/sketch/DataCaptureAdapter.js +1 -1
  336. package/widgets/OrientedImageryViewer/adapters/sketch/MeasurementAdapter.js +1 -1
  337. package/widgets/OrientedImageryViewer/adapters/view/MapViewAdapter.js +1 -1
  338. package/widgets/OrientedImageryViewer/services/SuperimposeService.js +1 -1
  339. package/widgets/OrientedImageryViewer/support/MediaPrefetcher.js +1 -1
  340. package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
  341. package/widgets/Popup/PopupViewModel.d.ts +0 -1
  342. package/widgets/Popup/PopupViewModel.js +1 -1
  343. package/widgets/Popup.js +1 -1
  344. package/widgets/Print/PrintViewModel.js +1 -1
  345. package/widgets/Print.js +1 -1
  346. package/widgets/ScaleBar/ScaleBarViewModel.js +1 -1
  347. package/widgets/Sketch/SketchViewModel.d.ts +0 -12
  348. package/widgets/Sketch.d.ts +0 -12
  349. package/widgets/TableList/ListItem.js +1 -1
  350. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceFeature.js +1 -1
  351. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
  352. package/widgets/VersionManagement/VersionManagementViewModel.js +1 -1
  353. package/widgets/Widget.js +1 -1
  354. package/widgets/support/geolocationUtils.js +1 -1
  355. package/widgets/support/tests.js +1 -1
  356. package/assets/esri/core/workers/chunks/04070767356c12026369.js +0 -1
  357. package/assets/esri/core/workers/chunks/045f178fecc23839bfa8.js +0 -680
  358. package/assets/esri/core/workers/chunks/073ee52705ea326fecfb.js +0 -1
  359. package/assets/esri/core/workers/chunks/0e81b6aa64d5491870b2.js +0 -1
  360. package/assets/esri/core/workers/chunks/126a8c26618425790804.js +0 -1
  361. package/assets/esri/core/workers/chunks/1a7c0a1dc6ecc93ea03a.js +0 -1
  362. package/assets/esri/core/workers/chunks/1cb1f125dccbf8c8cac9.js +0 -1
  363. package/assets/esri/core/workers/chunks/1f03e34520746e432719.js +0 -1
  364. package/assets/esri/core/workers/chunks/292498a9c7d462d215c6.js +0 -1
  365. package/assets/esri/core/workers/chunks/2ed81f1e490cb7e73405.js +0 -1
  366. package/assets/esri/core/workers/chunks/32f26757e36704923286.js +0 -1
  367. package/assets/esri/core/workers/chunks/33e86dd1a54e447fa0e3.js +0 -1
  368. package/assets/esri/core/workers/chunks/35c87b0a4d4ee7ce302d.js +0 -1
  369. package/assets/esri/core/workers/chunks/36b904912cea1744d1c6.js +0 -1
  370. package/assets/esri/core/workers/chunks/3a35779cae6a11cde51b.js +0 -1
  371. package/assets/esri/core/workers/chunks/3b7060d264888bf298b1.js +0 -1
  372. package/assets/esri/core/workers/chunks/3df5394b17e9659ecb8f.js +0 -1
  373. package/assets/esri/core/workers/chunks/4adfe7f8a8efe2cd8e80.js +0 -1
  374. package/assets/esri/core/workers/chunks/511b9c12a7479d39dac0.js +0 -1
  375. package/assets/esri/core/workers/chunks/5396a894e6f8030ca088.js +0 -1
  376. package/assets/esri/core/workers/chunks/5728d8440aca205e4f53.js +0 -1
  377. package/assets/esri/core/workers/chunks/66392ff750c28064040a.js +0 -1
  378. package/assets/esri/core/workers/chunks/668d84dc512b3085a960.js +0 -1
  379. package/assets/esri/core/workers/chunks/6849282c4a5cd733779d.js +0 -1
  380. package/assets/esri/core/workers/chunks/6adc17e6e287a365ad8d.js +0 -1
  381. package/assets/esri/core/workers/chunks/6db5ee9c589265b23b60.js +0 -1
  382. package/assets/esri/core/workers/chunks/76ed8e455f6bd79e561c.js +0 -1
  383. package/assets/esri/core/workers/chunks/7c34eb94e2c74602aeab.js +0 -1
  384. package/assets/esri/core/workers/chunks/831455798b177678720c.js +0 -1
  385. package/assets/esri/core/workers/chunks/88b08b386926ec889573.js +0 -1
  386. package/assets/esri/core/workers/chunks/8bd4c43c34aacf3b07da.js +0 -1
  387. package/assets/esri/core/workers/chunks/8ca88cfc0b9f84dc5832.js +0 -1
  388. package/assets/esri/core/workers/chunks/928b18e13e015330d44b.js +0 -1
  389. package/assets/esri/core/workers/chunks/937e347d130d469518ce.js +0 -1
  390. package/assets/esri/core/workers/chunks/93b40245378ced43ca08.js +0 -1
  391. package/assets/esri/core/workers/chunks/98dfe31e8ed9b522eaff.js +0 -1
  392. package/assets/esri/core/workers/chunks/a18cb809dd56c5537b3b.js +0 -1
  393. package/assets/esri/core/workers/chunks/a195f569eada3a8736be.js +0 -1
  394. package/assets/esri/core/workers/chunks/a40ede4d3375184f21fe.js +0 -1
  395. package/assets/esri/core/workers/chunks/a8167ab9fd846d699be5.js +0 -1
  396. package/assets/esri/core/workers/chunks/af96cbc4fb7bef726635.js +0 -1
  397. package/assets/esri/core/workers/chunks/b87aca8ad281870ae970.js +0 -1
  398. package/assets/esri/core/workers/chunks/ceb5bd9f2afaa2ea0808.js +0 -1
  399. package/assets/esri/core/workers/chunks/d25c37f169577a33db46.js +0 -1
  400. package/assets/esri/core/workers/chunks/d374cb2d17a2d11c500f.js +0 -1
  401. package/assets/esri/core/workers/chunks/dadf85890961bcc205eb.js +0 -1
  402. package/assets/esri/core/workers/chunks/db279d5d9c7deec554bb.js +0 -1
  403. package/assets/esri/core/workers/chunks/de0c94defb90e1805081.js +0 -1
  404. package/assets/esri/core/workers/chunks/e1340232962cf576d37e.js +0 -1
  405. package/assets/esri/core/workers/chunks/e38d1ba15babc238b151.js +0 -1
  406. package/assets/esri/core/workers/chunks/e73bb7c8de7412d9975c.js +0 -1
  407. package/assets/esri/core/workers/chunks/f23351a04643c464be84.js +0 -1
  408. package/assets/esri/core/workers/chunks/f3d331da3c61af5c5a2f.js +0 -1
  409. package/assets/esri/core/workers/chunks/f5125925f83c979edde7.js +0 -2
  410. package/assets/esri/core/workers/chunks/f912c173c58ae4299cbe.js +0 -1
  411. package/assets/esri/core/workers/chunks/f93facf47aba9b128fcc.js +0 -1
  412. package/assets/esri/core/workers/chunks/fae147d03ed723ab234d.js +0 -1
  413. package/views/2d/engine/ManagedCanvas.js +0 -2
  414. package/views/2d/layers/features/support/FeatureSetReaderAnnotationJSON.js +0 -2
  415. package/views/2d/layers/features/support/FeatureSetReaderDimensionJSON.js +0 -2
  416. package/views/2d/layers/support/annodime/annotationUtils.js +0 -2
  417. package/views/3d/state/controllers/SurfaceCollisionCorrectionController.js +0 -2
  418. /package/assets/esri/core/workers/chunks/{f5125925f83c979edde7.js.LICENSE.txt → f10a339b16d84b650012.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../../Graphic.js";import{createTask as t}from"../../../core/asyncUtils.js";import a from"../../../core/Collection.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{throwIfAborted as s}from"../../../core/promiseUtils.js";import i from"../../../geometry/Mesh.js";import{projectAsync as n}from"../../../geometry/projectionUtils.js";import o from"../../../geometry/support/MeshComponent.js";import c from"../../../geometry/support/MeshMaterial.js";import u from"../../../geometry/support/MeshTexture.js";import l from"../../../geometry/support/MeshVertexAttributes.js";import h from"../../../symbols/FillSymbol3DLayer.js";import m from"../../../symbols/MeshSymbol3D.js";import{calculateUpdatedWmsf as f}from"../imageMeasurementUtils.js";import{validateTifOrMrfExtension as p}from"../utils.js";import _ from"../support/resolveMediaProps.js";import{computeDefaultAreaOfInterest as x,getBaseRasterLevel as d,applySphereMeshOffsetInMeters as g,applyMeshOffsetInMeters as y,getRasterFetchParameters as v,getRasterLevelSize as w,computePanoramicAreasOfInterest as R,getViewDependentRasterLevel as M,clampRasterLevelForTextureSize as I,createSuperimposeSamplePixels as P,createSuperimposeGridVertexAttributes as O}from"../support/superimposeUtils.js";const b=2,T=2,F=2,D=2,Z=1,C=[255,255,255,255];class S{constructor(e){this._properties=e,this._cachedBaseTexture=null,this._cachedDefaultFrustumObjectId=null,this._cachedDefaultFrustumNearPlaneAverageZ=0,this._cachedPanoramicRadiusObjectId=null,this._defaultZOffsetInMeters=0,this._defaultZOffsetPercentage=0,this._defaultZOffsetRangeInMeters=0,this._defaultCameraFeature=null,this._graphics=[],this._panoramicZOffsetInMeters=0,this._panoramicZOffsetPercentage=0,this._panoramicZOffsetRangeInMeters=0,this._panoramicNavigationFeature=null,this._rasterTextureCacheFeature=null,this._rasterTextureFetchCache=new Map,this._task=null}clear(){this._destroyGraphics(this._graphics,!0),this._cachedBaseTexture=null,this._cachedDefaultFrustumObjectId=null,this._cachedDefaultFrustumNearPlaneAverageZ=0,this._cachedPanoramicRadiusObjectId=null,this._defaultZOffsetInMeters=0,this._defaultZOffsetRangeInMeters=0,this._defaultCameraFeature=null,this._graphics=[],this._panoramicZOffsetInMeters=0,this._panoramicZOffsetPercentage=0,this._panoramicZOffsetRangeInMeters=0,this._panoramicNavigationFeature=null,this._rasterTextureCacheFeature=null,this._rasterTextureFetchCache.clear()}destroy(){this._task=this._task?.abort()??null,this.clear()}update(e){this._task?.abort(),this._task=t(async t=>{if(!this._canUpdate(e))return void this._resetInactiveState(e.adapter);let a=!1,r=[];try{await this._updateDefaultCameraIfNeeded(e,t),this._resetRasterTextureCacheIfNeeded(e.currentBestFeature);const i=await this._resolveMedia(e,t);if(!i)return;if(({graphics:r}=await this._createGraphics(e,i,t)),!r.length)return;await this._updateNavigation(e,t),await this._applyPersistentZOffset(r,e,t),s(t),this._replaceGraphics(r,e.mode),a=!0}finally{a||this._destroyGraphics(r,!1)}})}_canUpdate(e){const t=["default","panoramic"];return e.superimposeViewEnabled&&"image-loaded"===e.state&&"3d"===e.view?.type&&!!e.currentBestFeature&&!!e.layer&&t.includes(e.mode)}_resetInactiveState(e){e?.disableDefaultSuperimposeNavigation?.(),e?.disablePanoramicSuperimposeNavigation?.(),this.clear()}async _updateDefaultCameraIfNeeded(e,t){const{currentBestFeature:a,mode:r}=e;if(a&&"default"===r)return this._shouldUpdateDefaultCamera(r,a)?(await(e.adapter?.updateDefaultSuperimposeCamera?.({currentBestFeature:a},{signal:t})),s(t),void(this._defaultCameraFeature=a)):void 0}async _resolveMedia(e,t){const{currentBestFeature:a,layer:r,mode:i,view:n}=e;if(!a||!r||!n||"default"!==i&&"panoramic"!==i)return null;const o=await _(a.attributes,r,{signal:t});if(s(t),!o?.mediaUrl)return null;if(!p(o.datasetFormat))return this._resolveNonRasterMedia(o);const c=await this._resolveRasterMedia(o,n,t);if(!c)return null;switch(i){case"default":{const a=await this._resolveDefaultAreaOfInterest(e,o,t);return this._resolveDefaultRasterMedia(c,a,n,t)}case"panoramic":return this._resolvePanoramicRasterMedia(c,e,t)}}_resolveNonRasterMedia(e){return{areaOfInterest:null,textureUrl:this._resolveTextureUrl(e)}}async _resolveDefaultAreaOfInterest(e,t,a){const{activeImageSize:r,currentBestFeature:i,mode:n,view:o}=e;if(!("default"===n&&r&&i&&o&&p(t.datasetFormat)))return null;const c=await x(i,o,r,this._properties.pointToPixel,{signal:a});return s(a),c}async _resolveRasterMedia(e,t,a){const r=await this._loadRaster(e,{signal:a});if(s(a),!r)return null;const i=d(r,t);let n=this._cachedBaseTexture;if(!n){const e=await this._createRasterTexture(r,null,i,{signal:a});s(a),e&&(n=e,this._cachedBaseTexture=e)}return n?{baseLevel:i,baseTexture:n,raster:r}:null}async _resolveDefaultRasterMedia(e,t,a,r){const{baseLevel:i,baseTexture:n,raster:o}=e;if(!t)return{areaOfInterest:null,baseTexture:n,raster:o,texture:n};const c=d(o,a,t),u=await this._createCompositedDefaultRasterTexture(o,t,c,i,{signal:r});return s(r),{areaOfInterest:t,baseTexture:n,overlayTexture:u,raster:o,texture:u??n}}async _resolvePanoramicRasterMedia(e,t,a){const{activeImageSize:r,currentBestFeature:i,view:n}=t,{baseTexture:o,raster:c}=e;if(!r||!i||!n)return{areaOfInterest:null,baseTexture:o,raster:c,texture:o};const u=await this._createPanoramicRasterTexture(c,i,n,r,{signal:a})??o;return s(a),{areaOfInterest:null,baseTexture:o,raster:c,texture:u}}async _createGraphics(e,t,a){switch(e.mode){case"default":return this._createDefaultGraphics(e,t,a);case"panoramic":return this._createPanoramicGraphics(e,t,a)}return{graphics:[]}}async _createDefaultGraphics(e,t,a){const r=await this._createAndDrapeDefaultGraphic(e,a,{texture:t.texture,textureUrl:t.textureUrl});return{graphics:r?[r]:[]}}async _createAndDrapeDefaultGraphic(e,t,a){const{activeImageSize:r,depthImageLoaded:i,view:n}=e,{areaOfInterest:o,texture:c,textureUrl:u}=a;if(!r||!n)return null;const l=await this._createDefaultGraphic({areaOfInterest:o,depthImageLoaded:i,imageSize:r,signal:t,texture:c,textureUrl:u,view:n});return l?(s(t),l):null}async _createPanoramicGraphics(e,t,a){const r=await this._createPanoramicSuperimposeGraphic(e,t,a);return{graphics:r?[r]:[]}}async _createPanoramicSuperimposeGraphic(e,t,a){const{activeImageSize:r,currentBestFeature:s,panoramicHorizonAngles:i,view:n}=e;return n?this._createPanoramicGraphic({currentBestFeature:s??void 0,horizonAngles:i,imageSize:r,signal:a,texture:t.texture,textureUrl:t.textureUrl,view:n}):null}async _updateNavigation(e,t){const{currentBestFeature:a,mode:r,view:s}=e;if(a&&s&&"3d"===s.type)switch(r){case"default":return void this._updateDefaultNavigation(e);case"panoramic":return void await this._updatePanoramicNavigation(e,a,s,t)}}_updateDefaultNavigation(e){this._updateDefaultSuperimposeNavigation(e.adapter,e.defaultSuperimposeCameraLockEnabled)}async _updatePanoramicNavigation(e,t,a,r){e.adapter?.disableDefaultSuperimposeNavigation?.();const i=t!==this._panoramicNavigationFeature?e.panoramicCamera??a.camera:a.camera;i&&this._shouldUpdatePanoramicCamera(e.mode,t)&&(e.adapter?.disablePanoramicSuperimposeNavigation?.(),await(e.adapter?.updatePanoramicSuperimposeCamera?.({camera:i,currentBestFeature:t},{signal:r})),s(r)),this._panoramicNavigationFeature=t}_replaceGraphics(e,t){if("panoramic"===t&&this._updatePanoramicGraphicInPlace(e))return;const a=this._graphics;this._graphics=e,this._properties.overlays.addMany(e),this._destroyGraphics(a,!0)}_updatePanoramicGraphicInPlace(e){if(1!==this._graphics.length||1!==e.length)return!1;const t=this._graphics[0],a=e[0];return!(!t||!a)&&(t.geometry=a.geometry,t.symbol=a.symbol,t.visible=a.visible,a.geometry=null,a.symbol=null,r(a),!0)}_destroyGraphics(e,t){e.length&&(t&&this._properties.overlays.removeMany(e),e.forEach(e=>r(e)))}_updateDefaultSuperimposeNavigation(e,t=!0){t?e?.enableDefaultSuperimposeNavigation?.():e?.disableDefaultSuperimposeNavigation?.(),this._panoramicNavigationFeature&&e?.disablePanoramicSuperimposeNavigation?.(),this._panoramicNavigationFeature=null}_shouldUpdateDefaultCamera(e,t){return"default"===e&&t!==this._defaultCameraFeature}_shouldUpdatePanoramicCamera(e,t){return"panoramic"===e&&t!==this._panoramicNavigationFeature}setDefaultZOffsetPercentage(e){const t=Math.max(0,Math.min(100,e)),a=this._defaultZOffsetRangeInMeters*t/100,r=a-this._defaultZOffsetInMeters;this._defaultZOffsetPercentage=t,this._defaultZOffsetInMeters=a,this._applyZOffset(this._graphics,"default",r)}setPanoramicRadiusPercentage(e){const t=Math.max(0,Math.min(100,e)),a=this._panoramicZOffsetRangeInMeters*t/100,r=a-this._panoramicZOffsetInMeters;this._panoramicZOffsetPercentage=t,this._panoramicZOffsetInMeters=a,this._applyZOffset(this._graphics,"panoramic",r)}updateZOffset(e){0!==e&&(this._panoramicZOffsetInMeters+=e,this._applyZOffset(this._graphics,"panoramic",e))}_applyZOffset(e,t,a){0!==a&&e.forEach(e=>{const r=e.geometry;"mesh"===r?.type&&("panoramic"!==t?y(r,{z:a}):g(r,{radiusOffset:a}))})}async _applyPersistentZOffset(e,t,a){if("panoramic"===t.mode)return this._panoramicZOffsetRangeInMeters=await this._resolvePanoramicZOffsetRangeInMeters(t.currentBestFeature,t.view,a),this._panoramicZOffsetInMeters=this._panoramicZOffsetRangeInMeters*this._panoramicZOffsetPercentage/100,void this._applyZOffset(e,"panoramic",this._panoramicZOffsetInMeters);this._defaultZOffsetRangeInMeters=await this._resolveDefaultZOffsetRangeInMeters(e,t.currentBestFeature,t.currentBestFeatureFrustum,t.view,a),this._defaultZOffsetInMeters=this._defaultZOffsetRangeInMeters*this._defaultZOffsetPercentage/100,this._applyZOffset(e,"default",this._defaultZOffsetInMeters)}async _resolveDefaultZOffsetRangeInMeters(e,t,a,r,i){const[o]=e,c=o?.geometry,u=t.attributes.objectId;if("mesh"!==c?.type||!a)return 0;if(this._cachedDefaultFrustumObjectId!==u){const e=a.spatialReference.equals(r.spatialReference)?a:await n(a.clone(),r.spatialReference,{signal:i});if(s(i),!e||"mesh"!==e.type)return this._cachedDefaultFrustumObjectId=u,this._cachedDefaultFrustumNearPlaneAverageZ=0,0;this._cachedDefaultFrustumObjectId=u,this._cachedDefaultFrustumNearPlaneAverageZ=this._getFrustumNearPlaneAverageZ(e)}return this._cachedDefaultFrustumNearPlaneAverageZ-this._getMeshAverageZ(c)}async _resolvePanoramicZOffsetRangeInMeters(e,t,a){const r=e.attributes.objectId;if(this._cachedPanoramicRadiusObjectId!==r){const i=e.attributes.farDistance,o=e.attributes.nearDistance??i;if(!(i>0&&o>=0))return this._cachedPanoramicRadiusObjectId=r,this._panoramicZOffsetRangeInMeters=0,0;const c=e.attributes.location,u=c.spatialReference.equals(t.spatialReference)?c:await n(c,t.spatialReference,{signal:a});if(s(a),!u)return this._cachedPanoramicRadiusObjectId=r,this._panoramicZOffsetRangeInMeters=0,0;const l=u.spatialReference.isWebMercator?f(u.y):1;this._cachedPanoramicRadiusObjectId=r,this._panoramicZOffsetRangeInMeters=(o-i)*l}return this._panoramicZOffsetRangeInMeters}_getFrustumNearPlaneAverageZ(e){const{position:t}=e.vertexAttributes;if(t.length<12)return this._getMeshAverageZ(e);let a=0;for(let r=0;r<4;r+=1)a+=t[3*r+2];return a/4}_getMeshAverageZ(e){const{position:t}=e.vertexAttributes,a=Math.floor(t.length/3);if(0===a)return 0;let r=0;for(let s=0;s<a;s+=1)r+=t[3*s+2];return r/a}_resolveTextureUrl(e){const t=new URL(e.mediaUrl);return Object.entries(e.searchParams).forEach(([e,a])=>{t.searchParams.has(e)||t.searchParams.set(e,a)}),t.toString()}_resetRasterTextureCacheIfNeeded(e){e&&e!==this._rasterTextureCacheFeature&&(this._cachedBaseTexture=null,this._rasterTextureFetchCache.clear(),this._rasterTextureCacheFeature=e)}_createImageDataFromPixelBlock(e){return new ImageData(e.getAsRGBA(),e.width,e.height)}_copyImageData(e,t,a,r,s=e.width,i=e.height){const n=e.data,o=t.data,c=e.width,u=e.height,l=t.width,h=t.height;for(let m=0;m<i;m+=1){const e=r+m;if(e<0||e>=h)continue;const t=Math.min(u-1,Math.floor(m*u/i));for(let r=0;r<s;r+=1){const i=a+r;if(i<0||i>=l)continue;const u=4*(t*c+Math.min(c-1,Math.floor(r*c/s))),h=4*(e*l+i);o[h]=n[u],o[h+1]=n[u+1],o[h+2]=n[u+2],o[h+3]=n[u+3]}}}_copyImageDataRegion(e,t,a,r,s,i,n,o){const c=e.data,u=t.data,l=e.width,h=t.width;for(let m=0;m<o;m+=1)for(let e=0;e<n;e+=1){const t=4*((r+m)*l+(a+e)),n=4*((i+m)*h+(s+e));u[n]=c[t],u[n+1]=c[t+1],u[n+2]=c[t+2],u[n+3]=c[t+3]}}async _fetchRasterTextureAtLevel(e,t,a,r){const{offset:i,size:n}=v(e,t,a),o=this._createRasterTextureExtent(i,n),c=this._createRasterTextureLevelCacheKey(e,t),u=this._getOrCreateRasterTextureLevelCache(c),l=this._getUncoveredRasterTextureExtents(o,u.patches);for(const h of l){const a=this._createRasterTextureExtentCacheKey(h);let i=u.inflight.get(a);i||(i=this._fetchRasterTexturePatch(e,t,h,r),u.inflight.set(a,i));try{const e=await i;s(r),e&&u.patches.push(e)}finally{u.inflight.delete(a)}}return this._composeRasterTextureFromCachedPatches(o,u.patches)}_getOrCreateRasterTextureLevelCache(e){let t=this._rasterTextureFetchCache.get(e);return t||(t={inflight:new Map,patches:[]},this._rasterTextureFetchCache.set(e,t)),t}_createRasterTextureLevelCacheKey(e,t){return[e.url,e.rasterInfo.width,e.rasterInfo.height,t].join(":")}_createRasterTextureExtentCacheKey(e){return[e.xmin,e.ymin,e.xmax,e.ymax].join(":")}_createRasterTextureExtent(e,t){return{xmin:e.x,ymin:e.y,xmax:e.x+t.width,ymax:e.y+t.height}}_getUncoveredRasterTextureExtents(e,t){let a=[e];for(const r of t)if(a=a.flatMap(e=>this._subtractRasterTextureExtent(e,r.extent)),!a.length)break;return a}_subtractRasterTextureExtent(e,t){const a=this._intersectRasterTextureExtents(e,t);if(!a)return[e];const r=[];return e.ymin<a.ymin&&r.push({xmin:e.xmin,ymin:e.ymin,xmax:e.xmax,ymax:a.ymin}),a.ymax<e.ymax&&r.push({xmin:e.xmin,ymin:a.ymax,xmax:e.xmax,ymax:e.ymax}),e.xmin<a.xmin&&r.push({xmin:e.xmin,ymin:a.ymin,xmax:a.xmin,ymax:a.ymax}),a.xmax<e.xmax&&r.push({xmin:a.xmax,ymin:a.ymin,xmax:e.xmax,ymax:a.ymax}),r.filter(({xmin:e,ymin:t,xmax:a,ymax:r})=>a>e&&r>t)}_intersectRasterTextureExtents(e,t){const a=Math.max(e.xmin,t.xmin),r=Math.max(e.ymin,t.ymin),s=Math.min(e.xmax,t.xmax),i=Math.min(e.ymax,t.ymax);return s>a&&i>r?{xmin:a,ymin:r,xmax:s,ymax:i}:null}async _fetchRasterTexturePatch(e,t,a,r){const{pixelBlock:i}=await e.fetchRawPixels(t,{x:a.xmin,y:a.ymin},{width:a.xmax-a.xmin,height:a.ymax-a.ymin},r);if(s(r),i)return{extent:a,imageData:this._createImageDataFromPixelBlock(i)}}_composeRasterTextureFromCachedPatches(e,t){const a=t.filter(t=>this._intersectRasterTextureExtents(e,t.extent));if(!a.length)return;const r=new ImageData(e.xmax-e.xmin,e.ymax-e.ymin);for(const s of a){const t=this._intersectRasterTextureExtents(e,s.extent);t&&this._copyImageDataRegion(s.imageData,r,t.xmin-s.extent.xmin,t.ymin-s.extent.ymin,t.xmin-e.xmin,t.ymin-e.ymin,t.xmax-t.xmin,t.ymax-t.ymin)}return r}async _loadRaster(e,t){const{loadRaster:a}=await import("../../PanoramicViewer/utils.js"),r=await a(this._resolveTextureUrl(e),t);return s(t),r}async _createCompositedDefaultRasterTexture(e,t,a,r,i){const{pyramidScalingFactor:n}=e.rasterInfo.storageInfo,o=n??b,c=w(e.rasterInfo.width,e.rasterInfo.height,a,o),l=await this._fetchRasterTextureAtLevel(e,r,null,i);if(s(i),!l)return;const h=await this._fetchRasterTextureAtLevel(e,a,t,i);if(s(i),!h)return new u({data:l});const m=new ImageData(c.width,c.height);this._copyImageData(l,m,0,0,c.width,c.height);const f=o**a,{x:p,y:_}=this._resolveRasterDrawOrigin(t,f);return this._copyImageData(h,m,p,_),new u({data:m})}async _createRasterTexture(e,t,a,r){const{maximumPyramidLevel:s}=e.rasterInfo.storageInfo,i=await this._fetchRasterTextureAtLevel(e,a??s,t,r);if(i)return new u({data:i})}async _createPanoramicRasterTexture(e,t,a,r,i){const n=await R(t,a,r,this._properties.pointToPixel,i);if(s(i),!n?.length)return this._createRasterTexture(e,null,void 0,i);const{baseLevel:o,level:c,scalingFactor:u}=this._resolvePanoramicRasterLevels(e,a,n);return o<=c?this._createRasterTexture(e,null,c,i):this._createCompositedPanoramicRasterTexture(e,n,{baseLevel:o,level:c,scalingFactor:u},i)}_resolvePanoramicRasterLevels(e,t,a){const{maximumPyramidLevel:r,pyramidScalingFactor:s}=e.rasterInfo.storageInfo,i=a.reduce((a,r)=>Math.min(a,M(e,t,r)),r),n=I(e,i),o=s??b;return{baseLevel:Math.min(r,n+T),level:n,scalingFactor:o}}async _createCompositedPanoramicRasterTexture(e,t,a,r){const{baseLevel:i,level:n,scalingFactor:o}=a,c=w(e.rasterInfo.width,e.rasterInfo.height,n,o),l=await this._fetchRasterTextureAtLevel(e,i,null,r);if(s(r),!l)return;const h=new ImageData(c.width,c.height);this._copyImageData(l,h,0,0,c.width,c.height);const m=o**n;for(const u of t){const t=await this._fetchRasterTextureAtLevel(e,n,u,r);if(s(r),!t)continue;const{x:a,y:i}=this._resolveRasterDrawOrigin(u,m);this._copyImageData(t,h,a,i)}return new u({data:h})}_resolveRasterDrawOrigin(e,t){return{x:Math.max(0,Math.floor(e.xmin/t)),y:Math.max(0,Math.floor(e.ymin/t))}}async _createFootprintMesh(e,t,a,r){if("3d"!==t.type)return null;const c=P(e,a),u=await this._properties.getMapPoint(c,r);s(r);const h=await Promise.all(u.map(e=>e.spatialReference.equals(t.spatialReference)?e:n(e,t.spatialReference,r)));if(s(r),h.some(e=>!e))return null;const{faces:m,position:f,uv:p}=O(h,e,a);return new i({vertexAttributes:new l({position:f,uv:p}),components:[new o({faces:m})],spatialReference:t.spatialReference.clone()})}async _createPanoramicGraphic(t){const{currentBestFeature:r,horizonAngles:i,signal:n,texture:o,textureUrl:c,view:u}=t;if(!t.imageSize||!r)return null;const l=this._createPanoramicMeshTexture(o,c),f=await this._resolvePanoramicMeshLocation(r,u,n);if(!f)return null;s(n);const{imageMesh:p,radiusOfSphericalMesh:_}=this._createPanoramicSphereMesh(r,f,l);return this._flipPanoramicMeshUv(p),this._rotatePanoramicMeshToHorizon(p,i),p.offset(0,0,-_),new e({geometry:p,symbol:new m({symbolLayers:new a([new h({})])})})}_createPanoramicMeshTexture(e,t){if(e)return e;if(!t)throw new Error("Missing texture URL or texture data.");return new u({url:t})}async _resolvePanoramicMeshLocation(e,t,a){const r=e.attributes.location,i=r.spatialReference.equals(t.spatialReference)?r.clone():await n(r,t.spatialReference,{signal:a});return s(a),i}_createPanoramicSphereMesh(e,t,a){const r=t.spatialReference.isWebMercator?f(t.y):1,s=e.attributes.farDistance*r,n=new c({colorTexture:a}),o=i.createSphere(t,{size:s*F,densificationFactor:D,vertexSpace:"georeferenced",material:n});return o.components?.forEach(e=>{e.material=n,e.trustSourceNormals=!0}),{imageMesh:o,radiusOfSphericalMesh:s}}_flipPanoramicMeshUv(e){const t=e.vertexAttributes,a=t.uv;if(!a)return;const r=a.length/2;for(let s=0;s<r;s++)a[2*s]=Z-a[2*s];e.vertexAttributes=t}_rotatePanoramicMeshToHorizon(e,t){if(!t)return;const[a,r,s]=t;e.rotate(-a,-r,s,{origin:e.extent.center})}async _createDefaultGraphic(t){const{texture:r,textureUrl:s}=t;if(!r&&!s)throw new Error("Missing texture URL or texture data.");if(!t.imageSize)return null;const i=await this._createFootprintMesh(t.imageSize,t.view,t.areaOfInterest,{signal:t.signal});if(!i)return null;const n=i.vertexAttributes.position,o=[];for(let e=0;e<n.length;e+=3)o.push(...C);i.vertexAttributes.color=new Uint8Array(o);const l=new c({colorTexture:r??new u({url:s})});return i.components?.forEach(e=>{e.shading="source",e.material=l}),new e({geometry:i,symbol:new m({symbolLayers:new a([new h({})])})})}}export{S as default};
2
+ import e from"../../../Graphic.js";import{createTask as t}from"../../../core/asyncUtils.js";import a from"../../../core/Collection.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{throwIfAborted as s}from"../../../core/promiseUtils.js";import i from"../../../geometry/Mesh.js";import{projectAsync as n}from"../../../geometry/projectionUtils.js";import o from"../../../geometry/support/MeshComponent.js";import c from"../../../geometry/support/MeshMaterial.js";import u from"../../../geometry/support/MeshTexture.js";import h from"../../../geometry/support/MeshVertexAttributes.js";import l from"../../../symbols/FillSymbol3DLayer.js";import m from"../../../symbols/MeshSymbol3D.js";import{calculateUpdatedWmsf as f}from"../imageMeasurementUtils.js";import{validateTifOrMrfExtension as p}from"../utils.js";import _ from"../support/resolveMediaProps.js";import{computeDefaultAreaOfInterest as x,getBaseRasterLevel as d,applySphereMeshOffsetInMeters as g,applyMeshOffsetInMeters as y,getRasterFetchParameters as v,getRasterLevelSize as w,computePanoramicAreasOfInterest as R,getViewDependentRasterLevel as M,clampRasterLevelForTextureSize as I,createSuperimposeSamplePixels as P,createSuperimposeGridVertexAttributes as O}from"../support/superimposeUtils.js";const b=2,T=2,F=2,D=2,Z=8,C=1,S=[255,255,255,255];class N{constructor(e){this._properties=e,this._cachedBaseTexture=null,this._cachedDefaultFrustumObjectId=null,this._cachedDefaultFrustumNearPlaneAverageZ=0,this._cachedPanoramicRadiusObjectId=null,this._defaultZOffsetInMeters=0,this._defaultZOffsetPercentage=0,this._defaultZOffsetRangeInMeters=0,this._defaultCameraFeature=null,this._graphics=[],this._panoramicZOffsetInMeters=0,this._panoramicZOffsetPercentage=0,this._panoramicZOffsetRangeInMeters=0,this._panoramicNavigationFeature=null,this._rasterTextureCacheFeature=null,this._rasterTextureFetchCache=new Map,this._task=null}clear(){this._destroyGraphics(this._graphics,!0),this._cachedBaseTexture=null,this._cachedDefaultFrustumObjectId=null,this._cachedDefaultFrustumNearPlaneAverageZ=0,this._cachedPanoramicRadiusObjectId=null,this._defaultZOffsetInMeters=0,this._defaultZOffsetRangeInMeters=0,this._defaultCameraFeature=null,this._graphics=[],this._panoramicZOffsetInMeters=0,this._panoramicZOffsetPercentage=0,this._panoramicZOffsetRangeInMeters=0,this._panoramicNavigationFeature=null,this._rasterTextureCacheFeature=null,this._rasterTextureFetchCache.clear()}destroy(){this._task=this._task?.abort()??null,this.clear()}update(e){this._task?.abort(),this._task=t(async t=>{if(!this._canUpdate(e))return void this._resetInactiveState(e.adapter);let a=!1,r=[];try{await this._updateDefaultCameraIfNeeded(e,t),this._resetRasterTextureCacheIfNeeded(e.currentBestFeature);const i=await this._resolveMedia(e,t);if(!i)return;if(({graphics:r}=await this._createGraphics(e,i,t)),!r.length)return;await this._updateNavigation(e,t),await this._applyPersistentZOffset(r,e,t),s(t),this._replaceGraphics(r,e.mode),a=!0}finally{a||this._destroyGraphics(r,!1)}})}_canUpdate(e){const t=["default","panoramic"];return e.superimposeViewEnabled&&"image-loaded"===e.state&&"3d"===e.view?.type&&!!e.currentBestFeature&&!!e.layer&&t.includes(e.mode)}_resetInactiveState(e){e?.disableDefaultSuperimposeNavigation?.(),e?.disablePanoramicSuperimposeNavigation?.(),this.clear()}async _updateDefaultCameraIfNeeded(e,t){const{currentBestFeature:a,mode:r}=e;if(a&&"default"===r)return this._shouldUpdateDefaultCamera(r,a)?(await(e.adapter?.updateDefaultSuperimposeCamera?.({currentBestFeature:a},{signal:t})),s(t),void(this._defaultCameraFeature=a)):void 0}async _resolveMedia(e,t){const{currentBestFeature:a,layer:r,mode:i,view:n}=e;if(!a||!r||!n||"default"!==i&&"panoramic"!==i)return null;const o=await _(a.attributes,r,{signal:t});if(s(t),!o?.mediaUrl)return null;if(!p(o.datasetFormat))return this._resolveNonRasterMedia(o);const c=await this._resolveRasterMedia(o,n,t);if(!c)return null;switch(i){case"default":{const a=await this._resolveDefaultAreaOfInterest(e,o,t);return this._resolveDefaultRasterMedia(c,a,n,t)}case"panoramic":return this._resolvePanoramicRasterMedia(c,e,t)}}_resolveNonRasterMedia(e){return{areaOfInterest:null,textureUrl:this._resolveTextureUrl(e)}}async _resolveDefaultAreaOfInterest(e,t,a){const{activeImageSize:r,currentBestFeature:i,mode:n,view:o}=e;if(!("default"===n&&r&&i&&o&&p(t.datasetFormat)))return null;const c=await x(i,o,r,this._properties.pointToPixel,{signal:a});return s(a),c}async _resolveRasterMedia(e,t,a){const r=await this._loadRaster(e,{signal:a});if(s(a),!r)return null;const i=d(r,t);let n=this._cachedBaseTexture;if(!n){const e=await this._createRasterTexture(r,null,i,{signal:a});s(a),e&&(n=e,this._cachedBaseTexture=e)}return n?{baseLevel:i,baseTexture:n,raster:r}:null}async _resolveDefaultRasterMedia(e,t,a,r){const{baseLevel:i,baseTexture:n,raster:o}=e;if(!t)return{areaOfInterest:null,baseTexture:n,raster:o,texture:n};const c=d(o,a,t),u=await this._createCompositedDefaultRasterTexture(o,t,c,i,{signal:r});return s(r),{areaOfInterest:t,baseTexture:n,overlayTexture:u,raster:o,texture:u??n}}async _resolvePanoramicRasterMedia(e,t,a){const{activeImageSize:r,currentBestFeature:i,view:n}=t,{baseTexture:o,raster:c}=e;if(!r||!i||!n)return{areaOfInterest:null,baseTexture:o,raster:c,texture:o};const u=await this._createPanoramicRasterTexture(c,i,n,r,{signal:a})??o;return s(a),{areaOfInterest:null,baseTexture:o,raster:c,texture:u}}async _createGraphics(e,t,a){switch(e.mode){case"default":return this._createDefaultGraphics(e,t,a);case"panoramic":return this._createPanoramicGraphics(e,t,a)}return{graphics:[]}}async _createDefaultGraphics(e,t,a){const r=await this._createAndDrapeDefaultGraphic(e,a,{texture:t.texture,textureUrl:t.textureUrl});return{graphics:r?[r]:[]}}async _createAndDrapeDefaultGraphic(e,t,a){const{activeImageSize:r,depthImageLoaded:i,view:n}=e,{areaOfInterest:o,texture:c,textureUrl:u}=a;if(!r||!n)return null;const h=await this._createDefaultGraphic({areaOfInterest:o,depthImageLoaded:i,imageSize:r,signal:t,texture:c,textureUrl:u,view:n});return h?(s(t),h):null}async _createPanoramicGraphics(e,t,a){const r=await this._createPanoramicSuperimposeGraphic(e,t,a);return{graphics:r?[r]:[]}}async _createPanoramicSuperimposeGraphic(e,t,a){const{activeImageSize:r,currentBestFeature:s,panoramicHorizonAngles:i,view:n}=e;return n?this._createPanoramicGraphic({currentBestFeature:s??void 0,horizonAngles:i,imageSize:r,signal:a,texture:t.texture,textureUrl:t.textureUrl,view:n}):null}async _updateNavigation(e,t){const{currentBestFeature:a,mode:r,view:s}=e;if(a&&s&&"3d"===s.type)switch(r){case"default":return void this._updateDefaultNavigation(e);case"panoramic":return void await this._updatePanoramicNavigation(e,a,s,t)}}_updateDefaultNavigation(e){this._updateDefaultSuperimposeNavigation(e.adapter,e.defaultSuperimposeCameraLockEnabled)}async _updatePanoramicNavigation(e,t,a,r){e.adapter?.disableDefaultSuperimposeNavigation?.();const i=t!==this._panoramicNavigationFeature?e.panoramicCamera??a.camera:a.camera;i&&this._shouldUpdatePanoramicCamera(e.mode,t)&&(e.adapter?.disablePanoramicSuperimposeNavigation?.(),await(e.adapter?.updatePanoramicSuperimposeCamera?.({camera:i,currentBestFeature:t},{signal:r})),s(r)),this._panoramicNavigationFeature=t}_replaceGraphics(e,t){if("panoramic"===t&&this._updatePanoramicGraphicInPlace(e))return;const a=this._graphics;this._graphics=e,this._properties.overlays.addMany(e),this._destroyGraphics(a,!0)}_updatePanoramicGraphicInPlace(e){if(1!==this._graphics.length||1!==e.length)return!1;const t=this._graphics[0],a=e[0];return!(!t||!a)&&(t.geometry=a.geometry,t.symbol=a.symbol,t.visible=a.visible,a.geometry=null,a.symbol=null,r(a),!0)}_destroyGraphics(e,t){e.length&&(t&&this._properties.overlays.removeMany(e),e.forEach(e=>r(e)))}_updateDefaultSuperimposeNavigation(e,t=!0){t?e?.enableDefaultSuperimposeNavigation?.():e?.disableDefaultSuperimposeNavigation?.(),this._panoramicNavigationFeature&&e?.disablePanoramicSuperimposeNavigation?.(),this._panoramicNavigationFeature=null}_shouldUpdateDefaultCamera(e,t){return"default"===e&&t!==this._defaultCameraFeature}_shouldUpdatePanoramicCamera(e,t){return"panoramic"===e&&t!==this._panoramicNavigationFeature}setDefaultZOffsetPercentage(e){const t=Math.max(0,Math.min(100,e)),a=this._defaultZOffsetRangeInMeters*t/100,r=a-this._defaultZOffsetInMeters;this._defaultZOffsetPercentage=t,this._defaultZOffsetInMeters=a,this._applyZOffset(this._graphics,"default",r)}setPanoramicRadiusPercentage(e){const t=Math.max(0,Math.min(100,e)),a=this._panoramicZOffsetRangeInMeters*t/100,r=a-this._panoramicZOffsetInMeters;this._panoramicZOffsetPercentage=t,this._panoramicZOffsetInMeters=a,this._applyZOffset(this._graphics,"panoramic",r)}updateZOffset(e){0!==e&&(this._panoramicZOffsetInMeters+=e,this._applyZOffset(this._graphics,"panoramic",e))}_applyZOffset(e,t,a){0!==a&&e.forEach(e=>{const r=e.geometry;"mesh"===r?.type&&("panoramic"!==t?y(r,{z:a}):g(r,{radiusOffset:a}))})}async _applyPersistentZOffset(e,t,a){if("panoramic"===t.mode)return this._panoramicZOffsetRangeInMeters=await this._resolvePanoramicZOffsetRangeInMeters(t.currentBestFeature,t.view,a),this._panoramicZOffsetInMeters=this._panoramicZOffsetRangeInMeters*this._panoramicZOffsetPercentage/100,void this._applyZOffset(e,"panoramic",this._panoramicZOffsetInMeters);this._defaultZOffsetRangeInMeters=await this._resolveDefaultZOffsetRangeInMeters(e,t.currentBestFeature,t.currentBestFeatureFrustum,t.view,a),this._defaultZOffsetInMeters=this._defaultZOffsetRangeInMeters*this._defaultZOffsetPercentage/100,this._applyZOffset(e,"default",this._defaultZOffsetInMeters)}async _resolveDefaultZOffsetRangeInMeters(e,t,a,r,i){const[o]=e,c=o?.geometry,u=t.attributes.objectId;if("mesh"!==c?.type||!a)return 0;if(this._cachedDefaultFrustumObjectId!==u){const e=a.spatialReference.equals(r.spatialReference)?a:await n(a.clone(),r.spatialReference,{signal:i});if(s(i),!e||"mesh"!==e.type)return this._cachedDefaultFrustumObjectId=u,this._cachedDefaultFrustumNearPlaneAverageZ=0,0;this._cachedDefaultFrustumObjectId=u,this._cachedDefaultFrustumNearPlaneAverageZ=this._getFrustumNearPlaneAverageZ(e)}return this._cachedDefaultFrustumNearPlaneAverageZ-this._getMeshAverageZ(c)}async _resolvePanoramicZOffsetRangeInMeters(e,t,a){const r=e.attributes.objectId;if(this._cachedPanoramicRadiusObjectId!==r){const i=e.attributes.farDistance,o=Math.max(Z,e.attributes.nearDistance??i);if(!(i>0&&o>=0))return this._cachedPanoramicRadiusObjectId=r,this._panoramicZOffsetRangeInMeters=0,0;const c=e.attributes.location,u=c.spatialReference.equals(t.spatialReference)?c:await n(c,t.spatialReference,{signal:a});if(s(a),!u)return this._cachedPanoramicRadiusObjectId=r,this._panoramicZOffsetRangeInMeters=0,0;const h=u.spatialReference.isWebMercator?f(u.y):1;this._cachedPanoramicRadiusObjectId=r,this._panoramicZOffsetRangeInMeters=(o-i)*h}return this._panoramicZOffsetRangeInMeters}_getFrustumNearPlaneAverageZ(e){const{position:t}=e.vertexAttributes;if(t.length<12)return this._getMeshAverageZ(e);let a=0;for(let r=0;r<4;r+=1)a+=t[3*r+2];return a/4}_getMeshAverageZ(e){const{position:t}=e.vertexAttributes,a=Math.floor(t.length/3);if(0===a)return 0;let r=0;for(let s=0;s<a;s+=1)r+=t[3*s+2];return r/a}_resolveTextureUrl(e){const t=new URL(e.mediaUrl);return Object.entries(e.searchParams).forEach(([e,a])=>{t.searchParams.has(e)||t.searchParams.set(e,a)}),t.toString()}_resetRasterTextureCacheIfNeeded(e){e&&e!==this._rasterTextureCacheFeature&&(this._cachedBaseTexture=null,this._rasterTextureFetchCache.clear(),this._rasterTextureCacheFeature=e)}_createImageDataFromPixelBlock(e){return new ImageData(e.getAsRGBA(),e.width,e.height)}_copyImageData(e,t,a,r,s=e.width,i=e.height){const n=e.data,o=t.data,c=e.width,u=e.height,h=t.width,l=t.height;for(let m=0;m<i;m+=1){const e=r+m;if(e<0||e>=l)continue;const t=Math.min(u-1,Math.floor(m*u/i));for(let r=0;r<s;r+=1){const i=a+r;if(i<0||i>=h)continue;const u=4*(t*c+Math.min(c-1,Math.floor(r*c/s))),l=4*(e*h+i);o[l]=n[u],o[l+1]=n[u+1],o[l+2]=n[u+2],o[l+3]=n[u+3]}}}_copyImageDataRegion(e,t,a,r,s,i,n,o){const c=e.data,u=t.data,h=e.width,l=t.width;for(let m=0;m<o;m+=1)for(let e=0;e<n;e+=1){const t=4*((r+m)*h+(a+e)),n=4*((i+m)*l+(s+e));u[n]=c[t],u[n+1]=c[t+1],u[n+2]=c[t+2],u[n+3]=c[t+3]}}async _fetchRasterTextureAtLevel(e,t,a,r){const{offset:i,size:n}=v(e,t,a),o=this._createRasterTextureExtent(i,n),c=this._createRasterTextureLevelCacheKey(e,t),u=this._getOrCreateRasterTextureLevelCache(c),h=this._getUncoveredRasterTextureExtents(o,u.patches);for(const l of h){const a=this._createRasterTextureExtentCacheKey(l);let i=u.inflight.get(a);i||(i=this._fetchRasterTexturePatch(e,t,l,r),u.inflight.set(a,i));try{const e=await i;s(r),e&&u.patches.push(e)}finally{u.inflight.delete(a)}}return this._composeRasterTextureFromCachedPatches(o,u.patches)}_getOrCreateRasterTextureLevelCache(e){let t=this._rasterTextureFetchCache.get(e);return t||(t={inflight:new Map,patches:[]},this._rasterTextureFetchCache.set(e,t)),t}_createRasterTextureLevelCacheKey(e,t){return[e.url,e.rasterInfo.width,e.rasterInfo.height,t].join(":")}_createRasterTextureExtentCacheKey(e){return[e.xmin,e.ymin,e.xmax,e.ymax].join(":")}_createRasterTextureExtent(e,t){return{xmin:e.x,ymin:e.y,xmax:e.x+t.width,ymax:e.y+t.height}}_getUncoveredRasterTextureExtents(e,t){let a=[e];for(const r of t)if(a=a.flatMap(e=>this._subtractRasterTextureExtent(e,r.extent)),!a.length)break;return a}_subtractRasterTextureExtent(e,t){const a=this._intersectRasterTextureExtents(e,t);if(!a)return[e];const r=[];return e.ymin<a.ymin&&r.push({xmin:e.xmin,ymin:e.ymin,xmax:e.xmax,ymax:a.ymin}),a.ymax<e.ymax&&r.push({xmin:e.xmin,ymin:a.ymax,xmax:e.xmax,ymax:e.ymax}),e.xmin<a.xmin&&r.push({xmin:e.xmin,ymin:a.ymin,xmax:a.xmin,ymax:a.ymax}),a.xmax<e.xmax&&r.push({xmin:a.xmax,ymin:a.ymin,xmax:e.xmax,ymax:a.ymax}),r.filter(({xmin:e,ymin:t,xmax:a,ymax:r})=>a>e&&r>t)}_intersectRasterTextureExtents(e,t){const a=Math.max(e.xmin,t.xmin),r=Math.max(e.ymin,t.ymin),s=Math.min(e.xmax,t.xmax),i=Math.min(e.ymax,t.ymax);return s>a&&i>r?{xmin:a,ymin:r,xmax:s,ymax:i}:null}async _fetchRasterTexturePatch(e,t,a,r){const{pixelBlock:i}=await e.fetchRawPixels(t,{x:a.xmin,y:a.ymin},{width:a.xmax-a.xmin,height:a.ymax-a.ymin},r);if(s(r),i)return{extent:a,imageData:this._createImageDataFromPixelBlock(i)}}_composeRasterTextureFromCachedPatches(e,t){const a=t.filter(t=>this._intersectRasterTextureExtents(e,t.extent));if(!a.length)return;const r=new ImageData(e.xmax-e.xmin,e.ymax-e.ymin);for(const s of a){const t=this._intersectRasterTextureExtents(e,s.extent);t&&this._copyImageDataRegion(s.imageData,r,t.xmin-s.extent.xmin,t.ymin-s.extent.ymin,t.xmin-e.xmin,t.ymin-e.ymin,t.xmax-t.xmin,t.ymax-t.ymin)}return r}async _loadRaster(e,t){const{loadRaster:a}=await import("../../PanoramicViewer/utils.js"),r=await a(this._resolveTextureUrl(e),t);return s(t),r}async _createCompositedDefaultRasterTexture(e,t,a,r,i){const{pyramidScalingFactor:n}=e.rasterInfo.storageInfo,o=n??b,c=w(e.rasterInfo.width,e.rasterInfo.height,a,o),h=await this._fetchRasterTextureAtLevel(e,r,null,i);if(s(i),!h)return;const l=await this._fetchRasterTextureAtLevel(e,a,t,i);if(s(i),!l)return new u({data:h});const m=new ImageData(c.width,c.height);this._copyImageData(h,m,0,0,c.width,c.height);const f=o**a,{x:p,y:_}=this._resolveRasterDrawOrigin(t,f);return this._copyImageData(l,m,p,_),new u({data:m})}async _createRasterTexture(e,t,a,r){const{maximumPyramidLevel:s}=e.rasterInfo.storageInfo,i=await this._fetchRasterTextureAtLevel(e,a??s,t,r);if(i)return new u({data:i})}async _createPanoramicRasterTexture(e,t,a,r,i){const n=await R(t,a,r,this._properties.pointToPixel,i);if(s(i),!n?.length)return this._createRasterTexture(e,null,void 0,i);const{baseLevel:o,level:c,scalingFactor:u}=this._resolvePanoramicRasterLevels(e,a,n);return o<=c?this._createRasterTexture(e,null,c,i):this._createCompositedPanoramicRasterTexture(e,n,{baseLevel:o,level:c,scalingFactor:u},i)}_resolvePanoramicRasterLevels(e,t,a){const{maximumPyramidLevel:r,pyramidScalingFactor:s}=e.rasterInfo.storageInfo,i=a.reduce((a,r)=>Math.min(a,M(e,t,r)),r),n=I(e,i),o=s??b;return{baseLevel:Math.min(r,n+T),level:n,scalingFactor:o}}async _createCompositedPanoramicRasterTexture(e,t,a,r){const{baseLevel:i,level:n,scalingFactor:o}=a,c=w(e.rasterInfo.width,e.rasterInfo.height,n,o),h=await this._fetchRasterTextureAtLevel(e,i,null,r);if(s(r),!h)return;const l=new ImageData(c.width,c.height);this._copyImageData(h,l,0,0,c.width,c.height);const m=o**n;for(const u of t){const t=await this._fetchRasterTextureAtLevel(e,n,u,r);if(s(r),!t)continue;const{x:a,y:i}=this._resolveRasterDrawOrigin(u,m);this._copyImageData(t,l,a,i)}return new u({data:l})}_resolveRasterDrawOrigin(e,t){return{x:Math.max(0,Math.floor(e.xmin/t)),y:Math.max(0,Math.floor(e.ymin/t))}}async _createFootprintMesh(e,t,a,r){if("3d"!==t.type)return null;const c=P(e,a),u=await this._properties.getMapPoint(c,r);s(r);const l=await Promise.all(u.map(e=>e.spatialReference.equals(t.spatialReference)?e:n(e,t.spatialReference,r)));if(s(r),l.some(e=>!e))return null;const{faces:m,position:f,uv:p}=O(l,e,a);return new i({vertexAttributes:new h({position:f,uv:p}),components:[new o({faces:m})],spatialReference:t.spatialReference.clone()})}async _createPanoramicGraphic(t){const{currentBestFeature:r,horizonAngles:i,signal:n,texture:o,textureUrl:c,view:u}=t;if(!t.imageSize||!r)return null;const h=this._createPanoramicMeshTexture(o,c),f=await this._resolvePanoramicMeshLocation(r,u,n);if(!f)return null;s(n);const{imageMesh:p,radiusOfSphericalMesh:_}=this._createPanoramicSphereMesh(r,f,h);return this._flipPanoramicMeshUv(p),this._rotatePanoramicMeshToHorizon(p,i),p.offset(0,0,-_),new e({geometry:p,symbol:new m({symbolLayers:new a([new l({})])})})}_createPanoramicMeshTexture(e,t){if(e)return e;if(!t)throw new Error("Missing texture URL or texture data.");return new u({url:t})}async _resolvePanoramicMeshLocation(e,t,a){const r=e.attributes.location,i=r.spatialReference.equals(t.spatialReference)?r.clone():await n(r,t.spatialReference,{signal:a});return s(a),i}_createPanoramicSphereMesh(e,t,a){const r=t.spatialReference.isWebMercator?f(t.y):1,s=e.attributes.farDistance*r,n=new c({colorTexture:a}),o=i.createSphere(t,{size:s*F,densificationFactor:D,vertexSpace:"georeferenced",material:n});return o.components?.forEach(e=>{e.material=n,e.trustSourceNormals=!0}),{imageMesh:o,radiusOfSphericalMesh:s}}_flipPanoramicMeshUv(e){const t=e.vertexAttributes,a=t.uv;if(!a)return;const r=a.length/2;for(let s=0;s<r;s++)a[2*s]=C-a[2*s];e.vertexAttributes=t}_rotatePanoramicMeshToHorizon(e,t){if(!t)return;const[a,r,s]=t;e.rotate(-a,-r,s,{origin:e.extent.center})}async _createDefaultGraphic(t){const{texture:r,textureUrl:s}=t;if(!r&&!s)throw new Error("Missing texture URL or texture data.");if(!t.imageSize)return null;const i=await this._createFootprintMesh(t.imageSize,t.view,t.areaOfInterest,{signal:t.signal});if(!i)return null;const n=i.vertexAttributes.position,o=[];for(let e=0;e<n.length;e+=3)o.push(...S);i.vertexAttributes.color=new Uint8Array(o);const h=new c({colorTexture:r??new u({url:s})});return i.components?.forEach(e=>{e.shading="source",e.material=h}),new e({geometry:i,symbol:new m({symbolLayers:new a([new l({})])})})}}export{N as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{createTask as t}from"../../../core/asyncUtils.js";import r from"../../../core/Error.js";import{LRUCache as e}from"../../../core/LRUCache.js";import{abortMaybe as i}from"../../../core/maybe.js";import{createPanoramicMedia as o,createNonPanoramicMedia as a}from"../utils.js";import s from"./resolveMediaProps.js";class n{constructor(t){this._cache=new e(t?.maxEntries??20,t=>t?.destroy&&t.destroy()),this._inFlight=new Map}destroy(){this._cache.destroy(),this._inFlight.forEach(t=>t?.abort&&t.abort()),this._inFlight.clear()}enqueueDirectionalPrefetch(t,r,e=5){if(!r)return;const i=["towards","right","backwards","left"];for(const o of i){const i=c(r,o,e);for(const r of i)this.startPrefetchForNode(r,t)}}enqueueSequentialPrefetch(t,r,e=5){if(!r)return;let i=r.next,o=r.previous;for(let a=0;a<e;a++)i&&(this.startPrefetchForNode(i,t),i=i.next),o&&(this.startPrefetchForNode(o,t),o=o.previous)}clear(){this._cache.clear(),this._inFlight.forEach(i),this._inFlight.clear()}getCachedMedia(t){return this._cache.get(`${t}`)}async startPrefetchForNode(e,i){const n=e.id;if(!n)return;const c=`${n}`;if(this._cache.get(c))return;const h=this._inFlight.get(c);if(h){try{await h.promise}catch(f){}return}const l=t(async t=>{const n=await s(e.attributes,i,{signal:t}).catch(()=>null);if(!n||n.getDataSetFormatError)throw new r("NoMediaPropsError","Could not resolve media properties for prefetching");const{mediaUrl:h,datasetFormat:l,rotation:u,searchParams:m,mode:d,cameraHeading:g,matrix:p}=n;let F=null;F="panoramic"===d||360===e.attributes.horizontalFieldOfView?o({url:h,extension:l,matrix:p,cameraHeading:g}):a({url:h,rotation:u,customParameters:m,datasetFormat:l});try{await F.load({signal:t}),this._cache.put(c,F)}catch(f){F.destroy(),F=null}return F});this._inFlight.set(c,l);try{await l.promise}finally{this._inFlight.delete(c)}}}function c(t,e,i=5){if(!t)throw new r("MissingArgumentError"," start node is required");const o=[];let a=t,s=0;for(;a&&s<i;){const t=a[e];if(!t)break;o.push(t),a=t,s+=1}return o}export{n as default};
2
+ import{createTask as t}from"../../../core/asyncUtils.js";import r from"../../../core/Error.js";import{LRUCache as e}from"../../../core/LRUCache.js";import{abortMaybe as i}from"../../../core/maybe.js";import{createPanoramicMedia as o,createNonPanoramicMedia as a}from"../utils.js";import s from"./resolveMediaProps.js";class c{constructor(t){this._cache=new e(t?.maxEntries??20,t=>t?.destroy&&t.destroy()),this._inFlight=new Map}destroy(){this._cache.destroy(),this._inFlight.forEach(t=>t?.abort&&t.abort()),this._inFlight.clear()}enqueueDirectionalPrefetch(t,r,e=5){if(!r)return;const i=["towards","right","backwards","left"];for(const o of i){const i=n(r,o,e);for(const r of i)this.startPrefetchForNode(r,t).catch(()=>{})}}enqueueSequentialPrefetch(t,r,e=5){if(!r)return;let i=r.next,o=r.previous;for(let a=0;a<e;a++)i&&(this.startPrefetchForNode(i,t).catch(()=>{}),i=i.next),o&&(this.startPrefetchForNode(o,t).catch(()=>{}),o=o.previous)}clear(){this._cache.clear(),this._inFlight.forEach(i),this._inFlight.clear()}getCachedMedia(t){return this._cache.get(`${t}`)}async startPrefetchForNode(e,i){const c=e.id;if(!c)return;const n=`${c}`;if(this._cache.get(n))return;const h=this._inFlight.get(n);if(h){try{await h.promise}catch(f){}return}const l=t(async t=>{const c=await s(e.attributes,i,{signal:t}).catch(()=>null);if(!c||c.getDataSetFormatError)throw new r("NoMediaPropsError","Could not resolve media properties for prefetching");const{mediaUrl:h,datasetFormat:l,rotation:u,searchParams:m,mode:d,cameraHeading:g,matrix:p}=c;let F=null;F="panoramic"===d||360===e.attributes.horizontalFieldOfView?o({url:h,extension:l,matrix:p,cameraHeading:g}):a({url:h,rotation:u,customParameters:m,datasetFormat:l});try{await F.load({signal:t}),this._cache.put(n,F)}catch(f){F.destroy(),F=null}return F});this._inFlight.set(n,l);try{await l.promise}finally{this._inFlight.delete(n)}}}function n(t,e,i=5){if(!t)throw new r("MissingArgumentError"," start node is required");const o=[];let a=t,s=0;for(;a&&s<i;){const t=a[e];if(!t)break;o.push(t),a=t,s+=1}return o}export{c as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/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{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};
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).catch(()=>{}))},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};
@@ -9,7 +9,6 @@ export interface PopupViewModelProperties extends FeaturesViewModelProperties {}
9
9
  * by providing users with a simple way to interact with and view attributes in a layer.
10
10
  * They play an important role in relaying information to the user, which improves the storytelling capabilities of the application.
11
11
  *
12
- * @deprecated since 5.1. Use the [Popup component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-popup/) or the [Features](https://developers.arcgis.com/javascript/latest/references/core/popup/Features/) class instead.
13
12
  * @since 4.0
14
13
  * @see [Popup](https://developers.arcgis.com/javascript/latest/references/core/widgets/Popup/) widget - _Deprecated since 5.0. Use the [Popup component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-popup/) instead._
15
14
  * @see [PopupTemplate](https://developers.arcgis.com/javascript/latest/references/core/PopupTemplate/)
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{deprecatedModule as r}from"../../core/deprecate.js";import o from"../../core/Logger.js";import{subclass as s}from"../../core/accessorSupport/decorators.js";import p from"../Features/FeaturesViewModel.js";let t=class extends p{constructor(e){super({...e,suppressDeprecationWarning:!0}),e?.suppressDeprecationWarning||r(o.getLogger(this),"esri.widgets.Popup.PopupViewModel",{version:"5.1",replacement:"Use the Popup component or the @arcgis/core/popup/Features module instead.",warnOnce:!0})}};t=e([s("esri.widgets.Popup.PopupViewModel")],t);export{t as default};
2
+ import{__decorate as e}from"tslib";import{subclass as o}from"../../core/accessorSupport/decorators.js";import r from"../Features/FeaturesViewModel.js";let s=class extends r{constructor(e){super(e)}};s=e([o("esri.widgets.Popup.PopupViewModel")],s);export{s as default};
package/widgets/Popup.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../core/Logger.js";import{watch as i,initial as o,on as s}from"../core/reactiveUtils.js";import{stripHTML as n}from"../core/string.js";import{property as r,subclass as l}from"../core/accessorSupport/decorators.js";import a from"../geometry/Point.js";import d from"../support/actions/ActionButton.js";import c from"./Features.js";import u from"./Widget.js";import h from"./Features/FeaturesViewModel.js";import{ActionsCollection as p}from"./Popup/actions.js";import{css as g}from"./Popup/css.js";import v from"./Popup/PopupViewModel.js";import m from"./Popup/PopupVisibleElements.js";import{loadCalciteComponents as f}from"./support/componentsUtils.js";import{globalCss as w}from"./support/globalCss.js";import{tsx as _,messageBundle as b,vmEvent as M}from"./support/widget.js";import{isRTL as k}from"./support/widgetUtils.js";const y={buttonEnabled:!0,position:"auto",breakpoint:{width:544}};let E=class extends u{constructor(e,t){super(e,t),this._dockAction=new d({id:"popup-dock-action"}),this._featuresWidget=new c({responsiveActionsEnabled:!0,suppressDeprecationWarning:!0}),this._containerNode=null,this._mainContainerNode=null,this._focusTrapNode=null,this._toggleFocusTrapFrameId=null,this._pointerOffsetInPx=16,this.alignment="auto",this.dockEnabled=!1,this.headingLevel=2,this.messages=null,this.shouldFocus=!1,this.viewModel=new v({suppressDeprecationWarning:!0}),this.visibleElements=new m}loadDependencies(){return f({"focus-trap":()=>import("@esri/calcite-components/dist/components/calcite-focus-trap")})}initialize(){this.addHandles([i(()=>[this.viewModel?.active,this.shouldFocus,this._focusTrapNode],()=>this._toggleFocusTrap()),i(()=>[this.viewModel?.view?.widthBreakpoint,this.dockEnabled],()=>this._handleDockIcon(),o),i(()=>[this.dockEnabled,this.messages?.undock,this.messages?.dock],()=>this._handleDockEnabled(),o),i(()=>this.dockOptions,e=>{const{_dockAction:t}=this,i=this._featuresWidget.headerActions;i.remove(t),e.buttonEnabled&&i.add(t)},o),i(()=>this.viewModel?.screenLocation,()=>this._positionContainer()),i(()=>[this.viewModel?.active,this.dockEnabled],()=>this._toggleScreenLocationEnabled()),i(()=>[this.viewModel?.screenLocation,this.viewModel?.view?.padding,this.viewModel?.view?.size,this.viewModel?.active,this.viewModel?.location,this.alignment],()=>this.reposition()),i(()=>this.viewModel?.view?.size,(e,t)=>this._updateDockEnabledForViewSize(e,t)),i(()=>this.viewModel?.view,(e,t)=>this._viewChange(e,t)),i(()=>this.viewModel?.view?.ready,(e,t)=>this._viewReadyChange(e??!1,t??!1)),i(()=>this.viewModel,()=>this._featuresWidget.viewModel=this.viewModel,o),i(()=>this._featureNavigationTop,e=>this._featuresWidget.featureNavigationTop=e,o),i(()=>this.headingLevel,e=>this._featuresWidget.headingLevel=e,o),i(()=>this.visibleElements.actionBar,e=>this._featuresWidget.visibleElements.actionBar=!!e,o),i(()=>this.visibleElements.closeButton,e=>this._featuresWidget.visibleElements.closeButton=!!e,o),i(()=>this.visibleElements.collapseButton,e=>this._featuresWidget.visibleElements.collapseButton=!!e,o),i(()=>this.visibleElements.heading,e=>this._featuresWidget.visibleElements.heading=!!e,o),i(()=>this.visibleElements.spinner,e=>this._featuresWidget.visibleElements.spinner=!!e,o),i(()=>this.visibleElements.featureNavigation,e=>this._featuresWidget.visibleElements.featureNavigation=!!e,o),i(()=>this.visibleElements.featureMenuHeading,e=>this._featuresWidget.visibleElements.featureMenuHeading=!!e,o),i(()=>this.visibleElements.featureListLayerTitle,e=>this._featuresWidget.visibleElements.featureListLayerTitle=!!e,o),s(()=>this._featuresWidget,"trigger-header-action",e=>{e.action===this._dockAction&&(this.dockEnabled=!this.dockEnabled)})])}destroy(){this._cancelToggleFocusTrapFrame(),this._dockAction.destroy(),this._featuresWidget&&(this._featuresWidget.viewModel=new h({suppressDeprecationWarning:!0}),this._featuresWidget.destroy())}get _featureNavigationTop(){const{currentAlignment:e,currentDockPosition:t}=this;return"bottom-left"===e||"bottom-center"===e||"bottom-right"===e||"top-left"===t||"top-center"===t||"top-right"===t}get actions(){return this.viewModel.actions}set actions(e){this.viewModel.actions=e}get active(){return this.viewModel.active}get autoCloseEnabled(){return this.viewModel.autoCloseEnabled}set autoCloseEnabled(e){this.viewModel.autoCloseEnabled=e}get defaultPopupTemplateEnabled(){return this.viewModel.defaultPopupTemplateEnabled}set defaultPopupTemplateEnabled(e){this.viewModel.defaultPopupTemplateEnabled=e}get content(){return this.viewModel.content}set content(e){this.viewModel.content=e}get collapsed(){return this._featuresWidget.collapsed}set collapsed(e){this._featuresWidget.collapsed=e}get currentAlignment(){return this._getCurrentAlignment()}get currentDockPosition(){return this._getCurrentDockPosition()}get dockOptions(){return this._get("dockOptions")||y}set dockOptions(e){const t={...y},i=this.viewModel?.view?.breakpoints,o={};i&&(o.width=i.xsmall,o.height=i.xsmall);const s={...t,...e},n={...t.breakpoint,...o},{breakpoint:r}=s;"object"==typeof r?s.breakpoint={...n,...r}:r&&(s.breakpoint=n),this._set("dockOptions",s),this._setCurrentDockPosition(),this.reposition()}get featureCount(){return this.viewModel.featureCount}get featureMenuOpen(){return this.viewModel.featureMenuOpen}set featureMenuOpen(e){this.viewModel.featureMenuOpen=e}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get highlightEnabled(){return this.viewModel.highlightEnabled}set highlightEnabled(e){this.viewModel.highlightEnabled=e}get icon(){return"popup"}set icon(e){this._overrideIfSome("icon",e)}get initialDisplayMode(){return this.viewModel.initialDisplayMode}set initialDisplayMode(e){this.viewModel.initialDisplayMode=e}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get promises(){return this.viewModel.promises}set promises(e){this.viewModel.promises=e}get selectedFeature(){return this.viewModel.selectedFeature}get selectedDrillInFeature(){return this._featuresWidget.selectedDrillInFeature??null}get selectedFeatureIndex(){return this.viewModel.selectedFeatureIndex}set selectedFeatureIndex(e){this.viewModel.selectedFeatureIndex=e}get selectedFeatureWidget(){return this._featuresWidget.selectedFeatureWidget}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}get updateLocationEnabled(){return this.viewModel.updateLocationEnabled}set updateLocationEnabled(e){this.viewModel.updateLocationEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}blur(){const{active:e}=this.viewModel;e||t.getLogger(this).warn("Popup can only be blurred when currently active."),this._featuresWidget.blur()}clear(){return this.viewModel.clear()}close(){this.visible=!1}fetchFeatures(e,t){return this.viewModel.fetchFeatures(e,t)}focus(){const{active:e}=this.viewModel;e||t.getLogger(this).warn("Popup can only be focused when currently active."),this._focusTrapNode?.setFocus()}next(){return this.viewModel.next()}open(e){const t=e?.featureMenuOpen??!1,i=e?.collapsed??!1,o=e?.shouldFocus??!1,s={collapsed:i,featureMenuOpen:t,shouldFocus:o};this.set(s),this.viewModel.open(e),o&&this._toggleFocusTrap()}previous(){return this.viewModel.previous()}reposition(){this.renderNow(),this._positionContainer(),this._setCurrentAlignment()}triggerAction(e){return this.viewModel.triggerAction(e)}render(){const{dockEnabled:e,currentAlignment:t,currentDockPosition:i}=this,{active:o,screenLocation:s}=this.viewModel,r=o&&e,l=o&&!e,a=this.selectedFeature?.layer?.title,d=this.selectedFeature?.layer?.id,c={[g.alignTopCenter]:"top-center"===t,[g.alignBottomCenter]:"bottom-center"===t,[g.alignTopLeft]:"top-left"===t,[g.alignBottomLeft]:"bottom-left"===t,[g.alignTopRight]:"top-right"===t,[g.alignBottomRight]:"bottom-right"===t,[g.isDocked]:r,[g.shadow]:l,[g.isDockedTopLeft]:"top-left"===i,[g.isDockedTopCenter]:"top-center"===i,[g.isDockedTopRight]:"top-right"===i,[g.isDockedBottomLeft]:"bottom-left"===i,[g.isDockedBottomCenter]:"bottom-center"===i,[g.isDockedBottomRight]:"bottom-right"===i};return _("div",{afterCreate:this._positionContainer,afterUpdate:this._positionContainer,"aria-hidden":(!o).toString(),"aria-label":n(this.title??""),"aria-modal":"false",bind:this,class:this.classes(g.base,c,{[g.baseHidden]:!s&&!e}),"data-layer-id":d,"data-layer-title":a,role:"dialog"},o?[this._renderMainContainer(),this._renderPointer()]:null)}_renderPointer(){return this.dockEnabled?null:_("div",{class:g.pointer,key:"popup-pointer",role:"presentation"},_("div",{class:this.classes(g.pointerDirection,g.shadow)}))}_renderMainContainer(){const{dockEnabled:e}=this,t={[g.shadow]:e};return _("div",{afterCreate:this._setMainContainerNode,afterUpdate:this._setMainContainerNode,bind:this,class:this.classes(g.main,w.widget,t)},_("calcite-focus-trap",{afterCreate:this._setFocusTrapNode,afterUpdate:this._setFocusTrapNode,bind:this},this._featuresWidget.render()))}_toggleFocusTrap(){this._cancelToggleFocusTrapFrame(),this._toggleFocusTrapFrameId=requestAnimationFrame(()=>{if(this._toggleFocusTrapFrameId=null,this.active&&this.shouldFocus){const e=this._focusTrapNode;if(!e)return;e.activate(),e.setFocus?.()}else this._focusTrapNode?.deactivate(),this.active||(this._focusTrapNode=null)})}_cancelToggleFocusTrapFrame(){null!==this._toggleFocusTrapFrameId&&(cancelAnimationFrame(this._toggleFocusTrapFrameId),this._toggleFocusTrapFrameId=null)}_isOutsideView(e){const{popupHeight:t,popupWidth:i,screenLocation:o,side:s,view:n}=e;if(isNaN(i)||isNaN(t)||!n||!o)return!1;const r=n.padding;return"right"===s&&o.x+i/2>n.width-r.right||("left"===s&&o.x-i/2<r.left||("top"===s&&o.y-t<r.top||"bottom"===s&&o.y+t>n.height-r.bottom))}_calculateAutoAlignment(e){if("auto"!==e)return e;const{_pointerOffsetInPx:t,_containerNode:i,_mainContainerNode:o,viewModel:s}=this,{screenLocation:n,view:r}=s;if(null==n||!r||!i)return"top-center";function l(e){return parseInt(e.replaceAll(/[^-\d.]/g,""),10)}const a=o?window.getComputedStyle(o,null):null,d=a?l(a.getPropertyValue("max-height")):0,c=a?l(a.getPropertyValue("height")):0,{height:u,width:h}=i.getBoundingClientRect(),p=h+t,g=Math.max(u,d,c)+t,v=this._isOutsideView({popupHeight:g,popupWidth:p,screenLocation:n,side:"right",view:r}),m=this._isOutsideView({popupHeight:g,popupWidth:p,screenLocation:n,side:"left",view:r}),f=this._isOutsideView({popupHeight:g,popupWidth:p,screenLocation:n,side:"top",view:r}),w=this._isOutsideView({popupHeight:g,popupWidth:p,screenLocation:n,side:"bottom",view:r});return m?f?"bottom-right":"top-right":v?f?"bottom-left":"top-left":f?w?"top-center":"bottom-center":"top-center"}_callCurrentAlignment(e){return"function"==typeof e?e.call(this):e}_getCurrentAlignment(){const{alignment:e,dockEnabled:t,_containerNode:i}=this;return!t&&this.viewModel.active&&i?this._calculatePositionResult(this._calculateAutoAlignment(this._callCurrentAlignment(e))):null}_setCurrentAlignment(){this._set("currentAlignment",this._getCurrentAlignment())}_setCurrentDockPosition(){this._set("currentDockPosition",this._getCurrentDockPosition())}_calculatePositionResult(e){const t=["left","right"];return k(this.container)&&t.reverse(),e?.replaceAll(/leading/gi,t[0]).replaceAll(/trailing/gi,t[1])}_callDockPosition(e){return"function"==typeof e?e.call(this):e}_getDockPosition(){return this._calculatePositionResult(this._calculateAutoDockPosition(this._callDockPosition(this.dockOptions?.position)))}_getCurrentDockPosition(){return this.dockEnabled&&this.viewModel.active?this._getDockPosition():null}_calculateAutoDockPosition(e){if("auto"!==e)return e;const t=this.viewModel?.view,i=k(this.container)?"top-left":"top-right";if(!t)return i;const o=t.padding||{left:0,right:0},s=t.width-o.left-o.right,{breakpoints:n}=t;return n&&s<=n.xsmall?"bottom-center":i}_getDockIcon(){const e=this._getDockPosition();if(this.dockEnabled)return"minimize";switch(e){case"top-left":case"bottom-left":return"dock-left";case"top-center":return"maximize";case"bottom-center":return"dock-bottom";default:return"dock-right"}}_handleDockIcon(){this._dockAction.icon=this._getDockIcon()}_handleDockEnabled(){this._dockAction.title=this.dockEnabled?this.messages?.undock:this.messages?.dock}_setMainContainerNode(e){this._mainContainerNode=e}_setFocusTrapNode(e){this._focusTrapNode!==e&&(this._focusTrapNode=e,this.active&&this.shouldFocus&&this._toggleFocusTrap())}_positionContainer(e=this._containerNode){if(e&&(this._containerNode=e),!this._containerNode)return;const{screenLocation:t}=this.viewModel,{width:i}=this._containerNode.getBoundingClientRect(),o=this._calculatePositionStyle(t,i);o&&Object.assign(this._containerNode.style,o)}_calculateFullWidth(e){const{currentAlignment:t,_pointerOffsetInPx:i}=this;return"top-left"===t||"bottom-left"===t||"top-right"===t||"bottom-right"===t?e+i:e}_calculateAlignmentPosition(e,t,i,o){const{currentAlignment:s,_pointerOffsetInPx:n}=this;if(!i)return;const{padding:r}=i,l=o/2,a=i.height-t,d=i.width-e;return"bottom-center"===s?{top:t+n-r.top,left:e-l-r.left}:"top-left"===s?{bottom:a+n-r.bottom,right:d+n-r.right}:"bottom-left"===s?{top:t+n-r.top,right:d+n-r.right}:"top-right"===s?{bottom:a+n-r.bottom,left:e+n-r.left}:"bottom-right"===s?{top:t+n-r.top,left:e+n-r.left}:"top-center"===s?{bottom:a+n-r.bottom,left:e-l-r.left}:void 0}_calculatePositionStyle(e,t){const{dockEnabled:i,view:o}=this;if(!o)return;if(i)return{left:"",top:"",right:"",bottom:""};if(null==e||!t)return;const s=this._calculateFullWidth(t),n=this._calculateAlignmentPosition(e.x,e.y,o,s);return n?{top:void 0!==n.top?`${n.top}px`:"auto",left:void 0!==n.left?`${n.left}px`:"auto",bottom:void 0!==n.bottom?`${n.bottom}px`:"auto",right:void 0!==n.right?`${n.right}px`:"auto"}:void 0}_viewChange(e,t){e&&t&&(this.close(),this.clear())}_viewReadyChange(e,t){e?this._wireUpView():t&&(this.close(),this.clear())}_wireUpView(){this._setDockEnabledForViewSize(this.dockOptions)}_dockingThresholdCrossed(e,t,i){const[o,s]=e,[n,r]=t,{width:l=0,height:a=0}=i??{};return o<=l&&n>l||o>l&&n<=l||s<=a&&r>a||s>a&&r<=a}_updateDockEnabledForViewSize(e,t){if(!e||!t)return;const i=this.viewModel?.view?.padding||{left:0,right:0,top:0,bottom:0},o=i.left+i.right,s=i.top+i.bottom,n=[],r=[];n[0]=e[0]-o,n[1]=e[1]-s,r[0]=t[0]-o,r[1]=t[1]-s;const{dockOptions:l}=this,a=l.breakpoint;this._dockingThresholdCrossed(n,r,a)&&this._setDockEnabledForViewSize(l),this._setCurrentDockPosition()}_toggleScreenLocationEnabled(){const{dockEnabled:e,viewModel:t}=this;if(!t)return;const i=t.active&&!e;t.screenLocationEnabled=i}_shouldDockAtCurrentViewSize(e){const t=e.breakpoint,i=this.viewModel?.view?.ui;if(!i)return!1;const{width:o,height:s}=i;if(isNaN(o)||isNaN(s))return!1;if(!t)return!1;const n=t.hasOwnProperty("width")&&o<=(t.width??0),r=t.hasOwnProperty("height")&&s<=(t.height??0);return n||r}_setDockEnabledForViewSize(e){e.breakpoint&&(this.dockEnabled=this._shouldDockAtCurrentViewSize(e))}};e([r()],E.prototype,"_containerNode",void 0),e([r()],E.prototype,"_focusTrapNode",void 0),e([r({readOnly:!0})],E.prototype,"_featureNavigationTop",null),e([r({type:p})],E.prototype,"actions",null),e([r({readOnly:!0})],E.prototype,"active",null),e([r()],E.prototype,"alignment",void 0),e([r()],E.prototype,"autoCloseEnabled",null),e([r()],E.prototype,"defaultPopupTemplateEnabled",null),e([r()],E.prototype,"content",null),e([r()],E.prototype,"collapsed",null),e([r({readOnly:!0})],E.prototype,"currentAlignment",null),e([r({readOnly:!0})],E.prototype,"currentDockPosition",null),e([r()],E.prototype,"dockOptions",null),e([r()],E.prototype,"dockEnabled",void 0),e([r({readOnly:!0})],E.prototype,"featureCount",null),e([r()],E.prototype,"featureMenuOpen",null),e([r()],E.prototype,"features",null),e([r()],E.prototype,"goToOverride",null),e([r()],E.prototype,"headingLevel",void 0),e([r()],E.prototype,"highlightEnabled",null),e([r()],E.prototype,"icon",null),e([r()],E.prototype,"initialDisplayMode",null),e([r({type:a})],E.prototype,"location",null),e([r()],E.prototype,"label",null),e([r(),b("esri/widgets/Popup/t9n/Popup")],E.prototype,"messages",void 0),e([r()],E.prototype,"promises",null),e([r({readOnly:!0})],E.prototype,"selectedFeature",null),e([r({readOnly:!0})],E.prototype,"selectedDrillInFeature",null),e([r()],E.prototype,"selectedFeatureIndex",null),e([r({readOnly:!0})],E.prototype,"selectedFeatureWidget",null),e([r()],E.prototype,"shouldFocus",void 0),e([r()],E.prototype,"title",null),e([r()],E.prototype,"updateLocationEnabled",null),e([r()],E.prototype,"view",null),e([r({type:v}),M(["triggerAction","trigger-action"])],E.prototype,"viewModel",void 0),e([r()],E.prototype,"visible",null),e([r({type:m,nonNullable:!0})],E.prototype,"visibleElements",void 0),E=e([l("esri.widgets.Popup")],E);const F=E;export{F as default};
2
+ import{__decorate as e}from"tslib";import t from"../core/Logger.js";import{watch as i,initial as o,on as s}from"../core/reactiveUtils.js";import{stripHTML as n}from"../core/string.js";import{property as r,subclass as l}from"../core/accessorSupport/decorators.js";import a from"../geometry/Point.js";import d from"../support/actions/ActionButton.js";import c from"./Features.js";import u from"./Widget.js";import h from"./Features/FeaturesViewModel.js";import{ActionsCollection as p}from"./Popup/actions.js";import{css as g}from"./Popup/css.js";import v from"./Popup/PopupViewModel.js";import m from"./Popup/PopupVisibleElements.js";import{loadCalciteComponents as f}from"./support/componentsUtils.js";import{globalCss as w}from"./support/globalCss.js";import{tsx as _,messageBundle as b,vmEvent as M}from"./support/widget.js";import{isRTL as k}from"./support/widgetUtils.js";const y={buttonEnabled:!0,position:"auto",breakpoint:{width:544}};let E=class extends u{constructor(e,t){super(e,t),this._dockAction=new d({id:"popup-dock-action"}),this._featuresWidget=new c({responsiveActionsEnabled:!0,suppressDeprecationWarning:!0}),this._containerNode=null,this._mainContainerNode=null,this._focusTrapNode=null,this._toggleFocusTrapFrameId=null,this._pointerOffsetInPx=16,this.alignment="auto",this.dockEnabled=!1,this.headingLevel=2,this.messages=null,this.shouldFocus=!1,this.viewModel=new v,this.visibleElements=new m}loadDependencies(){return f({"focus-trap":()=>import("@esri/calcite-components/dist/components/calcite-focus-trap")})}initialize(){this.addHandles([i(()=>[this.viewModel?.active,this.shouldFocus,this._focusTrapNode],()=>this._toggleFocusTrap()),i(()=>[this.viewModel?.view?.widthBreakpoint,this.dockEnabled],()=>this._handleDockIcon(),o),i(()=>[this.dockEnabled,this.messages?.undock,this.messages?.dock],()=>this._handleDockEnabled(),o),i(()=>this.dockOptions,e=>{const{_dockAction:t}=this,i=this._featuresWidget.headerActions;i.remove(t),e.buttonEnabled&&i.add(t)},o),i(()=>this.viewModel?.screenLocation,()=>this._positionContainer()),i(()=>[this.viewModel?.active,this.dockEnabled],()=>this._toggleScreenLocationEnabled()),i(()=>[this.viewModel?.screenLocation,this.viewModel?.view?.padding,this.viewModel?.view?.size,this.viewModel?.active,this.viewModel?.location,this.alignment],()=>this.reposition()),i(()=>this.viewModel?.view?.size,(e,t)=>this._updateDockEnabledForViewSize(e,t)),i(()=>this.viewModel?.view,(e,t)=>this._viewChange(e,t)),i(()=>this.viewModel?.view?.ready,(e,t)=>this._viewReadyChange(e??!1,t??!1)),i(()=>this.viewModel,()=>this._featuresWidget.viewModel=this.viewModel,o),i(()=>this._featureNavigationTop,e=>this._featuresWidget.featureNavigationTop=e,o),i(()=>this.headingLevel,e=>this._featuresWidget.headingLevel=e,o),i(()=>this.visibleElements.actionBar,e=>this._featuresWidget.visibleElements.actionBar=!!e,o),i(()=>this.visibleElements.closeButton,e=>this._featuresWidget.visibleElements.closeButton=!!e,o),i(()=>this.visibleElements.collapseButton,e=>this._featuresWidget.visibleElements.collapseButton=!!e,o),i(()=>this.visibleElements.heading,e=>this._featuresWidget.visibleElements.heading=!!e,o),i(()=>this.visibleElements.spinner,e=>this._featuresWidget.visibleElements.spinner=!!e,o),i(()=>this.visibleElements.featureNavigation,e=>this._featuresWidget.visibleElements.featureNavigation=!!e,o),i(()=>this.visibleElements.featureMenuHeading,e=>this._featuresWidget.visibleElements.featureMenuHeading=!!e,o),i(()=>this.visibleElements.featureListLayerTitle,e=>this._featuresWidget.visibleElements.featureListLayerTitle=!!e,o),s(()=>this._featuresWidget,"trigger-header-action",e=>{e.action===this._dockAction&&(this.dockEnabled=!this.dockEnabled)})])}destroy(){this._cancelToggleFocusTrapFrame(),this._dockAction.destroy(),this._featuresWidget&&(this._featuresWidget.viewModel=new h,this._featuresWidget.destroy())}get _featureNavigationTop(){const{currentAlignment:e,currentDockPosition:t}=this;return"bottom-left"===e||"bottom-center"===e||"bottom-right"===e||"top-left"===t||"top-center"===t||"top-right"===t}get actions(){return this.viewModel.actions}set actions(e){this.viewModel.actions=e}get active(){return this.viewModel.active}get autoCloseEnabled(){return this.viewModel.autoCloseEnabled}set autoCloseEnabled(e){this.viewModel.autoCloseEnabled=e}get defaultPopupTemplateEnabled(){return this.viewModel.defaultPopupTemplateEnabled}set defaultPopupTemplateEnabled(e){this.viewModel.defaultPopupTemplateEnabled=e}get content(){return this.viewModel.content}set content(e){this.viewModel.content=e}get collapsed(){return this._featuresWidget.collapsed}set collapsed(e){this._featuresWidget.collapsed=e}get currentAlignment(){return this._getCurrentAlignment()}get currentDockPosition(){return this._getCurrentDockPosition()}get dockOptions(){return this._get("dockOptions")||y}set dockOptions(e){const t={...y},i=this.viewModel?.view?.breakpoints,o={};i&&(o.width=i.xsmall,o.height=i.xsmall);const s={...t,...e},n={...t.breakpoint,...o},{breakpoint:r}=s;"object"==typeof r?s.breakpoint={...n,...r}:r&&(s.breakpoint=n),this._set("dockOptions",s),this._setCurrentDockPosition(),this.reposition()}get featureCount(){return this.viewModel.featureCount}get featureMenuOpen(){return this.viewModel.featureMenuOpen}set featureMenuOpen(e){this.viewModel.featureMenuOpen=e}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get highlightEnabled(){return this.viewModel.highlightEnabled}set highlightEnabled(e){this.viewModel.highlightEnabled=e}get icon(){return"popup"}set icon(e){this._overrideIfSome("icon",e)}get initialDisplayMode(){return this.viewModel.initialDisplayMode}set initialDisplayMode(e){this.viewModel.initialDisplayMode=e}get location(){return this.viewModel.location}set location(e){this.viewModel.location=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get promises(){return this.viewModel.promises}set promises(e){this.viewModel.promises=e}get selectedFeature(){return this.viewModel.selectedFeature}get selectedDrillInFeature(){return this._featuresWidget.selectedDrillInFeature??null}get selectedFeatureIndex(){return this.viewModel.selectedFeatureIndex}set selectedFeatureIndex(e){this.viewModel.selectedFeatureIndex=e}get selectedFeatureWidget(){return this._featuresWidget.selectedFeatureWidget}get title(){return this.viewModel.title}set title(e){this.viewModel.title=e}get updateLocationEnabled(){return this.viewModel.updateLocationEnabled}set updateLocationEnabled(e){this.viewModel.updateLocationEnabled=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}blur(){const{active:e}=this.viewModel;e||t.getLogger(this).warn("Popup can only be blurred when currently active."),this._featuresWidget.blur()}clear(){return this.viewModel.clear()}close(){this.visible=!1}fetchFeatures(e,t){return this.viewModel.fetchFeatures(e,t)}focus(){const{active:e}=this.viewModel;e||t.getLogger(this).warn("Popup can only be focused when currently active."),this._focusTrapNode?.setFocus()}next(){return this.viewModel.next()}open(e){const t=e?.featureMenuOpen??!1,i=e?.collapsed??!1,o=e?.shouldFocus??!1,s={collapsed:i,featureMenuOpen:t,shouldFocus:o};this.set(s),this.viewModel.open(e),o&&this._toggleFocusTrap()}previous(){return this.viewModel.previous()}reposition(){this.renderNow(),this._positionContainer(),this._setCurrentAlignment()}triggerAction(e){return this.viewModel.triggerAction(e)}render(){const{dockEnabled:e,currentAlignment:t,currentDockPosition:i}=this,{active:o,screenLocation:s}=this.viewModel,r=o&&e,l=o&&!e,a=this.selectedFeature?.layer?.title,d=this.selectedFeature?.layer?.id,c={[g.alignTopCenter]:"top-center"===t,[g.alignBottomCenter]:"bottom-center"===t,[g.alignTopLeft]:"top-left"===t,[g.alignBottomLeft]:"bottom-left"===t,[g.alignTopRight]:"top-right"===t,[g.alignBottomRight]:"bottom-right"===t,[g.isDocked]:r,[g.shadow]:l,[g.isDockedTopLeft]:"top-left"===i,[g.isDockedTopCenter]:"top-center"===i,[g.isDockedTopRight]:"top-right"===i,[g.isDockedBottomLeft]:"bottom-left"===i,[g.isDockedBottomCenter]:"bottom-center"===i,[g.isDockedBottomRight]:"bottom-right"===i};return _("div",{afterCreate:this._positionContainer,afterUpdate:this._positionContainer,"aria-hidden":(!o).toString(),"aria-label":n(this.title??""),"aria-modal":"false",bind:this,class:this.classes(g.base,c,{[g.baseHidden]:!s&&!e}),"data-layer-id":d,"data-layer-title":a,role:"dialog"},o?[this._renderMainContainer(),this._renderPointer()]:null)}_renderPointer(){return this.dockEnabled?null:_("div",{class:g.pointer,key:"popup-pointer",role:"presentation"},_("div",{class:this.classes(g.pointerDirection,g.shadow)}))}_renderMainContainer(){const{dockEnabled:e}=this,t={[g.shadow]:e};return _("div",{afterCreate:this._setMainContainerNode,afterUpdate:this._setMainContainerNode,bind:this,class:this.classes(g.main,w.widget,t)},_("calcite-focus-trap",{afterCreate:this._setFocusTrapNode,afterUpdate:this._setFocusTrapNode,bind:this},this._featuresWidget.render()))}_toggleFocusTrap(){this._cancelToggleFocusTrapFrame(),this._toggleFocusTrapFrameId=requestAnimationFrame(()=>{if(this._toggleFocusTrapFrameId=null,this.active&&this.shouldFocus){const e=this._focusTrapNode;if(!e)return;e.activate(),e.setFocus?.()}else this._focusTrapNode?.deactivate(),this.active||(this._focusTrapNode=null)})}_cancelToggleFocusTrapFrame(){null!==this._toggleFocusTrapFrameId&&(cancelAnimationFrame(this._toggleFocusTrapFrameId),this._toggleFocusTrapFrameId=null)}_isOutsideView(e){const{popupHeight:t,popupWidth:i,screenLocation:o,side:s,view:n}=e;if(isNaN(i)||isNaN(t)||!n||!o)return!1;const r=n.padding;return"right"===s&&o.x+i/2>n.width-r.right||("left"===s&&o.x-i/2<r.left||("top"===s&&o.y-t<r.top||"bottom"===s&&o.y+t>n.height-r.bottom))}_calculateAutoAlignment(e){if("auto"!==e)return e;const{_pointerOffsetInPx:t,_containerNode:i,_mainContainerNode:o,viewModel:s}=this,{screenLocation:n,view:r}=s;if(null==n||!r||!i)return"top-center";function l(e){return parseInt(e.replaceAll(/[^-\d.]/g,""),10)}const a=o?window.getComputedStyle(o,null):null,d=a?l(a.getPropertyValue("max-height")):0,c=a?l(a.getPropertyValue("height")):0,{height:u,width:h}=i.getBoundingClientRect(),p=h+t,g=Math.max(u,d,c)+t,v=this._isOutsideView({popupHeight:g,popupWidth:p,screenLocation:n,side:"right",view:r}),m=this._isOutsideView({popupHeight:g,popupWidth:p,screenLocation:n,side:"left",view:r}),f=this._isOutsideView({popupHeight:g,popupWidth:p,screenLocation:n,side:"top",view:r}),w=this._isOutsideView({popupHeight:g,popupWidth:p,screenLocation:n,side:"bottom",view:r});return m?f?"bottom-right":"top-right":v?f?"bottom-left":"top-left":f?w?"top-center":"bottom-center":"top-center"}_callCurrentAlignment(e){return"function"==typeof e?e.call(this):e}_getCurrentAlignment(){const{alignment:e,dockEnabled:t,_containerNode:i}=this;return!t&&this.viewModel.active&&i?this._calculatePositionResult(this._calculateAutoAlignment(this._callCurrentAlignment(e))):null}_setCurrentAlignment(){this._set("currentAlignment",this._getCurrentAlignment())}_setCurrentDockPosition(){this._set("currentDockPosition",this._getCurrentDockPosition())}_calculatePositionResult(e){const t=["left","right"];return k(this.container)&&t.reverse(),e?.replaceAll(/leading/gi,t[0]).replaceAll(/trailing/gi,t[1])}_callDockPosition(e){return"function"==typeof e?e.call(this):e}_getDockPosition(){return this._calculatePositionResult(this._calculateAutoDockPosition(this._callDockPosition(this.dockOptions?.position)))}_getCurrentDockPosition(){return this.dockEnabled&&this.viewModel.active?this._getDockPosition():null}_calculateAutoDockPosition(e){if("auto"!==e)return e;const t=this.viewModel?.view,i=k(this.container)?"top-left":"top-right";if(!t)return i;const o=t.padding||{left:0,right:0},s=t.width-o.left-o.right,{breakpoints:n}=t;return n&&s<=n.xsmall?"bottom-center":i}_getDockIcon(){const e=this._getDockPosition();if(this.dockEnabled)return"minimize";switch(e){case"top-left":case"bottom-left":return"dock-left";case"top-center":return"maximize";case"bottom-center":return"dock-bottom";default:return"dock-right"}}_handleDockIcon(){this._dockAction.icon=this._getDockIcon()}_handleDockEnabled(){this._dockAction.title=this.dockEnabled?this.messages?.undock:this.messages?.dock}_setMainContainerNode(e){this._mainContainerNode=e}_setFocusTrapNode(e){this._focusTrapNode!==e&&(this._focusTrapNode=e,this.active&&this.shouldFocus&&this._toggleFocusTrap())}_positionContainer(e=this._containerNode){if(e&&(this._containerNode=e),!this._containerNode)return;const{screenLocation:t}=this.viewModel,{width:i}=this._containerNode.getBoundingClientRect(),o=this._calculatePositionStyle(t,i);o&&Object.assign(this._containerNode.style,o)}_calculateFullWidth(e){const{currentAlignment:t,_pointerOffsetInPx:i}=this;return"top-left"===t||"bottom-left"===t||"top-right"===t||"bottom-right"===t?e+i:e}_calculateAlignmentPosition(e,t,i,o){const{currentAlignment:s,_pointerOffsetInPx:n}=this;if(!i)return;const{padding:r}=i,l=o/2,a=i.height-t,d=i.width-e;return"bottom-center"===s?{top:t+n-r.top,left:e-l-r.left}:"top-left"===s?{bottom:a+n-r.bottom,right:d+n-r.right}:"bottom-left"===s?{top:t+n-r.top,right:d+n-r.right}:"top-right"===s?{bottom:a+n-r.bottom,left:e+n-r.left}:"bottom-right"===s?{top:t+n-r.top,left:e+n-r.left}:"top-center"===s?{bottom:a+n-r.bottom,left:e-l-r.left}:void 0}_calculatePositionStyle(e,t){const{dockEnabled:i,view:o}=this;if(!o)return;if(i)return{left:"",top:"",right:"",bottom:""};if(null==e||!t)return;const s=this._calculateFullWidth(t),n=this._calculateAlignmentPosition(e.x,e.y,o,s);return n?{top:void 0!==n.top?`${n.top}px`:"auto",left:void 0!==n.left?`${n.left}px`:"auto",bottom:void 0!==n.bottom?`${n.bottom}px`:"auto",right:void 0!==n.right?`${n.right}px`:"auto"}:void 0}_viewChange(e,t){e&&t&&(this.close(),this.clear())}_viewReadyChange(e,t){e?this._wireUpView():t&&(this.close(),this.clear())}_wireUpView(){this._setDockEnabledForViewSize(this.dockOptions)}_dockingThresholdCrossed(e,t,i){const[o,s]=e,[n,r]=t,{width:l=0,height:a=0}=i??{};return o<=l&&n>l||o>l&&n<=l||s<=a&&r>a||s>a&&r<=a}_updateDockEnabledForViewSize(e,t){if(!e||!t)return;const i=this.viewModel?.view?.padding||{left:0,right:0,top:0,bottom:0},o=i.left+i.right,s=i.top+i.bottom,n=[],r=[];n[0]=e[0]-o,n[1]=e[1]-s,r[0]=t[0]-o,r[1]=t[1]-s;const{dockOptions:l}=this,a=l.breakpoint;this._dockingThresholdCrossed(n,r,a)&&this._setDockEnabledForViewSize(l),this._setCurrentDockPosition()}_toggleScreenLocationEnabled(){const{dockEnabled:e,viewModel:t}=this;if(!t)return;const i=t.active&&!e;t.screenLocationEnabled=i}_shouldDockAtCurrentViewSize(e){const t=e.breakpoint,i=this.viewModel?.view?.ui;if(!i)return!1;const{width:o,height:s}=i;if(isNaN(o)||isNaN(s))return!1;if(!t)return!1;const n=t.hasOwnProperty("width")&&o<=(t.width??0),r=t.hasOwnProperty("height")&&s<=(t.height??0);return n||r}_setDockEnabledForViewSize(e){e.breakpoint&&(this.dockEnabled=this._shouldDockAtCurrentViewSize(e))}};e([r()],E.prototype,"_containerNode",void 0),e([r()],E.prototype,"_focusTrapNode",void 0),e([r({readOnly:!0})],E.prototype,"_featureNavigationTop",null),e([r({type:p})],E.prototype,"actions",null),e([r({readOnly:!0})],E.prototype,"active",null),e([r()],E.prototype,"alignment",void 0),e([r()],E.prototype,"autoCloseEnabled",null),e([r()],E.prototype,"defaultPopupTemplateEnabled",null),e([r()],E.prototype,"content",null),e([r()],E.prototype,"collapsed",null),e([r({readOnly:!0})],E.prototype,"currentAlignment",null),e([r({readOnly:!0})],E.prototype,"currentDockPosition",null),e([r()],E.prototype,"dockOptions",null),e([r()],E.prototype,"dockEnabled",void 0),e([r({readOnly:!0})],E.prototype,"featureCount",null),e([r()],E.prototype,"featureMenuOpen",null),e([r()],E.prototype,"features",null),e([r()],E.prototype,"goToOverride",null),e([r()],E.prototype,"headingLevel",void 0),e([r()],E.prototype,"highlightEnabled",null),e([r()],E.prototype,"icon",null),e([r()],E.prototype,"initialDisplayMode",null),e([r({type:a})],E.prototype,"location",null),e([r()],E.prototype,"label",null),e([r(),b("esri/widgets/Popup/t9n/Popup")],E.prototype,"messages",void 0),e([r()],E.prototype,"promises",null),e([r({readOnly:!0})],E.prototype,"selectedFeature",null),e([r({readOnly:!0})],E.prototype,"selectedDrillInFeature",null),e([r()],E.prototype,"selectedFeatureIndex",null),e([r({readOnly:!0})],E.prototype,"selectedFeatureWidget",null),e([r()],E.prototype,"shouldFocus",void 0),e([r()],E.prototype,"title",null),e([r()],E.prototype,"updateLocationEnabled",null),e([r()],E.prototype,"view",null),e([r({type:v}),M(["triggerAction","trigger-action"])],E.prototype,"viewModel",void 0),e([r()],E.prototype,"visible",null),e([r({type:m,nonNullable:!0})],E.prototype,"visibleElements",void 0),E=e([l("esri.widgets.Popup")],E);const F=E;export{F as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/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 d,whenOnce as h}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 b}from"../../intl/date.js";import{getLocaleLanguage as x}from"../../intl/locale.js";import O from"../../portal/Portal.js";import E from"../../portal/PortalQueryParams.js";import{execute as P,getPrintCache as S,getTaskInfo as L}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 N from"./CustomTemplate.js";import W from"./FileLink.js";import R from"./TemplateOptions.js";import{fetchLayoutTemplateInfos as V,valueUnitKebabDict as z}from"./utils.js";const B=[30,144,255,255],q=[237,211,23,255],G=[216,48,32,255],J=/(\/GPServer\/).+/i,$=96,Q=i.ofType(N),K=i.ofType(W),X=new a({Feet:"feet",Miles:"miles",Meters:"meters",Kilometers:"kilometers"});function Y(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(),b("short-date"));"ar"===x()&&(i="‏"+i),e.push({date:i})}}function Z(t,e,i){const s=t.visible??!0,o=t.legendEnabled??!0;if(!s||!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)Z(p,e,i);else null!=t.id&&i.push(String(t.id))}function tt(t,e,i,s){if(!e.layoutOptions)return;if(!i)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 i of t??[])Z(i,o,e);r.push(new C({layerId:l.layer.id,title:l.layer.title||void 0,subLayerIds:t?e:void 0,dynamicLegend:s}))}e.layoutOptions.legendLayers=r}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 Q,this.datumTransformations=null,this.defaultTemplates=new Q,this.error=null,this.exportedLinks=new K,this.extraParameters=null,this.includeDefaultTemplates=!0,this.outSpatialReference=null,this.portal=O.getDefault(),this.portalTemplateIds=[],this.printServiceTemplates=new Q,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,()=>{const t={};for(const{name:e,extension:i}of this.exportedLinks){if(!e||!i)continue;const s=`${e}${i}`,o=t[s];t[s]=void 0!==o?o+1:0}this._exportedFileNameMap=t},d)])}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,datumTransformations:r}=this;if(!e)throw new s("print:view-required","view is not set");Y(t);const l=this._getOverlayItem(),n=t.scalePreserved||!this.showPrintAreaEnabled?void 0:H(new _,e.viewpoint,"map-only"===t.layout?[t.exportOptions.width,t.exportOptions.height]:[l.boxWidth,l.boxHeight]),p=new j({view:e,template:t,extent:n,extraParameters:i,updateDelay:o,outSpatialReference:a,datumTransformations:r});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,p,{timeout:this.printTimeout})}catch(m){throw new s("print:export-error","An error occurred while exporting the web map.",{error:m})}}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:d,layoutItem:h,legendEnabled:u,dynamicLegendEnabled:c,northArrowEnabled:f,scale:y,scaleBarEnabled:v,scaleBarUnit:T,scaleEnabled:w,title:_,width:I}){if(!d&&!h)throw new s("print:layout-required","layout is not set");const g={};e&&(g.authorText=e),i&&(g.copyrightText=i),o&&(g.customTextElements=o),_&&(g.titleText=_),v&&T&&(g.scalebarUnit=X.toJSON(T));const b=new M({attributionVisible:t,forceFeatureAttributes:r,format:l,includeTables:m,layout:d,layoutItem:h,layoutOptions:g,outScale:y??0,scalePreserved:w});if(I&&(b.exportOptions.width=I),n&&(b.exportOptions.height=n),a&&(b.exportOptions.dpi=a),b.layoutOptions){tt(this.view,b,u,c);const t=this.getLayoutTemplateById(p)?.mapSurroundInfoOptions;if(t){const e=t.northArrow;for(const t of e)et(b,t,f);const i=t.scaleBar;for(const t of i)et(b,t,v);const s=t.legend;for(const t of s)et(b,t,u)}}return b}getLayoutTemplateById(t){return t?this._templateIdToCustomTemplate.get(t):null}async addPortalTemplate(t){if(!this.portal||!t?.id)return;try{if("loading"===this.loadStatus&&await h(()=>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 N({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 W({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){if(!this.destroyed){if(await this._loadUrls(t),await this._loadTemplateInfos(t),this.effectivePrintServiceUrl){const e=await S(this.effectivePrintServiceUrl,t);this.cimVersion=e?.cimVersion}await 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 N({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 L(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=N.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{portal:e}=this,{layoutGroupQuery:i,sourceJSON:s}=e,{state:o,user:a}=s??{},{availableCredits:r=0,assignedCredits:l=0}=a??{},n="suspended"===o,p="active"===o&&r<=0&&l>0,m=a?.privileges?.includes("premium:user:print:customlayout");if(!i||n||p||!m)return[];const d=new E({query:i,disableExtraQuery:!0}),h=await this.portal.queryGroups(d,t);if(!h.total)return[];const u=h.results[0],c=new E({num:100,query:"type:Layout",sortField:u.sortField,sortOrder:u.sortOrder??void 0}),f=(await u.queryItems(c,t)).results;if(!f.length)return[];return f.map(t=>(this.portalTemplateIds.push(t.id),new N({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 N({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??(e?await V(e,void 0,t):[]);!i&&e&&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??(this.effectivePrintServiceUrl?await L(this.effectivePrintServiceUrl,"ExportWebMap",t):void 0);if(!i)throw new s("print:unavailable-service-info","Can't fetch templates info from service");!e&&this.effectivePrintServiceUrl&&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 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()},d),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)}async _updateOverLayItem(){if(!this.view)return;await this.view.when();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*$;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:d}=t,h=m&&d?d/this.view.scale:1;if(e.boxWidth=n*h||a,e.boxHeight=p*h||r,l&&(e.padding=l),e.backgroundWidth=a??0,e.backgroundHeight=r??0,"loading"===this.loadStatus)e.strokeColor=q;else if("loaded"===this.loadStatus)switch(this.templateOptions.state){case"pending":e.strokeColor=q;break;case"ready":e.strokeColor=B;break;case"error":e.strokeColor=G}}_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:Q})],it.prototype,"browseTemplates",void 0),t([T()],it.prototype,"cimVersion",void 0),t([T()],it.prototype,"datumTransformations",void 0),t([T({type:Q})],it.prototype,"defaultTemplates",void 0),t([T()],it.prototype,"error",void 0),t([T({type:K})],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:Q})],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 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 b}from"../../intl/date.js";import{getLocaleLanguage as x}from"../../intl/locale.js";import O from"../../portal/Portal.js";import E from"../../portal/PortalQueryParams.js";import{execute as P,getPrintCache as S,getTaskInfo as L}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 N from"./CustomTemplate.js";import W from"./FileLink.js";import R from"./TemplateOptions.js";import{fetchLayoutTemplateInfos as V,valueUnitKebabDict as z}from"./utils.js";const B=[30,144,255,255],q=[237,211,23,255],G=[216,48,32,255],J=/(\/GPServer\/).+/i,$=96,Q=i.ofType(N),K=i.ofType(W),X=new a({Feet:"feet",Miles:"miles",Meters:"meters",Kilometers:"kilometers"});function Y(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(),b("short-date"));"ar"===x()&&(i="‏"+i),e.push({date:i})}}function Z(t,e,i){const s=t.visible??!0,o=t.legendEnabled??!0;if(!s||!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)Z(p,e,i);else null!=t.id&&i.push(String(t.id))}function tt(t,e,i,s){if(!e.layoutOptions)return;if(!i)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 i of t??[])Z(i,o,e);r.push(new C({layerId:l.layer.id,title:l.layer.title||void 0,subLayerIds:t?e:void 0,dynamicLegend:s}))}e.layoutOptions.legendLayers=r}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 Q,this.datumTransformations=null,this.defaultTemplates=new Q,this.error=null,this.exportedLinks=new K,this.extraParameters=null,this.includeDefaultTemplates=!0,this.outSpatialReference=null,this.portal=O.getDefault(),this.portalTemplateIds=[],this.printServiceTemplates=new Q,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().catch(()=>{})}),m(()=>[this.allowedFormats,this.allowedLayouts],()=>{this.loaded&&this._loadTemplateInfos().catch(()=>{})}),m(()=>this.exportedLinks,()=>{const t={};for(const{name:e,extension:i}of this.exportedLinks){if(!e||!i)continue;const s=`${e}${i}`,o=t[s];t[s]=void 0!==o?o+1:0}this._exportedFileNameMap=t},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,datumTransformations:r}=this;if(!e)throw new s("print:view-required","view is not set");Y(t);const l=this._getOverlayItem(),n=t.scalePreserved||!this.showPrintAreaEnabled?void 0:H(new _,e.viewpoint,"map-only"===t.layout?[t.exportOptions.width,t.exportOptions.height]:[l.boxWidth,l.boxHeight]),p=new j({view:e,template:t,extent:n,extraParameters:i,updateDelay:o,outSpatialReference:a,datumTransformations:r});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,p,{timeout:this.printTimeout})}catch(m){throw new s("print:export-error","An error occurred while exporting the web map.",{error:m})}}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={};e&&(g.authorText=e),i&&(g.copyrightText=i),o&&(g.customTextElements=o),_&&(g.titleText=_),v&&T&&(g.scalebarUnit=X.toJSON(T));const b=new M({attributionVisible:t,forceFeatureAttributes:r,format:l,includeTables:m,layout:h,layoutItem:d,layoutOptions:g,outScale:y??0,scalePreserved:w});if(I&&(b.exportOptions.width=I),n&&(b.exportOptions.height=n),a&&(b.exportOptions.dpi=a),b.layoutOptions){tt(this.view,b,u,c);const t=this.getLayoutTemplateById(p)?.mapSurroundInfoOptions;if(t){const e=t.northArrow;for(const t of e)et(b,t,f);const i=t.scaleBar;for(const t of i)et(b,t,v);const s=t.legend;for(const t of s)et(b,t,u)}}return b}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 N({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 W({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){if(!this.destroyed){if(await this._loadUrls(t),await this._loadTemplateInfos(t),this.effectivePrintServiceUrl){const e=await S(this.effectivePrintServiceUrl,t);this.cimVersion=e?.cimVersion}await 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 N({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 L(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=N.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{portal:e}=this,{layoutGroupQuery:i,sourceJSON:s}=e,{state:o,user:a}=s??{},{availableCredits:r=0,assignedCredits:l=0}=a??{},n="suspended"===o,p="active"===o&&r<=0&&l>0,m=a?.privileges?.includes("premium:user:print:customlayout");if(!i||n||p||!m)return[];const h=new E({query:i,disableExtraQuery:!0}),d=await this.portal.queryGroups(h,t);if(!d.total)return[];const u=d.results[0],c=new E({num:100,query:"type:Layout",sortField:u.sortField,sortOrder:u.sortOrder??void 0}),f=(await u.queryItems(c,t)).results;if(!f.length)return[];return f.map(t=>(this.portalTemplateIds.push(t.id),new N({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 N({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??(e?await V(e,void 0,t):[]);!i&&e&&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??(this.effectivePrintServiceUrl?await L(this.effectivePrintServiceUrl,"ExportWebMap",t):void 0);if(!i)throw new s("print:unavailable-service-info","Can't fetch templates info from service");!e&&this.effectivePrintServiceUrl&&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 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)}async _updateOverLayItem(){if(!this.view)return;await this.view.when();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*$;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=q;else if("loaded"===this.loadStatus)switch(this.templateOptions.state){case"pending":e.strokeColor=q;break;case"ready":e.strokeColor=B;break;case"error":e.strokeColor=G}}_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:Q})],it.prototype,"browseTemplates",void 0),t([T()],it.prototype,"cimVersion",void 0),t([T()],it.prototype,"datumTransformations",void 0),t([T({type:Q})],it.prototype,"defaultTemplates",void 0),t([T()],it.prototype,"error",void 0),t([T({type:K})],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:Q})],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};