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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (365) hide show
  1. package/applications/KnowledgeStudio/resourceSerializationUtils.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{8f56f298e7c1a283f407.js → 0030d68d9edf42b4af57.js} +1 -1
  4. package/assets/esri/core/workers/chunks/01d460398f3ba6767a37.js +1 -0
  5. package/assets/esri/core/workers/chunks/02e7359162cf974b41b6.js +1 -0
  6. package/assets/esri/core/workers/chunks/{17d5f8dba6ebb1184506.js → 042cd64e1f4eb326c30f.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{66db5f77e09d25e33951.js → 063905fbf9a0c6586949.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{9486032af3e934d85582.js → 0a5d74414dd02a2fb8e1.js} +1 -1
  9. package/assets/esri/core/workers/chunks/{3815ffa13e7b439bca6e.js → 0d5212f59e9b62c16164.js} +1 -1
  10. package/assets/esri/core/workers/chunks/0f735b0dec173142f3b6.js +2 -0
  11. package/assets/esri/core/workers/chunks/{a8f998b8ec8c56150479.js.LICENSE.txt → 0f735b0dec173142f3b6.js.LICENSE.txt} +1 -1
  12. package/assets/esri/core/workers/chunks/{73487b9d85e726e9c012.js → 1257c37bf04d39c27b62.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{398f356b11fd33bd3831.js → 136a7d781dad05a7463b.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{1e4e7aedf4b779241a02.js → 15c7c10ff9ac63f0e792.js} +1 -1
  15. package/assets/esri/core/workers/chunks/17784cf16fa91504b9ea.js +1 -0
  16. package/assets/esri/core/workers/chunks/{a395373e3173e6458a56.js → 1ab37e13947d0e2e4181.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{f03635ddf56e2ef90e4c.js → 1d06fcae4c2f02fb1c95.js} +1 -1
  18. package/assets/esri/core/workers/chunks/1dfca37f95f2b968aa54.js +1 -0
  19. package/assets/esri/core/workers/chunks/{5bd36dbf46c25bd961c8.js → 21293b0c6405a10ec7b6.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{285762ff92d5388b6024.js → 2166238a7ad63a2d43c7.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{620a94b54be3ed78350d.js → 22ca80f491e070b2a5e7.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{88074189fa10c335370b.js → 24cd7b84cd0f3de4bff2.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{ccc0da0e01f023c8aa1f.js → 28d1f2cf6aae547615c3.js} +1 -1
  24. package/assets/esri/core/workers/chunks/292daac70bb828e4923f.js +1 -0
  25. package/assets/esri/core/workers/chunks/{7e43c105f1cfc44b7bd0.js → 2fa01bd3f3608616fd7f.js} +1 -1
  26. package/assets/esri/core/workers/chunks/30e220f4f843681a4cdd.js +1 -0
  27. package/assets/esri/core/workers/chunks/{5d3661d1fe46dd29aae9.js → 311b564e44ae637c960d.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{f4d0ae6be1b3984228d0.js → 31b6406960261da21dd4.js} +1 -1
  29. package/assets/esri/core/workers/chunks/31c7ce65e16f7858400f.js +1 -0
  30. package/assets/esri/core/workers/chunks/31dbe07047dc61303d7d.js +1 -0
  31. package/assets/esri/core/workers/chunks/{8a314b3790313e6dc5db.js → 333b62dad3811cff0f14.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{c8733cd621105afab2ac.js → 35c9b24e4430bd6c2b6b.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{e31192ae920e3e19b6aa.js → 37c1f155da14de91565a.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{c55c096669677321a227.js → 38cd3648932bf2534b0f.js} +1 -1
  35. package/assets/esri/core/workers/chunks/3a457e718a901a45902e.js.LICENSE.txt +1 -1
  36. package/assets/esri/core/workers/chunks/{f5e47eea8720ba84665b.js → 3c07aa2015ab1dff5f7b.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{e9311386f58f3cb95c22.js → 42a1e71d09e8583a7327.js} +1 -1
  38. package/assets/esri/core/workers/chunks/443dfe7029ec208f670c.js +1 -0
  39. package/assets/esri/core/workers/chunks/{b75930d60449eceb0f1c.js → 4baf6f6e7ddedb25f806.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{bb5484b5eeacc9ad2ceb.js → 4d0cbf9584446f411a37.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{17103e6542aae53c7301.js → 4e3e27673d0671fc2b58.js} +1 -1
  42. package/assets/esri/core/workers/chunks/4fb5f1c671892001a4fd.js +1 -0
  43. package/assets/esri/core/workers/chunks/{5fc7b61f467f1d60a284.js → 51ab2acac4ecc1ca9c34.js} +1 -1
  44. package/assets/esri/core/workers/chunks/{fc4417d1260b717a9385.js → 52282f767bd0e99ddca0.js} +1 -1
  45. package/assets/esri/core/workers/chunks/{dedc4583b5f32a278124.js → 5350d50b47b6a4e0e169.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{fc06014fb484fc8c697e.js → 53654edd766d9b4ef750.js} +1 -1
  47. package/assets/esri/core/workers/chunks/{90f8b4bda28af43ea019.js → 538f509d7fc8337d37ac.js} +1 -1
  48. package/assets/esri/core/workers/chunks/{ed8a85efbd90241512bb.js → 588533c3abe876f20f62.js} +1 -1
  49. package/assets/esri/core/workers/chunks/58e59ead33368ce38c8f.js +1 -0
  50. package/assets/esri/core/workers/chunks/5db37547963857295273.js +1 -0
  51. package/assets/esri/core/workers/chunks/{72846fb9c87c6642daf0.js → 5e2ce34def5e053913b2.js} +1 -1
  52. package/assets/esri/core/workers/chunks/{8c056eac35d05d9524b7.js → 5f29422a051311ef9b3c.js} +1 -1
  53. package/assets/esri/core/workers/chunks/{ac26e3e77df4302f47a2.js → 604777417722d4effe06.js} +1 -1
  54. package/assets/esri/core/workers/chunks/{ff35a077ac6776469805.js → 61d970ed75c2c358b1e9.js} +1 -1
  55. package/assets/esri/core/workers/chunks/{7a6a96edc892d7060b7d.js → 629127877042ad784ad2.js} +1 -1
  56. package/assets/esri/core/workers/chunks/{90b2b43b8b54c9a1ec35.js → 664ae441617afe4b17ec.js} +1 -1
  57. package/assets/esri/core/workers/chunks/67f03d042455cd0f7009.js +1 -0
  58. package/assets/esri/core/workers/chunks/{4c5a7249a311070d8f43.js → 6af18d7a0d314d7c1756.js} +1 -1
  59. package/assets/esri/core/workers/chunks/{f35aaa04cca676c2d3f8.js → 6b59f94040c7d2f6728a.js} +1 -1
  60. package/assets/esri/core/workers/chunks/6d9f2b113d6bde936a04.js +1 -0
  61. package/assets/esri/core/workers/chunks/{5132ca68e8c7af111a47.js → 6e22b02a9715c10578d0.js} +1 -1
  62. package/assets/esri/core/workers/chunks/{f0e0a63962784acb4ba1.js → 6f0aec7428021e440ac9.js} +1 -1
  63. package/assets/esri/core/workers/chunks/{deb2854bb7d082a26f52.js → 7005d956c990a04ee8b2.js} +1 -1
  64. package/assets/esri/core/workers/chunks/{a3991ae8caa713d4ddcd.js → 731f7b552dde0fb325cd.js} +1 -1
  65. package/assets/esri/core/workers/chunks/7565b382f6b3d2cb46a3.js +2 -0
  66. package/assets/esri/core/workers/chunks/{b96eb0ea506379182d62.js.LICENSE.txt → 7565b382f6b3d2cb46a3.js.LICENSE.txt} +1 -1
  67. package/assets/esri/core/workers/chunks/{464d42bebb365287808d.js → 773f2c6c9d38db76dfed.js} +1 -1
  68. package/assets/esri/core/workers/chunks/{3f3d492f1093b7832aab.js → 7803495f8862d9025bcd.js} +1 -1
  69. package/assets/esri/core/workers/chunks/7d641f2f5edd95b9bc18.js +1 -0
  70. package/assets/esri/core/workers/chunks/7e4c14d4502e3f06d94b.js +1 -0
  71. package/assets/esri/core/workers/chunks/812f2ccc01f44e3cfd41.js +1 -0
  72. package/assets/esri/core/workers/chunks/826fa0dfb63df77bfd95.js +1 -0
  73. package/assets/esri/core/workers/chunks/{7544316a75dbd981aea6.js → 86cb097deec50b0da3f3.js} +1 -1
  74. package/assets/esri/core/workers/chunks/87921f3fa9001f5801ed.js +1 -0
  75. package/assets/esri/core/workers/chunks/{95c594a87b732f5c4979.js → 89b748e064ca90b4f76a.js} +1 -1
  76. package/assets/esri/core/workers/chunks/8a40ed2ee4b032822c30.js +1 -0
  77. package/assets/esri/core/workers/chunks/{09de8be660174a229efb.js → 8cbb28476151a37ae958.js} +1 -1
  78. package/assets/esri/core/workers/chunks/{fe77ae6cf232a7a3298e.js → 8d9d3797c6d62fdfff9d.js} +1 -1
  79. package/assets/esri/core/workers/chunks/{62a49cfd9a2508950e9f.js → 8fedfd33c37172dba6bf.js} +1 -1
  80. package/assets/esri/core/workers/chunks/91aa1157da32f650983b.js +1 -0
  81. package/assets/esri/core/workers/chunks/{e7638b9ab6674bc8a18f.js → 91dfd29e2dba200eab09.js} +1 -1
  82. package/assets/esri/core/workers/chunks/{794748fd1edc29a621cd.js → 9698f36c143953a975d4.js} +1 -1
  83. package/assets/esri/core/workers/chunks/98584902c9db6faa3e4d.js +1 -0
  84. package/assets/esri/core/workers/chunks/9e5e05d6430712b0b1bc.js +1 -0
  85. package/assets/esri/core/workers/chunks/{e5a06ce0ef6a9a90e100.js → 9f21436016ff7a899e79.js} +1 -1
  86. package/assets/esri/core/workers/chunks/{67d9cfe02613cb73ee37.js → 9ff8ee6ed6b98c03ae7e.js} +2 -2
  87. package/assets/esri/core/workers/chunks/{67d9cfe02613cb73ee37.js.LICENSE.txt → 9ff8ee6ed6b98c03ae7e.js.LICENSE.txt} +1 -1
  88. package/assets/esri/core/workers/chunks/a6ee40dfc471d6612f3c.js +1 -0
  89. package/assets/esri/core/workers/chunks/aa78b69219d9a0ef1c54.js.LICENSE.txt +1 -1
  90. package/assets/esri/core/workers/chunks/{a4db5c9a90107e097df8.js → af47272aaaef0ea57e71.js} +1 -1
  91. package/assets/esri/core/workers/chunks/b05208d56a724a8f1661.js +1 -0
  92. package/assets/esri/core/workers/chunks/{79968c183135281d2a6f.js → b3613a38178cad2ebc82.js} +1 -1
  93. package/assets/esri/core/workers/chunks/{22d6b8102e75bdef204c.js → b7eb486354994dc70855.js} +1 -1
  94. package/assets/esri/core/workers/chunks/bc19a232076d98825eef.js +1 -0
  95. package/assets/esri/core/workers/chunks/c29486c4eeb3e72effff.js +1 -0
  96. package/assets/esri/core/workers/chunks/{2b94623cabc6ae0f86ce.js → c37f7756d48ff9af2656.js} +1 -1
  97. package/assets/esri/core/workers/chunks/{1c52999a6392370844a6.js → c4090a60d149a5962179.js} +1 -1
  98. package/assets/esri/core/workers/chunks/c715fd32f814a0f14f40.js +1 -0
  99. package/assets/esri/core/workers/chunks/{73c1d43070b4fe1e5c1e.js → c8e686efe344a33a0258.js} +1 -1
  100. package/assets/esri/core/workers/chunks/{6bb5158de43c4b59107f.js → c9b16fd41cd59d452522.js} +1 -1
  101. package/assets/esri/core/workers/chunks/ce16489cf7eb0d78c741.js.LICENSE.txt +1 -1
  102. package/assets/esri/core/workers/chunks/cf971e7b1b98d9c502d3.js +1 -0
  103. package/assets/esri/core/workers/chunks/{279366e6b743f9680603.js → cfff044859e6e6dcc75d.js} +1 -1
  104. package/assets/esri/core/workers/chunks/d07f911d40bf05fc0306.js +1 -0
  105. package/assets/esri/core/workers/chunks/{8833c3d168951be4bf20.js → d0d79dd3e88eecf5c314.js} +1 -1
  106. package/assets/esri/core/workers/chunks/d1ca7c3a32ce00ed8b81.js +1 -0
  107. package/assets/esri/core/workers/chunks/{76ae1702fecc7ad7017c.js → d1e97cce5047f1791e22.js} +1 -1
  108. package/assets/esri/core/workers/chunks/{17acde0245ecd956306c.js → d233cc33497a663450f9.js} +1 -1
  109. package/assets/esri/core/workers/chunks/{b017bac40dc8328013e3.js → d391bfbaf0e790cd10d6.js} +2 -2
  110. package/assets/esri/core/workers/chunks/{b017bac40dc8328013e3.js.LICENSE.txt → d391bfbaf0e790cd10d6.js.LICENSE.txt} +1 -1
  111. package/assets/esri/core/workers/chunks/d6e0528eacee7ea4c1ce.js.LICENSE.txt +1 -1
  112. package/assets/esri/core/workers/chunks/{36fe6b8228e622407ec2.js → d8793eead02491136841.js} +1 -1
  113. package/assets/esri/core/workers/chunks/{4d599008e1ea42321b37.js → da24ad57747714ac5eda.js} +1 -1
  114. package/assets/esri/core/workers/chunks/db678a6e352275e507a9.js +1 -0
  115. package/assets/esri/core/workers/chunks/{facb3886714222772ab2.js → ddfd01bb9ba8577c3ffc.js} +1 -1
  116. package/assets/esri/core/workers/chunks/de2ebd9cc3d9e68d435b.js +1 -0
  117. package/assets/esri/core/workers/chunks/{50d9f69d5255af4b29bb.js → df5afa06c6deb6b40109.js} +1 -1
  118. package/assets/esri/core/workers/chunks/e25c4b4a03270d48f408.js +1 -0
  119. package/assets/esri/core/workers/chunks/e3294318daf1192b8319.js +1 -0
  120. package/assets/esri/core/workers/chunks/e599125e746c27de106e.js +1 -0
  121. package/assets/esri/core/workers/chunks/{da573ecc68e6aa8f6da9.js → e767f83f9e2de6650f80.js} +1 -1
  122. package/assets/esri/core/workers/chunks/e9d4cae2144974489d6e.js +1 -0
  123. package/assets/esri/core/workers/chunks/{91df8638b8b904e6d8c5.js → ead8d0cbcebd12dbfad7.js} +1 -1
  124. package/assets/esri/core/workers/chunks/{f9324e88c359c03f35aa.js → eb9c166db0db6fa60e95.js} +1 -1
  125. package/assets/esri/core/workers/chunks/ebcc94234d9d4be1941f.js +316 -0
  126. package/assets/esri/core/workers/chunks/ee5f0fd5384caa11c986.js +1 -0
  127. package/assets/esri/core/workers/chunks/{bc241c7735e4efba734a.js → f34e3fa0c5b28531e289.js} +1 -1
  128. package/assets/esri/core/workers/chunks/f64037a88ab03662dc2a.js +1 -0
  129. package/assets/esri/core/workers/chunks/f651c05604eab83aef5f.js.LICENSE.txt +1 -1
  130. package/assets/esri/core/workers/chunks/{d97fadbc69e055d183a0.js → f77f4bd6a577b92cf66f.js} +1 -1
  131. package/assets/esri/core/workers/chunks/f80f5dbf96c343ac4df6.js +1 -0
  132. package/assets/esri/core/workers/chunks/{16d66770ef841564ee3f.js → f89c90f98c85667b0ebc.js} +1 -1
  133. package/assets/esri/core/workers/chunks/{4c4227b0ea21a5e429ab.js → fb192de7e4fa152342bb.js} +1 -1
  134. package/assets/esri/core/workers/chunks/fbd8d2f61f8a15bcf3db.js +1 -0
  135. package/assets/esri/core/workers/chunks/fccd931f95d81ecc57b2.js +1 -0
  136. package/assets/esri/core/workers/chunks/{2f78861afe0e9037dd8d.js → fe49321dca22dc60d105.js} +1 -1
  137. package/assets/esri/libs/parquet/pkg/bundle_bg.wasm +0 -0
  138. package/assets/esri/themes/base/widgets/_NavigationToggle.scss +1 -1
  139. package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +4 -4
  140. package/assets/esri/themes/base/widgets/_Widget.scss +1 -1
  141. package/assets/esri/themes/dark/main.css +1 -1
  142. package/assets/esri/themes/light/main.css +1 -1
  143. package/assets/esri/themes/light/view.css +1 -1
  144. package/chunks/MultiPathImpl.js +1 -1
  145. package/chunks/Point2D.js +1 -1
  146. package/chunks/UnitFactory.js +1 -1
  147. package/config.js +1 -1
  148. package/core/QueueProcessor.js +1 -1
  149. package/core/SetUtils.js +1 -1
  150. package/core/has.js +1 -1
  151. package/form/FormTemplate.js +1 -1
  152. package/form/elements/Element.js +1 -1
  153. package/form/elements/FieldElement.js +1 -1
  154. package/form/elements/GroupElement.js +1 -1
  155. package/geometry/operators/gx/operatorOffset.js +1 -1
  156. package/geometry/support/meshUtils/loadGLTFMesh.js +1 -1
  157. package/identity/Credential.js +1 -1
  158. package/identity/IdentityManager.js +1 -1
  159. package/identity/IdentityManagerBase.js +1 -1
  160. package/interfaces.d.ts +92 -50
  161. package/kernel.js +1 -1
  162. package/layers/FeatureLayer.js +1 -1
  163. package/layers/SceneLayer.js +1 -1
  164. package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
  165. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  166. package/layers/graphics/sources/connections/GeoEventConnection.js +1 -1
  167. package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
  168. package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
  169. package/layers/knowledgeGraph/layerUtils.js +1 -1
  170. package/layers/orientedImagery/core/ExposurePoint.js +1 -1
  171. package/layers/orientedImagery/transformations/imageToWorld.js +1 -1
  172. package/layers/support/RasterJobHandler.js +1 -1
  173. package/layers/support/RasterWorker.js +1 -1
  174. package/layers/support/fieldConfigUtils.js +1 -1
  175. package/layers/support/rasterDatasets/pixelReader.js +1 -1
  176. package/layers/support/rasterFunctions/pixelTransformUtils.js +5 -0
  177. package/layers/support/rasterFunctions/pixelUtils.js +1 -1
  178. package/layers/support/source/DataLayerSource.js +1 -1
  179. package/package.json +4 -4
  180. package/popup/FieldInfo.js +1 -1
  181. package/processRequest.js +5 -0
  182. package/request.js +1 -1
  183. package/requestConfig.js +5 -0
  184. package/requestQueue.js +5 -0
  185. package/rest/query/executeForCount.js +1 -1
  186. package/rest/query/executeForExtent.js +1 -1
  187. package/rest/query/executeForIds.js +1 -1
  188. package/rest/query/executeQueryJSON.js +1 -1
  189. package/rest/query/executeQueryPBF.js +1 -1
  190. package/rest/query/operations/query.js +1 -1
  191. package/rest/support/BaseImageMeasureResultValue.js +5 -0
  192. package/rest/support/ImageAreaResult.js +1 -1
  193. package/rest/support/ImageDistanceResult.js +1 -1
  194. package/rest/support/ImageHeightResult.js +1 -1
  195. package/rest/support/ImageMeasureResultAngleValue.js +5 -0
  196. package/rest/support/ImageMeasureResultAreaValue.js +5 -0
  197. package/rest/support/ImageMeasureResultLengthValue.js +5 -0
  198. package/rest/support/ImageWithType.js +5 -0
  199. package/rest/support/imageMeasureUtils.js +1 -1
  200. package/smartMapping/renderers/size.js +1 -1
  201. package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
  202. package/smartMapping/support/adapters/InMemoryLayerAdapter.js +1 -1
  203. package/smartMapping/support/adapters/support/histogramUtils.js +1 -1
  204. package/smartMapping/support/adapters/support/utils.js +1 -1
  205. package/support/revision.js +1 -1
  206. package/symbols/support/utils.js +1 -1
  207. package/views/2d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles2D.js +1 -1
  208. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  209. package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
  210. package/views/2d/layers/features/schema/SourceSchema.js +1 -1
  211. package/views/2d/layers/features/sources/FeatureSource.js +1 -1
  212. package/views/2d/layers/features/sources/strategies/AFeatureLoadStrategy.js +1 -1
  213. package/views/2d/layers/features/sources/strategies/ALoadStrategy.js +1 -1
  214. package/views/2d/layers/features/sources/strategies/ParquetSnapshotLoadStrategy.js +1 -1
  215. package/views/2d/layers/features/sources/strategies/ParquetTileLoadStrategy.js +1 -1
  216. package/views/2d/layers/features/sources/strategies/chunks/Overrides.js +1 -1
  217. package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
  218. package/views/{3d/support/ImageWithType.js → 2d/layers/features/sources/strategies/constants.js} +1 -1
  219. package/views/2d/layers/features/sources/strategies/support/queryAdapters.js +1 -1
  220. package/views/3d/GroundView3D.js +1 -1
  221. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  222. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
  223. package/views/3d/analysis/VolumeMeasurement/volumeMeasurementErrors.js +1 -1
  224. package/views/3d/glTF/DefaultLoadingContext.js +1 -1
  225. package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js +1 -1
  226. package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
  227. package/views/3d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles3D.js +1 -1
  228. package/views/3d/layers/ElevationLayerView3D.js +1 -1
  229. package/views/3d/layers/FeatureLayerViewBase3D.js +1 -1
  230. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  231. package/views/3d/layers/graphics/FeatureGraphics3DGraphicsPipeline.js +1 -1
  232. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  233. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  234. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  235. package/views/3d/layers/graphics/Graphics3DSymbolCreationContext.js +1 -1
  236. package/views/3d/layers/graphics/ObjectResourceCache.js +1 -1
  237. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  238. package/views/3d/layers/graphics/pipeline/Feature3DPipeline.js +1 -1
  239. package/views/3d/layers/graphics/pipeline/fetching/Tile3DFetcher.js +1 -1
  240. package/views/3d/layers/graphics/wosrLoader.js +1 -1
  241. package/views/3d/layers/i3s/I3SDataRequester.js +5 -0
  242. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  243. package/views/3d/layers/i3s/I3SNodeLoader.js +1 -1
  244. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  245. package/views/3d/layers/support/FeatureTile.js +1 -1
  246. package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
  247. package/views/3d/layers/support/MediaLayerInteractionOptions.js +1 -1
  248. package/views/3d/layers/support/MediaLayerInteractionReshapeOptions.js +5 -0
  249. package/views/3d/layers/support/SampledGeometryMaxDistanceRatio.js +5 -0
  250. package/views/3d/layers/support/featureTileQuery3D.js +1 -1
  251. package/views/3d/layers/support/fetchTile.js +1 -1
  252. package/views/3d/support/ResourceController.js +1 -1
  253. package/views/3d/support/SharedSymbolResources.js +1 -1
  254. package/views/3d/support/StreamTextureCollection.js +1 -1
  255. package/views/3d/terrain/TerrainSurface.js +1 -1
  256. package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
  257. package/views/3d/webgl-engine/lighting/SceneLighting.js +1 -1
  258. package/views/3d/webgl-engine/shaders/AnimatedLine.glsl.js +6 -0
  259. package/views/SceneView.js +1 -1
  260. package/views/analysis/ElevationProfile/ElevationProfileTool.js +1 -1
  261. package/views/analysis/ElevationProfile/elevationProfileGeometryUtils.js +1 -1
  262. package/views/draw/MultipointDrawAction.js +1 -1
  263. package/views/draw/PointDrawAction.js +1 -1
  264. package/views/draw/PolygonDrawAction.js +1 -1
  265. package/views/draw/PolylineDrawAction.js +1 -1
  266. package/views/draw/SegmentDrawAction.js +1 -1
  267. package/views/draw/input/CursorUpdateEvents.js +5 -0
  268. package/views/draw/input/DrawCompleteEvent.js +5 -0
  269. package/views/draw/input/VertexAddEvent.js +5 -0
  270. package/views/draw/input/VertexRemoveEvent.js +5 -0
  271. package/views/draw/input/VertexUpdateEvent.js +5 -0
  272. package/views/interactive/editGeometry/CheckpointingEditGeometryOperations.js +5 -0
  273. package/views/interactive/editGeometry/EditGeometry.js +1 -1
  274. package/views/interactive/editGeometry/operations/ReplayableAppendVertex.js +5 -0
  275. package/views/interactive/snapping/featureSources/FeatureServiceSnappingSource.js +1 -1
  276. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js +1 -1
  277. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTileStore.js +1 -1
  278. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiledFetcher.js +1 -1
  279. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTilesSimple.js +1 -1
  280. package/views/support/PromiseQueue.js +1 -1
  281. package/views/support/Scheduler.js +1 -1
  282. package/webscene/spec-certification/api.js +1 -1
  283. package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
  284. package/widgets/CoordinateConversion.js +1 -1
  285. package/widgets/Editor/AddAssociationWorkflow.js +1 -1
  286. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  287. package/widgets/Editor/EditorViewModel.js +1 -1
  288. package/widgets/Editor/MergeFeaturesWorkflow.js +1 -1
  289. package/widgets/Editor/SplitFeatureWorkflow.js +1 -1
  290. package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
  291. package/widgets/Editor/UpdateFeaturesWorkflow.js +1 -1
  292. package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
  293. package/widgets/Editor/UpdateRecordWorkflowData.js +1 -1
  294. package/widgets/Editor/UpdateWorkflow.js +1 -1
  295. package/widgets/Editor/UpdateWorkflowData.js +1 -1
  296. package/widgets/Editor/support/SketchController.js +1 -1
  297. package/widgets/Editor/support/errors.js +5 -0
  298. package/widgets/Editor/workflowUtils.js +1 -1
  299. package/widgets/Editor.js +1 -1
  300. package/widgets/Legend/LegendViewModel.js +1 -1
  301. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  302. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  303. package/widgets/OrientedImageryViewer/adapters/sketch/TriangulatedMeasurementAdapter.js +1 -1
  304. package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
  305. package/widgets/OrientedImageryViewer/galleryUtils.js +1 -1
  306. package/widgets/OrientedImageryViewer/services/DepthImageService.js +1 -1
  307. package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
  308. package/widgets/PanoramicViewer/PanoramicZoomManager.js +1 -1
  309. package/widgets/PanoramicViewer/support/PanoramicMeshManager.js +1 -1
  310. package/widgets/PanoramicViewer/support/PanoramicTileNode.js +1 -1
  311. package/widgets/PanoramicViewer/support/PanoramicTilePyramid.js +1 -1
  312. package/widgets/PanoramicViewer/support/getVisibleTiles.js +5 -0
  313. package/widgets/Sketch/CreateToolVisibilityMap.js +5 -0
  314. package/widgets/Sketch/SelectionToolVisibilityMap.js +5 -0
  315. package/widgets/Sketch/VisibleElements.js +1 -1
  316. package/widgets/Sketch.js +1 -1
  317. package/assets/esri/core/workers/chunks/020c8913d8e35d63080b.js +0 -1
  318. package/assets/esri/core/workers/chunks/02e69f0c63d97661da60.js +0 -1
  319. package/assets/esri/core/workers/chunks/05eee334d58a0b9f6316.js +0 -1
  320. package/assets/esri/core/workers/chunks/06ba43843e9c4988049b.js +0 -1
  321. package/assets/esri/core/workers/chunks/087973e7c4fea5fcfa5e.js +0 -1
  322. package/assets/esri/core/workers/chunks/326a76a4e80269d4029d.js +0 -1
  323. package/assets/esri/core/workers/chunks/377a66034e7c1bad5599.js +0 -1
  324. package/assets/esri/core/workers/chunks/4442817beb7a76c95770.js +0 -1
  325. package/assets/esri/core/workers/chunks/459a67928bde4a62b6a4.js +0 -1
  326. package/assets/esri/core/workers/chunks/4eebd74ebc20579dade8.js +0 -1
  327. package/assets/esri/core/workers/chunks/53bd8996e8812f1ad7b2.js +0 -1
  328. package/assets/esri/core/workers/chunks/557960763695abee4a83.js +0 -1
  329. package/assets/esri/core/workers/chunks/6201356f7f91e5c06425.js +0 -1
  330. package/assets/esri/core/workers/chunks/6c3b99209d542efa64d4.js +0 -1
  331. package/assets/esri/core/workers/chunks/6f4bd0ee85e7e5a74340.js +0 -1
  332. package/assets/esri/core/workers/chunks/7413e582bc2b16af6a0f.js +0 -1
  333. package/assets/esri/core/workers/chunks/7461124454bfb4fb6474.js +0 -1
  334. package/assets/esri/core/workers/chunks/75bf27271a31e26e1b21.js +0 -1
  335. package/assets/esri/core/workers/chunks/7aaaebbabee27690283c.js +0 -1
  336. package/assets/esri/core/workers/chunks/7c4a63aeead2505d6f02.js +0 -1
  337. package/assets/esri/core/workers/chunks/811d4c46c75cf6a63e78.js +0 -1
  338. package/assets/esri/core/workers/chunks/8ffd4710d168c2fcfd96.js +0 -1
  339. package/assets/esri/core/workers/chunks/90250e9239c173aace88.js +0 -1
  340. package/assets/esri/core/workers/chunks/9786f91455350eaae493.js +0 -1
  341. package/assets/esri/core/workers/chunks/99859dce1925b406ccd0.js +0 -1
  342. package/assets/esri/core/workers/chunks/9c5cbf8810f37b1a4718.js +0 -1
  343. package/assets/esri/core/workers/chunks/9e8dceef4c961f56940d.js +0 -1
  344. package/assets/esri/core/workers/chunks/9fac5a12e878cd745354.js +0 -1
  345. package/assets/esri/core/workers/chunks/a06bac9b8f9e18874de8.js +0 -316
  346. package/assets/esri/core/workers/chunks/a712cdff78fc826acd8c.js +0 -1
  347. package/assets/esri/core/workers/chunks/a8f998b8ec8c56150479.js +0 -2
  348. package/assets/esri/core/workers/chunks/aa54b6f2aba6952af149.js +0 -1
  349. package/assets/esri/core/workers/chunks/b96eb0ea506379182d62.js +0 -2
  350. package/assets/esri/core/workers/chunks/c476643002387f60ea42.js +0 -1
  351. package/assets/esri/core/workers/chunks/c4e4da69969499a89a2c.js +0 -1
  352. package/assets/esri/core/workers/chunks/cd1930f08e1fc8b30b14.js +0 -1
  353. package/assets/esri/core/workers/chunks/d1fe816b6990918c13c7.js +0 -1
  354. package/assets/esri/core/workers/chunks/d305a21666b1ed5bf33d.js +0 -1
  355. package/assets/esri/core/workers/chunks/d40f57f9fc47f9a9f97c.js +0 -1
  356. package/assets/esri/core/workers/chunks/e0bbfbe1ed39c82f1bd4.js +0 -1
  357. package/assets/esri/core/workers/chunks/e82f5437bd66779c6740.js +0 -1
  358. package/assets/esri/core/workers/chunks/f6c8beb60f6d29945a2e.js +0 -1
  359. package/assets/esri/core/workers/chunks/f746e3f7ebff2bbdf333.js +0 -1
  360. package/assets/esri/core/workers/chunks/fd2efd1d1cf9d95a87e6.js +0 -1
  361. package/views/3d/layers/i3s/I3SStreamDataController.js +0 -5
  362. package/views/3d/support/StreamDataLoader.js +0 -5
  363. package/views/3d/support/StreamDataRequester.js +0 -5
  364. package/views/3d/support/downloadSlots.js +0 -5
  365. package/views/draw/input/DrawEvents.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import{equals as i}from"../../../../../core/arrayUtils.js";import{createTask as s}from"../../../../../core/asyncUtils.js";import r from"../../../../../core/Logger.js";import{throwIfAbortError as o}from"../../../../../core/promiseUtils.js";import{when as n}from"../../../../../core/reactiveUtils.js";import{union as a,equals as l,isSubsetOf as u,difference as d}from"../../../../../core/SetUtils.js";import{normalizeGlobalID as c}from"../../../../../core/uuid.js";import{property as h}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import{subclass as p}from"../../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as y}from"../../../../../core/support/UpdatingHandles.js";import f from"../../../../../geometry/Extent.js";import{toExtent as m}from"../../../../../geometry/support/aaBoundingRect.js";import{unquantizeOptimizedFeatureSet as _,convertFromFeatureSet as g}from"../../../../../layers/graphics/featureConversionUtils.js";import{isHostedAgolService as F}from"../../../../../layers/support/arcgisLayerUrl.js";import{OptimizedFeatureSetParserContext as b}from"../../../../../rest/query/operations/pbfOptimizedFeatureSet.js";import{executeQueryForExtent as T,executeQueryPBF as P,executeQuery as v}from"../../../../../rest/query/operations/query.js";import I from"../../../../../rest/support/Query.js";import{PendingFeatureTile as O}from"./PendingFeatureTile.js";let S=class extends t{get _minimumVerticesPerFeature(){switch(this.store?.featureStore.geometryType){case"esriGeometryPoint":case"esriGeometryMultipoint":return 1;case"esriGeometryPolygon":return 4;case"esriGeometryPolyline":return 2}}get _mandatoryOutFields(){const e=new Set;return this.objectIdField&&e.add(this.objectIdField),this.globalIdField&&e.add(this.globalIdField),e}set outFields(e){const t=this._get("outFields"),i=a(e,this._mandatoryOutFields);l(i,t)||(this._set("outFields",i),u(i,t)||this.refresh())}get outFields(){return this._get("outFields")??this._mandatoryOutFields}set filter(e){const t=this._get("filter"),i=this._filterProperties(e);JSON.stringify(t)!==JSON.stringify(i)&&this._set("filter",i)}set customParameters(e){const t=this._get("customParameters");JSON.stringify(t)!==JSON.stringify(e)&&this._set("customParameters",e)}get _configuration(){return{filter:this.filter,customParameters:this.customParameters,tileInfo:this.tileInfo,tileSize:this.tileSize}}set tileInfo(e){const t=this._get("tileInfo");t!==e&&(null!=e&&null!=t&&JSON.stringify(e)===JSON.stringify(t)||(this._set("tileInfo",e),this.store.tileInfo=e))}set tileSize(e){this._get("tileSize")!==e&&this._set("tileSize",e)}get updating(){return this._updatingHandles.updating}get hasZ(){return this.store.featureStore.hasZ}constructor(e){super(e),this.suspended=!0,this._historicMoment=null,this.tilesOfInterest=new Array,this.availability=0,this._pendingTiles=new Map,this._updatingHandles=new y}initialize(){this._initializeFetchExtent(),this._updatingHandles.add(()=>this._configuration,()=>this.refresh()),this._updatingHandles.add(()=>this.tilesOfInterest,()=>{this._updatePriorities(),this._process()},{sync:!0,initial:!0,equals:(e,t)=>i(e,t,({id:e},{id:t})=>e===t)}),this.addHandles(n(()=>!this.suspended,()=>this._process()))}_updatePriorities(){this.store.setPriorityOrderByKey(this.tilesOfInterest.map(({id:e})=>e)??[])}destroy(){this._pendingTiles.forEach(e=>this._deletePendingTile(e)),this._pendingTiles.clear(),this.store.destroy(),this.tilesOfInterest.length=0,this._updatingHandles.destroy()}refresh(){this.store.refresh(),this._pendingTiles.forEach(e=>this._deletePendingTile(e)),this._process()}async handleEdits(e){if(e.historicMoment&&(this._historicMoment=e.historicMoment),!e.addedFeatures.length&&!e.updatedFeatures.length&&!e.deletedFeatures.length)return;for(const s of this._pendingTiles.values())s.reset();const t={...e,deletedFeatures:e.deletedFeatures.map(({objectId:e,globalId:t})=>e&&-1!==e?e:this._lookupObjectIdByGlobalId(t))},i=s(async e=>{try{await this.store.processEdits(t,(e,t)=>this._queryFeaturesById(e,t),e),this._processPendingTiles()}catch(i){o(i),r.getLogger(this).warn("Failed to apply edits",i)}});this.addHandles(i),await this._updatingHandles.addPromise(i.promise)}setHistoricMoment(e){e?.getTime()!==this._historicMoment?.getTime()&&(this._historicMoment=e,this.refresh())}_initializeFetchExtent(){if(!this.capabilities.query.supportsExtent||!F(this.url))return;const e=s(async e=>{try{const t=await T(this.url,new I({where:"1=1",outSpatialReference:this.spatialReference,cacheHint:this.capabilities.query.supportsCacheHint??void 0}),{query:this._configuration.customParameters,signal:e});this.store.extent=f.fromJSON(t.data?.extent)}catch(t){o(t),r.getLogger(this).warn("Failed to fetch data extent",t)}});this._updatingHandles.addPromise(e.promise.then(()=>this._process())),this.addHandles(e)}get debugInfo(){return{numberOfFeatures:this.store.featureStore.numFeatures,tilesOfInterest:this.tilesOfInterest,pendingTiles:Array.from(this._pendingTiles.values()).map(e=>e.debugInfo),storedTiles:this.store.debugInfo}}_process(){this._markTilesNotAlive(),this._createPendingTiles(),this._deletePendingTiles(),this._processPendingTiles()}_markTilesNotAlive(){for(const e of this._pendingTiles.values())e.alive=!1}_createPendingTiles(){if(this.suspended)return;const e=this._collectMissingTilesInfo();if(this._setAvailability(null==e?1:e.coveredArea/e.fullArea),null!=e)for(const{data:t,resolution:i}of e.missingTiles){const e=this._pendingTiles.get(t.id);e?(e.resolution=i,e.alive=!0):this._createPendingTile(t,i)}}_collectMissingTilesInfo(){let e=null;for(const t of this.tilesOfInterest){const i=this.store.process(t,(e,t)=>this._verifyTileComplexity(e,t),this.outFields);null==e?e=i:e.prepend(i)}return e}_deletePendingTiles(){for(const e of this._pendingTiles.values())e.alive||this._deletePendingTile(e)}_processPendingTiles(){const e={fetchCount:(e,t)=>this._fetchCount(e,t),fetchFeatures:(e,t,i)=>this._fetchFeatures(e,t,i),finish:(e,t)=>this._finishPendingTile(e,t),resume:()=>this._processPendingTiles()};if(this._ensureFetchAllCounts(e))for(const t of this._pendingTiles.values())this._verifyTileComplexity(this.store.getFeatureCount(t.key),t.resolution)&&this._updatingHandles.addPromise(t.process(e))}_verifyTileComplexity(e,t){return this._verifyVertexComplexity(e)&&this._verifyFeatureDensity(e,t)}_verifyVertexComplexity(e){return e*this._minimumVerticesPerFeature<x}_verifyFeatureDensity(e,t){if(null==this.tileInfo)return!1;const i=this.tileSize*t;return e*(C/(i*i))<q}_ensureFetchAllCounts(e){let t=!0;for(const i of this._pendingTiles.values())i.state.type<2&&this._updatingHandles.addPromise(i.process(e)),i.state.type<=1&&(t=!1);return t}_finishPendingTile(e,t){this.store.add(e.key,t),this._deletePendingTile(e),this._updateAvailability()}_updateAvailability(){const e=this._collectMissingTilesInfo();this._setAvailability(null==e?1:e.coveredArea/e.fullArea)}_setAvailability(e){this._set("availability",e)}_createPendingTile(e,t){const i=new O(e,t);return this._pendingTiles.set(e.id,i),i}_deletePendingTile(e){e.reset(),this._pendingTiles.delete(e.key.id)}async _fetchCount(e,t){return this.store.fetchCount(e.key,this.url,this._createCountQuery(e),{query:this.customParameters,timeout:w,signal:t})}async _fetchFeatures(e,t,i){let s=0;const r=[];let o=0,n=t;for(;;){const a=this._createFeaturesQuery(e),l=this._setPagingParameters(a,s,n),{features:u,exceededTransferLimit:d}=await this._queryFeatures(a,i);l&&(s+=a.num),o+=u.length;for(const e of u)r.push(e);if(n=t-o,!l||!d||n<=0)return r}}_filterProperties(e){return null==e?{where:"1=1",gdbVersion:void 0,timeExtent:void 0}:{where:e.where||"1=1",timeExtent:e.timeExtent,gdbVersion:e.gdbVersion}}_lookupObjectIdByGlobalId(e){const t=this.globalIdField,i=this.objectIdField;if(null==t)throw new Error("Expected globalIdField to be defined");let s=null;const r=e?c(e):e;if(this.store.featureStore.forEach(e=>{r===c(e.attributes[t])&&(s=e.objectId??e.attributes[i])}),null==s)throw new Error(`Expected to find a feature with globalId ${e}`);return s}_queryFeaturesById(e,t){const i=this._createFeaturesQuery();return i.objectIds=e,this._queryFeatures(i,t)}_queryFeatures(e,t){return this.capabilities.query.supportsFormatPBF?this._queryFeaturesPBF(e,t):this._queryFeaturesJSON(e,t)}async _queryFeaturesPBF(e,t){const{sourceSpatialReference:i}=this,{data:s}=await P(this.url,e,new b({sourceSpatialReference:i}),{query:this._configuration.customParameters,timeout:w,signal:t});return _(s)}async _queryFeaturesJSON(e,t){const{sourceSpatialReference:i}=this,{data:s}=await v(this.url,e,i,{query:this._configuration.customParameters,timeout:w,signal:t});return g(s,{type:"object-id",fieldName:this.objectIdField})}_createCountQuery(e){const t=this._createBaseQuery(e);return this.capabilities.query.supportsCacheHint&&(t.cacheHint=!0),t}_createFeaturesQuery(e=null){const t=this._createBaseQuery(e),i=null!=e?.key?this.store.getAttributesForTile(e?.key?.id):null,s=a(d(this.outFields,i??new Set),this._mandatoryOutFields);return t.outFields=Array.from(s),t.returnGeometry=!0,null!=e&&(this.capabilities.query.supportsResultType?t.resultType="tile":this.capabilities.query.supportsCacheHint&&(t.cacheHint=!0)),t}_createBaseQuery(e){const t=new I({returnZ:this.hasZ,returnM:!1,historicMoment:this._historicMoment,geometry:null!=this.tileInfo&&null!=e?m(e.key.extent,this.tileInfo.spatialReference):void 0}),i=this._configuration.filter;return null!=i&&(t.where=i.where,t.gdbVersion=i.gdbVersion,t.timeExtent=i.timeExtent),t.outSpatialReference=this.spatialReference,t}_setPagingParameters(e,t,i){if(!this.capabilities.query.supportsPagination)return!1;const{supportsMaxRecordCountFactor:s,supportsCacheHint:r,tileMaxRecordCount:o,maxRecordCount:n,supportsResultType:a}=this.capabilities.query,l=s?I.MAX_MAX_RECORD_COUNT_FACTOR:1,u=l*((a||r)&&o?o:n||j);return e.start=t,s?(e.maxRecordCountFactor=Math.min(l,Math.ceil(i/u)),e.num=Math.min(i,e.maxRecordCountFactor*u)):e.num=Math.min(i,u),!0}};e([h({constructOnly:!0})],S.prototype,"url",void 0),e([h({constructOnly:!0})],S.prototype,"objectIdField",void 0),e([h({constructOnly:!0})],S.prototype,"globalIdField",void 0),e([h({constructOnly:!0})],S.prototype,"capabilities",void 0),e([h({constructOnly:!0})],S.prototype,"sourceSpatialReference",void 0),e([h({constructOnly:!0})],S.prototype,"spatialReference",void 0),e([h({constructOnly:!0})],S.prototype,"store",void 0),e([h({readOnly:!0})],S.prototype,"_minimumVerticesPerFeature",null),e([h()],S.prototype,"_mandatoryOutFields",null),e([h()],S.prototype,"outFields",null),e([h()],S.prototype,"suspended",void 0),e([h()],S.prototype,"_historicMoment",void 0),e([h()],S.prototype,"filter",null),e([h()],S.prototype,"customParameters",null),e([h({readOnly:!0})],S.prototype,"_configuration",null),e([h()],S.prototype,"tileInfo",null),e([h()],S.prototype,"tileSize",null),e([h()],S.prototype,"tilesOfInterest",void 0),e([h({readOnly:!0})],S.prototype,"updating",null),e([h({readOnly:!0})],S.prototype,"availability",void 0),e([h()],S.prototype,"hasZ",null),S=e([p("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceTiledFetcher")],S);const j=2e3,w=6e5,x=1e6,C=25,q=1;export{S as FeatureServiceTiledFetcher};
5
+ import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import{equals as i}from"../../../../../core/arrayUtils.js";import{createTask as s}from"../../../../../core/asyncUtils.js";import r from"../../../../../core/Logger.js";import{throwIfAbortError as o}from"../../../../../core/promiseUtils.js";import{when as n}from"../../../../../core/reactiveUtils.js";import{union as a,equals as l,isSubsetOf as u,difference as c}from"../../../../../core/SetUtils.js";import{normalizeGlobalID as d}from"../../../../../core/uuid.js";import{property as h}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import{subclass as p}from"../../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as y}from"../../../../../core/support/UpdatingHandles.js";import f from"../../../../../geometry/Extent.js";import{toExtent as m}from"../../../../../geometry/support/aaBoundingRect.js";import{unquantizeOptimizedFeatureSet as _,convertFromFeatureSet as g}from"../../../../../layers/graphics/featureConversionUtils.js";import F from"../../../../../layers/graphics/OptimizedFeatureSet.js";import{isHostedAgolService as b}from"../../../../../layers/support/arcgisLayerUrl.js";import{OptimizedFeatureSetParserContext as T}from"../../../../../rest/query/operations/pbfOptimizedFeatureSet.js";import{executeQueryForExtent as P,executeQueryPBF as v,executeQuery as I}from"../../../../../rest/query/operations/query.js";import O from"../../../../../rest/support/Query.js";import{PendingFeatureTile as S}from"./PendingFeatureTile.js";let j=class extends t{get _minimumVerticesPerFeature(){switch(this.store?.featureStore.geometryType){case"esriGeometryPoint":case"esriGeometryMultipoint":return 1;case"esriGeometryPolygon":return 4;case"esriGeometryPolyline":return 2}}get _mandatoryOutFields(){const e=new Set;return this.objectIdField&&e.add(this.objectIdField),this.globalIdField&&e.add(this.globalIdField),e}set outFields(e){const t=this._get("outFields"),i=a(e,this._mandatoryOutFields);l(i,t)||(this._set("outFields",i),u(i,t)||this.refresh())}get outFields(){return this._get("outFields")??this._mandatoryOutFields}set filter(e){const t=this._get("filter"),i=this._filterProperties(e);JSON.stringify(t)!==JSON.stringify(i)&&this._set("filter",i)}set customParameters(e){const t=this._get("customParameters");JSON.stringify(t)!==JSON.stringify(e)&&this._set("customParameters",e)}get _configuration(){return{filter:this.filter,customParameters:this.customParameters,tileInfo:this.tileInfo,tileSize:this.tileSize}}set tileInfo(e){const t=this._get("tileInfo");t!==e&&(null!=e&&null!=t&&JSON.stringify(e)===JSON.stringify(t)||(this._set("tileInfo",e),this.store.tileInfo=e))}set tileSize(e){this._get("tileSize")!==e&&this._set("tileSize",e)}get updating(){return this._updatingHandles.updating}get hasZ(){return this.store.featureStore.hasZ}constructor(e){super(e),this.suspended=!0,this._historicMoment=null,this.tilesOfInterest=new Array,this.availability=0,this._pendingTiles=new Map,this._updatingHandles=new y}initialize(){this._initializeFetchExtent(),this._updatingHandles.add(()=>this._configuration,()=>this.refresh()),this._updatingHandles.add(()=>this.tilesOfInterest,()=>{this._updatePriorities(),this._process()},{sync:!0,initial:!0,equals:(e,t)=>i(e,t,({id:e},{id:t})=>e===t)}),this.addHandles(n(()=>!this.suspended,()=>this._process()))}_updatePriorities(){this.store.setPriorityOrderByKey(this.tilesOfInterest.map(({id:e})=>e)??[])}destroy(){this._pendingTiles.forEach(e=>this._deletePendingTile(e)),this._pendingTiles.clear(),this.store.destroy(),this.tilesOfInterest.length=0,this._updatingHandles.destroy()}refresh(){this.store.refresh(),this._pendingTiles.forEach(e=>this._deletePendingTile(e)),this._process()}async handleEdits(e){if(e.historicMoment&&(this._historicMoment=e.historicMoment),!e.addedFeatures.length&&!e.updatedFeatures.length&&!e.deletedFeatures.length)return;for(const s of this._pendingTiles.values())s.reset();const t={...e,deletedFeatures:e.deletedFeatures.map(({objectId:e,globalId:t})=>e&&-1!==e?e:this._lookupObjectIdByGlobalId(t))},i=s(async e=>{try{await this.store.processEdits(t,(e,t)=>this._queryFeaturesById(e,t),e),this._processPendingTiles()}catch(i){o(i),r.getLogger(this).warn("Failed to apply edits",i)}});this.addHandles(i),await this._updatingHandles.addPromise(i.promise)}setHistoricMoment(e){e?.getTime()!==this._historicMoment?.getTime()&&(this._historicMoment=e,this.refresh())}_initializeFetchExtent(){if(!this.capabilities.query.supportsExtent||!b(this.url))return;const e=s(async e=>{try{const t=await P(this.url,new O({where:"1=1",outSpatialReference:this.spatialReference,cacheHint:this.capabilities.query.supportsCacheHint??void 0}),{query:this._configuration.customParameters,signal:e});this.store.extent=f.fromJSON(t?.extent)}catch(t){o(t),r.getLogger(this).warn("Failed to fetch data extent",t)}});this._updatingHandles.addPromise(e.promise.then(()=>this._process())),this.addHandles(e)}get debugInfo(){return{numberOfFeatures:this.store.featureStore.numFeatures,tilesOfInterest:this.tilesOfInterest,pendingTiles:Array.from(this._pendingTiles.values()).map(e=>e.debugInfo),storedTiles:this.store.debugInfo}}_process(){this._markTilesNotAlive(),this._createPendingTiles(),this._deletePendingTiles(),this._processPendingTiles()}_markTilesNotAlive(){for(const e of this._pendingTiles.values())e.alive=!1}_createPendingTiles(){if(this.suspended)return;const e=this._collectMissingTilesInfo();if(this._setAvailability(null==e?1:e.coveredArea/e.fullArea),null!=e)for(const{data:t,resolution:i}of e.missingTiles){const e=this._pendingTiles.get(t.id);e?(e.resolution=i,e.alive=!0):this._createPendingTile(t,i)}}_collectMissingTilesInfo(){let e=null;for(const t of this.tilesOfInterest){const i=this.store.process(t,(e,t)=>this._verifyTileComplexity(e,t),this.outFields);null==e?e=i:e.prepend(i)}return e}_deletePendingTiles(){for(const e of this._pendingTiles.values())e.alive||this._deletePendingTile(e)}_processPendingTiles(){const e={fetchCount:(e,t)=>this._fetchCount(e,t),fetchFeatures:(e,t,i)=>this._fetchFeatures(e,t,i),finish:(e,t)=>this._finishPendingTile(e,t),resume:()=>this._processPendingTiles()};if(this._ensureFetchAllCounts(e))for(const t of this._pendingTiles.values())this._verifyTileComplexity(this.store.getFeatureCount(t.key),t.resolution)&&this._updatingHandles.addPromise(t.process(e))}_verifyTileComplexity(e,t){return this._verifyVertexComplexity(e)&&this._verifyFeatureDensity(e,t)}_verifyVertexComplexity(e){return e*this._minimumVerticesPerFeature<C}_verifyFeatureDensity(e,t){if(null==this.tileInfo)return!1;const i=this.tileSize*t;return e*(q/(i*i))<M}_ensureFetchAllCounts(e){let t=!0;for(const i of this._pendingTiles.values())i.state.type<2&&this._updatingHandles.addPromise(i.process(e)),i.state.type<=1&&(t=!1);return t}_finishPendingTile(e,t){this.store.add(e.key,t),this._deletePendingTile(e),this._updateAvailability()}_updateAvailability(){const e=this._collectMissingTilesInfo();this._setAvailability(null==e?1:e.coveredArea/e.fullArea)}_setAvailability(e){this._set("availability",e)}_createPendingTile(e,t){const i=new S(e,t);return this._pendingTiles.set(e.id,i),i}_deletePendingTile(e){e.reset(),this._pendingTiles.delete(e.key.id)}async _fetchCount(e,t){return this.store.fetchCount(e.key,this.url,this._createCountQuery(e),{query:this.customParameters,timeout:x,signal:t})}async _fetchFeatures(e,t,i){let s=0;const r=[];let o=0,n=t;for(;;){const a=this._createFeaturesQuery(e),l=this._setPagingParameters(a,s,n),{features:u,exceededTransferLimit:c}=await this._queryFeatures(a,i);l&&(s+=a.num),o+=u.length;for(const e of u)r.push(e);if(n=t-o,!l||!c||n<=0)return r}}_filterProperties(e){return null==e?{where:"1=1",gdbVersion:void 0,timeExtent:void 0}:{where:e.where||"1=1",timeExtent:e.timeExtent,gdbVersion:e.gdbVersion}}_lookupObjectIdByGlobalId(e){const t=this.globalIdField,i=this.objectIdField;if(null==t)throw new Error("Expected globalIdField to be defined");let s=null;const r=e?d(e):e;if(this.store.featureStore.forEach(e=>{r===d(e.attributes[t])&&(s=e.objectId??e.attributes[i])}),null==s)throw new Error(`Expected to find a feature with globalId ${e}`);return s}_queryFeaturesById(e,t){const i=this._createFeaturesQuery();return i.objectIds=e,this._queryFeatures(i,t)}async _queryFeatures(e,t){return 0===e.num?new F:this.capabilities.query.supportsFormatPBF?this._queryFeaturesPBF(e,t):this._queryFeaturesJSON(e,t)}async _queryFeaturesPBF(e,t){const{sourceSpatialReference:i}=this,s=await v(this.url,e,new T({sourceSpatialReference:i}),{query:this._configuration.customParameters,timeout:x,signal:t});return _(s)}async _queryFeaturesJSON(e,t){const{sourceSpatialReference:i}=this,s=await I(this.url,e,i,{query:this._configuration.customParameters,timeout:x,signal:t});return g(s,{type:"object-id",fieldName:this.objectIdField})}_createCountQuery(e){const t=this._createBaseQuery(e);return this.capabilities.query.supportsCacheHint&&(t.cacheHint=!0),t}_createFeaturesQuery(e=null){const t=this._createBaseQuery(e),i=null!=e?.key?this.store.getAttributesForTile(e?.key?.id):null,s=a(c(this.outFields,i??new Set),this._mandatoryOutFields);return t.outFields=Array.from(s),t.returnGeometry=!0,null!=e&&(this.capabilities.query.supportsResultType?t.resultType="tile":this.capabilities.query.supportsCacheHint&&(t.cacheHint=!0)),t}_createBaseQuery(e){const t=new O({returnZ:this.hasZ,returnM:!1,historicMoment:this._historicMoment,geometry:null!=this.tileInfo&&null!=e?m(e.key.extent,this.tileInfo.spatialReference):void 0}),i=this._configuration.filter;return null!=i&&(t.where=i.where,t.gdbVersion=i.gdbVersion,t.timeExtent=i.timeExtent),t.outSpatialReference=this.spatialReference,t}_setPagingParameters(e,t,i){if(!this.capabilities.query.supportsPagination)return!1;const{supportsMaxRecordCountFactor:s,supportsCacheHint:r,tileMaxRecordCount:o,maxRecordCount:n,supportsResultType:a}=this.capabilities.query,l=s?O.MAX_MAX_RECORD_COUNT_FACTOR:1,u=l*((a||r)&&o?o:n||w);return e.start=t,s?(e.maxRecordCountFactor=Math.min(l,Math.ceil(i/u)),e.num=Math.min(i,e.maxRecordCountFactor*u)):e.num=Math.min(i,u),!0}};e([h({constructOnly:!0})],j.prototype,"url",void 0),e([h({constructOnly:!0})],j.prototype,"objectIdField",void 0),e([h({constructOnly:!0})],j.prototype,"globalIdField",void 0),e([h({constructOnly:!0})],j.prototype,"capabilities",void 0),e([h({constructOnly:!0})],j.prototype,"sourceSpatialReference",void 0),e([h({constructOnly:!0})],j.prototype,"spatialReference",void 0),e([h({constructOnly:!0})],j.prototype,"store",void 0),e([h({readOnly:!0})],j.prototype,"_minimumVerticesPerFeature",null),e([h()],j.prototype,"_mandatoryOutFields",null),e([h()],j.prototype,"outFields",null),e([h()],j.prototype,"suspended",void 0),e([h()],j.prototype,"_historicMoment",void 0),e([h()],j.prototype,"filter",null),e([h()],j.prototype,"customParameters",null),e([h({readOnly:!0})],j.prototype,"_configuration",null),e([h()],j.prototype,"tileInfo",null),e([h()],j.prototype,"tileSize",null),e([h()],j.prototype,"tilesOfInterest",void 0),e([h({readOnly:!0})],j.prototype,"updating",null),e([h({readOnly:!0})],j.prototype,"availability",void 0),e([h()],j.prototype,"hasZ",null),j=e([p("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceTiledFetcher")],j);const w=2e3,x=6e5,C=1e6,q=25,M=1;export{j as FeatureServiceTiledFetcher};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import r from"../../../../../core/Accessor.js";import{property as t}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as o}from"../../../../../core/accessorSupport/decorators/subclass.js";import s from"../../../../../geometry/Point.js";import{fromValues as i}from"../../../../../geometry/support/aaBoundingRect.js";import p from"../../../../../layers/support/LOD.js";import l from"../../../../../layers/support/TileInfo.js";import{TileKey as n}from"../../../../../layers/support/TileKey.js";let a=class extends r{get tiles(){return[new n(0,0,0,i(-1e8,-1e8,1e8,1e8))]}get tileInfo(){return new l({origin:new s({x:-1e8,y:1e8,spatialReference:this.layer.spatialReference}),size:[512,512],lods:[new p({level:0,scale:1,resolution:390625})],spatialReference:this.layer.spatialReference})}get tileSize(){return this.tileInfo.size[0]}constructor(e){super(e),this.pointOfInterest=null}};e([t({readOnly:!0})],a.prototype,"tiles",null),e([t({readOnly:!0})],a.prototype,"tileInfo",null),e([t({readOnly:!0})],a.prototype,"tileSize",null),e([t({constructOnly:!0})],a.prototype,"layer",void 0),e([t()],a.prototype,"pointOfInterest",void 0),a=e([o("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceTilesSimple")],a);export{a as FeatureServiceTilesSimple};
5
+ import{__decorate as e}from"tslib";import r from"../../../../../core/Accessor.js";import{property as t}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as o}from"../../../../../core/accessorSupport/decorators/subclass.js";import s from"../../../../../geometry/Point.js";import{fromValues as i}from"../../../../../geometry/support/aaBoundingRect.js";import p from"../../../../../layers/support/LOD.js";import l from"../../../../../layers/support/TileInfo.js";import{TileKey as n}from"../../../../../layers/support/TileKey.js";let a=class extends r{get tiles(){return[new n(0,0,0,i(-1e8,-1e8,1e8,1e8))]}get tileInfo(){return new l({origin:new s({x:-1e8,y:1e8,spatialReference:this.layer.spatialReference}),size:[512,512],lods:[new p({level:0,scale:1,resolution:390625})],spatialReference:this.layer.spatialReference})}get tileSize(){return this.tileInfo.size[0]}constructor(e){super(e),this.pointOfInterest=null,this.updating=!1}};e([t({readOnly:!0})],a.prototype,"tiles",null),e([t({readOnly:!0})],a.prototype,"tileInfo",null),e([t({readOnly:!0})],a.prototype,"tileSize",null),e([t({constructOnly:!0})],a.prototype,"layer",void 0),e([t()],a.prototype,"pointOfInterest",void 0),e([t()],a.prototype,"updating",void 0),a=e([o("esri.views.interactive.snapping.featureSources.featureServiceSource.FeatureServiceTilesSimple")],a);export{a as FeatureServiceTilesSimple};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{neverReached as t}from"../../core/compilerUtils.js";import e from"../../core/Logger.js";import{isAborted as s,createAbortError as r,isPromiseLike as o}from"../../core/promiseUtils.js";import{signal as a}from"../../core/signal.js";import{Yield as n}from"./Yield.js";class i{constructor(){this._tasks=new Array,this._numPendingTasks=a(0),this._readyToRun=a(!1)}get length(){return this._tasks.length}get updating(){return this._numPendingTasks.value>0}get readyToRun(){return this._readyToRun.value}_updateReadyToRun(){this._readyToRun.value=this._tasks.length>0}destroy(){this.cancelAll()}runTask(t){if(0===this.length)return n;for(;!t.done&&this._process(t);)t.madeProgress()}push(t,e,s){return this._addTask((r,o)=>new u(r,o,t,e,s),Array.prototype.push)}unshift(t,e,s){return this._addTask((r,o)=>new u(r,o,t,e,s),Array.prototype.unshift)}pushGenerator(t,e,s){return this._addTask((r,o)=>new p(r,o,t,e,s),Array.prototype.push)}_process(e){if(0===this._tasks.length)return!1;const o=this._tasks.shift();this._updateReadyToRun();try{if(s(o.signal))this._cancelTask(o,r());else switch(o.type){case 0:this._processSimple(o,e);break;case 1:this._processGenerator(o,e);break;case 2:this._processIterator(o,e);break;default:t(o)}}catch(a){o.reject(a)}return!0}cancelAll(){const t=r();for(const e of this._tasks)this._cancelTask(e,t);this._tasks.length=0,this._updateReadyToRun()}_cancelTask(t,e){if(t.abortCallback){const s=t.abortCallback(e);2===t.type&&t.iterator.return&&c(t.iterator.return()),o(s)?s.then(t.resolve,t.reject):t.resolve(s)}else 2===t.type&&t.iterator.throw&&c(t.iterator.throw(e)),t.reject(e)}_onIteratorResult(t,e){e.done?t.resolve(e.value):(this._tasks.unshift(t),this._updateReadyToRun())}_processSimple(t,e){const s=t.callback(e);o(s)?s.then(t.resolve,t.reject):t.resolve(s)}_processGenerator(t,e){const s=t.generatorFunction(e),r=new d(t.resolve,t.reject,s,t.signal,t.abortCallback);this._processIterator(r,e)}_processIterator(t,e){const s=t.iterator.next(e);o(s)?s.then(e=>this._onIteratorResult(t,e),t.reject):this._onIteratorResult(t,s)}_addTask(t,e){return new Promise((s,r)=>{const o=t(s,r);e.call(this._tasks,o),++this._numPendingTasks.value,this._updateReadyToRun()}).finally(()=>--this._numPendingTasks.value)}}function c(t){o(t)?t.then(h):h(t)}function h(t){t.done||e.getLogger("esri.layers.support.PromiseQueue").warn("Generator iterator was aborted, but it is not done.")}class l{constructor(t,e,s=void 0,r=void 0){this.resolve=t,this.reject=e,this.signal=s,this.abortCallback=r}}class u extends l{constructor(t,e,s,r,o){super(t,e,r,o),this.callback=s,this.type=0}}class p extends l{constructor(t,e,s,r,o){super(t,e,r,o),this.generatorFunction=s,this.type=1}}class d extends l{constructor(t,e,s,r,o){super(t,e,r,o),this.iterator=s,this.type=2}}export{i as PromiseQueue};
5
+ import{neverReached as t}from"../../core/compilerUtils.js";import e from"../../core/Error.js";import s from"../../core/Logger.js";import{isAborted as r,createAbortError as o,isPromiseLike as a,isAbortError as n}from"../../core/promiseUtils.js";import{signal as i}from"../../core/signal.js";import{Yield as c}from"./Yield.js";class l{constructor(){this._tasks=new Array,this._numPendingTasks=i(0),this._readyToRun=i(!1)}get length(){return this._tasks.length}get updating(){return this._numPendingTasks.value>0}get readyToRun(){return this._readyToRun.value}_updateReadyToRun(){this._readyToRun.value=this._tasks.length>0}destroy(){this.cancelAll()}runTask(t){if(0===this.length)return c;for(;!t.done&&this._process(t);)t.madeProgress()}push(t,e,s){return this._addTask((r,o)=>new d(r,o,t,e,s),Array.prototype.push)}unshift(t,e,s){return this._addTask((r,o)=>new d(r,o,t,e,s),Array.prototype.unshift)}pushGenerator(t,e,s){return this._addTask((r,o)=>new _(r,o,t,e,s),Array.prototype.push)}_process(e){if(0===this._tasks.length)return!1;const s=this._tasks.shift();this._updateReadyToRun();try{if(r(s.signal))this._cancelTask(s,o());else switch(s.type){case 0:this._processSimple(s,e);break;case 1:this._processGenerator(s,e);break;case 2:this._processIterator(s,e);break;default:t(s)}}catch(a){s.reject(a)}return!0}cancelAll(){const t=o();for(const e of this._tasks)this._cancelTask(e,t);this._tasks.length=0,this._updateReadyToRun()}_cancelTask(t,e){if(t.abortCallback){const s=t.abortCallback(e);2===t.type&&t.iterator.return&&h(t.iterator.return()),a(s)?s.then(t.resolve,t.reject):t.resolve(s)}else 2===t.type&&t.iterator.throw&&h(t.iterator.throw(e)),t.reject(e)}_onIteratorResult(t,e){e.done?t.resolve(e.value):(this._tasks.unshift(t),this._updateReadyToRun())}_processSimple(t,e){const s=t.callback(e);a(s)?s.then(t.resolve,t.reject):t.resolve(s)}_processGenerator(t,e){const s=t.generatorFunction(e),r=new k(t.resolve,t.reject,s,t.signal,t.abortCallback);this._processIterator(r,e)}_processIterator(t,e){const s=t.iterator.next(e);a(s)?s.then(e=>this._onIteratorResult(t,e),t.reject):this._onIteratorResult(t,s)}_addTask(t,e){return new Promise((s,r)=>{const o=t(s,r);e.call(this._tasks,o),++this._numPendingTasks.value,this._updateReadyToRun()}).finally(()=>--this._numPendingTasks.value)}}function h(t){a(t)?t.then(u,u):u(t)}function u(t){n(t)||t instanceof Error||t instanceof e||null!=t&&"object"==typeof t&&"done"in t&&t.done||s.getLogger("esri.layers.support.PromiseQueue").warn("Generator iterator was aborted, but it is not done.")}class p{constructor(t,e,s=void 0,r=void 0){this.resolve=t,this.reject=e,this.signal=s,this.abortCallback=r}}class d extends p{constructor(t,e,s,r,o){super(t,e,r,o),this.callback=s,this.type=0}}class _ extends p{constructor(t,e,s,r,o){super(t,e,r,o),this.generatorFunction=s,this.type=1}}class k extends p{constructor(t,e,s,r,o){super(t,e,r,o),this.iterator=s,this.type=2}}export{l as PromiseQueue};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{removeUnordered as e,filterInPlace as t}from"../../core/arrayUtils.js";import s from"../../core/Handles.js";import"../../core/has.js";import r from"../../core/Logger.js";import{removeMaybe as i}from"../../core/maybe.js";import{recordPerformance as a}from"../../core/performance.js";import n from"../../core/PerformanceSampler.js";import{isAborted as u,createAbortError as _,when as h,isPromiseLike as o}from"../../core/promiseUtils.js";import{watch as E,initial as d,when as T}from"../../core/reactiveUtils.js";import{signal as c}from"../../core/signal.js";import{Milliseconds as m}from"../../core/time.js";import l from"./debugFlags.js";import{PromiseQueue as g}from"./PromiseQueue.js";import{Yield as R}from"./Yield.js";function I(){return new U}const f={RESOURCE_CONTROLLER_IMMEDIATE:"immediate",RESOURCE_CONTROLLER:"schedule",SLIDE:"slide",STREAM_DATA_LOADER:"stream loader",ELEVATION_QUERY:"elevation query",TERRAIN_SURFACE:"terrain",SURFACE_GEOMETRY_UPDATES:"surface geometry updates",LOD_RENDERER:"LoD renderer",GRAPHICS_CORE:"Graphics3D",I3S_CONTROLLER:"I3S",POINT_CLOUD_LAYER:"point cloud",FEATURE_TILE_FETCHER:"feature fetcher",STREAM_CONTROLLER:"stream controller",OVERLAY:"overlay",OVERLAY_RENDERER:"overlay renderer",STAGE:"stage",GRAPHICS_DECONFLICTOR:"graphics deconflictor",FILTER_VISIBILITY:"graphics filter visibility",SCALE_VISIBILITY:"graphics scale visibility",FRUSTUM_VISIBILITY:"graphics frustum visibility",POINT_OF_INTEREST_FREQUENT:"POI frequent",POINT_OF_INTEREST_INFREQUENT:"POI infrequent",LABELER:"labeler",FEATURE_QUERY_ENGINE:"feature query",FEATURE_TILE_TREE:"feature tile tree",FEATURE_TILE_TREE_ACTIVE:"fast feature tile tree",ELEVATION_ALIGNMENT:"elevation alignment",ELEVATION_ALIGNMENT_SCENE:"elevation alignment scene",TEXT_TEXTURE_ATLAS:"text texture atlas",TEXTURE_UNLOAD:"texture unload",LINE_OF_SIGHT_TOOL:"line of sight tool",LINE_OF_SIGHT_TOOL_INTERACTIVE:"interactive line of sight tool",ELEVATION_PROFILE:"elevation profile",SNAPPING:"snapping",SHADOW_ACCUMULATOR:"shadow accumulator",CLOUDS_GENERATOR:"clouds generator",FLOW_GENERATOR:"flow generator",MAPVIEW_FETCH_QUEUE:"mapview fetch queue",MAPVIEW_LAYERVIEW_UPDATE:"mapview layerview update",MAPVIEW_VECTOR_TILE_PARSING_QUEUE:"mapview vector tile parsing queue",NONE:0,TEST_PRIO:1},p=0,L=new Map([[f.RESOURCE_CONTROLLER_IMMEDIATE,p],[f.RESOURCE_CONTROLLER,4],[f.SLIDE,p],[f.STREAM_DATA_LOADER,p],[f.ELEVATION_QUERY,p],[f.TERRAIN_SURFACE,1],[f.SURFACE_GEOMETRY_UPDATES,1],[f.LOD_RENDERER,2],[f.GRAPHICS_CORE,2],[f.I3S_CONTROLLER,2],[f.POINT_CLOUD_LAYER,2],[f.FEATURE_TILE_FETCHER,2],[f.STREAM_CONTROLLER,2],[f.CLOUDS_GENERATOR,2],[f.OVERLAY,4],[f.OVERLAY_RENDERER,4],[f.STAGE,4],[f.GRAPHICS_DECONFLICTOR,4],[f.FILTER_VISIBILITY,4],[f.SCALE_VISIBILITY,4],[f.FRUSTUM_VISIBILITY,4],[f.POINT_OF_INTEREST_FREQUENT,6],[f.POINT_OF_INTEREST_INFREQUENT,30],[f.LABELER,8],[f.FEATURE_QUERY_ENGINE,8],[f.FEATURE_TILE_TREE,16],[f.FEATURE_TILE_TREE_ACTIVE,p],[f.ELEVATION_ALIGNMENT,12],[f.ELEVATION_ALIGNMENT_SCENE,14],[f.TEXT_TEXTURE_ATLAS,12],[f.TEXTURE_UNLOAD,12],[f.LINE_OF_SIGHT_TOOL,16],[f.LINE_OF_SIGHT_TOOL_INTERACTIVE,p],[f.SNAPPING,p],[f.SHADOW_ACCUMULATOR,30],[f.FLOW_GENERATOR,12],[f.MAPVIEW_FETCH_QUEUE,p],[f.MAPVIEW_LAYERVIEW_UPDATE,2],[f.MAPVIEW_VECTOR_TILE_PARSING_QUEUE,p]]);function A(e){return L.has(e)?L.get(e):"number"==typeof e?e:1}const O=m(6.5),N=m(1),b=m(30),k=m(1e3/30),S=m(100),P=.9;class U{get updating(){return this._updating.value}_updatingChanged(){this._updating.value=this._tasks.some(e=>e.needsUpdate)}constructor(){this._updating=c(!0),this._microTaskQueued=!1,this._frameNumber=0,this.performanceInfo={total:new n("total"),tasks:new Map},this._frameTaskTimes=new Map,this._budget=new F,this.state=1,this._tasks=new Array,this._runQueue=new Array,this._load=0,this._forceTask=!1,this._debug=!1,this._debugHandle=E(()=>l.SCHEDULER_LOG_SLOW_TASKS,e=>this._debug=e,d);for(const e of Object.keys(f))this.performanceInfo.tasks.set(f[e],new n(String(f[e])))}destroy(){this._tasks.forEach(e=>e.remove()),this._tasks.length=0,this._runQueue.length=0,i(this._debugHandle),this._microTaskQueued=!1,this._updatingChanged()}taskRunningChanged(e){this._updatingChanged(),e&&this._budget.remaining>0&&!this._microTaskQueued&&(this._microTaskQueued=!0,queueMicrotask(()=>{this._microTaskQueued&&(this._microTaskQueued=!1,this._budget.remaining>0&&this._schedule()&&this._runFrame())}))}registerTask(e,t){const s=new C(this,e,t);return this._tasks.push(s),this._updatingChanged(),this.performanceInfo.tasks.has(e)||this.performanceInfo.tasks.set(e,new n(e)),s}get load(){return this._load}frame(e){if(this._startFrameTaskTimes(),this._updateBudget(e)){const e=this._budget.now();this._runFrame();const t=this._budget.now();this._recordFrameTaskTimes(t-e);const s=2===this.state?"Idle":1===this.state?"Interacting":"Animating";return a(`${s} Frame Tasks`,e,t,"Maps SDK","Scheduling"),!0}return this._recordFrameTaskTimes(0),!1}_updateBudget(e){this._test&&(this._test.usedBudget=0),++this._frameNumber;let t=O,s=e.frameDuration,r=N;switch(this.state){case 2:t=m(0),s=m(Math.max(S,e.frameDuration)),r=b;break;case 1:s=m(Math.max(k,e.frameDuration))}return s=m(s-e.elapsedFrameTime-t),2!==this.state&&s<N&&!this._forceTask?(this._forceTask=!0,!1):(s=m(Math.max(s,r)),this._budget.reset(s),this._updateLoad(),this._schedule())}_runFrame(){switch(this._forceTask=!1,this._microTaskQueued=!1,this.state){case 2:this._runIdle();break;case 1:this._runInteracting();break;default:this._runAnimating()}this._test&&(this._test.usedBudget=this._budget.elapsed)}stopFrame(){this._budget.reset(m(0)),this._budget.madeProgress()}removeTask(t){e(this._tasks,t),e(this._runQueue,t),this._updatingChanged()}_updateTask(e){this._tasks.forEach(t=>{t.name===e&&t.setPriority(e)})}_getState(e){if(this._runQueue.some(t=>t.name===e))return"s";let t="i";return this._tasks.forEach(s=>{s.name===e&&s.needsUpdate&&(s.schedulePriority<=1?t="r":"r"!==t&&(t="w"))}),t}_getRuntime(e){let t=0;return this._tasks.forEach(s=>{s.name===e&&(t+=s.runtime)}),t}_resetRuntimes(){this._tasks.forEach(e=>e.runtime=0)}_getRunning(){const e=new Map;if(this._tasks.forEach(t=>{t.needsUpdate&&e.set(t.name,(e.get(t.name)||0)+1)}),0===e.size)return null;let t="";return e.forEach((e,s)=>{t+=e>1?` ${e}x ${s}`:` ${s}`}),t}_runIdle(){this._run()}_runInteracting(){this._run()}_runAnimating(){this._run()}_updateLoad(){const e=this._tasks.reduce((e,t)=>t.needsUpdate?++e:e,0);this._load=this._load*P+e*(1-P)}_schedule(){for(t(this._runQueue,e=>!!e.needsUpdate||(e.schedulePriority=e.basePriority,!1)),this._tasks.forEach(e=>{e.basePriority===p&&e.needsUpdate&&!this._runQueue.includes(e)&&e.blockFrame!==this._frameNumber&&this._runQueue.unshift(e)});0===this._runQueue.length;){let e=!1,t=0;if(this._tasks.forEach(s=>{if(s.needsUpdate&&0!==s.schedulePriority&&s.basePriority!==p&&s.blockFrame!==this._frameNumber)if(e=!0,t=Math.max(t,s.basePriority),1===s.schedulePriority)s.schedulePriority=0,this._runQueue.push(s);else--s.schedulePriority}),!e)return this._updatingChanged(),!1}return this._updatingChanged(),!0}_run(){do{for(;this._runQueue.length>0;){const t=this._budget.now(),s=this._runQueue.pop();this._budget.resetProgress();try{s.task.runTask(this._budget)===R&&(s.blockFrame=this._frameNumber)}catch(e){r.getLogger("esri.views.support.Scheduler").error(`Exception in task "${s.name}"`,e),s.blockFrame=this._frameNumber}!this._budget.hasProgressed&&s.blockFrame!==this._frameNumber&&s.needsUpdate&&(s.name,f.I3S_CONTROLLER,s.blockFrame=this._frameNumber),s.schedulePriority=s.basePriority;const i=this._budget.now(),n=i-t;if(a(`${s.name}`,t,i,"Maps SDK","Scheduling"),s.runtime+=n,this._frameTaskTimes.set(s.priority,this._frameTaskTimes.get(s.priority)+n),this._budget.remaining<=0)return void this._updatingChanged()}}while(this._schedule());this._updatingChanged()}_startFrameTaskTimes(){for(const e of Object.keys(f))this._frameTaskTimes.set(f[e],0)}_recordFrameTaskTimes(e){this._frameTaskTimes.forEach((e,t)=>this.performanceInfo.tasks.get(t).push(e)),this.performanceInfo.total.push(e)}get test(){return this._test}}class C{get task(){return this._task.value}get readyToRun(){return this._queue.readyToRun}get updating(){return this._queue.updating}constructor(e,t,r){this._scheduler=e,this.name=t,this.blockFrame=0,this.runtime=0,this._queue=new g,this._handles=new s,this._basePriority=A(t),this.schedulePriority=this._basePriority,this._task=c(null!=r?r:this._queue),this._handles.add(T(()=>this.task.readyToRun,t=>e.taskRunningChanged(t)))}remove(){this.processQueue(y),this._scheduler.removeTask(this),this.schedule=M.schedule,this.reschedule=M.reschedule,this.scheduleGenerator=M.scheduleGenerator,this._handles.destroy()}get basePriority(){return this._basePriority}setPriority(e){if(this.name===e)return;this.name=e;const t=A(e);this._basePriority!==p&&0===this.schedulePriority||(this.schedulePriority=t),this._basePriority=t}get priority(){return this.name}set priority(e){this.setPriority(e)}get needsUpdate(){return this.readyToRun||!this.task.destroyed&&this.task.readyToRun}schedule(e,t,s){return this._queue.push(e,t,s)}reschedule(e,t,s){return this._queue.unshift(e,t,s)}scheduleGenerator(e,t,s){return this._queue.pushGenerator(e,t,s)}processQueue(e){return this._queue.runTask(e)}}class F{constructor(){this._begin=performance?.now()??0,this._budget=0,this._done=!1,this._progressed=!1,this._enabled=!0}run(e){return!this.done&&(!0===e()&&this.madeProgress(),!0)}get done(){return this._done}get budget(){return this._budget}madeProgress(){return this._progressed=!0,this._done=this.elapsed>=this._budget&&this._enabled,this._done}get enabled(){return this._enabled}set enabled(e){this._enabled=e}reset(e){this._begin=this.now(),this._budget=e,this.resetProgress()}get remaining(){return Math.max(this._budget-this.elapsed,0)}now(){return performance.now()}get elapsed(){return this.now()-this._begin}resetProgress(){this._progressed=!1,this._done=!1}get hasProgressed(){return this._progressed}}const y=new F;function w(e){const t=new F;return t.reset(e),t}y.enabled=!1;class D{remove(){}processQueue(){}schedule(e,t,s){try{if(u(t)){const e=_();return s?Promise.resolve(s(e)):Promise.reject(e)}return h(e(y))}catch(r){return Promise.reject(r)}}reschedule(e,t,s){return this.schedule(e,t,s)}async scheduleGenerator(e,t,s){if(u(t)){const e=_();if(s)return s(e);throw e}const r=e(y);for(;;){const e=r.next(y),i=o(e)?await e:e;if(u(t)){const e=_();if(s){const t=s(e);return r.return(null),t}throw r.throw(e),e}if(i.done)return i.value}}}const M=new D;export{M as ImmediateTask,f as TaskPriority,A as getTaskPriority,w as makeBudget,I as newScheduler,y as noBudget,L as taskPriorities};
5
+ import{removeUnordered as e,filterInPlace as t}from"../../core/arrayUtils.js";import s from"../../core/Handles.js";import"../../core/has.js";import r from"../../core/Logger.js";import{removeMaybe as i}from"../../core/maybe.js";import{recordPerformance as a}from"../../core/performance.js";import n from"../../core/PerformanceSampler.js";import{isAborted as u,createAbortError as _,when as h,isPromiseLike as o,ignoreAbortErrors as E}from"../../core/promiseUtils.js";import{watch as d,initial as T,when as c}from"../../core/reactiveUtils.js";import{signal as m}from"../../core/signal.js";import{Milliseconds as l}from"../../core/time.js";import g from"./debugFlags.js";import{PromiseQueue as R}from"./PromiseQueue.js";import{Yield as I}from"./Yield.js";function f(){return new C}const p={RESOURCE_CONTROLLER_IMMEDIATE:"immediate",RESOURCE_CONTROLLER:"schedule",SLIDE:"slide",STREAM_DATA_LOADER:"stream loader",ELEVATION_QUERY:"elevation query",TERRAIN_SURFACE:"terrain",SURFACE_GEOMETRY_UPDATES:"surface geometry updates",LOD_RENDERER:"LoD renderer",GRAPHICS_CORE:"Graphics3D",I3S_CONTROLLER:"I3S",POINT_CLOUD_LAYER:"point cloud",FEATURE_TILE_FETCHER:"feature fetcher",STREAM_CONTROLLER:"stream controller",OVERLAY:"overlay",OVERLAY_RENDERER:"overlay renderer",STAGE:"stage",GRAPHICS_DECONFLICTOR:"graphics deconflictor",FILTER_VISIBILITY:"graphics filter visibility",SCALE_VISIBILITY:"graphics scale visibility",FRUSTUM_VISIBILITY:"graphics frustum visibility",POINT_OF_INTEREST_FREQUENT:"POI frequent",POINT_OF_INTEREST_INFREQUENT:"POI infrequent",LABELER:"labeler",FEATURE_QUERY_ENGINE:"feature query",FEATURE_TILE_TREE:"feature tile tree",FEATURE_TILE_TREE_ACTIVE:"fast feature tile tree",ELEVATION_ALIGNMENT:"elevation alignment",ELEVATION_ALIGNMENT_SCENE:"elevation alignment scene",TEXT_TEXTURE_ATLAS:"text texture atlas",TEXTURE_UNLOAD:"texture unload",LINE_OF_SIGHT_TOOL:"line of sight tool",LINE_OF_SIGHT_TOOL_INTERACTIVE:"interactive line of sight tool",ELEVATION_PROFILE:"elevation profile",SNAPPING:"snapping",SHADOW_ACCUMULATOR:"shadow accumulator",CLOUDS_GENERATOR:"clouds generator",FLOW_GENERATOR:"flow generator",MAPVIEW_FETCH_QUEUE:"mapview fetch queue",MAPVIEW_LAYERVIEW_UPDATE:"mapview layerview update",MAPVIEW_VECTOR_TILE_PARSING_QUEUE:"mapview vector tile parsing queue",NONE:0,TEST_PRIO:1},L=0,A=new Map([[p.RESOURCE_CONTROLLER_IMMEDIATE,L],[p.RESOURCE_CONTROLLER,4],[p.SLIDE,L],[p.STREAM_DATA_LOADER,L],[p.ELEVATION_QUERY,L],[p.TERRAIN_SURFACE,1],[p.SURFACE_GEOMETRY_UPDATES,1],[p.LOD_RENDERER,2],[p.GRAPHICS_CORE,2],[p.I3S_CONTROLLER,2],[p.POINT_CLOUD_LAYER,2],[p.FEATURE_TILE_FETCHER,2],[p.STREAM_CONTROLLER,2],[p.CLOUDS_GENERATOR,2],[p.OVERLAY,4],[p.OVERLAY_RENDERER,4],[p.STAGE,4],[p.GRAPHICS_DECONFLICTOR,4],[p.FILTER_VISIBILITY,4],[p.SCALE_VISIBILITY,4],[p.FRUSTUM_VISIBILITY,4],[p.POINT_OF_INTEREST_FREQUENT,6],[p.POINT_OF_INTEREST_INFREQUENT,30],[p.LABELER,8],[p.FEATURE_QUERY_ENGINE,8],[p.FEATURE_TILE_TREE,16],[p.FEATURE_TILE_TREE_ACTIVE,L],[p.ELEVATION_ALIGNMENT,12],[p.ELEVATION_ALIGNMENT_SCENE,14],[p.TEXT_TEXTURE_ATLAS,12],[p.TEXTURE_UNLOAD,12],[p.LINE_OF_SIGHT_TOOL,16],[p.LINE_OF_SIGHT_TOOL_INTERACTIVE,L],[p.SNAPPING,L],[p.SHADOW_ACCUMULATOR,30],[p.FLOW_GENERATOR,12],[p.MAPVIEW_FETCH_QUEUE,L],[p.MAPVIEW_LAYERVIEW_UPDATE,2],[p.MAPVIEW_VECTOR_TILE_PARSING_QUEUE,L]]);function O(e){return A.has(e)?A.get(e):"number"==typeof e?e:1}const N=l(6.5),b=l(1),k=l(30),S=l(1e3/30),P=l(100),U=.9;class C{get updating(){return this._updating.value}_updatingChanged(){this._updating.value=this._tasks.some(e=>e.needsUpdate)}constructor(){this._updating=m(!0),this._microTaskQueued=!1,this._frameNumber=0,this.performanceInfo={total:new n("total"),tasks:new Map},this._frameTaskTimes=new Map,this._budget=new y,this.state=1,this._tasks=new Array,this._runQueue=new Array,this._load=0,this._forceTask=!1,this._debug=!1,this._debugHandle=d(()=>g.SCHEDULER_LOG_SLOW_TASKS,e=>this._debug=e,T);for(const e of Object.keys(p))this.performanceInfo.tasks.set(p[e],new n(String(p[e])))}destroy(){this._tasks.forEach(e=>e.remove()),this._tasks.length=0,this._runQueue.length=0,i(this._debugHandle),this._microTaskQueued=!1,this._updatingChanged()}taskRunningChanged(e){this._updatingChanged(),e&&this._budget.remaining>0&&!this._microTaskQueued&&(this._microTaskQueued=!0,queueMicrotask(()=>{this._microTaskQueued&&(this._microTaskQueued=!1,this._budget.remaining>0&&this._schedule()&&this._runFrame())}))}registerTask(e,t){const s=new F(this,e,t);return this._tasks.push(s),this._updatingChanged(),this.performanceInfo.tasks.has(e)||this.performanceInfo.tasks.set(e,new n(e)),s}get load(){return this._load}frame(e){if(this._startFrameTaskTimes(),this._updateBudget(e)){const e=this._budget.now();this._runFrame();const t=this._budget.now();this._recordFrameTaskTimes(t-e);const s=2===this.state?"Idle":1===this.state?"Interacting":"Animating";return a(`${s} Frame Tasks`,e,t,"Maps SDK","Scheduling"),!0}return this._recordFrameTaskTimes(0),!1}_updateBudget(e){this._test&&(this._test.usedBudget=0),++this._frameNumber;let t=N,s=e.frameDuration,r=b;switch(this.state){case 2:t=l(0),s=l(Math.max(P,e.frameDuration)),r=k;break;case 1:s=l(Math.max(S,e.frameDuration))}return s=l(s-e.elapsedFrameTime-t),2!==this.state&&s<b&&!this._forceTask?(this._forceTask=!0,!1):(s=l(Math.max(s,r)),this._budget.reset(s),this._updateLoad(),this._schedule())}_runFrame(){switch(this._forceTask=!1,this._microTaskQueued=!1,this.state){case 2:this._runIdle();break;case 1:this._runInteracting();break;default:this._runAnimating()}this._test&&(this._test.usedBudget=this._budget.elapsed)}stopFrame(){this._budget.reset(l(0)),this._budget.madeProgress()}removeTask(t){e(this._tasks,t),e(this._runQueue,t),this._updatingChanged()}_updateTask(e){this._tasks.forEach(t=>{t.name===e&&t.setPriority(e)})}_getState(e){if(this._runQueue.some(t=>t.name===e))return"s";let t="i";return this._tasks.forEach(s=>{s.name===e&&s.needsUpdate&&(s.schedulePriority<=1?t="r":"r"!==t&&(t="w"))}),t}_getRuntime(e){let t=0;return this._tasks.forEach(s=>{s.name===e&&(t+=s.runtime)}),t}_resetRuntimes(){this._tasks.forEach(e=>e.runtime=0)}_getRunning(){const e=new Map;if(this._tasks.forEach(t=>{t.needsUpdate&&e.set(t.name,(e.get(t.name)||0)+1)}),0===e.size)return null;let t="";return e.forEach((e,s)=>{t+=e>1?` ${e}x ${s}`:` ${s}`}),t}_runIdle(){this._run()}_runInteracting(){this._run()}_runAnimating(){this._run()}_updateLoad(){const e=this._tasks.reduce((e,t)=>t.needsUpdate?++e:e,0);this._load=this._load*U+e*(1-U)}_schedule(){for(t(this._runQueue,e=>!!e.needsUpdate||(e.schedulePriority=e.basePriority,!1)),this._tasks.forEach(e=>{e.basePriority===L&&e.needsUpdate&&!this._runQueue.includes(e)&&e.blockFrame!==this._frameNumber&&this._runQueue.unshift(e)});0===this._runQueue.length;){let e=!1,t=0;if(this._tasks.forEach(s=>{if(s.needsUpdate&&0!==s.schedulePriority&&s.basePriority!==L&&s.blockFrame!==this._frameNumber)if(e=!0,t=Math.max(t,s.basePriority),1===s.schedulePriority)s.schedulePriority=0,this._runQueue.push(s);else--s.schedulePriority}),!e)return this._updatingChanged(),!1}return this._updatingChanged(),!0}_run(){do{for(;this._runQueue.length>0;){const t=this._budget.now(),s=this._runQueue.pop();this._budget.resetProgress();try{s.task.runTask(this._budget)===I&&(s.blockFrame=this._frameNumber)}catch(e){r.getLogger("esri.views.support.Scheduler").error(`Exception in task "${s.name}"`,e),s.blockFrame=this._frameNumber}!this._budget.hasProgressed&&s.blockFrame!==this._frameNumber&&s.needsUpdate&&(s.name,p.I3S_CONTROLLER,s.blockFrame=this._frameNumber),s.schedulePriority=s.basePriority;const i=this._budget.now(),n=i-t;if(a(`${s.name}`,t,i,"Maps SDK","Scheduling"),s.runtime+=n,this._frameTaskTimes.set(s.priority,this._frameTaskTimes.get(s.priority)+n),this._budget.remaining<=0)return void this._updatingChanged()}}while(this._schedule());this._updatingChanged()}_startFrameTaskTimes(){for(const e of Object.keys(p))this._frameTaskTimes.set(p[e],0)}_recordFrameTaskTimes(e){this._frameTaskTimes.forEach((e,t)=>this.performanceInfo.tasks.get(t).push(e)),this.performanceInfo.total.push(e)}get test(){return this._test}}class F{get task(){return this._task.value}get readyToRun(){return this._queue.readyToRun}get updating(){return this._queue.updating}constructor(e,t,r){this._scheduler=e,this.name=t,this.blockFrame=0,this.runtime=0,this._queue=new R,this._handles=new s,this._basePriority=O(t),this.schedulePriority=this._basePriority,this._task=m(null!=r?r:this._queue),this._handles.add(c(()=>this.task.readyToRun,t=>e.taskRunningChanged(t)))}remove(){this.processQueue(w),this._scheduler.removeTask(this),this.schedule=Q.schedule,this.reschedule=Q.reschedule,this.scheduleGenerator=Q.scheduleGenerator,this._handles.destroy()}get basePriority(){return this._basePriority}setPriority(e){if(this.name===e)return;this.name=e;const t=O(e);this._basePriority!==L&&0===this.schedulePriority||(this.schedulePriority=t),this._basePriority=t}get priority(){return this.name}set priority(e){this.setPriority(e)}get needsUpdate(){return this.readyToRun||!this.task.destroyed&&this.task.readyToRun}schedule(e,t,s){return this._queue.push(e,t,s)}reschedule(e,t,s){return this._queue.unshift(e,t,s)}scheduleGenerator(e,t,s){return this._queue.pushGenerator(e,t,s)}processQueue(e){return this._queue.runTask(e)}}class y{constructor(){this._begin=performance?.now()??0,this._budget=0,this._done=!1,this._progressed=!1,this._enabled=!0}run(e){return!this.done&&(!0===e()&&this.madeProgress(),!0)}get done(){return this._done}get budget(){return this._budget}madeProgress(){return this._progressed=!0,this._done=this.elapsed>=this._budget&&this._enabled,this._done}get enabled(){return this._enabled}set enabled(e){this._enabled=e}reset(e){this._begin=this.now(),this._budget=e,this.resetProgress()}get remaining(){return Math.max(this._budget-this.elapsed,0)}now(){return performance.now()}get elapsed(){return this.now()-this._begin}resetProgress(){this._progressed=!1,this._done=!1}get hasProgressed(){return this._progressed}}const w=new y;function D(e){const t=new y;return t.reset(e),t}w.enabled=!1;class M{remove(){}processQueue(){}schedule(e,t,s){try{if(u(t)){const e=_();return s?Promise.resolve(s(e)):Promise.reject(e)}return h(e(w))}catch(r){return Promise.reject(r)}}reschedule(e,t,s){return this.schedule(e,t,s)}async scheduleGenerator(e,t,s){if(u(t)){const e=_();if(s)return s(e);throw e}const r=e(w);for(;;){const e=r.next(w),i=o(e)?await e:e;if(u(t)){const e=_();if(s){const t=s(e),i=r.return(null);return o(i)&&await E(i),t}const t=r.throw(e);throw o(t)&&await E(t),e}if(i.done)return i.value}}}const Q=new M;export{Q as ImmediateTask,p as TaskPriority,O as getTaskPriority,D as makeBudget,f as newScheduler,w as noBudget,A as taskPriorities};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__addDisposableResource as e,__disposeResources as t}from"tslib";import r from"../../Basemap.js";import n from"../../Ground.js";import a from"../../WebScene.js";import"../../core/has.js";import{isLongFormType as s,Null as l,Integer as y}from"../../core/accessorSupport/ensureType.js";import{isCollection as o}from"../../core/accessorSupport/extensions/serializableProperty/type.js";import i from"../../layers/GroupLayer.js";import p from"../../layers/KMLLayer.js";import{typeModuleMap as u}from"../../layers/mixins/operationalLayerModuleMap.js";import{supportedTypes as c}from"../../layers/mixins/operationalLayers.js";import f from"../../layers/support/Sublayer.js";import{JoinTableDataSource as m,DataLayerSource as d}from"../../layers/support/source/DataLayerSource.js";import{MapLayerSource as b}from"../../layers/support/source/MapLayerSource.js";import w from"../InitialViewProperties.js";import{ScanContext as j,sorted as N}from"./utils.js";import{webSceneAnalysisRegistry as g}from"../support/analysisUtils.js";import v from"../support/SlideElements.js";async function T(r){const n={stack:[],error:void 0,hasError:!1};try{const t=e(n,new j,!1);return await P(null,{typeName:"json",type:r},void 0,t)}catch(a){n.error=a,n.hasError=!0}finally{t(n)}}async function q(e,t,r,n){switch(t.typeName){case"array":await R(e,t,r,n);break;case"union":await M(e,t,r,n);break;case"json":await P(e,t,r,n);break;case"native":await h(e,t,r,n);break;case"enum":await k(e,t,r,n)}}async function h(e,t,r,n){const a=r??t;n.addProperty({name:e,type:O(n,t),default:a.default,required:a.isRequired,nullable:a.nullable})}async function k(e,t,r,n){const a=r??t;n.currentClass?.typeValue&&"type"===e?n.addProperty({name:e,type:"string",enum:`"${n.currentClass.typeValue}"`,default:a.default,required:a.isRequired,nullable:a.nullable}):n.addProperty({name:e,type:O(n,t),enum:N(t.values).map(e=>"string"==typeof e?`"${e}"`:`${e}`).join("|"),default:a.default,required:a.isRequired,nullable:a.nullable})}async function R(e,t,r,n){t.elementType.isRequired=t.isRequired,await q(`${e}[]`,t.elementType,r??t.elementType,n)}function S(e,t){if("json"===e.typeName){const t=e.type.__accessorMetadata__,r=t?.type,n=r&&U(r),a=n?.type,s=a||r?.type;if(s&&Array.isArray(s)&&1===s.length&&"string"==typeof s[0])return a?s[0]:D(r,s[0])}return t}async function M(e,t,r,n){const a=[],s=r??t;for(const l of t.types)if("native"!==l.type.typeName&&t.key){const a=`${e}<${S(l.type,l.value)}>`;await q(a,l.type,r??t,n)}else a.push(l.type);if(a.length){const t=N(a.map(e=>O(n,e)));n.addProperty({type:t.join("|"),name:e,default:s.default,required:s.isRequired,nullable:s.nullable})}}async function C(e,t){return e.type===a&&"layers"===t?_("web-scene/operational-layers","operational-layers"):e.type===a&&"tables"===t?_("web-scene/tables","tables"):e.type!==r||"baseLayers"!==t&&"baseMapLayers"!==t?e.type===r&&"groundLayers"===t?_("web-scene/basemap-ground-layers","basemap-ground-layers"):e.type===r&&"elevationLayers"===t||e.type===n&&"layers"===t?_("web-scene/ground","ground"):e.type===i&&"layers"===t?_("web-scene/operational-layers","operational-layers",e=>e!==i):e.type!==v&&e.type!==w||"analyses"!==t?e.type!==m||"leftTableSource"!==t&&"rightTableSource"!==t?null:V({},{key:"type",base:null,typeMap:{"data-layer":d,"map-layer":b}}):{typeName:"array",elementType:{typeName:"union",key:"type",types:await Promise.all(Object.entries(g).map(async([e,t])=>({type:{typeName:"json",type:await t()},value:e})))}}:_("web-scene/basemap-base-layers","basemap-base-layers")}async function L(e,t,r){const n=I(r),a=await C(e,t);return a?(a.isRequired=n.isRequired,a.nullable=n.nullable,a.default=n.default,a):n}async function P(e,t,r,n){const a=t.type.__accessorMetadata__,s=n.getDeclaredClass(t.type);if(!a)return e&&n.addProperty({name:e,type:"unknown"}),null;let l=s,y=null;t.layerContainerType&&(l+=`--${t.layerContainerType}`);const o=e?.match(/<([^>]+)>$/);o&&(l+=`--${o[1]}`,y=o[1]);const i=r??t;t.type===f&&(l+=`--${n.currentClass?.name}`,y=n.currentClass?.name);const p=n.seen.get(l);if(p&&e)return n.addProperty({name:e,type:p,required:i.isRequired,default:i.default,nullable:i.nullable}),p;const u={type:t.type,name:s,id:l,properties:[]};e&&(n.addProperty({name:e,type:u,required:i.isRequired,default:i.default,nullable:i.nullable}),u.typeValue=y),n.push(e,u);for(const c in a){const e=a[c],r=F(e);if(!r?.enabled)continue;if(r.layerContainerTypes&&t.layerContainerType&&!r.layerContainerTypes.includes(t.layerContainerType))continue;if(t.type===f){const e="esri/layers/TileLayer"===n.stack[n.stack.length-2].klass.name;if(e&&f.test.isMapImageLayerOverridePolicy(r.overridePolicy)||!e&&f.test.isTileImageLayerOverridePolicy(r.overridePolicy))continue}const s=r.target;if("string"==typeof s||null==s){const r=await L(t,c,e);if(!r)continue;await q("string"==typeof s?s:c,r,void 0,n)}else await $(t,s,n)}return n.pop()}async function $(e,t,r){for(const n in t){let a=await C(e,n);if(!a){const e=t[n];a=e.types?V({default:e.default,write:e},e.types):J(e.type),a.default=e.default,a.isRequired=e.isRequired,a.nullable=e.allowNull,a=E(a)}await q(n,a,void 0,r)}}async function _(e,t,r){const n={typeName:"union",key:"layerType",types:[]};for(const a in c[e]){if("web-scene/operational-layers"===e&&"ArcGISTiledElevationServiceLayer"===a)continue;const s=await u[a]();s&&(r&&!r(s)||s!==p&&n.types.push({type:{typeName:"json",layerContainerType:t,type:s},value:a}))}if(0===n.types.length)return null;return{typeName:"array",elementType:1===n.types.length?n.types[0].type:n}}function O(e,t){switch(t.typeName){case"array":return`${O(e,t.elementType)}[]`;case"union":return`${N(t.types.map(t=>O(e,t.type))).join(" | ")}`;case"native":switch(t.type){case Number:return"number";case y:return"integer";case String:return"string";case Boolean:return"boolean";case Object:return"object";default:return"unknown"}case"json":return e.getDeclaredClass(t.type);case"enum":return"string"}}function A(e){const t=e.prototype.itemType?.Type;if(!t)return{typeName:"array",elementType:{typeName:"native",type:null}};if("function"==typeof t)return{typeName:"array",elementType:J(t)};if(t.typeMap){const e=[];for(const r in t.typeMap){const n=t.typeMap[r];e.push({type:J(n),value:K(n)?null:r})}return{typeName:"array",elementType:{typeName:"union",key:"string"==typeof t.key?t.key:"type",types:e}}}}function x(e){if("json"!==e.typeName)return null;const t=e.type.__accessorMetadata__,r=t?.type,n=r&&U(r),a=n?.type,s=a||r?.type;return s&&Array.isArray(s)&&"string"==typeof s[0]?a||r.type.map(e=>D(r,e)):null}function E(e){if("array"===e.typeName)return e.elementType=E(e.elementType),e;const t=x(e);return t?{typeName:"union",key:"type",nullable:e.nullable,isRequired:e.isRequired,types:t.map(t=>({value:t,type:e}))}:e}function I(e){const t=U(e);return t?.types?V(t,t.types):!t?.type&&e.types?V(t,e.types):E(G(e))}function V(e,t){if(Array.isArray(t))return{typeName:"array",elementType:V(e,t[0])};const r=[];for(const n in t.typeMap){const e=t.typeMap[n];r.push({type:J(e),value:K(e)?null:n})}return{typeName:"union",key:"string"==typeof t.key?t.key:"type",types:r,nullable:e?.write?.allowNull,isRequired:e?.write?.isRequired,default:e?.default}}function B(e){return null!=e&&e.isJSONMapWriter}function D(e,t){const r=F(e);if(r&&B(r.writer)){const e={value:""};return r.writer?.(t,e,"value"),e.value}return t}function G(e){const t=U(e),r=F(e),n=t?.type,a=J(n||e.type);return t&&void 0!==t.default&&"function"!=typeof t.default&&(a.default=D(e,t.default)),r?.allowNull&&(a.nullable=!0),r?.isRequired&&(a.isRequired=!0),a}function J(e){if(!e)return{typeName:"native",type:null};if(s(e))return W(e);if(Array.isArray(e)){if("string"==typeof e[0]||"number"==typeof e[0])return{typeName:"enum",values:e};if(e.length>1){const t=[];let r;for(const n of e)n!==l?t.push({type:J(n),value:null}):r=!0;return 1===t.length?{...t[0].type,nullable:r}:{typeName:"union",key:null,types:t,nullable:r}}return{typeName:"array",elementType:J(e[0])}}return o(e)?A(e):K(e)?{typeName:"native",type:e}:z(e)?{typeName:"json",type:e}:{typeName:"native",type:null}}function W(e){switch(e.type){case"native":return{typeName:"native",type:e.value};case"array":return{typeName:"array",elementType:J(e.value)};case"one-of":return{typeName:"union",key:null,types:e.values.map(e=>({type:W(e),value:null}))}}}function z(e){let t=e;for(;t;){if(t.prototype&&("esri.core.JSONSupport"===t.prototype.declaredClass||"esri.core.MultiOriginJSONSupport"===t.prototype.declaredClass))return!0;t=Object.getPrototypeOf(t)}return!1}function K(e){return e===String||e===Boolean||e===Number||e===y||e===Object||e===l}function U(e){if(!e.json)return null;const t=e.json.origins,r=e.json,n=t?.["web-scene"],a=t?.["web-document"];return n||a||r||null}function F(e){if(!e.json)return null;const t=e.json.origins,r=e.json.write,n=t?.["web-scene"]?.write,a=t?.["web-document"]?.write;return n||a||r||null}export{T as scan};
5
+ import{__addDisposableResource as e,__disposeResources as t}from"tslib";import r from"../../Basemap.js";import n from"../../Ground.js";import a from"../../WebScene.js";import"../../core/has.js";import{isLongFormType as s,Null as l,Integer as y}from"../../core/accessorSupport/ensureType.js";import{isCollection as o}from"../../core/accessorSupport/extensions/serializableProperty/type.js";import i from"../../layers/GroupLayer.js";import p from"../../layers/KMLLayer.js";import{typeModuleMap as u}from"../../layers/mixins/operationalLayerModuleMap.js";import{supportedTypes as c}from"../../layers/mixins/operationalLayers.js";import f from"../../layers/support/Sublayer.js";import{JoinTableDataSourceClass as m,DataLayerSource as d}from"../../layers/support/source/DataLayerSource.js";import{MapLayerSource as b}from"../../layers/support/source/MapLayerSource.js";import w from"../InitialViewProperties.js";import{ScanContext as j,sorted as N}from"./utils.js";import{webSceneAnalysisRegistry as g}from"../support/analysisUtils.js";import v from"../support/SlideElements.js";async function T(r){const n={stack:[],error:void 0,hasError:!1};try{const t=e(n,new j,!1);return await P(null,{typeName:"json",type:r},void 0,t)}catch(a){n.error=a,n.hasError=!0}finally{t(n)}}async function q(e,t,r,n){switch(t.typeName){case"array":await R(e,t,r,n);break;case"union":await M(e,t,r,n);break;case"json":await P(e,t,r,n);break;case"native":await h(e,t,r,n);break;case"enum":await k(e,t,r,n)}}async function h(e,t,r,n){const a=r??t;n.addProperty({name:e,type:O(n,t),default:a.default,required:a.isRequired,nullable:a.nullable})}async function k(e,t,r,n){const a=r??t;n.currentClass?.typeValue&&"type"===e?n.addProperty({name:e,type:"string",enum:`"${n.currentClass.typeValue}"`,default:a.default,required:a.isRequired,nullable:a.nullable}):n.addProperty({name:e,type:O(n,t),enum:N(t.values).map(e=>"string"==typeof e?`"${e}"`:`${e}`).join("|"),default:a.default,required:a.isRequired,nullable:a.nullable})}async function R(e,t,r,n){t.elementType.isRequired=t.isRequired,await q(`${e}[]`,t.elementType,r??t.elementType,n)}function S(e,t){if("json"===e.typeName){const t=e.type.__accessorMetadata__,r=t?.type,n=r&&U(r),a=n?.type,s=a||r?.type;if(s&&Array.isArray(s)&&1===s.length&&"string"==typeof s[0])return a?s[0]:D(r,s[0])}return t}async function M(e,t,r,n){const a=[],s=r??t;for(const l of t.types)if("native"!==l.type.typeName&&t.key){const a=`${e}<${S(l.type,l.value)}>`;await q(a,l.type,r??t,n)}else a.push(l.type);if(a.length){const t=N(a.map(e=>O(n,e)));n.addProperty({type:t.join("|"),name:e,default:s.default,required:s.isRequired,nullable:s.nullable})}}async function C(e,t){return e.type===a&&"layers"===t?_("web-scene/operational-layers","operational-layers"):e.type===a&&"tables"===t?_("web-scene/tables","tables"):e.type!==r||"baseLayers"!==t&&"baseMapLayers"!==t?e.type===r&&"groundLayers"===t?_("web-scene/basemap-ground-layers","basemap-ground-layers"):e.type===r&&"elevationLayers"===t||e.type===n&&"layers"===t?_("web-scene/ground","ground"):e.type===i&&"layers"===t?_("web-scene/operational-layers","operational-layers",e=>e!==i):e.type!==v&&e.type!==w||"analyses"!==t?e.type!==m||"leftTableSource"!==t&&"rightTableSource"!==t?null:V({},{key:"type",base:null,typeMap:{"data-layer":d,"map-layer":b}}):{typeName:"array",elementType:{typeName:"union",key:"type",types:await Promise.all(Object.entries(g).map(async([e,t])=>({type:{typeName:"json",type:await t()},value:e})))}}:_("web-scene/basemap-base-layers","basemap-base-layers")}async function L(e,t,r){const n=I(r),a=await C(e,t);return a?(a.isRequired=n.isRequired,a.nullable=n.nullable,a.default=n.default,a):n}async function P(e,t,r,n){const a=t.type.__accessorMetadata__,s=n.getDeclaredClass(t.type);if(!a)return e&&n.addProperty({name:e,type:"unknown"}),null;let l=s,y=null;t.layerContainerType&&(l+=`--${t.layerContainerType}`);const o=e?.match(/<([^>]+)>$/);o&&(l+=`--${o[1]}`,y=o[1]);const i=r??t;t.type===f&&(l+=`--${n.currentClass?.name}`,y=n.currentClass?.name);const p=n.seen.get(l);if(p&&e)return n.addProperty({name:e,type:p,required:i.isRequired,default:i.default,nullable:i.nullable}),p;const u={type:t.type,name:s,id:l,properties:[]};e&&(n.addProperty({name:e,type:u,required:i.isRequired,default:i.default,nullable:i.nullable}),u.typeValue=y),n.push(e,u);for(const c in a){const e=a[c],r=F(e);if(!r?.enabled)continue;if(r.layerContainerTypes&&t.layerContainerType&&!r.layerContainerTypes.includes(t.layerContainerType))continue;if(t.type===f){const e="esri/layers/TileLayer"===n.stack[n.stack.length-2].klass.name;if(e&&f.test.isMapImageLayerOverridePolicy(r.overridePolicy)||!e&&f.test.isTileImageLayerOverridePolicy(r.overridePolicy))continue}const s=r.target;if("string"==typeof s||null==s){const r=await L(t,c,e);if(!r)continue;await q("string"==typeof s?s:c,r,void 0,n)}else await $(t,s,n)}return n.pop()}async function $(e,t,r){for(const n in t){let a=await C(e,n);if(!a){const e=t[n];a=e.types?V({default:e.default,write:e},e.types):J(e.type),a.default=e.default,a.isRequired=e.isRequired,a.nullable=e.allowNull,a=E(a)}await q(n,a,void 0,r)}}async function _(e,t,r){const n={typeName:"union",key:"layerType",types:[]};for(const a in c[e]){if("web-scene/operational-layers"===e&&"ArcGISTiledElevationServiceLayer"===a)continue;const s=await u[a]();s&&(r&&!r(s)||s!==p&&n.types.push({type:{typeName:"json",layerContainerType:t,type:s},value:a}))}if(0===n.types.length)return null;return{typeName:"array",elementType:1===n.types.length?n.types[0].type:n}}function O(e,t){switch(t.typeName){case"array":return`${O(e,t.elementType)}[]`;case"union":return`${N(t.types.map(t=>O(e,t.type))).join(" | ")}`;case"native":switch(t.type){case Number:return"number";case y:return"integer";case String:return"string";case Boolean:return"boolean";case Object:return"object";default:return"unknown"}case"json":return e.getDeclaredClass(t.type);case"enum":return"string"}}function A(e){const t=e.prototype.itemType?.Type;if(!t)return{typeName:"array",elementType:{typeName:"native",type:null}};if("function"==typeof t)return{typeName:"array",elementType:J(t)};if(t.typeMap){const e=[];for(const r in t.typeMap){const n=t.typeMap[r];e.push({type:J(n),value:K(n)?null:r})}return{typeName:"array",elementType:{typeName:"union",key:"string"==typeof t.key?t.key:"type",types:e}}}}function x(e){if("json"!==e.typeName)return null;const t=e.type.__accessorMetadata__,r=t?.type,n=r&&U(r),a=n?.type,s=a||r?.type;return s&&Array.isArray(s)&&"string"==typeof s[0]?a||r.type.map(e=>D(r,e)):null}function E(e){if("array"===e.typeName)return e.elementType=E(e.elementType),e;const t=x(e);return t?{typeName:"union",key:"type",nullable:e.nullable,isRequired:e.isRequired,types:t.map(t=>({value:t,type:e}))}:e}function I(e){const t=U(e);return t?.types?V(t,t.types):!t?.type&&e.types?V(t,e.types):E(G(e))}function V(e,t){if(Array.isArray(t))return{typeName:"array",elementType:V(e,t[0])};const r=[];for(const n in t.typeMap){const e=t.typeMap[n];r.push({type:J(e),value:K(e)?null:n})}return{typeName:"union",key:"string"==typeof t.key?t.key:"type",types:r,nullable:e?.write?.allowNull,isRequired:e?.write?.isRequired,default:e?.default}}function B(e){return null!=e&&e.isJSONMapWriter}function D(e,t){const r=F(e);if(r&&B(r.writer)){const e={value:""};return r.writer?.(t,e,"value"),e.value}return t}function G(e){const t=U(e),r=F(e),n=t?.type,a=J(n||e.type);return t&&void 0!==t.default&&"function"!=typeof t.default&&(a.default=D(e,t.default)),r?.allowNull&&(a.nullable=!0),r?.isRequired&&(a.isRequired=!0),a}function J(e){if(!e)return{typeName:"native",type:null};if(s(e))return W(e);if(Array.isArray(e)){if("string"==typeof e[0]||"number"==typeof e[0])return{typeName:"enum",values:e};if(e.length>1){const t=[];let r;for(const n of e)n!==l?t.push({type:J(n),value:null}):r=!0;return 1===t.length?{...t[0].type,nullable:r}:{typeName:"union",key:null,types:t,nullable:r}}return{typeName:"array",elementType:J(e[0])}}return o(e)?A(e):K(e)?{typeName:"native",type:e}:z(e)?{typeName:"json",type:e}:{typeName:"native",type:null}}function W(e){switch(e.type){case"native":return{typeName:"native",type:e.value};case"array":return{typeName:"array",elementType:J(e.value)};case"one-of":return{typeName:"union",key:null,types:e.values.map(e=>({type:W(e),value:null}))}}}function z(e){let t=e;for(;t;){if(t.prototype&&("esri.core.JSONSupport"===t.prototype.declaredClass||"esri.core.MultiOriginJSONSupport"===t.prototype.declaredClass))return!0;t=Object.getPrototypeOf(t)}return!1}function K(e){return e===String||e===Boolean||e===Number||e===y||e===Object||e===l}function U(e){if(!e.json)return null;const t=e.json.origins,r=e.json,n=t?.["web-scene"],a=t?.["web-document"];return n||a||r||null}function F(e){if(!e.json)return null;const t=e.json.origins,r=e.json.write,n=t?.["web-scene"]?.write,a=t?.["web-document"]?.write;return n||a||r||null}export{T as scan};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import{getAssetUrl as e}from"../../assets.js";import o from"../../Graphic.js";import"../../intl.js";import i from"../../core/Collection.js";import s from"../../core/Error.js";import{EventedAccessor as r}from"../../core/Evented.js";import n from"../../core/Logger.js";import{watch as a,initial as h,when as c}from"../../core/reactiveUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import{cast as l}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import p from"../../geometry/Point.js";import{load as v}from"../../geometry/projectionUtils.js";import u from"../../symbols/PictureMarkerSymbol.js";import{pointSymbolTypes as f}from"../../symbols/support/typeUtils.js";import g from"./support/Conversion.js";import{isValidPoint as w,isSupportedNotation as _}from"./support/coordinateConversionUtils.js";import y from"./support/Format.js";import{generateDefaultFormats as C,setDefaultPatterns as b}from"./support/formatUtils.js";import{GoTo as L}from"../support/GoTo.js";import{fetchMessageBundle as M}from"../../intl/messages.js";import{onLocaleChange as P,getLocale as j}from"../../intl/locale.js";const S=new p([0,0,500]),H="xy",F=["mgrs","utm","usng","dd","dms","ddm"],G="esri__coordinateConversionWidgetState",x={conversions:"conversions",formats:"formats",view:"view",viewChange:"view-change",cursor:"cursor"},E="esri/images/search/search-symbol-32.png";let T=class extends(L(r)){constructor(t){super(t),this._conversionPromise=null,this._locationGraphic=null,this._pointerCount=0,this.conversions=new i,this.formats=new i,this.formatterAvailable=!1,this.messages=null,this.filteredFormats=new i,this.locationSymbol=new u({url:e(E),width:24,height:24}),this.storageEnabled=!0,this.storageType="session",this.view=null,this._saveWidgetState=this._saveWidgetState.bind(this),this._handleFormatChange=this._handleFormatChange.bind(this),this._handleConversionChange=this._handleConversionChange.bind(this),this._handleViewChange=this._handleViewChange.bind(this),this._onClick=this._onClick.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerUp=this._onPointerUp.bind(this)}initialize(){const t=async()=>this.messages=await M("esri/widgets/CoordinateConversion/t9n/CoordinateConversion");this.formats.addMany(C()),t().then(()=>{if(!this.destroyed&&(b(this.messages,this.formats),this.storageEnabled&&this._loadWidgetState(),this.formats.forEach(t=>{t.viewModel=this,this.addHandles(a(()=>t.currentPattern,this._saveWidgetState),t.name??"unnamed-format")}),this.addHandles(this.conversions.on("change",this._handleConversionChange),x.conversions),this.addHandles(this.formats.on("change",this._handleFormatChange),x.formats),this.addHandles(P(()=>{t().then(()=>{b(this.messages,this.formats)})})),v().then(()=>{this.formatterAvailable=!0}).catch(t=>{n.getLogger(this).error(new s("coordinate-conversion:projection-load-failed","Failed to load the projection module.",{error:t})),this.formatterAvailable=!1,this._filterFormatsAndConversions()}).then(()=>this.addHandles(a(()=>this.view,this._handleViewChange,h),x.viewChange)),0===this.conversions.length)){const t=this.formats.find(t=>t.name===H)||this.formats.at(0);this.conversions.add(new g({format:t}))}})}destroy(){this.removeHandles(),this._cleanUpView(this.view),this.view=null}castConversions(t){return this._castToConversions(t)}set currentLocation(t){this._set("currentLocation",t),this._updateConversions()}get currentLocation(){return this._get("currentLocation")||null}set mode(t){switch(t){case"capture":this.currentLocation=null,this._startCaptureMode(),this._set("mode",t);break;case"live":this._startLiveMode(),this._set("mode",t)}}get mode(){return this._get("mode")||"live"}get state(){const{messages:t,view:e}=this,o=e?.ready;return t?o?"ready":e?"loading":"disabled":"disabled"}get storage(){const{storageType:t}=this;return"session"===t?sessionStorage:localStorage}get waitingForConversions(){return null!=this._conversionPromise}setLocation(t){if(this._locationGraphic&&this.view?.graphics.remove(this._locationGraphic),!t)return;const e=t.clone();e.hasZ&&(e.z=void 0),this._locationGraphic=new o({geometry:e,symbol:this.locationSymbol}),this.view?.graphics.add(this._locationGraphic)}async convert(t,e){if(!w(e))throw new s("coordinate-conversion:invalid-point","Invalid point cannot be converted.",{point:e});return Promise.resolve().then(()=>t.convert(e))}async goToLocation(t){const{view:e}=this;if(!e)throw new s("coordinate-conversion:go-to-failed","no view");const o="3d"===e.type?e.clippingArea:null,i=e.map?.basemap?.baseLayers;if(o||(i?.length??0)>0){const e=o??i?.at(0)?.fullExtent;if(null!=e&&!e.contains(t))throw new s("coordinate-conversion:go-to-failed","Point outside basemap extent.",{point:t})}return this.callGoTo({target:t})}pause(){this.currentLocation=null,this.removeHandles(x.view),this.view&&(this.removeHandles(x.cursor),this._locationGraphic&&this.view.graphics.remove(this._locationGraphic))}async previewConversion(t,e=this.currentLocation||S){return(await W(t,e)).displayCoordinate}resume(){"capture"===this.mode?this._startCaptureMode():this._startLiveMode()}reverseConvert(t,e){return e.reverseConvert(t)}async updateConversions(t,e){if("point"!==e?.type)throw this._clearConversions(this.conversions),new s("coordinate-conversion:invalid-input-point","Point is invalid, conversions cannot be updated.",{point:e});return this._convertMany(t,e)}_castToConversions(t){const e=new i;return t.forEach(t=>{let o=null;if(t instanceof g)o=t;else if("string"==typeof t){const e=this.formats.find(e=>e.name===t);e&&(o=new g({format:e}))}o&&e.add(o)}),e}_cleanUpView(t){t&&(this._locationGraphic&&t.graphics.remove(this._locationGraphic),this.removeHandles(x.view),this.removeHandles(x.cursor))}_clearConversions(t){t.forEach(t=>{t.position={location:null,coordinate:null}})}async _convertMany(t,e){return Promise.all(t.map(t=>W(t,e)))}_handleConversionChange(t){for(const e of t.added){const{format:t}=e;t&&(t.viewModel=this,this.currentLocation&&(this._set("waitingForConversions",!0),this.convert(t,this.currentLocation).then(t=>{e.position=t,this._set("waitingForConversions",!1)})))}this._saveWidgetState()}_handleFormatChange(t){t.added.forEach(t=>{this.addHandles(a(()=>t.currentPattern,this._saveWidgetState),t.name??"unnamed-format"),t.viewModel=this}),t.removed.forEach(t=>{t.viewModel=null;const e=this.conversions.filter(e=>e.format===t);this.conversions.removeMany(e),t.name&&this.removeHandles(t.name)})}_loadWidgetState(){try{const t=JSON.parse(this.storage.getItem(G));t&&this._setWidgetState(t)}catch(t){n.getLogger(this).error(new s("coordinate-conversion:invalid-session-storage-json","Could not read from storage.",{error:t}))}}_startCaptureMode(){this.removeHandles(x.view),this.view&&(this.currentLocation&&this.setLocation(this.currentLocation),this.removeHandles(x.cursor),this.addHandles(this.view.acquireCursor("crosshair","high"),x.cursor),this.addHandles(this.view.on("click",this._onClick),x.view))}_startLiveMode(){this._pointerCount=0,this.removeHandles(x.view),this.view&&(this.removeHandles(x.cursor),this._locationGraphic&&this.view.graphics.remove(this._locationGraphic),this.addHandles([this.view.on("pointer-down",this._onPointerDown),this.view.on("pointer-up",this._onPointerUp),this.view.on("pointer-move",this._onPointerMove)],x.view))}_handleViewChange(t,e){e&&e!==t&&this._cleanUpView(e),t&&("capture"===this.mode?this._startCaptureMode():this._startLiveMode(),e&&this._filterFormatsAndConversions())}_onClick(t){if(0===t.button){const e=this.view?.toMap(t),o=e?.normalize();this.setLocation(o),this.currentLocation=o}}_onPointerDown(t){const{pointerType:e}=t;if(this._pointerCount++,("touch"===e||"pen"===e)&&1===this._pointerCount){const e=this.view?.toMap(t);this.currentLocation=e?.normalize()}}_onPointerMove(t){const{pointerType:e}=t;if("mouse"===e||1===this._pointerCount){const e=this.view?.toMap(t);this.currentLocation=e?.normalize()}}_onPointerUp(){this._pointerCount--}_setWidgetState(t){try{t.formats.forEach(e=>{const o=this.formats.find(t=>t.name===e.name);o&&t.locale===j()&&e.currentPattern&&(o.currentPattern=e.currentPattern),o&&e.index>=0&&this.conversions.add(new g({format:o}))})}catch(e){n.getLogger(this).warn(new s("coordinate-conversion:session-storage-read-error","Could not get widget state from stored JSON.",{error:e}))}}_saveWidgetState(){if(!this.storageEnabled)return;const t=this._toJSON();try{this.storage.setItem(G,JSON.stringify({formats:t,locale:j()}))}catch(e){n.getLogger(this).error(new s("coordinate-conversion:local-storage-write-error","Could not write to localStorage.",{error:e}))}}async _updateConversions(){try{await this.updateConversions(this.conversions.toArray(),this.currentLocation)}catch{}}_toJSON(){return this.formats.filter(t=>{const e=t.name;return"xy"===e||"basemap"===e||_(e)}).map(t=>({name:t.name,currentPattern:t.currentPattern,defaultPattern:t.defaultPattern,index:this.conversions.findIndex(e=>e.format===t)})).sort((t,e)=>t.index-e.index).toArray()}_filterFormatsAndConversions(){const{formatterAvailable:t,conversions:e,formats:o}=this;t||this.addHandles(c(()=>this.view?.spatialReference,t=>{const i=t.isWebMercator||t.isWGS84,s=o.filter(t=>{const{name:e}=t;return!!U(e)||"xy"===e&&!i}),r=this.filteredFormats.filter(t=>"xy"===t.name&&i&&!this.formats.includes(t)),n=e.filter(t=>s.includes(t.format));o.removeMany(s),e.removeMany(n),this.filteredFormats.addMany(s.filter(t=>!this.filteredFormats.includes(t))),o.addMany(r)},{once:!0,initial:!0}),x.view)}};async function W(t,e){try{t.position=await(t.format?.convert(e))}catch(o){t.position=null}return t}function U(t){return F.includes(t)}t([d({type:i.ofType(g)})],T.prototype,"conversions",void 0),t([l("conversions")],T.prototype,"castConversions",null),t([d({type:p})],T.prototype,"currentLocation",null),t([d({type:i.ofType(y)})],T.prototype,"formats",void 0),t([d()],T.prototype,"messages",void 0),t([d()],T.prototype,"mode",null),t([d()],T.prototype,"filteredFormats",void 0),t([d({readOnly:!0})],T.prototype,"state",null),t([d({types:f})],T.prototype,"locationSymbol",void 0),t([d({readOnly:!0,dependsOn:["storageType"]})],T.prototype,"storage",null),t([d()],T.prototype,"storageEnabled",void 0),t([d()],T.prototype,"storageType",void 0),t([d({readOnly:!0})],T.prototype,"waitingForConversions",null),t([d()],T.prototype,"view",void 0),T=t([m("esri.widgets.CoordinateConversion.CoordinateConversionViewModel")],T);const A=T;export{A as default};
5
+ import{__decorate as t}from"tslib";import{getAssetUrl as e}from"../../assets.js";import o from"../../Graphic.js";import"../../intl.js";import i from"../../core/Collection.js";import s from"../../core/Error.js";import{EventedAccessor as r}from"../../core/Evented.js";import n from"../../core/Logger.js";import{watch as a,initial as h,when as c}from"../../core/reactiveUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import{cast as l}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import p from"../../geometry/Point.js";import{load as v}from"../../geometry/projectionUtils.js";import u from"../../symbols/PictureMarkerSymbol.js";import{pointSymbolTypes as f}from"../../symbols/support/typeUtils.js";import g from"./support/Conversion.js";import{isValidPoint as w,isSupportedNotation as _}from"./support/coordinateConversionUtils.js";import y from"./support/Format.js";import{generateDefaultFormats as C,setDefaultPatterns as b}from"./support/formatUtils.js";import{GoTo as L}from"../support/GoTo.js";import{fetchMessageBundle as M}from"../../intl/messages.js";import{onLocaleChange as P,getLocale as j}from"../../intl/locale.js";const S=new p([0,0,500]),H="xy",F=["mgrs","utm","usng","dd","dms","ddm"],G="esri__coordinateConversionWidgetState",x={conversions:"conversions",formats:"formats",view:"view",viewChange:"view-change",cursor:"cursor"},E="esri/images/search/search-symbol-32.png";let T=class extends(L(r)){constructor(t){super(t),this._conversionPromise=null,this._locationGraphic=null,this._pointerCount=0,this.conversions=new i,this.formats=new i,this.formatterAvailable=!1,this.messages=null,this.filteredFormats=new i,this.locationSymbol=new u({url:e(E),width:24,height:24}),this.storageEnabled=!0,this.storageType="session",this.view=null,this._saveWidgetState=this._saveWidgetState.bind(this),this._handleFormatChange=this._handleFormatChange.bind(this),this._handleConversionChange=this._handleConversionChange.bind(this),this._handleViewChange=this._handleViewChange.bind(this),this._onClick=this._onClick.bind(this),this._onPointerMove=this._onPointerMove.bind(this),this._onPointerDown=this._onPointerDown.bind(this),this._onPointerUp=this._onPointerUp.bind(this)}initialize(){const t=async()=>this.messages=await M("esri/widgets/CoordinateConversion/t9n/CoordinateConversion");this.formats.addMany(C()),t().then(()=>{if(!this.destroyed&&(b(this.messages,this.formats),this.storageEnabled&&this._loadWidgetState(),this.formats.forEach(t=>{t.viewModel=this,this.addHandles(a(()=>t.currentPattern,this._saveWidgetState),t.name??"unnamed-format")}),this.addHandles(this.conversions.on("change",this._handleConversionChange),x.conversions),this.addHandles(this.formats.on("change",this._handleFormatChange),x.formats),this.addHandles(P(()=>{t().then(()=>{b(this.messages,this.formats)})})),v().then(()=>{this.formatterAvailable=!0}).catch(t=>{n.getLogger(this).error(new s("coordinate-conversion:projection-load-failed","Failed to load the projection module.",{error:t})),this.formatterAvailable=!1,this._filterFormatsAndConversions()}).then(()=>this.addHandles(a(()=>this.view,this._handleViewChange,h),x.viewChange)),0===this.conversions.length)){const t=this.formats.find(t=>t.name===H)||this.formats.at(0);this.conversions.add(new g({format:t}))}})}destroy(){this.removeHandles(),this._cleanUpView(this.view),this.view=null}castConversions(t){return this._castToConversions(t)}set currentLocation(t){this._set("currentLocation",t),this._updateConversions()}get currentLocation(){return this._get("currentLocation")||null}set mode(t){switch(t){case"capture":this.currentLocation=null,this._startCaptureMode(),this._set("mode",t);break;case"live":this._startLiveMode(),this._set("mode",t)}}get mode(){return this._get("mode")||"live"}get state(){const{messages:t,view:e}=this,o=e?.ready;return t?o?"ready":e?"loading":"disabled":"disabled"}get storage(){const{storageType:t}=this;return"session"===t?sessionStorage:localStorage}get waitingForConversions(){return null!=this._conversionPromise}setLocation(t){if(this._locationGraphic&&this.view?.graphics.remove(this._locationGraphic),!t)return;const e=t.clone();e.hasZ&&(e.z=void 0),this._locationGraphic=new o({geometry:e,symbol:this.locationSymbol}),this.view?.graphics.add(this._locationGraphic)}async convert(t,e){if(!w(e))throw new s("coordinate-conversion:invalid-point","Invalid point cannot be converted.",{point:e});return Promise.resolve().then(()=>t.convert(e))}async goToLocation(t){const{view:e}=this;if(!e)throw new s("coordinate-conversion:go-to-failed","no view");const o="3d"===e.type?e.clippingArea:null,i=e.map?.basemap?.baseLayers;if(o||(i?.length??0)>0){const e=o??i?.at(0)?.fullExtent;if(null!=e&&!e.contains(t))throw new s("coordinate-conversion:go-to-failed","Point outside basemap extent.",{point:t})}return this.callGoTo({target:t})}pause(){this.currentLocation=null,this.removeHandles(x.view),this.view&&(this.removeHandles(x.cursor),this._locationGraphic&&this.view.graphics.remove(this._locationGraphic))}async previewConversion(t,e=this.currentLocation||S){return(await W(t,e)).displayCoordinate}resume(){"capture"===this.mode?this._startCaptureMode():this._startLiveMode()}reverseConvert(t,e){return e.reverseConvert(t)}async updateConversions(t,e){if("point"!==e?.type)throw this._clearConversions(this.conversions),new s("coordinate-conversion:invalid-input-point","Point is invalid, conversions cannot be updated.",{point:e});return this._convertMany(t,e)}_castToConversions(t){const e=new i;return t.forEach(t=>{let o=null;if(t instanceof g)o=t;else if("string"==typeof t){const e=this.formats.find(e=>e.name===t);e&&(o=new g({format:e}))}o&&e.add(o)}),e}_cleanUpView(t){t&&(this._locationGraphic&&t.graphics.remove(this._locationGraphic),this.removeHandles(x.view),this.removeHandles(x.cursor))}_clearConversions(t){t.forEach(t=>{t.position={location:null,coordinate:null}})}async _convertMany(t,e){return Promise.all(t.map(t=>W(t,e)))}_handleConversionChange(t){for(const e of t.added){const{format:t}=e;t&&(t.viewModel=this,this.currentLocation&&(this._set("waitingForConversions",!0),this.convert(t,this.currentLocation).then(t=>{e.position=t,this._set("waitingForConversions",!1)})))}this._saveWidgetState()}_handleFormatChange(t){t.added.forEach(t=>{this.addHandles(a(()=>t.currentPattern,this._saveWidgetState),t.name??"unnamed-format"),t.viewModel=this}),t.removed.forEach(t=>{t.viewModel=null;const e=this.conversions.filter(e=>e.format===t);this.conversions.removeMany(e),t.name&&this.removeHandles(t.name)})}_loadWidgetState(){try{const t=JSON.parse(this.storage.getItem(G));t&&this._setWidgetState(t)}catch(t){n.getLogger(this).error(new s("coordinate-conversion:invalid-session-storage-json","Could not read from storage.",{error:t}))}}_startCaptureMode(){this.removeHandles(x.view),this.view&&(this.currentLocation&&this.setLocation(this.currentLocation),this.removeHandles(x.cursor),this.addHandles(this.view.acquireCursor("crosshair","high"),x.cursor),this.addHandles(this.view.on("click",this._onClick),x.view))}_startLiveMode(){this._pointerCount=0,this.removeHandles(x.view),this.view&&(this.removeHandles(x.cursor),this._locationGraphic&&this.view.graphics.remove(this._locationGraphic),this.addHandles([this.view.on("pointer-down",this._onPointerDown),this.view.on("pointer-up",this._onPointerUp),this.view.on("pointer-move",this._onPointerMove)],x.view))}_handleViewChange(t,e){e&&e!==t&&this._cleanUpView(e),t&&("capture"===this.mode?this._startCaptureMode():this._startLiveMode(),e&&this._filterFormatsAndConversions())}_onClick(t){if(0===t.button){const e=this.view?.toMap(t),o=e?.normalize();this.setLocation(o),this.currentLocation=o}}_onPointerDown(t){const{pointerType:e}=t;if(this._pointerCount++,("touch"===e||"pen"===e)&&1===this._pointerCount){const e=this.view?.toMap(t);this.currentLocation=e?.normalize()}}_onPointerMove(t){const{pointerType:e}=t;if("mouse"===e||1===this._pointerCount){const e=this.view?.toMap(t);this.currentLocation=e?.normalize()}}_onPointerUp(){this._pointerCount--}_setWidgetState(t){try{t.formats.forEach(e=>{const o=this.formats.find(t=>t.name===e.name);o&&t.locale===j()&&e.currentPattern&&(o.currentPattern=e.currentPattern),o&&e.index>=0&&this.conversions.add(new g({format:o}))})}catch(e){n.getLogger(this).warn(new s("coordinate-conversion:session-storage-read-error","Could not get state from stored JSON.",{error:e}))}}_saveWidgetState(){if(!this.storageEnabled)return;const t=this._toJSON();try{this.storage.setItem(G,JSON.stringify({formats:t,locale:j()}))}catch(e){n.getLogger(this).error(new s("coordinate-conversion:local-storage-write-error","Could not write to localStorage.",{error:e}))}}async _updateConversions(){try{await this.updateConversions(this.conversions.toArray(),this.currentLocation)}catch{}}_toJSON(){return this.formats.filter(t=>{const e=t.name;return"xy"===e||"basemap"===e||_(e)}).map(t=>({name:t.name,currentPattern:t.currentPattern,defaultPattern:t.defaultPattern,index:this.conversions.findIndex(e=>e.format===t)})).sort((t,e)=>t.index-e.index).toArray()}_filterFormatsAndConversions(){const{formatterAvailable:t,conversions:e,formats:o}=this;t||this.addHandles(c(()=>this.view?.spatialReference,t=>{const i=t.isWebMercator||t.isWGS84,s=o.filter(t=>{const{name:e}=t;return!!U(e)||"xy"===e&&!i}),r=this.filteredFormats.filter(t=>"xy"===t.name&&i&&!this.formats.includes(t)),n=e.filter(t=>s.includes(t.format));o.removeMany(s),e.removeMany(n),this.filteredFormats.addMany(s.filter(t=>!this.filteredFormats.includes(t))),o.addMany(r)},{once:!0,initial:!0}),x.view)}};async function W(t,e){try{t.position=await(t.format?.convert(e))}catch(o){t.position=null}return t}function U(t){return F.includes(t)}t([d({type:i.ofType(g)})],T.prototype,"conversions",void 0),t([l("conversions")],T.prototype,"castConversions",null),t([d({type:p})],T.prototype,"currentLocation",null),t([d({type:i.ofType(y)})],T.prototype,"formats",void 0),t([d()],T.prototype,"messages",void 0),t([d()],T.prototype,"mode",null),t([d()],T.prototype,"filteredFormats",void 0),t([d({readOnly:!0})],T.prototype,"state",null),t([d({types:f})],T.prototype,"locationSymbol",void 0),t([d({readOnly:!0,dependsOn:["storageType"]})],T.prototype,"storage",null),t([d()],T.prototype,"storageEnabled",void 0),t([d()],T.prototype,"storageType",void 0),t([d({readOnly:!0})],T.prototype,"waitingForConversions",null),t([d()],T.prototype,"view",void 0),T=t([m("esri.widgets.CoordinateConversion.CoordinateConversionViewModel")],T);const A=T;export{A as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../core/Logger.js";import{maybeProperty as o}from"../core/maybe.js";import{property as i}from"../core/accessorSupport/decorators/property.js";import{cast as s}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";import r from"./Widget.js";import a from"./CoordinateConversion/CoordinateConversionViewModel.js";import l from"./CoordinateConversion/support/Conversion.js";import{loadCalciteComponents as p}from"./support/componentsUtils.js";import{globalCss as c}from"./support/globalCss.js";import{Heading as d}from"./support/Heading.js";import{legacyIcon as u}from"./support/legacyIcon.js";import{accessibleHandler as h}from"./support/decorators/accessibleHandler.js";import{messageBundle as _}from"./support/decorators/messageBundle.js";import{tsx as m}from"./support/jsxFactory.js";import{isRTL as v,storeNode as g}from"./support/widgetUtils.js";import"@arcgis/toolkit/dom";const b="esri-coordinate-conversion",y={base:b,captureMode:`${b}--capture-mode`,noBasemap:`${b}--no-basemap`,popup:`${b}__popup`,clipboardPopup:`${b}__clipboard-popup`,conversionList:`${b}__conversion-list`,conversionRow:`${b}__row`,coordDisplay:`${b}__display`,expandButton:`${b}__expand-button`,expanded:`${b}__conversions-view--expanded`,expandDown:`${b}__conversions-view--expand-down`,expandUp:`${b}__conversions-view--expand-up`,conversionsView:`${b}__conversions-view`,rowSelect:`${b}__select-row`,toolDisplay:`${b}__tools`,modeToggle:`${b}__mode-toggle`,rowButton:`${b}__row-button`,coordinateInput:`${b}__input-coordinate`,inputForm:`${b}__input-form`,inputFormGroup:`${b}__input-group`,inputSelect:`${b}__input-select`,sectionHeading:`${b}__heading`,patternInput:`${b}__pattern-input`,settings:`${b}__settings`,settingsFormGroup:`${b}__settings-group`,settingsFormGroupHorizontal:`${b}__settings-group-horizontal`,previewCoordinate:`${b}__preview-coordinate`},C={settingsButton:!0,inputButton:!0,captureButton:!0,expandButton:!0},w=750,f=2500;let T=class extends r{constructor(e,t){super(e,t),this._popupMessage=null,this._popupTimeoutId=void 0,this._clipboardPopupTimeoutId=void 0,this._coordinateInput=null,this._badInput=!1,this._goToEnabled=!1,this._conversionFormat=null,this._settingsFormat=null,this._previewConversion=null,this._expanded=!1,this._clipboardPopupVisible=!1,this._popupVisible=!1,this._settingsVisible=!1,this._inputVisible=!1,this.headingLevel=4,this.messages=null,this.messagesCommon=null,this.orientation="auto",this.viewModel=new a,this.visibleElements={...C}}loadDependencies(){return p({button:()=>import("@esri/calcite-components/dist/components/calcite-button"),checkbox:()=>import("@esri/calcite-components/dist/components/calcite-checkbox"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),option:()=>import("@esri/calcite-components/dist/components/calcite-option"),select:()=>import("@esri/calcite-components/dist/components/calcite-select")})}get conversions(){return this.viewModel.conversions}set conversions(e){this.viewModel.conversions=e}get currentLocation(){return this.viewModel.currentLocation}set currentLocation(e){this.viewModel.currentLocation=e}get formats(){return this.viewModel.formats}set formats(e){this.viewModel.formats=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get icon(){return"coordinate-system"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get mode(){return this.viewModel.mode}set mode(e){this.viewModel.mode=e}set multipleConversions(e){!1===e&&(this._expanded=!1,this.conversions.splice(1,this.conversions.length-1)),this._set("multipleConversions",e)}get multipleConversions(){const e=this._get("multipleConversions");return"boolean"!=typeof e||e}get locationSymbol(){return this.viewModel.locationSymbol}set locationSymbol(e){this.viewModel.locationSymbol=e}get storageEnabled(){return this.viewModel.storageEnabled}set storageEnabled(e){this.viewModel.storageEnabled=e}get storageType(){return this.viewModel.storageType}set storageType(e){this.viewModel.storageType=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}castVisibleElements(e){return{...C,...e}}reverseConvert(e,t){return this.viewModel.reverseConvert(e,t)}render(){const e=this.viewModel?.state,t="disabled"===e?m("div",{key:"esri-coordinate__no-basemap"},this.messages?.noBasemap):null,o=!t&&this._inputVisible?this._renderInputForm():null,i=!t&&this._settingsVisible?this._renderSettings():null,s=t||o||i?null:this._renderConversionsView(),n=this._popupVisible?this._renderPopup():null,r={[y.captureMode]:"capture"===this.mode,[c.disabled]:"loading"===e,[y.noBasemap]:"disabled"===e};return m("div",{class:this.classes(y.base,c.widget,r)},n,t,s,i,o)}_addConversion(e){const t=e.target,o=t.selectedOption.value,i=x(t);if(null==o||null==i)return;const s=new l({format:o});t.value="default",i>=0?(this.conversions.removeAt(i),this.conversions.add(s,i)):this.conversions.add(s)}_findSettingsFormat(){return this._settingsFormat||this.conversions.reduceRight((e,t)=>{const o=t.format;return o?.hasDisplayProperties?o:e},null)||this.formats.find(e=>e.hasDisplayProperties)}_hidePopup(){this._popupTimeoutId&&(clearTimeout(this._popupTimeoutId),this._popupTimeoutId=void 0),this._popupVisible=!1,this._popupMessage=null,this.scheduleRender()}_hideClipboardPopup(){this._clipboardPopupTimeoutId&&(clearTimeout(this._clipboardPopupTimeoutId),this._clipboardPopupTimeoutId=void 0),this._clipboardPopupVisible=!1,this.scheduleRender()}_onConvertComplete(){this._inputVisible=!1,this._coordinateInput.value=""}_onCopy(e){const t=P(e.currentTarget)?.displayCoordinate;null!=t&&(e.clipboardData?.setData("text/plain",t),this._showClipboardPopup(),e.preventDefault())}_processUserInput(e){const i=o(e,"key"),s=this.viewModel;if("Enter"!==i&&i)this._badInput&&(this._badInput=!1);else{const e=this._conversionFormat||this.conversions.at(0).format;if(!e)return;const o=this._coordinateInput.value;this._reverseConvert(o,e).then(e=>{"capture"===this.mode?s.resume():this.mode="capture",this.currentLocation=e,s.setLocation(e),this._onConvertComplete()}).catch(e=>{t.getLogger(this).error(e),this._showPopup(this.messages?.invalidCoordinate),this._badInput=!0})}}async _reverseConvert(e,o){const i=this.viewModel,s=await o.reverseConvert(e);return this._goToEnabled&&s&&i.goToLocation(s).catch(e=>{t.getLogger(this).warn(e),this._showPopup(this.messages?.locationOffBasemap)}),s}_setInputFormat(e){const t=e.target.selectedOption.value;null!=t&&(this._conversionFormat=t)}_setPreviewConversion(){const e=this._findSettingsFormat(),t=this.viewModel;if(e){const o=this.conversions.find(t=>t.format===e);this._previewConversion=new l({format:e,position:{location:this.currentLocation,coordinate:o?.position?.coordinate}}),this._previewConversion.position?.coordinate||t.previewConversion(this._previewConversion)}}_setSettingsFormat(e){const t=e.target.selectedOption.value;null!=t&&(this._settingsFormat=t,this._setPreviewConversion())}_showClipboardPopup(){this._clipboardPopupVisible?clearTimeout(this._clipboardPopupTimeoutId):this._clipboardPopupVisible=!0,this.scheduleRender(),this._popupTimeoutId=setTimeout(()=>{this._popupTimeoutId=void 0,this._hideClipboardPopup()},w)}_showPopup(e,t=f){this._popupMessage=e,this._popupVisible?clearTimeout(this._popupTimeoutId):this._popupVisible=!0,this.scheduleRender(),this._popupTimeoutId=setTimeout(()=>{this._popupTimeoutId=void 0,this._hidePopup()},t)}_toggleGoTo(){this._goToEnabled=!this._goToEnabled}_updateCurrentPattern(e){e.stopPropagation();const t=e.target,o=this._findSettingsFormat();o&&(o.currentPattern=t.value)}_renderConversion(e,t){const{messages:o}=this;if(!o)return m("li",null);const{format:i}=e,s=i?.label??"",n=`${this.id}__list-item-${t}`,r=`${s} ${o.conversionOutputSuffix}`,a=0===t,l=a||this._expanded,p=a?this._renderFirstConversion(e):this._renderTools(t,e,n),c=a&&!e.displayCoordinate?o.noLocation:e.displayCoordinate,d=m("div",{"aria-label":c,class:y.coordDisplay,"data-conversion":e,role:"listitem",tabIndex:0,title:c??""},c),u=this._renderOptions(this.formats.filter(e=>e!==i));return l?m("li",{"aria-label":r,class:y.conversionRow,id:n,key:e,role:"group",tabIndex:0,title:r},m("calcite-select",{"aria-controls":n,bind:this,class:y.rowSelect,"data-index":t,label:o.selectFormat,scale:"s",onCalciteSelectChange:this._addConversion},m("calcite-option",{label:s.toUpperCase(),selected:!0},s.toUpperCase()),u),d,p):null}_renderCopyButton(e){const t=this._clipboardPopupVisible&&this._renderClipboardPopup(),{messagesCommon:o}=this;return o?m("li",{"aria-label":o.copy,bind:this,class:this.classes(c.widgetButton,y.rowButton),"data-conversion":e,onclick:this._copyCoordinateOutput,oncopy:this._onCopy,onkeydown:this._copyCoordinateOutput,role:"button",tabIndex:0,title:o.copy},t,m("span",{"aria-hidden":"true",class:u.duplicate})):m("li",null)}_renderFirstConversion(e){const t=this.id,{messages:o,messagesCommon:i,multipleConversions:s,visibleElements:n}=this;if(!i||!o)return m("ul",null);const r="live"===this.mode?o.captureMode:o.liveMode,a=this._expanded?i.collapse:i.expand,l=e.displayCoordinate&&"capture"===this.mode?this._renderCopyButton(e):null,p=s&&n.expandButton&&this._renderIconButton({iconType:this._expanded?"chevron-down":"chevron-up",clickFunction:this._toggleExpand,classes:[y.expandButton],attributes:{"aria-controls":`${t}__${y.conversionList}`,label:a}}),c=!s&&n.captureButton&&this._renderIconButton({iconType:"live"===this.mode?"pin-tear":"pin-tear-f",clickFunction:this._toggleMode,classes:[y.modeToggle],attributes:{label:r}});return m("ul",{class:y.toolDisplay},l,p,c)}_renderInputForm(){const e=this._conversionFormat||this.conversions.at(0).format,t=this.formats.findIndex(t=>t.name===e?.name),o=this.id,i=`${o}__${y.coordinateInput}`,s=`${o}__${y.coordinateInput}__header`,n=this._renderOptions(this.formats,!0,t),{messages:r,messagesCommon:a,headingLevel:l}=this;if(!a||!r)return m("div",null);const p=this._renderIconButton({iconType:v(this.container)?"arrow-right":"arrow-left",clickFunction:this._toggleInputVisibility,attributes:{label:a.back}});return m("div",{"aria-labelledby":s,class:y.inputForm,key:"esri-coordinate-conversion__input-form",role:"search"},m("div",{class:y.sectionHeading},p,m(d,{class:c.heading,id:s,level:l},r.inputCoordTitle)),m("div",{class:y.inputFormGroup},m("calcite-select",{"aria-controls":i,bind:this,class:y.inputSelect,label:r.selectFormat,scale:"s",onCalciteSelectChange:this._setInputFormat},n),m("calcite-input",{afterCreate:g,"aria-labelledby":s,bind:this,class:y.coordinateInput,"data-format":e,"data-node-ref":"_coordinateInput",id:i,onkeydown:this._processUserInput,placeholder:r.inputCoordTitle,required:!0,scale:"s",spellcheck:!1,status:this._badInput?"invalid":"idle"})),m("div",{class:y.inputFormGroup},m("calcite-label",{layout:"inline",scale:"s"},m("calcite-checkbox",{bind:this,checked:this._goToEnabled,onCalciteCheckboxChange:this._toggleGoTo}),r.goTo),m("calcite-button",{appearance:"outline",bind:this,kind:"neutral",onclick:this._processUserInput,type:"button",width:"auto"},r.convert)))}_renderConversionsView(){const{messages:e}=this;if(!e)return m("div",null);const t=`${this.id}__${y.conversionList}`,o=this._renderPrimaryTools(),i=this._renderOptions(this.formats),s=this.conversions.map((e,t)=>this._renderConversion(e,t)).toArray(),n=this._expanded?m("div",{class:y.conversionRow},m("calcite-select",{"aria-controls":t,bind:this,"data-index":-1,label:e.addConversion,scale:"s",onCalciteSelectChange:this._addConversion},m("calcite-option",{disabled:!0,selected:!0,value:"default"},e.addConversion),i),o):null,r={[y.expanded]:this._expanded,[y.expandUp]:"expand-up"===this.orientation,[y.expandDown]:"expand-down"===this.orientation};return m("div",{class:this.classes(y.conversionsView,r),key:"esri-coordinate-conversion__main-view"},m("ul",{"aria-expanded":this._expanded?"true":"false",class:y.conversionList,id:t},s),n)}_renderOptions(e,t,o){const i=this.conversions.at(0),s=i.format?.name;return e.map((e,n)=>{const r=!(t||!i)&&(s===e.name||this.conversions.map(e=>e.format?.name).includes(e.name));return m("calcite-option",{disabled:r,key:e.name??"unnamed-format",label:e.label.toUpperCase(),selected:n===o,value:e},e.label)}).toArray()}_renderPopup(){return m("div",{class:y.popup,role:"alert"},this._popupMessage)}_renderClipboardPopup(){const{messages:e}=this;return e?m("div",{class:this.classes(y.popup,y.clipboardPopup),role:"alert"},e.copySuccessMessage):m("div",null)}_renderPrimaryTools(){const{messages:e,visibleElements:t}=this;if(!e)return m("ul",null);const o="live"===this.mode?e.captureMode:e.liveMode,i=t.inputButton&&this._renderIconButton({iconType:"pencil",clickFunction:this._toggleInputVisibility,attributes:{label:e.inputCoordTitle}}),s=t.captureButton&&this._renderIconButton({iconType:"live"===this.mode?"pin-tear":"pin-tear-f",clickFunction:this._toggleMode,classes:[y.modeToggle],attributes:{label:o}}),n=t.settingsButton&&this._renderIconButton({iconType:"gear",clickFunction:this._toggleSettingsVisibility,attributes:{label:e.settingsTitle}});return m("ul",{class:y.toolDisplay},i,s,n)}_renderSettings(){const e=this.id,t=`${e}__${y.patternInput}`,o=`${e}__${y.patternInput}__header`,i=`${e}__${y.previewCoordinate}`,s=this.formats.filter(e=>e.hasDisplayProperties),n=this._findSettingsFormat(),r=n?s.indexOf(n):-1,a=this._renderOptions(s,!0,r),l=n?.currentPattern,{messages:p,messagesCommon:u,headingLevel:h}=this;if(!u||!p)return m("div",null);const _=this._renderIconButton({iconType:v(this.container)?"arrow-right":"arrow-left",clickFunction:this._toggleSettingsVisibility,attributes:{label:u.back}}),g=this._renderIconButton({iconType:"reset",clickFunction:this._setDefaultPattern,attributes:{label:p.defaultPattern}});return m("div",{"aria-labelledby":o,class:y.settings,key:y.settings},m("div",{class:y.sectionHeading},_,m(d,{class:c.heading,id:o,level:h},p.settingsTitle)),m("div",{class:y.settingsFormGroup},m("label",{for:t},p.changeCoordinateDisplay),m("calcite-select",{bind:this,label:p.selectFormat,width:"full",onCalciteSelectChange:this._setSettingsFormat},a),m("div",{class:y.settingsFormGroupHorizontal},m("calcite-input",{"aria-controls":i,bind:this,class:y.patternInput,id:t,spellcheck:!1,type:"text",value:l,onCalciteInputInput:this._updateCurrentPattern}),g)),m("div",{class:y.settingsFormGroup},m("label",null,u.preview,m("div",{class:y.previewCoordinate,id:i,tabIndex:0},this._previewConversion?.displayCoordinate))))}_renderIconButton(e){const{iconType:t,clickFunction:o,classes:i,attributes:s}=e;return m("calcite-button",{appearance:"transparent",bind:this,class:this.classes(i),iconStart:t,kind:"neutral",onclick:o,onkeydown:o,...s})}_renderTools(e,t,o){const i=t.displayCoordinate&&"capture"===this.mode?this._renderCopyButton(t):null,{messages:s}=this;if(!s)return m("ul",null);const n=this._renderIconButton({iconType:"x",clickFunction:this._removeConversion,attributes:{"aria-controls":o,label:s.removeConversion,"data-index":e}});return m("ul",{class:y.toolDisplay,role:"listitem"},i,m("li",{class:this.classes(y.rowButton)},n))}_copyCoordinateOutput(e){const t=e.target;if(!("createTextRange"in document.body)){const e=window.getSelection(),o=document.createRange();o.selectNodeContents(t),e?.removeAllRanges(),e?.addRange(o)}document.execCommand("copy")}_removeConversion(e){const t=x(e.currentTarget);null!=t&&this.conversions.removeAt(t)}_setDefaultPattern(e){e.stopPropagation();const t=this._findSettingsFormat();t&&(t.currentPattern=t.defaultPattern)}_toggleExpand(){this._expanded=!this._expanded}_toggleInputVisibility(){this._inputVisible=!this._inputVisible,this._popupVisible&&this._hidePopup(),this._inputVisible?this.viewModel.pause():this.viewModel.resume()}_toggleMode(){this.mode="live"===this.mode?"capture":"live"}_toggleSettingsVisibility(){this._settingsVisible=!this._settingsVisible,this._popupVisible&&this._hidePopup(),this._settingsVisible?(this._setPreviewConversion(),this.viewModel.pause()):this.viewModel.resume()}};e([i()],T.prototype,"conversions",null),e([i()],T.prototype,"currentLocation",null),e([i()],T.prototype,"formats",null),e([i()],T.prototype,"goToOverride",null),e([i()],T.prototype,"headingLevel",void 0),e([i()],T.prototype,"icon",null),e([i()],T.prototype,"label",null),e([i(),_("esri/widgets/CoordinateConversion/t9n/CoordinateConversion")],T.prototype,"messages",void 0),e([i(),_("esri/t9n/common")],T.prototype,"messagesCommon",void 0),e([i()],T.prototype,"mode",null),e([i()],T.prototype,"orientation",void 0),e([i()],T.prototype,"multipleConversions",null),e([i()],T.prototype,"locationSymbol",null),e([i()],T.prototype,"storageEnabled",null),e([i()],T.prototype,"storageType",null),e([i()],T.prototype,"view",null),e([i({type:a})],T.prototype,"viewModel",void 0),e([i()],T.prototype,"visibleElements",void 0),e([s("visibleElements")],T.prototype,"castVisibleElements",null),e([h()],T.prototype,"_copyCoordinateOutput",null),e([h()],T.prototype,"_removeConversion",null),e([h()],T.prototype,"_setDefaultPattern",null),e([h()],T.prototype,"_toggleExpand",null),e([h()],T.prototype,"_toggleInputVisibility",null),e([h()],T.prototype,"_toggleMode",null),e([h()],T.prototype,"_toggleSettingsVisibility",null),T=e([n("esri.widgets.CoordinateConversion")],T);const I=T;function x(e){return e["data-index"]}function P(e){return e["data-conversion"]}export{I as default};
5
+ import{__decorate as e}from"tslib";import{deprecateWidget as t}from"../core/deprecate.js";import o from"../core/Logger.js";import{maybeProperty as i}from"../core/maybe.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import{cast as n}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import"../core/RandomLCG.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import a from"./Widget.js";import l from"./CoordinateConversion/CoordinateConversionViewModel.js";import p from"./CoordinateConversion/support/Conversion.js";import{loadCalciteComponents as c}from"./support/componentsUtils.js";import{globalCss as d}from"./support/globalCss.js";import{Heading as u}from"./support/Heading.js";import{legacyIcon as h}from"./support/legacyIcon.js";import{accessibleHandler as _}from"./support/decorators/accessibleHandler.js";import{messageBundle as m}from"./support/decorators/messageBundle.js";import{tsx as v}from"./support/jsxFactory.js";import{isRTL as g,storeNode as b}from"./support/widgetUtils.js";import"@arcgis/toolkit/dom";const y="esri-coordinate-conversion",C={base:y,captureMode:`${y}--capture-mode`,noBasemap:`${y}--no-basemap`,popup:`${y}__popup`,clipboardPopup:`${y}__clipboard-popup`,conversionList:`${y}__conversion-list`,conversionRow:`${y}__row`,coordDisplay:`${y}__display`,expandButton:`${y}__expand-button`,expanded:`${y}__conversions-view--expanded`,expandDown:`${y}__conversions-view--expand-down`,expandUp:`${y}__conversions-view--expand-up`,conversionsView:`${y}__conversions-view`,rowSelect:`${y}__select-row`,toolDisplay:`${y}__tools`,modeToggle:`${y}__mode-toggle`,rowButton:`${y}__row-button`,coordinateInput:`${y}__input-coordinate`,inputForm:`${y}__input-form`,inputFormGroup:`${y}__input-group`,inputSelect:`${y}__input-select`,sectionHeading:`${y}__heading`,patternInput:`${y}__pattern-input`,settings:`${y}__settings`,settingsFormGroup:`${y}__settings-group`,settingsFormGroupHorizontal:`${y}__settings-group-horizontal`,previewCoordinate:`${y}__preview-coordinate`},w={settingsButton:!0,inputButton:!0,captureButton:!0,expandButton:!0},f=750,T=2500;let I=class extends a{constructor(e,i){super(e,i),this._popupMessage=null,this._popupTimeoutId=void 0,this._clipboardPopupTimeoutId=void 0,this._coordinateInput=null,this._badInput=!1,this._goToEnabled=!1,this._conversionFormat=null,this._settingsFormat=null,this._previewConversion=null,this._expanded=!1,this._clipboardPopupVisible=!1,this._popupVisible=!1,this._settingsVisible=!1,this._inputVisible=!1,this.headingLevel=4,this.messages=null,this.messagesCommon=null,this.orientation="auto",this.viewModel=new l,this.visibleElements={...w},t(o.getLogger(this),"CoordinateConversion","arcgis-coordinate-conversion",{version:"4.34"})}loadDependencies(){return c({button:()=>import("@esri/calcite-components/dist/components/calcite-button"),checkbox:()=>import("@esri/calcite-components/dist/components/calcite-checkbox"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),option:()=>import("@esri/calcite-components/dist/components/calcite-option"),select:()=>import("@esri/calcite-components/dist/components/calcite-select")})}get conversions(){return this.viewModel.conversions}set conversions(e){this.viewModel.conversions=e}get currentLocation(){return this.viewModel.currentLocation}set currentLocation(e){this.viewModel.currentLocation=e}get formats(){return this.viewModel.formats}set formats(e){this.viewModel.formats=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get icon(){return"coordinate-system"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get mode(){return this.viewModel.mode}set mode(e){this.viewModel.mode=e}set multipleConversions(e){!1===e&&(this._expanded=!1,this.conversions.splice(1,this.conversions.length-1)),this._set("multipleConversions",e)}get multipleConversions(){const e=this._get("multipleConversions");return"boolean"!=typeof e||e}get locationSymbol(){return this.viewModel.locationSymbol}set locationSymbol(e){this.viewModel.locationSymbol=e}get storageEnabled(){return this.viewModel.storageEnabled}set storageEnabled(e){this.viewModel.storageEnabled=e}get storageType(){return this.viewModel.storageType}set storageType(e){this.viewModel.storageType=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}castVisibleElements(e){return{...w,...e}}reverseConvert(e,t){return this.viewModel.reverseConvert(e,t)}render(){const e=this.viewModel?.state,t="disabled"===e?v("div",{key:"esri-coordinate__no-basemap"},this.messages?.noBasemap):null,o=!t&&this._inputVisible?this._renderInputForm():null,i=!t&&this._settingsVisible?this._renderSettings():null,s=t||o||i?null:this._renderConversionsView(),n=this._popupVisible?this._renderPopup():null,r={[C.captureMode]:"capture"===this.mode,[d.disabled]:"loading"===e,[C.noBasemap]:"disabled"===e};return v("div",{class:this.classes(C.base,d.widget,r)},n,t,s,i,o)}_addConversion(e){const t=e.target,o=t.selectedOption.value,i=P(t);if(null==o||null==i)return;const s=new p({format:o});t.value="default",i>=0?(this.conversions.removeAt(i),this.conversions.add(s,i)):this.conversions.add(s)}_findSettingsFormat(){return this._settingsFormat||this.conversions.reduceRight((e,t)=>{const o=t.format;return o?.hasDisplayProperties?o:e},null)||this.formats.find(e=>e.hasDisplayProperties)}_hidePopup(){this._popupTimeoutId&&(clearTimeout(this._popupTimeoutId),this._popupTimeoutId=void 0),this._popupVisible=!1,this._popupMessage=null,this.scheduleRender()}_hideClipboardPopup(){this._clipboardPopupTimeoutId&&(clearTimeout(this._clipboardPopupTimeoutId),this._clipboardPopupTimeoutId=void 0),this._clipboardPopupVisible=!1,this.scheduleRender()}_onConvertComplete(){this._inputVisible=!1,this._coordinateInput.value=""}_onCopy(e){const t=M(e.currentTarget)?.displayCoordinate;null!=t&&(e.clipboardData?.setData("text/plain",t),this._showClipboardPopup(),e.preventDefault())}_processUserInput(e){const t=i(e,"key"),s=this.viewModel;if("Enter"!==t&&t)this._badInput&&(this._badInput=!1);else{const e=this._conversionFormat||this.conversions.at(0).format;if(!e)return;const t=this._coordinateInput.value;this._reverseConvert(t,e).then(e=>{"capture"===this.mode?s.resume():this.mode="capture",this.currentLocation=e,s.setLocation(e),this._onConvertComplete()}).catch(e=>{o.getLogger(this).error(e),this._showPopup(this.messages?.invalidCoordinate),this._badInput=!0})}}async _reverseConvert(e,t){const i=this.viewModel,s=await t.reverseConvert(e);return this._goToEnabled&&s&&i.goToLocation(s).catch(e=>{o.getLogger(this).warn(e),this._showPopup(this.messages?.locationOffBasemap)}),s}_setInputFormat(e){const t=e.target.selectedOption.value;null!=t&&(this._conversionFormat=t)}_setPreviewConversion(){const e=this._findSettingsFormat(),t=this.viewModel;if(e){const o=this.conversions.find(t=>t.format===e);this._previewConversion=new p({format:e,position:{location:this.currentLocation,coordinate:o?.position?.coordinate}}),this._previewConversion.position?.coordinate||t.previewConversion(this._previewConversion)}}_setSettingsFormat(e){const t=e.target.selectedOption.value;null!=t&&(this._settingsFormat=t,this._setPreviewConversion())}_showClipboardPopup(){this._clipboardPopupVisible?clearTimeout(this._clipboardPopupTimeoutId):this._clipboardPopupVisible=!0,this.scheduleRender(),this._popupTimeoutId=setTimeout(()=>{this._popupTimeoutId=void 0,this._hideClipboardPopup()},f)}_showPopup(e,t=T){this._popupMessage=e,this._popupVisible?clearTimeout(this._popupTimeoutId):this._popupVisible=!0,this.scheduleRender(),this._popupTimeoutId=setTimeout(()=>{this._popupTimeoutId=void 0,this._hidePopup()},t)}_toggleGoTo(){this._goToEnabled=!this._goToEnabled}_updateCurrentPattern(e){e.stopPropagation();const t=e.target,o=this._findSettingsFormat();o&&(o.currentPattern=t.value)}_renderConversion(e,t){const{messages:o}=this;if(!o)return v("li",null);const{format:i}=e,s=i?.label??"",n=`${this.id}__list-item-${t}`,r=`${s} ${o.conversionOutputSuffix}`,a=0===t,l=a||this._expanded,p=a?this._renderFirstConversion(e):this._renderTools(t,e,n),c=a&&!e.displayCoordinate?o.noLocation:e.displayCoordinate,d=v("div",{"aria-label":c,class:C.coordDisplay,"data-conversion":e,role:"listitem",tabIndex:0,title:c??""},c),u=this._renderOptions(this.formats.filter(e=>e!==i));return l?v("li",{"aria-label":r,class:C.conversionRow,id:n,key:e,role:"group",tabIndex:0,title:r},v("calcite-select",{"aria-controls":n,bind:this,class:C.rowSelect,"data-index":t,label:o.selectFormat,scale:"s",onCalciteSelectChange:this._addConversion},v("calcite-option",{label:s.toUpperCase(),selected:!0},s.toUpperCase()),u),d,p):null}_renderCopyButton(e){const t=this._clipboardPopupVisible&&this._renderClipboardPopup(),{messagesCommon:o}=this;return o?v("li",{"aria-label":o.copy,bind:this,class:this.classes(d.widgetButton,C.rowButton),"data-conversion":e,onclick:this._copyCoordinateOutput,oncopy:this._onCopy,onkeydown:this._copyCoordinateOutput,role:"button",tabIndex:0,title:o.copy},t,v("span",{"aria-hidden":"true",class:h.duplicate})):v("li",null)}_renderFirstConversion(e){const t=this.id,{messages:o,messagesCommon:i,multipleConversions:s,visibleElements:n}=this;if(!i||!o)return v("ul",null);const r="live"===this.mode?o.captureMode:o.liveMode,a=this._expanded?i.collapse:i.expand,l=e.displayCoordinate&&"capture"===this.mode?this._renderCopyButton(e):null,p=s&&n.expandButton&&this._renderIconButton({iconType:this._expanded?"chevron-down":"chevron-up",clickFunction:this._toggleExpand,classes:[C.expandButton],attributes:{"aria-controls":`${t}__${C.conversionList}`,label:a}}),c=!s&&n.captureButton&&this._renderIconButton({iconType:"live"===this.mode?"pin-tear":"pin-tear-f",clickFunction:this._toggleMode,classes:[C.modeToggle],attributes:{label:r}});return v("ul",{class:C.toolDisplay},l,p,c)}_renderInputForm(){const e=this._conversionFormat||this.conversions.at(0).format,t=this.formats.findIndex(t=>t.name===e?.name),o=this.id,i=`${o}__${C.coordinateInput}`,s=`${o}__${C.coordinateInput}__header`,n=this._renderOptions(this.formats,!0,t),{messages:r,messagesCommon:a,headingLevel:l}=this;if(!a||!r)return v("div",null);const p=this._renderIconButton({iconType:g(this.container)?"arrow-right":"arrow-left",clickFunction:this._toggleInputVisibility,attributes:{label:a.back}});return v("div",{"aria-labelledby":s,class:C.inputForm,key:"esri-coordinate-conversion__input-form",role:"search"},v("div",{class:C.sectionHeading},p,v(u,{class:d.heading,id:s,level:l},r.inputCoordTitle)),v("div",{class:C.inputFormGroup},v("calcite-select",{"aria-controls":i,bind:this,class:C.inputSelect,label:r.selectFormat,scale:"s",onCalciteSelectChange:this._setInputFormat},n),v("calcite-input",{afterCreate:b,"aria-labelledby":s,bind:this,class:C.coordinateInput,"data-format":e,"data-node-ref":"_coordinateInput",id:i,onkeydown:this._processUserInput,placeholder:r.inputCoordTitle,required:!0,scale:"s",spellcheck:!1,status:this._badInput?"invalid":"idle"})),v("div",{class:C.inputFormGroup},v("calcite-label",{layout:"inline",scale:"s"},v("calcite-checkbox",{bind:this,checked:this._goToEnabled,onCalciteCheckboxChange:this._toggleGoTo}),r.goTo),v("calcite-button",{appearance:"outline",bind:this,kind:"neutral",onclick:this._processUserInput,type:"button",width:"auto"},r.convert)))}_renderConversionsView(){const{messages:e}=this;if(!e)return v("div",null);const t=`${this.id}__${C.conversionList}`,o=this._renderPrimaryTools(),i=this._renderOptions(this.formats),s=this.conversions.map((e,t)=>this._renderConversion(e,t)).toArray(),n=this._expanded?v("div",{class:C.conversionRow},v("calcite-select",{"aria-controls":t,bind:this,"data-index":-1,label:e.addConversion,scale:"s",onCalciteSelectChange:this._addConversion},v("calcite-option",{disabled:!0,selected:!0,value:"default"},e.addConversion),i),o):null,r={[C.expanded]:this._expanded,[C.expandUp]:"expand-up"===this.orientation,[C.expandDown]:"expand-down"===this.orientation};return v("div",{class:this.classes(C.conversionsView,r),key:"esri-coordinate-conversion__main-view"},v("ul",{"aria-expanded":this._expanded?"true":"false",class:C.conversionList,id:t},s),n)}_renderOptions(e,t,o){const i=this.conversions.at(0),s=i.format?.name;return e.map((e,n)=>{const r=!(t||!i)&&(s===e.name||this.conversions.map(e=>e.format?.name).includes(e.name));return v("calcite-option",{disabled:r,key:e.name??"unnamed-format",label:e.label.toUpperCase(),selected:n===o,value:e},e.label)}).toArray()}_renderPopup(){return v("div",{class:C.popup,role:"alert"},this._popupMessage)}_renderClipboardPopup(){const{messages:e}=this;return e?v("div",{class:this.classes(C.popup,C.clipboardPopup),role:"alert"},e.copySuccessMessage):v("div",null)}_renderPrimaryTools(){const{messages:e,visibleElements:t}=this;if(!e)return v("ul",null);const o="live"===this.mode?e.captureMode:e.liveMode,i=t.inputButton&&this._renderIconButton({iconType:"pencil",clickFunction:this._toggleInputVisibility,attributes:{label:e.inputCoordTitle}}),s=t.captureButton&&this._renderIconButton({iconType:"live"===this.mode?"pin-tear":"pin-tear-f",clickFunction:this._toggleMode,classes:[C.modeToggle],attributes:{label:o}}),n=t.settingsButton&&this._renderIconButton({iconType:"gear",clickFunction:this._toggleSettingsVisibility,attributes:{label:e.settingsTitle}});return v("ul",{class:C.toolDisplay},i,s,n)}_renderSettings(){const e=this.id,t=`${e}__${C.patternInput}`,o=`${e}__${C.patternInput}__header`,i=`${e}__${C.previewCoordinate}`,s=this.formats.filter(e=>e.hasDisplayProperties),n=this._findSettingsFormat(),r=n?s.indexOf(n):-1,a=this._renderOptions(s,!0,r),l=n?.currentPattern,{messages:p,messagesCommon:c,headingLevel:h}=this;if(!c||!p)return v("div",null);const _=this._renderIconButton({iconType:g(this.container)?"arrow-right":"arrow-left",clickFunction:this._toggleSettingsVisibility,attributes:{label:c.back}}),m=this._renderIconButton({iconType:"reset",clickFunction:this._setDefaultPattern,attributes:{label:p.defaultPattern}});return v("div",{"aria-labelledby":o,class:C.settings,key:C.settings},v("div",{class:C.sectionHeading},_,v(u,{class:d.heading,id:o,level:h},p.settingsTitle)),v("div",{class:C.settingsFormGroup},v("label",{for:t},p.changeCoordinateDisplay),v("calcite-select",{bind:this,label:p.selectFormat,width:"full",onCalciteSelectChange:this._setSettingsFormat},a),v("div",{class:C.settingsFormGroupHorizontal},v("calcite-input",{"aria-controls":i,bind:this,class:C.patternInput,id:t,spellcheck:!1,type:"text",value:l,onCalciteInputInput:this._updateCurrentPattern}),m)),v("div",{class:C.settingsFormGroup},v("label",null,c.preview,v("div",{class:C.previewCoordinate,id:i,tabIndex:0},this._previewConversion?.displayCoordinate))))}_renderIconButton(e){const{iconType:t,clickFunction:o,classes:i,attributes:s}=e;return v("calcite-button",{appearance:"transparent",bind:this,class:this.classes(i),iconStart:t,kind:"neutral",onclick:o,onkeydown:o,...s})}_renderTools(e,t,o){const i=t.displayCoordinate&&"capture"===this.mode?this._renderCopyButton(t):null,{messages:s}=this;if(!s)return v("ul",null);const n=this._renderIconButton({iconType:"x",clickFunction:this._removeConversion,attributes:{"aria-controls":o,label:s.removeConversion,"data-index":e}});return v("ul",{class:C.toolDisplay,role:"listitem"},i,v("li",{class:this.classes(C.rowButton)},n))}_copyCoordinateOutput(e){const t=e.target;if(!("createTextRange"in document.body)){const e=window.getSelection(),o=document.createRange();o.selectNodeContents(t),e?.removeAllRanges(),e?.addRange(o)}document.execCommand("copy")}_removeConversion(e){const t=P(e.currentTarget);null!=t&&this.conversions.removeAt(t)}_setDefaultPattern(e){e.stopPropagation();const t=this._findSettingsFormat();t&&(t.currentPattern=t.defaultPattern)}_toggleExpand(){this._expanded=!this._expanded}_toggleInputVisibility(){this._inputVisible=!this._inputVisible,this._popupVisible&&this._hidePopup(),this._inputVisible?this.viewModel.pause():this.viewModel.resume()}_toggleMode(){this.mode="live"===this.mode?"capture":"live"}_toggleSettingsVisibility(){this._settingsVisible=!this._settingsVisible,this._popupVisible&&this._hidePopup(),this._settingsVisible?(this._setPreviewConversion(),this.viewModel.pause()):this.viewModel.resume()}};e([s()],I.prototype,"conversions",null),e([s()],I.prototype,"currentLocation",null),e([s()],I.prototype,"formats",null),e([s()],I.prototype,"goToOverride",null),e([s()],I.prototype,"headingLevel",void 0),e([s()],I.prototype,"icon",null),e([s()],I.prototype,"label",null),e([s(),m("esri/widgets/CoordinateConversion/t9n/CoordinateConversion")],I.prototype,"messages",void 0),e([s(),m("esri/t9n/common")],I.prototype,"messagesCommon",void 0),e([s()],I.prototype,"mode",null),e([s()],I.prototype,"orientation",void 0),e([s()],I.prototype,"multipleConversions",null),e([s()],I.prototype,"locationSymbol",null),e([s()],I.prototype,"storageEnabled",null),e([s()],I.prototype,"storageType",null),e([s()],I.prototype,"view",null),e([s({type:l})],I.prototype,"viewModel",void 0),e([s()],I.prototype,"visibleElements",void 0),e([n("visibleElements")],I.prototype,"castVisibleElements",null),e([_()],I.prototype,"_copyCoordinateOutput",null),e([_()],I.prototype,"_removeConversion",null),e([_()],I.prototype,"_setDefaultPattern",null),e([_()],I.prototype,"_toggleExpand",null),e([_()],I.prototype,"_toggleInputVisibility",null),e([_()],I.prototype,"_toggleMode",null),e([_()],I.prototype,"_toggleSettingsVisibility",null),I=e([r("esri.widgets.CoordinateConversion")],I);const x=I;function P(e){return e["data-index"]}function M(e){return e["data-conversion"]}export{x as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import e from"../../core/Error.js";import{makeHandle as i,abortHandle as o}from"../../core/handleUtils.js";import{isAborted as s}from"../../core/promiseUtils.js";import{watch as r}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{isSubtypeSublayer as n}from"../../layers/support/layerUtils.js";import{createFeatureServices as d}from"../../rest/featureService/utils.js";import c from"../../views/draw/support/HighlightHelper.js";import{temporaryHighlightName as u}from"../../views/support/HighlightDefaults.js";import p from"./AddAssociationWorkflowData.js";import w from"./Workflow.js";import{fetchFullFeatures as h}from"./workflowUtils.js";import m from"../FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js";import{getFeatureTitle as y}from"../support/UtilityNetworkAssociations/utils/getFeatureTitle.js";var A;const f={exit:Symbol()};let g=class extends w{static{A=this}constructor(t){super(t),this._utilityNetworkAssociationAddAssociationViewModel=new m,this._highlightHelper=null,this.sourceFeatureItem=null,this.type="add-association"}initialize(){const{data:t}=this,{view:e}=t.viewModel;e&&(this._highlightHelper=new c({view:e,highlightName:u}),this.addHandles(i(()=>this._highlightHelper?.removeAll())));const s=new AbortController;this.addHandles(o(s)),this._updatingHandles.addPromise(this._setup(s))}get editorItem(){return this.data.editorItem}get featureFormViewModel(){return this._featureFormViewModel}get utilityNetworkAssociationAddAssociationViewModel(){return this._utilityNetworkAssociationAddAssociationViewModel}get hasPendingEdits(){return!!this._utilityNetworkAssociationAddAssociationViewModel.selectedFeature}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get reliesOnOwnerAdminPrivileges(){return this.editorItem.capabilities.create.reliesOnOwnerAdminPrivileges}async enter(){this._addHandles()}exit(){this.removeHandles(f.exit)}async start(){return await super.start(),null}async _setup(t){const{data:i}=this,{feature:o}=i;try{const[e]=await h([o],o.sourceLayer,i.viewModel.view.spatialReference,t.signal);if(s(t))return;const r=e.sourceLayer&&"getFeatureTitle"in e.sourceLayer?await e.sourceLayer.getFeatureTitle(e):y(e);if(s(t))return;this.sourceFeatureItem={feature:o,label:r},this._initializeUtilityNetworkAssociationAddAssociationViewModel()}catch(r){await this.cancel({force:!0,error:new e("editor:failed-to-fetch-full-feature","Failed to retrieve all information for this feature. The update cannot proceed.",{detail:{error:r}})})}}_initializeUtilityNetworkAssociationAddAssociationViewModel(){const{viewModel:{view:t},utilityNetwork:e,associationType:i}=this.data,o=this._utilityNetworkAssociationAddAssociationViewModel;o.graphic=this.sourceFeatureItem.feature,o.map=t?.map,o.utilityNetwork=e,o.layer=this.layer,o.associationType=i,o.highlightHelper=this._highlightHelper,e.networkSystemLayers.loadAssociationsTable()}_addHandles(){const t=this._utilityNetworkAssociationAddAssociationViewModel;this.addHandles([r(()=>t.selectedLayer,t=>{t&&this.go("add-association-select-feature")}),r(()=>t.selectedFeature,t=>{t&&this.go("add-association-create-association")})],f.exit)}static async create(t){const e=new A({data:await p.create(t),onCommit:this._onCommitFactory(t.applyEditsFeatureService)});return e._set("steps",this._createWorkflowSteps(e)),e}static _createWorkflowSteps(t){return[{id:"add-association-select-layer",async setUp(){const{utilityNetworkAssociationAddAssociationViewModel:e}=t.data.viewModel;e&&(e.selectedLayer=null,e.selectedFeature=null,e.association=null)},async tearDown(){}},{id:"add-association-select-feature",async setUp(){const{utilityNetworkAssociationAddAssociationViewModel:e}=t.data.viewModel;e&&(e.selectedFeature=null,e.association=null)},async tearDown(){}},{id:"add-association-create-association",async setUp(){},async tearDown(){}}]}static{this._onCommitFactory=t=>async i=>{const{feature:o,utilityNetwork:s,associationInput:r}=i,{utilityNetworkAssociationAddAssociationViewModel:a}=i.viewModel,{association:l}=a;await s.networkSystemLayers.loadAssociationsTable();const c=s?.generateAddAssociations([l]);if(!c)throw new e("editor:failed-to-add-association","Could not create payload needed to add association");const u=o.sourceLayer,p=n(u)&&u.parent?u.parent:u,w=d([p]),h=w.values().next().value?.featureService;if(!h)throw new e("editor:failed-to-delete-association","Could not retrieve feature service needed to delete association");await(h?.load());const m=s?.gdbVersion??void 0;await t(h,[c],{gdbVersion:m}),await r.refresh()}}};t([a()],g.prototype,"_utilityNetworkAssociationAddAssociationViewModel",void 0),t([a()],g.prototype,"_featureFormViewModel",void 0),t([a()],g.prototype,"editorItem",null),t([a()],g.prototype,"featureFormViewModel",null),t([a()],g.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),t([a()],g.prototype,"sourceFeatureItem",void 0),t([a()],g.prototype,"hasPendingEdits",null),t([a()],g.prototype,"layer",null),t([a()],g.prototype,"parent",null),t([a()],g.prototype,"reliesOnOwnerAdminPrivileges",null),g=A=t([l("esri.widgets.Editor.AddAssociationWorkflow")],g);export{g as AddAssociationWorkflow};
5
+ import{__decorate as t}from"tslib";import e from"../../core/Error.js";import{makeHandle as i,abortHandle as o}from"../../core/handleUtils.js";import{isAborted as s}from"../../core/promiseUtils.js";import{watch as r}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{isSubtypeSublayer as n}from"../../layers/support/layerUtils.js";import{createFeatureServices as d}from"../../rest/featureService/utils.js";import c from"../../views/draw/support/HighlightHelper.js";import{temporaryHighlightName as u}from"../../views/support/HighlightDefaults.js";import p from"./AddAssociationWorkflowData.js";import w from"./Workflow.js";import{fetchFullFeatures as h}from"./workflowUtils.js";import m from"../FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js";import{getFeatureTitle as y}from"../support/UtilityNetworkAssociations/utils/getFeatureTitle.js";var A;const f={exit:Symbol()};let g=class extends w{static{A=this}constructor(t){super(t),this._utilityNetworkAssociationAddAssociationViewModel=new m,this._highlightHelper=null,this.sourceFeatureItem=null,this.type="add-association"}initialize(){const{data:t}=this,{view:e}=t.viewModel;e&&(this._highlightHelper=new c({view:e,highlightName:u}),this.addHandles(i(()=>this._highlightHelper?.removeAll())));const s=new AbortController;this.addHandles(o(s)),this._updatingHandles.addPromise(this._setup(s))}get editorItem(){return this.data.editorItem}get formViewModel(){return this._formViewModel}get utilityNetworkAssociationAddAssociationViewModel(){return this._utilityNetworkAssociationAddAssociationViewModel}get hasPendingEdits(){return!!this._utilityNetworkAssociationAddAssociationViewModel.selectedFeature}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get reliesOnOwnerAdminPrivileges(){return this.editorItem.capabilities.create.reliesOnOwnerAdminPrivileges}async enter(){this._addHandles()}exit(){this.removeHandles(f.exit)}async start(){return await super.start(),null}async _setup(t){const{data:i}=this,{feature:o}=i;try{const[e]=await h([o],o.sourceLayer,i.viewModel.view.spatialReference,t.signal);if(s(t))return;const r=e.sourceLayer&&"getFeatureTitle"in e.sourceLayer?await e.sourceLayer.getFeatureTitle(e):y(e);if(s(t))return;this.sourceFeatureItem={feature:o,label:r},this._initializeUtilityNetworkAssociationAddAssociationViewModel()}catch(r){await this.cancel({force:!0,error:new e("editor:failed-to-fetch-full-feature","Failed to retrieve all information for this feature. The update cannot proceed.",{detail:{error:r}})})}}_initializeUtilityNetworkAssociationAddAssociationViewModel(){const{viewModel:{view:t},utilityNetwork:e,associationType:i}=this.data,o=this._utilityNetworkAssociationAddAssociationViewModel;o.graphic=this.sourceFeatureItem.feature,o.map=t?.map,o.utilityNetwork=e,o.layer=this.layer,o.associationType=i,o.highlightHelper=this._highlightHelper,e.networkSystemLayers.loadAssociationsTable()}_addHandles(){const t=this._utilityNetworkAssociationAddAssociationViewModel;this.addHandles([r(()=>t.selectedLayer,t=>{t&&this.go("add-association-select-feature")}),r(()=>t.selectedFeature,t=>{t&&this.go("add-association-create-association")})],f.exit)}static async create(t){const e=new A({data:await p.create(t),onCommit:this._onCommitFactory(t.applyEditsFeatureService)});return e._set("steps",this._createWorkflowSteps(e)),e}static _createWorkflowSteps(t){return[{id:"add-association-select-layer",async setUp(){const{utilityNetworkAssociationAddAssociationViewModel:e}=t.data.viewModel;e&&(e.selectedLayer=null,e.selectedFeature=null,e.association=null)},async tearDown(){}},{id:"add-association-select-feature",async setUp(){const{utilityNetworkAssociationAddAssociationViewModel:e}=t.data.viewModel;e&&(e.selectedFeature=null,e.association=null)},async tearDown(){}},{id:"add-association-create-association",async setUp(){},async tearDown(){}}]}static{this._onCommitFactory=t=>async i=>{const{feature:o,utilityNetwork:s,associationInput:r}=i,{utilityNetworkAssociationAddAssociationViewModel:a}=i.viewModel,{association:l}=a;await s.networkSystemLayers.loadAssociationsTable();const c=s?.generateAddAssociations([l]);if(!c)throw new e("editor:failed-to-add-association","Could not create payload needed to add association");const u=o.sourceLayer,p=n(u)&&u.parent?u.parent:u,w=d([p]),h=w.values().next().value?.featureService;if(!h)throw new e("editor:failed-to-delete-association","Could not retrieve feature service needed to delete association");await(h?.load());const m=s?.gdbVersion??void 0;await t(h,[c],{gdbVersion:m}),await r.refresh()}}};t([a()],g.prototype,"_utilityNetworkAssociationAddAssociationViewModel",void 0),t([a()],g.prototype,"_formViewModel",void 0),t([a()],g.prototype,"editorItem",null),t([a()],g.prototype,"formViewModel",null),t([a()],g.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),t([a()],g.prototype,"sourceFeatureItem",void 0),t([a()],g.prototype,"hasPendingEdits",null),t([a()],g.prototype,"layer",null),t([a()],g.prototype,"parent",null),t([a()],g.prototype,"reliesOnOwnerAdminPrivileges",null),g=A=t([l("esri.widgets.Editor.AddAssociationWorkflow")],g);export{g as AddAssociationWorkflow};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i,handlesGroup as r,abortHandle as s}from"../../core/handleUtils.js";import"../../core/has.js";import o from"../../core/Logger.js";import{removeMaybe as n,destroyMaybe as l}from"../../core/maybe.js";import{debounce as d,isPromiseLike as c}from"../../core/promiseUtils.js";import{watch as u,when as h,initial as p,whenOnce as m,syncAndInitial as f}from"../../core/reactiveUtils.js";import{generateBracedUUID as w}from"../../core/uuid.js";import{property as g}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import{isSharedTemplateOrMetadata as v,isSharedTemplate as F,isStandardFeatureTemplate as _}from"../../editing/templateUtils.js";import b from"../../layers/GraphicsLayer.js";import{isTable as M}from"../../layers/support/layerUtils.js";import{isNumber as I}from"../../support/guards.js";import{getDisplayedSymbol as V}from"../../symbols/support/symbolUtils.js";import{getDrawHelpMessage as k}from"../../views/draw/support/helpMessageUtils.js";import S from"../../views/draw/support/HighlightHelper.js";import A from"../../views/interactive/sketch/SketchOptions.js";import C from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as P}from"../../views/support/HighlightDefaults.js";import T from"./CreateFeaturesWorkflowData.js";import{isModelUpload as E,handleModelUpload as H}from"./modelUploadUtils.js";import U from"./Workflow.js";import{createToolFromGeometryType as j,findEditorItemForLayer as L,getServiceEditsFromWorkflowData as x,getServiceInfoForLayer as O,orderEditsByRelationshipDependencies as z,getFullTemplateForCreationInfo as W,getServiceLayersById as D,startCreatingNewFeature as R,findLayerInfo as G,updateGraphicSymbolWhenRequired as N,isTerminalUpdateEventType as K,getVisualVariableAttributes as Z,startUpdatingFeatureGeometry as q,createWorkflowSteps as B,avoidFeatureTemplateSelectionWithOnlyOneItem as J,getCreationAttributes as Q,setUpSketchCreateWatchers as X,setRelationshipFields as Y,prepareAttachmentsForCreateFeaturesWorkflow as $,showProgressCursor as ee,setVisualVariablesAndElevationInfoForUpdate as te,visualVariableInteractiveUpdate as ae}from"./workflowUtils.js";import ie from"../FeatureForm/FeatureFormViewModel.js";import re from"../Sketch/SketchViewModel.js";var se;const oe=Symbol(),ne=Symbol(),le=Symbol(),de=Symbol(),ce={point:["point"],multipoint:["multipoint"],polygon:["polygon","freehandPolygon","rectangle","circle"],polyline:["polyline","freehandPolyline"],mesh:[],multipatch:[]};let ue=se=class extends U{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.data=void 0,this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._webStyleCache=new Map,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._featureFormViewModel=new ie,this._sketchLayer=null,this._sketchViewModel=null,this._attachmentFileInfos=new Map,this._isActive=!0}initialize(){this.isNested&&(this._isActive=!1),this._initializeSketchViewModel()}destroy(){this._sketchViewModel.destroy()}get featureFormViewModel(){return this._featureFormViewModel}get hasPendingEdits(){if(this.pendingFeatures.some(e=>!!this.data.getEditsForPendingFeature(e)?.modified))return!0;const{creationInfo:e,upload:t}=this.data,{activeComponent:a,createGraphic:i}=this._sketchViewModel,r=i?.geometry?.type;return!("polyline"!==r&&"polygon"!==r&&"multipoint"!==r||"draw-2d"!==a?.type&&"draw-3d"!==a?.type)&&a.drawOperation.committedVertices.length>0||(!(!t||"pending"!==t.state&&"success"!==t.state)||!!e?.geometryToPlace)}get hasPreviousStep(){return this._stepIndex>0||"update-pending"===this.createFeatureState&&!!this.data.selectedPendingFeature&&!this.parent&&!E(this.data.creationInfo)}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const{_sketchViewModel:a}=this,i=e.layer.geometryType,r=a.createGraphic;if("mesh"===i){this._getDrawMeshHelpMessage||import("../../views/draw/support/helpMessageUtils3d.js").then(e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage});const{view:e}=t;return"3d"===e?.type?this._getDrawMeshHelpMessage?.(r,e):void 0}const{activeCreateToolDrawMode:s,activeTool:o}=a;return k("rectangle"===o||"circle"===o?o:i,r?.geometry,s)}get layer(){return this.data.creationInfo?.layer}get numPendingFeatures(){return this.pendingFeatures.length}get numPendingFeaturesExcludingHidden(){return this.pendingFeatures.filter(e=>this.data.isDisplayable(e)).length}get parent(){return this.data.parent}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){return this.data.editorItem?.capabilities.create.reliesOnOwnerAdminPrivileges??!1}get shouldShowAttachments(){return(this.data.selectedPendingFeature&&this.data.editorItem?.capabilities.create.attachments.enabled)??!1}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get sketchViewModel(){return this._sketchViewModel}get test(){}get availableCreateTools(){const e=this.data.creationInfo?.layer.geometryType,t=this.data.viewModel.view;if(!e)return[];if(this.data.creationInfo?.maxFeatures&&this.data.creationInfo.maxFeatures<=this.numPendingFeatures)return[];if(v(this.data.fullTemplate)){const{tool:t}=j(e,this.data.fullTemplate);return[t]}return"2d"!==t?.type&&"multipoint"===e?[]:[...ce[e]]}get _attachmentsActive(){const e=this.data.viewModel.attachmentsViewModel.mode,t=this.stepId;return this.shouldShowAttachments&&("add"===e||"edit"===e||"adding-attachment"===t||"editing-attachment"===t)}async enter(){this._isActive=!0,"awaiting-feature-creation-info"!==this.stepId&&await this._updatingHandles.addPromise(this._setUpCreatingFeaturesStep())}exit(){this._isActive=!1,this.removeHandles([le])}async updatePendingFeature(e){if(e!==this.data.selectedPendingFeature)return this._sketchViewModel.cancel(),this._startUpdating({feature:e})}async start(){return await super.start(),M(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}async save(){const{featureFormViewModel:e}=this;if(e.pendingSubtypeChoice)return;e.submit(),this._stashValidationState();const t=this.data.selectedPendingFeature,a=this._hasValidationErrors(t)?t:this.data.pendingFeatures.find(e=>this._hasValidationErrors(e));return a?(await this._startUpdating({feature:a}),void e?.submit()):super.save()}back(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||E(this.data.creationInfo)||this._attachmentsActive||this.parent?super.back(e):this._clearSelectedFeature()}previous(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||E(this.data.creationInfo)||this._attachmentsActive?super.previous(e):this._clearSelectedFeature()}cancelFeature(e){this.data.isSharedTemplateWorkflow?o.getLogger(this).warn("Cannot cancel individual features created by shared templates."):(this.data.removePendingFeature(e),this.sketchViewModel.removeGraphic(e))}static create(e){const{addAttachmentsCallback:t,applyEdits:a,applyEditsFeatureService:i,isNested:r,creationInfo:s,parent:o,snappingManager:n,startAt:l,viewModel:d}=e,c=e.sketchOptions??new A,u=s?.layer,h=u?L(d.editorItems,u):void 0,p=new se({data:new T({creationInfo:s,editorItem:h,parent:o,sketchOptions:c,snappingManager:n,viewModel:d}),isNested:r,onCommit:async e=>{const{creationInfo:r}=e;if(!r)return;p._sketchViewModel.cancel();const s=e.pendingFeatures.toArray(),{layer:o}=r,n=o.capabilities?.editing.supportsGlobalId&&"globalIdField"in o,l=p._attachmentFileInfos,{fullTemplate:c}=e,u=x(p.data),h=F(c)&&u;if(n){if(fe(s),h){let t=ge(u,l);const a=await O(o,d.view);a&&(t=z({edits:t,serviceInfo:a,view:d.view,findOriginalFeature:t=>e.getEditsForPendingFeature(t)?.initialFeature??t})),await i(c.featureService,t,{globalIdUsed:!0,gdbVersion:c.layer.gdbVersion??void 0})}else{const e=we(s,l);await a(o,e,{globalIdUsed:!0})}return}const m=h?await i(c.featureService,u,{gdbVersion:c.layer.gdbVersion??void 0}):[await a(o,{addFeatures:s})];m&&l.size>0&&await Promise.all(m.map(e=>{if(e?.addFeatureResults)return t(o,me(s,e.addFeatureResults,o,l))}))}});return p._set("steps",this._createWorkflowSteps(p,l)),p}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",i(()=>e.effect=t)}const t=e.opacity;return e.opacity=.7,i(()=>e.opacity=t)}async _initializeFullTemplateAndExecutorInfo(e){const{creationInfo:t}=e,{view:a}=e.viewModel;if(!t||!a)return null;const i=await W(t,a);if(e.fullTemplate=i,i&&F(i)){const{createTemplateExecutor:r}=await import("../../editing/sharedTemplates/executor/createTemplateExecutor.js"),s={completionResults:[],executor:await r(i),serviceLayersById:await D(t.layer,a)};e.templateExecutorInfo=s}return i}async _startCreating(){this.removeHandles(ne);const{data:e}=this;if(!e.creationInfo)return;const t=this.data.creationInfo?.maxFeatures;if(t&&this.numPendingFeatures>=t)return this.sketchViewModel.cancel(),void(this.numPendingFeatures&&await this._startUpdating({feature:this.pendingFeatures.at(-1)}));this.createFeatureState="create-new",await R(this._sketchViewModel,this._sketchLayer,e,this._webStyleCache)}async _clearSelectedFeature(){const e=this._featureFormViewModel.pendingSubtypeChoice;e&&(e.resolve("undo"),await e.promise),this._stashValidationState(),this.sketchViewModel.cancel(),this.data.selectedPendingFeature=null,this._featureFormHandle=n(this._featureFormHandle),this._featureFormViewModel.feature=null;const t=this.data.viewModel.attachmentsViewModel;"add"!==t.mode&&"edit"!==t.mode||await(this.data.viewModel.activeWorkflow?.previous())}_stashValidationState(){const e=this._featureFormViewModel.feature,t=e&&this.data.getEditsForPendingFeature(e);t&&(t.submittable=this._featureFormViewModel.submittable)}async _selectFeatureForUpdate({feature:e,initialFeature:t=e}){this._stashValidationState();const{data:a,pendingFeatures:i,_webStyleCache:s}=this;i.includes(e)||a.addPendingFeature(e,t),a.selectedPendingFeature=e;const{_featureFormViewModel:o,_sketchViewModel:l}=this,{creationInfo:d,viewModel:c}=a,{attachmentsViewModel:h,layerInfos:p,view:m}=c;if(!m||!d)return;n(this._featureFormHandle);const f=e.sourceLayer,w=G(p,f),g=w?.formTemplate,y=m.spatialReference;o.set({editType:"INSERT",feature:e,formTemplate:g,spatialReference:y,map:m.map}),"add"!==h.mode&&"edit"!==h.mode||await(c.activeWorkflow?.previous()),h.graphic=e,h.fileInfos.removeAll(),h.mode="view";(this._attachmentFileInfos.get(e)||[]).forEach(({file:e,form:t})=>h.addFile(e,t)),await N(e,s,"2d"===m.type?m.scale:null);const v=a.getEditsForPendingFeature(e);this._featureFormHandle=r([o.on("value-change",async({fieldName:t,value:a})=>{if(v?.updateAttributes(o.getValues()),I(a)){const e=this._visualVariableAttributes;e.size&&!e.size.isUpdatingInteractively&&t===e.size.field&&e.size.setInitialValue(a),e.rotation&&!e.rotation.isUpdatingInteractively&&t===e.rotation.field&&e.rotation.setInitialValue(a)}await N(e,s,"2d"===m.type?m.scale:null)}),l.on(["update","undo","redo"],e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&K(e.toolEventInfo.type))&&o.notifyFeatureGeometryChanged()}),u(()=>o.feature?.sourceLayer,t=>e.sourceLayer=t),u(()=>[o.feature,o.submittable],()=>this._stashValidationState())]),this.createFeatureState="update-pending"}async _startUpdating({feature:e,initialFeature:t=e}){await this._selectFeatureForUpdate({feature:e,initialFeature:t});const{_sketchLayer:a,_sketchViewModel:i,data:r}=this,{creationInfo:s,viewModel:o}=r,{view:n}=o;if(!n||!s)return;const l=e.sourceLayer??s.layer;return M(l)?void 0:(this._visualVariableAttributes=Z(e),q({graphic:e,sketchLayer:a,sketchViewModel:i,sourceLayer:l,visualVariables:this._visualVariableAttributes,webStyleCache:this._webStyleCache}))}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=B(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],t,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){const{creationInfo:t,viewModel:i}=a,{view:r}=i;r&&(E(t)?e.addHandles(await H({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&e.addHandles(i.restrictFeatureTemplatesViewModelToLayer(t.layer),this.id),e.addHandles(i.featureTemplatesViewModel.on("select",({item:t})=>{t&&(a.creationInfo={...a.creationInfo,layer:t.layer,template:t.template},e.next())}),this.id)))},async tearDown(){e.removeHandles(this.id)}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([le,oe,ne,de]),i.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear())}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}})});return J(a,i)}static _configureSketchViewModel(e){const{data:t,_sketchLayer:a,_sketchViewModel:s,_webStyleCache:o}=e,{creationInfo:n,viewModel:l}=t,{view:c}=l,p=[];if(!c)return i();if("2d"===c.type){n&&p.push(e._fadeExistingFeatures(n.layer));const t=d((e,t)=>Promise.all(e.map(e=>N(e,o,t))));p.push(u(()=>c.scale,e=>t(a.graphics,e)))}const m=Q(t.fullTemplate,n?.attributeOverrides),f=u(()=>s.createGraphic,a=>{a&&!e.hasHandles(ne)&&e._updatingHandles.addPromise(X({creationAttributes:m,data:t,sketchViewModel:s,view:c,webStyleCache:o}).then(t=>e.addHandles(t,ne)))}),w=async t=>{if("cancel"!==t.state&&"complete"!==t.state||e.removeHandles(ne),"cancel"===t.state&&null!==c.activeTool&&c.activeTool!==e.sketchViewModel.activeComponent&&(await e._waitForActiveToolCleared(),await e._startCreating()),"complete"===t.state&&t.graphic){const a=await e._processEdits(t.graphic,{scale:"2d"===c.type?c.scale:null,useSourceLayer:!0,webStyleCache:e._webStyleCache});a&&(await e._waitForActiveToolCleared(),await e._startUpdating({feature:a}))}},g=async i=>{const{attachmentsViewModel:r}=l,{_featureFormViewModel:o}=e;if(i.graphics.length>1)return void await e._clearSelectedFeature();const d=i.graphics[0];if("complete"===i.state){const{submittable:t}=o;if(e.numPendingFeatures!==n?.maxFeatures&&t||o.submit(),await e._clearSelectedFeature(),"add"!==r.mode&&"edit"!==r.mode||await(l.activeWorkflow?.previous()),!i.aborted&&c.activeTool===e.sketchViewModel.activeComponent&&(await e.sketchViewModel.wait(),"ready"===e.sketchViewModel.state&&"mesh"!==e.data.creationInfo?.layer.geometryType))return e._startCreating()}else{if("start"===i.state)return d.sourceLayer??=t.creationInfo?.layer,await te({graphic:d,sketchLayer:a,sketchViewModel:s,visualVariables:e._visualVariableAttributes,webStyleCache:e._webStyleCache,sourceLayer:d.sourceLayer}),e._selectFeatureForUpdate({feature:d});if("active"===i.state){await e.updatePendingFeature(d);const t=e._visualVariableAttributes;ae(c,d,i,t)&&await N(d,e._webStyleCache,"2d"===c.type?c.scale:null);const a=d.attributes,{rotation:r,size:s}=t;if(null!=r){const{field:e}=r;o.setValue(e,a[e])}if(null!=s){const{field:e}=s;o.setValue(e,a[e])}}}},y=async a=>{if(a.graphics.forEach(e=>{t.removePendingFeature(e)}),!E(t.creationInfo))return e._startCreating()},v=async()=>{if(E(t.creationInfo))try{await e.data.viewModel.back()}catch{}return e._startCreating()};p.push(f,s.on("create",t=>e._updatingHandles.addPromise(w(t))),s.on("update",t=>e._updatingHandles.addPromise(g(t))),s.on("delete",t=>e._updatingHandles.addPromise(y(t))),h(()=>!e.numPendingFeatures,()=>e._updatingHandles.addPromise(v())),i(()=>{s.cancel()}),he(s,a,t),...pe(t));const F=r(p);return s.addHandles(F),F}_initializeSketchViewModel(){const{data:e}=this,{view:t}=e.viewModel,a=new b({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:"hide",title:"createFeaturesWorkflow-internal"}),r=new re({layer:a,creationMode:"single",sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},view:t});this._sketchLayer=a,this._sketchViewModel=r,t?.map.add(a),this.addHandles([i(()=>{t?.destroyed||t?.map.remove(a),a.destroy()}),u(()=>this.numPendingFeatures>0,e=>this._sketchViewModel.updateOnGraphicClick=e,p)])}_hasValidationErrors(e){return!!e&&(!this.data.isSubmittable(e)||!!this._featureFormViewModel.validateContingencyConstraints(e.attributes,{includeIncompleteViolations:!0})?.length)}async _processEdits(e,t){const{data:a,_featureFormViewModel:i,_sketchLayer:r}=this,{layerInfos:s,view:o}=a.viewModel;i.editType="INSERT",i.map=o?.map,i.spatialReference=o?.spatialReference;const{templateExecutorInfo:n}=a;if(!n){const t=e.clone();return t.geometry=null,await this._addAndInitializeEdits(e,t),e}r.remove(e);const{executor:l}=n,d=l(e.geometry,"completion"),u=c(d)?await d:d;n.completionResults.push(u),Y(u.relationships),i.editType="INSERT",i.map=o?.map,i.spatialReference=o?.spatialReference,u.primary&&a.creationInfo?.attributeOverrides&&(u.primary.graphic.attributes={...u.primary.graphic.attributes,...a.creationInfo.attributeOverrides});for(const c of u.edits){let e=null;if(c.addFeatures)for(const a of c.addFeatures){const i=a.clone();i.geometry=null,null!=a.geometry&&(a.symbol=await V(a,t),r.add(a)),a.sourceLayer!==e?.layer&&(e=G(s,a.sourceLayer));const o=!!u.associationGraphics?.has(a);await this._addAndInitializeEdits(a,i,e,o)}}i.feature=null,await m(()=>!i.updating);return u.edits.reduce((e,t)=>e+(t.addFeatures?.length??0),0)>1?null:u.primary?.graphic}async _addAndInitializeEdits(e,t,a,i=!1){const{data:r,_featureFormViewModel:s}=this,{layerInfos:o}=r.viewModel,n=r.addPendingFeature(e,t,{isAssociation:i});a??=G(o,e.sourceLayer),s.feature=e,s.formTemplate=a?.formTemplate,await m(()=>!s.updating),n.submittable=s.submittable}async _setUpCreatingFeaturesStep(){if(this.hasHandles(le))return;const{data:e,sketchViewModel:s}=this,{creationInfo:o,viewModel:l}=e,{attachmentsViewModel:d,view:c}=l;if(!c||!o?.layer)throw new a("missing-parameters","CreateFeaturesWorkflow requires a view and creationInfo.");const{initialFeature:h,layer:m}=o,f=[],w=[];this._featureFormHandle=n(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},e.editorItem=L(l.editorItems,o.layer),o.template&&(null==e.fullTemplate&&await this._initializeFullTemplateAndExecutorInfo(e),w.push(i(()=>{e.templateExecutorInfo&&(e.templateExecutorInfo.completionResults=[])}))),s.allowDeleteKey=!e.isSharedTemplateWorkflow,$(d),f.push(u(()=>d.mode,e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}}));const g=ee(c);f.push(g);const y=M(o.layer),{template:F}=o,b=!F||_(F)||v(F)&&"feature"===F.type,I=y&&b;try{if(I){const a=h??new t({attributes:Q(e.fullTemplate,o.attributeOverrides),sourceLayer:m}),i=await this._processEdits(a);i&&await this._startUpdating({feature:i})}else f.push(se._configureSketchViewModel(this)),h?(E(o)&&o.geometryToPlace&&(h.attributes=Q(e.fullTemplate,o.attributeOverrides)),s.addGraphic(h),await this._startUpdating({feature:h})):await this._startCreating()}finally{g.remove()}const V=i(()=>{for(const t of e.pendingFeatures)s.removeGraphic(t),e.removePendingFeature(t)}),k=u(()=>c?.timeZone,e=>{this._featureFormViewModel.timeZone=e,this.data.timeZone=e},p),S=i(()=>{E(o)&&l.cancelWorkflow({warnIfNoWorkflow:!1})});this._featureFormHandle&&f.push(this._featureFormHandle),this.addHandles(f,this._handleKeys.beforeCommit),this.addHandles(w,this._handleKeys.afterCommit),this.addHandles([i(()=>d.fileInfos.removeAll()),r(f),r(w),S,V,k],le)}async _waitForActiveToolCleared(){const e=this.data.viewModel.view;if(null==e?.activeTool)return;const t=new AbortController;this.addHandles(s(t),de),await m(()=>null==e?.activeTool,t.signal),t.abort()}};function he(e,t,a){let s=null;const o=()=>e.snappingOptions.featureSources,n=()=>(s=new C({layer:t}),o().add(s),s),d=()=>{null!=s&&(o().remove(s),s=l(s))};return r([u(()=>{const e=a.creationInfo?.layer,t=o().find(t=>t.layer===e);return{hasFeatureLayerSource:!!t,enabled:t?.enabled??!1}},({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return d();s??=n(),s.enabled=t},f),i(d)])}function pe(e){const t=e.viewModel.view;if(!t)return[];const a=[];if("3d"===t.type){const r=new S({view:t});a.push(u(()=>e.selectedPendingFeature,(e,t)=>{r.remove(e),r.add(t)}),i(()=>r.destroy()))}const r=new S({view:t,highlightName:P});return a.push(u(()=>e.temporaryHighlightFeature,e=>{r.removeAll(),r.add(e)}),i(()=>r.destroy())),a}function me(e,t,a,i){const r=[];return t.forEach((t,s)=>{if(!t.error){const o=e[s],n=i.get(o)||[];o.attributes[a.objectIdField]=t.objectId,n.forEach(({form:e})=>r.push({feature:o,attachment:e}))}}),r}function fe(e){for(const t of e){const{sourceLayer:e}=t;e&&"globalIdField"in e&&null!=e.globalIdField&&(t.attributes[e.globalIdField]??=w())}}function we(e,t){const a=[];if(!t||0===t.size)return{addFeatures:e};for(const[i,r]of t)for(const{file:e}of r)a.push({feature:i,attachment:{globalId:w(),data:e}});return a.length?{addFeatures:e,addAttachments:a}:{addFeatures:e}}function ge(e,t){return e.map(e=>{const{addFeatures:a}=e;if(!a||0===a.length)return e;const i=[];for(const r of a){const e=t.get(r);if(e)for(const{file:t}of e)i.push({feature:r,attachment:{globalId:w(),data:t}})}return i.length?{...e,addAttachments:i}:e})}e([g()],ue.prototype,"createFeatureState",void 0),e([g()],ue.prototype,"data",void 0),e([g({constructOnly:!0})],ue.prototype,"isNested",void 0),e([g()],ue.prototype,"featureFormViewModel",null),e([g()],ue.prototype,"hasPendingEdits",null),e([g()],ue.prototype,"hasPreviousStep",null),e([g()],ue.prototype,"_getDrawMeshHelpMessage",void 0),e([g()],ue.prototype,"helpMessage",null),e([g()],ue.prototype,"layer",null),e([g()],ue.prototype,"parent",null),e([g()],ue.prototype,"keyboardCancellationEnabled",null),e([g()],ue.prototype,"reliesOnOwnerAdminPrivileges",null),e([g()],ue.prototype,"shouldShowAttachments",null),e([g()],ue.prototype,"shouldAllowAttachmentEditing",null),e([g()],ue.prototype,"sketchViewModel",null),e([g()],ue.prototype,"availableCreateTools",null),e([g()],ue.prototype,"_attachmentsActive",null),ue=se=e([y("esri.widgets.Editor.CreateFeaturesWorkflow")],ue);const ye=ue;export{ye as default};
5
+ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i,handlesGroup as r,abortHandle as s}from"../../core/handleUtils.js";import"../../core/has.js";import o from"../../core/Logger.js";import{removeMaybe as n,destroyMaybe as l}from"../../core/maybe.js";import{debounce as d,isPromiseLike as c}from"../../core/promiseUtils.js";import{watch as u,when as h,initial as p,whenOnce as m,syncAndInitial as f}from"../../core/reactiveUtils.js";import{generateBracedUUID as w}from"../../core/uuid.js";import{property as g}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import{isSharedTemplateOrMetadata as v,isSharedTemplate as _,isStandardFeatureTemplate as F}from"../../editing/templateUtils.js";import b from"../../layers/GraphicsLayer.js";import{isTable as M}from"../../layers/support/layerUtils.js";import{isNumber as I}from"../../support/guards.js";import{getDisplayedSymbol as V}from"../../symbols/support/symbolUtils.js";import{getDrawHelpMessage as k}from"../../views/draw/support/helpMessageUtils.js";import S from"../../views/draw/support/HighlightHelper.js";import A from"../../views/interactive/sketch/SketchOptions.js";import C from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as P}from"../../views/support/HighlightDefaults.js";import T from"./CreateFeaturesWorkflowData.js";import{isModelUpload as E,handleModelUpload as H}from"./modelUploadUtils.js";import U from"./Workflow.js";import{createToolFromGeometryType as j,findEditorItemForLayer as L,getServiceEditsFromWorkflowData as x,getServiceInfoForLayer as O,orderEditsByRelationshipDependencies as z,getFullTemplateForCreationInfo as W,getServiceLayersById as D,startCreatingNewFeature as R,findLayerInfo as G,updateGraphicSymbolWhenRequired as N,isTerminalUpdateEventType as K,getVisualVariableAttributes as Z,startUpdatingFeatureGeometry as q,createWorkflowSteps as B,avoidFeatureTemplateSelectionWithOnlyOneItem as J,getCreationAttributes as Q,setUpSketchCreateWatchers as X,setRelationshipFields as Y,prepareAttachmentsForCreateFeaturesWorkflow as $,showProgressCursor as ee,setVisualVariablesAndElevationInfoForUpdate as te,visualVariableInteractiveUpdate as ae}from"./workflowUtils.js";import ie from"../FeatureForm/FeatureFormViewModel.js";import re from"../Sketch/SketchViewModel.js";var se;const oe=Symbol(),ne=Symbol(),le=Symbol(),de=Symbol(),ce={point:["point"],multipoint:["multipoint"],polygon:["polygon","freehandPolygon","rectangle","circle"],polyline:["polyline","freehandPolyline"],mesh:[],multipatch:[]};let ue=se=class extends U{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.data=void 0,this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._webStyleCache=new Map,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._formViewModel=new ie,this._sketchLayer=null,this._sketchViewModel=null,this._attachmentFileInfos=new Map,this._isActive=!0}initialize(){this.isNested&&(this._isActive=!1),this._initializeSketchViewModel()}destroy(){this._sketchViewModel.destroy()}get formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return!!this.data.editorItem?.hasInvalidFormTemplate}get hasPendingEdits(){if(this.pendingFeatures.some(e=>!!this.data.getEditsForPendingFeature(e)?.modified))return!0;const{creationInfo:e,upload:t}=this.data,{activeComponent:a,createGraphic:i}=this._sketchViewModel,r=i?.geometry?.type;return!("polyline"!==r&&"polygon"!==r&&"multipoint"!==r||"draw-2d"!==a?.type&&"draw-3d"!==a?.type)&&a.drawOperation.committedVertices.length>0||(!(!t||"pending"!==t.state&&"success"!==t.state)||!!e?.geometryToPlace)}get hasPreviousStep(){return this._stepIndex>0||"update-pending"===this.createFeatureState&&!!this.data.selectedPendingFeature&&!this.parent&&!E(this.data.creationInfo)}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const{_sketchViewModel:a}=this,i=e.layer.geometryType,r=a.createGraphic;if("mesh"===i){this._getDrawMeshHelpMessage||import("../../views/draw/support/helpMessageUtils3d.js").then(e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage});const{view:e}=t;return"3d"===e?.type?this._getDrawMeshHelpMessage?.(r,e):void 0}const{activeCreateToolDrawMode:s,activeTool:o}=a;return k("rectangle"===o||"circle"===o?o:i,r?.geometry,s)}get layer(){return this.data.creationInfo?.layer}get numPendingFeatures(){return this.pendingFeatures.length}get numPendingFeaturesExcludingHidden(){return this.pendingFeatures.filter(e=>this.data.isDisplayable(e)).length}get parent(){return this.data.parent}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){return this.data.editorItem?.capabilities.create.reliesOnOwnerAdminPrivileges??!1}get shouldShowAttachments(){return(this.data.selectedPendingFeature&&this.data.editorItem?.capabilities.create.attachments.enabled)??!1}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get sketchViewModel(){return this._sketchViewModel}get test(){}get availableCreateTools(){const e=this.data.creationInfo?.layer.geometryType,t=this.data.viewModel.view;if(!e)return[];if(this.data.creationInfo?.maxFeatures&&this.data.creationInfo.maxFeatures<=this.numPendingFeatures)return[];if(v(this.data.fullTemplate)){const{tool:t}=j(e,this.data.fullTemplate);return[t]}return"2d"!==t?.type&&"multipoint"===e?[]:[...ce[e]]}get _attachmentsActive(){const e=this.data.viewModel.attachmentsViewModel.mode,t=this.stepId;return this.shouldShowAttachments&&("add"===e||"edit"===e||"adding-attachment"===t||"editing-attachment"===t)}async enter(){this._isActive=!0,"awaiting-feature-creation-info"!==this.stepId&&await this._updatingHandles.addPromise(this._setUpCreatingFeaturesStep())}exit(){this._isActive=!1,this.removeHandles([le])}async updatePendingFeature(e){if(e!==this.data.selectedPendingFeature)return this._sketchViewModel.cancel(),this._startUpdating({feature:e})}async start(){return await super.start(),M(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}async save(){const{formViewModel:e}=this;if(e.pendingSubtypeChoice)return;e.submit(),this._stashValidationState();const t=this.data.selectedPendingFeature,a=this._hasValidationErrors(t)?t:this.data.pendingFeatures.find(e=>this._hasValidationErrors(e));return a?(await this._startUpdating({feature:a}),void e?.submit()):super.save()}back(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||E(this.data.creationInfo)||this._attachmentsActive||this.parent?super.back(e):this._clearSelectedFeature()}previous(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||E(this.data.creationInfo)||this._attachmentsActive?super.previous(e):this._clearSelectedFeature()}cancelFeature(e){this.data.isSharedTemplateWorkflow?o.getLogger(this).warn("Cannot cancel individual features created by shared templates."):(this.data.removePendingFeature(e),this.sketchViewModel.removeGraphic(e))}static create(e){const{addAttachmentsCallback:t,applyEdits:a,applyEditsFeatureService:i,isNested:r,creationInfo:s,parent:o,snappingManager:n,startAt:l,viewModel:d}=e,c=e.sketchOptions??new A,u=s?.layer,h=u?L(d.editorItems,u):void 0,p=new se({data:new T({creationInfo:s,editorItem:h,parent:o,sketchOptions:c,snappingManager:n,viewModel:d}),isNested:r,onCommit:async e=>{const{creationInfo:r}=e;if(!r)return;p._sketchViewModel.cancel();const s=e.pendingFeatures.toArray(),{layer:o}=r,n=o.capabilities?.editing.supportsGlobalId&&"globalIdField"in o,l=p._attachmentFileInfos,{fullTemplate:c}=e,u=x(p.data),h=_(c)&&u;if(n){if(fe(s),h){let t=ge(u,l);const a=await O(o,d.view);a&&(t=z({edits:t,serviceInfo:a,view:d.view,findOriginalFeature:t=>e.getEditsForPendingFeature(t)?.initialFeature??t})),await i(c.featureService,t,{globalIdUsed:!0,gdbVersion:c.layer.gdbVersion??void 0})}else{const e=we(s,l);await a(o,e,{globalIdUsed:!0})}return}const m=h?await i(c.featureService,u,{gdbVersion:c.layer.gdbVersion??void 0}):[await a(o,{addFeatures:s})];m&&l.size>0&&await Promise.all(m.map(e=>{if(e?.addFeatureResults)return t(o,me(s,e.addFeatureResults,o,l))}))}});return p._set("steps",this._createWorkflowSteps(p,l)),p}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",i(()=>e.effect=t)}const t=e.opacity;return e.opacity=.7,i(()=>e.opacity=t)}async _initializeFullTemplateAndExecutorInfo(e){const{creationInfo:t}=e,{view:a}=e.viewModel;if(!t||!a)return null;const i=await W(t,a);if(e.fullTemplate=i,i&&_(i)){const{createTemplateExecutor:r}=await import("../../editing/sharedTemplates/executor/createTemplateExecutor.js"),s={completionResults:[],executor:await r(i),serviceLayersById:await D(t.layer,a)};e.templateExecutorInfo=s}return i}async _startCreating(){this.removeHandles(ne);const{data:e}=this;if(!e.creationInfo)return;const t=this.data.creationInfo?.maxFeatures;if(t&&this.numPendingFeatures>=t)return this.sketchViewModel.cancel(),void(this.numPendingFeatures&&await this._startUpdating({feature:this.pendingFeatures.at(-1)}));this.createFeatureState="create-new",await R(this._sketchViewModel,this._sketchLayer,e,this._webStyleCache)}async _clearSelectedFeature(){const e=this._formViewModel.pendingSubtypeChoice;e&&(e.resolve("undo"),await e.promise),this._stashValidationState(),this.sketchViewModel.cancel(),this.data.selectedPendingFeature=null,this._featureFormHandle=n(this._featureFormHandle),this._formViewModel.feature=null;const t=this.data.viewModel.attachmentsViewModel;"add"!==t.mode&&"edit"!==t.mode||await(this.data.viewModel.activeWorkflow?.previous())}_stashValidationState(){const e=this._formViewModel.feature,t=e&&this.data.getEditsForPendingFeature(e);t&&(t.submittable=this._formViewModel.submittable)}async _selectFeatureForUpdate({feature:e,initialFeature:t=e}){this._stashValidationState();const{data:a,pendingFeatures:i,_webStyleCache:s}=this;i.includes(e)||a.addPendingFeature(e,t),a.selectedPendingFeature=e;const{_formViewModel:o,_sketchViewModel:l}=this,{creationInfo:d,viewModel:c}=a,{attachmentsViewModel:h,layerInfos:p,view:m}=c;if(!m||!d)return;n(this._featureFormHandle);const f=e.sourceLayer,w=G(p,f),g=w?.formTemplate,y=m.spatialReference;o.set({editType:"INSERT",feature:e,formTemplate:g,spatialReference:y,map:m.map}),"add"!==h.mode&&"edit"!==h.mode||await(c.activeWorkflow?.previous()),h.graphic=e,h.fileInfos.removeAll(),h.mode="view";(this._attachmentFileInfos.get(e)||[]).forEach(({file:e,form:t})=>h.addFile(e,t)),await N(e,s,"2d"===m.type?m.scale:null);const v=a.getEditsForPendingFeature(e);this._featureFormHandle=r([o.on("value-change",async({fieldName:t,value:a})=>{if(v?.updateAttributes(o.getValues()),I(a)){const e=this._visualVariableAttributes;e.size&&!e.size.isUpdatingInteractively&&t===e.size.field&&e.size.setInitialValue(a),e.rotation&&!e.rotation.isUpdatingInteractively&&t===e.rotation.field&&e.rotation.setInitialValue(a)}await N(e,s,"2d"===m.type?m.scale:null)}),l.on(["update","undo","redo"],e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&K(e.toolEventInfo.type))&&o.notifyFeatureGeometryChanged()}),u(()=>o.feature?.sourceLayer,t=>e.sourceLayer=t),u(()=>[o.feature,o.submittable],()=>this._stashValidationState())]),this.createFeatureState="update-pending"}async _startUpdating({feature:e,initialFeature:t=e}){await this._selectFeatureForUpdate({feature:e,initialFeature:t});const{_sketchLayer:a,_sketchViewModel:i,data:r}=this,{creationInfo:s,viewModel:o}=r,{view:n}=o;if(!n||!s)return;const l=e.sourceLayer??s.layer;return M(l)?void 0:(this._visualVariableAttributes=Z(e),q({graphic:e,sketchLayer:a,sketchViewModel:i,sourceLayer:l,visualVariables:this._visualVariableAttributes,webStyleCache:this._webStyleCache}))}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=B(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],t,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){const{creationInfo:t,viewModel:i}=a,{view:r}=i;r&&(E(t)?e.addHandles(await H({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&e.addHandles(i.restrictFeatureTemplatesViewModelToLayer(t.layer),this.id),e.addHandles(i.featureTemplatesViewModel.on("select",({item:t})=>{t&&(a.creationInfo={...a.creationInfo,layer:t.layer,template:t.template},e.next())}),this.id)))},async tearDown(){e.removeHandles(this.id)}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([le,oe,ne,de]),i.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear())}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}})});return J(a,i)}static _configureSketchViewModel(e){const{data:t,_sketchLayer:a,_sketchViewModel:s,_webStyleCache:o}=e,{creationInfo:n,viewModel:l}=t,{view:c}=l,p=[];if(!c)return i();if("2d"===c.type){n&&p.push(e._fadeExistingFeatures(n.layer));const t=d((e,t)=>Promise.all(e.map(e=>N(e,o,t))));p.push(u(()=>c.scale,e=>t(a.graphics,e)))}const m=Q(t.fullTemplate,n?.attributeOverrides),f=u(()=>s.createGraphic,a=>{a&&!e.hasHandles(ne)&&e._updatingHandles.addPromise(X({creationAttributes:m,data:t,sketchViewModel:s,view:c,webStyleCache:o}).then(t=>e.addHandles(t,ne)))}),w=async t=>{if("cancel"!==t.state&&"complete"!==t.state||e.removeHandles(ne),"cancel"===t.state&&null!==c.activeTool&&c.activeTool!==e.sketchViewModel.activeComponent&&(await e._waitForActiveToolCleared(),await e._startCreating()),"complete"===t.state&&t.graphic){const a=await e._processEdits(t.graphic,{scale:"2d"===c.type?c.scale:null,useSourceLayer:!0,webStyleCache:e._webStyleCache});a&&(await e._waitForActiveToolCleared(),await e._startUpdating({feature:a}))}},g=async i=>{const{attachmentsViewModel:r}=l,{_formViewModel:o}=e;if(i.graphics.length>1)return void await e._clearSelectedFeature();const d=i.graphics[0];if("complete"===i.state){const{submittable:t}=o;if(e.numPendingFeatures!==n?.maxFeatures&&t||o.submit(),await e._clearSelectedFeature(),"add"!==r.mode&&"edit"!==r.mode||await(l.activeWorkflow?.previous()),!i.aborted&&c.activeTool===e.sketchViewModel.activeComponent&&(await e.sketchViewModel.wait(),"ready"===e.sketchViewModel.state&&"mesh"!==e.data.creationInfo?.layer.geometryType))return e._startCreating()}else{if("start"===i.state)return d.sourceLayer??=t.creationInfo?.layer,await te({graphic:d,sketchLayer:a,sketchViewModel:s,visualVariables:e._visualVariableAttributes,webStyleCache:e._webStyleCache,sourceLayer:d.sourceLayer}),e._selectFeatureForUpdate({feature:d});if("active"===i.state){await e.updatePendingFeature(d);const t=e._visualVariableAttributes;ae(c,d,i,t)&&await N(d,e._webStyleCache,"2d"===c.type?c.scale:null);const a=d.attributes,{rotation:r,size:s}=t;if(null!=r){const{field:e}=r;o.setValue(e,a[e])}if(null!=s){const{field:e}=s;o.setValue(e,a[e])}}}},y=async a=>{if(a.graphics.forEach(e=>{t.removePendingFeature(e)}),!E(t.creationInfo))return e._startCreating()},v=async()=>{if(E(t.creationInfo))try{await e.data.viewModel.back()}catch{}return e._startCreating()};p.push(f,s.on("create",t=>e._updatingHandles.addPromise(w(t))),s.on("update",t=>e._updatingHandles.addPromise(g(t))),s.on("delete",t=>e._updatingHandles.addPromise(y(t))),h(()=>!e.numPendingFeatures,()=>e._updatingHandles.addPromise(v())),i(()=>{s.cancel()}),he(s,a,t),...pe(t));const _=r(p);return s.addHandles(_),_}_initializeSketchViewModel(){const{data:e}=this,{view:t}=e.viewModel,a=new b({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:"hide",title:"createFeaturesWorkflow-internal"}),r=new re({layer:a,creationMode:"single",sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},view:t});this._sketchLayer=a,this._sketchViewModel=r,t?.map.add(a),this.addHandles([i(()=>{t?.destroyed||t?.map.remove(a),a.destroy()}),u(()=>this.numPendingFeatures>0,e=>this._sketchViewModel.updateOnGraphicClick=e,p)])}_hasValidationErrors(e){return!!e&&(!this.data.isSubmittable(e)||!!this._formViewModel.validateContingencyConstraints(e.attributes,{includeIncompleteViolations:!0})?.length)}async _processEdits(e,t){const{data:a,_formViewModel:i,_sketchLayer:r}=this,{layerInfos:s,view:o}=a.viewModel;i.editType="INSERT",i.map=o?.map,i.spatialReference=o?.spatialReference;const{templateExecutorInfo:n}=a;if(!n){const t=e.clone();return t.geometry=null,await this._addAndInitializeEdits(e,t),e}r.remove(e);const{executor:l}=n,d=l(e.geometry,"completion"),u=c(d)?await d:d;n.completionResults.push(u),Y(u.relationships),i.editType="INSERT",i.map=o?.map,i.spatialReference=o?.spatialReference,u.primary&&a.creationInfo?.attributeOverrides&&(u.primary.graphic.attributes={...u.primary.graphic.attributes,...a.creationInfo.attributeOverrides});for(const c of u.edits){let e=null;if(c.addFeatures)for(const a of c.addFeatures){const i=a.clone();i.geometry=null,null!=a.geometry&&(a.symbol=await V(a,t),r.add(a)),a.sourceLayer!==e?.layer&&(e=G(s,a.sourceLayer));const o=!!u.associationGraphics?.has(a);await this._addAndInitializeEdits(a,i,e,o)}}i.feature=null,await m(()=>!i.updating);return u.edits.reduce((e,t)=>e+(t.addFeatures?.length??0),0)>1?null:u.primary?.graphic}async _addAndInitializeEdits(e,t,a,i=!1){const{data:r,_formViewModel:s}=this,{layerInfos:o}=r.viewModel,n=r.addPendingFeature(e,t,{isAssociation:i});a??=G(o,e.sourceLayer),s.feature=e,s.formTemplate=a?.formTemplate,await m(()=>!s.updating),n.submittable=s.submittable}async _setUpCreatingFeaturesStep(){if(this.hasHandles(le))return;const{data:e,sketchViewModel:s}=this,{creationInfo:o,viewModel:l}=e,{attachmentsViewModel:d,view:c}=l;if(!c||!o?.layer)throw new a("missing-parameters","CreateFeaturesWorkflow requires a view and creationInfo.");const{initialFeature:h,layer:m}=o,f=[],w=[];this._featureFormHandle=n(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},e.editorItem=L(l.editorItems,o.layer),o.template&&(null==e.fullTemplate&&await this._initializeFullTemplateAndExecutorInfo(e),w.push(i(()=>{e.templateExecutorInfo&&(e.templateExecutorInfo.completionResults=[])}))),s.allowDeleteKey=!e.isSharedTemplateWorkflow,$(d),f.push(u(()=>d.mode,e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}}));const g=ee(c);f.push(g);const y=M(o.layer),{template:_}=o,b=!_||F(_)||v(_)&&"feature"===_.type,I=y&&b;try{if(I){const a=h??new t({attributes:Q(e.fullTemplate,o.attributeOverrides),sourceLayer:m}),i=await this._processEdits(a);i&&await this._startUpdating({feature:i})}else f.push(se._configureSketchViewModel(this)),h?(E(o)&&o.geometryToPlace&&(h.attributes=Q(e.fullTemplate,o.attributeOverrides)),s.addGraphic(h),await this._startUpdating({feature:h})):await this._startCreating()}finally{g.remove()}const V=i(()=>{for(const t of e.pendingFeatures)s.removeGraphic(t),e.removePendingFeature(t)}),k=u(()=>c?.timeZone,e=>{this._formViewModel.timeZone=e,this.data.timeZone=e},p),S=i(()=>{E(o)&&l.cancelWorkflow({warnIfNoWorkflow:!1})});this._featureFormHandle&&f.push(this._featureFormHandle),this.addHandles(f,this._handleKeys.beforeCommit),this.addHandles(w,this._handleKeys.afterCommit),this.addHandles([i(()=>d.fileInfos.removeAll()),r(f),r(w),S,V,k],le)}async _waitForActiveToolCleared(){const e=this.data.viewModel.view;if(null==e?.activeTool)return;const t=new AbortController;this.addHandles(s(t),de),await m(()=>null==e?.activeTool,t.signal),t.abort()}};function he(e,t,a){let s=null;const o=()=>e.snappingOptions.featureSources,n=()=>(s=new C({layer:t}),o().add(s),s),d=()=>{null!=s&&(o().remove(s),s=l(s))};return r([u(()=>{const e=a.creationInfo?.layer,t=o().find(t=>t.layer===e);return{hasFeatureLayerSource:!!t,enabled:t?.enabled??!1}},({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return d();s??=n(),s.enabled=t},f),i(d)])}function pe(e){const t=e.viewModel.view;if(!t)return[];const a=[];if("3d"===t.type){const r=new S({view:t});a.push(u(()=>e.selectedPendingFeature,(e,t)=>{r.remove(e),r.add(t)}),i(()=>r.destroy()))}const r=new S({view:t,highlightName:P});return a.push(u(()=>e.temporaryHighlightFeature,e=>{r.removeAll(),r.add(e)}),i(()=>r.destroy())),a}function me(e,t,a,i){const r=[];return t.forEach((t,s)=>{if(!t.error){const o=e[s],n=i.get(o)||[];o.attributes[a.objectIdField]=t.objectId,n.forEach(({form:e})=>r.push({feature:o,attachment:e}))}}),r}function fe(e){for(const t of e){const{sourceLayer:e}=t;e&&"globalIdField"in e&&null!=e.globalIdField&&(t.attributes[e.globalIdField]??=w())}}function we(e,t){const a=[];if(!t||0===t.size)return{addFeatures:e};for(const[i,r]of t)for(const{file:e}of r)a.push({feature:i,attachment:{globalId:w(),data:e}});return a.length?{addFeatures:e,addAttachments:a}:{addFeatures:e}}function ge(e,t){return e.map(e=>{const{addFeatures:a}=e;if(!a||0===a.length)return e;const i=[];for(const r of a){const e=t.get(r);if(e)for(const{file:t}of e)i.push({feature:r,attachment:{globalId:w(),data:t}})}return i.length?{...e,addAttachments:i}:e})}e([g()],ue.prototype,"createFeatureState",void 0),e([g()],ue.prototype,"data",void 0),e([g({constructOnly:!0})],ue.prototype,"isNested",void 0),e([g()],ue.prototype,"formViewModel",null),e([g()],ue.prototype,"hasInvalidFormTemplate",null),e([g()],ue.prototype,"hasPendingEdits",null),e([g()],ue.prototype,"hasPreviousStep",null),e([g()],ue.prototype,"_getDrawMeshHelpMessage",void 0),e([g()],ue.prototype,"helpMessage",null),e([g()],ue.prototype,"layer",null),e([g()],ue.prototype,"parent",null),e([g()],ue.prototype,"keyboardCancellationEnabled",null),e([g()],ue.prototype,"reliesOnOwnerAdminPrivileges",null),e([g()],ue.prototype,"shouldShowAttachments",null),e([g()],ue.prototype,"shouldAllowAttachmentEditing",null),e([g()],ue.prototype,"sketchViewModel",null),e([g()],ue.prototype,"availableCreateTools",null),e([g()],ue.prototype,"_attachmentsActive",null),ue=se=e([y("esri.widgets.Editor.CreateFeaturesWorkflow")],ue);const ye=ue;export{ye as default};