@arcgis/core 4.24.0-next.20220329 → 4.24.0-next.20220401

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 (456) hide show
  1. package/PopupTemplate.js +1 -1
  2. package/WebMap.js +1 -1
  3. package/WebScene.js +1 -1
  4. package/analysis/LineOfSightAnalysisObserver.js +1 -1
  5. package/analysis/LineOfSightAnalysisTarget.js +1 -1
  6. package/arcade/featureset/actions/Adapted.js +1 -1
  7. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  8. package/arcade/featureset/sources/FeatureLayerMemory.js +1 -1
  9. package/arcade/featureset/sources/FeatureLayerRelated.js +1 -1
  10. package/arcade/featureset/support/FeatureSet.js +1 -1
  11. package/arcade/featureset/support/RecentlyUsedCache.js +1 -1
  12. package/arcade/featureset/support/shared.js +1 -1
  13. package/arcade/functions/convertdirection.js +1 -1
  14. package/arcade/lib/character.js +1 -1
  15. package/arcade/lib/scanner.js +1 -1
  16. package/arcade/lib/tokenizer.js +1 -1
  17. package/arcade/request.js +1 -1
  18. package/arcade/treeAnalysis.js +1 -1
  19. package/assets/esri/core/workers/RemoteClient.js +1 -1
  20. package/assets/esri/core/workers/chunks/0bfedb1dbdff8205e468.js +1 -0
  21. package/assets/esri/core/workers/chunks/{5e472c89a38d6a42b84d.js → 0e29250c24a3a7b1ce13.js} +1 -1
  22. package/assets/esri/core/workers/chunks/0eb9c9477d36cd212f8b.js +1 -0
  23. package/assets/esri/core/workers/chunks/10779a256841c37f2429.js +1 -0
  24. package/assets/esri/core/workers/chunks/10a119889d1ab13402a3.js +1 -0
  25. package/assets/esri/core/workers/chunks/125b14c2ccd96d7c20c2.js +1 -0
  26. package/assets/esri/core/workers/chunks/23ec33a30db201e8b2c3.js +1 -0
  27. package/assets/esri/core/workers/chunks/2530e8ccf6e12787ce76.js +1 -0
  28. package/assets/esri/core/workers/chunks/2d9e97ba5b50aec4dd01.js +1 -0
  29. package/assets/esri/core/workers/chunks/365dc146398420f13f82.js +1 -0
  30. package/assets/esri/core/workers/chunks/3ae2827e8d55d6713d20.js +1 -0
  31. package/assets/esri/core/workers/chunks/3e3eebaa0844742db2f2.js +1 -0
  32. package/assets/esri/core/workers/chunks/3fd5b2d6eccd9098d492.js +1 -0
  33. package/assets/esri/core/workers/chunks/404f1d7bce014c7e6965.js +1 -0
  34. package/assets/esri/core/workers/chunks/411b7777bb5e943c156f.js +1 -0
  35. package/assets/esri/core/workers/chunks/{12ca192a5233bb2875d0.js → 4312902ab6e42fbe119b.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{4ef07f50da39f8607c1c.js → 44e95e87bd9e820aeb53.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{4d4c5e535d8b9ceb865a.js → 4810edf605838d07e5c5.js} +1 -1
  38. package/assets/esri/core/workers/chunks/4bce446391176a9d4588.js +1 -0
  39. package/assets/esri/core/workers/chunks/52a0e387073ea264e194.js +1 -0
  40. package/assets/esri/core/workers/chunks/560234694f3e53802aff.js +1 -0
  41. package/assets/esri/core/workers/chunks/5633710daeb3bbb79bcf.js +1 -0
  42. package/assets/esri/core/workers/chunks/5682039666f874836451.js +1 -0
  43. package/assets/esri/core/workers/chunks/6f01905936396fe87865.js +1 -0
  44. package/assets/esri/core/workers/chunks/6f7917da7166e8c6854b.js +1 -0
  45. package/assets/esri/core/workers/chunks/7388824eac8da01ea03d.js +1 -0
  46. package/assets/esri/core/workers/chunks/7745efef7d5119d0b087.js +1 -0
  47. package/assets/esri/core/workers/chunks/794b47764ebb0257ed41.js +1 -0
  48. package/assets/esri/core/workers/chunks/{da64dedf9270b64f42b2.js → 79bdb26244ec7b4472fe.js} +1 -1
  49. package/assets/esri/core/workers/chunks/79ec28b3e3c57fe026aa.js +1 -0
  50. package/assets/esri/core/workers/chunks/81e9d860a044acec74ce.js +1 -0
  51. package/assets/esri/core/workers/chunks/831dc0187f71e658550c.js +1 -0
  52. package/assets/esri/core/workers/chunks/86ad6b020c01850d9095.js +1 -0
  53. package/assets/esri/core/workers/chunks/{fb7397da8d4ec2ae4587.js → 87458fbf395338511662.js} +1 -1
  54. package/assets/esri/core/workers/chunks/{1a859be598ad96bb4719.js → 8771296b537f366596c4.js} +18 -18
  55. package/assets/esri/core/workers/chunks/8958cd555f4887526e8b.js +1 -0
  56. package/assets/esri/core/workers/chunks/{e57b71ba70f088a3a052.js → 90dcd86cdef90099abfa.js} +1 -1
  57. package/assets/esri/core/workers/chunks/93067e27eea5844edc6c.js +1 -0
  58. package/assets/esri/core/workers/chunks/{9fbee2d9bf50c4c148c6.js → 9a146c9e9b4bf7fba88f.js} +1 -1
  59. package/assets/esri/core/workers/chunks/9b9821772b6cbe189fe0.js +1 -0
  60. package/assets/esri/core/workers/chunks/{6c4ce530b493c6f7c430.js → 9df2f9f7c28b31866be8.js} +1 -1
  61. package/assets/esri/core/workers/chunks/{d0620ce99b620621d8bc.js → a0552044e123a3c51ddf.js} +1 -1
  62. package/assets/esri/core/workers/chunks/acc1a4acd57f5657e782.js +1 -0
  63. package/assets/esri/core/workers/chunks/b055ae7c54796751b64c.js +1 -0
  64. package/assets/esri/core/workers/chunks/{acc2cfb116fee7f82ae9.js → b26bd8fde2fc65bb67fb.js} +1 -1
  65. package/assets/esri/core/workers/chunks/{9b45b94c4dbdc8d2c5fd.js → b34ba22c7a5adce8a7a2.js} +1 -1
  66. package/assets/esri/core/workers/chunks/b75665d0bf417c6ef24a.js +1 -0
  67. package/assets/esri/core/workers/chunks/bd50ec30688463b821d1.js +1 -0
  68. package/assets/esri/core/workers/chunks/c28f7ae4756ad1ba94bd.js +1 -0
  69. package/assets/esri/core/workers/chunks/c4f713959d4115b87c6c.js +1 -0
  70. package/assets/esri/core/workers/chunks/c58aa209492bd94b7aad.js +1 -0
  71. package/assets/esri/core/workers/chunks/{9b117097b7be0efd21d4.js → c59b0b58e24e6a60cf3e.js} +1 -1
  72. package/assets/esri/core/workers/chunks/c7bd5a4d318299388645.js +1 -0
  73. package/assets/esri/core/workers/chunks/c7cee13a962396b23a5e.js +1 -0
  74. package/assets/esri/core/workers/chunks/{3bbff5ea1ea0e955c592.js → cd3679fa86129ebabfdf.js} +1 -1
  75. package/assets/esri/core/workers/chunks/{1a36dc0daffd536ea44d.js → cee7ce362860717713bf.js} +1 -1
  76. package/assets/esri/core/workers/chunks/cf463d6309f14df2f2fa.js +1 -0
  77. package/assets/esri/core/workers/chunks/{224c0e64160bdc170051.js → d076627bb7dadea89e89.js} +1 -1
  78. package/assets/esri/core/workers/chunks/{fff4200bc61b82dd6193.js → d1d1c45243af614f2e74.js} +1 -1
  79. package/assets/esri/core/workers/chunks/{1e0498dc9836658d9aba.js → d5fd12ea541c1a6b7fce.js} +1 -1
  80. package/assets/esri/core/workers/chunks/{10322d990cda5aedf2f0.js → d6e32ca237ad9309c76a.js} +1 -1
  81. package/assets/esri/core/workers/chunks/e06ad3a3d71154fed654.js +1 -0
  82. package/assets/esri/core/workers/chunks/{7a77d4cd27c30f1a5cae.js → ee3387a43dfbb3df23e1.js} +1 -1
  83. package/assets/esri/core/workers/chunks/{5d5fa2b1fc48a17eb9ab.js → f4fc165420d449e442b8.js} +1 -1
  84. package/assets/esri/core/workers/chunks/{3d6d9906a534ddd8fa37.js → f5ee03f3fca7a75192de.js} +1 -1
  85. package/assets/esri/themes/base/widgets/_Daylight.scss +1 -1
  86. package/assets/esri/themes/base/widgets/_ElevationProfile.scss +1 -1
  87. package/assets/esri/themes/base/widgets/_Weather.scss +1 -1
  88. package/assets/esri/themes/base/widgets/_Widget.scss +12 -0
  89. package/assets/esri/themes/dark/main.css +1 -1
  90. package/assets/esri/themes/dark-blue/main.css +1 -1
  91. package/assets/esri/themes/dark-green/main.css +1 -1
  92. package/assets/esri/themes/dark-purple/main.css +1 -1
  93. package/assets/esri/themes/dark-red/main.css +1 -1
  94. package/assets/esri/themes/light/main.css +1 -1
  95. package/assets/esri/themes/light/view.css +1 -1
  96. package/assets/esri/themes/light-blue/main.css +1 -1
  97. package/assets/esri/themes/light-green/main.css +1 -1
  98. package/assets/esri/themes/light-purple/main.css +1 -1
  99. package/assets/esri/themes/light-red/main.css +1 -1
  100. package/chunks/ComponentShader.glsl.js +25 -25
  101. package/chunks/HighlightApply.glsl.js +36 -0
  102. package/chunks/HighlightBlur.glsl.js +26 -0
  103. package/chunks/HighlightDownsample.glsl.js +12 -0
  104. package/chunks/ImageMaterial.glsl.js +8 -8
  105. package/chunks/LineCallout.glsl.js +1 -1
  106. package/chunks/Pattern.glsl.js +2 -2
  107. package/chunks/SimpleAtmosphere.glsl.js +7 -7
  108. package/chunks/Stars.glsl.js +1 -1
  109. package/chunks/arcade.js +1 -1
  110. package/chunks/color.js +1 -1
  111. package/chunks/languageUtils.js +1 -1
  112. package/chunks/mat3.js +1 -1
  113. package/copyright.txt +2 -2
  114. package/core/AsyncUpdate.js +1 -1
  115. package/core/Evented.js +1 -1
  116. package/core/PooledArray.js +1 -1
  117. package/core/accessorSupport/diffUtils.js +1 -1
  118. package/core/accessorSupport/get.js +1 -1
  119. package/core/accessorSupport/read.js +1 -1
  120. package/core/accessorSupport/set.js +1 -1
  121. package/core/accessorSupport/tracking.js +1 -1
  122. package/core/accessorSupport/utils.js +1 -1
  123. package/core/arrayUtils.js +1 -1
  124. package/core/libs/gl-matrix-2/mat3.js +1 -1
  125. package/core/libs/gl-matrix-2/math/mat3.js +1 -1
  126. package/core/number.js +1 -1
  127. package/core/object.js +1 -1
  128. package/core/string.js +1 -1
  129. package/core/unitUtils.js +1 -1
  130. package/core/watchUtils.js +1 -1
  131. package/core/workers/RemoteClient.js +1 -1
  132. package/exports/csv.js +1 -1
  133. package/geometry/support/heightModelInfoUtils.js +1 -1
  134. package/geometry/support/meshUtils/exporters/gltf/geometry.js +1 -1
  135. package/geometry/support/normalizeUtils.js +1 -1
  136. package/identity/IdentityManagerBase.js +1 -1
  137. package/interfaces.d.ts +155 -20
  138. package/layers/ImageryLayer.js +1 -1
  139. package/layers/MapImageLayer.js +1 -1
  140. package/layers/RouteLayer.js +1 -1
  141. package/layers/SceneLayer.js +1 -1
  142. package/layers/SubtypeGroupLayer.js +1 -1
  143. package/layers/TileLayer.js +1 -1
  144. package/layers/VectorTileLayer.js +1 -1
  145. package/layers/WMSLayer.js +1 -1
  146. package/layers/WMTSLayer.js +1 -1
  147. package/layers/WebTileLayer.js +1 -1
  148. package/layers/graphics/data/AttributesBuilder.js +1 -1
  149. package/layers/graphics/data/QueryEngine.js +1 -1
  150. package/layers/graphics/editingSupport.js +1 -1
  151. package/layers/graphics/sources/connections/GeoEventConnection.js +1 -1
  152. package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
  153. package/layers/graphics/sources/support/inferenceUtils.js +1 -1
  154. package/layers/mixins/ArcGISCachedService.js +1 -1
  155. package/layers/mixins/ArcGISImageService.js +1 -1
  156. package/layers/ogc/ogcFeatureUtils.js +1 -1
  157. package/layers/support/ExportImageServiceParameters.js +1 -1
  158. package/layers/support/PixelBlock.js +1 -1
  159. package/layers/support/RasterJobHandler.js +1 -1
  160. package/layers/support/SpriteSource.js +1 -1
  161. package/layers/support/Sublayer.js +1 -1
  162. package/layers/support/TilemapCache.js +1 -1
  163. package/layers/support/WMTSSublayer.js +1 -1
  164. package/layers/support/arcgisLayerUrl.js +1 -1
  165. package/layers/support/fieldUtils.js +1 -1
  166. package/layers/support/kmlUtils.js +1 -1
  167. package/layers/support/layerUtils.js +1 -1
  168. package/layers/support/rasterDatasets/ImageAuxRaster.js +1 -1
  169. package/layers/support/rasterDatasets/ImageServerRaster.js +1 -1
  170. package/layers/support/rasterDatasets/RasterFactory.js +1 -1
  171. package/layers/support/rasterDatasets/WCSRaster.js +1 -1
  172. package/layers/support/rasterDatasets/multipartParser.js +1 -1
  173. package/layers/support/rasterDatasets/wcsCoverageParser.js +1 -1
  174. package/layers/support/rasterDatasets/xmlUtilities.js +1 -1
  175. package/layers/support/rasterFormats/RasterCodec.js +1 -1
  176. package/layers/support/rasterFormats/TiffDecoder.js +1 -1
  177. package/layers/support/rasterFunctions/pixelUtils.js +1 -1
  178. package/layers/support/vectorTileLayerLoader.js +1 -1
  179. package/layers/support/wmsUtils.js +1 -1
  180. package/layers/support/wmtsUtils.js +1 -1
  181. package/libs/i3s/I3SModule.js +1 -1
  182. package/libs/vxl/VxlModule.js +1 -1
  183. package/package.json +1 -1
  184. package/portal/Portal.js +1 -1
  185. package/portal/PortalItem.js +1 -1
  186. package/portal/schemas/definitions.js +1 -1
  187. package/portal/support/layersLoader.js +1 -1
  188. package/portal/support/portalItemUtils.js +1 -1
  189. package/portal/support/portalLayers.js +1 -1
  190. package/renderers/support/AuthoringInfoVisualVariable.js +1 -1
  191. package/renderers/support/DictionaryLoader.js +1 -1
  192. package/renderers/support/RasterSymbolizer.js +1 -1
  193. package/renderers/support/numberUtils.js +1 -1
  194. package/renderers/support/rasterRendererHelper.js +1 -1
  195. package/renderers/support/utils.js +1 -1
  196. package/request.js +1 -1
  197. package/rest/imageService.js +1 -1
  198. package/rest/operations/find.js +1 -1
  199. package/rest/query/operations/query.js +1 -1
  200. package/rest/query/operations/queryRelatedRecords.js +1 -1
  201. package/rest/query/operations/queryTopFeatures.js +1 -1
  202. package/rest/support/DirectionLine.js +1 -1
  203. package/rest/support/DirectionPoint.js +1 -1
  204. package/rest/support/PointBarrier.js +1 -1
  205. package/rest/support/PolygonBarrier.js +1 -1
  206. package/rest/support/PolylineBarrier.js +1 -1
  207. package/rest/support/RouteInfo.js +1 -1
  208. package/rest/support/Stop.js +1 -1
  209. package/smartMapping/labels/clusters.js +1 -1
  210. package/smartMapping/popup/dotDensity.js +1 -1
  211. package/smartMapping/popup/support/clusterUtils.js +1 -1
  212. package/smartMapping/popup/support/utils.js +1 -1
  213. package/smartMapping/raster/support/utils.js +1 -1
  214. package/smartMapping/renderers/color.js +1 -1
  215. package/smartMapping/renderers/location.js +1 -1
  216. package/smartMapping/renderers/predominance.js +1 -1
  217. package/smartMapping/renderers/relationship.js +1 -1
  218. package/smartMapping/renderers/size.js +1 -1
  219. package/smartMapping/renderers/support/utils.js +1 -1
  220. package/smartMapping/renderers/type.js +1 -1
  221. package/smartMapping/renderers/univariateColorSize.js +1 -1
  222. package/smartMapping/statistics/summaryStatisticsForAge.js +1 -1
  223. package/smartMapping/statistics/support/ageUtils.js +1 -1
  224. package/smartMapping/statistics/support/utils.js +1 -1
  225. package/smartMapping/support/adapters/SceneLayerAdapter.js +1 -1
  226. package/smartMapping/support/adapters/support/utils.js +1 -1
  227. package/smartMapping/support/utils.js +1 -1
  228. package/smartMapping/symbology/support/Theme.js +1 -1
  229. package/smartMapping/symbology/support/colorRamps.js +1 -1
  230. package/smartMapping/symbology/support/symbologyUtils.js +1 -1
  231. package/smartMapping/symbology/support/utils.js +1 -1
  232. package/statistics/utils.js +1 -1
  233. package/support/basemapDefinitions.js +1 -1
  234. package/support/basemapUtils.js +1 -1
  235. package/support/elevationInfoUtils.js +1 -1
  236. package/support/popupUtils.js +1 -1
  237. package/support/revision.js +1 -1
  238. package/symbols/cim/CIMSymbolRasterizer.js +1 -1
  239. package/symbols/cim/cimAnalyzer.js +1 -1
  240. package/symbols/cim/utils.js +1 -1
  241. package/symbols/support/previewSymbol3D.js +1 -1
  242. package/symbols/support/renderUtils.js +1 -1
  243. package/symbols/support/symbolLayerUtils.js +1 -1
  244. package/views/2d/engine/Bitmap.js +1 -1
  245. package/views/2d/engine/flow/FlowDisplayObject.js +1 -1
  246. package/views/2d/engine/imagery/RasterBitmap.js +1 -1
  247. package/views/2d/engine/imagery/RasterVFDisplayObject.js +1 -1
  248. package/views/2d/engine/vectorTiles/TextShaping.js +1 -1
  249. package/views/2d/engine/vectorTiles/TileParser.js +1 -1
  250. package/views/2d/engine/vectorTiles/buckets/SymbolBucket.js +1 -1
  251. package/views/2d/engine/vectorTiles/expression/expression.js +1 -1
  252. package/views/2d/engine/vectorTiles/shaders/VTLMaterial.js +1 -1
  253. package/views/2d/engine/webgl/Profiler.js +1 -1
  254. package/views/2d/engine/webgl/Utils.js +1 -1
  255. package/views/2d/engine/webgl/brushes/WGLGeometryBrush.js +1 -1
  256. package/views/2d/engine/webgl/definitions.js +1 -1
  257. package/views/2d/engine/webgl/effects/HittestEffect.js +1 -1
  258. package/views/2d/engine/webgl/effects/HittestEffectVTL.js +1 -1
  259. package/views/2d/engine/webgl/mesh/templates/WGLTemplateStore.js +1 -1
  260. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  261. package/views/2d/engine/webgl/util/Lock.js +1 -1
  262. package/views/2d/layers/RouteLayerView2D.js +1 -1
  263. package/views/2d/layers/features/schemaUtils.js +1 -1
  264. package/views/2d/layers/features/sources/SnapshotFeatureSource.js +1 -1
  265. package/views/2d/layers/features/support/AttributeStore.js +1 -1
  266. package/views/2d/layers/features/support/FeatureSetReaderPBF.js +1 -1
  267. package/views/2d/layers/features/tileRenderers/SymbolTileRenderer.js +1 -1
  268. package/views/2d/layers/support/webStyleUtils.js +1 -1
  269. package/views/2d/support/Timeline.js +1 -1
  270. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  271. package/views/3d/analysis/LineOfSight/LineOfSightIntersectionResult.js +1 -1
  272. package/views/3d/analysis/LineOfSight/LineOfSightRayIntersector.js +1 -1
  273. package/views/3d/analysis/Slice/SliceController.js +1 -1
  274. package/views/3d/environment/PanoramicAtmosphere.js +1 -1
  275. package/views/3d/environment/SceneViewAtmosphere.js +1 -1
  276. package/views/3d/environment/StarsTechnique.js +1 -1
  277. package/views/3d/externalRenderers/ExternalRendererStore.js +1 -1
  278. package/views/3d/glTF/loader.js +1 -1
  279. package/views/3d/interactive/analysisTools/lineOfSight/LineOfSightTool.js +1 -1
  280. package/views/3d/interactive/analysisTools/slice/SliceTool.js +1 -1
  281. package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
  282. package/views/3d/layers/FeatureLikeLayerView3D.js +1 -1
  283. package/views/3d/layers/I3SMeshView3D.js +1 -1
  284. package/views/3d/layers/ImageryLayerView3D.js +1 -1
  285. package/views/3d/layers/LayerView3D.js +1 -1
  286. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  287. package/views/3d/layers/RouteLayerView3D.js +1 -1
  288. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  289. package/views/3d/layers/VectorTileLayerView3D.js +1 -1
  290. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  291. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  292. package/views/3d/layers/i3s/I3SMeshViewFilter.js +1 -1
  293. package/views/3d/layers/i3s/I3SNodeLoader.js +1 -1
  294. package/views/3d/layers/i3s/I3SUtil.js +1 -1
  295. package/views/3d/layers/i3s/IDBMockCache.js +5 -0
  296. package/views/3d/layers/i3s/PointCloudWorkerUtil.js +1 -1
  297. package/views/3d/layers/support/PopupSceneLayerView.js +1 -1
  298. package/views/3d/state/ViewStateManager.js +1 -1
  299. package/views/3d/state/controllers/RotateController.js +1 -1
  300. package/views/3d/state/controllers/global/PinchAndPanController.js +1 -1
  301. package/views/3d/state/controllers/global/ZoomController.js +1 -1
  302. package/views/3d/state/controllers/global/ZoomStepController.js +1 -1
  303. package/views/3d/state/controllers/local/PinchAndPanController.js +1 -1
  304. package/views/3d/state/controllers/local/ZoomController.js +1 -1
  305. package/views/3d/support/HighlightOptions.js +1 -1
  306. package/views/3d/support/buffer/InterleavedLayout.js +1 -1
  307. package/views/3d/support/debugFlags.js +1 -1
  308. package/views/3d/support/orientedBoundingBox.js +1 -1
  309. package/views/3d/terrain/TerrainSurface.js +1 -1
  310. package/views/3d/webgl-engine/Stage.js +1 -1
  311. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  312. package/views/3d/webgl-engine/collections/Component/DepthRange.js +1 -1
  313. package/views/3d/webgl-engine/core/shaderLibrary/ForwardLinearDepth.glsl.js +3 -3
  314. package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexPosition.glsl.js +5 -5
  315. package/views/3d/webgl-engine/core/shaderModules/ShaderBuilder.js +1 -1
  316. package/views/3d/webgl-engine/lib/HighlightHelper.js +1 -1
  317. package/views/3d/webgl-engine/lib/Object3D.js +1 -1
  318. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  319. package/views/3d/webgl-engine/lib/edgeRendering/EdgeRenderer.js +1 -1
  320. package/views/3d/webgl-engine/lib/edgeRendering/EdgeShaderParameters.js +1 -1
  321. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  322. package/views/3d/webgl-engine/lib/lodRendering/InstanceData.js +1 -1
  323. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  324. package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
  325. package/views/3d/webgl-engine/materials/WaterTechnique.js +1 -1
  326. package/views/3d/webgl-engine/parts/ScreenshotManager.js +1 -1
  327. package/views/3d/webgl-engine/shaders/HighlightApply.glsl.js +5 -0
  328. package/views/3d/webgl-engine/shaders/HighlightApplyTechnique.js +5 -0
  329. package/views/3d/webgl-engine/shaders/HighlightBlur.glsl.js +5 -0
  330. package/views/3d/webgl-engine/shaders/HighlightBlurTechnique.js +5 -0
  331. package/views/3d/webgl-engine/shaders/HighlightDownsample.glsl.js +5 -0
  332. package/views/3d/webgl-engine/shaders/HighlightDownsampleTechnique.js +5 -0
  333. package/views/3d/webgl-engine/shaders/HighlightOptions.js +4 -0
  334. package/views/3d/webgl-engine/shaders/HighlightPassParameters.js +5 -0
  335. package/views/3d/webgl-engine/shaders/ImageMaterial.glsl.js +1 -1
  336. package/views/3d/webgl-engine/shaders/ImageMaterialTechnique.js +1 -1
  337. package/views/3d/webgl-engine/shaders/NativeLineTechnique.js +1 -1
  338. package/views/3d/webgl-engine/shaders/PatternTechnique.js +1 -1
  339. package/views/3d/webgl-engine/shaders/sources/edgeRenderer/AdjustProjectedPosition.glsl.js +5 -7
  340. package/views/3d/webgl-engine/shaders/sources/edgeRenderer/EdgeUtil.glsl.js +14 -14
  341. package/views/SceneView.js +1 -1
  342. package/views/draw/support/GraphicMover.js +1 -1
  343. package/views/input/InputHandler.js +1 -1
  344. package/views/input/InputManager.js +1 -1
  345. package/views/layers/ImageryTileLayerView.js +1 -1
  346. package/views/layers/MapImageLayerView.js +1 -1
  347. package/views/layers/TileLayerView.js +1 -1
  348. package/views/layers/support/popupUtils.js +1 -1
  349. package/views/support/DefaultsFromMap.js +1 -1
  350. package/views/support/Scheduler.js +1 -1
  351. package/views/support/screenshotUtils.js +1 -1
  352. package/views/ui/DefaultUI.js +1 -1
  353. package/views/webgl/ShaderTranspiler.js +1 -1
  354. package/webscene/Slide.js +1 -1
  355. package/webscene/spec-certification/spec.js +1 -1
  356. package/widgets/AreaMeasurement3D/AreaMeasurement3DViewModel.js +1 -1
  357. package/widgets/Attachments/support/attachmentUtils.js +1 -1
  358. package/widgets/Attachments.js +1 -1
  359. package/widgets/Attribution.js +1 -1
  360. package/widgets/BasemapLayerList.js +1 -1
  361. package/widgets/Bookmarks/BookmarksViewModel.js +1 -1
  362. package/widgets/Bookmarks.js +1 -1
  363. package/widgets/BuildingExplorer/support/filterUtils.js +1 -1
  364. package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
  365. package/widgets/CoordinateConversion/support/coordinateConversionUtils.js +1 -1
  366. package/widgets/CoordinateConversion/support/formatUtils.js +1 -1
  367. package/widgets/DirectLineMeasurement3D/DirectLineMeasurement3DViewModel.js +1 -1
  368. package/widgets/Directions/DirectionsViewModel.js +1 -1
  369. package/widgets/Directions.js +1 -1
  370. package/widgets/Editor/EditorViewModel.js +1 -1
  371. package/widgets/Editor/workflowUtils.js +1 -1
  372. package/widgets/Editor.js +1 -1
  373. package/widgets/ElevationProfile/ElevationProfileViewModel.js +1 -1
  374. package/widgets/Feature/FeatureMedia.js +1 -1
  375. package/widgets/Feature/support/featureUtils.js +1 -1
  376. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  377. package/widgets/FeatureForm/InputField.js +1 -1
  378. package/widgets/FeatureForm.js +1 -1
  379. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  380. package/widgets/FeatureTable/Grid/Grid.js +1 -1
  381. package/widgets/FeatureTable/support/FeatureStore.js +1 -1
  382. package/widgets/FeatureTemplates.js +1 -1
  383. package/widgets/FloorFilter/FloorFilterViewModel.js +1 -1
  384. package/widgets/LayerList/ListItemPanel.js +1 -1
  385. package/widgets/LayerList.js +1 -1
  386. package/widgets/Legend/LegendViewModel.js +1 -1
  387. package/widgets/Legend/styles/Card.js +1 -1
  388. package/widgets/Legend/styles/Classic.js +1 -1
  389. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  390. package/widgets/Legend/support/colorRampUtils.js +1 -1
  391. package/widgets/Legend/support/relationshipRampUtils.js +1 -1
  392. package/widgets/Legend/support/sizeRampUtils.js +1 -1
  393. package/widgets/Popup/PopupViewModel.js +1 -1
  394. package/widgets/Popup/actionUtils.js +1 -1
  395. package/widgets/Print/PrintViewModel.js +1 -1
  396. package/widgets/Print.js +1 -1
  397. package/widgets/ScaleBar/ScaleBarViewModel.js +1 -1
  398. package/widgets/Search/SearchViewModel.js +1 -1
  399. package/widgets/Search/support/layerSearchUtils.js +1 -1
  400. package/widgets/Slider.js +1 -1
  401. package/widgets/Swipe.js +1 -1
  402. package/widgets/TableList.js +1 -1
  403. package/widgets/TimeSlider/TimeSliderViewModel.js +1 -1
  404. package/widgets/TimeSlider.js +1 -1
  405. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
  406. package/widgets/support/DatePicker.js +1 -1
  407. package/widgets/support/Popover.js +1 -1
  408. package/widgets/support/SnappingControls.js +1 -1
  409. package/widgets/support/TimePicker.js +1 -1
  410. package/widgets/support/timeWidgetUtils.js +1 -1
  411. package/assets/esri/core/workers/chunks/083a5d10f8e243641cb9.js +0 -1
  412. package/assets/esri/core/workers/chunks/0872812ce4d0ec8faf8f.js +0 -1
  413. package/assets/esri/core/workers/chunks/0bc26899780c33637746.js +0 -1
  414. package/assets/esri/core/workers/chunks/113362697da1b69deaed.js +0 -1
  415. package/assets/esri/core/workers/chunks/11a2f9708938eac98815.js +0 -1
  416. package/assets/esri/core/workers/chunks/11a45709b703be84caaf.js +0 -1
  417. package/assets/esri/core/workers/chunks/1c1294ff1ebbd8f774f7.js +0 -1
  418. package/assets/esri/core/workers/chunks/1c915cc9a9d5729b6f17.js +0 -1
  419. package/assets/esri/core/workers/chunks/31786756b3d44540f8c0.js +0 -1
  420. package/assets/esri/core/workers/chunks/36a6f34fe40785beff5d.js +0 -1
  421. package/assets/esri/core/workers/chunks/373c16f8b8093d001064.js +0 -1
  422. package/assets/esri/core/workers/chunks/382a331a592abb61267f.js +0 -1
  423. package/assets/esri/core/workers/chunks/3bf106fe34e3992032c4.js +0 -1
  424. package/assets/esri/core/workers/chunks/3dcec610f1c1497d87bc.js +0 -1
  425. package/assets/esri/core/workers/chunks/46495e726d8739260d44.js +0 -1
  426. package/assets/esri/core/workers/chunks/4a82a6a473b3d540d0be.js +0 -1
  427. package/assets/esri/core/workers/chunks/4b6719377a95ac10fa43.js +0 -1
  428. package/assets/esri/core/workers/chunks/4d2ef57ff3a5cfc1313f.js +0 -1
  429. package/assets/esri/core/workers/chunks/4fd2b8153d62592210a2.js +0 -1
  430. package/assets/esri/core/workers/chunks/56e6a1079269e2964b02.js +0 -1
  431. package/assets/esri/core/workers/chunks/5b4d9786c010d265346c.js +0 -1
  432. package/assets/esri/core/workers/chunks/604637e1c3937b376a0d.js +0 -1
  433. package/assets/esri/core/workers/chunks/60f83257e361f87fa6fd.js +0 -1
  434. package/assets/esri/core/workers/chunks/6d3f80be6fceb2c18b5d.js +0 -1
  435. package/assets/esri/core/workers/chunks/6f827a32646bab0a8777.js +0 -1
  436. package/assets/esri/core/workers/chunks/70bd2ab42e3801ef5974.js +0 -1
  437. package/assets/esri/core/workers/chunks/746222184b361b50d6ba.js +0 -1
  438. package/assets/esri/core/workers/chunks/7fb72b2d11e8d840f982.js +0 -1
  439. package/assets/esri/core/workers/chunks/85bb6a1a7704fcdcbec2.js +0 -1
  440. package/assets/esri/core/workers/chunks/8b4c76cebb100e6c06f8.js +0 -1
  441. package/assets/esri/core/workers/chunks/9586a6b320edb1922926.js +0 -1
  442. package/assets/esri/core/workers/chunks/99638697ffda9022ce92.js +0 -1
  443. package/assets/esri/core/workers/chunks/a9da1cb118ca62a9581d.js +0 -1
  444. package/assets/esri/core/workers/chunks/aaa41a5013eef713c032.js +0 -1
  445. package/assets/esri/core/workers/chunks/ac321f939dd488ff6ce4.js +0 -1
  446. package/assets/esri/core/workers/chunks/add6027a96398ecf69de.js +0 -1
  447. package/assets/esri/core/workers/chunks/b75206b46ba81606087c.js +0 -1
  448. package/assets/esri/core/workers/chunks/bf8456828e38a768eba3.js +0 -1
  449. package/assets/esri/core/workers/chunks/c0720d0d8adcba6738d4.js +0 -1
  450. package/assets/esri/core/workers/chunks/c5bb712d5cf8c05a4e13.js +0 -1
  451. package/assets/esri/core/workers/chunks/d343f05a3366f95e0494.js +0 -1
  452. package/assets/esri/core/workers/chunks/d8b1f00075983d769985.js +0 -1
  453. package/chunks/Highlight.glsl.js +0 -88
  454. package/views/3d/webgl-engine/shaders/Highlight.glsl.js +0 -5
  455. package/views/3d/webgl-engine/shaders/HighlightTechnique.js +0 -5
  456. package/views/3d/webgl-engine/shaders/HighlightTechniqueConfiguration.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/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../Graphic.js";import"../intl.js";import{on as s,pausable as o}from"../core/events.js";import i from"../core/Handles.js";import{isSome as r,isNone as n,unwrap as a,unwrapOrValue as l}from"../core/maybe.js";import{watch as c,initial as d,when as h,on as u}from"../core/reactiveUtils.js";import{aliasOf as p}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{property as m}from"../core/accessorSupport/decorators/property.js";import{subclass as v}from"../core/accessorSupport/decorators/subclass.js";import _ from"../rest/support/Stop.js";import g from"../symbols/SimpleMarkerSymbol.js";import S from"./Search.js";import w from"./Widget.js";import y from"./Directions/DirectionsViewModel.js";import{formatDistance as M,formatTime as f,isTimeUnits as T}from"./Directions/support/directionsUtils.js";import{DepartureTime as b,CSS as C,getIconPath as I}from"./Directions/support/resources.js";import{isArcGISWorldGeocoder as k,meteredArcGISLocatorUrl as R}from"./Search/support/locatorUtils.js";import D from"./support/DatePicker.js";import{Heading as P,incrementHeadingLevel as j}from"./support/Heading.js";import x from"./support/TimePicker.js";import{accessibleHandler as H}from"./support/decorators/accessibleHandler.js";import{messageBundle as U}from"./support/decorators/messageBundle.js";import"../core/Logger.js";import{tsx as L}from"./support/jsxFactory.js";import"./support/widgetUtils.js";import z from"sortablejs";import{substitute as A}from"../intl/substitute.js";import{formatDate as E,convertDateFormatToIntlOptions as O}from"../intl/date.js";import{formatNumber as $}from"../intl/number.js";function B(e){const t=e.getTimezoneOffset(),s=t>0?"-":"+",o=60,i=Math.abs(Math.floor(t/o)),r=Math.abs(Math.floor(t)%o),n={minimumIntegerDigits:2};return`GMT${s}${$(i,n)}${$(r,n)}`}function F(e){return!(null==e.composedPath||!e.composedPath().find((e=>{var t;return null==(t=e.classList)?void 0:t.contains("esri-search__suggestions-list")})))}const N={awaitingViewClickStop:"awaiting-view-click-stop"},V=100,q=500;let W=class extends w{constructor(e,t){super(e,t),this._autoStopRemovalDelay=V,this._departureTime=b.NOW,this._datePicker=new D,this._handles=new i,this._newPlaceholderStop=null,this._pointerPressedSearchSuggestionStop=null,this._sections=null,this._stopsToSearches=new Map,this._timePicker=new x,this.apiKey=null,this.goToOverride=null,this.headingLevel=2,this.iconClass=C.widgetIcon,this.label=void 0,this.lastRoute=null,this.maxStops=null,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.routeServiceUrl=void 0,this.routeSymbol=null,this.searchProperties=null,this.stopSymbols=null,this.view=null,this.viewModel=new y,this._setUpDragAndDropStops=e=>{this._sortable=z.create(e,{draggable:`.${C.validStopRow}`,ghostClass:C.stopRowGhost,handle:`.${C.stopHandle}`,onEnd:this._handleStopInputDragEnd})},this._handleDragHandlePointerDown=()=>this.viewModel.stops.forEach((e=>this._acquireSearch(e).activeMenu="none")),this._handleStopInputDragEnd=({oldIndex:e,newIndex:t,target:s})=>{if(e===t)return;const{children:o}=s,i=o[t],r=o[e],n=t-e<0;s.insertBefore(i,n?r.nextElementSibling:r);const a=this.viewModel.stops;a.reorder(a.getItemAt(e),t);for(const l of a)l.sequence=null;this._processStops()}}initialize(){this.own([c((()=>this.viewModel.lastRoute),(()=>{if(r(this.viewModel.lastRoute)){for(const e of this._stopsToSearches.values())e.destroy();this._stopsToSearches.clear();for(const e of this.viewModel.lastRoute.stops){this._acquireSearch(e).searchTerm=r(e.name)?e.name:""}}this._activeStop=null,this._activeManeuver=null,this._focusedManeuver=null,this._sections=this._getSections(),this.scheduleRender()}),d),c((()=>[this.viewModel.selectedTravelMode,this.viewModel.departureTime]),(async()=>{this.viewModel.stops.filter((e=>r(e.geometry))).length>1&&(await this.viewModel.load(),this.getDirections())}),d),h((()=>this.view),((e,t)=>{if(t&&(this._viewClickHandle=null,this._handles.remove(t)),e){const t=this._prepPointerDownUpClick(),o=this._prepViewClick();t.pause(),o.pause(),this._handles.add([s(e.surface,"mousedown",(()=>this._autoStopRemovalDelay=q)),s(e.surface,"mouseup",(()=>this._autoStopRemovalDelay=V)),t,o],this.view.surface),this._pointerDownUpHandle=t,this._viewClickHandle=o}}),d),h((()=>n(this.viewModel.serviceDescription)),(()=>{this.viewModel.load()}),d)])}destroy(){this._datePicker.destroy(),this._timePicker.destroy(),this._stopsToSearches.forEach((e=>e.destroy())),this._sortable&&this._sortable.destroy()}getDirections(){return null}zoomToRoute(){}render(){return L("div",{class:this.classes(C.base,C.scroller)},this._renderPanelContent())}_renderPanelContent(){const{viewModel:{state:e}}=this,t="initializing"===e,s="error"===e&&!this.viewModel.serviceDescription,o="unauthenticated"===e,i={[C.panelContentLoading]:t,[C.panelContentError]:s,[C.panelContentSignIn]:o},r=t?"presentation":"group",n=o?this._renderSignIn():s?this._renderMessage(this._getErrorMessage()):t?this._renderLoader():this._renderReadyContent();return L("div",{class:this.classes(C.panelContent,i),role:r},n)}_renderReadyContent(){return[this._renderStopsContainer(),this._renderTravelModeOptions(),this._renderDepartureTimeControls(),this._renderSectionSplitter(),this._renderDirectionsContainer()]}_renderSignIn(){return L("div",{key:"sign-in",class:C.signInContent},L(P,{class:C.contentTitle,level:this.headingLevel},this.messages.widgetLabel),this._renderPlaceholder(),L(P,{level:j(this.headingLevel)},this.messages.signInRequired),L("button",{class:this.classes(C.button,C.buttonSecondary,C.signInButton),tabIndex:0,onclick:this._handleSignInClick,bind:this,type:"button"},this.messagesCommon.auth.signIn))}_handleSignInClick(){this.viewModel.load().catch((()=>{}))}_renderTravelModeOptions(){const{selectedTravelMode:e,travelModes:t}=this.viewModel;if(0===t.length)return null;const s=r(e)?e.name:this.messages.travelMode;return L("select",{"aria-label":s,bind:this,class:this.classes(C.travelModeSelect,C.select),key:"esri-directions__travel-mode-options",onchange:this._handleTravelModeChange,title:s},t.map((t=>{const s=r(e)&&t.id===e.id;return L("option",{key:t,"data-mode":t,selected:s,value:t.id},t.name)})))}_handleTravelModeChange(e){const t=e.currentTarget,s=t.item(t.selectedIndex);this.viewModel.selectedTravelMode=s["data-mode"]}_renderStopsContainer(){return L("div",{class:C.section,key:"esri-directions__stops-container",role:"group"},this._renderStops())}_renderDepartureTimeControls(){const e=this._departureTime,{messages:t}=this,s=t.departureTime;return L("div",{class:C.departureTime,key:"esri-directions__departure-time-controls",role:"group"},L("select",{"aria-label":s,bind:this,class:this.classes(C.departureTimeSelect,C.select),onchange:this._handleDepartureOptionChange,title:s},L("option",{value:b.NOW,selected:e===b.NOW},t.leaveNow),L("option",{value:b.DEPART_BY,selected:e===b.DEPART_BY},t.departBy),L("option",{value:b.UNSPECIFIED,selected:e===b.UNSPECIFIED},t.timeUnspecified)),e===b.DEPART_BY?this._renderTimeControls():null)}_renderStops(){const e=this.viewModel.stops;let t=0;e.forEach((e=>{"none"!==this._acquireSearch(e).activeMenu&&(t+=1)}));const s=e.toArray().map(((s,o)=>{const i=e.length,a=o>1&&n(s.geometry),l={[C.stopsIcon]:o>=0&&o<i-1,[C.lastStopIcon]:o===i-1},c={[C.lastStopIconContainer]:o===i-1},d={[C.validStopRow]:!a},h=e.getItemAt(i-1),u=h&&r(h.geometry),p=e.getItemAt(o+1),m=p&&r(p.geometry),v=o===i-1,_=o===i-2,g=2===i&&0===o||i>2&&!v&&!_||i>2&&_&&m||i>2&&v&&n(s.geometry),S=2===i||3===i&&!u||a,w=this._acquireSearch(s),{messages:y}=this,{removeStop:M,reverseStops:f,unlocated:T}=y,b=A(y.stopLabelTemplate,{number:o+1,label:r(s.geometry)?s.name:T}),I=`${this.id}__stop--${o}`,k=!!w.searchTerm&&!!w.selectedResult&&r(s.geometry)&&w.selectedResult.name===s.name,R={zIndex:"none"!==w.activeMenu?""+t--:""};return L("li",{"aria-label":b,afterCreate:this._handleStopFieldCreation,bind:this,class:this.classes(C.stopRow,d),id:I,key:o,"data-stop-index":o,styles:R},L("div",{class:C.stopHandle},L("span",{"aria-hidden":"true",class:this.classes(C.stopIcon,C.handleIcon,C.stopHandleIcon,C.interactiveStopIcon),onpointerdown:this._handleDragHandlePointerDown}),L("div",{bind:this,"aria-labelledby":I,class:this.classes(C.stopIconContainer,c),"data-stop-index":o,onclick:this._handleStopIconClick,onkeydown:this._handleStopIconClick,role:"button"},L("span",{class:this.classes(C.stopIcon,l),tabindex:k?"0":null}))),L("div",{class:C.stopInput},w.render()),L("div",{class:C.stopOptions,role:"group"},L("div",{"aria-label":M,class:C.removeStopButton,bind:this,"data-stop-index":o,hidden:S,onkeydown:this._handleRemoveStop,onclick:this._handleRemoveStop,role:"button",tabIndex:0,title:M},L("span",{"aria-hidden":"true",class:this.classes(C.stopIcon,C.removeStop,C.removeStopIcon,C.interactiveStopIcon)}),L("span",{class:C.screenReaderText},"removeStopTitle")),L("div",{"aria-label":f,class:C.reverseStops,bind:this,hidden:g,onkeydown:this._handleReverseStops,onclick:this._handleReverseStops,role:"button",tabIndex:0,title:f},L("span",{"aria-hidden":"true",class:this.classes(C.stopIcon,C.reverseStopIcon,C.interactiveStopIcon)}),L("span",{class:C.screenReaderText},"removeStopTitle"))))})),o=e.every((e=>r(e.geometry))),i=e.length>=this.maxStops,a=this.messages.addStop,l=e.length>=2&&o&&!i?L("div",{"aria-label":a,bind:this,class:C.addStop,key:"esri-directions__add-stop",onfocus:this._handleAddStopFocus,tabIndex:0},L("span",{"aria-hidden":"true",class:this.classes(C.addStopIcon,C.stopIcon,C.interactiveStopIcon)}),L("div",{"aria-hidden":"true",class:C.addStopText},a)):null;return L("div",null,L("ol",{class:C.stops,role:"group",afterCreate:this._setUpDragAndDropStops},s),l)}_handleStopIconClick(e){const t=e.currentTarget["data-stop-index"],s=this.viewModel.stops.getItemAt(t);s&&r(s.geometry)&&this._centerAtStop(s)}_handleClearRouteClick(){this.viewModel.reset()}_centerAtStop(e){this.viewModel.centerAt(e)}_handleStopFieldCreation(e){const t=this._newPlaceholderStop;if(!t)return;const s=e["data-stop-index"],o=this.viewModel.stops.getItemAt(s);if(t===o){const e=this._acquireSearch(o);e.when((()=>{this.renderNow(),e.focus()}))}this._newPlaceholderStop=null}_handleStopInputBlur(e,t){this._handles.remove(N.awaitingViewClickStop),this.view.cursor=this._previousCursor;if(!e.selectedResult||!r(t.geometry)||!r(e.selectedResult.feature.geometry)||t.geometry!==e.selectedResult.feature.geometry)return"none"===e.activeMenu&&e.searchTerm&&(n(e.selectedResult.feature.geometry)&&n(t.geometry)||r(t.geometry)&&r(e.selectedResult.feature.geometry)&&t.geometry!==e.selectedResult.feature.geometry)?(e.search(),void this._pointerDownUpHandle.pause()):void(e.searchTerm||(this._viewClickHandle.resume(),clearTimeout(this._autoStopRemovalTimeoutId),this._autoStopRemovalTimeoutId=setTimeout((()=>{this.destroyed||(this._viewClickHandle.pause(),"searching"!==e.viewModel.state?this._pointerPressedSearchSuggestionStop||(r(t.geometry)&&(t.geometry=null,this._processStops()),this.scheduleRender()):this._pointerDownUpHandle.pause())}),this._autoStopRemovalDelay)));this._pointerDownUpHandle.pause()}_handleStopInputFocus(e,t){if(this._pointerDownUpHandle.resume(),this._handles.has(N.awaitingViewClickStop))return;const{view:s,view:{cursor:o}}=this;this._previousCursor=o,this._handles.add(c((()=>e.searchTerm),(t=>{e.destroyed||(s.cursor=0===t.length?"copy":o)}),d),N.awaitingViewClickStop),this._activeStop=t}_prepViewClick(){const{view:e}=this.viewModel,t=o(e,"click",this._handleViewClick.bind(this)),s=o(e.surface,"click",(()=>{clearTimeout(this._autoStopRemovalTimeoutId),s.pause()}));return{remove(){s.remove(),t.remove()},pause(){s.pause(),t.pause()},resume(){s.resume(),t.resume()}}}_prepPointerDownUpClick(){const e=o(document,"pointerdown",(e=>{this._pointerPressedSearchSuggestionStop=F(e)?this._activeStop:null})),t=o(document,"pointerup",(e=>{this._pointerDownUpHandle.pause();const t=F(e),s=this._activeStop;t||s!==this._pointerPressedSearchSuggestionStop||this._removeStop(s),this.scheduleRender(),this._pointerPressedSearchSuggestionStop=t?s:null}));return{remove(){t.remove(),e.remove()},pause(){t.pause(),e.pause()},resume(){e.resume()}}}_handleViewClick(e){const t=this._stopsToSearches.get(this._activeStop);t&&!t.searchTerm&&(t.search(e.mapPoint).then((e=>{const s=e.results[0].results[0],{feature:o,name:i}=s;this._activeStop.geometry=o.geometry,this._activeStop.name=i,t.searchTerm=i})),this.scheduleRender()),this._viewClickHandle.pause(),clearTimeout(this._autoStopRemovalTimeoutId)}_handleAddStopFocus(){this._addNewPlaceholder()}_addNewPlaceholder(){if(this._pointerDownUpHandle.pause(),this._newPlaceholderStop)return;const e=new _({symbol:new g});this.viewModel.stops.add(e),this._newPlaceholderStop=e}_handleReverseStops(){this._reverseStops()}_reverseStops(){this.viewModel.stops.reverse();for(const e of this.viewModel.stops)e.sequence=null;this._processStops()}_handleRemoveStop(e){const t=e.currentTarget["data-stop-index"];this._removeStop(this.viewModel.stops.getItemAt(t)),this._processStops()}_removeStop(e){this.viewModel.stops.length<=2||(this._disposeSearch(e),this.viewModel.stops.remove(e))}_handleDepartureOptionChange(e){const t=e.currentTarget,s=t.item(t.selectedIndex);s.value===b.NOW?(this._departureTime=b.NOW,this.viewModel.departureTime=b.NOW,this._handles.remove("departure-time-controls")):s.value===b.DEPART_BY?(this._departureTime=b.DEPART_BY,this._handles.add([c((()=>this._datePicker.value),(()=>this._updateDepartureTime()),d),c((()=>this._timePicker.value),(()=>this._updateDepartureTime()),d)],"departure-time-controls")):(this._departureTime=b.UNSPECIFIED,this.viewModel.departureTime=null)}_updateDepartureTime(){const e=this._datePicker.value,t=this._timePicker.value;e&&t&&(this.viewModel.departureTime=new Date(e.getFullYear(),e.getMonth(),e.getDate(),t.getHours(),t.getMinutes()))}_renderTimeControls(){return L("div",{class:C.departureTimeControls,key:"esri-directions__time-controls",role:"group"},this._datePicker.render(),this._timePicker.render())}_renderSectionSplitter(){return L("div",{class:C.sectionSplitter})}_renderDirectionsContainer(){return L("div",{class:this.classes(C.directionsSection,C.section),key:"esri-directions__container"},this._renderDirectionsContainerContent())}_renderLoader(){return L("div",{class:C.loader,key:"loader"})}_renderWarningCard(){return L("div",{class:C.warningCard,role:"alert"},L("div",{class:C.warningHeader},L("span",{class:C.warningIcon,"aria-hidden":"true"}),L(P,{class:C.warningHeading,level:this.headingLevel},this.messagesCommon.warning)),L("div",{class:C.warningMessage},this._getErrorMessage()))}_renderDirectionsContainerContent(){const{lastRoute:e,viewModel:{state:t}}=this,s="routing"===t;return"error"===t?this._renderWarningCard():s?this._renderLoader():r(e)&&r(e.directionLines)?L("div",{class:C.summary,key:"esri-directions__summary",role:"group"},this._renderCosts(),this._renderRouteActions(),this._renderManeuverSections()):L("div",{key:"esri-directions__placeholder",class:C.emptyContent},this._renderPlaceholder(),L(P,{class:C.message,level:this.headingLevel},this.messages.directionsPlaceholder))}_renderPlaceholder(){return L("svg",{class:C.emptyIllustration,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256"},L("path",{fill:"currentcolor",d:"M192 36c-15.477 0-24 6.034-24 16.99v45.822l24 24 24-24v-45.82C216 42.033 207.477 36 192 36zm20 61.155l-20 20-20-20V52.99c0-8.62 6.73-12.99 20-12.99s20 4.37 20 12.99zM192 52a12 12 0 1 0 12 12 12.013 12.013 0 0 0-12-12zm0 20a8 8 0 1 1 8-8 8.008 8.008 0 0 1-8 8zM92 140.99C92 130.035 83.477 124 68 124s-24 6.034-24 16.99v45.822l24 24 24-24zm-4 44.165l-20 20-20-20V140.99c0-8.62 6.73-12.99 20-12.99s20 4.37 20 12.99zM68 140a12 12 0 1 0 12 12 12.013 12.013 0 0 0-12-12zm0 20a8 8 0 1 1 8-8 8.008 8.008 0 0 1-8 8zm84-44h16v4h-16zm-24 80h4v12h-12v-4h8zm0-28h4v16h-4zm0-52h12v4h-8v8h-4zm0 24h4v16h-4zm-36 64h16v4H92z"}))}_renderMessage(e){return L(P,{level:this.headingLevel},e)}_renderRouteActions(){return L("div",{class:C.routeActions},L("button",{"aria-label":this.messages.clearRoute,class:this.classes(C.clearRouteButton,C.button,C.buttonTertiary),tabIndex:0,onclick:this._handleClearRouteClick,bind:this,type:"button"},this.messages.clearRoute))}_getSections(){if(n(this.lastRoute))return null;const{directionPoints:e,directionLines:t,stops:s}=this.lastRoute;if(n(e)||n(t))return null;const o=[];let i=null;for(const a of e){const{objectId:e,stopId:l}=a;if(r(l)){const e=s.find((e=>e.objectId===l)),t=0===o.length;(n(i)||i.stop!==e)&&(i={stop:e,directions:[],open:t},o.push(i));continue}if(n(i))continue;const c=t.find((t=>t.directionPointId===e));n(c)||i.directions.push({directionPoint:a,directionLine:c})}return o}_renderManeuverSections(){return n(this._sections)?null:L("div",{class:C.maneuvers,role:"group"},this._sections.map(((e,t)=>{const{open:s}=e;let o;e.directions.length>0&&s&&(o=L("ol",{class:C.maneuverList},e.directions.map((e=>this._renderManeuver(e)))));const i=a(this._sections).length>2,r=t===a(this._sections).length-1,n={[C.collapsibleSection]:i},l={[C.openIcon]:!s,[C.closeIcon]:s};let c;if(i&&!r){const t=s?this.messagesCommon.open:this.messagesCommon.close;c=L("header",{class:this.classes(C.maneuverSectionHeader,C.maneuverSectionToggle),key:"esri-directions__maneuver-section-header"},L("div",{"aria-expanded":s.toString(),"aria-label":t,bind:this,class:C.maneuverSectionHeaderButton,"data-maneuver-section":e,onkeydown:this._handleSectionToggle,onclick:this._handleSectionToggle,role:"button",tabIndex:0,title:t},L(P,{class:C.maneuverSectionTitle,level:this.headingLevel},e.stop.name),L("span",{"aria-hidden":"true",class:this.classes(l)})))}else c=L("header",{class:C.maneuverSectionHeader,key:"esri-directions__maneuver-section-header"},L(P,{class:C.maneuverSectionTitle,level:this.headingLevel},e.stop.name));return L("section",{class:this.classes(C.maneuverSection,n),key:t},c,o)})))}_handleSectionToggle(e){const t=e.currentTarget["data-maneuver-section"];t.open=!t.open}_renderCosts(){const{lastRoute:e}=this;if(n(e))return null;const t=this._getCostSummary(),{directionPoints:s}=e;if(n(s)||n(t))return null;const o=s.getItemAt(s.length-1).arrivalTime,{primary:i,secondary:a}=t,{eta:l,etaTemplate:c,primaryCosts:d,secondaryCosts:h,zoomToRoute:u}=this.messages,p=O("short-time"),m=r(o)?`<strong>${E(o,p)}</strong>`:null,v=r(o)?`${B(o)}`:null,_=A(c,{time:m,gmt:v});return L("div",{"aria-label":u,bind:this,class:C.directionCosts,onkeydown:this._handleSummaryInteraction,onclick:this._handleSummaryInteraction,role:"button",tabIndex:0,title:u},L("div",{class:C.costsDetails,role:"group"},L("div",{"aria-label":d,class:C.primaryCosts,title:d},i),L("div",{class:C.verticalSplitter}),L("div",{"aria-label":h,class:C.secondaryCosts,title:h},a)),L("div",{"aria-label":l,innerHTML:_,title:l}))}_handleSummaryInteraction(){this._activeManeuver=null,this._focusedManeuver=null,this.viewModel.clearHighlights(),this.zoomToRoute()}_getErrorMessage(){const{messages:e,viewModel:{error:t}}=this;if(r(t))switch(t.name){case"directions-view-model:unable-to-route":return e.errors.unableToRoute;case"directions-view-model:service-metadata-unavailable":return e.errors.unableToLoadServiceMetadata}return e.errors.unknownError}_normalizeSearchSources(e){this._overrideDefaultSources(e),this._applyLocatorSourceOverrides(e)}_overrideDefaultSources(e){e.viewModel.defaultSources.forEach((e=>{e.autoNavigate=!1}))}_applyLocatorSourceOverrides({allSources:e}){for(const t of e){if("url"in t&&t.url)null!=t.locationType||(t.locationType="street"),k(t.url)&&this.apiKey&&null==t.apiKey&&(t.apiKey=this.apiKey,t.url=R)}}_acquireSearch(e){const{view:t}=this.viewModel;if(this._stopsToSearches.has(e)){const s=this._stopsToSearches.get(e);return s.view=t,this._overrideDefaultSources(s),s}const s=new S({view:t,resultGraphicEnabled:!1,popupEnabled:!1,...this.searchProperties});return this._normalizeSearchSources(s),this._handles.add([u((()=>s.allSources),"change",(()=>this._normalizeSearchSources(s))),s.on("select-result",(()=>{e.geometry=s.selectedResult.feature.geometry,e.name=s.selectedResult.name,this._processStops()})),s.on("search-focus",(()=>this._handleStopInputFocus(s,e))),s.on("search-blur",(()=>this._handleStopInputBlur(s,e)))],s),this._stopsToSearches.set(e,s),s}_disposeSearch(e){this._stopsToSearches.get(e).destroy(),this._stopsToSearches.delete(e)}_processStops(){const e=this.viewModel.stops.filter((e=>r(e.geometry)));this.viewModel.stops=e,e.length>1&&this.getDirections()}_renderManeuver(e){const t="",{directionsLengthUnits:s}=this.viewModel.routeParameters,{directionPoint:o,directionLine:i}=e,{distance:n,duration:a}=i,{messages:c,messagesUnits:d}=this,h=M(c,d,l(n,0),{fromUnits:"meters",toUnits:s}),u=f(l(a,0),"minutes"),p=h&&u?`${h}&nbsp;&middot;&nbsp;${u}`:`${h}${u}`,m=this._getFormattedManeuverText(o),{objectId:v,directionPointType:_}=o,g=I(_),S=`esri-directions__maneuver-${v}`,w=`esri-directions__cumulative-costs-${v}`,y=`esri-directions__intermediate-costs-${v}`,T={[C.maneuverActive]:this._activeManeuver===i};return L("li",{"aria-labelledby":`${S} ${w} ${y}`,bind:this,class:this.classes(C.maneuver,T),"data-maneuver":i,key:i,onclick:this._handleManeuverClick,onkeydown:this._handleManeuverClick,onfocus:this._handleManeuverFocus,onmouseover:this._handleManeuverMouseOver,onmouseout:this._handleManeuverMouseOut,onblur:this._handleManeuverBlur,tabIndex:0},r(g)&&L("img",{alt:"",class:C.maneuverIcon,src:g}),L("div",{class:C.maneuverCostsContainer},L("span",{id:S,innerHTML:l(m,"")}),L("div",{class:C.maneuverCosts},L("div",{class:C.horizontalSplitter}),L("div",{id:w,"aria-label":c.cumulativeCosts,class:C.cumulativeCost,innerHTML:t,title:c.cumulativeCosts}),L("div",{id:y,"aria-label":c.intermediateCosts,class:C.intermediateCost,innerHTML:p,title:c.intermediateCosts}))))}_handleManeuverClick(e){const s=e.currentTarget["data-maneuver"];if(this._activeManeuver===s)return this._activeManeuver=null,void this.zoomToRoute();this._activeManeuver=s;const{geometry:o,symbol:i}=s,r=new t({geometry:o,symbol:i});this.viewModel.centerAt(r),this.viewModel.highlightSegment(r)}_handleManeuverMouseOver(e){if(this._activeManeuver||this._focusedManeuver)return;const s=e.currentTarget["data-maneuver"],{geometry:o,symbol:i}=s,r=new t({geometry:o,symbol:i});this.viewModel.highlightSegment(r)}_handleManeuverMouseOut(){this._activeManeuver||this._focusedManeuver||this.viewModel.clearHighlights()}_handleManeuverBlur(){this._activeManeuver||(this._focusedManeuver=null,this.viewModel.clearHighlights())}_handleManeuverFocus(e){if(this._activeManeuver)return;const s=e.currentTarget["data-maneuver"];this._focusedManeuver=s;const{geometry:o,symbol:i}=s,r=new t({geometry:o,symbol:i});this.viewModel.highlightSegment(r)}_getFormattedManeuverText(e){const{displayText:t,name:s,intersectingName:o}=e;if(n(t))return"";let i=t;return r(s)&&i.includes(s)&&(i=i.replace(s,`<strong>${s}</strong>`)),r(o)&&i.includes(o)&&(i=i.replace(o,`<strong>${o}</strong>`)),i}_getCostSummary(){const{viewModel:{impedanceAttribute:e,routeParameters:t},lastRoute:s}=this;if(n(e)||n(s))return null;const{routeInfo:o}=s;let{totalDuration:i,totalDistance:a}=o;const{directionsLengthUnits:l}=t;a=r(a)?a:0,i=r(i)?i:0;const c=M(this.messages,this.messagesUnits,a,{fromUnits:"meters",toUnits:l}),d=f(i,"minutes"),[h,u]=T(e.units)?[d,c]:[c,d];return{primary:h,secondary:u}}};e([p("viewModel.apiKey")],W.prototype,"apiKey",void 0),e([p("viewModel.goToOverride")],W.prototype,"goToOverride",void 0),e([m()],W.prototype,"headingLevel",void 0),e([m()],W.prototype,"iconClass",void 0),e([m({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],W.prototype,"label",void 0),e([p("viewModel.lastRoute")],W.prototype,"lastRoute",void 0),e([p("viewModel.maxStops")],W.prototype,"maxStops",void 0),e([m(),U("esri/widgets/Directions/t9n/Directions")],W.prototype,"messages",void 0),e([m(),U("esri/t9n/common")],W.prototype,"messagesCommon",void 0),e([m(),U("esri/core/t9n/Units")],W.prototype,"messagesUnits",void 0),e([p("viewModel.routeServiceUrl")],W.prototype,"routeServiceUrl",void 0),e([p("viewModel.routeSymbol")],W.prototype,"routeSymbol",void 0),e([m()],W.prototype,"searchProperties",void 0),e([p("viewModel.stopSymbols")],W.prototype,"stopSymbols",void 0),e([p("viewModel.view")],W.prototype,"view",void 0),e([m({type:y})],W.prototype,"viewModel",void 0),e([p("viewModel.getDirections")],W.prototype,"getDirections",null),e([p("viewModel.zoomToRoute")],W.prototype,"zoomToRoute",null),e([H()],W.prototype,"_handleStopIconClick",null),e([H()],W.prototype,"_handleClearRouteClick",null),e([H()],W.prototype,"_handleReverseStops",null),e([H()],W.prototype,"_handleRemoveStop",null),e([H()],W.prototype,"_handleSectionToggle",null),e([H()],W.prototype,"_handleSummaryInteraction",null),e([H()],W.prototype,"_handleManeuverClick",null),W=e([v("esri.widgets.Directions")],W);const K=W;export{K as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../Graphic.js";import"../intl.js";import{on as s,pausable as o}from"../core/events.js";import i from"../core/Handles.js";import{isSome as r,isNone as n,unwrap as a,unwrapOrValue as l}from"../core/maybe.js";import{watch as c,initial as d,when as h,on as u}from"../core/reactiveUtils.js";import{aliasOf as p}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import"../core/accessorSupport/ensureType.js";import{property as m}from"../core/accessorSupport/decorators/property.js";import{subclass as v}from"../core/accessorSupport/decorators/subclass.js";import _ from"../rest/support/Stop.js";import g from"../symbols/SimpleMarkerSymbol.js";import S from"./Search.js";import w from"./Widget.js";import y from"./Directions/DirectionsViewModel.js";import{formatDistance as M,formatTime as f,isTimeUnits as T}from"./Directions/support/directionsUtils.js";import{DepartureTime as b,CSS as C,getIconPath as I}from"./Directions/support/resources.js";import{isArcGISWorldGeocoder as k,meteredArcGISLocatorUrl as R}from"./Search/support/locatorUtils.js";import D from"./support/DatePicker.js";import{Heading as P,incrementHeadingLevel as j}from"./support/Heading.js";import x from"./support/TimePicker.js";import{accessibleHandler as H}from"./support/decorators/accessibleHandler.js";import{messageBundle as U}from"./support/decorators/messageBundle.js";import"../core/Logger.js";import{tsx as L}from"./support/jsxFactory.js";import"./support/widgetUtils.js";import z from"sortablejs";import{substitute as A}from"../intl/substitute.js";import{formatDate as E,convertDateFormatToIntlOptions as O}from"../intl/date.js";import{formatNumber as $}from"../intl/number.js";function B(e){const t=e.getTimezoneOffset(),s=t>0?"-":"+",o=60,i=Math.abs(Math.floor(t/o)),r=Math.abs(Math.floor(t)%o),n={minimumIntegerDigits:2};return`GMT${s}${$(i,n)}${$(r,n)}`}function F(e){return!(null==e.composedPath||!e.composedPath().find((e=>{var t;return null==(t=e.classList)?void 0:t.contains("esri-search__suggestions-list")})))}const N={awaitingViewClickStop:"awaiting-view-click-stop"},V=100,q=500;let W=class extends w{constructor(e,t){super(e,t),this._autoStopRemovalDelay=V,this._departureTime=b.NOW,this._datePicker=new D,this._handles=new i,this._newPlaceholderStop=null,this._pointerPressedSearchSuggestionStop=null,this._sections=null,this._stopsToSearches=new Map,this._timePicker=new x,this.apiKey=null,this.goToOverride=null,this.headingLevel=2,this.iconClass=C.widgetIcon,this.label=void 0,this.lastRoute=null,this.maxStops=null,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.routeServiceUrl=void 0,this.routeSymbol=null,this.searchProperties=null,this.stopSymbols=null,this.view=null,this.viewModel=new y,this._setUpDragAndDropStops=e=>{this._sortable=z.create(e,{draggable:`.${C.validStopRow}`,ghostClass:C.stopRowGhost,handle:`.${C.stopHandle}`,onEnd:this._handleStopInputDragEnd})},this._handleDragHandlePointerDown=()=>this.viewModel.stops.forEach((e=>this._acquireSearch(e).activeMenu="none")),this._handleStopInputDragEnd=({oldIndex:e,newIndex:t,target:s})=>{if(e===t)return;const{children:o}=s,i=o[t],r=o[e],n=t-e<0;s.insertBefore(i,n?r.nextElementSibling:r);const a=this.viewModel.stops;a.reorder(a.getItemAt(e),t);for(const l of a)l.sequence=null;this._processStops()}}initialize(){this.own([c((()=>this.viewModel.lastRoute),(()=>{if(r(this.viewModel.lastRoute)){for(const e of this._stopsToSearches.values())e.destroy();this._stopsToSearches.clear();for(const e of this.viewModel.lastRoute.stops){this._acquireSearch(e).searchTerm=r(e.name)?e.name:""}}this._activeStop=null,this._activeManeuver=null,this._focusedManeuver=null,this._sections=this._getSections(),this.scheduleRender()}),d),c((()=>[this.viewModel.selectedTravelMode,this.viewModel.departureTime]),(async()=>{this.viewModel.stops.filter((e=>r(e.geometry))).length>1&&(await this.viewModel.load(),this._getDirections())}),d),h((()=>this.view),((e,t)=>{if(t&&(this._viewClickHandle=null,this._handles.remove(t)),e){const t=this._prepPointerDownUpClick(),o=this._prepViewClick();t.pause(),o.pause(),this._handles.add([s(e.surface,"mousedown",(()=>this._autoStopRemovalDelay=q)),s(e.surface,"mouseup",(()=>this._autoStopRemovalDelay=V)),t,o],this.view.surface),this._pointerDownUpHandle=t,this._viewClickHandle=o}}),d),h((()=>n(this.viewModel.serviceDescription)),(()=>{this.viewModel.load()}),d)])}destroy(){this._datePicker.destroy(),this._timePicker.destroy(),this._stopsToSearches.forEach((e=>e.destroy())),this._sortable&&this._sortable.destroy()}getDirections(){return null}zoomToRoute(){}render(){return L("div",{class:this.classes(C.base,C.scroller)},this._renderPanelContent())}_renderPanelContent(){const{viewModel:{serviceDescription:e,state:t}}=this,s="initializing"===t,o="error"===t&&!e,i="unauthenticated"===t,r={[C.panelContentLoading]:s,[C.panelContentError]:o,[C.panelContentSignIn]:i},n=s?"presentation":"group",a=i?this._renderSignIn():o?this._renderMessage(this._getErrorMessage()):s?this._renderLoader():this._renderReadyContent();return L("div",{class:this.classes(C.panelContent,r),role:n},a)}_renderReadyContent(){return[this._renderStopsContainer(),this._renderTravelModeOptions(),this._renderDepartureTimeControls(),this._renderSectionSplitter(),this._renderDirectionsContainer()]}_renderSignIn(){return L("div",{key:"sign-in",class:C.signInContent},L(P,{class:C.contentTitle,level:this.headingLevel},this.messages.widgetLabel),this._renderPlaceholder(),L(P,{level:j(this.headingLevel)},this.messages.signInRequired),L("button",{class:this.classes(C.button,C.buttonSecondary,C.signInButton),tabIndex:0,onclick:this._handleSignInClick,bind:this,type:"button"},this.messagesCommon.auth.signIn))}_handleSignInClick(){this.viewModel.load().catch((()=>{}))}_renderTravelModeOptions(){const{selectedTravelMode:e,travelModes:t}=this.viewModel;if(0===t.length)return null;const s=r(e)?e.name:this.messages.travelMode;return L("select",{"aria-label":s,bind:this,class:this.classes(C.travelModeSelect,C.select),key:"esri-directions__travel-mode-options",onchange:this._handleTravelModeChange,title:s},t.map((t=>{const s=r(e)&&t.id===e.id;return L("option",{key:t,"data-mode":t,selected:s,value:t.id},t.name)})))}_handleTravelModeChange(e){const t=e.currentTarget,s=t.item(t.selectedIndex);this.viewModel.selectedTravelMode=s["data-mode"]}_renderStopsContainer(){return L("div",{class:C.section,key:"esri-directions__stops-container",role:"group"},this._renderStops())}_renderDepartureTimeControls(){const e=this._departureTime,{messages:t}=this,s=t.departureTime;return L("div",{class:C.departureTime,key:"esri-directions__departure-time-controls",role:"group"},L("select",{"aria-label":s,bind:this,class:this.classes(C.departureTimeSelect,C.select),onchange:this._handleDepartureOptionChange,title:s},L("option",{value:b.NOW,selected:e===b.NOW},t.leaveNow),L("option",{value:b.DEPART_BY,selected:e===b.DEPART_BY},t.departBy),L("option",{value:b.UNSPECIFIED,selected:e===b.UNSPECIFIED},t.timeUnspecified)),e===b.DEPART_BY?this._renderTimeControls():null)}_renderStops(){const e=this.viewModel.stops;let t=0;e.forEach((e=>{"none"!==this._acquireSearch(e).activeMenu&&(t+=1)}));const s=e.toArray().map(((s,o)=>{const i=e.length,a=o>1&&n(s.geometry),l={[C.stopsIcon]:o>=0&&o<i-1,[C.lastStopIcon]:o===i-1},c={[C.lastStopIconContainer]:o===i-1},d={[C.validStopRow]:!a},h=e.getItemAt(i-1),u=h&&r(h.geometry),p=e.getItemAt(o+1),m=p&&r(p.geometry),v=o===i-1,_=o===i-2,g=2===i&&0===o||i>2&&!v&&!_||i>2&&_&&m||i>2&&v&&n(s.geometry),S=2===i||3===i&&!u||a,w=this._acquireSearch(s),{messages:y}=this,{removeStop:M,reverseStops:f,unlocated:T}=y,b=A(y.stopLabelTemplate,{number:o+1,label:r(s.geometry)?s.name:T}),I=`${this.id}__stop--${o}`,k=!!w.searchTerm&&!!w.selectedResult&&r(s.geometry)&&w.selectedResult.name===s.name,R={zIndex:"none"!==w.activeMenu?""+t--:""};return L("li",{"aria-label":b,afterCreate:this._handleStopFieldCreation,bind:this,class:this.classes(C.stopRow,d),id:I,key:o,"data-stop-index":o,styles:R},L("div",{class:C.stopHandle},L("span",{"aria-hidden":"true",class:this.classes(C.stopIcon,C.handleIcon,C.stopHandleIcon,C.interactiveStopIcon),onpointerdown:this._handleDragHandlePointerDown}),L("div",{bind:this,"aria-labelledby":I,class:this.classes(C.stopIconContainer,c),"data-stop-index":o,onclick:this._handleStopIconClick,onkeydown:this._handleStopIconClick,role:"button"},L("span",{class:this.classes(C.stopIcon,l),tabindex:k?"0":null}))),L("div",{class:C.stopInput},w.render()),L("div",{class:C.stopOptions,role:"group"},L("div",{"aria-label":M,class:C.removeStopButton,bind:this,"data-stop-index":o,hidden:S,onkeydown:this._handleRemoveStop,onclick:this._handleRemoveStop,role:"button",tabIndex:0,title:M},L("span",{"aria-hidden":"true",class:this.classes(C.stopIcon,C.removeStop,C.removeStopIcon,C.interactiveStopIcon)}),L("span",{class:C.screenReaderText},"removeStopTitle")),L("div",{"aria-label":f,class:C.reverseStops,bind:this,hidden:g,onkeydown:this._handleReverseStops,onclick:this._handleReverseStops,role:"button",tabIndex:0,title:f},L("span",{"aria-hidden":"true",class:this.classes(C.stopIcon,C.reverseStopIcon,C.interactiveStopIcon)}),L("span",{class:C.screenReaderText},"removeStopTitle"))))})),o=e.every((e=>r(e.geometry))),i=e.length>=this.maxStops,a=this.messages.addStop,l=e.length>=2&&o&&!i?L("div",{"aria-label":a,bind:this,class:C.addStop,key:"esri-directions__add-stop",onfocus:this._handleAddStopFocus,tabIndex:0},L("span",{"aria-hidden":"true",class:this.classes(C.addStopIcon,C.stopIcon,C.interactiveStopIcon)}),L("div",{"aria-hidden":"true",class:C.addStopText},a)):null;return L("div",null,L("ol",{class:C.stops,role:"group",afterCreate:this._setUpDragAndDropStops},s),l)}_handleStopIconClick(e){const t=e.currentTarget["data-stop-index"],s=this.viewModel.stops.getItemAt(t);s&&r(s.geometry)&&this._centerAtStop(s)}_handleClearRouteClick(){this.viewModel.reset()}_centerAtStop(e){this.viewModel.centerAt(e)}_handleStopFieldCreation(e){const t=this._newPlaceholderStop;if(!t)return;const s=e["data-stop-index"],o=this.viewModel.stops.getItemAt(s);if(t===o){const e=this._acquireSearch(o);e.when((()=>{this.renderNow(),e.focus()}))}this._newPlaceholderStop=null}_handleStopInputBlur(e,t){this._handles.remove(N.awaitingViewClickStop),this.view.cursor=this._previousCursor;if(!e.selectedResult||!r(t.geometry)||!r(e.selectedResult.feature.geometry)||t.geometry!==e.selectedResult.feature.geometry)return"none"===e.activeMenu&&e.searchTerm&&(n(e.selectedResult.feature.geometry)&&n(t.geometry)||r(t.geometry)&&r(e.selectedResult.feature.geometry)&&t.geometry!==e.selectedResult.feature.geometry)?(e.search(),void this._pointerDownUpHandle.pause()):void(e.searchTerm||(this._viewClickHandle.resume(),clearTimeout(this._autoStopRemovalTimeoutId),this._autoStopRemovalTimeoutId=setTimeout((()=>{this.destroyed||(this._viewClickHandle.pause(),"searching"!==e.viewModel.state?this._pointerPressedSearchSuggestionStop||(r(t.geometry)&&(t.geometry=null,this._processStops()),this.scheduleRender()):this._pointerDownUpHandle.pause())}),this._autoStopRemovalDelay)));this._pointerDownUpHandle.pause()}_handleStopInputFocus(e,t){if(this._pointerDownUpHandle.resume(),this._handles.has(N.awaitingViewClickStop))return;const{view:s,view:{cursor:o}}=this;this._previousCursor=o,this._handles.add(c((()=>e.searchTerm),(t=>{e.destroyed||(s.cursor=0===t.length?"copy":o)}),d),N.awaitingViewClickStop),this._activeStop=t}_prepViewClick(){const{view:e}=this.viewModel,t=o(e,"click",this._handleViewClick.bind(this)),s=o(e.surface,"click",(()=>{clearTimeout(this._autoStopRemovalTimeoutId),s.pause()}));return{remove(){s.remove(),t.remove()},pause(){s.pause(),t.pause()},resume(){s.resume(),t.resume()}}}_prepPointerDownUpClick(){const e=o(document,"pointerdown",(e=>{this._pointerPressedSearchSuggestionStop=F(e)?this._activeStop:null})),t=o(document,"pointerup",(e=>{this._pointerDownUpHandle.pause();const t=F(e),s=this._activeStop;t||s!==this._pointerPressedSearchSuggestionStop||this._removeStop(s),this.scheduleRender(),this._pointerPressedSearchSuggestionStop=t?s:null}));return{remove(){t.remove(),e.remove()},pause(){t.pause(),e.pause()},resume(){e.resume()}}}_handleViewClick(e){const t=this._stopsToSearches.get(this._activeStop);t&&!t.searchTerm&&(t.search(e.mapPoint).then((e=>{const s=e.results[0].results[0],{feature:o,name:i}=s;this._activeStop.geometry=o.geometry,this._activeStop.name=i,t.searchTerm=i})),this.scheduleRender()),this._viewClickHandle.pause(),clearTimeout(this._autoStopRemovalTimeoutId)}_handleAddStopFocus(){this._addNewPlaceholder()}_addNewPlaceholder(){if(this._pointerDownUpHandle.pause(),this._newPlaceholderStop)return;const e=new _({symbol:new g});this.viewModel.stops.add(e),this._newPlaceholderStop=e}_handleReverseStops(){this._reverseStops()}_reverseStops(){this.viewModel.stops.reverse();for(const e of this.viewModel.stops)e.sequence=null;this._processStops()}_handleRemoveStop(e){const t=e.currentTarget["data-stop-index"];this._removeStop(this.viewModel.stops.getItemAt(t)),this._processStops()}_removeStop(e){this.viewModel.stops.length<=2||(this._disposeSearch(e),this.viewModel.stops.remove(e))}_handleDepartureOptionChange(e){const t=e.currentTarget,s=t.item(t.selectedIndex);s.value===b.NOW?(this._departureTime=b.NOW,this.viewModel.departureTime=b.NOW,this._handles.remove("departure-time-controls")):s.value===b.DEPART_BY?(this._departureTime=b.DEPART_BY,this._handles.add([c((()=>this._datePicker.value),(()=>this._updateDepartureTime()),d),c((()=>this._timePicker.value),(()=>this._updateDepartureTime()),d)],"departure-time-controls")):(this._departureTime=b.UNSPECIFIED,this.viewModel.departureTime=null)}_updateDepartureTime(){const e=this._datePicker.value,t=this._timePicker.value;e&&t&&(this.viewModel.departureTime=new Date(e.getFullYear(),e.getMonth(),e.getDate(),t.getHours(),t.getMinutes()))}_renderTimeControls(){return L("div",{class:C.departureTimeControls,key:"esri-directions__time-controls",role:"group"},this._datePicker.render(),this._timePicker.render())}_renderSectionSplitter(){return L("div",{class:C.sectionSplitter})}_renderDirectionsContainer(){return L("div",{class:this.classes(C.directionsSection,C.section),key:"esri-directions__container"},this._renderDirectionsContainerContent())}_renderLoader(){return L("div",{class:C.loader,key:"loader"})}_renderWarningCard(){return L("div",{class:C.warningCard,role:"alert"},L("div",{class:C.warningHeader},L("span",{class:C.warningIcon,"aria-hidden":"true"}),L(P,{class:C.warningHeading,level:this.headingLevel},this.messagesCommon.warning)),L("div",{class:C.warningMessage},this._getErrorMessage()))}_renderDirectionsContainerContent(){const{lastRoute:e,viewModel:{state:t}}=this,s="routing"===t;return"error"===t?this._renderWarningCard():s?this._renderLoader():r(e)&&r(e.directionLines)?L("div",{class:C.summary,key:"esri-directions__summary",role:"group"},this._renderCosts(),this._renderRouteActions(),this._renderManeuverSections()):L("div",{key:"esri-directions__placeholder",class:C.emptyContent},this._renderPlaceholder(),L(P,{class:C.message,level:this.headingLevel},this.messages.directionsPlaceholder))}_renderPlaceholder(){return L("svg",{class:C.emptyIllustration,xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 256 256"},L("path",{fill:"currentcolor",d:"M192 36c-15.477 0-24 6.034-24 16.99v45.822l24 24 24-24v-45.82C216 42.033 207.477 36 192 36zm20 61.155l-20 20-20-20V52.99c0-8.62 6.73-12.99 20-12.99s20 4.37 20 12.99zM192 52a12 12 0 1 0 12 12 12.013 12.013 0 0 0-12-12zm0 20a8 8 0 1 1 8-8 8.008 8.008 0 0 1-8 8zM92 140.99C92 130.035 83.477 124 68 124s-24 6.034-24 16.99v45.822l24 24 24-24zm-4 44.165l-20 20-20-20V140.99c0-8.62 6.73-12.99 20-12.99s20 4.37 20 12.99zM68 140a12 12 0 1 0 12 12 12.013 12.013 0 0 0-12-12zm0 20a8 8 0 1 1 8-8 8.008 8.008 0 0 1-8 8zm84-44h16v4h-16zm-24 80h4v12h-12v-4h8zm0-28h4v16h-4zm0-52h12v4h-8v8h-4zm0 24h4v16h-4zm-36 64h16v4H92z"}))}_renderMessage(e){return L(P,{level:this.headingLevel},e)}_renderRouteActions(){return L("div",{class:C.routeActions},L("button",{"aria-label":this.messages.clearRoute,class:this.classes(C.clearRouteButton,C.button,C.buttonTertiary),tabIndex:0,onclick:this._handleClearRouteClick,bind:this,type:"button"},this.messages.clearRoute))}_getSections(){if(n(this.lastRoute))return null;const{directionPoints:e,directionLines:t,stops:s}=this.lastRoute;if(n(e)||n(t))return null;const o=[];let i=null;for(const a of e){const{objectId:e,stopId:l}=a;if(r(l)){const e=s.find((e=>e.objectId===l)),t=0===o.length;(n(i)||i.stop!==e)&&(i={stop:e,directions:[],open:t},o.push(i));continue}if(n(i))continue;const c=t.find((t=>t.directionPointId===e));n(c)||i.directions.push({directionPoint:a,directionLine:c})}return o}_renderManeuverSections(){return n(this._sections)?null:L("div",{class:C.maneuvers,role:"group"},this._sections.map(((e,t)=>{const{open:s}=e;let o;e.directions.length>0&&s&&(o=L("ol",{class:C.maneuverList},e.directions.map((e=>this._renderManeuver(e)))));const i=a(this._sections).length>2,r=t===a(this._sections).length-1,n={[C.collapsibleSection]:i},l={[C.openIcon]:!s,[C.closeIcon]:s};let c;if(i&&!r){const t=s?this.messagesCommon.open:this.messagesCommon.close;c=L("header",{class:this.classes(C.maneuverSectionHeader,C.maneuverSectionToggle),key:"esri-directions__maneuver-section-header"},L("div",{"aria-expanded":s.toString(),"aria-label":t,bind:this,class:C.maneuverSectionHeaderButton,"data-maneuver-section":e,onkeydown:this._handleSectionToggle,onclick:this._handleSectionToggle,role:"button",tabIndex:0,title:t},L(P,{class:C.maneuverSectionTitle,level:this.headingLevel},e.stop.name),L("span",{"aria-hidden":"true",class:this.classes(l)})))}else c=L("header",{class:C.maneuverSectionHeader,key:"esri-directions__maneuver-section-header"},L(P,{class:C.maneuverSectionTitle,level:this.headingLevel},e.stop.name));return L("section",{class:this.classes(C.maneuverSection,n),key:t},c,o)})))}_handleSectionToggle(e){const t=e.currentTarget["data-maneuver-section"];t.open=!t.open}_renderCosts(){const{lastRoute:e}=this;if(n(e))return null;const t=this._getCostSummary(),{directionPoints:s}=e;if(n(s)||n(t))return null;const o=s.getItemAt(s.length-1).arrivalTime,{primary:i,secondary:a}=t,{eta:l,etaTemplate:c,primaryCosts:d,secondaryCosts:h,zoomToRoute:u}=this.messages,p=O("short-time"),m=r(o)?`<strong>${E(o,p)}</strong>`:null,v=r(o)?`${B(o)}`:null,_=A(c,{time:m,gmt:v});return L("div",{"aria-label":u,bind:this,class:C.directionCosts,onkeydown:this._handleSummaryInteraction,onclick:this._handleSummaryInteraction,role:"button",tabIndex:0,title:u},L("div",{class:C.costsDetails,role:"group"},L("div",{"aria-label":d,class:C.primaryCosts,title:d},i),L("div",{class:C.verticalSplitter}),L("div",{"aria-label":h,class:C.secondaryCosts,title:h},a)),L("div",{"aria-label":l,innerHTML:_,title:l}))}_handleSummaryInteraction(){this._activeManeuver=null,this._focusedManeuver=null,this.viewModel.clearHighlights(),this.zoomToRoute()}_getErrorMessage(){const{messages:e,viewModel:{error:t}}=this;if(r(t))switch(t.name){case"directions-view-model:unable-to-route":return e.errors.unableToRoute;case"directions-view-model:service-metadata-unavailable":return e.errors.unableToLoadServiceMetadata}return e.errors.unknownError}_normalizeSearchSources(e){this._overrideDefaultSources(e),this._applyLocatorSourceOverrides(e)}_overrideDefaultSources(e){e.viewModel.defaultSources.forEach((e=>{e.autoNavigate=!1}))}_applyLocatorSourceOverrides({allSources:e}){for(const t of e){if("url"in t&&t.url)null!=t.locationType||(t.locationType="street"),k(t.url)&&this.apiKey&&null==t.apiKey&&(t.apiKey=this.apiKey,t.url=R)}}_acquireSearch(e){const{view:t}=this.viewModel;if(this._stopsToSearches.has(e)){const s=this._stopsToSearches.get(e);return s.view=t,this._overrideDefaultSources(s),s}const s=new S({view:t,resultGraphicEnabled:!1,popupEnabled:!1,...this.searchProperties});return this._normalizeSearchSources(s),this._handles.add([u((()=>s.allSources),"change",(()=>this._normalizeSearchSources(s))),s.on("select-result",(()=>{e.geometry=s.selectedResult.feature.geometry,e.name=s.selectedResult.name,this._processStops()})),s.on("search-focus",(()=>this._handleStopInputFocus(s,e))),s.on("search-blur",(()=>this._handleStopInputBlur(s,e)))],s),this._stopsToSearches.set(e,s),s}_disposeSearch(e){this._stopsToSearches.get(e).destroy(),this._stopsToSearches.delete(e)}_processStops(){const e=this.viewModel.stops.filter((e=>r(e.geometry)));this.viewModel.stops=e,e.length>1&&this._getDirections()}_renderManeuver(e){const t="",{directionsLengthUnits:s}=this.viewModel.routeParameters,{directionPoint:o,directionLine:i}=e,{distance:n,duration:a}=i,{messages:c,messagesUnits:d}=this,h=M(c,d,l(n,0),{fromUnits:"meters",toUnits:s}),u=f(l(a,0),"minutes"),p=h&&u?`${h}&nbsp;&middot;&nbsp;${u}`:`${h}${u}`,m=this._getFormattedManeuverText(o),{objectId:v,directionPointType:_}=o,g=I(_),S=`esri-directions__maneuver-${v}`,w=`esri-directions__cumulative-costs-${v}`,y=`esri-directions__intermediate-costs-${v}`,T={[C.maneuverActive]:this._activeManeuver===i};return L("li",{"aria-labelledby":`${S} ${w} ${y}`,bind:this,class:this.classes(C.maneuver,T),"data-maneuver":i,key:i,onclick:this._handleManeuverClick,onkeydown:this._handleManeuverClick,onfocus:this._handleManeuverFocus,onmouseover:this._handleManeuverMouseOver,onmouseout:this._handleManeuverMouseOut,onblur:this._handleManeuverBlur,tabIndex:0},r(g)&&L("img",{alt:"",class:C.maneuverIcon,src:g}),L("div",{class:C.maneuverCostsContainer},L("span",{id:S,innerHTML:l(m,"")}),L("div",{class:C.maneuverCosts},L("div",{class:C.horizontalSplitter}),L("div",{id:w,"aria-label":c.cumulativeCosts,class:C.cumulativeCost,innerHTML:t,title:c.cumulativeCosts}),L("div",{id:y,"aria-label":c.intermediateCosts,class:C.intermediateCost,innerHTML:p,title:c.intermediateCosts}))))}_handleManeuverClick(e){const s=e.currentTarget["data-maneuver"];if(this._activeManeuver===s)return this._activeManeuver=null,void this.zoomToRoute();this._activeManeuver=s;const{geometry:o,symbol:i}=s,r=new t({geometry:o,symbol:i});this.viewModel.centerAt(r),this.viewModel.highlightSegment(r)}_handleManeuverMouseOver(e){if(this._activeManeuver||this._focusedManeuver)return;const s=e.currentTarget["data-maneuver"],{geometry:o,symbol:i}=s,r=new t({geometry:o,symbol:i});this.viewModel.highlightSegment(r)}_handleManeuverMouseOut(){this._activeManeuver||this._focusedManeuver||this.viewModel.clearHighlights()}_handleManeuverBlur(){this._activeManeuver||(this._focusedManeuver=null,this.viewModel.clearHighlights())}_handleManeuverFocus(e){if(this._activeManeuver)return;const s=e.currentTarget["data-maneuver"];this._focusedManeuver=s;const{geometry:o,symbol:i}=s,r=new t({geometry:o,symbol:i});this.viewModel.highlightSegment(r)}_getFormattedManeuverText(e){const{displayText:t,name:s,intersectingName:o}=e;if(n(t))return"";let i=t;return r(s)&&i.includes(s)&&(i=i.replace(s,`<strong>${s}</strong>`)),r(o)&&i.includes(o)&&(i=i.replace(o,`<strong>${o}</strong>`)),i}_getCostSummary(){const{viewModel:{impedanceAttribute:e,routeParameters:t},lastRoute:s}=this;if(n(e)||n(s))return null;const{routeInfo:o}=s;let{totalDuration:i,totalDistance:a}=o;const{directionsLengthUnits:l}=t;a=r(a)?a:0,i=r(i)?i:0;const c=M(this.messages,this.messagesUnits,a,{fromUnits:"meters",toUnits:l}),d=f(i,"minutes"),[h,u]=T(e.units)?[d,c]:[c,d];return{primary:h,secondary:u}}async _getDirections(){try{await this.viewModel.getDirections()}catch{}}};e([p("viewModel.apiKey")],W.prototype,"apiKey",void 0),e([p("viewModel.goToOverride")],W.prototype,"goToOverride",void 0),e([m()],W.prototype,"headingLevel",void 0),e([m()],W.prototype,"iconClass",void 0),e([m({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],W.prototype,"label",void 0),e([p("viewModel.lastRoute")],W.prototype,"lastRoute",void 0),e([p("viewModel.maxStops")],W.prototype,"maxStops",void 0),e([m(),U("esri/widgets/Directions/t9n/Directions")],W.prototype,"messages",void 0),e([m(),U("esri/t9n/common")],W.prototype,"messagesCommon",void 0),e([m(),U("esri/core/t9n/Units")],W.prototype,"messagesUnits",void 0),e([p("viewModel.routeServiceUrl")],W.prototype,"routeServiceUrl",void 0),e([p("viewModel.routeSymbol")],W.prototype,"routeSymbol",void 0),e([m()],W.prototype,"searchProperties",void 0),e([p("viewModel.stopSymbols")],W.prototype,"stopSymbols",void 0),e([p("viewModel.view")],W.prototype,"view",void 0),e([m({type:y})],W.prototype,"viewModel",void 0),e([p("viewModel.getDirections")],W.prototype,"getDirections",null),e([p("viewModel.zoomToRoute")],W.prototype,"zoomToRoute",null),e([H()],W.prototype,"_handleStopIconClick",null),e([H()],W.prototype,"_handleClearRouteClick",null),e([H()],W.prototype,"_handleReverseStops",null),e([H()],W.prototype,"_handleRemoveStop",null),e([H()],W.prototype,"_handleSectionToggle",null),e([H()],W.prototype,"_handleSummaryInteraction",null),e([H()],W.prototype,"_handleManeuverClick",null),W=e([v("esri.widgets.Directions")],W);const K=W;export{K as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Collection.js";import r from"../../core/Error.js";import a from"../../core/Evented.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import i from"../../core/Logger.js";import{on as s,init as n,watch as l,whenFalseOnce as c}from"../../core/watchUtils.js";import{aliasOf as d}from"../../core/accessorSupport/decorators/aliasOf.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";import w from"../../layers/GraphicsLayer.js";import f from"../../views/interactive/snapping/SnappingOptions.js";import h from"../Attachments/AttachmentsViewModel.js";import k from"./CreateFeaturesWorkflow.js";import m from"./CreateWorkflow.js";import{workflowDeprecation as y}from"./deprecationUtils.js";import W from"./UpdateWorkflow.js";import v from"../FeatureForm/FeatureFormViewModel.js";import g from"../FeatureTemplates/FeatureTemplatesViewModel.js";import _ from"../Sketch/SketchViewModel.js";import C from"../Spinner/SpinnerViewModel.js";const F="esri.widgets.Editor.EditorViewModel",b=i.getLogger(F),j=["create","create-features","update"];function A(e,t,a){b.error(new r(e,t,a))}function M(e,t){return e&&e.find((e=>e.layer===t))}let V=class extends(o(a.EventedAccessor)){constructor(e){super(e),this._sketchGraphicsLayer=new w({listMode:"hide",internal:!0}),this.activeWorkflow=null,this.activityQueue=[],this.failures=[],this.attachmentsViewModel=new h({abilities:{editing:!0}}),this.featureFormViewModel=new v,this.featureTemplatesViewModel=new g,this.layerInfos=null,this.sketchViewModel=new _({layer:this._sketchGraphicsLayer}),this.snappingOptions=new f,this.spinnerViewModel=new C}initialize(){this.handles.add([s(this,"activeWorkflow","cancel",(()=>this.emit("workflow-cancel"))),s(this,"activeWorkflow","commit",(()=>this.emit("workflow-commit"))),n(this,"view.map",(e=>{e&&e.add(this._sketchGraphicsLayer)})),l(this,"editableItems",(()=>{const{activeWorkflow:e}=this;if(this.refreshCreationTemplates(),!e)return;const{stepId:t}=e;"create"!==e.type?"update"===e.type&&("awaiting-feature-to-update"===t&&!this.canUpdate||"awaiting-update-feature-candidate"===t&&!e.data.candidates.some((e=>{const t=this.editableItems.find((t=>t.layer===e.layer));return t&&t.supports.indexOf("update")>-1})))&&this._cancelWorkflow():"awaiting-feature-creation-info"!==t||this.canCreate||this._cancelWorkflow()}))])}destroy(){this._cancelWorkflow().then((()=>{var e;null!=(e=this.view)&&e.map&&this.view.map.remove(this._sketchGraphicsLayer),this.view=null}))}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(e){e&&0!==e.length||(e=[...j]),this._set("allowedWorkflows",e)}get canCreate(){return this.editableItems.some((e=>e.supports.includes("create")))}get canUpdate(){return this.editableItems.some((e=>e.supports.includes("update")))}get editableItems(){var e,r,a;const o=null==(e=this.view)?void 0:e.allLayerViews;if(!o)return new t;const i=new Set(null==(r=this.view)||null==(a=r.map)?void 0:a.editableLayers);return o.filter((e=>i.has(e.layer))).map((e=>{const{layer:t,suspended:r}=e,{data:a,operations:o}=t.capabilities,i=M(this.layerInfos,t),s="supportsAttachment"in a&&a.supportsAttachment&&(!i||!1!==i.allowAttachments);if(r)return{hasAttachments:s,layer:t,supports:[]};const n=[];return o.supportsAdd&&(this.allowedWorkflows.includes("create")||this.allowedWorkflows.includes("create-features"))&&(!i||!1!==i.enabled&&!1!==i.addEnabled)&&n.push("create"),o.supportsUpdate&&this.allowedWorkflows.includes("update")&&(!i||!1!==i.enabled&&!1!==i.updateEnabled)&&n.push("update"),!1!==(i&&i.deleteEnabled)&&o.supportsDelete&&n.push("delete"),{hasAttachments:s,layer:t,supports:n}})).reverse()}get state(){if(!this.get("view.ready")||0===this.editableItems.length)return"disabled";const e=this.attachmentsViewModel.mode;if("add"===e)return"adding-attachment";if("edit"===e)return"editing-attachment";const{activeWorkflow:t}=this;return t?t.stepId:"ready"}get syncing(){return this.activityQueue.length>0}set view(e){this.sketchViewModel.view=e,this.spinnerViewModel.view=e,this._set("view",e)}async startCreateWorkflowAtFeatureTypeSelection(){if(y(b,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),!this.canCreate)return void A("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow();await e.start(),this._set("activeWorkflow",e)}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateWorkflowAtFeatureCreation(e){if(y(b,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),!this.canCreate)return void A("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow("awaiting-feature-to-create");t.data.creationInfo=e,await t.start(),this._set("activeWorkflow",t)}async startCreateFeaturesWorkflowAtFeatureCreation(e){return this.startCreateFeaturesWorkflow(e,"creating-features")}async startCreateFeaturesWorkflow(e,t="awaiting-feature-creation-info"){if(!this.canCreate)throw new r("editing:unsupported-workflow","Creating features is unsupported or disabled.");await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow(e,t);await a.start(),this._set("activeWorkflow",a)}async startCreateWorkflowAtFeatureEdit(e){if(y(b,"startCreateWorkflowAtFeatureEdit"),!this.canCreate)return void A("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow("editing-new-feature");t.data.edits.feature=e,await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtFeatureSelection(){if(!this.canUpdate)return void A("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow();await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtMultipleFeatureSelection(e){if(!this.canUpdate)return void A("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow("awaiting-update-feature-candidate");t.data.candidates=e,await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtFeatureEdit(e){if(!this.canUpdate)return void A("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow("editing-existing-feature");t.data.edits.feature=e,await t.start(),this._set("activeWorkflow",t)}async deleteFeatureFromWorkflow(){const{activeWorkflow:e}=this;e&&"update"===e.type?(await this._delete(e.data.edits.feature),await e.reset()):A("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(e){return this._cancelWorkflow({warn:!0,...e})}refreshCreationTemplates(){const e=[];for(const{layer:t,supports:r}of this.editableItems)t.loaded&&r.includes("create")&&e.push(t);this.featureTemplatesViewModel.layers=e}async _cancelWorkflow(e){const t=this.activeWorkflow;if(!t)return void(e&&e.warn&&A("editing:no-active-workflow","There is no active workflow to cancel."));if(!e||!1!==e.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await t.cancel(e);await t.cancel(e),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(e,t){return k.create(this,e,t,((e,t)=>this._applyEdits(e,t)))}_createCreateWorkflow(e){return m.create(this,e,((e,t)=>this._applyEdits(e,t)))}_createUpdateWorkflow(e){return W.create(this,e,((e,t)=>this._applyEdits(e,t)))}async _delete(e){const t=e.sourceLayer;"applyEdits"in t&&await this._applyEdits(t,{deleteFeatures:[e]})}async _applyEdits(e,t){await this._queueOperation((async()=>{const r=await this.view.whenLayerView(e),a=await e.applyEdits(t);return await c(r,"updating"),a}))}_queueOperation(e){this.activityQueue.push(e),this.notifyChange("syncing");const t=(e,t)=>{const r=t.indexOf(e);r>-1&&t.splice(r,1)};return e().then((({addFeatureResults:e,deleteFeatureResults:t,updateFeatureResults:r})=>{const a=e.find((e=>!!e.error))||r.find((e=>!!e.error))||t.find((e=>!!e.error));if(a)throw a.error})).catch((r=>{A("editing:operation-error","An error occurred.",{error:r});const a={error:r,retry:()=>(t(a,this.failures),this._queueOperation(e)),cancel:()=>{t(a,this.failures)}};this._set("failures",[...this.failures,a])})).then((()=>{t(e,this.activityQueue),this.notifyChange("syncing")}))}};e([p({readOnly:!0})],V.prototype,"activeWorkflow",void 0),e([p({readOnly:!0})],V.prototype,"activityQueue",void 0),e([p({value:[...j]})],V.prototype,"allowedWorkflows",null),e([p({readOnly:!0})],V.prototype,"canCreate",null),e([p({readOnly:!0})],V.prototype,"canUpdate",null),e([p({readOnly:!0})],V.prototype,"editableItems",null),e([p({readOnly:!0})],V.prototype,"failures",void 0),e([p()],V.prototype,"attachmentsViewModel",void 0),e([p()],V.prototype,"featureFormViewModel",void 0),e([p()],V.prototype,"featureTemplatesViewModel",void 0),e([p()],V.prototype,"layerInfos",void 0),e([p()],V.prototype,"sketchViewModel",void 0),e([d("sketchViewModel.snappingOptions")],V.prototype,"snappingOptions",void 0),e([p()],V.prototype,"spinnerViewModel",void 0),e([p()],V.prototype,"state",null),e([p({readOnly:!0})],V.prototype,"syncing",null),e([p()],V.prototype,"view",null),V=e([u(F)],V);const U=V;export{U as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Collection.js";import r from"../../core/Error.js";import a from"../../core/Evented.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import i from"../../core/Logger.js";import{on as s,init as n,watch as l,whenFalseOnce as c}from"../../core/watchUtils.js";import{aliasOf as d}from"../../core/accessorSupport/decorators/aliasOf.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";import w from"../../layers/GraphicsLayer.js";import f from"../../views/interactive/snapping/SnappingOptions.js";import h from"../Attachments/AttachmentsViewModel.js";import k from"./CreateFeaturesWorkflow.js";import m from"./CreateWorkflow.js";import{workflowDeprecation as y}from"./deprecationUtils.js";import W from"./UpdateWorkflow.js";import v from"../FeatureForm/FeatureFormViewModel.js";import g from"../FeatureTemplates/FeatureTemplatesViewModel.js";import _ from"../Sketch/SketchViewModel.js";import C from"../Spinner/SpinnerViewModel.js";const F="esri.widgets.Editor.EditorViewModel",b=i.getLogger(F),j=["create","create-features","update"];function A(e,t,a){b.error(new r(e,t,a))}function M(e,t){return e&&e.find((e=>e.layer===t))}let V=class extends(o(a.EventedAccessor)){constructor(e){super(e),this._sketchGraphicsLayer=new w({listMode:"hide",internal:!0}),this.activeWorkflow=null,this.activityQueue=[],this.failures=[],this.attachmentsViewModel=new h({abilities:{editing:!0}}),this.featureFormViewModel=new v,this.featureTemplatesViewModel=new g,this.layerInfos=null,this.sketchViewModel=new _({layer:this._sketchGraphicsLayer}),this.snappingOptions=new f,this.spinnerViewModel=new C}initialize(){this.handles.add([s(this,"activeWorkflow","cancel",(()=>this.emit("workflow-cancel"))),s(this,"activeWorkflow","commit",(()=>this.emit("workflow-commit"))),n(this,"view.map",(e=>{e&&e.add(this._sketchGraphicsLayer)})),l(this,"editableItems",(()=>{const{activeWorkflow:e}=this;if(this.refreshCreationTemplates(),!e)return;const{stepId:t}=e;"create"!==e.type?"update"===e.type&&("awaiting-feature-to-update"===t&&!this.canUpdate||"awaiting-update-feature-candidate"===t&&!e.data.candidates.some((e=>{const t=this.editableItems.find((t=>t.layer===e.layer));return t&&t.supports.includes("update")})))&&this._cancelWorkflow():"awaiting-feature-creation-info"!==t||this.canCreate||this._cancelWorkflow()}))])}destroy(){this._cancelWorkflow().then((()=>{var e;null!=(e=this.view)&&e.map&&this.view.map.remove(this._sketchGraphicsLayer),this.view=null}))}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(e){e&&0!==e.length||(e=[...j]),this._set("allowedWorkflows",e)}get canCreate(){return this.editableItems.some((e=>e.supports.includes("create")))}get canUpdate(){return this.editableItems.some((e=>e.supports.includes("update")))}get editableItems(){var e,r,a;const o=null==(e=this.view)?void 0:e.allLayerViews;if(!o)return new t;const i=new Set(null==(r=this.view)||null==(a=r.map)?void 0:a.editableLayers);return o.filter((e=>i.has(e.layer))).map((e=>{const{layer:t,suspended:r}=e,{data:a,operations:o}=t.capabilities,i=M(this.layerInfos,t),s="supportsAttachment"in a&&a.supportsAttachment&&(!i||!1!==i.allowAttachments);if(r)return{hasAttachments:s,layer:t,supports:[]};const n=[];return o.supportsAdd&&(this.allowedWorkflows.includes("create")||this.allowedWorkflows.includes("create-features"))&&(!i||!1!==i.enabled&&!1!==i.addEnabled)&&n.push("create"),o.supportsUpdate&&this.allowedWorkflows.includes("update")&&(!i||!1!==i.enabled&&!1!==i.updateEnabled)&&n.push("update"),!1!==(i&&i.deleteEnabled)&&o.supportsDelete&&n.push("delete"),{hasAttachments:s,layer:t,supports:n}})).reverse()}get state(){if(!this.get("view.ready")||0===this.editableItems.length)return"disabled";const e=this.attachmentsViewModel.mode;if("add"===e)return"adding-attachment";if("edit"===e)return"editing-attachment";const{activeWorkflow:t}=this;return t?t.stepId:"ready"}get syncing(){return this.activityQueue.length>0}set view(e){this.sketchViewModel.view=e,this.spinnerViewModel.view=e,this._set("view",e)}async startCreateWorkflowAtFeatureTypeSelection(){if(y(b,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),!this.canCreate)return void A("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow();await e.start(),this._set("activeWorkflow",e)}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateWorkflowAtFeatureCreation(e){if(y(b,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),!this.canCreate)return void A("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow("awaiting-feature-to-create");t.data.creationInfo=e,await t.start(),this._set("activeWorkflow",t)}async startCreateFeaturesWorkflowAtFeatureCreation(e){return this.startCreateFeaturesWorkflow(e,"creating-features")}async startCreateFeaturesWorkflow(e,t="awaiting-feature-creation-info"){if(!this.canCreate)throw new r("editing:unsupported-workflow","Creating features is unsupported or disabled.");await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow(e,t);await a.start(),this._set("activeWorkflow",a)}async startCreateWorkflowAtFeatureEdit(e){if(y(b,"startCreateWorkflowAtFeatureEdit"),!this.canCreate)return void A("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow("editing-new-feature");t.data.edits.feature=e,await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtFeatureSelection(){if(!this.canUpdate)return void A("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow();await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtMultipleFeatureSelection(e){if(!this.canUpdate)return void A("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow("awaiting-update-feature-candidate");t.data.candidates=e,await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtFeatureEdit(e){if(!this.canUpdate)return void A("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow("editing-existing-feature");t.data.edits.feature=e,await t.start(),this._set("activeWorkflow",t)}async deleteFeatureFromWorkflow(){const{activeWorkflow:e}=this;e&&"update"===e.type?(await this._delete(e.data.edits.feature),await e.reset()):A("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(e){return this._cancelWorkflow({warn:!0,...e})}refreshCreationTemplates(){const e=[];for(const{layer:t,supports:r}of this.editableItems)t.loaded&&r.includes("create")&&e.push(t);this.featureTemplatesViewModel.layers=e}async _cancelWorkflow(e){const t=this.activeWorkflow;if(!t)return void(e&&e.warn&&A("editing:no-active-workflow","There is no active workflow to cancel."));if(!e||!1!==e.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await t.cancel(e);await t.cancel(e),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(e,t){return k.create(this,e,t,((e,t)=>this._applyEdits(e,t)))}_createCreateWorkflow(e){return m.create(this,e,((e,t)=>this._applyEdits(e,t)))}_createUpdateWorkflow(e){return W.create(this,e,((e,t)=>this._applyEdits(e,t)))}async _delete(e){const t=e.sourceLayer;"applyEdits"in t&&await this._applyEdits(t,{deleteFeatures:[e]})}async _applyEdits(e,t){await this._queueOperation((async()=>{const r=await this.view.whenLayerView(e),a=await e.applyEdits(t);return await c(r,"updating"),a}))}_queueOperation(e){this.activityQueue.push(e),this.notifyChange("syncing");const t=(e,t)=>{const r=t.indexOf(e);r>-1&&t.splice(r,1)};return e().then((({addFeatureResults:e,deleteFeatureResults:t,updateFeatureResults:r})=>{const a=e.find((e=>!!e.error))||r.find((e=>!!e.error))||t.find((e=>!!e.error));if(a)throw a.error})).catch((r=>{A("editing:operation-error","An error occurred.",{error:r});const a={error:r,retry:()=>(t(a,this.failures),this._queueOperation(e)),cancel:()=>{t(a,this.failures)}};this._set("failures",[...this.failures,a])})).then((()=>{t(e,this.activityQueue),this.notifyChange("syncing")}))}};e([p({readOnly:!0})],V.prototype,"activeWorkflow",void 0),e([p({readOnly:!0})],V.prototype,"activityQueue",void 0),e([p({value:[...j]})],V.prototype,"allowedWorkflows",null),e([p({readOnly:!0})],V.prototype,"canCreate",null),e([p({readOnly:!0})],V.prototype,"canUpdate",null),e([p({readOnly:!0})],V.prototype,"editableItems",null),e([p({readOnly:!0})],V.prototype,"failures",void 0),e([p()],V.prototype,"attachmentsViewModel",void 0),e([p()],V.prototype,"featureFormViewModel",void 0),e([p()],V.prototype,"featureTemplatesViewModel",void 0),e([p()],V.prototype,"layerInfos",void 0),e([p()],V.prototype,"sketchViewModel",void 0),e([d("sketchViewModel.snappingOptions")],V.prototype,"snappingOptions",void 0),e([p()],V.prototype,"spinnerViewModel",void 0),e([p()],V.prototype,"state",null),e([p({readOnly:!0})],V.prototype,"syncing",null),e([p()],V.prototype,"view",null),V=e([u(F)],V);const U=V;export{U as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../Graphic.js";import"../../core/has.js";import{isSome as t,isNone as r,removeMaybe as i}from"../../core/maybe.js";import{whenOrAbort as a,eachAlways as n}from"../../core/promiseUtils.js";import{px2pt as s}from"../../core/screenUtils.js";import{init as o,whenFalseOnce as l}from"../../core/watchUtils.js";import{diff as c}from"../../core/accessorSupport/diffUtils.js";import{calculateTolerance as u}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as p}from"../../renderers/support/lengthUtils.js";import{getTransformationType as y,TransformationType as f}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{getRotationAngle as d,getSize as m}from"../../renderers/visualVariables/support/visualVariableUtils.js";import{to3D as h}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as g}from"../../symbols/support/symbolUtils.js";import{GraphicState as b}from"../../views/3d/layers/graphics/GraphicState.js";import{createQueryGeometry as w}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as v}from"../../views/support/hitTestSelectUtils.js";function S(e){const r=e.sourceLayer;if("feature"!==r.type||!F(r.renderer))return{rotation:null,size:null};let i=null,a=null;const n=r.renderer.getVisualVariablesForType("rotation").filter((r=>(!r.axis||"heading"===r.axis)&&r.field&&!r.valueExpression&&t(d(r,e))));1===n.length&&(i=j(n[0],r));const s=r.renderer.getVisualVariablesForType("size").filter((r=>r.field&&!r.useSymbolValue&&!r.valueExpression&&y(r)===f.RealWorldSize&&t(m(r,e))));return 1===s.length&&(a=U(s[0],r)),{rotation:i,size:a}}function j(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,i=e.field,a=t.fields&&t.fields.filter((e=>e.name===i)),n=a&&1===a.length?a[0].type:"double",s={initial:0,current:0};return{field:i,getDefault:()=>Promise.resolve(0),getValue:e=>(s.current=s.initial-r*e,z((s.current+360)%360,n)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1}}function I(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function V(e,t,i){if(r(t))return 0;const{symbol:a}=h(t);if(r(a)||"web-style"===a.type||"cim"===a.type)return 0;const n=a.symbolLayers.getItemAt(0);if(!n)return 0;switch(n.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return n.size||Math.min(B.icon,(await e(n,B.icon))[0])||B.icon}case"text":return n.size||B.text;case"line":return n.size||B.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return I(await t(n,e.scale/B.viewScaleSizeFactor),i)}case"path":return(null!=n.width?n.width:n.height)||e.scale/B.viewScaleSizeFactor;case"extrude":return n.size||e.scale/B.viewScaleSizeFactor;default:return 0}}function U(e,t){const r=e.field,i=e.axis,a=t.fields&&t.fields.filter((e=>e.name===r)),n=a&&1===a.length?a[0].type:"double",s={updating:!1,initial:0,current:0},o=p[e.valueUnit];let l;return l="area"===e.valueRepresentation?e=>(e*o/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*o/2:e=>e*o,{field:r,getDefault:async(e,t)=>z(l(await V(t,e,i)),n),getValue:(e,t)=>(s.initial||(s.initial=t.pixelSizeAt(t.center)),s.current=s.initial*e,z(s.current,n)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1}}function z(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function F(e){switch(e.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":return!0;default:return!1}}async function L(e){const r=await g(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0}),i=c(e.symbol,r);t(i)&&(e.symbol=r)}function x(e){if("mesh"===e||"multipatch"===e)throw new Error("Mesh and Multipatch not supported");return e}async function M(e,t,r){await R(e,t);const i=e.on("create",(async i=>{if("cancel"===i.state)return R(e,t);if("complete"===i.state){const e=i.graphic;e.sourceLayer||(e.sourceLayer=t.layer),e.attributes||(e.attributes={...t.template.prototype.attributes}),await L(e),r(e)}}));return{remove:()=>{i.remove(),e.cancel()}}}async function R(e,t){const r=t.layer,i={...t.template.prototype.attributes};await E(e,r,i);const a={graphicProperties:{attributes:i,sourceLayer:r},hasZ:r.capabilities.data.supportsZ};return e.layer.elevationInfo=r.elevationInfo,e.create(x(r.geometryType),a)}async function E(t,i,a){var n;const s=new e({sourceLayer:i,attributes:a}),{rotation:o,size:l}=S(s);let c=await g(s,{useSourceLayer:!0}),u=!1;for(const e of[l,o]){if(r(e))continue;null==a[e.field]&&(a[e.field]=await e.getDefault(c,t.view),u=!0)}switch(u&&(c=await g(s,{useSourceLayer:!0})),null==(n=c)?void 0:n.type){case"simple-fill":case"polygon-3d":t.polygonSymbol=c;break;case"simple-line":case"line-3d":t.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":t.pointSymbol=c}}function T(e,t){return e&&e.find((e=>e.layer===t))}async function k(e,t,r,i){if(0===e.length)return[];const{updatable:s,graphicsByLayer:o}=await r.async((async()=>{const{results:n}=await a(v(t,r),i),s=new Map,o=({layer:e})=>{const t=s.get(e);if(!t){const t=new Array;return s.set(e,t),t}return t};n.forEach((({graphic:e})=>o(e).push(e)));const l=e.filter((({supports:e,layer:t})=>e.indexOf("update")>-1&&s.has(t)));return 0!==l.length&&r.stopPropagation(),{updatable:l,graphicsByLayer:s}}));return a(n(s.map((async({layer:e})=>{const{objectIdField:t,displayField:r}=e,a=[t];e.fieldsIndex.has(r)&&a.push(r);const n=o.get(e);if(!!n.some((e=>a.some((t=>!(t in e.attributes)))))){const t=e.createQuery();return t.outFields=a,t.returnGeometry=!1,t.objectIds=n.map((e=>e.getObjectId())),e.queryFeatures(t,{signal:i}).then((({features:e})=>e))}return n}))),i)}async function A(e,t,r,i){if(0===e.length)return[];let s=null;const o=await r.async((async()=>{const{results:n}=await a(t.hitTest(r),i);if(0===n.length)return[];const o=new Set;s=n,s.forEach((({graphic:e})=>o.add(e.layer)));const l=e.items.filter((({layer:e,supports:t})=>t.indexOf("update")>-1&&o.has(e)));return l.length>0&&r.stopPropagation(),l}));return a(n(o.map((({layer:e})=>{const{objectIdField:a,displayField:n}=e,o=[a];e.fieldsIndex.has(n)&&o.push(n);const l=e.createQuery();l.outFields=o,l.returnGeometry=!1;const c="renderer"in e?u({renderer:e.renderer,event:r}):0;return l.geometry=w(r.mapPoint,c,t),l.outSpatialReference=t.spatialReference,e.queryFeatures(l,{signal:i}).then((({features:t})=>(s.forEach((({graphic:r})=>{if(r.layer===e){t.find((t=>t.attributes[a]===r.attributes[e.objectIdField]))||t.push(r)}})),t)))}))),i)}async function G(e,t,r,i){switch(t.type){case"3d":return k(e,t,r,i);case"2d":return A(e,t,r,i)}}async function P(e,t,r){const i=e.layer,a=i.createQuery();return a.objectIds=[e.getAttribute(i.objectIdField)],a.outFields=["*"],a.outSpatialReference=t.spatialReference,a.returnM=i.capabilities.data.supportsM,a.returnZ=i.capabilities.data.supportsZ,(await i.queryFeatures(a,{signal:r})).features[0]}async function q(e,i,a,n){let s=!1;const{rotation:o,size:l}=n;[o,l].forEach((async a=>{if(r(a))return;const n=i.attributes[a.field];if(t(n))a.initValue(n);else{const t=await a.getDefault(i.symbol,e.view);a.initValue(t),i.setAttribute(a.field,t),s=!0}})),s&&await L(i);const c={multipleSelectionEnabled:!1};return"point"===a.geometryType&&(c.enableRotation=t(o),c.enableScaling=t(l)),e.layer.elevationInfo=a.elevationInfo,e.update(i,c)}function D(e){return!e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function O(e){return!e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function Z(e,r,i,a){var n;if(!t(r.geometry)||"point"!==(null==(n=r.geometry)?void 0:n.type))return;const s=a.rotation,o=D(i.toolEventInfo);if(t(s)&&t(o))if("rotate-stop"===o.type)s.isUpdatingInteractively=!1,s.initValue();else{s.isUpdatingInteractively=!0;const{field:t,getValue:i}=s;r.attributes[t]=i(o.angle,e)}const l=a.size,c=O(i.toolEventInfo);if(t(l)&&t(c))if("scale-stop"===c.type)l.isUpdatingInteractively=!1,l.initValue();else{l.isUpdatingInteractively=!0;const{field:t,getValue:i}=l;r.attributes[t]=i(c.xScale,e)}await L(r)}async function Q(e,a,n,s,c){const u=e.clone();await L(u),s.map.add(n.layer),n.layer.add(u);const p=e.sourceLayer,y=s.whenLayerView(p),f=()=>{const t=e.layer,r=e.attributes[t.objectIdField];return y.then((e=>e.setVisibility(r,!1)),(()=>{})),{remove(){y.then((e=>e.setVisibility(r,!0)),(()=>{}))}}};let d=null,m=null;if("3d"===s.type){const e=new b({graphic:u});d=s.trackGraphicState(e),o(e,"displaying",(e=>{m=e?f():i(m)}))}else m=f();await q(n,u,p,a);let h=null;y.then((e=>h=e),(()=>{}));const g=a.size,w=a.rotation,v=e.watch("attributes",(async e=>{let i=!1;for(const a in e){const n=e[a];n!==u.attributes[a]&&(u.setAttribute(a,n),t(g)&&!g.isUpdatingInteractively&&g.field===a&&g.initValue(n),t(w)&&!w.isUpdatingInteractively&&w.field===a&&w.initValue(n),(r(h)||h.requiredFields.includes(a))&&(i=!0))}i&&await L(u)})),S=n.on("update",(async e=>{const t=e.graphics[0];if("complete"===e.state)return q(n,t,p,a);await Z(s,t,e,a),c(t.clone())})),j=n.on(["undo","redo"],(async e=>{c(e.graphics[0].clone())})),I=()=>{};return{interactive:{remove(){j.remove(),S.remove(),n.cancel(),v&&v.remove(),this.remove=I}},visual:{remove(){i(m),s.whenLayerView(p).then((e=>l(e,"updating"))).then((()=>{i(d),n.layer.remove(u),this.remove=I}))}}}}const B={icon:s(24),text:s(12),line:s(1),viewScaleSizeFactor:100};function C(e,t,r){let i=!1;return e.filter((e=>!!i||(i=e===t,i))).map((e=>r[e]()))}function W(e){if(1!==e.length)return null;const t=e[0];if("items"in t){const e=t;return 1===e.items.length?e.items[0]:null}return t}function H(e,r){if(e.viewModel.refreshCreationTemplates(),"awaiting-feature-creation-info"===r[0].id){const i=W(e.viewModel.featureTemplatesViewModel.items);t(i)&&(e.creationInfo={layer:i.layer,template:i.template},r.shift())}return r}export{H as avoidFeatureTemplateSelectionWithOnlyOneItem,C as createWorkflowSteps,G as fetchCandidates,P as fetchFullFeature,T as findLayerInfo,S as getVisualVariableAttributes,M as setUpFeatureAdd,Q as setUpGeometryUpdate,B as sizeDefaults,R as startCreatingNewFeature,q as startUpdatingFeature,L as updateGraphicSymbolWhenRequired,Z as visualVariableInteractiveUpdate};
5
+ import e from"../../Graphic.js";import"../../core/has.js";import{isSome as t,isNone as r,removeMaybe as i}from"../../core/maybe.js";import{whenOrAbort as a,eachAlways as n}from"../../core/promiseUtils.js";import{px2pt as s}from"../../core/screenUtils.js";import{init as o,whenFalseOnce as l}from"../../core/watchUtils.js";import{diff as c}from"../../core/accessorSupport/diffUtils.js";import{calculateTolerance as u}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as p}from"../../renderers/support/lengthUtils.js";import{getTransformationType as y,TransformationType as f}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{getRotationAngle as d,getSize as m}from"../../renderers/visualVariables/support/visualVariableUtils.js";import{to3D as h}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as g}from"../../symbols/support/symbolUtils.js";import{GraphicState as b}from"../../views/3d/layers/graphics/GraphicState.js";import{createQueryGeometry as w}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as v}from"../../views/support/hitTestSelectUtils.js";function S(e){const r=e.sourceLayer;if("feature"!==r.type||!F(r.renderer))return{rotation:null,size:null};let i=null,a=null;const n=r.renderer.getVisualVariablesForType("rotation").filter((r=>(!r.axis||"heading"===r.axis)&&r.field&&!r.valueExpression&&t(d(r,e))));1===n.length&&(i=j(n[0],r));const s=r.renderer.getVisualVariablesForType("size").filter((r=>r.field&&!r.useSymbolValue&&!r.valueExpression&&y(r)===f.RealWorldSize&&t(m(r,e))));return 1===s.length&&(a=U(s[0],r)),{rotation:i,size:a}}function j(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,i=e.field,a=t.fields&&t.fields.filter((e=>e.name===i)),n=a&&1===a.length?a[0].type:"double",s={initial:0,current:0};return{field:i,getDefault:()=>Promise.resolve(0),getValue:e=>(s.current=s.initial-r*e,z((s.current+360)%360,n)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1}}function I(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function V(e,t,i){if(r(t))return 0;const{symbol:a}=h(t);if(r(a)||"web-style"===a.type||"cim"===a.type)return 0;const n=a.symbolLayers.getItemAt(0);if(!n)return 0;switch(n.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return n.size||Math.min(C.icon,(await e(n,C.icon))[0])||C.icon}case"text":return n.size||C.text;case"line":return n.size||C.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return I(await t(n,e.scale/C.viewScaleSizeFactor),i)}case"path":return(null!=n.width?n.width:n.height)||e.scale/C.viewScaleSizeFactor;case"extrude":return n.size||e.scale/C.viewScaleSizeFactor;default:return 0}}function U(e,t){const r=e.field,i=e.axis,a=t.fields&&t.fields.filter((e=>e.name===r)),n=a&&1===a.length?a[0].type:"double",s={updating:!1,initial:0,current:0},o=p[e.valueUnit];let l;return l="area"===e.valueRepresentation?e=>(e*o/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*o/2:e=>e*o,{field:r,getDefault:async(e,t)=>z(l(await V(t,e,i)),n),getValue:(e,t)=>(s.initial||(s.initial=t.pixelSizeAt(t.center)),s.current=s.initial*e,z(s.current,n)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1}}function z(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function F(e){switch(e.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":return!0;default:return!1}}async function L(e){const r=await g(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0}),i=c(e.symbol,r);t(i)&&(e.symbol=r)}function x(e){if("mesh"===e||"multipatch"===e)throw new Error("Mesh and Multipatch not supported");return e}async function M(e,t,r){await R(e,t);const i=e.on("create",(async i=>{if("cancel"===i.state)return R(e,t);if("complete"===i.state){const e=i.graphic;e.sourceLayer||(e.sourceLayer=t.layer),e.attributes||(e.attributes={...t.template.prototype.attributes}),await L(e),r(e)}}));return{remove:()=>{i.remove(),e.cancel()}}}async function R(e,t){const r=t.layer,i={...t.template.prototype.attributes};await E(e,r,i);const a={graphicProperties:{attributes:i,sourceLayer:r},hasZ:r.capabilities.data.supportsZ};return e.layer.elevationInfo=r.elevationInfo,e.create(x(r.geometryType),a)}async function E(t,i,a){var n;const s=new e({sourceLayer:i,attributes:a}),{rotation:o,size:l}=S(s);let c=await g(s,{useSourceLayer:!0}),u=!1;for(const e of[l,o]){if(r(e))continue;null==a[e.field]&&(a[e.field]=await e.getDefault(c,t.view),u=!0)}switch(u&&(c=await g(s,{useSourceLayer:!0})),null==(n=c)?void 0:n.type){case"simple-fill":case"polygon-3d":t.polygonSymbol=c;break;case"simple-line":case"line-3d":t.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":t.pointSymbol=c}}function T(e,t){return e&&e.find((e=>e.layer===t))}async function k(e,t,r,i){if(0===e.length)return[];const{updatable:s,graphicsByLayer:o}=await r.async((async()=>{const{results:n}=await a(v(t,r),i),s=new Map,o=({layer:e})=>{const t=s.get(e);if(!t){const t=new Array;return s.set(e,t),t}return t};n.forEach((({graphic:e})=>o(e).push(e)));const l=e.filter((({supports:e,layer:t})=>e.includes("update")&&s.has(t)));return 0!==l.length&&r.stopPropagation(),{updatable:l,graphicsByLayer:s}}));return a(n(s.map((async({layer:e})=>{const{objectIdField:t,displayField:r}=e,a=[t];e.fieldsIndex.has(r)&&a.push(r);const n=o.get(e);if(!!n.some((e=>a.some((t=>!(t in e.attributes)))))){const t=e.createQuery();return t.outFields=a,t.returnGeometry=!1,t.objectIds=n.map((e=>e.getObjectId())),e.queryFeatures(t,{signal:i}).then((({features:e})=>e))}return n}))),i)}async function A(e,t,r,i){if(0===e.length)return[];let s=null;const o=await r.async((async()=>{const{results:n}=await a(t.hitTest(r),i);if(0===n.length)return[];const o=new Set;s=n,s.forEach((({graphic:e})=>o.add(e.layer)));const l=e.items.filter((({layer:e,supports:t})=>t.includes("update")&&o.has(e)));return l.length>0&&r.stopPropagation(),l}));return a(n(o.map((({layer:e})=>{const{objectIdField:a,displayField:n}=e,o=[a];e.fieldsIndex.has(n)&&o.push(n);const l=e.createQuery();l.outFields=o,l.returnGeometry=!1;const c="renderer"in e?u({renderer:e.renderer,event:r}):0;return l.geometry=w(r.mapPoint,c,t),l.outSpatialReference=t.spatialReference,e.queryFeatures(l,{signal:i}).then((({features:t})=>(s.forEach((({graphic:r})=>{if(r.layer===e){t.find((t=>t.attributes[a]===r.attributes[e.objectIdField]))||t.push(r)}})),t)))}))),i)}async function G(e,t,r,i){switch(t.type){case"3d":return k(e,t,r,i);case"2d":return A(e,t,r,i)}}async function P(e,t,r){const i=e.layer,a=i.createQuery();return a.objectIds=[e.getAttribute(i.objectIdField)],a.outFields=["*"],a.outSpatialReference=t.spatialReference,a.returnM=i.capabilities.data.supportsM,a.returnZ=i.capabilities.data.supportsZ,(await i.queryFeatures(a,{signal:r})).features[0]}async function q(e,i,a,n){let s=!1;const{rotation:o,size:l}=n;[o,l].forEach((async a=>{if(r(a))return;const n=i.attributes[a.field];if(t(n))a.initValue(n);else{const t=await a.getDefault(i.symbol,e.view);a.initValue(t),i.setAttribute(a.field,t),s=!0}})),s&&await L(i);const c={multipleSelectionEnabled:!1};return"point"===a.geometryType&&(c.enableRotation=t(o),c.enableScaling=t(l)),e.layer.elevationInfo=a.elevationInfo,e.update(i,c)}function D(e){return!e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function Z(e){return!e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function Q(e,r,i,a){var n;if(!t(r.geometry)||"point"!==(null==(n=r.geometry)?void 0:n.type))return;const s=a.rotation,o=D(i.toolEventInfo);if(t(s)&&t(o))if("rotate-stop"===o.type)s.isUpdatingInteractively=!1,s.initValue();else{s.isUpdatingInteractively=!0;const{field:t,getValue:i}=s;r.attributes[t]=i(o.angle,e)}const l=a.size,c=Z(i.toolEventInfo);if(t(l)&&t(c))if("scale-stop"===c.type)l.isUpdatingInteractively=!1,l.initValue();else{l.isUpdatingInteractively=!0;const{field:t,getValue:i}=l;r.attributes[t]=i(c.xScale,e)}await L(r)}async function B(e,a,n,s,c){const u=e.clone();await L(u),s.map.add(n.layer),n.layer.add(u);const p=e.sourceLayer,y=s.whenLayerView(p),f=()=>{const t=e.layer,r=e.attributes[t.objectIdField];return y.then((e=>e.setVisibility(r,!1)),(()=>{})),{remove(){y.then((e=>e.setVisibility(r,!0)),(()=>{}))}}};let d=null,m=null;if("3d"===s.type){const e=new b({graphic:u});d=s.trackGraphicState(e),o(e,"displaying",(e=>{m=e?f():i(m)}))}else m=f();await q(n,u,p,a);let h=null;y.then((e=>h=e),(()=>{}));const g=a.size,w=a.rotation,v=e.watch("attributes",(async e=>{let i=!1;for(const a in e){const n=e[a];n!==u.attributes[a]&&(u.setAttribute(a,n),t(g)&&!g.isUpdatingInteractively&&g.field===a&&g.initValue(n),t(w)&&!w.isUpdatingInteractively&&w.field===a&&w.initValue(n),(r(h)||h.requiredFields.includes(a))&&(i=!0))}i&&await L(u)})),S=n.on("update",(async e=>{const t=e.graphics[0];if("complete"===e.state)return q(n,t,p,a);await Q(s,t,e,a),c(t.clone())})),j=n.on(["undo","redo"],(async e=>{c(e.graphics[0].clone())})),I=()=>{};return{interactive:{remove(){j.remove(),S.remove(),n.cancel(),v&&v.remove(),this.remove=I}},visual:{remove(){i(m),s.whenLayerView(p).then((e=>l(e,"updating"))).then((()=>{i(d),n.layer.remove(u),this.remove=I}))}}}}const C={icon:s(24),text:s(12),line:s(1),viewScaleSizeFactor:100};function O(e,t,r){let i=!1;return e.filter((e=>!!i||(i=e===t,i))).map((e=>r[e]()))}function W(e){if(1!==e.length)return null;const t=e[0];if("items"in t){const e=t;return 1===e.items.length?e.items[0]:null}return t}function H(e,r){if(e.viewModel.refreshCreationTemplates(),"awaiting-feature-creation-info"===r[0].id){const i=W(e.viewModel.featureTemplatesViewModel.items);t(i)&&(e.creationInfo={layer:i.layer,template:i.template},r.shift())}return r}export{H as avoidFeatureTemplateSelectionWithOnlyOneItem,O as createWorkflowSteps,G as fetchCandidates,P as fetchFullFeature,T as findLayerInfo,S as getVisualVariableAttributes,M as setUpFeatureAdd,B as setUpGeometryUpdate,C as sizeDefaults,R as startCreatingNewFeature,q as startUpdatingFeature,L as updateGraphicSymbolWhenRequired,Q as visualVariableInteractiveUpdate};
package/widgets/Editor.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{HandleOwnerMixin as t}from"../core/HandleOwner.js";import s from"../core/Logger.js";import{isSome as i}from"../core/maybe.js";import{watch as a}from"../core/reactiveUtils.js";import{init as r,on as o,watch as n,whenNot as l}from"../core/watchUtils.js";import{aliasOf as d}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import{cast as c}from"../core/accessorSupport/decorators/cast.js";import{property as p}from"../core/accessorSupport/decorators/property.js";import{subclass as h}from"../core/accessorSupport/decorators/subclass.js";import{getDisplayFieldName as m}from"../layers/support/fieldUtils.js";import u from"../views/interactive/snapping/SnappingOptions.js";import g from"./Attachments.js";import v from"./FeatureForm.js";import _ from"./FeatureTemplates.js";import w from"./Spinner.js";import f from"./Widget.js";import{workflowDeprecation as k}from"./Editor/deprecationUtils.js";import y from"./Editor/EditorViewModel.js";import{ItemList as b}from"./FeatureTemplates/ItemList.js";import{Heading as C,incrementHeadingLevel as M}from"./support/Heading.js";import F from"./support/SnappingControls.js";import{accessibleHandler as A}from"./support/decorators/accessibleHandler.js";import{messageBundle as W}from"./support/decorators/messageBundle.js";import{vmEvent as T}from"./support/decorators/vmEvent.js";import{tsx as S}from"./support/jsxFactory.js";import{classes as E}from"./support/widgetUtils.js";import{substitute as B}from"../intl/substitute.js";const P={base:"esri-editor esri-widget esri-widget--panel",scroller:"esri-editor__scroller",content:"esri-editor__content",contentGroup:"esri-editor__content-group",message:"esri-editor__message",controls:"esri-editor__controls",progressBar:"esri-editor__progress-bar",promptContainer:"esri-editor__prompt",promptHeader:"esri-editor__prompt__header",promptHeading:"esri-editor__prompt__header__heading",promptMessage:"esri-editor__prompt__message",promptDivider:"esri-editor__prompt__divider",promptActions:"esri-editor__prompt__actions",promptOption:"esri-editor__prompt__option",promptOptionPrimary:"esri-editor__prompt__option--primary",promptOptionNegative:"esri-editor__prompt__option--negative",promptOptionPositive:"esri-editor__prompt__option--positive",controlButton:"esri-editor__control-button",overlay:"esri-editor__overlay",warningIcon:"esri-icon-notice-triangle",widgetIcon:"esri-icon-edit",button:"esri-button",buttonDisabled:"esri-button--disabled",buttonSecondary:"esri-button--secondary",buttonTertiary:"esri-button--tertiary",input:"esri-input",interactive:"esri-interactive",select:"esri-select",panelToolbar:"esri-editor__panel-toolbar",panelToolbarSnappingButton:"esri-editor__panel-toolbar__snapping-button",panelContent:"esri-editor__panel-content",panelContentSection:"esri-editor__panel-content--section",updateFeaturesActionButtons:"esri-editor__update-features-action-buttons",updateFeaturesActionButtonsButton:"esri-editor__update-features-action-buttons--button",featureTemplatesContainer:"esri-editor__feature-templates-container",snappingControlsPopover:"esri-editor__snapping-controls-popover",scrimOverlay:"esri-editor__scrim-overlay"},j={undoRedoButtons:!1};function L(e){e.focus()}const x="esri.widgets.Editor",U=s.getLogger(x);let V=class extends(t(f)){constructor(e,t){super(e,t),this._candidateCommitted=!1,this._featureForm=new v,this._stateStack=[],this._attachments=new g({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._featureTemplates=new _({enableListScroll:!1}),this._filterText="",this._prompt=null,this._spinner=new w,this._snappingPopover=null,this.activeWorkflow=null,this.allowedWorkflows=null,this.useDeprecatedCreateWorkflow=!1,this.headingLevel=4,this.iconClass=P.widgetIcon,this.label=void 0,this.layerInfos=null,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.snappingOptions=new u,this.supportingWidgetDefaults=null,this.view=null,this.viewModel=new y,this.visibleElements={...j},this._setCandidateFeature=(e,t=!1)=>{if(this._candidateCommitted)return;const s=this._assertActiveUpdateWorkflow();s.data.edits.feature=e,t&&(s.next(),this._candidateCommitted=!0)},this._handleSave=this._handleSave.bind(this),this._handleBack=this._handleBack.bind(this),this._handleDone=this._handleDone.bind(this),this._handleDelete=this._handleDelete.bind(this),this._handleAdd=this._handleAdd.bind(this),this._handleEdit=this._handleEdit.bind(this),this._handleAttachmentAdd=this._handleAttachmentAdd.bind(this),this._handleAttachmentUpdate=this._handleAttachmentUpdate.bind(this),this._handleAttachmentDelete=this._handleAttachmentDelete.bind(this),this.EditorPanel=this.EditorPanel.bind(this)}initialize(){const{view:e,snappingOptions:t}=this;this._snappingControls=new F({snappingOptions:t,view:e,visibleElements:{header:!1}}),this.own([r(this,"headingLevel",(e=>{this._featureForm.headingLevel=M(e),this._featureTemplates.headingLevel=M(e)})),this.viewModel.featureTemplatesViewModel.on("select",(({item:e})=>this.useDeprecatedCreateWorkflow?this.startCreateWorkflowAtFeatureCreation(e):this.startCreateFeaturesWorkflowAtFeatureCreation(e))),a((()=>this.viewModel.state),((e,t)=>{const s=this._stateStack.indexOf(e);-1===s?this._stateStack.push(t):this._stateStack.splice(s)})),r(this,"viewModel",(e=>{this._featureForm.viewModel=e?e.featureFormViewModel:null,this._attachments.viewModel=e?e.attachmentsViewModel:null,this._featureTemplates.viewModel=e?e.featureTemplatesViewModel:null,this._spinner.viewModel=e?e.spinnerViewModel:null})),r(this,"view",((e,t)=>{const s=`editor-${this.id}-spinner`;t&&t.ui.remove(this._spinner,s),e&&e.ui.add(this._spinner,{key:s,position:"manual"})})),o(this,"viewModel.sketchViewModel","create",(()=>{this.scheduleRender()})),o(this,"viewModel.activeWorkflow","cancel-request",(({controller:e})=>{const{messages:t,messagesCommon:s}=this;this._prompt={title:t.cancelRequestTitle,message:t.cancelRequestWarningMessage,context:"danger",actions:{primary:{label:s.form.yes,action:()=>{e.allow(),this._prompt=null}},secondary:{label:s.form.no,action:()=>(e.deny(),this._prompt=null)}}},this.scheduleRender()})),r(this,"supportingWidgetDefaults",(e=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel.set(e.sketch))})),n(this,"_attachments.error",(e=>{if(!e)return;const{messages:t,messagesCommon:s}=this;this._prompt={title:t.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:s.form.ok,action:()=>{this._prompt=null}}}}})),n(this,"viewModel.failures",(e=>{if(!e)return;const{messages:t}=this,[{error:s,retry:i,cancel:a}]=e;this._prompt={title:t.errorWarningTitle,message:B(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{i(),this._prompt=null}},secondary:{label:t.ignore,action:()=>(a(),this._prompt=null)}}}})),n(this,"viewModel.state",(e=>{"awaiting-feature-to-update"===e&&(this._filterText=""),"awaiting-update-feature-candidate"===e&&(this._candidateCommitted=!1)})),n(this,["_attachments.selectedFile","_attachments.submitting"],(()=>this.scheduleRender())),l(this,"viewModel.activeWorkflow",(()=>this._featureTemplates.filterText=""))])}destroy(){this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._snappingControls.destroy()}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-action.js"),import("@esri/calcite-components/dist/components/calcite-action-menu.js"),import("@esri/calcite-components/dist/components/calcite-button.js"),import("@esri/calcite-components/dist/components/calcite-flow.js"),import("@esri/calcite-components/dist/components/calcite-icon.js"),import("@esri/calcite-components/dist/components/calcite-loader.js"),import("@esri/calcite-components/dist/components/calcite-panel.js"),import("@esri/calcite-components/dist/components/calcite-popover.js"),import("@esri/calcite-components/dist/components/calcite-popover-manager.js"),import("@esri/calcite-components/dist/components/calcite-scrim.js"),import("@esri/calcite-components/dist/components/calcite-tooltip-manager.js")])}castVisibleElements(e){return{...j,...e}}startCreateWorkflowAtFeatureTypeSelection(){return k(U,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),this.viewModel.startCreateWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateWorkflowAtFeatureCreation(e){return k(U,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),this.viewModel.startCreateWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateWorkflowAtFeatureEdit(e){return k(U,"startCreateWorkflowAtFeatureEdit"),this.viewModel.startCreateWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{_attachments:e,_prompt:t,viewModel:s}=this;if(!s)return S("div",{class:P.base});const{state:a}=s,r=i(t)?S("calcite-scrim",null,this.renderPrompt(t)):null;return S("div",{class:P.base},s.syncing||e.submitting?this.renderProgressBar():null,S("calcite-flow",null,this._stateStack.map((e=>this.renderState(e))),this.renderState(a)),r)}renderState(e){switch(e){case"disabled":break;case"ready":return this.renderLanding(e);case"awaiting-feature-creation-info":return this.renderTemplates(e);case"creating-features":case"editing-new-feature":case"editing-existing-feature":return this.renderAttributeEditing(e);case"awaiting-feature-to-update":return this.renderFeatureUpdating(e);case"awaiting-update-feature-candidate":return this.renderFeatureList(e);case"awaiting-feature-to-create":return this.renderFeatureCreation(e);case"adding-attachment":return this.renderAttachmentAdding(e);case"editing-attachment":return this.renderAttachmentEditing(e)}return S("div",null)}isPanelActive(e){return this.viewModel.state===e}renderTemplates(e){const{EditorPanel:t,headingLevel:s,messages:i,messagesCommon:a,_handleBack:r,_snappingControls:o,viewModel:{sketchViewModel:n}}=this;return S(t,{active:this.isPanelActive(e),key:"templates-panel",handleBack:r,heading:i.selectTemplate,headingLevel:s,messages:i,messagesCommon:a,sketchViewModel:n,snappingControls:o},this._featureTemplates.render())}renderAttributeEditing(e){const{activeWorkflow:t,EditorPanel:s,messages:i,messagesCommon:a,headingLevel:r,_handleBack:o,_snappingControls:n,viewModel:l}=this,{sketchViewModel:d}=l,c=l.featureFormViewModel;if("create-features"===t.type&&t.pendingFeatures.length<1)return this.renderFeatureCreation(e);const p="update"===t.type&&!t.data.edits.modified||l.syncing||c.inputFields.length>0&&!c.submittable,h="update"===t.type?i.editFeature:i.createFeatures,m="update"===t.type?a.update:a.create,u="create-features"===t.type&&"create-new"===t.createFeatureState,g=[{label:"create-features"===t.type&&t.numPendingFeatures>1?B(i.createFeaturesTemplate,{numFeatures:t.numPendingFeatures}):m,type:"primary",disabled:p,clickHandler:this._handleSave}];let v=!1;return"update"===t.type&&(t.data.editableItem.hasAttachments&&(v=!0),t.data.editableItem.supports.includes("delete")&&g.push({label:a.delete,type:"tertiary",clickHandler:this._handleDelete})),S(s,{active:this.isPanelActive(e),key:"attribute-editing-panel",heading:h,headingLevel:r,showContentScrim:u,handleBack:o,messages:i,messagesCommon:a,sketchViewModel:d,snappingControls:n},S("div",{class:P.panelContentSection},S("div",{class:P.contentGroup},c.inputFields.length>0?this._featureForm.render():this.renderMessage(B(i.clickToFinishTemplate,{button:m})),v?S("div",{key:"attachments"},S("div",null,i.attachments),this._attachments.render()):null)),S("div",{class:this._prompt?"":P.scrimOverlay},this.renderControls(g)))}renderAttachmentAdding(e){const{_attachments:t,EditorPanel:s,_handleBack:i,headingLevel:a,messages:r,messagesCommon:o,_snappingControls:n,viewModel:{sketchViewModel:l}}=this,d=[{label:t.submitting?o.cancel:o.add,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._handleAttachmentAdd}];return S(s,{active:this.isPanelActive(e),key:"attachment-adding-panel",heading:r.addAttachment,headingLevel:a,handleBack:i,messages:r,messagesCommon:o,sketchViewModel:l,snappingControls:n},S("div",{class:this.classes(P.content,P.scroller)},t.render()),this.renderControls(d))}renderAttachmentEditing(e){const{_attachments:t,EditorPanel:s,_handleBack:i,headingLevel:a,messages:r,messagesCommon:o,_snappingControls:n,viewModel:{sketchViewModel:l}}=this,d=[{label:o.update,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._handleAttachmentUpdate},{label:o.delete,disabled:t.submitting,type:"tertiary",clickHandler:this._handleAttachmentDelete}];return S(s,{active:this.isPanelActive(e),key:"attachment-editing-panel",heading:r.editAttachment,headingLevel:a,handleBack:i,messages:r,messagesCommon:o,sketchViewModel:l,snappingControls:n},S("div",{class:this.classes(P.content,P.scroller)},t.render()),this.renderControls(d))}renderFeatureUpdating(e){const{EditorPanel:t,_handleBack:s,headingLevel:i,messages:a,messagesCommon:r,_snappingControls:o,viewModel:{sketchViewModel:n}}=this;return S(t,{active:this.isPanelActive(e),key:"feature-updating-panel",heading:a.selectFeature,headingLevel:i,handleBack:s,messages:a,messagesCommon:r,sketchViewModel:n,snappingControls:o},S("div",{class:this.classes(P.content,P.scroller)},this.renderMessage(a.selectFeatureToEdit)))}renderMessage(e){return S("div",{class:P.message},e)}renderFeatureCreation(e){const{EditorPanel:t,_handleBack:s,headingLevel:i,messages:a,messagesCommon:r,_snappingControls:o,viewModel:n}=this,{sketchViewModel:l}=n,d=n.sketchViewModel,c=this._assertActiveCreateWorkflow().data.creationInfo.layer,p=d.canUndo()&&d.createGraphic?d.createGraphic:null,h=this._getSketchingTip(c.geometryType,p);return S(t,{active:this.isPanelActive(e),key:"feature-creation-panel",heading:a.placeFeature,headingLevel:i,handleBack:s,messages:a,messagesCommon:r,sketchViewModel:l,snappingControls:o},S("div",{class:this.classes(P.content,P.scroller)},this.renderMessage(h)))}renderControls(e){return S("div",{class:P.controls,key:"controls"},e.map((({disabled:e=!1,label:t,type:s,clickHandler:i},a)=>this.renderButton({label:t,class:this.classes(P.controlButton,P.button,"secondary"===s?P.buttonSecondary:"tertiary"===s?P.buttonTertiary:null,e?P.buttonDisabled:null),disabled:e,clickHandler:i,key:a}))))}renderPrompt({title:e,message:t,context:s,actions:i}){const a=!!i.secondary,r=S("calcite-button",{appearance:"solid",color:"danger"===s?"red":"blue",width:a?"half":"full",onclick:i.primary.action,key:"prompt-primary-button",afterCreate:L},i.primary.label),o=a?S("calcite-button",{appearance:"clear",color:"danger"===s?"red":"blue",width:"half",onclick:i.secondary.action,key:"prompt-secondary-button"},i.secondary.label):null;return S("div",{class:`${P.promptContainer}--${s}`},S("div",{class:P.promptHeader},S("calcite-icon",{icon:"exclamation-mark-triangle"}),S(C,{class:P.promptHeading,level:this.headingLevel},e)),S("div",{class:P.promptMessage},t),S("div",{class:P.promptDivider}),S("div",{class:P.promptActions},o,r))}renderProgressBar(){return S("div",{class:this.classes(P.progressBar),key:"progress-bar"})}renderButton(e){return S("button",{class:e.class,disabled:e.disabled,key:e.key,onclick:e.clickHandler,type:"button"},e.label)}renderLanding(e){const{EditorPanel:t,headingLevel:s,messages:i,messagesCommon:a,_snappingControls:r,viewModel:{sketchViewModel:o}}=this;return S(t,{active:this.isPanelActive(e),key:"landing-panel",heading:i.widgetLabel,headingLevel:s,showBackButton:!1,messages:i,messagesCommon:a,sketchViewModel:o,snappingControls:r},S("div",{key:"edit-actions",class:P.panelContentSection},this.renderUpdateActions()),S("div",{key:"create-actions",class:P.panelContentSection},this.renderCreateActions()))}renderUpdateActions(){const{messages:e,messagesCommon:t}=this;return S("div",null,S(C,{level:M(this.headingLevel)},e.editFeatures),S("div",{class:P.updateFeaturesActionButtons},S("calcite-action",{text:t.select,textEnabled:!0,icon:"cursor",alignment:"start",class:P.updateFeaturesActionButtonsButton,onclick:this._handleEdit})))}renderCreateActions(){const{messages:e}=this;return S("div",null,S(C,{level:M(this.headingLevel)},e.createFeatures),S("div",{key:"templates",class:P.featureTemplatesContainer},this._featureTemplates.render()))}renderFeatureList(e){const{EditorPanel:t,_handleBack:s,headingLevel:i,messages:a,messagesCommon:r,messagesTemplates:o,_snappingControls:n,viewModel:{editableItems:l,sketchViewModel:d}}=this,c=this._assertActiveUpdateWorkflow().data.candidates,p=B(a.multipleFeaturesTemplate,{total:c.length}),h=new Map;let m=0;c.map((e=>({label:this._getLabel(e),id:e.attributes[e.layer.objectIdField],data:e}))).filter((e=>{const{label:t,data:s}=e,i=this._filterText.toLowerCase(),{title:a}=s.layer,r=this.viewModel.editableItems.find((e=>e.layer===s.layer));return r.supports.indexOf("update")>-1&&(!i||t.toLowerCase().indexOf(i)>-1||a.toLowerCase().indexOf(i)>-1)})).forEach((e=>{m++;const t=e.data.layer;h.has(t)?h.get(t).items.push(e):h.set(t,{id:`${t.id}`,label:t.title,items:[e]})}));const u=l.filter((({layer:e})=>h.has(e))).map((({layer:e})=>h.get(e))).toArray(),g=m>10||this._filterText.length>0;return S(t,{active:this.isPanelActive(e),key:"feature-list",heading:p,headingLevel:i,handleBack:s,messages:a,messagesCommon:r,sketchViewModel:d,snappingControls:n},b({id:this.id,enableListScroll:!1,filterEnabled:g,filterText:this._filterText,items:u,messages:{filterPlaceholder:o.filterPlaceholder,noItems:o.noItems,noMatches:o.noMatches},onItemMouseEnter:({data:e})=>this._setCandidateFeature(e),onItemMouseLeave:()=>this._setCandidateFeature(null),onItemSelect:({data:e})=>this._setCandidateFeature(e,!0),onFilterChange:e=>this._filterText=e}))}EditorPanel(e,...t){const{active:s,handleBack:i,heading:a,headingLevel:r,key:o,messages:n,messagesCommon:l,showBackButton:d,showContentScrim:c,sketchViewModel:p,snappingControls:h}=e;return S("calcite-panel",{bind:this,key:o,heading:a,headingLevel:r,showBackButton:null==d||d,beforeBack:null!=i?i:null,onCalcitePanelScroll:this._onSnappingPopoverPanelScroll},S("calcite-popover-manager",{autoClose:s,class:P.panelToolbar},S("calcite-popover",{afterCreate:this._afterSnappingPopoverCreated,afterUpdate:this._afterSnappingPopoverUpdated,bind:this,label:n.snappingSettings,heading:n.snappingSettings,"reference-element":`${o}__snappingButton`,"overlay-positioning":"fixed"},S("div",{class:P.snappingControlsPopover},h.render())),S("calcite-button",{id:`${o}__snappingButton`,text:n.snapping,appearance:"transparent",color:"neutral",alignment:"icon-end-space-between","icon-start":"vertex-gps","icon-end":"caret-down",width:"full",class:P.panelToolbarSnappingButton},n.snapping),this.visibleElements.undoRedoButtons?[S("calcite-button",{key:"undo-button",text:l.undo,appearance:"transparent",color:"neutral",alignment:"center","icon-start":"undo",scale:"l",disabled:!p.canUndo(),onclick:p.undo.bind(p)}),S("calcite-button",{key:"redo-button",text:l.redo,appearance:"transparent",color:"neutral",alignment:"center","icon-start":"redo",scale:"l",disabled:!p.canRedo(),onclick:p.redo.bind(p)})]:null),S("div",{class:E(P.panelContent,P.scroller)},t,c?S("calcite-scrim",null):null))}_onSnappingPopoverPanelScroll(){var e;null!=(e=this._snappingPopover)&&e.open&&this._snappingPopover.toggle()}_afterSnappingPopoverCreated(e){this._snappingPopover=e}_afterSnappingPopoverUpdated(e){this._snappingPopover=e}_getSketchingTip(e,t){const{messages:s}=this;if("point"===e)return s.tips.clickToAddPoint;if("polygon"===e||"polyline"===e){if(!t)return s.tips.clickToStart;const i=t.geometry,a="polygon"===e?"rings":"paths",[r]=i[a];return"polygon"===e&&r<4?s.tips.clickToContinue:s.tips.clickToContinueThenDoubleClickToEnd}return s.tips.clickToAddFeature}_getLabel(e){const t=e.layer;if(!t)return null;const{objectIdField:s}=t,{attributes:i}=e,a=m(t);return a&&i[a]&&`${i[a]}`||B(this.messages.untitledFeatureTemplate,{id:i[s]})}_handleDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.viewModel.deleteFeatureFromWorkflow(),this._prompt=null}},secondary:{label:e.keepFeature,action:()=>this._prompt=null}}}}_handleSave(){this.viewModel.featureFormViewModel.validateContingencyConstraints(this.viewModel.featureFormViewModel.getValues(),{includeIncompleteViolations:!0}).length>0||this.viewModel.activeWorkflow.commit()}_handleAttachmentAdd(){const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.addAttachment().then((()=>t.previous()))}_handleAttachmentUpdate(){const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.updateAttachment().then((()=>t.previous()))}_handleAttachmentDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.deleteAttachment(e.viewModel.activeAttachmentInfo).then((()=>{t.previous(),this._prompt=null}))}},secondary:{label:e.keepAttachment,action:()=>this._prompt=null}}}}_handleAdd(){this.viewModel.canCreate}_handleEdit(){this.viewModel.canUpdate&&this.viewModel.startUpdateWorkflowAtFeatureSelection()}_handleDone(){this.viewModel.cancelWorkflow({force:!0})}async _handleBack(){const{messages:e}=this,t=this.activeWorkflow,s=()=>{t.hasPreviousStep?t.previous({cancelCurrentStep:!0}):this.viewModel.cancelWorkflow({force:!0})};if("create"===t.type||"create-features"===t.type&&t.numPendingFeatures>0||"update"===t.type&&t.data.edits.modified){const{type:i}=t,a="create"===i?e.cancelAddWarningMessage:e.cancelEditWarningMessage,r="create"===i?e.cancelAddTitle:e.cancelEditTitle,o="create"===i?e.continueAdding:e.continueEditing,n="create"===i?e.discardFeature:e.discardEdits;return this._prompt={title:r,message:a,context:"danger",actions:{primary:{label:n,action:()=>{s(),this._prompt=null}},secondary:{label:o,action:()=>this._prompt=null}}},this.scheduleRender(),Promise.reject()}s()}_assertActiveCreateWorkflow(){const{type:e}=this.viewModel.activeWorkflow;if("create"===e||"create-features"===e)return this.viewModel.activeWorkflow;throw Error("Expected activeWorkflow to be instance of CreateWorkflow or CreateFeaturesWorkflow")}_assertActiveUpdateWorkflow(){if("update"===this.viewModel.activeWorkflow.type)return this.viewModel.activeWorkflow;throw Error("Expected activeWorkflow to be an UpdateWorkflow")}};e([p()],V.prototype,"_attachments",void 0),e([d("viewModel.activeWorkflow")],V.prototype,"activeWorkflow",void 0),e([d("viewModel.allowedWorkflows")],V.prototype,"allowedWorkflows",void 0),e([p()],V.prototype,"useDeprecatedCreateWorkflow",void 0),e([p()],V.prototype,"headingLevel",void 0),e([p()],V.prototype,"iconClass",void 0),e([p({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],V.prototype,"label",void 0),e([d("viewModel.layerInfos")],V.prototype,"layerInfos",void 0),e([p(),W("esri/widgets/Editor/t9n/Editor")],V.prototype,"messages",void 0),e([p(),W("esri/t9n/common")],V.prototype,"messagesCommon",void 0),e([p(),W("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],V.prototype,"messagesTemplates",void 0),e([d("viewModel.snappingOptions")],V.prototype,"snappingOptions",void 0),e([p()],V.prototype,"supportingWidgetDefaults",void 0),e([d("viewModel.view")],V.prototype,"view",void 0),e([p(),T(["workflow-cancel","workflow-commit"])],V.prototype,"viewModel",void 0),e([p()],V.prototype,"visibleElements",void 0),e([c("visibleElements")],V.prototype,"castVisibleElements",null),e([A()],V.prototype,"_handleDelete",null),e([A()],V.prototype,"_handleAttachmentAdd",null),e([A()],V.prototype,"_handleAttachmentUpdate",null),e([A()],V.prototype,"_handleAttachmentDelete",null),e([A()],V.prototype,"_handleAdd",null),e([A()],V.prototype,"_handleEdit",null),e([A()],V.prototype,"_handleDone",null),V=e([h(x)],V);const D=V;export{D as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{HandleOwnerMixin as t}from"../core/HandleOwner.js";import s from"../core/Logger.js";import{isSome as i}from"../core/maybe.js";import{watch as a}from"../core/reactiveUtils.js";import{init as r,on as o,watch as n,whenNot as l}from"../core/watchUtils.js";import{aliasOf as d}from"../core/accessorSupport/decorators/aliasOf.js";import"../core/arrayUtils.js";import"../core/has.js";import{cast as c}from"../core/accessorSupport/decorators/cast.js";import{property as p}from"../core/accessorSupport/decorators/property.js";import{subclass as h}from"../core/accessorSupport/decorators/subclass.js";import{getDisplayFieldName as m}from"../layers/support/fieldUtils.js";import u from"../views/interactive/snapping/SnappingOptions.js";import g from"./Attachments.js";import v from"./FeatureForm.js";import _ from"./FeatureTemplates.js";import w from"./Spinner.js";import f from"./Widget.js";import{workflowDeprecation as k}from"./Editor/deprecationUtils.js";import y from"./Editor/EditorViewModel.js";import{ItemList as b}from"./FeatureTemplates/ItemList.js";import{Heading as C,incrementHeadingLevel as M}from"./support/Heading.js";import A from"./support/SnappingControls.js";import{accessibleHandler as F}from"./support/decorators/accessibleHandler.js";import{messageBundle as W}from"./support/decorators/messageBundle.js";import{vmEvent as T}from"./support/decorators/vmEvent.js";import{tsx as S}from"./support/jsxFactory.js";import{classes as E}from"./support/widgetUtils.js";import{substitute as B}from"../intl/substitute.js";const P={base:"esri-editor esri-widget esri-widget--panel",scroller:"esri-editor__scroller",content:"esri-editor__content",contentGroup:"esri-editor__content-group",message:"esri-editor__message",controls:"esri-editor__controls",progressBar:"esri-editor__progress-bar",promptContainer:"esri-editor__prompt",promptHeader:"esri-editor__prompt__header",promptHeading:"esri-editor__prompt__header__heading",promptMessage:"esri-editor__prompt__message",promptDivider:"esri-editor__prompt__divider",promptActions:"esri-editor__prompt__actions",promptOption:"esri-editor__prompt__option",promptOptionPrimary:"esri-editor__prompt__option--primary",promptOptionNegative:"esri-editor__prompt__option--negative",promptOptionPositive:"esri-editor__prompt__option--positive",controlButton:"esri-editor__control-button",overlay:"esri-editor__overlay",warningIcon:"esri-icon-notice-triangle",widgetIcon:"esri-icon-edit",button:"esri-button",buttonDisabled:"esri-button--disabled",buttonSecondary:"esri-button--secondary",buttonTertiary:"esri-button--tertiary",input:"esri-input",interactive:"esri-interactive",select:"esri-select",panelToolbar:"esri-editor__panel-toolbar",panelToolbarSnappingButton:"esri-editor__panel-toolbar__snapping-button",panelContent:"esri-editor__panel-content",panelContentSection:"esri-editor__panel-content--section",updateFeaturesActionButtons:"esri-editor__update-features-action-buttons",updateFeaturesActionButtonsButton:"esri-editor__update-features-action-buttons--button",featureTemplatesContainer:"esri-editor__feature-templates-container",snappingControlsPopover:"esri-editor__snapping-controls-popover",scrimOverlay:"esri-editor__scrim-overlay"},j={undoRedoButtons:!1};function L(e){e.focus()}const U="esri.widgets.Editor",V=s.getLogger(U);let x=class extends(t(f)){constructor(e,t){super(e,t),this._candidateCommitted=!1,this._featureForm=new v,this._stateStack=[],this._attachments=new g({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._featureTemplates=new _({enableListScroll:!1}),this._filterText="",this._prompt=null,this._spinner=new w,this._snappingPopover=null,this.activeWorkflow=null,this.allowedWorkflows=null,this.useDeprecatedCreateWorkflow=!1,this.headingLevel=4,this.iconClass=P.widgetIcon,this.label=void 0,this.layerInfos=null,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.snappingOptions=new u,this.supportingWidgetDefaults=null,this.view=null,this.viewModel=new y,this.visibleElements={...j},this._setCandidateFeature=(e,t=!1)=>{if(this._candidateCommitted)return;const s=this._assertActiveUpdateWorkflow();s.data.edits.feature=e,t&&(s.next(),this._candidateCommitted=!0)},this._handleSave=this._handleSave.bind(this),this._handleBack=this._handleBack.bind(this),this._handleDone=this._handleDone.bind(this),this._handleDelete=this._handleDelete.bind(this),this._handleAdd=this._handleAdd.bind(this),this._handleEdit=this._handleEdit.bind(this),this._handleAttachmentAdd=this._handleAttachmentAdd.bind(this),this._handleAttachmentUpdate=this._handleAttachmentUpdate.bind(this),this._handleAttachmentDelete=this._handleAttachmentDelete.bind(this),this.EditorPanel=this.EditorPanel.bind(this)}initialize(){const{view:e,snappingOptions:t}=this;this._snappingControls=new A({snappingOptions:t,view:e,visibleElements:{header:!1}}),this.own([r(this,"headingLevel",(e=>{this._featureForm.headingLevel=M(e),this._featureTemplates.headingLevel=M(e)})),this.viewModel.featureTemplatesViewModel.on("select",(({item:e})=>this.useDeprecatedCreateWorkflow?this.startCreateWorkflowAtFeatureCreation(e):this.startCreateFeaturesWorkflowAtFeatureCreation(e))),a((()=>this.viewModel.state),((e,t)=>{const s=this._stateStack.indexOf(e);-1===s?this._stateStack.push(t):this._stateStack.splice(s)})),r(this,"viewModel",(e=>{this._featureForm.viewModel=e?e.featureFormViewModel:null,this._attachments.viewModel=e?e.attachmentsViewModel:null,this._featureTemplates.viewModel=e?e.featureTemplatesViewModel:null,this._spinner.viewModel=e?e.spinnerViewModel:null})),r(this,"view",((e,t)=>{const s=`editor-${this.id}-spinner`;t&&t.ui.remove(this._spinner,s),e&&e.ui.add(this._spinner,{key:s,position:"manual"})})),o(this,"viewModel.sketchViewModel","create",(()=>{this.scheduleRender()})),o(this,"viewModel.activeWorkflow","cancel-request",(({controller:e})=>{const{messages:t,messagesCommon:s}=this;this._prompt={title:t.cancelRequestTitle,message:t.cancelRequestWarningMessage,context:"danger",actions:{primary:{label:s.form.yes,action:()=>{e.allow(),this._prompt=null}},secondary:{label:s.form.no,action:()=>(e.deny(),this._prompt=null)}}},this.scheduleRender()})),r(this,"supportingWidgetDefaults",(e=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel.set(e.sketch))})),n(this,"_attachments.error",(e=>{if(!e)return;const{messages:t,messagesCommon:s}=this;this._prompt={title:t.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:s.form.ok,action:()=>{this._prompt=null}}}}})),n(this,"viewModel.failures",(e=>{if(!e)return;const{messages:t}=this,[{error:s,retry:i,cancel:a}]=e;this._prompt={title:t.errorWarningTitle,message:B(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{i(),this._prompt=null}},secondary:{label:t.ignore,action:()=>(a(),this._prompt=null)}}}})),n(this,"viewModel.state",(e=>{"awaiting-feature-to-update"===e&&(this._filterText=""),"awaiting-update-feature-candidate"===e&&(this._candidateCommitted=!1)})),n(this,["_attachments.selectedFile","_attachments.submitting"],(()=>this.scheduleRender())),l(this,"viewModel.activeWorkflow",(()=>this._featureTemplates.filterText=""))])}destroy(){this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._snappingControls.destroy()}loadDependencies(){return Promise.all([import("@esri/calcite-components/dist/components/calcite-action.js"),import("@esri/calcite-components/dist/components/calcite-action-menu.js"),import("@esri/calcite-components/dist/components/calcite-button.js"),import("@esri/calcite-components/dist/components/calcite-flow.js"),import("@esri/calcite-components/dist/components/calcite-icon.js"),import("@esri/calcite-components/dist/components/calcite-loader.js"),import("@esri/calcite-components/dist/components/calcite-panel.js"),import("@esri/calcite-components/dist/components/calcite-popover.js"),import("@esri/calcite-components/dist/components/calcite-popover-manager.js"),import("@esri/calcite-components/dist/components/calcite-scrim.js"),import("@esri/calcite-components/dist/components/calcite-tooltip-manager.js")])}castVisibleElements(e){return{...j,...e}}startCreateWorkflowAtFeatureTypeSelection(){return k(V,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),this.viewModel.startCreateWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateWorkflowAtFeatureCreation(e){return k(V,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),this.viewModel.startCreateWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateWorkflowAtFeatureEdit(e){return k(V,"startCreateWorkflowAtFeatureEdit"),this.viewModel.startCreateWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{_attachments:e,_prompt:t,viewModel:s}=this;if(!s)return S("div",{class:P.base});const{state:a}=s,r=i(t)?S("calcite-scrim",null,this.renderPrompt(t)):null;return S("div",{class:P.base},s.syncing||e.submitting?this.renderProgressBar():null,S("calcite-flow",null,this._stateStack.map((e=>this.renderState(e))),this.renderState(a)),r)}renderState(e){switch(e){case"disabled":break;case"ready":return this.renderLanding(e);case"awaiting-feature-creation-info":return this.renderTemplates(e);case"creating-features":case"editing-new-feature":case"editing-existing-feature":return this.renderAttributeEditing(e);case"awaiting-feature-to-update":return this.renderFeatureUpdating(e);case"awaiting-update-feature-candidate":return this.renderFeatureList(e);case"awaiting-feature-to-create":return this.renderFeatureCreation(e);case"adding-attachment":return this.renderAttachmentAdding(e);case"editing-attachment":return this.renderAttachmentEditing(e)}return S("div",null)}isPanelActive(e){return this.viewModel.state===e}renderTemplates(e){const{EditorPanel:t,headingLevel:s,messages:i,messagesCommon:a,_handleBack:r,_snappingControls:o,viewModel:{sketchViewModel:n}}=this;return S(t,{active:this.isPanelActive(e),key:"templates-panel",handleBack:r,heading:i.selectTemplate,headingLevel:s,messages:i,messagesCommon:a,sketchViewModel:n,snappingControls:o},this._featureTemplates.render())}renderAttributeEditing(e){const{activeWorkflow:t,EditorPanel:s,messages:i,messagesCommon:a,headingLevel:r,_handleBack:o,_snappingControls:n,viewModel:l}=this,{sketchViewModel:d}=l,c=l.featureFormViewModel;if("create-features"===t.type&&t.pendingFeatures.length<1)return this.renderFeatureCreation(e);const p="update"===t.type&&!t.data.edits.modified||l.syncing,h="update"===t.type?i.editFeature:i.createFeatures,m="update"===t.type?a.update:a.create,u="create-features"===t.type&&"create-new"===t.createFeatureState,g=[{label:"create-features"===t.type&&t.numPendingFeatures>1?B(i.createFeaturesTemplate,{numFeatures:t.numPendingFeatures}):m,type:"primary",disabled:p,clickHandler:this._handleSave}];let v=!1;return"update"===t.type&&(t.data.editableItem.hasAttachments&&(v=!0),t.data.editableItem.supports.includes("delete")&&g.push({label:a.delete,type:"tertiary",clickHandler:this._handleDelete})),S(s,{active:this.isPanelActive(e),key:"attribute-editing-panel",heading:h,headingLevel:r,showContentScrim:u,handleBack:o,messages:i,messagesCommon:a,sketchViewModel:d,snappingControls:n},S("div",{class:P.panelContentSection},S("div",{class:P.contentGroup},c.inputFields.length>0?this._featureForm.render():this.renderMessage(B(i.clickToFinishTemplate,{button:m})),v?S("div",{key:"attachments"},S("div",null,i.attachments),this._attachments.render()):null)),S("div",{class:this._prompt?"":P.scrimOverlay},this.renderControls(g)))}renderAttachmentAdding(e){const{_attachments:t,EditorPanel:s,_handleBack:i,headingLevel:a,messages:r,messagesCommon:o,_snappingControls:n,viewModel:{sketchViewModel:l}}=this,d=[{label:t.submitting?o.cancel:o.add,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._handleAttachmentAdd}];return S(s,{active:this.isPanelActive(e),key:"attachment-adding-panel",heading:r.addAttachment,headingLevel:a,handleBack:i,messages:r,messagesCommon:o,sketchViewModel:l,snappingControls:n},S("div",{class:this.classes(P.content,P.scroller)},t.render()),this.renderControls(d))}renderAttachmentEditing(e){const{_attachments:t,EditorPanel:s,_handleBack:i,headingLevel:a,messages:r,messagesCommon:o,_snappingControls:n,viewModel:{sketchViewModel:l}}=this,d=[{label:o.update,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._handleAttachmentUpdate},{label:o.delete,disabled:t.submitting,type:"tertiary",clickHandler:this._handleAttachmentDelete}];return S(s,{active:this.isPanelActive(e),key:"attachment-editing-panel",heading:r.editAttachment,headingLevel:a,handleBack:i,messages:r,messagesCommon:o,sketchViewModel:l,snappingControls:n},S("div",{class:this.classes(P.content,P.scroller)},t.render()),this.renderControls(d))}renderFeatureUpdating(e){const{EditorPanel:t,_handleBack:s,headingLevel:i,messages:a,messagesCommon:r,_snappingControls:o,viewModel:{sketchViewModel:n}}=this;return S(t,{active:this.isPanelActive(e),key:"feature-updating-panel",heading:a.selectFeature,headingLevel:i,handleBack:s,messages:a,messagesCommon:r,sketchViewModel:n,snappingControls:o},S("div",{class:this.classes(P.content,P.scroller)},this.renderMessage(a.selectFeatureToEdit)))}renderMessage(e){return S("div",{class:P.message},e)}renderFeatureCreation(e){const{EditorPanel:t,_handleBack:s,headingLevel:i,messages:a,messagesCommon:r,_snappingControls:o,viewModel:n}=this,{sketchViewModel:l}=n,d=n.sketchViewModel,c=this._assertActiveCreateWorkflow().data.creationInfo.layer,p=d.canUndo()&&d.createGraphic?d.createGraphic:null,h=this._getSketchingTip(c.geometryType,p);return S(t,{active:this.isPanelActive(e),key:"feature-creation-panel",heading:a.placeFeature,headingLevel:i,handleBack:s,messages:a,messagesCommon:r,sketchViewModel:l,snappingControls:o},S("div",{class:this.classes(P.content,P.scroller)},this.renderMessage(h)))}renderControls(e){return S("div",{class:P.controls,key:"controls"},e.map((({disabled:e=!1,label:t,type:s,clickHandler:i},a)=>this.renderButton({label:t,class:this.classes(P.controlButton,P.button,"secondary"===s?P.buttonSecondary:"tertiary"===s?P.buttonTertiary:null,e?P.buttonDisabled:null),disabled:e,clickHandler:i,key:a}))))}renderPrompt({title:e,message:t,context:s,actions:i}){const a=!!i.secondary,r=S("calcite-button",{appearance:"solid",color:"danger"===s?"red":"blue",width:a?"half":"full",onclick:i.primary.action,key:"prompt-primary-button",afterCreate:L},i.primary.label),o=a?S("calcite-button",{appearance:"clear",color:"danger"===s?"red":"blue",width:"half",onclick:i.secondary.action,key:"prompt-secondary-button"},i.secondary.label):null;return S("div",{class:`${P.promptContainer}--${s}`},S("div",{class:P.promptHeader},S("calcite-icon",{icon:"exclamation-mark-triangle"}),S(C,{class:P.promptHeading,level:this.headingLevel},e)),S("div",{class:P.promptMessage},t),S("div",{class:P.promptDivider}),S("div",{class:P.promptActions},o,r))}renderProgressBar(){return S("div",{class:this.classes(P.progressBar),key:"progress-bar"})}renderButton(e){return S("button",{class:e.class,disabled:e.disabled,key:e.key,onclick:e.clickHandler,type:"button"},e.label)}renderLanding(e){const{EditorPanel:t,headingLevel:s,messages:i,messagesCommon:a,_snappingControls:r,viewModel:{sketchViewModel:o}}=this;return S(t,{active:this.isPanelActive(e),key:"landing-panel",heading:i.widgetLabel,headingLevel:s,showBackButton:!1,messages:i,messagesCommon:a,sketchViewModel:o,snappingControls:r},S("div",{key:"edit-actions",class:P.panelContentSection},this.renderUpdateActions()),S("div",{key:"create-actions",class:P.panelContentSection},this.renderCreateActions()))}renderUpdateActions(){const{messages:e,messagesCommon:t}=this;return S("div",null,S(C,{level:M(this.headingLevel)},e.editFeatures),S("div",{class:P.updateFeaturesActionButtons},S("calcite-action",{text:t.select,textEnabled:!0,icon:"cursor",alignment:"start",class:P.updateFeaturesActionButtonsButton,onclick:this._handleEdit})))}renderCreateActions(){const{messages:e}=this;return S("div",null,S(C,{level:M(this.headingLevel)},e.createFeatures),S("div",{key:"templates",class:P.featureTemplatesContainer},this._featureTemplates.render()))}renderFeatureList(e){const{EditorPanel:t,_handleBack:s,headingLevel:i,messages:a,messagesCommon:r,messagesTemplates:o,_snappingControls:n,viewModel:{editableItems:l,sketchViewModel:d}}=this,c=this._assertActiveUpdateWorkflow().data.candidates,p=B(a.multipleFeaturesTemplate,{total:c.length}),h=new Map;let m=0;c.map((e=>({label:this._getLabel(e),id:e.attributes[e.layer.objectIdField],data:e}))).filter((e=>{const{label:t,data:s}=e,i=this._filterText.toLowerCase(),{title:a}=s.layer,r=this.viewModel.editableItems.find((e=>e.layer===s.layer));return r.supports.includes("update")&&(!i||t.toLowerCase().includes(i)||a.toLowerCase().includes(i))})).forEach((e=>{m++;const t=e.data.layer;h.has(t)?h.get(t).items.push(e):h.set(t,{id:`${t.id}`,label:t.title,items:[e]})}));const u=l.filter((({layer:e})=>h.has(e))).map((({layer:e})=>h.get(e))).toArray(),g=m>10||this._filterText.length>0;return S(t,{active:this.isPanelActive(e),key:"feature-list",heading:p,headingLevel:i,handleBack:s,messages:a,messagesCommon:r,sketchViewModel:d,snappingControls:n},b({id:this.id,enableListScroll:!1,filterEnabled:g,filterText:this._filterText,items:u,messages:{filterPlaceholder:o.filterPlaceholder,noItems:o.noItems,noMatches:o.noMatches},onItemMouseEnter:({data:e})=>this._setCandidateFeature(e),onItemMouseLeave:()=>this._setCandidateFeature(null),onItemSelect:({data:e})=>this._setCandidateFeature(e,!0),onFilterChange:e=>this._filterText=e}))}EditorPanel(e,...t){const{active:s,handleBack:i,heading:a,headingLevel:r,key:o,messages:n,messagesCommon:l,showBackButton:d,showContentScrim:c,sketchViewModel:p,snappingControls:h}=e;return S("calcite-panel",{bind:this,key:o,heading:a,headingLevel:r,showBackButton:null==d||d,beforeBack:null!=i?i:null,onCalcitePanelScroll:this._onSnappingPopoverPanelScroll},S("calcite-popover-manager",{autoClose:s,class:P.panelToolbar},S("calcite-popover",{afterCreate:this._afterSnappingPopoverCreated,afterUpdate:this._afterSnappingPopoverUpdated,bind:this,label:n.snappingSettings,heading:n.snappingSettings,"reference-element":`${o}__snappingButton`,"overlay-positioning":"fixed"},S("div",{class:P.snappingControlsPopover},h.render())),S("calcite-button",{id:`${o}__snappingButton`,text:n.snapping,appearance:"transparent",color:"neutral",alignment:"icon-end-space-between","icon-start":"vertex-gps","icon-end":"caret-down",width:"full",class:P.panelToolbarSnappingButton},n.snapping),this.visibleElements.undoRedoButtons?[S("calcite-button",{key:"undo-button",text:l.undo,appearance:"transparent",color:"neutral",alignment:"center","icon-start":"undo",scale:"l",disabled:!p.canUndo(),onclick:p.undo.bind(p)}),S("calcite-button",{key:"redo-button",text:l.redo,appearance:"transparent",color:"neutral",alignment:"center","icon-start":"redo",scale:"l",disabled:!p.canRedo(),onclick:p.redo.bind(p)})]:null),S("div",{class:E(P.panelContent,P.scroller)},t,c?S("calcite-scrim",null):null))}_onSnappingPopoverPanelScroll(){var e;null!=(e=this._snappingPopover)&&e.open&&this._snappingPopover.toggle()}_afterSnappingPopoverCreated(e){this._snappingPopover=e}_afterSnappingPopoverUpdated(e){this._snappingPopover=e}_getSketchingTip(e,t){const{messages:s}=this;if("point"===e)return s.tips.clickToAddPoint;if("polygon"===e||"polyline"===e){if(!t)return s.tips.clickToStart;const i=t.geometry,a="polygon"===e?"rings":"paths",[r]=i[a];return"polygon"===e&&r<4?s.tips.clickToContinue:s.tips.clickToContinueThenDoubleClickToEnd}return s.tips.clickToAddFeature}_getLabel(e){const t=e.layer;if(!t)return null;const{objectIdField:s}=t,{attributes:i}=e,a=m(t);return a&&i[a]&&`${i[a]}`||B(this.messages.untitledFeatureTemplate,{id:i[s]})}_handleDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.viewModel.deleteFeatureFromWorkflow(),this._prompt=null}},secondary:{label:e.keepFeature,action:()=>this._prompt=null}}}}_handleSave(){const{featureFormViewModel:e}=this.viewModel;e.submit(),!e.submittable||e.validateContingencyConstraints(e.getValues(),{includeIncompleteViolations:!0}).length>0||this.viewModel.activeWorkflow.commit()}_handleAttachmentAdd(){const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.addAttachment().then((()=>t.previous()))}_handleAttachmentUpdate(){const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.updateAttachment().then((()=>t.previous()))}_handleAttachmentDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{const{_attachments:e}=this,{activeWorkflow:t}=this.viewModel;e.deleteAttachment(e.viewModel.activeAttachmentInfo).then((()=>{t.previous(),this._prompt=null}))}},secondary:{label:e.keepAttachment,action:()=>this._prompt=null}}}}_handleAdd(){this.viewModel.canCreate}_handleEdit(){this.viewModel.canUpdate&&this.viewModel.startUpdateWorkflowAtFeatureSelection()}_handleDone(){this.viewModel.cancelWorkflow({force:!0})}async _handleBack(){const{messages:e}=this,t=this.activeWorkflow,s=()=>{t.hasPreviousStep?t.previous({cancelCurrentStep:!0}):this.viewModel.cancelWorkflow({force:!0})};if("create"===t.type||"create-features"===t.type&&t.numPendingFeatures>0||"update"===t.type&&t.data.edits.modified){const{type:i}=t,a="create"===i?e.cancelAddWarningMessage:e.cancelEditWarningMessage,r="create"===i?e.cancelAddTitle:e.cancelEditTitle,o="create"===i?e.continueAdding:e.continueEditing,n="create"===i?e.discardFeature:e.discardEdits;throw this._prompt={title:r,message:a,context:"danger",actions:{primary:{label:n,action:()=>{s(),this._prompt=null}},secondary:{label:o,action:()=>this._prompt=null}}},this.scheduleRender(),new Error}s()}_assertActiveCreateWorkflow(){const{type:e}=this.viewModel.activeWorkflow;if("create"===e||"create-features"===e)return this.viewModel.activeWorkflow;throw Error("Expected activeWorkflow to be instance of CreateWorkflow or CreateFeaturesWorkflow")}_assertActiveUpdateWorkflow(){if("update"===this.viewModel.activeWorkflow.type)return this.viewModel.activeWorkflow;throw Error("Expected activeWorkflow to be an UpdateWorkflow")}};e([p()],x.prototype,"_attachments",void 0),e([d("viewModel.activeWorkflow")],x.prototype,"activeWorkflow",void 0),e([d("viewModel.allowedWorkflows")],x.prototype,"allowedWorkflows",void 0),e([p()],x.prototype,"useDeprecatedCreateWorkflow",void 0),e([p()],x.prototype,"headingLevel",void 0),e([p()],x.prototype,"iconClass",void 0),e([p({aliasOf:{source:"messages.widgetLabel",overridable:!0}})],x.prototype,"label",void 0),e([d("viewModel.layerInfos")],x.prototype,"layerInfos",void 0),e([p(),W("esri/widgets/Editor/t9n/Editor")],x.prototype,"messages",void 0),e([p(),W("esri/t9n/common")],x.prototype,"messagesCommon",void 0),e([p(),W("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],x.prototype,"messagesTemplates",void 0),e([d("viewModel.snappingOptions")],x.prototype,"snappingOptions",void 0),e([p()],x.prototype,"supportingWidgetDefaults",void 0),e([d("viewModel.view")],x.prototype,"view",void 0),e([p(),T(["workflow-cancel","workflow-commit"])],x.prototype,"viewModel",void 0),e([p()],x.prototype,"visibleElements",void 0),e([c("visibleElements")],x.prototype,"castVisibleElements",null),e([F()],x.prototype,"_handleDelete",null),e([F()],x.prototype,"_handleAttachmentAdd",null),e([F()],x.prototype,"_handleAttachmentUpdate",null),e([F()],x.prototype,"_handleAttachmentDelete",null),e([F()],x.prototype,"_handleAdd",null),e([F()],x.prototype,"_handleEdit",null),e([F()],x.prototype,"_handleDone",null),x=e([h(U)],x);const D=x;export{D as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../Graphic.js";import i from"../../core/Accessor.js";import{min as o}from"../../core/arrayUtils.js";import{ByteSizeUnit as r}from"../../core/byteSizeEstimations.js";import s from"../../core/Collection.js";import{referenceSetter as l}from"../../core/collectionUtils.js";import n from"../../core/Handles.js";import a from"../../core/Logger.js";import p from"../../core/LRUCache.js";import{isNone as u,destroyMaybe as h,isSome as c,applySome as d}from"../../core/maybe.js";import{memoize as f}from"../../core/memoize.js";import{watch as m,syncAndInitial as v}from"../../core/reactiveUtils.js";import{preferredLengthUnit as y,preferredVerticalLengthUnit as g,measurementLengthUnits as _}from"../../core/unitUtils.js";import{aliasOf as U}from"../../core/accessorSupport/decorators/aliasOf.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{property as b}from"../../core/accessorSupport/decorators/property.js";import{subclass as P}from"../../core/accessorSupport/decorators/subclass.js";import{ElevationQueryTileCache as j}from"../../layers/support/ElevationQueryTileCache.js";import{defaultUnitPropertyMetadata as w}from"../../properties/defaultUnit.js";import{ElevationProfileController as E}from"./ElevationProfileController.js";import O from"./ElevationProfileLineGround.js";import{ElevationProfileLineCollection as C}from"./elevationProfileLineTypes.js";import{ElevationProfileTool as S}from"./ElevationProfileTool.js";import{ElevationProfileState as T,ElevationProfileErrorState as D}from"./support/constants.js";import{isPolyline as G,isValidInputPath as I}from"./support/geometryUtils.js";import{isProfileGenerationError as L,ProfileGenerationErrorCause as k}from"./support/ProfileGenerationError.js";import{createProfileQueue as R}from"./support/profileUtils.js";import{getBoundsInMeters as x,mergeStatistics as V}from"./support/statisticsUtils.js";const z=a.getLogger("esri.widgets.ElevationProfile.ElevationProfileViewModel");let M=class extends i{constructor(t){super(t),this.view=null,this.input=null,this._getEffectiveUnitsMemoized=f(((t,e)=>({distance:t,elevation:e}))),this.geodesicDistanceThreshold=1e5,this.hoveredChartPosition=null,this.uniformChartScaling=!1,this.highlightEnabled=!0,this.defaultUnit=null,this.queue=null,this._currentTileCache=null,this.error=null,this._handles=new n,this._defaultProfileLineGround=new O,this._userUnitOptions=null,this._userUnit=null,null!=t&&t.profiles||(this.profiles=new s([this._defaultProfileLineGround]))}initialize(){this._handles.add(m((()=>this.view),(t=>{var e;u(t)?z.warnOnce("no view. Widget will be disabled until a view is provided."):this.queue=R("3d"===t.type?null==(e=t.resourceController)?void 0:e.scheduler:void 0)}),v)),this.tool=new S({viewModel:this}),this._controller=new E({viewModel:this})}destroy(){this._handles=h(this._handles),this._defaultProfileLineGround=h(this._defaultProfileLineGround),this._controller=h(this._controller),this._currentTileCache=h(this._currentTileCache),this.tool=h(this.tool),this.queue=h(this.queue)}set profiles(t){const e=this._get("profiles"),i=null!=t?t:new s;this._set("profiles",l(i,e))}get state(){const t=this.view;return c(t)&&t.ready?this.tool.state:T.Disabled}get progress(){let t=0,e=0;for(const i of this.visibleProfiles)t++,e+=i.progress;return t>0?e/t:0}set unitOptions(t){this._userUnitOptions=t,this._set("unitOptions",this._filteredOrAllUnits(this._userUnitOptions))}get unitOptions(){return this._filteredOrAllUnits(this._userUnitOptions)}set unit(t){this._userUnit=t?this._findSelectableUnit(t,this._userUnit):null,this.notifyChange("unit")}get unit(){return this._userUnit?(this._userUnit=this._findSelectableUnit(this._userUnit,this.defaultUnit),this._userUnit):this._findSelectableUnit(this.defaultUnit)}get effectiveUnits(){const t=x(this.visibleProfiles.map((t=>t.result))),e=y(t.maxDistance,"meters",this.unit),i=g(t.maxElevation,"meters",this.unit);return this._getEffectiveUnitsMemoized(e,i)}get hasVertices(){const t=d(this.input,(t=>t.geometry));return G(t)&&t.paths.reduce(((t,e)=>t+e.length),0)>0}get hoveredPoints(){return!u(this.input)&&this.visible&&this.tool.editable?this.visibleProfiles.map((t=>{const e=t.hoveredPoint;return c(e)?{hoveredPoint:e,color:t.color}:null})).filter(c):[]}get statistics(){return V(this.visibleProfiles.map((t=>t.statistics)))}get chartData(){if(u(this.input))return null;const{effectiveUnits:t,progress:e,statistics:i,visibleProfiles:o,uniformChartScaling:r}=this,s=o.filter((t=>t.hasZ)).map((t=>({id:t.id,type:t.type,title:t.title,color:t.color,samples:t.samples,progress:t.progress,chartFillEnabled:t.chartFillEnabled,chartStrokeWidth:t.chartStrokeWidth,chartStrokeOffsetY:t.chartStrokeOffsetY,viewVisualizationEnabled:t.viewVisualizationEnabled})));return 0===s.length?null:{lines:s,effectiveUnits:t,statistics:i,refined:1===e,dynamicElevationRange:o.some((t=>"view"===t.type)),uniformScaling:r}}get visibleProfiles(){return this.profiles.toArray().filter((t=>t.available&&t.visible))}get minDemResolutions(){const t=[];for(const{minDemResolution:e}of this.visibleProfiles)c(e)&&t.push(e);return t}get minDemResolution(){return o(this.minDemResolutions)}get errorState(){const t=d(this.input,(t=>t.geometry));if(!I(t))return D.NoValidInput;if(c(this.error)){if(L(this.error))switch(this.error.cause){case k.TooComplex:return D.TooComplex;case k.InvalidGeometry:return D.InvalidGeometry;case k.InvalidElevationInfo:return D.InvalidElevationInfo;case k.ElevationQueryError:return D.NoValidInput}return D.UnknownError}return 0===this.visibleProfiles.length?D.NoVisibleProfiles:u(this.chartData)&&1===this.progress?D.RefinedButNoChartData:D.None}get tileCache(){this._currentTileCache=h(this._currentTileCache);const t=this.view;if(c(t)&&"3d"===(null==t?void 0:t.type)){var e;const i=null==(e=t.basemapTerrain)?void 0:e.elevationQueryCache;if(c(i))return i}return u(this._currentTileCache)&&(this._currentTileCache=new j(new p(20*r.MEGABYTES))),this._currentTileCache}get inputIsSketched(){return this.tool.interaction.isSketchedGraphic(this.input)}get elevationProvider(){const t=this.view;return c(t)&&"3d"===t.type?t.elevationProvider:null}start(t){this.tool.interaction.start(t)}stop(){this.tool.interaction.stop()}cancel(){this.tool.interaction.cancel()}clear(){this.tool.interaction.clear()}_findSelectableUnit(t,e){const i=this.unitOptions;return c(t)&&-1!==i.indexOf(t)?t:e?this._findSelectableUnit(e):i[0]}_filteredOrAllUnits(t){const e=(c(t)?t:[]).filter((t=>-1!==_.indexOf(t)));return 0===e.length?_.slice():e}};t([b()],M.prototype,"view",void 0),t([b({type:e})],M.prototype,"input",void 0),t([b({type:C,nonNullable:!0})],M.prototype,"profiles",null),t([b({readOnly:!0})],M.prototype,"state",null),t([b({readOnly:!0})],M.prototype,"progress",null),t([b()],M.prototype,"unitOptions",null),t([b()],M.prototype,"unit",null),t([b({readOnly:!0})],M.prototype,"effectiveUnits",null),t([b({type:Number})],M.prototype,"geodesicDistanceThreshold",void 0),t([b()],M.prototype,"hoveredChartPosition",void 0),t([b()],M.prototype,"uniformChartScaling",void 0),t([U("tool.highlightEnabled")],M.prototype,"highlightEnabled",void 0),t([b({readOnly:!0})],M.prototype,"hoveredPoints",null),t([b({readOnly:!0})],M.prototype,"statistics",null),t([b()],M.prototype,"chartData",null),t([b()],M.prototype,"visibleProfiles",null),t([b()],M.prototype,"minDemResolutions",null),t([b({readOnly:!0})],M.prototype,"minDemResolution",null),t([b({readOnly:!0})],M.prototype,"errorState",null),t([b(w)],M.prototype,"defaultUnit",void 0),t([b()],M.prototype,"queue",void 0),t([b()],M.prototype,"tileCache",null),t([b()],M.prototype,"tool",void 0),t([U("tool.visible")],M.prototype,"visible",void 0),t([b()],M.prototype,"error",void 0),t([b()],M.prototype,"inputIsSketched",null),t([b()],M.prototype,"elevationProvider",null),t([b()],M.prototype,"_defaultProfileLineGround",void 0),t([b()],M.prototype,"_userUnitOptions",void 0),t([b()],M.prototype,"_controller",void 0),t([b()],M.prototype,"_userUnit",void 0),M=t([P("esri.widgets.ElevationProfile.ElevationProfileViewModel")],M);const N=M;export{N as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../Graphic.js";import i from"../../core/Accessor.js";import{min as o}from"../../core/arrayUtils.js";import{ByteSizeUnit as r}from"../../core/byteSizeEstimations.js";import s from"../../core/Collection.js";import{referenceSetter as l}from"../../core/collectionUtils.js";import n from"../../core/Handles.js";import a from"../../core/Logger.js";import p from"../../core/LRUCache.js";import{isNone as u,destroyMaybe as h,isSome as c,applySome as d}from"../../core/maybe.js";import{memoize as f}from"../../core/memoize.js";import{watch as m,syncAndInitial as v}from"../../core/reactiveUtils.js";import{preferredLengthUnit as y,preferredVerticalLengthUnit as g,measurementLengthUnits as _}from"../../core/unitUtils.js";import{aliasOf as U}from"../../core/accessorSupport/decorators/aliasOf.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{property as b}from"../../core/accessorSupport/decorators/property.js";import{subclass as P}from"../../core/accessorSupport/decorators/subclass.js";import{ElevationQueryTileCache as j}from"../../layers/support/ElevationQueryTileCache.js";import{defaultUnitPropertyMetadata as w}from"../../properties/defaultUnit.js";import{ElevationProfileController as E}from"./ElevationProfileController.js";import C from"./ElevationProfileLineGround.js";import{ElevationProfileLineCollection as O}from"./elevationProfileLineTypes.js";import{ElevationProfileTool as S}from"./ElevationProfileTool.js";import{ElevationProfileState as T,ElevationProfileErrorState as D}from"./support/constants.js";import{isPolyline as G,isValidInputPath as I}from"./support/geometryUtils.js";import{isProfileGenerationError as L,ProfileGenerationErrorCause as k}from"./support/ProfileGenerationError.js";import{createProfileQueue as R}from"./support/profileUtils.js";import{getBoundsInMeters as V,mergeStatistics as z}from"./support/statisticsUtils.js";const M=a.getLogger("esri.widgets.ElevationProfile.ElevationProfileViewModel");let N=class extends i{constructor(t){super(t),this.view=null,this.input=null,this._getEffectiveUnitsMemoized=f(((t,e)=>({distance:t,elevation:e}))),this.geodesicDistanceThreshold=1e5,this.hoveredChartPosition=null,this.uniformChartScaling=!1,this.highlightEnabled=!0,this.defaultUnit=null,this.queue=null,this._currentTileCache=null,this.error=null,this._handles=new n,this._defaultProfileLineGround=new C,this._userUnitOptions=null,this._userUnit=null,null!=t&&t.profiles||(this.profiles=new s([this._defaultProfileLineGround]))}initialize(){this._handles.add(m((()=>this.view),(t=>{var e;u(t)?M.warnOnce("no view. Widget will be disabled until a view is provided."):this.queue=R("3d"===t.type?null==(e=t.resourceController)?void 0:e.scheduler:void 0)}),v)),this.tool=new S({viewModel:this}),this._controller=new E({viewModel:this})}destroy(){this._handles=h(this._handles),this._defaultProfileLineGround=h(this._defaultProfileLineGround),this._controller=h(this._controller),this._currentTileCache=h(this._currentTileCache),this.tool=h(this.tool),this.queue=h(this.queue)}set profiles(t){const e=this._get("profiles"),i=null!=t?t:new s;this._set("profiles",l(i,e))}get state(){const t=this.view;return c(t)&&t.ready?this.tool.state:T.Disabled}get progress(){let t=0,e=0;for(const i of this.visibleProfiles)t++,e+=i.progress;return t>0?e/t:0}set unitOptions(t){this._userUnitOptions=t,this._set("unitOptions",this._filteredOrAllUnits(this._userUnitOptions))}get unitOptions(){return this._filteredOrAllUnits(this._userUnitOptions)}set unit(t){this._userUnit=t?this._findSelectableUnit(t,this._userUnit):null,this.notifyChange("unit")}get unit(){return this._userUnit?(this._userUnit=this._findSelectableUnit(this._userUnit,this.defaultUnit),this._userUnit):this._findSelectableUnit(this.defaultUnit)}get effectiveUnits(){const t=V(this.visibleProfiles.map((t=>t.result))),e=y(t.maxDistance,"meters",this.unit),i=g(t.maxElevation,"meters",this.unit);return this._getEffectiveUnitsMemoized(e,i)}get hasVertices(){const t=d(this.input,(t=>t.geometry));return G(t)&&t.paths.reduce(((t,e)=>t+e.length),0)>0}get hoveredPoints(){return!u(this.input)&&this.visible&&this.tool.editable?this.visibleProfiles.map((t=>{const e=t.hoveredPoint;return c(e)?{hoveredPoint:e,color:t.color}:null})).filter(c):[]}get statistics(){return z(this.visibleProfiles.map((t=>t.statistics)))}get chartData(){if(u(this.input))return null;const{effectiveUnits:t,progress:e,statistics:i,visibleProfiles:o,uniformChartScaling:r}=this,s=o.filter((t=>t.hasZ)).map((t=>({id:t.id,type:t.type,title:t.title,color:t.color,samples:t.samples,progress:t.progress,chartFillEnabled:t.chartFillEnabled,chartStrokeWidth:t.chartStrokeWidth,chartStrokeOffsetY:t.chartStrokeOffsetY,viewVisualizationEnabled:t.viewVisualizationEnabled})));return 0===s.length?null:{lines:s,effectiveUnits:t,statistics:i,refined:1===e,dynamicElevationRange:o.some((t=>"view"===t.type)),uniformScaling:r}}get visibleProfiles(){return this.profiles.toArray().filter((t=>t.available&&t.visible))}get minDemResolutions(){const t=[];for(const{minDemResolution:e}of this.visibleProfiles)c(e)&&t.push(e);return t}get minDemResolution(){return o(this.minDemResolutions)}get errorState(){const t=d(this.input,(t=>t.geometry));if(!I(t))return D.NoValidInput;if(c(this.error)){if(L(this.error))switch(this.error.cause){case k.TooComplex:return D.TooComplex;case k.InvalidGeometry:return D.InvalidGeometry;case k.InvalidElevationInfo:return D.InvalidElevationInfo;case k.ElevationQueryError:return D.NoValidInput}return D.UnknownError}return 0===this.visibleProfiles.length?D.NoVisibleProfiles:u(this.chartData)&&1===this.progress?D.RefinedButNoChartData:D.None}get tileCache(){this._currentTileCache=h(this._currentTileCache);const t=this.view;if(c(t)&&"3d"===(null==t?void 0:t.type)){var e;const i=null==(e=t.basemapTerrain)?void 0:e.elevationQueryCache;if(c(i))return i}return u(this._currentTileCache)&&(this._currentTileCache=new j(new p(20*r.MEGABYTES))),this._currentTileCache}get inputIsSketched(){return this.tool.interaction.isSketchedGraphic(this.input)}get elevationProvider(){const t=this.view;return c(t)&&"3d"===t.type?t.elevationProvider:null}start(t){this.tool.interaction.start(t)}stop(){this.tool.interaction.stop()}cancel(){this.tool.interaction.cancel()}clear(){this.tool.interaction.clear()}_findSelectableUnit(t,e){const i=this.unitOptions;return c(t)&&i.includes(t)?t:e?this._findSelectableUnit(e):i[0]}_filteredOrAllUnits(t){const e=(c(t)?t:[]).filter((t=>_.includes(t)));return 0===e.length?_.slice():e}};t([b()],N.prototype,"view",void 0),t([b({type:e})],N.prototype,"input",void 0),t([b({type:O,nonNullable:!0})],N.prototype,"profiles",null),t([b({readOnly:!0})],N.prototype,"state",null),t([b({readOnly:!0})],N.prototype,"progress",null),t([b()],N.prototype,"unitOptions",null),t([b()],N.prototype,"unit",null),t([b({readOnly:!0})],N.prototype,"effectiveUnits",null),t([b({type:Number})],N.prototype,"geodesicDistanceThreshold",void 0),t([b()],N.prototype,"hoveredChartPosition",void 0),t([b()],N.prototype,"uniformChartScaling",void 0),t([U("tool.highlightEnabled")],N.prototype,"highlightEnabled",void 0),t([b({readOnly:!0})],N.prototype,"hoveredPoints",null),t([b({readOnly:!0})],N.prototype,"statistics",null),t([b()],N.prototype,"chartData",null),t([b()],N.prototype,"visibleProfiles",null),t([b()],N.prototype,"minDemResolutions",null),t([b({readOnly:!0})],N.prototype,"minDemResolution",null),t([b({readOnly:!0})],N.prototype,"errorState",null),t([b(w)],N.prototype,"defaultUnit",void 0),t([b()],N.prototype,"queue",void 0),t([b()],N.prototype,"tileCache",null),t([b()],N.prototype,"tool",void 0),t([U("tool.visible")],N.prototype,"visible",void 0),t([b()],N.prototype,"error",void 0),t([b()],N.prototype,"inputIsSketched",null),t([b()],N.prototype,"elevationProvider",null),t([b()],N.prototype,"_defaultProfileLineGround",void 0),t([b()],N.prototype,"_userUnitOptions",void 0),t([b()],N.prototype,"_controller",void 0),t([b()],N.prototype,"_userUnit",void 0),N=t([P("esri.widgets.ElevationProfile.ElevationProfileViewModel")],N);const x=N;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/4.24/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{eventKey as t}from"../../core/events.js";import{init as i}from"../../core/watchUtils.js";import{aliasOf as r}from"../../core/accessorSupport/decorators/aliasOf.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import s from"../Widget.js";import n from"./FeatureMedia/FeatureMediaViewModel.js";import l from"./support/FeatureElementInfo.js";import{shouldOpenInNewTab as d}from"./support/featureUtils.js";import{loadChartsModule as c,getColorSet as m}from"../support/chartUtils.js";import{isRTL as u}from"../support/widgetUtils.js";import{messageBundle as h}from"../support/decorators/messageBundle.js";import"../../core/Logger.js";import{tsx as p}from"../support/jsxFactory.js";import{isDarkTheme as f}from"../support/widgetThemeUtils.js";const v={base:"esri-feature-media",mediaContainer:"esri-feature-media__container",mediaItemContainer:"esri-feature-media__item-container",mediaItem:"esri-feature-media__item",mediaItemTitle:"esri-feature-media__item-title",mediaItemCaption:"esri-feature-media__item-caption",mediaPrevious:"esri-feature-media__previous",mediaPreviousIconLTR:"esri-feature-media__previous-icon",mediaPreviousIconRTL:"esri-feature-media__previous-icon--rtl",mediaNext:"esri-feature-media__next",mediaNextIconLTR:"esri-feature-media__next-icon",mediaNextIconRTL:"esri-feature-media__next-icon--rtl",mediaChart:"esri-feature-media__chart",mediaButton:"esri-feature-media__button",mediaIcon:"esri-feature-media__icon",iconLeftTriangleArrow:"esri-icon-left-triangle-arrow",iconRightTriangleArrow:"esri-icon-right-triangle-arrow"},_=.05,I=.95,M=15;let w=class extends s{constructor(e,t){super(e,t),this._refreshTimer=null,this._refreshIntervalInfo=null,this._featureElementInfo=null,this.attributes=null,this.activeMediaInfoIndex=null,this.description=null,this.fieldInfoMap=null,this.layer=null,this.mediaInfos=null,this.popupTemplate=null,this.relatedInfos=null,this.title=null,this.viewModel=new n,this.messages=null,this._getChartDependencies=async e=>{const t=await c(),{destroyed:i,viewModel:r}=this;if(i||!r||!e)return;const{activeMediaInfo:a}=r;this._renderChart({chartDiv:e,mediaInfo:a,chartsModule:t})}}initialize(){this._featureElementInfo=new l,this.own(i(this,["viewModel.activeMediaInfo","viewModel.activeMediaInfoIndex"],(()=>this._setupMediaRefreshTimer())),i(this,["viewModel.description","viewModel.title"],(()=>this._setupFeatureElementInfo())))}destroy(){this._clearMediaRefreshTimer(),this._featureElementInfo.destroy()}render(){var e;return p("div",{bind:this,class:v.base,onkeyup:this._handleMediaKeyup},null==(e=this._featureElementInfo)?void 0:e.render(),this.renderMedia())}renderMedia(){const{formattedMediaInfoCount:e}=this.viewModel;return e?p("div",{key:"media-element-container",class:v.mediaContainer},this.renderMediaPageButton("previous"),this.renderMediaInfo(),this.renderMediaPageButton("next")):null}renderImageMediaInfo(e){const{_refreshIntervalInfo:t}=this,{activeMediaInfoIndex:i,formattedMediaInfoCount:r}=this.viewModel,{value:a,refreshInterval:o,altText:s,title:n,type:l}=e,{sourceURL:c,linkURL:m}=a,u=d(m)?"_blank":"_self",h="_blank"===u?"noreferrer":"",f=o?t:null,v=f?f.timestamp:0,_=f?f.sourceURL:c,I=p("img",{alt:s||n,key:`media-${l}-${i}-${r}-${v}`,src:_}),M=m?p("a",{title:n,href:m,rel:h,target:u},I):null;return M||I}renderChartMediaInfo(e){const{activeMediaInfoIndex:t,formattedMediaInfoCount:i}=this.viewModel;return p("div",{key:`media-${e.type}-${t}-${i}`,bind:this,class:v.mediaChart,afterCreate:this._getChartDependencies})}renderMediaInfoType(){const{activeMediaInfo:e}=this.viewModel;return e?"image"===e.type?this.renderImageMediaInfo(e):-1!==e.type.indexOf("chart")?this.renderChartMediaInfo(e):null:null}renderMediaInfo(){const{activeMediaInfo:e}=this.viewModel;if(!e)return null;const t=e.title?p("div",{key:"media-title",class:v.mediaItemTitle,innerHTML:e.title}):null,i=e.caption?p("div",{key:"media-caption",class:v.mediaItemCaption,innerHTML:e.caption}):null;return p("div",{key:"media-container",class:v.mediaItemContainer},p("div",{key:"media-item-container",class:v.mediaItem},this.renderMediaInfoType()),t,i)}renderMediaPageButton(e){if(this.viewModel.formattedMediaInfoCount<2)return null;const t="previous"===e,i=t?this.messages.previous:this.messages.next,r=t?this.classes(v.mediaButton,v.mediaPrevious):this.classes(v.mediaButton,v.mediaNext),a=t?this.classes(v.mediaIcon,v.mediaPreviousIconLTR,v.iconLeftTriangleArrow):this.classes(v.mediaIcon,v.mediaNextIconLTR,v.iconRightTriangleArrow),o=t?this.classes(v.mediaIcon,v.mediaPreviousIconRTL,v.iconRightTriangleArrow):this.classes(v.mediaIcon,v.mediaNextIconRTL,v.iconLeftTriangleArrow),s=t?"media-previous":"media-next",n=t?this._previous:this._next;return p("button",{type:"button",key:s,title:i,"aria-label":i,tabIndex:0,class:r,bind:this,onclick:n},p("span",{"aria-hidden":"true",class:a}),p("span",{"aria-hidden":"true",class:o}))}_setupFeatureElementInfo(){const{description:e,title:t}=this;this._featureElementInfo.set({description:e,title:t})}_next(){this.viewModel.next()}_previous(){this.viewModel.previous()}_handleMediaKeyup(e){const i=t(e);"ArrowLeft"===i&&(e.stopPropagation(),this.viewModel.previous()),"ArrowRight"===i&&(e.stopPropagation(),this.viewModel.next())}_renderChart(e){const{abilities:t}=this.viewModel,{chartsModule:i,chartDiv:r,mediaInfo:a}=e,{value:o,type:s}=a,{am4core:n}=i,l=m(n);function d(e){e instanceof n.ColorSet&&l&&(e.list=l)}f()&&n.useTheme(i.am4themes_dark);const c=window.matchMedia("(prefers-reduced-motion: reduce)");t.chartAnimation&&!c.matches?n.useTheme(i.am4themes_animated):n.unuseTheme(i.am4themes_animated),n.useTheme(d);const u="pie-chart"===s?this._createPieChart(e):this._createXYChart(e);r.setAttribute("aria-label",a.altText||a.title),u.data=o.series.map((e=>({tooltip:e.tooltip,value:e.value}))).filter((e=>"pie-chart"!==s||e.value>0))}_customizeChartTooltip(e,t){e.label.wrap=!0,e.label.maxWidth=200,e.autoTextColor=!1,e.getFillFromObject=!1,e.label.fill=t.color("#ffffff"),e.background.fill=t.color({r:0,g:0,b:0,a:.7})}_createPieChart(e){const{chartDiv:t,chartsModule:i}=e,{am4core:r,am4charts:a}=i,o=r.create(t,a.PieChart);o.rtl=u(this.container);const s=o.series.push(new a.PieSeries);return s.labels.template.disabled=!0,s.ticks.template.disabled=!0,s.dataFields.value="value",s.dataFields.category="tooltip",this._customizeChartTooltip(s.tooltip,r),s.slices.template.tooltipText=o.rtl?"{category}: %{value.percent.formatNumber('#.0')}":"{category}: {value.percent.formatNumber('#.0')}%",o}_getMinSeriesValue(e){let t=0;return e.forEach((e=>t=Math.min(e.value,t))),t}_createColumnChart(e,t){const{chartsModule:i,mediaInfo:r}=t,{value:a}=r,{am4core:o,am4charts:s}=i,n=e.xAxes.push(new s.CategoryAxis);n.dataFields.category="tooltip",n.renderer.labels.template.disabled=!0,this._customizeChartTooltip(n.tooltip,o),n.tooltip.events.on("sizechanged",(()=>{n.tooltip.dy=-n.tooltip.contentHeight}));const l=e.yAxes.push(new s.ValueAxis),d=l.renderer.labels.template;l.renderer.minLabelPosition=_,l.renderer.maxLabelPosition=I,l.min=this._getMinSeriesValue(a.series),this._customizeChartTooltip(l.tooltip,o),d.wrap=!0;const c=e.series.push(new s.ColumnSeries);c.dataFields.valueY="value",c.dataFields.categoryX="tooltip",e.cursor=new s.XYCursor,a.series.length>M&&(e.scrollbarX=new o.Scrollbar)}_createBarChart(e,t){const{chartsModule:i,mediaInfo:r}=t,{value:a}=r,{am4core:o,am4charts:s}=i,n=e.yAxes.push(new s.CategoryAxis);n.dataFields.category="tooltip",n.renderer.inversed=!0,n.renderer.labels.template.disabled=!0,this._customizeChartTooltip(n.tooltip,o),n.tooltip.events.on("sizechanged",(()=>{n.tooltip.dx=n.tooltip.contentWidth}));const l=e.xAxes.push(new s.ValueAxis),d=l.renderer.labels.template;l.renderer.minLabelPosition=_,l.renderer.maxLabelPosition=I,l.min=this._getMinSeriesValue(a.series),this._customizeChartTooltip(l.tooltip,o),d.wrap=!0;const c=e.series.push(new s.ColumnSeries);c.dataFields.valueX="value",c.dataFields.categoryY="tooltip",e.cursor=new s.XYCursor,a.series.length>M&&(e.scrollbarY=new o.Scrollbar)}_createLineChart(e,t){const{chartsModule:i,mediaInfo:r}=t,{value:a}=r,{am4core:o,am4charts:s}=i,n=e.xAxes.push(new s.CategoryAxis);n.dataFields.category="tooltip",n.renderer.labels.template.disabled=!0,this._customizeChartTooltip(n.tooltip,o),n.tooltip.events.on("sizechanged",(()=>{n.tooltip.dy=-n.tooltip.contentHeight}));const l=e.yAxes.push(new s.ValueAxis),d=l.renderer.labels.template;l.renderer.minLabelPosition=_,l.renderer.maxLabelPosition=I,l.min=this._getMinSeriesValue(a.series),this._customizeChartTooltip(l.tooltip,o),d.wrap=!0;const c=e.series.push(new s.LineSeries);c.dataFields.categoryX="tooltip",c.dataFields.valueY="value",e.cursor=new s.XYCursor,a.series.length>M&&(e.scrollbarX=new o.Scrollbar)}_createXYChart(e){const{chartDiv:t,chartsModule:i,mediaInfo:r}=e,{type:a}=r,{am4core:o,am4charts:s}=i,n=o.create(t,s.XYChart);return n.rtl=u(this.container),"column-chart"===a&&this._createColumnChart(n,e),"bar-chart"===a&&this._createBarChart(n,e),"line-chart"===a&&this._createLineChart(n,e),n}_clearMediaRefreshTimer(){const{_refreshTimer:e}=this;e&&(clearTimeout(e),this._refreshTimer=null)}_updateMediaInfoTimestamp(e){const t=Date.now();this._refreshIntervalInfo={timestamp:t,sourceURL:this._getImageSource(e,t)},this.scheduleRender()}_setupMediaRefreshTimer(){this._clearMediaRefreshTimer();const{activeMediaInfo:e}=this.viewModel;e&&"image"===e.type&&e.refreshInterval&&this._setRefreshTimeout(e)}_setRefreshTimeout(e){const{refreshInterval:t,value:i}=e;if(!t)return;const r=6e4*t;this._updateMediaInfoTimestamp(i.sourceURL);const a=setInterval((()=>{this._updateMediaInfoTimestamp(i.sourceURL)}),r);this._refreshTimer=a}_getImageSource(e,t){const i=-1!==e.indexOf("?")?"&":"?",[r,a=""]=e.split("#");return`${r}${i}timestamp=${t}${a?"#":""}${a}`}};e([r("viewModel.attributes")],w.prototype,"attributes",void 0),e([r("viewModel.activeMediaInfoIndex")],w.prototype,"activeMediaInfoIndex",void 0),e([r("viewModel.description")],w.prototype,"description",void 0),e([r("viewModel.fieldInfoMap")],w.prototype,"fieldInfoMap",void 0),e([r("viewModel.layer")],w.prototype,"layer",void 0),e([r("viewModel.mediaInfos")],w.prototype,"mediaInfos",void 0),e([r("viewModel.popupTemplate")],w.prototype,"popupTemplate",void 0),e([r("viewModel.relatedInfos")],w.prototype,"relatedInfos",void 0),e([r("viewModel.title")],w.prototype,"title",void 0),e([a({type:n})],w.prototype,"viewModel",void 0),e([a(),h("esri/widgets/Feature/t9n/Feature")],w.prototype,"messages",void 0),w=e([o("esri.widgets.Feature.FeatureMedia")],w);const g=w;export{g as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{eventKey as t}from"../../core/events.js";import{init as i}from"../../core/watchUtils.js";import{aliasOf as r}from"../../core/accessorSupport/decorators/aliasOf.js";import"../../core/arrayUtils.js";import"../../core/has.js";import"../../core/accessorSupport/ensureType.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import s from"../Widget.js";import n from"./FeatureMedia/FeatureMediaViewModel.js";import l from"./support/FeatureElementInfo.js";import{shouldOpenInNewTab as d}from"./support/featureUtils.js";import{loadChartsModule as c,getColorSet as m}from"../support/chartUtils.js";import{isRTL as u}from"../support/widgetUtils.js";import{messageBundle as h}from"../support/decorators/messageBundle.js";import"../../core/Logger.js";import{tsx as p}from"../support/jsxFactory.js";import{isDarkTheme as f}from"../support/widgetThemeUtils.js";const v={base:"esri-feature-media",mediaContainer:"esri-feature-media__container",mediaItemContainer:"esri-feature-media__item-container",mediaItem:"esri-feature-media__item",mediaItemTitle:"esri-feature-media__item-title",mediaItemCaption:"esri-feature-media__item-caption",mediaPrevious:"esri-feature-media__previous",mediaPreviousIconLTR:"esri-feature-media__previous-icon",mediaPreviousIconRTL:"esri-feature-media__previous-icon--rtl",mediaNext:"esri-feature-media__next",mediaNextIconLTR:"esri-feature-media__next-icon",mediaNextIconRTL:"esri-feature-media__next-icon--rtl",mediaChart:"esri-feature-media__chart",mediaButton:"esri-feature-media__button",mediaIcon:"esri-feature-media__icon",iconLeftTriangleArrow:"esri-icon-left-triangle-arrow",iconRightTriangleArrow:"esri-icon-right-triangle-arrow"},_=.05,I=.95,M=15;let w=class extends s{constructor(e,t){super(e,t),this._refreshTimer=null,this._refreshIntervalInfo=null,this._featureElementInfo=null,this.attributes=null,this.activeMediaInfoIndex=null,this.description=null,this.fieldInfoMap=null,this.layer=null,this.mediaInfos=null,this.popupTemplate=null,this.relatedInfos=null,this.title=null,this.viewModel=new n,this.messages=null,this._getChartDependencies=async e=>{const t=await c(),{destroyed:i,viewModel:r}=this;if(i||!r||!e)return;const{activeMediaInfo:a}=r;this._renderChart({chartDiv:e,mediaInfo:a,chartsModule:t})}}initialize(){this._featureElementInfo=new l,this.own(i(this,["viewModel.activeMediaInfo","viewModel.activeMediaInfoIndex"],(()=>this._setupMediaRefreshTimer())),i(this,["viewModel.description","viewModel.title"],(()=>this._setupFeatureElementInfo())))}destroy(){this._clearMediaRefreshTimer(),this._featureElementInfo.destroy()}render(){var e;return p("div",{bind:this,class:v.base,onkeyup:this._handleMediaKeyup},null==(e=this._featureElementInfo)?void 0:e.render(),this.renderMedia())}renderMedia(){const{formattedMediaInfoCount:e}=this.viewModel;return e?p("div",{key:"media-element-container",class:v.mediaContainer},this.renderMediaPageButton("previous"),this.renderMediaInfo(),this.renderMediaPageButton("next")):null}renderImageMediaInfo(e){const{_refreshIntervalInfo:t}=this,{activeMediaInfoIndex:i,formattedMediaInfoCount:r}=this.viewModel,{value:a,refreshInterval:o,altText:s,title:n,type:l}=e,{sourceURL:c,linkURL:m}=a,u=d(m)?"_blank":"_self",h="_blank"===u?"noreferrer":"",f=o?t:null,v=f?f.timestamp:0,_=f?f.sourceURL:c,I=p("img",{alt:s||n,key:`media-${l}-${i}-${r}-${v}`,src:_}),M=m?p("a",{title:n,href:m,rel:h,target:u},I):null;return M||I}renderChartMediaInfo(e){const{activeMediaInfoIndex:t,formattedMediaInfoCount:i}=this.viewModel;return p("div",{key:`media-${e.type}-${t}-${i}`,bind:this,class:v.mediaChart,afterCreate:this._getChartDependencies})}renderMediaInfoType(){const{activeMediaInfo:e}=this.viewModel;return e?"image"===e.type?this.renderImageMediaInfo(e):e.type.includes("chart")?this.renderChartMediaInfo(e):null:null}renderMediaInfo(){const{activeMediaInfo:e}=this.viewModel;if(!e)return null;const t=e.title?p("div",{key:"media-title",class:v.mediaItemTitle,innerHTML:e.title}):null,i=e.caption?p("div",{key:"media-caption",class:v.mediaItemCaption,innerHTML:e.caption}):null;return p("div",{key:"media-container",class:v.mediaItemContainer},p("div",{key:"media-item-container",class:v.mediaItem},this.renderMediaInfoType()),t,i)}renderMediaPageButton(e){if(this.viewModel.formattedMediaInfoCount<2)return null;const t="previous"===e,i=t?this.messages.previous:this.messages.next,r=t?this.classes(v.mediaButton,v.mediaPrevious):this.classes(v.mediaButton,v.mediaNext),a=t?this.classes(v.mediaIcon,v.mediaPreviousIconLTR,v.iconLeftTriangleArrow):this.classes(v.mediaIcon,v.mediaNextIconLTR,v.iconRightTriangleArrow),o=t?this.classes(v.mediaIcon,v.mediaPreviousIconRTL,v.iconRightTriangleArrow):this.classes(v.mediaIcon,v.mediaNextIconRTL,v.iconLeftTriangleArrow),s=t?"media-previous":"media-next",n=t?this._previous:this._next;return p("button",{type:"button",key:s,title:i,"aria-label":i,tabIndex:0,class:r,bind:this,onclick:n},p("span",{"aria-hidden":"true",class:a}),p("span",{"aria-hidden":"true",class:o}))}_setupFeatureElementInfo(){const{description:e,title:t}=this;this._featureElementInfo.set({description:e,title:t})}_next(){this.viewModel.next()}_previous(){this.viewModel.previous()}_handleMediaKeyup(e){const i=t(e);"ArrowLeft"===i&&(e.stopPropagation(),this.viewModel.previous()),"ArrowRight"===i&&(e.stopPropagation(),this.viewModel.next())}_renderChart(e){const{abilities:t}=this.viewModel,{chartsModule:i,chartDiv:r,mediaInfo:a}=e,{value:o,type:s}=a,{am4core:n}=i,l=m(n);function d(e){e instanceof n.ColorSet&&l&&(e.list=l)}f()&&n.useTheme(i.am4themes_dark);const c=window.matchMedia("(prefers-reduced-motion: reduce)");t.chartAnimation&&!c.matches?n.useTheme(i.am4themes_animated):n.unuseTheme(i.am4themes_animated),n.useTheme(d);const u="pie-chart"===s?this._createPieChart(e):this._createXYChart(e);r.setAttribute("aria-label",a.altText||a.title),u.data=o.series.map((e=>({tooltip:e.tooltip,value:e.value}))).filter((e=>"pie-chart"!==s||e.value>0))}_customizeChartTooltip(e,t){e.label.wrap=!0,e.label.maxWidth=200,e.autoTextColor=!1,e.getFillFromObject=!1,e.label.fill=t.color("#ffffff"),e.background.fill=t.color({r:0,g:0,b:0,a:.7})}_createPieChart(e){const{chartDiv:t,chartsModule:i}=e,{am4core:r,am4charts:a}=i,o=r.create(t,a.PieChart);o.rtl=u(this.container);const s=o.series.push(new a.PieSeries);return s.labels.template.disabled=!0,s.ticks.template.disabled=!0,s.dataFields.value="value",s.dataFields.category="tooltip",this._customizeChartTooltip(s.tooltip,r),s.slices.template.tooltipText=o.rtl?"{category}: %{value.percent.formatNumber('#.0')}":"{category}: {value.percent.formatNumber('#.0')}%",o}_getMinSeriesValue(e){let t=0;return e.forEach((e=>t=Math.min(e.value,t))),t}_createColumnChart(e,t){const{chartsModule:i,mediaInfo:r}=t,{value:a}=r,{am4core:o,am4charts:s}=i,n=e.xAxes.push(new s.CategoryAxis);n.dataFields.category="tooltip",n.renderer.labels.template.disabled=!0,this._customizeChartTooltip(n.tooltip,o),n.tooltip.events.on("sizechanged",(()=>{n.tooltip.dy=-n.tooltip.contentHeight}));const l=e.yAxes.push(new s.ValueAxis),d=l.renderer.labels.template;l.renderer.minLabelPosition=_,l.renderer.maxLabelPosition=I,l.min=this._getMinSeriesValue(a.series),this._customizeChartTooltip(l.tooltip,o),d.wrap=!0;const c=e.series.push(new s.ColumnSeries);c.dataFields.valueY="value",c.dataFields.categoryX="tooltip",e.cursor=new s.XYCursor,a.series.length>M&&(e.scrollbarX=new o.Scrollbar)}_createBarChart(e,t){const{chartsModule:i,mediaInfo:r}=t,{value:a}=r,{am4core:o,am4charts:s}=i,n=e.yAxes.push(new s.CategoryAxis);n.dataFields.category="tooltip",n.renderer.inversed=!0,n.renderer.labels.template.disabled=!0,this._customizeChartTooltip(n.tooltip,o),n.tooltip.events.on("sizechanged",(()=>{n.tooltip.dx=n.tooltip.contentWidth}));const l=e.xAxes.push(new s.ValueAxis),d=l.renderer.labels.template;l.renderer.minLabelPosition=_,l.renderer.maxLabelPosition=I,l.min=this._getMinSeriesValue(a.series),this._customizeChartTooltip(l.tooltip,o),d.wrap=!0;const c=e.series.push(new s.ColumnSeries);c.dataFields.valueX="value",c.dataFields.categoryY="tooltip",e.cursor=new s.XYCursor,a.series.length>M&&(e.scrollbarY=new o.Scrollbar)}_createLineChart(e,t){const{chartsModule:i,mediaInfo:r}=t,{value:a}=r,{am4core:o,am4charts:s}=i,n=e.xAxes.push(new s.CategoryAxis);n.dataFields.category="tooltip",n.renderer.labels.template.disabled=!0,this._customizeChartTooltip(n.tooltip,o),n.tooltip.events.on("sizechanged",(()=>{n.tooltip.dy=-n.tooltip.contentHeight}));const l=e.yAxes.push(new s.ValueAxis),d=l.renderer.labels.template;l.renderer.minLabelPosition=_,l.renderer.maxLabelPosition=I,l.min=this._getMinSeriesValue(a.series),this._customizeChartTooltip(l.tooltip,o),d.wrap=!0;const c=e.series.push(new s.LineSeries);c.dataFields.categoryX="tooltip",c.dataFields.valueY="value",e.cursor=new s.XYCursor,a.series.length>M&&(e.scrollbarX=new o.Scrollbar)}_createXYChart(e){const{chartDiv:t,chartsModule:i,mediaInfo:r}=e,{type:a}=r,{am4core:o,am4charts:s}=i,n=o.create(t,s.XYChart);return n.rtl=u(this.container),"column-chart"===a&&this._createColumnChart(n,e),"bar-chart"===a&&this._createBarChart(n,e),"line-chart"===a&&this._createLineChart(n,e),n}_clearMediaRefreshTimer(){const{_refreshTimer:e}=this;e&&(clearTimeout(e),this._refreshTimer=null)}_updateMediaInfoTimestamp(e){const t=Date.now();this._refreshIntervalInfo={timestamp:t,sourceURL:this._getImageSource(e,t)},this.scheduleRender()}_setupMediaRefreshTimer(){this._clearMediaRefreshTimer();const{activeMediaInfo:e}=this.viewModel;e&&"image"===e.type&&e.refreshInterval&&this._setRefreshTimeout(e)}_setRefreshTimeout(e){const{refreshInterval:t,value:i}=e;if(!t)return;const r=6e4*t;this._updateMediaInfoTimestamp(i.sourceURL);const a=setInterval((()=>{this._updateMediaInfoTimestamp(i.sourceURL)}),r);this._refreshTimer=a}_getImageSource(e,t){const i=e.includes("?")?"&":"?",[r,a=""]=e.split("#");return`${r}${i}timestamp=${t}${a?"#":""}${a}`}};e([r("viewModel.attributes")],w.prototype,"attributes",void 0),e([r("viewModel.activeMediaInfoIndex")],w.prototype,"activeMediaInfoIndex",void 0),e([r("viewModel.description")],w.prototype,"description",void 0),e([r("viewModel.fieldInfoMap")],w.prototype,"fieldInfoMap",void 0),e([r("viewModel.layer")],w.prototype,"layer",void 0),e([r("viewModel.mediaInfos")],w.prototype,"mediaInfos",void 0),e([r("viewModel.popupTemplate")],w.prototype,"popupTemplate",void 0),e([r("viewModel.relatedInfos")],w.prototype,"relatedInfos",void 0),e([r("viewModel.title")],w.prototype,"title",void 0),e([a({type:n})],w.prototype,"viewModel",void 0),e([a(),h("esri/widgets/Feature/t9n/Feature")],w.prototype,"messages",void 0),w=e([o("esri.widgets.Feature.FeatureMedia")],w);const g=w;export{g as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.24/esri/copyright.txt for details.
4
4
  */
5
- import"../../../intl.js";import e from"../../../core/Logger.js";import{isNone as t,isSome as r}from"../../../core/maybe.js";import{replace as n}from"../../../core/string.js";import{formatDate as i,convertDateFormatToIntlOptions as o}from"../../../intl/date.js";import{formatNumber as a,convertNumberFormatToIntlOptions as u}from"../../../intl/number.js";import{featureHasFields as l}from"../../../layers/support/fieldUtils.js";import s from"../../../popup/support/FieldInfoFormat.js";import{loadArcade as f}from"../../../support/arcadeOnDemand.js";const c="esri.widgets.Feature.support.featureUtils",d=e.getLogger(c),p=/href=(""|'')/gi,m=/(\{([^\{\r\n]+)\})/g,y=/\'/g,g=/^\s*expression\//i,h=/(\n)/gi,b=/[\u00A0-\u9999<>\&]/gim,F=/href\s*=\s*(?:\"([^\"]+)\"|\'([^\']+)\')/gi,I=/^(?:mailto:|tel:)/,w="relationships/",N=o("short-date-short-time");function x(e){if(!t(e))return e.get("sourceLayer")||e.get("layer")}async function E(e,t){return"function"==typeof e?e.call(null,t):e}function v(e=""){if(e)return!I.test(e.trim().toLowerCase())}function j(e){return!!e&&g.test(e)}function T(e,t){if(!j(t)||!e)return null;const r=t.replace(g,"").toLowerCase();let n;return e.some((e=>e.name.toLowerCase()===r&&(n=e,!0))),n}function C(e,t){const r=T(t,null==e?void 0:e.fieldName);return r?r.title||null:e?e.label||e.fieldName:null}function q(e,t){const r=t.get(e.toLowerCase());return`{${r&&r.fieldName||e}}`}function D(e){return e.replace(p,"")}function R(e,t){const r=M(t,e);return r?r.name:e}function L(e,t){return e&&e.map((e=>R(e,t)))}function M(e,t){return e&&"function"==typeof e.getField?e.getField(t):null}function U(e){return`${e}`.trim()}function $({attributes:e,globalAttributes:t,layer:r,text:n,expressionAttributes:i,fieldInfoMap:o}){return n?A({formattedAttributes:t,template:P(n,{...t,...i,...e},r),fieldInfoMap:o}):""}function A({formattedAttributes:e,template:t,fieldInfoMap:r}){return U(D(n(n(t,(e=>q(e,r))),e)))}function O(e,t,r=!1){const n=t[e];if("string"==typeof n){const i="%27",o=(r?encodeURIComponent(n):n).replace(y,i);t[e]=o}}function S(e,t=!1){const r={...e};return Object.keys(r).forEach((e=>O(e,r,t))),r}function G(e,t,r){const i=(t=U(t))&&"{"!==t[0];return n(e,S(r,i))}function k(e,t){return e.replace(m,((e,r,n)=>{const i=M(t,n);return i?`{${i.name}}`:r}))}function P(e,t,r){const n=k(e,r);return n?n.replace(F,((e,r,n)=>G(e,r||n,t))):n}function _(e,t){if("string"==typeof e&&t&&null==t.dateFormat&&(null!=t.places||null!=t.digitSeparator)){const t=Number(e);if(!isNaN(t))return t}return e}function z(e){return"feature"===(null==e?void 0:e.type)}function H(e){return!(null==e||!e.layer)}function Q(e){return"map-image"===(null==e?void 0:e.type)}function Z(e,t){const r=t.fieldInfos,n=t.fieldName,i=B(r,n),o=null==i?void 0:i.clone(),l=t.preventPlacesFormatting,f=t.layer,c=M(f,n);if(o&&"date"===(null==c?void 0:c.type)){const e=o.format||new s;e.dateFormat=e.dateFormat||"short-date-short-time",e.dateTimeFormatOptions=!H(f)&&z(f)&&f.datesInUnknownTimezone||H(f)&&Q(f.layer)&&f.layer.datesInUnknownTimezone?{timeZone:"UTC"}:null,o.format=e}const d=o&&o.format;return"string"==typeof(e=_(e,d))||null==e||null==d?ee(e):l?a(e,{...u(d),minimumFractionDigits:0,maximumFractionDigits:20}):d.format(e)}function B(e,t){if(!e||!e.length||!t)return;const r=t.toLowerCase();let n;return e.some((e=>!(!e.fieldName||e.fieldName.toLowerCase()!==r)&&(n=e,!0))),n}function J({fieldName:e,graphic:t,layer:r}){if(ae(e))return null;if(!r||"function"!=typeof r.getFeatureType)return null;const{typeIdField:n}=r;if(!n||e!==n)return null;const i=r.getFeatureType(t);return i?i.name:null}function K({fieldName:e,value:t,graphic:r,layer:n}){if(ae(e))return null;if(!n||"function"!=typeof n.getFieldDomain)return null;const i=n.getFieldDomain(e,{feature:r});return i&&"coded-value"===i.type?i.getName(t):null}function V(e,t){const{creatorField:r,creationDateField:n,editorField:o,editDateField:a}=e;if(!t)return;const u=t[a];if("number"==typeof u){const e=t[o];return{type:"edit",date:i(u,N),user:e}}const l=t[n];if("number"==typeof l){const e=t[r];return{type:"create",date:i(l,N),user:e}}return null}function W(e,t){const r=new Map;return e&&e.forEach((e=>{const n=R(e.fieldName,t);e.fieldName=n,r.set(n.toLowerCase(),e)})),r}function X(e){const t=[];if(!e)return t;const{fieldInfos:r,content:n}=e;return r&&t.push(...r),n&&Array.isArray(n)?(n.forEach((e=>{if("fields"===e.type){const r=e&&e.fieldInfos;r&&t.push(...r)}})),t):t}function Y(e){return e.replace(b,(e=>`&#${e.charCodeAt(0)};`))}function ee(e){return"string"==typeof e?e.replace(h,'<br class="esri-text-new-line" />'):e}function te(e){const{value:t,fieldName:r,fieldInfos:n,fieldInfoMap:o,layer:a,graphic:u}=e;if(null==t)return"";const l=K({fieldName:r,value:t,graphic:u,layer:a});if(l)return l;const s=J({fieldName:r,graphic:u,layer:a});if(s)return s;if(o.get(r.toLowerCase()))return Z(t,{fieldInfos:n,fieldName:r,layer:a});const f=a&&a.fieldsIndex;return f&&f.isDateField(r)?i(t,N):ee(t)}function re({fieldInfos:e,attributes:t,layer:r,graphic:n,fieldInfoMap:i,relatedInfos:o}){const a={};return null==o||o.forEach((e=>se(a,e))),Object.keys(t).forEach((o=>{const u=t[o];a[o]=te({fieldName:o,fieldInfos:e,fieldInfoMap:i,layer:r,value:u,graphic:n})})),a}async function ne(e,t){var r,n;const{layer:i,graphic:o,outFields:a,objectIds:u,returnGeometry:l,spatialReference:s}=e,f=u[0];if("number"!=typeof f&&"string"!=typeof f){const e="Could not query required fields for the specified feature. The feature's ID is invalid.",t={layer:i,graphic:o,objectId:f,requiredFields:a};return d.warn(e,t),null}if(null==(r=i.capabilities)||null==(n=r.operations)||!n.supportsQuery){const e="The specified layer cannot be queried. The following fields will not be available.",t={layer:i,graphic:o,requiredFields:a,returnGeometry:l};return d.warn(e,t),null}const c=i.createQuery();c.objectIds=u,c.outFields=null!=a&&a.length?a:[i.objectIdField],c.returnGeometry=!!l,c.returnZ=!!l,c.returnM=!!l,c.outSpatialReference=s;return(await i.queryFeatures(c,t)).features[0]}async function ie(e){var t;if(null==(t=e.expressionInfos)||!t.length)return!1;const r=await f(),{arcadeUtils:{hasGeometryFunctions:n}}=r;return n(e)}async function oe({graphic:e,popupTemplate:t,layer:r,spatialReference:n},i){if(!r||!t)return;if("function"==typeof r.load&&await r.load(i),!e.attributes)return;const o=e.attributes[r.objectIdField];if(null==o)return;const a=[o],u=await t.getRequiredFields(r.fieldsIndex),s=l(u,e),f=s?[]:u,c=t.returnGeometry||await ie(t);if(s&&!c)return;const d=await ne({layer:r,graphic:e,outFields:f,objectIds:a,returnGeometry:c,spatialReference:n},i);d&&(d.geometry&&(e.geometry=d.geometry),d.attributes&&(e.attributes={...e.attributes,...d.attributes}))}function ae(e=""){return!!e&&-1!==e.indexOf(w)}function ue(e){return e?`${w}${e.layerId}/${e.fieldName}`:""}function le({attributes:e,graphic:t,relatedInfo:r}){e&&t&&r&&Object.keys(t.attributes).forEach((n=>{const i=ue({layerId:r.relation.id.toString(),fieldName:n});e[i]=t.attributes[n]}))}function se(e,t){e&&t&&(t.relatedFeatures&&t.relatedFeatures&&t.relatedFeatures.forEach((r=>le({attributes:e,graphic:r,relatedInfo:t}))),t.relatedStatsFeatures&&t.relatedStatsFeatures&&t.relatedStatsFeatures.forEach((r=>le({attributes:e,graphic:r,relatedInfo:t}))))}const fe=e=>{if(!e)return!1;const t=e.toUpperCase();return t.indexOf("CURRENT_TIMESTAMP")>-1||t.indexOf("CURRENT_DATE")>-1||t.indexOf("CURRENT_TIME")>-1},ce=({layer:e,method:t,query:n,definitionExpression:i})=>{var o,a;if(null==(o=e.capabilities)||null==(a=o.query)||!a.supportsCacheHint||"attachments"===t)return;const u=r(n.where)&&n.where,l=r(n.geometry)&&n.geometry;fe(i)||fe(u)||"extent"===(null==l?void 0:l.type)||"tile"===n.resultType||(n.cacheHint=!0)},de=({query:e,layer:t,method:r})=>{ce({layer:t,method:r,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression}`})},pe=({queryPayload:e,layer:t,method:r})=>{ce({layer:t,method:r,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression}`})};export{ee as applyTextFormattingHTML,W as createfieldInfoMap,k as fixTokens,re as formatAttributes,V as formatEditInfo,Z as formatValueToFieldInfo,X as getAllFieldInfos,B as getFieldInfo,C as getFieldInfoLabel,R as getFixedFieldName,L as getFixedFieldNames,x as getSourceLayer,E as graphicCallback,Y as htmlEntities,j as isExpressionField,ae as isRelatedField,de as preLayerQueryCallback,pe as preRequestCallback,oe as queryUpdatedFeature,v as shouldOpenInNewTab,A as substituteAttributes,$ as substituteFieldsInLinksAndAttributes};
5
+ import"../../../intl.js";import e from"../../../core/Logger.js";import{isNone as t,isSome as r}from"../../../core/maybe.js";import{replace as n}from"../../../core/string.js";import{formatDate as i,convertDateFormatToIntlOptions as o}from"../../../intl/date.js";import{formatNumber as a,convertNumberFormatToIntlOptions as l}from"../../../intl/number.js";import{featureHasFields as u}from"../../../layers/support/fieldUtils.js";import s from"../../../popup/support/FieldInfoFormat.js";import{loadArcade as f}from"../../../support/arcadeOnDemand.js";const c="esri.widgets.Feature.support.featureUtils",d=e.getLogger(c),p=/href=(""|'')/gi,m=/(\{([^\{\r\n]+)\})/g,y=/\'/g,g=/^\s*expression\//i,h=/(\n)/gi,I=/[\u00A0-\u9999<>\&]/gim,b=/href\s*=\s*(?:\"([^\"]+)\"|\'([^\']+)\')/gi,F=/^(?:mailto:|tel:)/,w="relationships/",N=o("short-date-short-time");function E(e){if(!t(e))return e.get("sourceLayer")||e.get("layer")}async function v(e,t){return"function"==typeof e?e.call(null,t):e}function j(e=""){if(e)return!F.test(e.trim().toLowerCase())}function T(e){return!!e&&g.test(e)}function x(e,t){if(!T(t)||!e)return null;const r=t.replace(g,"").toLowerCase();let n;return e.some((e=>e.name.toLowerCase()===r&&(n=e,!0))),n}function C(e,t){const r=x(t,null==e?void 0:e.fieldName);return r?r.title||null:e?e.label||e.fieldName:null}function M(e,t){const r=t.get(e.toLowerCase());return`{${r&&r.fieldName||e}}`}function q(e){return e.replace(p,"")}function D(e,t){const r=L(t,e);return r?r.name:e}function R(e,t){return e&&e.map((e=>D(e,t)))}function L(e,t){return e&&"function"==typeof e.getField?e.getField(t):null}function U(e){return`${e}`.trim()}function $({attributes:e,globalAttributes:t,layer:r,text:n,expressionAttributes:i,fieldInfoMap:o}){return n?A({formattedAttributes:t,template:P(n,{...t,...i,...e},r),fieldInfoMap:o}):""}function A({formattedAttributes:e,template:t,fieldInfoMap:r}){return U(q(n(n(t,(e=>M(e,r))),e)))}function S(e,t,r=!1){const n=t[e];if("string"==typeof n){const i="%27",o=(r?encodeURIComponent(n):n).replace(y,i);t[e]=o}}function G(e,t=!1){const r={...e};return Object.keys(r).forEach((e=>S(e,r,t))),r}function k(e,t,r){const i=(t=U(t))&&"{"!==t[0];return n(e,G(r,i))}function O(e,t){return e.replace(m,((e,r,n)=>{const i=L(t,n);return i?`{${i.name}}`:r}))}function P(e,t,r){const n=O(e,r);return n?n.replace(b,((e,r,n)=>k(e,r||n,t))):n}function _(e,t){if("string"==typeof e&&t&&null==t.dateFormat&&(null!=t.places||null!=t.digitSeparator)){const t=Number(e);if(!isNaN(t))return t}return e}function z(e){return"feature"===(null==e?void 0:e.type)}function H(e){return!(null==e||!e.layer)}function Q(e){return"map-image"===(null==e?void 0:e.type)}function Z(e,t){const r=t.fieldInfos,n=t.fieldName,i=B(r,n),o=null==i?void 0:i.clone(),u=t.preventPlacesFormatting,f=t.layer,c=L(f,n);if(o&&"date"===(null==c?void 0:c.type)){const e=o.format||new s;e.dateFormat=e.dateFormat||"short-date-short-time",e.dateTimeFormatOptions=!H(f)&&z(f)&&f.datesInUnknownTimezone||H(f)&&Q(f.layer)&&f.layer.datesInUnknownTimezone?{timeZone:"UTC"}:null,o.format=e}const d=o&&o.format;return"string"==typeof(e=_(e,d))||null==e||null==d?ee(e):u?a(e,{...l(d),minimumFractionDigits:0,maximumFractionDigits:20}):d.format(e)}function B(e,t){if(!e||!e.length||!t)return;const r=t.toLowerCase();let n;return e.some((e=>!(!e.fieldName||e.fieldName.toLowerCase()!==r)&&(n=e,!0))),n}function J({fieldName:e,graphic:t,layer:r}){if(ae(e))return null;if(!r||"function"!=typeof r.getFeatureType)return null;const{typeIdField:n}=r;if(!n||e!==n)return null;const i=r.getFeatureType(t);return i?i.name:null}function K({fieldName:e,value:t,graphic:r,layer:n}){if(ae(e))return null;if(!n||"function"!=typeof n.getFieldDomain)return null;const i=n.getFieldDomain(e,{feature:r});return i&&"coded-value"===i.type?i.getName(t):null}function V(e,t){const{creatorField:r,creationDateField:n,editorField:o,editDateField:a}=e;if(!t)return;const l=t[a];if("number"==typeof l){const e=t[o];return{type:"edit",date:i(l,N),user:e}}const u=t[n];if("number"==typeof u){const e=t[r];return{type:"create",date:i(u,N),user:e}}return null}function W(e,t){const r=new Map;return e&&e.forEach((e=>{const n=D(e.fieldName,t);e.fieldName=n,r.set(n.toLowerCase(),e)})),r}function X(e){const t=[];if(!e)return t;const{fieldInfos:r,content:n}=e;return r&&t.push(...r),n&&Array.isArray(n)?(n.forEach((e=>{if("fields"===e.type){const r=e&&e.fieldInfos;r&&t.push(...r)}})),t):t}function Y(e){return e.replace(I,(e=>`&#${e.charCodeAt(0)};`))}function ee(e){return"string"==typeof e?e.replace(h,'<br class="esri-text-new-line" />'):e}function te(e){const{value:t,fieldName:r,fieldInfos:n,fieldInfoMap:o,layer:a,graphic:l}=e;if(null==t)return"";const u=K({fieldName:r,value:t,graphic:l,layer:a});if(u)return u;const s=J({fieldName:r,graphic:l,layer:a});if(s)return s;if(o.get(r.toLowerCase()))return Z(t,{fieldInfos:n,fieldName:r,layer:a});const f=a&&a.fieldsIndex;return f&&f.isDateField(r)?i(t,N):ee(t)}function re({fieldInfos:e,attributes:t,layer:r,graphic:n,fieldInfoMap:i,relatedInfos:o}){const a={};return null==o||o.forEach((t=>se({attributes:a,relatedInfo:t,fieldInfoMap:i,fieldInfos:e,layer:r}))),Object.keys(t).forEach((o=>{const l=t[o];a[o]=te({fieldName:o,fieldInfos:e,fieldInfoMap:i,layer:r,value:l,graphic:n})})),a}async function ne(e,t){var r,n;const{layer:i,graphic:o,outFields:a,objectIds:l,returnGeometry:u,spatialReference:s}=e,f=l[0];if("number"!=typeof f&&"string"!=typeof f){const e="Could not query required fields for the specified feature. The feature's ID is invalid.",t={layer:i,graphic:o,objectId:f,requiredFields:a};return d.warn(e,t),null}if(null==(r=i.capabilities)||null==(n=r.operations)||!n.supportsQuery){const e="The specified layer cannot be queried. The following fields will not be available.",t={layer:i,graphic:o,requiredFields:a,returnGeometry:u};return d.warn(e,t),null}const c=i.createQuery();c.objectIds=l,c.outFields=null!=a&&a.length?a:[i.objectIdField],c.returnGeometry=!!u,c.returnZ=!!u,c.returnM=!!u,c.outSpatialReference=s;return(await i.queryFeatures(c,t)).features[0]}async function ie(e){var t;if(null==(t=e.expressionInfos)||!t.length)return!1;const r=await f(),{arcadeUtils:{hasGeometryFunctions:n}}=r;return n(e)}async function oe({graphic:e,popupTemplate:t,layer:r,spatialReference:n},i){if(!r||!t)return;if("function"==typeof r.load&&await r.load(i),!e.attributes)return;const o=e.attributes[r.objectIdField];if(null==o)return;const a=[o],l=await t.getRequiredFields(r.fieldsIndex),s=u(l,e),f=s?[]:l,c=t.returnGeometry||await ie(t);if(s&&!c)return;const d=await ne({layer:r,graphic:e,outFields:f,objectIds:a,returnGeometry:c,spatialReference:n},i);d&&(d.geometry&&(e.geometry=d.geometry),d.attributes&&(e.attributes={...e.attributes,...d.attributes}))}function ae(e=""){return!!e&&e.includes(w)}function le(e){return e?`${w}${e.layerId}/${e.fieldName}`:""}function ue({attributes:e,graphic:t,relatedInfo:r,fieldInfos:n,fieldInfoMap:i,layer:o}){e&&t&&r&&Object.keys(t.attributes).forEach((a=>{const l=le({layerId:r.relation.id.toString(),fieldName:a}),u=t.attributes[a];e[l]=te({fieldName:l,fieldInfos:n,fieldInfoMap:i,layer:o,value:u,graphic:t})}))}function se({attributes:e,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i}){e&&t&&(t.relatedFeatures&&t.relatedFeatures&&t.relatedFeatures.forEach((o=>ue({attributes:e,graphic:o,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i}))),t.relatedStatsFeatures&&t.relatedStatsFeatures&&t.relatedStatsFeatures.forEach((o=>ue({attributes:e,graphic:o,relatedInfo:t,fieldInfoMap:r,fieldInfos:n,layer:i}))))}const fe=e=>{if(!e)return!1;const t=e.toUpperCase();return t.includes("CURRENT_TIMESTAMP")||t.includes("CURRENT_DATE")||t.includes("CURRENT_TIME")},ce=({layer:e,method:t,query:n,definitionExpression:i})=>{var o,a;if(null==(o=e.capabilities)||null==(a=o.query)||!a.supportsCacheHint||"attachments"===t)return;const l=r(n.where)&&n.where,u=r(n.geometry)&&n.geometry;fe(i)||fe(l)||"extent"===(null==u?void 0:u.type)||"tile"===n.resultType||(n.cacheHint=!0)},de=({query:e,layer:t,method:r})=>{ce({layer:t,method:r,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression}`})},pe=({queryPayload:e,layer:t,method:r})=>{ce({layer:t,method:r,query:e,definitionExpression:`${t.definitionExpression} ${t.serviceDefinitionExpression}`})};export{ee as applyTextFormattingHTML,W as createfieldInfoMap,O as fixTokens,re as formatAttributes,V as formatEditInfo,Z as formatValueToFieldInfo,X as getAllFieldInfos,B as getFieldInfo,C as getFieldInfoLabel,D as getFixedFieldName,R as getFixedFieldNames,E as getSourceLayer,v as graphicCallback,Y as htmlEntities,T as isExpressionField,ae as isRelatedField,de as preLayerQueryCallback,pe as preRequestCallback,oe as queryUpdatedFeature,j as shouldOpenInNewTab,A as substituteAttributes,$ as substituteFieldsInLinksAndAttributes};