@arcgis/core 4.32.0-next.20250203 → 4.32.0-next.20250205

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 (242) hide show
  1. package/WebScene.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{d3a8aabdbfb59dd433e3.js → 01c3507d78398baaf61b.js} +1 -1
  4. package/assets/esri/core/workers/chunks/06f693780f70e5a627c4.js +1 -0
  5. package/assets/esri/core/workers/chunks/1a2e1a414e651e988435.js +2 -0
  6. package/assets/esri/core/workers/chunks/{bf9bc52a3c559108c19a.js.LICENSE.txt → 1a2e1a414e651e988435.js.LICENSE.txt} +1 -1
  7. package/assets/esri/core/workers/chunks/{6e25742ceedea7fb1b97.js → 287362f9af132fafe4de.js} +1 -1
  8. package/assets/esri/core/workers/chunks/308ec51ff4a66f7fcb0d.js.LICENSE.txt +1 -1
  9. package/assets/esri/core/workers/chunks/354531dc2f0dea2ad96f.js +2 -0
  10. package/assets/esri/core/workers/chunks/{6e8905f20101c1f4509d.js.LICENSE.txt → 354531dc2f0dea2ad96f.js.LICENSE.txt} +1 -1
  11. package/assets/esri/core/workers/chunks/41cd1a5c99ab3bbd1fb4.js +1 -0
  12. package/assets/esri/core/workers/chunks/44abd2cd17aae3299ede.js +1 -0
  13. package/assets/esri/core/workers/chunks/{adfa126cea32298c28e9.js → 48ecc5a74fecbb2b9c6f.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{af2a70d33afb12bb536f.js → 4d0a6ccb8434f8898377.js} +44 -44
  15. package/assets/esri/core/workers/chunks/{e9f0402fa3ac5a249807.js → 5196c43dbce48d1b81ae.js} +1 -1
  16. package/assets/esri/core/workers/chunks/568bcf809fcfd4d9c713.js +1 -0
  17. package/assets/esri/core/workers/chunks/{f2fae056a81f12b56b04.js → 5e7f16b312077ca8c18d.js} +1 -1
  18. package/assets/esri/core/workers/chunks/61243217aed5de012e93.js +1 -0
  19. package/assets/esri/core/workers/chunks/6d5bfcc7856cafe7b043.js +2 -0
  20. package/assets/esri/core/workers/chunks/{7d3a441d2eb18d709ef9.js.LICENSE.txt → 6d5bfcc7856cafe7b043.js.LICENSE.txt} +1 -1
  21. package/assets/esri/core/workers/chunks/72cf9192292e5c85c6df.js.LICENSE.txt +1 -1
  22. package/assets/esri/core/workers/chunks/73d03c208242778e67bf.js +1 -0
  23. package/assets/esri/core/workers/chunks/{bc50585615f07d5ec1a9.js → 746c964cf07e4306f21f.js} +1 -1
  24. package/assets/esri/core/workers/chunks/77764ca90bdd13ee2167.js +2 -0
  25. package/assets/esri/core/workers/chunks/{25c8cc30faade043c8dc.js.LICENSE.txt → 77764ca90bdd13ee2167.js.LICENSE.txt} +1 -1
  26. package/assets/esri/core/workers/chunks/{07360fde6ea65664e6ca.js → 82d26884127ed772cc4b.js} +1 -1
  27. package/assets/esri/core/workers/chunks/{ba3c18d1efde46461231.js → 8438fba57e82e4cc7c11.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{d1678945cf6a58f76863.js → 858b191c078d04232342.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{0ef5b0f8aa8a09acd6e0.js → 8e90c5fee4ad7c7275dc.js} +1 -1
  30. package/assets/esri/core/workers/chunks/918bdba41fa470cf77fd.js +1 -0
  31. package/assets/esri/core/workers/chunks/{3ec51b75d1a86dad6cb1.js → 91d2bdfa6e34c10b7f50.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{12dd892cf61a76fb40ad.js → 991e0f619f1f81f94d56.js} +1 -1
  33. package/assets/esri/core/workers/chunks/9a27824d94df702e6e28.js +1 -0
  34. package/assets/esri/core/workers/chunks/9a2d7c98fa0c4f8a9fd5.js +314 -0
  35. package/assets/esri/core/workers/chunks/a2409d4921c02614169a.js +1 -0
  36. package/assets/esri/core/workers/chunks/{7810579a5a780933cdc9.js → ad3e692681b50bd1acc2.js} +1 -1
  37. package/assets/esri/core/workers/chunks/b21b152fa15896577242.js.LICENSE.txt +1 -1
  38. package/assets/esri/core/workers/chunks/{c7a94e569c905f97244a.js → b33122adfd1fb68f7c0f.js} +1 -1
  39. package/assets/esri/core/workers/chunks/{da77eefaad83c0644380.js → b8fae500c69ca2cff62a.js} +1 -1
  40. package/assets/esri/core/workers/chunks/b9d9a1dc3c5d799e2685.js +1 -0
  41. package/assets/esri/core/workers/chunks/{79afe4674a0557eb26e4.js → bf26f58210755875748c.js} +1 -1
  42. package/assets/esri/core/workers/chunks/{5adeb979f178944b9ce5.js → c4c2b94e5cee7b824093.js} +1 -1
  43. package/assets/esri/core/workers/chunks/c7b6f237efaab333459e.js +1 -0
  44. package/assets/esri/core/workers/chunks/{3e872e5e528dca7bee0c.js → cc75bbfd779f409943a3.js} +1 -1
  45. package/assets/esri/core/workers/chunks/{4c5279fedf982a174706.js → d175953337fa655dc6b0.js} +1 -1
  46. package/assets/esri/core/workers/chunks/d35efcbe439500bf18bc.js +1 -0
  47. package/assets/esri/core/workers/chunks/d3d1dcb440588a295eba.js +1 -0
  48. package/assets/esri/core/workers/chunks/e26dc0c1654316bb1558.js +1 -0
  49. package/assets/esri/core/workers/chunks/{448ee44c7f594e5b2551.js → e410a09650530d7aad10.js} +1 -1
  50. package/assets/esri/core/workers/chunks/{2345344be4b0e487d3a6.js → f198f4ba7d3d52882d98.js} +1 -1
  51. package/assets/esri/core/workers/chunks/{881ddbdeb40336208e90.js → f29715459ecd46180829.js} +1 -1
  52. package/assets/esri/core/workers/chunks/f4e48bbdbc9da10ec71a.js +1 -0
  53. package/assets/esri/themes/base/widgets/_Directions.scss +74 -17
  54. package/assets/esri/themes/dark/main.css +1 -1
  55. package/assets/esri/themes/light/main.css +1 -1
  56. package/assets/esri/themes/light/view.css +1 -1
  57. package/assets/esri/widgets/Directions/t9n/Directions_ar.json +1 -1
  58. package/assets/esri/widgets/Directions/t9n/Directions_bg.json +1 -1
  59. package/assets/esri/widgets/Directions/t9n/Directions_bs.json +1 -1
  60. package/assets/esri/widgets/Directions/t9n/Directions_ca.json +1 -1
  61. package/assets/esri/widgets/Directions/t9n/Directions_cs.json +1 -1
  62. package/assets/esri/widgets/Directions/t9n/Directions_da.json +1 -1
  63. package/assets/esri/widgets/Directions/t9n/Directions_de.json +1 -1
  64. package/assets/esri/widgets/Directions/t9n/Directions_el.json +1 -1
  65. package/assets/esri/widgets/Directions/t9n/Directions_es.json +1 -1
  66. package/assets/esri/widgets/Directions/t9n/Directions_et.json +1 -1
  67. package/assets/esri/widgets/Directions/t9n/Directions_fi.json +1 -1
  68. package/assets/esri/widgets/Directions/t9n/Directions_fr.json +1 -1
  69. package/assets/esri/widgets/Directions/t9n/Directions_he.json +1 -1
  70. package/assets/esri/widgets/Directions/t9n/Directions_hr.json +1 -1
  71. package/assets/esri/widgets/Directions/t9n/Directions_hu.json +1 -1
  72. package/assets/esri/widgets/Directions/t9n/Directions_id.json +1 -1
  73. package/assets/esri/widgets/Directions/t9n/Directions_it.json +1 -1
  74. package/assets/esri/widgets/Directions/t9n/Directions_ja.json +1 -1
  75. package/assets/esri/widgets/Directions/t9n/Directions_ko.json +1 -1
  76. package/assets/esri/widgets/Directions/t9n/Directions_lt.json +1 -1
  77. package/assets/esri/widgets/Directions/t9n/Directions_lv.json +1 -1
  78. package/assets/esri/widgets/Directions/t9n/Directions_nl.json +1 -1
  79. package/assets/esri/widgets/Directions/t9n/Directions_no.json +1 -1
  80. package/assets/esri/widgets/Directions/t9n/Directions_pl.json +1 -1
  81. package/assets/esri/widgets/Directions/t9n/Directions_pt-BR.json +1 -1
  82. package/assets/esri/widgets/Directions/t9n/Directions_pt-PT.json +1 -1
  83. package/assets/esri/widgets/Directions/t9n/Directions_ro.json +1 -1
  84. package/assets/esri/widgets/Directions/t9n/Directions_ru.json +1 -1
  85. package/assets/esri/widgets/Directions/t9n/Directions_sk.json +1 -1
  86. package/assets/esri/widgets/Directions/t9n/Directions_sl.json +1 -1
  87. package/assets/esri/widgets/Directions/t9n/Directions_sr.json +1 -1
  88. package/assets/esri/widgets/Directions/t9n/Directions_sv.json +1 -1
  89. package/assets/esri/widgets/Directions/t9n/Directions_th.json +1 -1
  90. package/assets/esri/widgets/Directions/t9n/Directions_tr.json +1 -1
  91. package/assets/esri/widgets/Directions/t9n/Directions_uk.json +1 -1
  92. package/assets/esri/widgets/Directions/t9n/Directions_vi.json +1 -1
  93. package/assets/esri/widgets/Directions/t9n/Directions_zh-CN.json +1 -1
  94. package/assets/esri/widgets/Directions/t9n/Directions_zh-HK.json +1 -1
  95. package/assets/esri/widgets/Directions/t9n/Directions_zh-TW.json +1 -1
  96. package/chunks/ColorMaterial.glsl.js +4 -5
  97. package/chunks/ComponentShader.glsl.js +30 -30
  98. package/chunks/DefaultMaterial.glsl.js +19 -19
  99. package/chunks/HUDMaterial.glsl.js +34 -34
  100. package/chunks/MeasurementArrow.glsl.js +6 -6
  101. package/chunks/NativeLine.glsl.js +4 -4
  102. package/chunks/Pattern.glsl.js +1 -1
  103. package/chunks/QuadraticBezier.js +1 -1
  104. package/chunks/RealisticTree.glsl.js +14 -14
  105. package/chunks/RibbonLine.glsl.js +32 -32
  106. package/chunks/Terrain.glsl.js +31 -31
  107. package/chunks/WaterSurface.glsl.js +15 -15
  108. package/copyright.txt +0 -29
  109. package/core/Collection.js +1 -1
  110. package/core/has.js +1 -1
  111. package/geometry/operators/projectOperator.js +1 -1
  112. package/geometry/operators/shapePreservingProjectOperator.js +1 -1
  113. package/geometry/support/centroid.js +1 -1
  114. package/interfaces.d.ts +120 -13
  115. package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
  116. package/layers/graphics/sources/geojson/GeoJSONSourceWorker.js +1 -1
  117. package/layers/graphics/sources/support/MemorySourceWorker.js +1 -1
  118. package/layers/mixins/ArcGISImageService.js +1 -1
  119. package/layers/mixins/ImageryTileMixin.js +1 -1
  120. package/layers/ogc/wcsUtils.js +1 -1
  121. package/layers/support/RasterFunctionTemplate.js +1 -1
  122. package/layers/support/Sublayer.js +1 -1
  123. package/layers/support/capabilities.js +1 -1
  124. package/layers/support/featureLayerUtils.js +1 -1
  125. package/layers/support/labelUtils.js +1 -1
  126. package/layers/support/rasterDatasets/WCSRaster.js +1 -1
  127. package/layers/support/rasterDatasets/multidimensionalUtils.js +1 -1
  128. package/layers/support/rasterDatasets/multipartParser.js +1 -1
  129. package/layers/support/rasterDatasets/wcsCapabilitiesParser.js +1 -1
  130. package/layers/support/serviceCapabilitiesUtils.js +1 -1
  131. package/package.json +4 -5
  132. package/popup/content/AttachmentsContent.js +1 -1
  133. package/popup/support/AttachmentsOrderByInfo.d.ts +4 -0
  134. package/popup/support/AttachmentsOrderByInfo.js +5 -0
  135. package/portal/schemas/definitions.js +1 -1
  136. package/rest/imageService/fetchRasterInfo.js +1 -1
  137. package/rest/query/operations/queryAttachments.js +1 -1
  138. package/rest/support/AttachmentQuery.js +1 -1
  139. package/support/revision.js +1 -1
  140. package/support/timeUtils.d.ts +0 -1
  141. package/support/timeUtils.js +1 -1
  142. package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
  143. package/views/2d/engine/webgl/mesh/factories/FeatureMeshFactory.js +1 -1
  144. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedShader.js +1 -1
  145. package/views/2d/engine/webgl/shaderGraph/techniques/line/GradientStrokeTechnique.js +1 -1
  146. package/views/2d/engine/webgl/shaderGraph/techniques/line/gradientStrokeConstants.js +1 -1
  147. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/GradientStrokeShader.js +1 -1
  148. package/views/2d/engine/webgl/util/LabelMatcher.js +1 -1
  149. package/views/2d/engine/webgl/util/createMatcher.js +1 -1
  150. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  151. package/views/2d/layers/GraphicsLayerView2D.js +1 -1
  152. package/views/2d/layers/ImageryLayerView2D.js +1 -1
  153. package/views/2d/layers/LayerView2D.js +1 -1
  154. package/views/2d/layers/MapImageLayerView2D.js +1 -1
  155. package/views/2d/layers/TileLayerView2D.js +1 -1
  156. package/views/2d/layers/graphics/HighlightGraphicContainer.js +1 -1
  157. package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
  158. package/views/2d/layers/support/util.js +1 -1
  159. package/views/3d/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiles3D.js +1 -1
  160. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  161. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  162. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  163. package/views/3d/layers/graphics/Graphics3DGraphicsPipeline.js +1 -1
  164. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  165. package/views/3d/layers/graphics/Graphics3DLineCalloutSymbolLayer.js +1 -1
  166. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  167. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  168. package/views/3d/layers/i3s/I3SClientMaterialUtil.js +1 -1
  169. package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
  170. package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
  171. package/views/3d/layers/support/FeatureTileFetcher3DContext.js +1 -1
  172. package/views/3d/layers/support/FeatureTileTree3D.js +1 -1
  173. package/views/3d/layers/support/FeatureVisibilityFilter.js +1 -1
  174. package/views/3d/terrain/PatchRenderData.js +1 -1
  175. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  176. package/views/3d/webgl-engine/collections/Component/Material/shader/ComponentShader.glsl.js +1 -1
  177. package/views/3d/webgl-engine/core/shaderLibrary/util/DiscardOrAdjustAlpha.glsl.js +3 -3
  178. package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
  179. package/views/3d/webgl-engine/materials/CheckerBoardMaterial.js +1 -1
  180. package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
  181. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  182. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  183. package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
  184. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  185. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  186. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  187. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  188. package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
  189. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  190. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  191. package/views/3d/webgl-engine/shaders/DefaultMaterial.glsl.js +1 -1
  192. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  193. package/views/3d/webgl-engine/shaders/HUDMaterial.glsl.js +1 -1
  194. package/views/3d/webgl-engine/shaders/MeasurementArrow.glsl.js +1 -1
  195. package/views/3d/webgl-engine/shaders/NativeLine.glsl.js +1 -1
  196. package/views/3d/webgl-engine/shaders/OutputColorHighlightOID.glsl.js +8 -8
  197. package/views/3d/webgl-engine/shaders/RealisticTree.glsl.js +1 -1
  198. package/views/3d/webgl-engine/shaders/RibbonLine.glsl.js +1 -1
  199. package/views/3d/webgl-engine/shaders/Terrain.glsl.js +1 -1
  200. package/views/3d/webgl-engine/shaders/WaterSurface.glsl.js +1 -1
  201. package/views/layers/FeatureLayerView.js +1 -1
  202. package/views/layers/ImageryTileLayerView.d.ts +4 -0
  203. package/views/layers/ImageryTileLayerView.js +1 -1
  204. package/views/layers/support/MapServiceLayerViewHelper.js +1 -1
  205. package/webscene/spec-certification/index.js +1 -1
  206. package/widgets/Attachments/AttachmentsViewModel.js +1 -1
  207. package/widgets/BasemapLayerList.js +1 -1
  208. package/widgets/Directions/DirectionsViewModel.js +1 -1
  209. package/widgets/Directions.js +1 -1
  210. package/widgets/Editor/UpdateWorkflow.js +1 -1
  211. package/widgets/Editor/support/EditorItem.js +1 -1
  212. package/widgets/Feature/FeatureExpression/FeatureExpressionViewModel.js +1 -1
  213. package/widgets/Feature/FeatureViewModel.js +1 -1
  214. package/widgets/Feature/support/arcadeFeatureUtils.js +1 -1
  215. package/widgets/LayerList.js +1 -1
  216. package/widgets/Legend/LegendViewModel.js +1 -1
  217. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  218. package/widgets/Legend.js +1 -1
  219. package/widgets/NavigationToggle/NavigationToggleViewModel.js +1 -1
  220. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  221. package/widgets/support/geolocationUtils.js +1 -1
  222. package/assets/esri/core/workers/chunks/06d72622590dbd38c5de.js +0 -1
  223. package/assets/esri/core/workers/chunks/0a19e1aec6a5502e391a.js +0 -1
  224. package/assets/esri/core/workers/chunks/12964a4b16113cdc9c93.js +0 -1
  225. package/assets/esri/core/workers/chunks/1e3ab66d0e8a7f160f33.js +0 -1
  226. package/assets/esri/core/workers/chunks/25c8cc30faade043c8dc.js +0 -2
  227. package/assets/esri/core/workers/chunks/34d464dacee52739c98c.js +0 -1
  228. package/assets/esri/core/workers/chunks/402de76b5de05615e111.js +0 -1
  229. package/assets/esri/core/workers/chunks/4263eee3247aaf4e64bf.js +0 -1
  230. package/assets/esri/core/workers/chunks/4cab082b8432ddc05345.js +0 -1
  231. package/assets/esri/core/workers/chunks/613db14d698741886753.js +0 -1
  232. package/assets/esri/core/workers/chunks/6e8905f20101c1f4509d.js +0 -2
  233. package/assets/esri/core/workers/chunks/7d3a441d2eb18d709ef9.js +0 -2
  234. package/assets/esri/core/workers/chunks/ba37ab9e560644dc1f18.js +0 -1
  235. package/assets/esri/core/workers/chunks/bf9bc52a3c559108c19a.js +0 -2
  236. package/assets/esri/core/workers/chunks/c4b0e3f7dcad6c7ea620.js +0 -314
  237. package/assets/esri/core/workers/chunks/c74441fbe0f63633796f.js +0 -1
  238. package/assets/esri/core/workers/chunks/dd46ec81cebe1a0a7b9c.js +0 -1
  239. package/assets/esri/core/workers/chunks/e444ec05a8a1dfbd21a8.js +0 -1
  240. package/assets/esri/core/workers/chunks/f8367c21fa91435c7c53.js +0 -1
  241. package/assets/esri/core/workers/chunks/ffa2b9d70830aed03a8f.js +0 -1
  242. /package/{views/3d/webgl-engine/core/shaderLibrary/util → webscene/support}/AlphaCutoff.js +0 -0
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import{isSome as t}from"../core/arrayUtils.js";import{isAbortError as i}from"../core/promiseUtils.js";import{watch as s,initial as o,on as r}from"../core/reactiveUtils.js";import{escapeRegExpString as a}from"../core/string.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import c from"../portal/Portal.js";import{defaultUnitPropertyMetadata as d}from"../properties/defaultUnit.js";import m from"../rest/support/Stop.js";import p from"../symbols/SimpleMarkerSymbol.js";import h from"./Search.js";import u from"./Widget.js";import{DirectionsSearchTool as v}from"./Directions/DirectionsSearchTool.js";import g from"./Directions/DirectionsViewModel.js";import _ from"./Directions/DirectionsVisibleElements.js";import{formatDistance as w,formatDuration as y,DepartureTimeOption as b,getIconName as f}from"./Directions/support/directionsUtils.js";import{isArcGISWorldGeocoder as S,meteredArcGISLocatorUrl as M}from"./Search/support/locatorUtils.js";import{loadCalciteComponents as k}from"./support/componentsUtils.js";import{globalCss as I}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as F}from"./support/decorators/messageBundle.js";import{tsx as x}from"./support/jsxFactory.js";function T(e){const{branchName:i,displayText:s,exitName:o,intersectingName:r,name:n,objectId:l,towardName:c}=e;if(null==s)return null;const d=[i,o,r,n,c].filter(t).sort(((e,t)=>t.length-e.length)).map((e=>a(e)));if(!d.length)return s;const m=new RegExp(d.join("|"),"g"),p=s.matchAll(m);let h=0;const u=[];for(const{0:t,index:a}of p)u.push(s.slice(h,a),x("span",{class:$.labelEmphasize,key:`maneuver-${a}`},t)),h=a+t.length;return u.push(s.slice(h)),x("span",{id:`key-${l}`},u)}function C(e){const t=new Date(e);return new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())}const D="esri-directions",$={base:D,accordion:`${D}__accordion`,actionContainer:`${D}__action-container`,departureTimeOptions:`${D}__departure-time-options`,directionsHeader:`${D}__directions-header`,directionsHeaderStopNames:`${D}__directions-header-stop-names`,editFooter:`${D}__edit-footer`,editToolbar:`${D}__edit-toolbar`,editToolbarContainer:`${D}__edit-toolbar-container`,flexColumn:`${D}__flex-column`,flexRow:`${D}__flex-row`,labelEmphasize:`${D}__label-emphasize`,labelNoBottomMargin:`${D}__label-no-bottom-margin`,marginInlineMedium:`${D}__margin-inline-medium`,paddingMedium:`${D}__padding-medium`,panelHeaderAction:`${D}__panel-header-action`,panelHeaderActionColumns:`${D}__panel-header-action-columns`,panelTopBorder:`${D}__panel-top-border`,primaryFlowItem:`${D}__primary-flow-item`,primaryFooter:`${D}__primary-footer`,primaryFooterCentered:`${D}__primary-footer-centered`,saveError:`${D}__save-error`,saveErrorIcon:`${D}__save-error-icon`,saveErrorLabel:`${D}__save-error-label`,saveProcessLoader:`${D}__save-process-loader`,selectedFeatureContainer:`${D}__selected-feature-container`,separator:`${D}__separator`,stopContainer:`${D}__stop-container`,stopItem:`${D}__stop-item`};let A=class extends u{constructor(e,t){super(e,t),this._activeManeuver=null,this._placeholderStops=[new m,new m],this._portalFolderCombobox=null,this._portalFolders=null,this._portalItemNameInput=null,this._portalUserName=null,this._sections=null,this._stopsToSearches=new Map,this._currentFlowItem="primary",this._parentFlowItem="primary",this._saveState="initialized",this.headingLevel=2,this.messages=null,this.messagesUnits=null,this.searchProperties=null,this.viewModel=new g,this.visibleElements=new _}initialize(){this.addHandles([s((()=>this.viewModel.layer),(()=>{try{this.viewModel.load()}catch{}}),o),s((()=>this.viewModel.layer?.routeInfo),(()=>{this._sections=this._getStopSections()}),o)])}loadDependencies(){return k({accordion:()=>import("@esri/calcite-components/dist/components/calcite-accordion"),"accordion-item":()=>import("@esri/calcite-components/dist/components/calcite-accordion-item"),action:()=>import("@esri/calcite-components/dist/components/calcite-action"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch")})}get apiKey(){return this.viewModel.apiKey}set apiKey(e){this.viewModel.apiKey=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get icon(){return"right"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get lastRoute(){return this.viewModel.lastRoute}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get maxStops(){return this.viewModel.maxStops}set maxStops(e){this.viewModel.maxStops=e}get unit(){return this.defaultUnit}set unit(e){this._overrideIfSome("unit",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}acquireSearch(e){const{view:t}=this.viewModel;if(this._stopsToSearches.has(e)){const i=this._stopsToSearches.get(e);return i.view=t,this._overrideDefaultSources(i),i}const i=new h({icon:!1,popupEnabled:!1,resultGraphicEnabled:!1,view:t,...this.searchProperties});return this._normalizeSearchSources(i),this.addHandles([r((()=>i.allSources),"change",(()=>this._normalizeSearchSources(i))),i.on("search-clear",(()=>{e.geometry=null,e.name=null,this.viewModel.layer?.removeResult()})),i.on("select-result",(()=>{const t=i.selectedResult;e.geometry=t?.feature.geometry,e.name=t?.name,this._solveRoute()})),s((()=>i.searchTerm),(t=>{e.name=t}))],i),this._stopsToSearches.set(e,i),i}getDirections(){return this.viewModel.getDirections()}render(){return x("div",{class:this.classes($.base,I.widget,I.panel)},x("calcite-flow",null,this._renderPrimaryFlowItem(),this._renderDirectionsFlowItem(),this._renderEditFlowItem(),this._renderSaveFlowItem()))}save(){return this.viewModel.save()}saveAs(e,t={}){return this.viewModel.saveAs(e,t)}zoomToRoute(){return this.viewModel.zoomToRoute()}_applyLocatorSourceOverrides({allSources:e}){for(const t of e)"url"in t&&t.url&&(t.locationType??="street",S(t.url)&&this.apiKey&&null==t.apiKey&&(t.apiKey=this.apiKey,t.url=M))}_disposeSearch(e){if(!e||!this._stopsToSearches.has(e))return;const t=this._stopsToSearches.get(e);this.removeHandles(t),t.destroy(),this._stopsToSearches.delete(e)}_getErrorDescription(){switch(this.viewModel.lastError?.name){case"directions-view-model:unable-to-route":return this.messages.errors.unableToRoute;case"directions-view-model:service-metadata-unavailable":return this.messages.errors.unableToLoadServiceMetadata;default:return this.messages.errors.unknownError}}_getNetworkFeatureName(e){switch(e.type){case"stop":switch(e.locationType){case"stop":default:return this.messages.networkFeatures.stops.stop;case"waypoint":return this.messages.networkFeatures.stops.waypoint;case"break":return this.messages.networkFeatures.stops.break}case"point-barrier":return this.messages.networkFeatures.pointBarrier;case"polyline-barrier":return this.messages.networkFeatures.polylineBarrier;case"polygon-barrier":return this.messages.networkFeatures.polygonBarrier}}_getRouteCostSummary(){const e=this.viewModel.layer?.routeInfo;if(!e)return null;const t=e.totalDistance??0,i=e.totalDuration??0,{messagesUnits:s,unit:o}=this;return{distance:w(s,t,o),duration:y(i)}}_getStopSections(){if(!this.viewModel.layer)return null;const{directionPoints:e,directionLines:t,stops:i}=this.viewModel.layer;if(!e||!t)return null;const s=[];let o=null;for(const r of e){const{objectId:e,stopId:a}=r;if(null!=a){const e=i.find((({objectId:e})=>e===a));o&&o.stop===e||(o={stop:e,directions:[]},s.push(o));continue}if(null==o)continue;const n=t.find((({directionPointId:t})=>t===e));null!=n&&o.directions.push({directionPoint:r,directionLine:n})}return s}_handleLocateStopAction(e){const{view:t}=this;if(!t)return;const i=new v({stop:e,view:t}),s="directions-search-tool";this.removeHandles(s),this.addHandles(i.on("click",(async i=>{if(i.mapPoint&&this._stopsToSearches.has(e)){const s=this._stopsToSearches.get(e),o=await s.search(i.mapPoint),r=o?.results?.[0].results?.[0];if(r){const{feature:i,name:o}=r;s.searchTerm=o,e.geometry=i.geometry,t.activeTool=null}}this.removeHandles(s)})),s),t.addAndActivateTool(i)}async _handleSaveLayerAsAction(){const e=c.getDefault();try{await e.signIn()}catch(t){if(i(t)||"identity-manager:user-aborted"===t.name)return;return this._parentFlowItem=this._currentFlowItem,this._currentFlowItem="save",void(this._saveState="connect-to-portal-error")}this._saveState="fetch-portal-information",this._parentFlowItem=this._currentFlowItem,this._currentFlowItem="save",this._portalUserName=e.user?.username;try{this._portalFolders=await(e.user?.fetchFolders())}catch{return void(this._saveState="fetch-portal-information-error")}this._saveState="save-layer"}_normalizeSearchSources(e){this._overrideDefaultSources(e),this._applyLocatorSourceOverrides(e)}_overrideDefaultSources(e){for(const t of e.viewModel.defaultSources)t.autoNavigate=!1}_renderClearRouteAction(){return x("calcite-action",{icon:"trash",key:"clear-route",onclick:()=>{this._currentFlowItem="primary",this.viewModel.reset()},slot:"header-menu-actions",text:this.messages.common.clear,textEnabled:!0})}_renderDeleteStopAction(e){const t=this.viewModel.layer?.stops;return x("calcite-action",{disabled:(t?.length??0)<=2,icon:"trash",onclick:()=>{this.viewModel.layer?.stops.remove(e),this._disposeSearch(e),this._solveRoute()},scale:"s",text:this.messages.deleteStop})}_renderDepartureTime(){const{DEPART_AT:e,NOW:t,UNSPECIFIED:i}=b;return x("calcite-label",{key:"departure-time",scale:"s"},this.messages.departureTime,x("calcite-combobox",{clearDisabled:!0,label:this.messages.departureTime,overlayPositioning:"fixed",scale:"s",selectionMode:"single",onCalciteComboboxChange:({currentTarget:e})=>{const{selectedItems:t}=e;t.length&&(this.viewModel.departureOption=t[0].value,this._solveRoute())}},x("calcite-combobox-item",{heading:this.messages.leaveNow,key:t,label:this.messages.leaveNow,selected:this.viewModel.departureOption===t,value:t}),x("calcite-combobox-item",{heading:this.messages.departAt,key:e,label:this.messages.departAt,selected:this.viewModel.departureOption===e,value:e}),x("calcite-combobox-item",{heading:this.messages.timeUnspecified,key:i,label:this.messages.timeUnspecified,selected:this.viewModel.departureOption===i,value:i})))}_renderDepartureTimeOptions(){return this.viewModel.departureOption!==b.DEPART_AT?null:x("div",{class:$.departureTimeOptions},x("calcite-input-date-picker",{scale:"s",valueAsDate:C(this.viewModel.departureIsoDate),onCalciteInputDatePickerChange:({currentTarget:{value:e}})=>{this.viewModel.departureIsoDate=e,this._solveRoute()}}),x("calcite-input-time-picker",{scale:"s",value:this.viewModel.departureIsoTime,onCalciteInputTimePickerChange:({currentTarget:{value:e}})=>{this.viewModel.departureIsoTime=e,this._solveRoute()}}))}_renderDirectionsFlowItem(){if("directions"!==this._currentFlowItem)return null;const e=this._getRouteCostSummary();if(!this._sections||!e)return null;const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel,o=this._sections.at(0)?.stop.name??"",r=this._sections.at(-1)?.stop.name??"";return x("calcite-flow-item",{key:"directions-flow-item",selected:"directions"===this._currentFlowItem,onCalciteFlowItemBack:e=>{e.stopPropagation(),this._currentFlowItem="primary"}},x("calcite-panel",{class:$.labelNoBottomMargin,overlayPositioning:"fixed",slot:"header-actions-end"},x("div",{class:$.directionsHeader,slot:"header-actions-start"},x("div",{class:$.flexRow},x("div",{class:$.flexColumn},x("calcite-label",null,this.messages.from),x("calcite-label",null,this.messages.to)),x("div",{class:$.directionsHeaderStopNames},x("calcite-label",null,o),x("calcite-label",null,r))),x("calcite-label",null,`${i} | ${t}`),s?x("calcite-label",null,s):null),this._renderRouteLayerActions()),x("calcite-accordion",{class:$.accordion,iconPosition:"start",selectionMode:"single"},this._sections.map(((e,t)=>{const{stop:i,directions:s}=e,{name:o}=i;return x("calcite-accordion-item",{expanded:0===t,heading:o??"",key:`stop-${t}`},x("calcite-action",{icon:"zoom-to-object",onclick:()=>{this.viewModel.centerAt(i)},slot:"actions-end",text:this.messages.panToStop}),this._renderDirectionTurns(s))}))))}_renderDirectionTurns(e){return x("calcite-list",{label:this.messages.drivingDirections,selectionMode:"none"},e.map(((e,t)=>{const{directionPoint:i,directionLine:s}=e,{distance:o,duration:r}=s,a=w(this.messagesUnits,o??0,this.unit),n=y(r??0),l=a&&n?`${a} | ${n}`:`${a||n}`,c=T(i),d=f(i.directionPointType);return x("calcite-list-item",{class:$.labelNoBottomMargin,key:`driving-direction-${t}`,onpointerenter:()=>{this.viewModel.highlight(s)},onpointerleave:()=>{this.viewModel.clearHighlights()},onCalciteListItemSelect:()=>{this._activeManeuver===s?this.zoomToRoute():(this._activeManeuver=s,this.viewModel.centerAt(s.geometry))}},x("calcite-icon",{icon:d,slot:"content-start"}),x("div",{slot:"content"},x("calcite-label",{layout:"inline",scale:"s"},c),x("calcite-label",{layout:"inline",scale:"s"},l)))})))}_renderEditFlowItem(){return"edit"!==this._currentFlowItem?null:x("calcite-flow-item",{heading:this.messages.editRoute,headingLevel:this.headingLevel,key:"edit-flow-item",selected:"edit"===this._currentFlowItem,onCalciteFlowItemBack:e=>{e.stopPropagation(),this.viewModel.stopEditing(),this._currentFlowItem="primary"}},x("div",{class:$.flexColumn,key:"edit-container"},x("div",{class:$.editToolbarContainer},x("div",{class:$.editToolbar},x("calcite-action",{icon:"flag",key:"add-stop",onclick:()=>{this.viewModel.create("stop")},scale:"s",text:this.messages.networkFeatures.stops.stop,textEnabled:!0}),x("calcite-action",{icon:"line",key:"add-barrier",onclick:()=>{this.viewModel.create("polyline-barrier")},scale:"s",text:this.messages.barrier,textEnabled:!0}),x("calcite-action",{disabled:this.viewModel.autoSolve,icon:"refresh",key:"solve",onclick:()=>{this._solveRoute()},scale:"s",text:this.messages.solve}),x("calcite-action",{active:this.viewModel.autoSolve,icon:"app-update",key:"auto-solve",onclick:()=>{this.viewModel.autoSolve=!this.viewModel.autoSolve},scale:"s",text:this.messages.automaticallySolve}))),x("div",{class:$.selectedFeatureContainer},x("calcite-list",{label:this.messages.selectedNetworkFeatures,scale:"s",selectionMode:"none"},this.viewModel.selectedNetworkFeatures?.toArray().map(((e,t)=>x("calcite-list-item",{description:this._getNetworkFeatureName(e),key:`network-feature-${t}`,label:e.name??e.objectId?.toString()??this.messages.unnamed},x("calcite-action",{icon:"trash",onclick:()=>{this.viewModel.delete()},scale:"s",slot:"actions-end",text:this.messages.common.delete})))))),x("div",{class:$.editFooter},x("calcite-button",{onclick:e=>{e.stopPropagation(),this.viewModel.stopEditing(),this._currentFlowItem="primary"},scale:"m",width:"full"},this.messages.common.done))))}_renderFooter(){if(!this.viewModel.layer)return x("div",{class:$.primaryFooter,key:"footer-missing-layer"},x("calcite-notice",{icon:"information",open:!0},x("calcite-label",{class:$.labelNoBottomMargin,slot:"message"},this.messages.missingLayer)));if("unauthenticated"===this.viewModel.state)return x("div",{class:$.primaryFooterCentered,key:"footer-sign-in"},x("calcite-label",null,this.messages.signInRequired),x("calcite-button",{onclick:()=>{this.viewModel.load().catch((()=>{}))}},this.messages.common.auth.signIn));if("error"===this.viewModel.state&&!this.viewModel.serviceDescription)return x("div",{class:$.primaryFooter,key:"footer-service-error"},x("calcite-notice",{icon:"exclamation-mark-circle",kind:"danger",open:!0},x("calcite-label",{class:$.labelNoBottomMargin,slot:"message"},this._getErrorDescription())));if(!this.viewModel.layer?.routeInfo)return x("div",{class:$.primaryFooter,key:"footer-unsolved-route"},x("calcite-notice",{icon:"information",open:!0},x("calcite-label",{class:$.labelNoBottomMargin,slot:"message"},this.messages.directionsPlaceholder)));const e=this._getRouteCostSummary();if(!e||!this.viewModel.layer?.directionPoints)return x("div",{class:$.primaryFooter,key:"footer-invalid-route"},x("calcite-notice",{icon:"exclamation-mark-triangle",kind:"danger",open:!0},x("calcite-label",{class:$.labelNoBottomMargin,slot:"message"},this.messages.invalidRoute)));const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel;return x("calcite-panel",{class:$.panelTopBorder,key:"footer-directions-summary",overlayPositioning:"fixed"},x("calcite-action",{onclick:()=>{this._currentFlowItem="directions"},slot:"header-actions-start",text:this.messages.viewDrivingDirections},x("div",{class:$.panelHeaderAction},x("div",{class:this.classes($.labelNoBottomMargin,$.panelHeaderActionColumns)},x("calcite-label",{class:$.labelEmphasize},`${i} | ${t}`),x("calcite-label",{scale:"s"},s)),x("calcite-icon",{icon:"chevron-right"}))),this._renderRouteLayerActions())}_renderInteractiveRouteActions(){return x("div",{class:$.actionContainer,key:"interactive-route-action-container"},x("calcite-button",{appearance:"outline",iconStart:"plus",kind:"neutral",label:this.messages.addStop,onclick:()=>{const e=new p;this.viewModel.layer?.stops.add(new m({symbol:e}))}},this.messages.addStop),x("calcite-button",{appearance:"outline",iconStart:"pencil",kind:"neutral",label:this.messages.editRoute,onclick:()=>{this._currentFlowItem="edit",this.viewModel.startEditing()}},this.messages.editRoute),x("calcite-button",{appearance:"outline",bind:this,iconStart:"arrow-up-down",kind:"neutral",label:this.messages.reverseStops,onclick:()=>{this.viewModel.layer?.stops.reverse(),this._resetStopSequence(),this._solveRoute()}}))}_renderLocateStopAction(e){if(null!=e.name||null!=e.geometry)return null;const t=this.viewModel.layer?.stops.indexOf(e)??-1;return x("calcite-action",{icon:"select",key:`stop-location-action-${t}`,onclick:()=>this._handleLocateStopAction(e),scale:"s",text:this.messages.pickALocationOnTheMap})}_renderOptimizeStopOrder(){const{routeParameters:e}=this.viewModel,{findBestSequence:t,preserveFirstStop:i,preserveLastStop:s}=e;return x("div",null,x("calcite-label",{layout:"inline-space-between",scale:"s"},this.messages.optimizeOrder,x("calcite-switch",{checked:t,scale:"s",onCalciteSwitchChange:({target:t})=>{e.findBestSequence=t.checked,t.checked||this._resetStopSequence(),this._solveRoute()}})),t?[x("calcite-label",{key:"preserve-first-stop",layout:"inline-space-between",scale:"s"},this.messages.preserveFirstStop,x("calcite-switch",{checked:i,scale:"s",onCalciteSwitchChange:({target:{checked:t}})=>{e.preserveFirstStop=t,this._resetStopSequence(),this._solveRoute()}})),x("calcite-label",{key:"preserve-last-stop",layout:"inline-space-between",scale:"s"},this.messages.preserveLastStop,x("calcite-switch",{checked:s,scale:"s",onCalciteSwitchChange:({target:{checked:t}})=>{e.preserveLastStop=t,this._resetStopSequence(),this._solveRoute()}}))]:null)}_renderPrimaryFlowItem(){return x("calcite-flow-item",{key:"primary-flow-item",loading:"initializing"===this.viewModel.state,selected:"primary"===this._currentFlowItem},x("calcite-panel",{class:$.primaryFlowItem,disabled:!this.viewModel.layer||"unauthenticated"===this.viewModel.state||"error"===this.viewModel.state&&!this.viewModel.serviceDescription},this._renderStops(),this._renderInteractiveRouteActions(),this._renderSeparator(),this._renderRouteSolveOptions()),this._renderFooter())}_renderRouteLayerActions(){return[this._renderClearRouteAction(),this._renderSaveLayerAction(),this._renderSaveLayerAsAction(),this._renderViewItemDetailsAction()]}_renderRouteSolveOptions(){return x("div",{class:$.marginInlineMedium,key:"route-solve-options"},this._renderTravelModes(),this._renderDepartureTime(),this._renderDepartureTimeOptions(),this._renderOptimizeStopOrder())}_renderSaveContent(){switch(this._saveState){case"initialized":return this._renderSaveInitialized();case"connect-to-portal":return this._renderSaveProcessing(this.messages.identity.lblSigning);case"connect-to-portal-error":return this._renderSaveError(this.messages.errors.authenticating);case"fetch-portal-information":return this._renderSaveProcessing(this.messages.processing.fetching);case"fetch-portal-information-error":return this._renderSaveError(this.messages.errors.fetching);case"save-layer":return this._renderSaveLayerSettings();case"saving":return this._renderSaveProcessing(this.messages.processing.saving);case"saving-error":return this._renderSaveError(this.messages.errors.saving)}}_renderSaveError(e){return x("calcite-panel",{class:$.paddingMedium,key:"save-layer-error"},x("div",{class:$.saveError},x("calcite-icon",{class:$.saveErrorIcon,icon:"exclamation-mark-triangle",scale:"l",textLabel:this.messages.common.errorMessage}),x("calcite-label",{class:$.saveErrorLabel},e)),x("calcite-button",{appearance:"outline",onclick:()=>{this._currentFlowItem=this._parentFlowItem},slot:"footer-actions",width:"full"},this.messages.common.close))}_renderSaveInitialized(){return x("calcite-panel",{class:$.paddingMedium,key:"save-layer-initialized"})}_renderSaveFlowItem(){return"save"!==this._currentFlowItem?null:x("calcite-flow-item",{heading:this.messages.saveLayer,headingLevel:this.headingLevel,key:"save-layer-flow-item",selected:"save"===this._currentFlowItem,onCalciteFlowItemBack:e=>{e.stopPropagation(),this._currentFlowItem=this._parentFlowItem}},this._renderSaveContent())}_renderSaveLayerAction(){if(!this.visibleElements.saveButton)return null;const e=this.viewModel.layer,t=e?.routeInfo,i=e?.portalItem?.itemControl;return x("calcite-action",{disabled:!(!!t&&("admin"===i||"update"===i)),icon:"save",key:"save-route",onclick:()=>{this.viewModel.layer?.save()},slot:"header-menu-actions",text:this.messages.common.save,textEnabled:!0})}_renderSaveLayerAsAction(){if(!this.visibleElements.saveAsButton)return null;const e=!this.viewModel.layer?.routeInfo;return x("calcite-action",{disabled:e,icon:"save-as",key:"save-as-route",onclick:()=>{this._handleSaveLayerAsAction()},slot:"header-menu-actions",text:this.messages.common.saveAs,textEnabled:!0})}_renderSaveLayerSettings(){if(null==this.layer||null==this._portalFolders||null==this._portalUserName)return this._renderSaveInitialized();const{stops:e}=this.layer,t=`${e.at(0).name} - ${e.at(-1).name}`,i=this._portalFolders.map((e=>x("calcite-combobox-item",{heading:e.title??"",key:`${D}-folder-${e.id}`,value:e.id})));return i.unshift(x("calcite-combobox-item",{heading:`${this._portalUserName} (${this.messages.common.home})`,key:`${D}-folder-home`,selected:!0,value:null})),x("calcite-panel",{key:"save-layer-panel"},x("div",{class:$.paddingMedium},x("calcite-label",null,this.messages.laverName,x("calcite-input",{afterCreate:e=>{this._portalItemNameInput=e},label:this.messages.laverName,value:t})),x("calcite-label",null,this.messages.saveInFolder,x("calcite-combobox",{afterCreate:e=>{this._portalFolderCombobox=e},label:this.messages.saveInFolder,overlayPositioning:"fixed",selectionMode:"single"},i))),x("calcite-button",{onclick:()=>{if(this._saveState="saving",null==this.layer||null==this._portalFolders)return;const e=this._portalItemNameInput?.value,t=this._portalFolderCombobox?.value,i=this._portalFolders.find((({id:e})=>e===t));this.layer.saveAs({title:e},{folder:i}).then((()=>{this._currentFlowItem=this._parentFlowItem})).catch((()=>{this._saveState="saving-error"}))},slot:"footer-actions",width:"full"},this.messages.common.save),x("calcite-button",{appearance:"outline",onclick:()=>{this._currentFlowItem=this._parentFlowItem},slot:"footer-actions",width:"full"},this.messages.common.cancel))}_renderSaveProcessing(e){return x("calcite-panel",{class:$.marginInlineMedium,key:"save-layer-processing"},x("calcite-loader",{class:$.saveProcessLoader,label:e,text:e}))}_renderSeparator(){return x("div",{class:$.separator,key:"separator"})}_renderStop(e){const t=this.acquireSearch(e);null!=e.name&&(t.searchTerm=e.name);const i=this._renderLocateStopAction(e),s=this._renderDeleteStopAction(e),o=this.viewModel.layer?.stops.indexOf(e)??-1;return x("calcite-list-item",{key:`stop-${o}`,value:e},x("div",{class:$.flexRow,slot:"actions-end"},i,s),x("div",{class:$.stopItem,slot:"content"},t.render()))}_renderStops(){const e=this.viewModel.layer?.stops.toArray()??this._placeholderStops;for(const t of this._stopsToSearches.keys())e.includes(t)||this._disposeSearch(t);return x("div",{class:$.stopContainer,key:$.stopContainer},x("calcite-list",{dragEnabled:!0,label:this.messages.widgetLabel,scale:"s",onCalciteListOrderChange:({detail:e})=>{this.viewModel.layer?.stops.reorder(e.dragEl.value,e.newIndex),this._resetStopSequence(),this._solveRoute()}},e.map((e=>this._renderStop(e)))))}_renderTravelModes(){return this.viewModel.travelModes.length?x("calcite-label",{key:"travel-modes",scale:"s"},this.messages.mode,x("calcite-combobox",{clearDisabled:!0,label:"mode",overlayPositioning:"fixed",scale:"s",selectionMode:"single",onCalciteComboboxChange:({currentTarget:e})=>{const{selectedItems:t}=e;t.length&&(this.viewModel.selectedTravelMode=t[0].value,this._solveRoute())}},this.viewModel.travelModes.map((e=>x("calcite-combobox-item",{heading:e.name,key:e.id,label:e.name,selected:this.viewModel.selectedTravelMode?.id===e.id,value:e}))))):null}_renderViewItemDetailsAction(){if(!this.visibleElements.layerDetails)return null;const e=this.viewModel.layer?.portalItem;return x("calcite-action",{disabled:!e,icon:"launch",key:"open-route-details-link",onclick:()=>{e&&window.open(`${e.portal.url}/home/item.html?id=${e.id}`,"_blank")},slot:"header-menu-actions",text:this.messages.viewLayerDetails,textEnabled:!0})}_resetStopSequence(){this.viewModel.layer?.stops.forEach((e=>{e.sequence=null}))}async _solveRoute(){this.viewModel.updateDepartureTime();const e=this.viewModel.layer?.stops.filter((({geometry:e})=>null!=e));if(e&&!(e.length<2))try{await this.viewModel.getDirections()}catch{}}};e([n()],A.prototype,"_currentFlowItem",void 0),e([n()],A.prototype,"_saveState",void 0),e([n()],A.prototype,"apiKey",null),e([n(d)],A.prototype,"defaultUnit",void 0),e([n()],A.prototype,"goToOverride",null),e([n()],A.prototype,"headingLevel",void 0),e([n()],A.prototype,"icon",null),e([n()],A.prototype,"label",null),e([n({readOnly:!0})],A.prototype,"lastRoute",null),e([n()],A.prototype,"layer",null),e([n()],A.prototype,"maxStops",null),e([n(),F("esri/widgets/Directions/t9n/Directions")],A.prototype,"messages",void 0),e([n(),F("esri/core/t9n/Units")],A.prototype,"messagesUnits",void 0),e([n()],A.prototype,"searchProperties",void 0),e([n()],A.prototype,"unit",null),e([n()],A.prototype,"view",null),e([n({type:g})],A.prototype,"viewModel",void 0),e([n({type:_,nonNullable:!0})],A.prototype,"visibleElements",void 0),A=e([l("esri.widgets.Directions")],A);const E=A;export{E as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import{isSome as t}from"../core/arrayUtils.js";import i from"../core/Collection.js";import{isAbortError as s}from"../core/promiseUtils.js";import{watch as o,initial as r,on as a}from"../core/reactiveUtils.js";import{escapeRegExpString as n}from"../core/string.js";import{property as l}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as c}from"../core/accessorSupport/decorators/subclass.js";import d from"../portal/Portal.js";import{defaultUnitPropertyMetadata as m}from"../properties/defaultUnit.js";import p from"../rest/support/Stop.js";import u from"../symbols/SimpleMarkerSymbol.js";import h from"./Search.js";import v from"./Widget.js";import{DirectionsSearchTool as g}from"./Directions/DirectionsSearchTool.js";import _ from"./Directions/DirectionsViewModel.js";import w from"./Directions/DirectionsVisibleElements.js";import{formatDistance as y,formatDuration as b,DepartureTimeOption as f,getIconName as S}from"./Directions/support/directionsUtils.js";import{isArcGISWorldGeocoder as M,meteredArcGISLocatorUrl as k}from"./Search/support/locatorUtils.js";import{loadCalciteComponents as I}from"./support/componentsUtils.js";import{globalCss as F}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as x}from"./support/decorators/messageBundle.js";import{tsx as T}from"./support/jsxFactory.js";function C(e){const{branchName:i,displayText:s,exitName:o,intersectingName:r,name:a,objectId:l,towardName:c}=e;if(null==s)return null;const d=[i,o,r,a,c].filter(t).sort(((e,t)=>t.length-e.length)).map((e=>n(e)));if(!d.length)return s;const m=new RegExp(d.join("|"),"g"),p=s.matchAll(m);let u=0;const h=[];for(const{0:t,index:n}of p)h.push(s.slice(u,n),T("span",{class:L.labelEmphasize,key:`maneuver-${n}`},t)),u=n+t.length;return h.push(s.slice(u)),T("span",{id:`key-${l}`},h)}function D(e){const t=new Date(e);return new Date(t.getUTCFullYear(),t.getUTCMonth(),t.getUTCDate())}const $="esri-directions",L={base:$,accordion:`${$}__accordion`,actionContainer:`${$}__action-container`,addStopButton:`${$}__add-stop-button`,departureTimeOptions:`${$}__departure-time-options`,directionsHeader:`${$}__directions-header`,directionsHeaderStopName:`${$}__directions-header-stop-name`,editFooter:`${$}__edit-footer`,editToolbar:`${$}__edit-toolbar`,editToolbarContainer:`${$}__edit-toolbar-container`,flexColumn:`${$}__flex-column`,flexRow:`${$}__flex-row`,headerStops:`${$}__header-stops`,labelEmphasize:`${$}__label-emphasize`,labelNoBottomMargin:`${$}__label-no-bottom-margin`,marginInlineMedium:`${$}__margin-inline-medium`,paddingMedium:`${$}__padding-medium`,primaryFlowItem:`${$}__primary-flow-item`,primaryFooter:`${$}__primary-footer`,primaryFooterCentered:`${$}__primary-footer-centered`,routeItem:`${$}__route-item`,routeItemButton:`${$}__route-item-button`,routeItemButtonContent:`${$}__route-item-button-content`,routeItemLabel:`${$}__route-item-label`,routeItemDescription:`${$}__route-item-description`,saveError:`${$}__save-error`,saveErrorIcon:`${$}__save-error-icon`,saveErrorLabel:`${$}__save-error-label`,saveProcessLoader:`${$}__save-process-loader`,selectedFeatureContainer:`${$}__selected-feature-container`,separator:`${$}__separator`,stopContainer:`${$}__stop-container`,stopList:`${$}__stop-list`,stopItem:`${$}__stop-item`};let A=class extends v{constructor(e,t){super(e,t),this._activeManeuver=null,this._placeholderStops=new i([new p,new p]),this._portalFolderCombobox=null,this._portalFolders=null,this._portalItemNameInput=null,this._portalUserName=null,this._sections=null,this._stopsToSearches=new Map,this._currentFlowItem="primary",this._parentFlowItem="primary",this._saveState="initialized",this.headingLevel=2,this.messages=null,this.messagesUnits=null,this.searchProperties=null,this.viewModel=new _,this.visibleElements=new w}initialize(){this.addHandles([o((()=>this.viewModel.layer),(()=>{try{this.viewModel.load()}catch{}}),r),o((()=>this.viewModel.layer?.routeInfo),(()=>{this._sections=this._getStopSections()}),r)])}loadDependencies(){return I({accordion:()=>import("@esri/calcite-components/dist/components/calcite-accordion"),"accordion-item":()=>import("@esri/calcite-components/dist/components/calcite-accordion-item"),action:()=>import("@esri/calcite-components/dist/components/calcite-action"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch")})}get apiKey(){return this.viewModel.apiKey}set apiKey(e){this.viewModel.apiKey=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get icon(){return"right"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get lastRoute(){return this.viewModel.lastRoute}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get maxStops(){return this.viewModel.maxStops}set maxStops(e){this.viewModel.maxStops=e}get unit(){return this.defaultUnit}set unit(e){this._overrideIfSome("unit",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}acquireSearch(e){const{view:t}=this.viewModel;if(this._stopsToSearches.has(e)){const i=this._stopsToSearches.get(e);return i.view=t,this._overrideDefaultSources(i),i}const i=new h({icon:!1,popupEnabled:!1,resultGraphicEnabled:!1,view:t,...this.searchProperties});return this._normalizeSearchSources(i),this.addHandles([a((()=>i.allSources),"change",(()=>this._normalizeSearchSources(i))),i.on("search-clear",(()=>{e.geometry=null,e.name=null,this.viewModel.layer?.removeResult()})),i.on("select-result",(()=>{const t=i.selectedResult;e.geometry=t?.feature.geometry,e.name=t?.name,this._solveRoute()})),o((()=>i.searchTerm),(t=>{e.name=t}))],i),this._stopsToSearches.set(e,i),i}getDirections(){return this.viewModel.getDirections()}render(){return T("div",{class:this.classes(L.base,F.widget,F.panel)},T("calcite-flow",null,this._renderPrimaryFlowItem(),this._renderDirectionsFlowItem(),this._renderEditFlowItem(),this._renderSaveFlowItem()))}save(){return this.viewModel.save()}saveAs(e,t={}){return this.viewModel.saveAs(e,t)}zoomToRoute(){return this.viewModel.zoomToRoute()}_applyLocatorSourceOverrides({allSources:e}){for(const t of e)"url"in t&&t.url&&(t.locationType??="street",M(t.url)&&this.apiKey&&null==t.apiKey&&(t.apiKey=this.apiKey,t.url=k))}_disposeSearch(e){if(!e||!this._stopsToSearches.has(e))return;const t=this._stopsToSearches.get(e);this.removeHandles(t),t.destroy(),this._stopsToSearches.delete(e)}_getErrorDescription(){switch(this.viewModel.lastError?.name){case"directions-view-model:unable-to-route":return this.messages.errors.unableToRoute;case"directions-view-model:service-metadata-unavailable":return this.messages.errors.unableToLoadServiceMetadata;default:return this.messages.errors.unknownError}}_getNetworkFeatureName(e){switch(e.type){case"stop":switch(e.locationType){case"stop":default:return this.messages.networkFeatures.stops.stop;case"waypoint":return this.messages.networkFeatures.stops.waypoint;case"break":return this.messages.networkFeatures.stops.break}case"point-barrier":return this.messages.networkFeatures.pointBarrier;case"polyline-barrier":return this.messages.networkFeatures.polylineBarrier;case"polygon-barrier":return this.messages.networkFeatures.polygonBarrier}}_getRouteCostSummary(){const e=this.viewModel.layer?.routeInfo;if(!e)return null;const t=e.totalDistance??0,i=e.totalDuration??0,{messagesUnits:s,unit:o}=this;return{distance:y(s,t,o),duration:b(i)}}_getStopSections(){if(!this.viewModel.layer)return null;const{directionPoints:e,directionLines:t,stops:i}=this.viewModel.layer;if(!e||!t)return null;const s=[];let o=null;for(const r of e){const{objectId:e,stopId:a}=r;if(null!=a){const e=i.find((({objectId:e})=>e===a));o&&o.stop===e||(o={stop:e,directions:[]},s.push(o));continue}if(null==o)continue;const n=t.find((({directionPointId:t})=>t===e));null!=n&&o.directions.push({directionPoint:r,directionLine:n})}return s}_handleLocateStopAction(e){const{view:t}=this;if(!t)return;const i=new g({stop:e,view:t}),s="directions-search-tool";this.removeHandles(s),this.addHandles(i.on("click",(async i=>{if(i.mapPoint&&this._stopsToSearches.has(e)){const s=this._stopsToSearches.get(e),o=await s.search(i.mapPoint),r=o?.results?.[0].results?.[0];if(r){const{feature:i,name:o}=r;s.searchTerm=o,e.geometry=i.geometry,t.activeTool=null}}this.removeHandles(s)})),s),t.addAndActivateTool(i)}async _handleSaveLayerAsAction(){const e=d.getDefault();try{await e.signIn()}catch(t){if(s(t)||"identity-manager:user-aborted"===t.name)return;return this._parentFlowItem=this._currentFlowItem,this._currentFlowItem="save",void(this._saveState="connect-to-portal-error")}this._saveState="fetch-portal-information",this._parentFlowItem=this._currentFlowItem,this._currentFlowItem="save",this._portalUserName=e.user?.username;try{this._portalFolders=await(e.user?.fetchFolders())}catch{return void(this._saveState="fetch-portal-information-error")}this._saveState="save-layer"}_normalizeSearchSources(e){this._overrideDefaultSources(e),this._applyLocatorSourceOverrides(e)}_overrideDefaultSources(e){for(const t of e.viewModel.defaultSources)t.autoNavigate=!1}_renderClearRouteAction(e){return T("calcite-action",{icon:"trash",key:"clear-route",onclick:()=>{this._currentFlowItem="primary",this.viewModel.reset()},...e,text:this.messages.common.clear,textEnabled:!0})}_renderDeleteStopAction(e){const t=this.viewModel.layer?.stops;return T("calcite-action",{disabled:(t?.length??0)<=2,icon:"trash",onclick:()=>{this.viewModel.layer?.stops.remove(e),this._disposeSearch(e),this._solveRoute()},scale:"s",slot:"actions-end",text:this.messages.deleteStop})}_renderDepartureTime(){const{DEPART_AT:e,NOW:t,UNSPECIFIED:i}=f;return T("calcite-label",{key:"departure-time",scale:"s"},this.messages.departureTime,T("calcite-combobox",{clearDisabled:!0,label:this.messages.departureTime,overlayPositioning:"fixed",scale:"s",selectionMode:"single",onCalciteComboboxChange:({currentTarget:e})=>{const{selectedItems:t}=e;t.length&&(this.viewModel.departureOption=t[0].value,this._solveRoute())}},T("calcite-combobox-item",{heading:this.messages.leaveNow,key:t,label:this.messages.leaveNow,selected:this.viewModel.departureOption===t,value:t}),T("calcite-combobox-item",{heading:this.messages.departAt,key:e,label:this.messages.departAt,selected:this.viewModel.departureOption===e,value:e}),T("calcite-combobox-item",{heading:this.messages.timeUnspecified,key:i,label:this.messages.timeUnspecified,selected:this.viewModel.departureOption===i,value:i})))}_renderDepartureTimeOptions(){return this.viewModel.departureOption!==f.DEPART_AT?null:T("div",{class:L.departureTimeOptions},T("calcite-input-date-picker",{scale:"s",valueAsDate:D(this.viewModel.departureIsoDate),onCalciteInputDatePickerChange:({currentTarget:{value:e}})=>{this.viewModel.departureIsoDate=e,this._solveRoute()}}),T("calcite-input-time-picker",{scale:"s",value:this.viewModel.departureIsoTime,onCalciteInputTimePickerChange:({currentTarget:{value:e}})=>{this.viewModel.departureIsoTime=e,this._solveRoute()}}))}_renderDirectionsFlowItem(){if("directions"!==this._currentFlowItem)return null;const e=this._getRouteCostSummary();if(!this._sections||!e)return null;const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel,o=this._sections.at(0)?.stop.name??"",r=this._sections.at(-1)?.stop.name??"";return T("calcite-flow-item",{key:"directions-flow-item",overlayPositioning:"fixed",selected:"directions"===this._currentFlowItem,onCalciteFlowItemBack:e=>{e.stopPropagation(),this._currentFlowItem="primary"}},T("div",{class:L.directionsHeader,slot:"header-content"},T("div",{class:L.headerStops},T("span",null,this.messages.from)," ",T("span",{class:L.directionsHeaderStopName},o),T("span",null,this.messages.to)," ",T("span",{class:L.directionsHeaderStopName},r)),T("div",{class:L.flexColumn},T("span",null,`${i} (${t})`),s?T("span",null,s):null)),this._renderRouteLayerActions({slot:"header-menu-actions"}),T("calcite-accordion",{class:L.accordion,iconPosition:"start",selectionMode:"single"},this._sections.map(((e,t)=>{const{stop:i,directions:s}=e,{name:o}=i;return T("calcite-accordion-item",{expanded:0===t,heading:o??"",key:`stop-${t}`},T("calcite-action",{icon:"zoom-to-object",onclick:()=>{this.viewModel.centerAt(i)},slot:"actions-end",text:this.messages.panToStop}),this._renderDirectionTurns(s))}))))}_renderDirectionTurns(e){return T("calcite-list",{label:this.messages.drivingDirections,selectionMode:"none"},e.map(((e,t)=>{const{directionPoint:i,directionLine:s}=e,{distance:o,duration:r}=s,a=y(this.messagesUnits,o??0,this.unit),n=b(r??0),l=a&&n?`${a} | ${n}`:`${a||n}`,c=C(i),d=S(i.directionPointType);return T("calcite-list-item",{class:L.labelNoBottomMargin,key:`driving-direction-${t}`,onpointerenter:()=>{this.viewModel.highlight(s)},onpointerleave:()=>{this.viewModel.clearHighlights()},onCalciteListItemSelect:()=>{this._activeManeuver===s?this.zoomToRoute():(this._activeManeuver=s,this.viewModel.centerAt(s.geometry))}},T("calcite-icon",{icon:d,slot:"content-start"}),T("div",{slot:"content"},T("calcite-label",{layout:"inline",scale:"s"},c),T("calcite-label",{layout:"inline",scale:"s"},l)))})))}_renderEditFlowItem(){return"edit"!==this._currentFlowItem?null:T("calcite-flow-item",{heading:this.messages.editRoute,headingLevel:this.headingLevel,key:"edit-flow-item",selected:"edit"===this._currentFlowItem,onCalciteFlowItemBack:e=>{e.stopPropagation(),this.viewModel.stopEditing(),this._currentFlowItem="primary"}},T("div",{class:L.flexColumn,key:"edit-container"},T("div",{class:L.editToolbarContainer},T("div",{class:L.editToolbar},T("calcite-action",{icon:"flag",key:"add-stop",onclick:()=>{this.viewModel.create("stop")},scale:"s",text:this.messages.networkFeatures.stops.stop,textEnabled:!0}),T("calcite-action",{icon:"line",key:"add-barrier",onclick:()=>{this.viewModel.create("polyline-barrier")},scale:"s",text:this.messages.barrier,textEnabled:!0}),T("calcite-action",{disabled:this.viewModel.autoSolve,icon:"refresh",key:"solve",onclick:()=>{this._solveRoute()},scale:"s",text:this.messages.solve}),T("calcite-action",{active:this.viewModel.autoSolve,icon:"app-update",key:"auto-solve",onclick:()=>{this.viewModel.autoSolve=!this.viewModel.autoSolve},scale:"s",text:this.messages.automaticallySolve}))),T("div",{class:L.selectedFeatureContainer},T("calcite-list",{label:this.messages.selectedNetworkFeatures,scale:"s",selectionMode:"none"},this.viewModel.selectedNetworkFeatures?.toArray().map(((e,t)=>T("calcite-list-item",{description:this._getNetworkFeatureName(e),key:`network-feature-${t}`,label:e.name??e.objectId?.toString()??this.messages.unnamed},T("calcite-action",{icon:"trash",onclick:()=>{this.viewModel.delete()},scale:"s",slot:"actions-end",text:this.messages.common.delete})))))),T("div",{class:L.editFooter},T("calcite-button",{onclick:e=>{e.stopPropagation(),this.viewModel.stopEditing(),this._currentFlowItem="primary"},scale:"m",width:"full"},this.messages.common.done))))}_renderFooter(){if(!this.viewModel.layer)return T("div",{class:L.primaryFooter,key:"footer-missing-layer"},T("calcite-notice",{icon:"information",open:!0},T("calcite-label",{class:L.labelNoBottomMargin,slot:"message"},this.messages.missingLayer)));if("unauthenticated"===this.viewModel.state)return T("div",{class:L.primaryFooterCentered,key:"footer-sign-in"},T("calcite-label",null,this.messages.signInRequired),T("calcite-button",{onclick:()=>{this.viewModel.load().catch((()=>{}))}},this.messages.common.auth.signIn));if("error"===this.viewModel.state&&!this.viewModel.serviceDescription)return T("div",{class:L.primaryFooter,key:"footer-service-error"},T("calcite-notice",{icon:"exclamation-mark-circle",kind:"danger",open:!0},T("calcite-label",{class:L.labelNoBottomMargin,slot:"message"},this._getErrorDescription())));if(!this.viewModel.layer?.routeInfo)return T("div",{class:L.primaryFooter,key:"footer-unsolved-route"},T("calcite-notice",{icon:"information",open:!0},T("calcite-label",{class:L.labelNoBottomMargin,slot:"message"},this.messages.directionsPlaceholder)));const e=this._getRouteCostSummary();if(!e||!this.viewModel.layer?.directionPoints)return T("div",{class:L.primaryFooter,key:"footer-invalid-route"},T("calcite-notice",{icon:"exclamation-mark-triangle",kind:"danger",open:!0},T("calcite-label",{class:L.labelNoBottomMargin,slot:"message"},this.messages.invalidRoute)));const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel;return T("div",{class:L.routeItem,key:"footer-directions-summary"},T("button",{"aria-busy":"false","aria-label":this.messages.viewDrivingDirections,"aria-live":"polite",class:L.routeItemButton,onclick:()=>{this._currentFlowItem="directions"},type:"button"},T("div",{class:L.routeItemButtonContent},T("span",{class:L.routeItemLabel},`${i} (${t})`),T("span",{class:L.routeItemDescription},s)),T("calcite-icon",{icon:"chevron-right",scale:"s"})),T("calcite-dropdown",null,T("calcite-action",{icon:"ellipsis",slot:"trigger",text:"Route actions"}),this._renderRouteLayerActions()))}_renderInteractiveRouteActions(){return T("div",{class:L.actionContainer,key:"interactive-route-action-container"},T("calcite-button",{appearance:"outline",class:L.addStopButton,iconStart:"plus",kind:"neutral",label:this.messages.addStop,onclick:()=>{const e=new u;this.viewModel.layer?.stops.add(new p({symbol:e}))},width:"half"},this.messages.addStop),T("calcite-button",{appearance:"outline",iconStart:"pencil",kind:"neutral",label:this.messages.editRoute,onclick:()=>{this._currentFlowItem="edit",this.viewModel.startEditing()},width:"half"},this.messages.editRoute))}_renderLocateStopAction(e){if(null!=e.name||null!=e.geometry)return null;const t=this.viewModel.layer?.stops.indexOf(e)??-1;return T("calcite-action",{icon:"select",key:`stop-location-action-${t}`,onclick:()=>this._handleLocateStopAction(e),scale:"s",slot:"actions-end",text:this.messages.pickALocationOnTheMap})}_renderOptimizeStopOrder(){const{routeParameters:e}=this.viewModel,{findBestSequence:t,preserveFirstStop:i,preserveLastStop:s}=e;return T("div",null,T("calcite-label",{layout:"inline-space-between",scale:"s"},this.messages.optimizeOrder,T("calcite-switch",{checked:t,scale:"s",onCalciteSwitchChange:({target:t})=>{e.findBestSequence=t.checked,t.checked||this._resetStopSequence(),this._solveRoute()}})),t?[T("calcite-label",{key:"preserve-first-stop",layout:"inline-space-between",scale:"s"},this.messages.preserveFirstStop,T("calcite-switch",{checked:i,scale:"s",onCalciteSwitchChange:({target:{checked:t}})=>{e.preserveFirstStop=t,this._resetStopSequence(),this._solveRoute()}})),T("calcite-label",{key:"preserve-last-stop",layout:"inline-space-between",scale:"s"},this.messages.preserveLastStop,T("calcite-switch",{checked:s,scale:"s",onCalciteSwitchChange:({target:{checked:t}})=>{e.preserveLastStop=t,this._resetStopSequence(),this._solveRoute()}}))]:null)}_renderPrimaryFlowItem(){return T("calcite-flow-item",{key:"primary-flow-item",loading:"initializing"===this.viewModel.state,selected:"primary"===this._currentFlowItem},T("calcite-panel",{class:L.primaryFlowItem,disabled:!this.viewModel.layer||"unauthenticated"===this.viewModel.state||"error"===this.viewModel.state&&!this.viewModel.serviceDescription},this._renderStops(),this._renderInteractiveRouteActions(),this._renderSeparator(),this._renderRouteSolveOptions()),this._renderFooter())}_renderRouteLayerActions(e){return[this._renderClearRouteAction(e),this._renderSaveLayerAction(e),this._renderSaveLayerAsAction(e),this._renderViewItemDetailsAction(e)]}_renderRouteSolveOptions(){return T("div",{class:L.marginInlineMedium,key:"route-solve-options"},this._renderTravelModes(),this._renderDepartureTime(),this._renderDepartureTimeOptions(),this._renderOptimizeStopOrder())}_renderSaveContent(){switch(this._saveState){case"initialized":return this._renderSaveInitialized();case"connect-to-portal":return this._renderSaveProcessing(this.messages.identity.lblSigning);case"connect-to-portal-error":return this._renderSaveError(this.messages.errors.authenticating);case"fetch-portal-information":return this._renderSaveProcessing(this.messages.processing.fetching);case"fetch-portal-information-error":return this._renderSaveError(this.messages.errors.fetching);case"save-layer":return this._renderSaveLayerSettings();case"saving":return this._renderSaveProcessing(this.messages.processing.saving);case"saving-error":return this._renderSaveError(this.messages.errors.saving)}}_renderSaveError(e){return T("calcite-panel",{class:L.paddingMedium,key:"save-layer-error"},T("div",{class:L.saveError},T("calcite-icon",{class:L.saveErrorIcon,icon:"exclamation-mark-triangle",scale:"l",textLabel:this.messages.common.errorMessage}),T("calcite-label",{class:L.saveErrorLabel},e)),T("calcite-button",{appearance:"outline",onclick:()=>{this._currentFlowItem=this._parentFlowItem},slot:"footer-actions",width:"full"},this.messages.common.close))}_renderSaveInitialized(){return T("calcite-panel",{class:L.paddingMedium,key:"save-layer-initialized"})}_renderSaveFlowItem(){return"save"!==this._currentFlowItem?null:T("calcite-flow-item",{heading:this.messages.saveLayer,headingLevel:this.headingLevel,key:"save-layer-flow-item",selected:"save"===this._currentFlowItem,onCalciteFlowItemBack:e=>{e.stopPropagation(),this._currentFlowItem=this._parentFlowItem}},this._renderSaveContent())}_renderSaveLayerAction(e){if(!this.visibleElements.saveButton)return null;const t=this.viewModel.layer,i=t?.routeInfo,s=t?.portalItem?.itemControl;return T("calcite-action",{disabled:!(!!i&&("admin"===s||"update"===s)),icon:"save",key:"save-route",onclick:()=>{this.viewModel.layer?.save()},...e,text:this.messages.common.save,textEnabled:!0})}_renderSaveLayerAsAction(e){if(!this.visibleElements.saveAsButton)return null;const t=!this.viewModel.layer?.routeInfo;return T("calcite-action",{disabled:t,icon:"save-as",key:"save-as-route",onclick:()=>{this._handleSaveLayerAsAction()},...e,text:this.messages.common.saveAs,textEnabled:!0})}_renderSaveLayerSettings(){if(null==this.layer||null==this._portalFolders||null==this._portalUserName)return this._renderSaveInitialized();const{stops:e}=this.layer,t=`${e.at(0).name} - ${e.at(-1).name}`,i=this._portalFolders.map((e=>T("calcite-combobox-item",{heading:e.title??"",key:`${$}-folder-${e.id}`,value:e.id})));return i.unshift(T("calcite-combobox-item",{heading:`${this._portalUserName} (${this.messages.common.home})`,key:`${$}-folder-home`,selected:!0,value:null})),T("calcite-panel",{key:"save-layer-panel"},T("div",{class:L.paddingMedium},T("calcite-label",null,this.messages.laverName,T("calcite-input",{afterCreate:e=>{this._portalItemNameInput=e},label:this.messages.laverName,value:t})),T("calcite-label",null,this.messages.saveInFolder,T("calcite-combobox",{afterCreate:e=>{this._portalFolderCombobox=e},label:this.messages.saveInFolder,overlayPositioning:"fixed",selectionMode:"single"},i))),T("calcite-button",{onclick:()=>{if(this._saveState="saving",null==this.layer||null==this._portalFolders)return;const e=this._portalItemNameInput?.value,t=this._portalFolderCombobox?.value,i=this._portalFolders.find((({id:e})=>e===t));this.layer.saveAs({title:e},{folder:i}).then((()=>{this._currentFlowItem=this._parentFlowItem})).catch((()=>{this._saveState="saving-error"}))},slot:"footer-actions",width:"full"},this.messages.common.save),T("calcite-button",{appearance:"outline",onclick:()=>{this._currentFlowItem=this._parentFlowItem},slot:"footer-actions",width:"full"},this.messages.common.cancel))}_renderSaveProcessing(e){return T("calcite-panel",{class:L.marginInlineMedium,key:"save-layer-processing"},T("calcite-loader",{class:L.saveProcessLoader,label:e,text:e}))}_renderSeparator(){return T("div",{class:L.separator,key:"separator"})}_renderStop(e){const t=this.acquireSearch(e);null!=e.name&&(t.searchTerm=e.name);const i=this.viewModel.layer?.stops??this._placeholderStops,s=this._renderLocateStopAction(e),o=i.length>2&&this._renderDeleteStopAction(e);return T("calcite-list-item",{key:e,value:e},s,o,T("div",{class:L.stopItem,slot:"content"},t.render()))}_renderStops(){const e=this.viewModel.layer?.stops??this._placeholderStops;for(const t of this._stopsToSearches.keys())e.includes(t)||this._disposeSearch(t);return T("div",{class:L.stopContainer,key:L.stopContainer},T("calcite-list",{class:L.stopList,dragEnabled:!0,label:this.messages.widgetLabel,scale:"s",onCalciteListOrderChange:({detail:t})=>{e.reorder(t.dragEl.value,t.newIndex),this._resetStopSequence(),this._solveRoute()}},e.toArray().map((e=>this._renderStop(e)))),e.length>1&&T("calcite-action",{icon:"arrow-up-down",onclick:()=>{e.reverse(),this._resetStopSequence(),this._solveRoute()},scale:"s",text:this.messages.reverseStops}))}_renderTravelModes(){return this.viewModel.travelModes.length?T("calcite-label",{key:"travel-modes",scale:"s"},this.messages.mode,T("calcite-combobox",{clearDisabled:!0,label:"mode",overlayPositioning:"fixed",scale:"s",selectionMode:"single",onCalciteComboboxChange:({currentTarget:e})=>{const{selectedItems:t}=e;t.length&&(this.viewModel.selectedTravelMode=t[0].value,this._solveRoute())}},this.viewModel.travelModes.map((e=>T("calcite-combobox-item",{heading:e.name,key:e.id,label:e.name,selected:this.viewModel.selectedTravelMode?.id===e.id,value:e}))))):null}_renderViewItemDetailsAction(e){if(!this.visibleElements.layerDetails)return null;const t=this.viewModel.layer?.portalItem;return T("calcite-action",{disabled:!t,icon:"launch",key:"open-route-details-link",onclick:()=>{t&&window.open(`${t.portal.url}/home/item.html?id=${t.id}`,"_blank")},...e,text:this.messages.viewLayerDetails,textEnabled:!0})}_resetStopSequence(){this.viewModel.layer?.stops.forEach((e=>{e.sequence=null}))}async _solveRoute(){this.viewModel.updateDepartureTime();const e=this.viewModel.layer?.stops.filter((({geometry:e})=>null!=e));if(e&&!(e.length<2))try{await this.viewModel.getDirections()}catch{}}};e([l()],A.prototype,"_currentFlowItem",void 0),e([l()],A.prototype,"_saveState",void 0),e([l()],A.prototype,"apiKey",null),e([l(m)],A.prototype,"defaultUnit",void 0),e([l()],A.prototype,"goToOverride",null),e([l()],A.prototype,"headingLevel",void 0),e([l()],A.prototype,"icon",null),e([l()],A.prototype,"label",null),e([l({readOnly:!0})],A.prototype,"lastRoute",null),e([l()],A.prototype,"layer",null),e([l()],A.prototype,"maxStops",null),e([l(),x("esri/widgets/Directions/t9n/Directions")],A.prototype,"messages",void 0),e([l(),x("esri/core/t9n/Units")],A.prototype,"messagesUnits",void 0),e([l()],A.prototype,"searchProperties",void 0),e([l()],A.prototype,"unit",null),e([l()],A.prototype,"view",null),e([l({type:_})],A.prototype,"viewModel",void 0),e([l({type:w,nonNullable:!0})],A.prototype,"visibleElements",void 0),A=e([c("esri.widgets.Directions")],A);const E=A;export{E 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.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import o from"../../core/Logger.js";import{abortMaybe as r}from"../../core/maybe.js";import{createResolver as s,onAbort as n,createAbortError as l,throwIfAborted as d,debounce as c}from"../../core/promiseUtils.js";import p from"../../core/Queue.js";import{whenOnce as u,when as w,watch as h,sync as f}from"../../core/reactiveUtils.js";import{last as g}from"../../core/SetUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as k}from"../../core/accessorSupport/decorators/subclass.js";import{getServiceInfoForLayer as v,getAllStandardFeatureTemplatesForLayer as y}from"../../editing/templateUtils.js";import{isEditableLayer as W}from"../../layers/support/editableLayers.js";import{isFeatureLayer as b,isSubtypeSublayer as C,isSubtypeGroupLayer as _,isTable as M}from"../../layers/support/layerUtils.js";import{getServices as A}from"../../undoredo/support/Services.js";import F from"../../views/draw/support/HighlightHelper.js";import{ViewEventPriorities as S}from"../../views/input/InputManager.js";import I from"../../views/interactive/sketch/SketchOptions.js";import{temporaryHighlightName as j}from"../../views/support/HighlightDefaults.js";import E from"./CreateFeaturesWorkflow.js";import{UpdateFeatureWorkflow as U}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as P}from"./UpdateRecordWorkflow.js";import L from"./UpdateWorkflowData.js";import V from"./Workflow.js";import{createWorkflowSteps as x,fetchCandidates as O}from"./workflowUtils.js";import{isGraphicForRelatableFeatureSupportedLayer as R}from"../Feature/support/featureUtils.js";var T;const H="esri.widgets.Editor.UpdateWorkflow",D=()=>o.getLogger(H);let N=T=class extends V{constructor(e){super(e),this._workflowStack=new p(g),this._sketchStack=new p(g),this.data=void 0,this.type="update"}get activeEditorItem(){return this.activeWorkflow?.data.editorItem??void 0}get activeFeatureFormViewModel(){return this.activeWorkflow?.featureFormViewModel}get activeSketchViewModel(){return this._sketchStack.peek()?.viewModel}get canDeleteAssociation(){const{activeFeatureFormViewModel:e}=this;if(!this.activeWorkflow||!this.data.viewModel.view||!e)return!1;const{activeAssociation:t,feature:a}=e;return!(!t||!a?.sourceLayer||!b(a?.sourceLayer)&&!C(a?.sourceLayer))}get activeWorkflow(){return this._workflowStack.last()}get updating(){return this._updatingHandles.updating||!!this.activeWorkflow?.updating}get hasPreviousStep(){const e=this.activeWorkflow?.featureFormViewModel;return this._stepIndex>0||this.nestedWorkflowCount>1||null!=e?.relationshipId||"view"!==this.data.viewModel.attachmentsViewModel.mode||null!=e?.associationId||null!=e?.associatedLayer}get hasUpdatableCandidates(){const{candidates:e,viewModel:t}=this.data;return e.some((({layer:e})=>t.findEditorItemForLayer(e)?.supportsUpdateWorkflow))}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return!!this.activeEditorItem?.capabilities.attachments.enabled}get shouldAllowAttachmentEditing(){return!!this.activeEditorItem?.capabilities.update.attachments.enabled}get hasPendingEdits(){return Array.from(this._workflowStack).some((e=>e.hasPendingEdits))}get helpMessage(){return this.activeWorkflow?.helpMessage?this.activeWorkflow.helpMessage:"awaiting-feature-to-update"===this.stepId?"select":void 0}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return!!this.activeEditorItem?.hasInvalidFormTemplate}async back(e=()=>Promise.resolve(!0)){const{activeWorkflow:t}=this,a=t?.featureFormViewModel;if(null==a?.relationshipId)if(null==a?.associatedLayer)if(null==a?.associationId)if(t){if(t.hasPendingEdits){if(!await e())return}t.hasPreviousStep?await t.previous({cancelCurrentStep:!0}):await this.cancelActiveWorkflow({force:!0})}else this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0});else a.associationId=null;else a.associatedLayer=null;else a.relationshipId=null}async cancelActiveWorkflow(e){await(this.activeWorkflow?.cancel(e)),await this._popWorkflow()}async commit(){await this._drainWorkflowStack((e=>e.commit())),await super.commit()}static create(e){const{viewModel:t,snappingManager:a,startAt:i,addAttachmentsCallback:o,applyEditsCallback:r,applyEditsAssociationCallback:s}=e,n=e.sketchOptions??new I,l=new T({data:new L({addAttachmentsCallback:o,applyEditsCallback:r,applyEditsAssociationCallback:s,sketchOptions:n,snappingManager:a,viewModel:t}),onCommit:async()=>{}});return l._set("steps",this._createWorkflowSteps(l,i)),l}async save(){this.nestedWorkflowCount>1?(await(this.activeWorkflow?.commit()),await this._popWorkflow()):await this.commit()}async startCreatingRelatedRecord(e){try{const t=await this._createNestedCreateFeaturesWorkflow(e);await this._pushWorkflow(t)}catch(t){throw new a("editor:unable-to-start-creating","Could not begin updating the provided feature or table record.",{error:t})}}async startUpdating(e,t){try{const a=await this._createNestedUpdateWorkflow(e,t);await this._pushWorkflow(a)}catch(i){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:i})}}async deleteActiveFeature(){const{activeWorkflow:e}=this;if(!e)throw new a("editor:nothing-to-delete","There is no feature to delete");z(e)?await e.deleteAndCommit():await e.cancel(),1===this.nestedWorkflowCount?await this.reset():(await this._popWorkflow(),await this._returnToPageWithContent())}async deleteActiveAssociation(){if(!this.canDeleteAssociation)throw new a("editor:nothing-to-delete","There is no association to delete");await this._deleteActiveAssociation(),await this._popWorkflow(),await this._returnToPageWithContent()}async cancelAll(){await this._drainWorkflowStack((e=>e.cancel({force:!0})))}async _deleteActiveAssociation(){const{activeFeatureFormViewModel:e,data:t}=this,{activeAssociation:i,feature:o}=e,{applyEditsAssociationCallback:r}=t,{view:s}=t.viewModel,n=await A(s).load(),l=v(n,o.sourceLayer)?.featureService,{utilityNetwork:d}=e.allAssociationInputs[0],c=d?.generateDeleteAssociations([i]),p=d?.gdbVersion??void 0;if(!l||!c)throw new a("editor:failed-to-delete-association","Could not create payload needed to delete association");await r(l,[c],{gdbVersion:p})}async _returnToPageWithContent(){const{activeFeatureFormViewModel:e}=this;if(!e?.activeAssociationInput)return;const{activeAssociationInput:t,associationId:a}=e;await t.refresh(),t.associatedLayer&&!t.associatedFeatures?.length&&(e.associatedLayer=null),null==a||t.associatedFeatureInfos.size||(e.associationId=null)}async _createNestedCreateFeaturesWorkflow(e){const{relatedLayer:t}=e,{addAttachmentsCallback:i,applyEditsCallback:o,sketchOptions:r,snappingManager:s,viewModel:n}=this.data;if(!W(t))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const l=this._getCreationInfoForNestedCreateFeaturesWorkflow(e),d=l.template||l.initialFeature?"creating-features":"awaiting-feature-creation-info",c="create-features"!==this.activeWorkflow?.type?this.activeWorkflow:void 0;return E.create({addAttachmentsCallback:i,applyEditsCallback:o,creationInfo:l,isNested:!0,parent:c,sketchOptions:r,snappingManager:s,startAt:d,viewModel:n})}_getCreationInfoForNestedCreateFeaturesWorkflow(e){const{relatedLayer:i}=e;if(!W(i)||_(i))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const o={layer:i,maxFeatures:1},r=this._makeRelatedRecordAttributes(e),s=y(i);return s?.length>0?(o.attributeOverrides=r,1===s.length&&(o.template=s[0])):o.initialFeature=new t({sourceLayer:i,attributes:r}),o}async _createNestedUpdateWorkflow(e,t){const a=M(e.sourceLayer)?P:U,{applyEditsCallback:i,applyEditsAssociationCallback:o,sketchOptions:r,snappingManager:s,viewModel:n}=this.data,l="create-features"!==this.activeWorkflow?.type?this.activeWorkflow:void 0,d=await a.create({association:t,feature:e,parent:l,sketchOptions:r,snappingManager:s,viewModel:n,applyEdits:i,applyEditsAssociation:o,featureFormCallbacks:{addRelatedRecord:async e=>await this.startCreatingRelatedRecord(e),editRelatedRecord:async({relatedFeature:e})=>await this.startUpdating(e),selectAssociatedFeature:async({feature:e,association:t})=>await this.startUpdating(e,t)}});return await u((()=>!d.updating)),d}async _drainWorkflowStack(e){const t=this._workflowStack,a=[];for(;t.length>0;){const i=t.pop();this._sketchStack.pop();const o=e(i).then((()=>i.destroy()));this._updatingHandles.addPromise(o),a.push(o)}await Promise.all(a)}_makeRelatedRecordAttributes(e){const{parentFeature:t,relatedLayer:a,relationshipId:i}=e;if(!R(t))return;const o=a.relationships?.find((e=>e.id===i));if(!o)return void G("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the destination layer.");if("origin"===o.role)return void G("unsupported-role","Creating new related records in the 'origin' table of a relationship is not yet supported");const r=t.sourceLayer;o.relatedTableId!==r.layerId&&G("invalid-argument-combination","The given parent feature does not belong to the relationship designated by the given relationship ID.");const s=r.relationships?.find((e=>e.id===i));if(!s)return void G("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the origin layer.");const n=q(r,s),l=t.getAttribute(n);l||G("no-key-on-origin-feature","The given parent feature does not have a value for the relationship's origin primary key field.");const d=q(a,o);return{[d]:l}}async _popWorkflow(){this._workflowStack.pop()?.destroy(),this._sketchStack.pop();const e=await this._reconcileWorkflowStack();if(e.failureCount>0)throw new a("editor:next-workflow-failed","Popped the top workflow, but the next workflow in the stack failed to activate",e)}async _pushWorkflow(e){const t=this._workflowRequiresSketchViewModel(e);this.activeWorkflow?.exit({removeSketchHandles:t});const i=this._sketchStack,o=await(e?.start()),r=i.peek();o?(r?.exit(),i.push(o)):i.push(this._cloneSketchController(r)),this._workflowStack.push(e);const s=await this._reconcileWorkflowStack();if(s.failureCount>0)throw new a("editor:failed-to-start-updating-feature","Failed to enter the provided workflow.",s)}async _reconcileWorkflowStack(){const e=this._workflowStack,t=this._sketchStack;try{const a=e.peek();return await(a?.enter()),await(t.peek()?.enter()),{activeWorkflow:a,failureCount:0}}catch(a){e.pop().destroy(),t.pop();const{activeWorkflow:i,failureCount:o}=await this._reconcileWorkflowStack();return{activeWorkflow:i,failureCount:o+1}}}_cloneSketchController(e){return{enter:e?.enter??(async()=>{}),exit:e?.exit??(async()=>{}),viewModel:e?.viewModel}}_workflowRequiresSketchViewModel(e){const{type:t}=e;return"update-feature"===t||"create-features"===t&&!M(e.data.creationInfo?.layer)}static _createWorkflowSteps(e,t="awaiting-feature-to-update"){const{data:o}=e;return x(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],t,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:t}=o.viewModel,a=o.viewModel.view;a.activeTool=null;let c=null;e.addHandles(i((()=>{c=r(c)})),this.id),o.rootFeature=null,o.candidates=[];const p=a.on("immediate-click",(async i=>{const r=s();e._updatingHandles.addPromise(r.promise);try{t.location=i.mapPoint,t.visible=!0,c?.abort();const{editorItems:r}=o.viewModel;c=new AbortController;const s=await i.async((()=>new Promise(((e,t)=>{n(c?.signal,(()=>t(l()))),e(O(r,a,i,c?.signal))}))));if(d(c),o.candidates=s.filter((e=>"fulfilled"===e.status)).flatMap((e=>e.value)).filter((e=>!e.isAggregate)),t.visible=1===o.candidates.length,0===o.candidates.length)return;i.stopPropagation(),1===o.candidates.length?(o.rootFeature=o.candidates[0],e.go("editing-existing-feature").catch((()=>{})).then((()=>t.visible=!1))):e.next()}finally{r.resolve()}}),S.TOOL),u=w((()=>null!=a.activeTool),(()=>e.cancel({force:!0})),{once:!0});a.focus(),e.addHandles([p,u],this.id)},async tearDown(){0===o.candidates.length&&(o.viewModel.spinnerViewModel.visible=!1),e.removeHandles(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){o.rootFeature=null;const{view:t}=o.viewModel;if(!t)return;const a=new F({view:t,highlightName:j});e.addHandles([h((()=>o.rootFeature),((e,t)=>{a.remove(t),a.add(e)}),f),i((()=>a.removeAll()))],this.id)},async tearDown(){e.removeHandles(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){const{rootFeature:t,viewModel:i}=e.data;if(!t)throw new a("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until the root feature is defined");await e.startUpdating(t),i.spinnerViewModel.visible=!1;const o=c((async()=>{await u((()=>!e.updating)),e.previous()}));e.addHandles([h((()=>e.nestedWorkflowCount),((e,t)=>{0===e&&0!==t&&o()}),f)],this.id)},async tearDown(){await e.cancelAll(),e.removeHandles(this.id)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){o.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){o.viewModel.attachmentsViewModel.mode="view"}})})}};function q(e,{keyField:t}){return e.getField(t)?.name??t}e([m()],N.prototype,"activeEditorItem",null),e([m()],N.prototype,"activeFeatureFormViewModel",null),e([m()],N.prototype,"activeSketchViewModel",null),e([m()],N.prototype,"canDeleteAssociation",null),e([m()],N.prototype,"activeWorkflow",null),e([m()],N.prototype,"updating",null),e([m()],N.prototype,"data",void 0),e([m()],N.prototype,"hasPreviousStep",null),e([m()],N.prototype,"hasUpdatableCandidates",null),e([m()],N.prototype,"nestedWorkflowCount",null),e([m()],N.prototype,"shouldShowAttachments",null),e([m()],N.prototype,"shouldAllowAttachmentEditing",null),e([m()],N.prototype,"hasPendingEdits",null),e([m()],N.prototype,"helpMessage",null),e([m()],N.prototype,"reliesOnOwnerAdminPrivileges",null),e([m()],N.prototype,"hasInvalidFormTemplate",null),N=T=e([k(H)],N);const G=(e,t)=>D().warn(`editor:${e}`,t,"The create operation will be allowed to proceed, but the resulting feature may not be related to the given parent feature."),z=e=>!!e&&/update-/.test(e.type),Q=N;export{Q as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import o from"../../core/Logger.js";import{abortMaybe as r}from"../../core/maybe.js";import{createResolver as s,onAbort as n,createAbortError as l,throwIfAborted as d,debounce as c}from"../../core/promiseUtils.js";import p from"../../core/Queue.js";import{whenOnce as u,when as h,watch as w,sync as f}from"../../core/reactiveUtils.js";import{last as g}from"../../core/SetUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as k}from"../../core/accessorSupport/decorators/subclass.js";import{getAllStandardFeatureTemplatesForLayer as v}from"../../editing/templateUtils.js";import{isEditableLayer as y}from"../../layers/support/editableLayers.js";import{isFeatureLayer as W,isSubtypeSublayer as b,isSubtypeGroupLayer as C,isTable as _}from"../../layers/support/layerUtils.js";import{createFeatureServices as M}from"../../rest/featureService/utils.js";import A from"../../views/draw/support/HighlightHelper.js";import{ViewEventPriorities as F}from"../../views/input/InputManager.js";import S from"../../views/interactive/sketch/SketchOptions.js";import{temporaryHighlightName as I}from"../../views/support/HighlightDefaults.js";import j from"./CreateFeaturesWorkflow.js";import{UpdateFeatureWorkflow as E}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as U}from"./UpdateRecordWorkflow.js";import P from"./UpdateWorkflowData.js";import L from"./Workflow.js";import{createWorkflowSteps as V,fetchCandidates as x}from"./workflowUtils.js";import{isGraphicForRelatableFeatureSupportedLayer as O}from"../Feature/support/featureUtils.js";var R;const T="esri.widgets.Editor.UpdateWorkflow",H=()=>o.getLogger(T);let D=R=class extends L{constructor(e){super(e),this._workflowStack=new p(g),this._sketchStack=new p(g),this.data=void 0,this.type="update"}get activeEditorItem(){return this.activeWorkflow?.data.editorItem??void 0}get activeFeatureFormViewModel(){return this.activeWorkflow?.featureFormViewModel}get activeSketchViewModel(){return this._sketchStack.peek()?.viewModel}get canDeleteAssociation(){const{activeFeatureFormViewModel:e}=this;if(!this.activeWorkflow||!this.data.viewModel.view||!e)return!1;const{activeAssociation:t,feature:a}=e;return!(!t||!a?.sourceLayer||!W(a?.sourceLayer)&&!b(a?.sourceLayer))}get activeWorkflow(){return this._workflowStack.last()}get updating(){return this._updatingHandles.updating||!!this.activeWorkflow?.updating}get hasPreviousStep(){const e=this.activeWorkflow?.featureFormViewModel;return this._stepIndex>0||this.nestedWorkflowCount>1||null!=e?.relationshipId||"view"!==this.data.viewModel.attachmentsViewModel.mode||null!=e?.associationId||null!=e?.associatedLayer}get hasUpdatableCandidates(){const{candidates:e,viewModel:t}=this.data;return e.some((({layer:e})=>t.findEditorItemForLayer(e)?.supportsUpdateWorkflow))}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return!!this.activeEditorItem?.capabilities.attachments.enabled}get shouldAllowAttachmentEditing(){return!!this.activeEditorItem?.capabilities.update.attachments.enabled}get hasPendingEdits(){return Array.from(this._workflowStack).some((e=>e.hasPendingEdits))}get helpMessage(){return this.activeWorkflow?.helpMessage?this.activeWorkflow.helpMessage:"awaiting-feature-to-update"===this.stepId?"select":void 0}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return!!this.activeEditorItem?.hasInvalidFormTemplate}async back(e=()=>Promise.resolve(!0)){const{activeWorkflow:t}=this,a=t?.featureFormViewModel;if(null==a?.relationshipId)if(null==a?.associatedLayer)if(null==a?.associationId)if(t){if(t.hasPendingEdits){if(!await e())return}t.hasPreviousStep?await t.previous({cancelCurrentStep:!0}):await this.cancelActiveWorkflow({force:!0})}else this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0});else a.associationId=null;else a.associatedLayer=null;else a.relationshipId=null}async cancelActiveWorkflow(e){await(this.activeWorkflow?.cancel(e)),await this._popWorkflow()}async commit(){await this._drainWorkflowStack((e=>e.commit())),await super.commit()}static create(e){const{viewModel:t,snappingManager:a,startAt:i,addAttachmentsCallback:o,applyEditsCallback:r,applyEditsAssociationCallback:s}=e,n=e.sketchOptions??new S,l=new R({data:new P({addAttachmentsCallback:o,applyEditsCallback:r,applyEditsAssociationCallback:s,sketchOptions:n,snappingManager:a,viewModel:t}),onCommit:async()=>{}});return l._set("steps",this._createWorkflowSteps(l,i)),l}async save(){this.nestedWorkflowCount>1?(await(this.activeWorkflow?.commit()),await this._popWorkflow()):await this.commit()}async startCreatingRelatedRecord(e){try{const t=await this._createNestedCreateFeaturesWorkflow(e);await this._pushWorkflow(t)}catch(t){throw new a("editor:unable-to-start-creating","Could not begin updating the provided feature or table record.",{error:t})}}async startUpdating(e,t){try{const a=await this._createNestedUpdateWorkflow(e,t);await this._pushWorkflow(a)}catch(i){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:i})}}async deleteActiveFeature(){const{activeWorkflow:e}=this;if(!e)throw new a("editor:nothing-to-delete","There is no feature to delete");G(e)?await e.deleteAndCommit():await e.cancel(),1===this.nestedWorkflowCount?await this.reset():(await this._popWorkflow(),await this._returnToPageWithContent())}async deleteActiveAssociation(){if(!this.canDeleteAssociation)throw new a("editor:nothing-to-delete","There is no association to delete");await this._deleteActiveAssociation(),await this._popWorkflow(),await this._returnToPageWithContent()}async cancelAll(){await this._drainWorkflowStack((e=>e.cancel({force:!0})))}async _deleteActiveAssociation(){const{activeFeatureFormViewModel:e,data:t}=this,{activeAssociation:i,feature:o}=e,{applyEditsAssociationCallback:r}=t,{sourceLayer:s}=o,n=b(s)&&s.parent?s.parent:s,l=M([n]),d=l.values().next().value?.featureService;if(!d)throw new a("editor:failed-to-delete-association","Could not retrieve feature service needed to delete association");await(d?.load());const{utilityNetwork:c}=e.allAssociationInputs[0],p=c?.generateDeleteAssociations([i]);if(!p)throw new a("editor:failed-to-delete-association","Could not create payload needed to delete association");const u=c?.gdbVersion??void 0;await r(d,[p],{gdbVersion:u})}async _returnToPageWithContent(){const{activeFeatureFormViewModel:e}=this;if(!e?.activeAssociationInput)return;const{activeAssociationInput:t,associationId:a}=e;await t.refresh(),t.associatedLayer&&!t.associatedFeatures?.length&&(e.associatedLayer=null),null==a||t.associatedFeatureInfos.size||(e.associationId=null)}async _createNestedCreateFeaturesWorkflow(e){const{relatedLayer:t}=e,{addAttachmentsCallback:i,applyEditsCallback:o,sketchOptions:r,snappingManager:s,viewModel:n}=this.data;if(!y(t))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const l=this._getCreationInfoForNestedCreateFeaturesWorkflow(e),d=l.template||l.initialFeature?"creating-features":"awaiting-feature-creation-info",c="create-features"!==this.activeWorkflow?.type?this.activeWorkflow:void 0;return j.create({addAttachmentsCallback:i,applyEditsCallback:o,creationInfo:l,isNested:!0,parent:c,sketchOptions:r,snappingManager:s,startAt:d,viewModel:n})}_getCreationInfoForNestedCreateFeaturesWorkflow(e){const{relatedLayer:i}=e;if(!y(i)||C(i))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const o={layer:i,maxFeatures:1},r=this._makeRelatedRecordAttributes(e),s=v(i);return s?.length>0?(o.attributeOverrides=r,1===s.length&&(o.template=s[0])):o.initialFeature=new t({sourceLayer:i,attributes:r}),o}async _createNestedUpdateWorkflow(e,t){const a=_(e.sourceLayer)?U:E,{applyEditsCallback:i,applyEditsAssociationCallback:o,sketchOptions:r,snappingManager:s,viewModel:n}=this.data,l="create-features"!==this.activeWorkflow?.type?this.activeWorkflow:void 0,d=await a.create({association:t,feature:e,parent:l,sketchOptions:r,snappingManager:s,viewModel:n,applyEdits:i,applyEditsAssociation:o,featureFormCallbacks:{addRelatedRecord:async e=>await this.startCreatingRelatedRecord(e),editRelatedRecord:async({relatedFeature:e})=>await this.startUpdating(e),selectAssociatedFeature:async({feature:e,association:t})=>await this.startUpdating(e,t)}});return await u((()=>!d.updating)),d}async _drainWorkflowStack(e){const t=this._workflowStack,a=[];for(;t.length>0;){const i=t.pop();this._sketchStack.pop();const o=e(i).then((()=>i.destroy()));this._updatingHandles.addPromise(o),a.push(o)}await Promise.all(a)}_makeRelatedRecordAttributes(e){const{parentFeature:t,relatedLayer:a,relationshipId:i}=e;if(!O(t))return;const o=a.relationships?.find((e=>e.id===i));if(!o)return void q("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the destination layer.");if("origin"===o.role)return void q("unsupported-role","Creating new related records in the 'origin' table of a relationship is not yet supported");const r=t.sourceLayer;o.relatedTableId!==r.layerId&&q("invalid-argument-combination","The given parent feature does not belong to the relationship designated by the given relationship ID.");const s=r.relationships?.find((e=>e.id===i));if(!s)return void q("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the origin layer.");const n=N(r,s),l=t.getAttribute(n);l||q("no-key-on-origin-feature","The given parent feature does not have a value for the relationship's origin primary key field.");const d=N(a,o);return{[d]:l}}async _popWorkflow(){this._workflowStack.pop()?.destroy(),this._sketchStack.pop();const e=await this._reconcileWorkflowStack();if(e.failureCount>0)throw new a("editor:next-workflow-failed","Popped the top workflow, but the next workflow in the stack failed to activate",e)}async _pushWorkflow(e){const t=this._workflowRequiresSketchViewModel(e);this.activeWorkflow?.exit({removeSketchHandles:t});const i=this._sketchStack,o=await(e?.start()),r=i.peek();o?(r?.exit(),i.push(o)):i.push(this._cloneSketchController(r)),this._workflowStack.push(e);const s=await this._reconcileWorkflowStack();if(s.failureCount>0)throw new a("editor:failed-to-start-updating-feature","Failed to enter the provided workflow.",s)}async _reconcileWorkflowStack(){const e=this._workflowStack,t=this._sketchStack;try{const a=e.peek();return await(a?.enter()),await(t.peek()?.enter()),{activeWorkflow:a,failureCount:0}}catch(a){e.pop().destroy(),t.pop();const{activeWorkflow:i,failureCount:o}=await this._reconcileWorkflowStack();return{activeWorkflow:i,failureCount:o+1}}}_cloneSketchController(e){return{enter:e?.enter??(async()=>{}),exit:e?.exit??(async()=>{}),viewModel:e?.viewModel}}_workflowRequiresSketchViewModel(e){const{type:t}=e;return"update-feature"===t||"create-features"===t&&!_(e.data.creationInfo?.layer)}static _createWorkflowSteps(e,t="awaiting-feature-to-update"){const{data:o}=e;return V(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],t,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:t}=o.viewModel,a=o.viewModel.view;a.activeTool=null;let c=null;e.addHandles(i((()=>{c=r(c)})),this.id),o.rootFeature=null,o.candidates=[];const p=a.on("immediate-click",(async i=>{const r=s();e._updatingHandles.addPromise(r.promise);try{t.location=i.mapPoint,t.visible=!0,c?.abort();const{editorItems:r}=o.viewModel;c=new AbortController;const s=await i.async((()=>new Promise(((e,t)=>{n(c?.signal,(()=>t(l()))),e(x(r,a,i,c?.signal))}))));if(d(c),o.candidates=s.filter((e=>"fulfilled"===e.status)).flatMap((e=>e.value)).filter((e=>!e.isAggregate)),t.visible=1===o.candidates.length,0===o.candidates.length)return;i.stopPropagation(),1===o.candidates.length?(o.rootFeature=o.candidates[0],e.go("editing-existing-feature").catch((()=>{})).then((()=>t.visible=!1))):e.next()}finally{r.resolve()}}),F.TOOL),u=h((()=>null!=a.activeTool),(()=>e.cancel({force:!0})),{once:!0});a.focus(),e.addHandles([p,u],this.id)},async tearDown(){0===o.candidates.length&&(o.viewModel.spinnerViewModel.visible=!1),e.removeHandles(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){o.rootFeature=null;const{view:t}=o.viewModel;if(!t)return;const a=new A({view:t,highlightName:I});e.addHandles([w((()=>o.rootFeature),((e,t)=>{a.remove(t),a.add(e)}),f),i((()=>a.removeAll()))],this.id)},async tearDown(){e.removeHandles(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){const{rootFeature:t,viewModel:i}=e.data;if(!t)throw new a("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until the root feature is defined");await e.startUpdating(t),i.spinnerViewModel.visible=!1;const o=c((async()=>{await u((()=>!e.updating)),e.previous()}));e.addHandles([w((()=>e.nestedWorkflowCount),((e,t)=>{0===e&&0!==t&&o()}),f)],this.id)},async tearDown(){await e.cancelAll(),e.removeHandles(this.id)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){o.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){o.viewModel.attachmentsViewModel.mode="view"}})})}};function N(e,{keyField:t}){return e.getField(t)?.name??t}e([m()],D.prototype,"activeEditorItem",null),e([m()],D.prototype,"activeFeatureFormViewModel",null),e([m()],D.prototype,"activeSketchViewModel",null),e([m()],D.prototype,"canDeleteAssociation",null),e([m()],D.prototype,"activeWorkflow",null),e([m()],D.prototype,"updating",null),e([m()],D.prototype,"data",void 0),e([m()],D.prototype,"hasPreviousStep",null),e([m()],D.prototype,"hasUpdatableCandidates",null),e([m()],D.prototype,"nestedWorkflowCount",null),e([m()],D.prototype,"shouldShowAttachments",null),e([m()],D.prototype,"shouldAllowAttachmentEditing",null),e([m()],D.prototype,"hasPendingEdits",null),e([m()],D.prototype,"helpMessage",null),e([m()],D.prototype,"reliesOnOwnerAdminPrivileges",null),e([m()],D.prototype,"hasInvalidFormTemplate",null),D=R=e([k(T)],D);const q=(e,t)=>H().warn(`editor:${e}`,t,"The create operation will be allowed to proceed, but the resulting feature may not be related to the given parent feature."),G=e=>!!e&&/update-/.test(e.type),z=D;export{z 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.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import{isTable as o}from"../../../layers/support/layerUtils.js";import i from"./EditorEditingCapabilities.js";import{formTemplateHasInvalidFields as l}from"../../FeatureForm/featureFormUtils.js";let a=class extends t{constructor(e){super(e),this.disabled=!1,this.layer=null,this.layerInfo=null,this.layerView=null}get _suspended(){return!!this.layerView?.suspended}get capabilities(){return new i({layer:this.layer,layerInfo:this.layerInfo,layerView:this.layerView})}get editable(){const{create:e,relationship:t,update:r,delete:{enabled:s}}=this.capabilities,o=e.attachments.enabled||r.attachments.enabled;return!this.disabled&&(e.enabled||r.enabled||o||s||t.enabled)}get formTemplate(){return this.capabilities.formTemplate}get hasInvalidFormTemplate(){return l(this.layer,this.formTemplate)}get isTable(){return o(this.layer)}get supportsCreateFeaturesWorkflow(){if(this.disabled)return!1;const{enabled:e,geometry:t}=this.capabilities.create;return this.isTable?e:e&&t}get supportsUpdateWorkflow(){const{capabilities:e}=this;return!this.disabled&&(e.update.enabled||e.update.attachments.enabled||e.delete.enabled)}get visible(){const{layer:e}=this,t=e.parent;return!this._suspended&&e.visible&&(!t||!("visible"in t)||t.visible)}};e([r()],a.prototype,"_suspended",null),e([r()],a.prototype,"capabilities",null),e([r()],a.prototype,"disabled",void 0),e([r()],a.prototype,"editable",null),e([r()],a.prototype,"formTemplate",null),e([r()],a.prototype,"hasInvalidFormTemplate",null),e([r()],a.prototype,"isTable",null),e([r()],a.prototype,"layer",void 0),e([r()],a.prototype,"layerInfo",void 0),e([r()],a.prototype,"layerView",void 0),e([r()],a.prototype,"supportsCreateFeaturesWorkflow",null),e([r()],a.prototype,"supportsUpdateWorkflow",null),e([r()],a.prototype,"visible",null),a=e([s("esri.widgets.Editor.support.EditorItem")],a);const p=a;export{p as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import{isTable as o}from"../../../layers/support/layerUtils.js";import{hasEffectiveFeatureExpressionInfo as i}from"../../../support/elevationInfoUtils.js";import l from"./EditorEditingCapabilities.js";import{formTemplateHasInvalidFields as a}from"../../FeatureForm/featureFormUtils.js";let p=class extends t{constructor(e){super(e),this.disabled=!1,this.layer=null,this.layerInfo=null,this.layerView=null}get _suspended(){return!!this.layerView?.suspended}get capabilities(){return new l({layer:this.layer,layerInfo:this.layerInfo,layerView:this.layerView})}get editable(){const{create:e,relationship:t,update:r,delete:{enabled:s}}=this.capabilities,o=e.attachments.enabled||r.attachments.enabled;return!this.disabled&&(e.enabled||r.enabled||o||s||t.enabled)}get formTemplate(){return this.capabilities.formTemplate}get hasInvalidFormTemplate(){return a(this.layer,this.formTemplate)}get isTable(){return o(this.layer)}get supportsCreateFeaturesWorkflow(){if(this.disabled)return!1;if("3d"===this.layerView?.view?.type&&i(this.layer.elevationInfo))return!1;const{enabled:e,geometry:t}=this.capabilities.create;return this.isTable?e:e&&t}get supportsUpdateWorkflow(){const{capabilities:e}=this;return!this.disabled&&(e.update.enabled||e.update.attachments.enabled||e.delete.enabled)}get visible(){const{layer:e}=this,t=e.parent;return!this._suspended&&e.visible&&(!t||!("visible"in t)||t.visible)}};e([r()],p.prototype,"_suspended",null),e([r()],p.prototype,"capabilities",null),e([r()],p.prototype,"disabled",void 0),e([r()],p.prototype,"editable",null),e([r()],p.prototype,"formTemplate",null),e([r()],p.prototype,"hasInvalidFormTemplate",null),e([r()],p.prototype,"isTable",null),e([r()],p.prototype,"layer",void 0),e([r()],p.prototype,"layerInfo",void 0),e([r()],p.prototype,"layerView",void 0),e([r()],p.prototype,"supportsCreateFeaturesWorkflow",null),e([r()],p.prototype,"supportsUpdateWorkflow",null),e([r()],p.prototype,"visible",null),p=e([s("esri.widgets.Editor.support.EditorItem")],p);const n=p;export{n 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.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../Graphic.js";import o from"../../../core/Accessor.js";import{watch as n,initial as r}from"../../../core/reactiveUtils.js";import{throttle as i}from"../../../core/throttle.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import p from"../../../geometry/Point.js";import"../../../popup/content/AttachmentsContent.js";import"../../../popup/content/Content.js";import"../../../popup/content/CustomContent.js";import"../../../popup/content/ExpressionContent.js";import a from"../../../popup/content/FieldsContent.js";import c from"../../../popup/content/MediaContent.js";import"../../../popup/content/RelationshipContent.js";import m from"../../../popup/content/TextContent.js";import"../../../popup/content/UtilityNetworkAssociationsContent.js";import d from"../../../popup/ElementExpressionInfo.js";import h from"../FeatureContent/FeatureContentViewModel.js";import u from"../FeatureFields/FeatureFieldsViewModel.js";import f from"../FeatureMedia/FeatureMediaViewModel.js";import{loadArcade as y,createCompiledExpression as _}from"../support/arcadeFeatureUtils.js";const w=1;let j=class extends o{constructor(t){super(t),this._abortController=null,this.expressionInfo=null,this.graphic=null,this.contentElement=null,this.contentElementViewModel=null,this.interceptor=null,this.location=null,this.view=null,this._cancelQuery=()=>{const{_abortController:t}=this;t&&t.abort(),this._abortController=null},this._createVM=()=>{const t=this.contentElement?.type;this.contentElementViewModel?.destroy();const e="fields"===t?new u:"media"===t?new f:"text"===t?new h:null;this._set("contentElementViewModel",e)},this._compile=async()=>{this._cancelQuery();const t=new AbortController;this._abortController=t,await this._compileExpression(),this._abortController===t&&(this._abortController=null)},this._compileThrottled=i(this._compile,w,this),this._compileExpression=async()=>{const{expressionInfo:t,graphic:e,interceptor:o,spatialReference:n,map:r,location:i,view:s,_abortController:l}=this;if(!t||!e)return void this._set("contentElement",null);const p=await y();if(l!==this._abortController)return;const d=await _({arcade:p,expressionInfo:t,graphic:e,location:i,interceptor:o,map:r,spatialReference:n,view:s});if(!d||"esri.arcade.Dictionary"!==d.declaredClass)return void this._set("contentElement",null);const h=await d.castAsJsonAsync(l?.signal),u=h?.type,f="media"===u?c.fromJSON(h):"text"===u?m.fromJSON(h):"fields"===u?a.fromJSON(h):null;"media"===f.type&&!f.mediaInfos||"fields"===f.type&&!f.fieldInfos||"text"===f.type&&!f.text?this._set("contentElement",null):this._set("contentElement",f)},this.addHandles([n((()=>[this.expressionInfo,this.graphic,this.map,this.spatialReference,this.view]),(()=>this._compileThrottled()),r),n((()=>[this.contentElement]),(()=>this._createVM()),r)])}initialize(){this.addHandles(this._compileThrottled)}destroy(){this._cancelQuery(),this.contentElementViewModel?.destroy(),this._set("contentElementViewModel",null),this._set("contentElement",null)}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(t){this._override("spatialReference",t)}get state(){const{_abortController:t,contentElement:e,contentElementViewModel:o}=this;return t?"loading":e||o?"ready":"disabled"}get map(){return this.view?.map??null}set map(t){this._override("map",t)}};t([s()],j.prototype,"_abortController",void 0),t([s({type:d})],j.prototype,"expressionInfo",void 0),t([s({type:e})],j.prototype,"graphic",void 0),t([s({readOnly:!0})],j.prototype,"contentElement",void 0),t([s({readOnly:!0})],j.prototype,"contentElementViewModel",void 0),t([s()],j.prototype,"interceptor",void 0),t([s({type:p})],j.prototype,"location",void 0),t([s()],j.prototype,"spatialReference",null),t([s({readOnly:!0})],j.prototype,"state",null),t([s()],j.prototype,"map",null),t([s()],j.prototype,"view",void 0),j=t([l("esri.widgets.Feature.FeatureExpression.FeatureExpressionViewModel")],j);const C=j;export{C as default};
5
+ import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../Graphic.js";import o from"../../../core/Accessor.js";import{createTask as s}from"../../../core/asyncUtils.js";import{abortMaybe as i}from"../../../core/maybe.js";import{throwIfAborted as n}from"../../../core/promiseUtils.js";import{watch as r,initial as a,when as l}from"../../../core/reactiveUtils.js";import{throttle as p}from"../../../core/throttle.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as m}from"../../../core/accessorSupport/decorators/subclass.js";import h from"../../../geometry/Point.js";import"../../../popup/content/AttachmentsContent.js";import"../../../popup/content/Content.js";import"../../../popup/content/CustomContent.js";import"../../../popup/content/ExpressionContent.js";import u from"../../../popup/content/FieldsContent.js";import d from"../../../popup/content/MediaContent.js";import"../../../popup/content/RelationshipContent.js";import f from"../../../popup/content/TextContent.js";import"../../../popup/content/UtilityNetworkAssociationsContent.js";import v from"../../../popup/ElementExpressionInfo.js";import _ from"../FeatureContent/FeatureContentViewModel.js";import y from"../FeatureFields/FeatureFieldsViewModel.js";import w from"../FeatureMedia/FeatureMediaViewModel.js";import{loadArcade as T,compileExpression as j}from"../support/arcadeFeatureUtils.js";const k=1;let g=class extends o{constructor(t){super(t),this._compileTask=null,this._evaluateTask=null,this.expressionInfo=null,this.graphic=null,this.contentElementViewModel=null,this.interceptor=null,this.location=null,this.view=null,this._createVM=()=>{const t=this.contentElement?.type;this.contentElementViewModel?.destroy();const e="fields"===t?new y:"media"===t?new w:"text"===t?new _:null;this._set("contentElementViewModel",e)},this._compileThrottled=p(this._startCompile,(()=>this.notifyChange("state")),k,this),this._evaluateThrottled=p(this._startEvaluate,(()=>this.notifyChange("state")),k,this),this.addHandles([r((()=>[this.expressionInfo,this.graphic]),(()=>this._compileThrottled()),a),r((()=>[this.contentElement]),(()=>this._createVM()),a),l((()=>{if(!this._compileTask?.finished)return null;const t=this._compileTask.value,e=t?.dependencies;return[t,this.spatialReference,this.map,this.view,e?.has("view-scale")?this.view?.scale:null,e?.has("view-time-extent")?this.view?.timeExtent?.start:null,e?.has("view-time-extent")?this.view?.timeExtent?.end:null]}),(([t])=>this._evaluateThrottled(t)))])}initialize(){this.addHandles([this._compileThrottled,this._evaluateThrottled])}destroy(){this._compileTask=i(this._compileTask),this._evaluateTask=i(this._evaluateTask),this.contentElementViewModel?.destroy(),this._set("contentElementViewModel",null)}get contentElement(){return this._evaluateTask?.value}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(t){this._override("spatialReference",t)}get state(){const{contentElement:t,contentElementViewModel:e}=this;return this._compileThrottled.hasPendingUpdates()||this._evaluateThrottled.hasPendingUpdates()||!this._compileTask?.finished||!this._evaluateTask?.finished?"loading":t||e?"ready":"disabled"}get map(){return this.view?.map??null}set map(t){this._override("map",t)}_startCompile(){this._evaluateTask=i(this._evaluateTask),this._compileTask=i(this._compileTask),this._compileTask=s((async t=>{const{expressionInfo:e,graphic:o}=this;if(!e||!o)return null;const s=await T();n(t);const i=await j({expressionInfo:e,arcade:s,graphic:o});return n(t),i}))}_startEvaluate(t){this._evaluateTask=i(this._evaluateTask),this._evaluateTask=s((async e=>{const{graphic:o}=this;if(!t||!o)return null;const{interceptor:s,spatialReference:i,map:r,location:a,view:l}=this,p=await t.evaluate({graphic:o,interceptor:s,location:a,map:r,options:{signal:e},spatialReference:i,view:l});n(e);const c=p;if(!c||"esri.arcade.Dictionary"!==c.declaredClass)return null;const m=await c.castAsJsonAsync(e);n(e);const h=m?.type,v="media"===h?d.fromJSON(m):"text"===h?f.fromJSON(m):"fields"===h?u.fromJSON(m):null;return"media"===v.type&&!v.mediaInfos||"fields"===v.type&&!v.fieldInfos||"text"===v.type&&!v.text?null:v}))}};t([c()],g.prototype,"_compileTask",void 0),t([c()],g.prototype,"_evaluateTask",void 0),t([c({type:v})],g.prototype,"expressionInfo",void 0),t([c({type:e})],g.prototype,"graphic",void 0),t([c({readOnly:!0})],g.prototype,"contentElement",null),t([c({readOnly:!0})],g.prototype,"contentElementViewModel",void 0),t([c()],g.prototype,"interceptor",void 0),t([c({type:h})],g.prototype,"location",void 0),t([c()],g.prototype,"spatialReference",null),t([c({readOnly:!0})],g.prototype,"state",null),t([c()],g.prototype,"map",null),t([c()],g.prototype,"view",void 0),g=t([m("esri.widgets.Feature.FeatureExpression.FeatureExpressionViewModel")],g);const E=g;export{E 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.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{FeatureSetQueryInterceptor as i}from"../../arcade/featureset/support/FeatureSetQueryInterceptor.js";import o from"../../core/Accessor.js";import{isSome as r}from"../../core/arrayUtils.js";import s from"../../core/Collection.js";import n from"../../core/Identifiable.js";import a from"../../core/Logger.js";import{isAbortError as l,eachAlways as c}from"../../core/promiseUtils.js";import{watch as p,on as d,whenOnce as u,initial as h}from"../../core/reactiveUtils.js";import{throttle as f}from"../../core/throttle.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import{cast as _}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import b from"../../geometry/Point.js";import g from"../../geometry/SpatialReference.js";import A from"../../popup/content/TextContent.js";import{getFeaturePopupTitle as w}from"../../support/popupUtils.js";import{system as I}from"../../time/timeZoneUtils.js";import M from"./FeatureAttachments/FeatureAttachmentsViewModel.js";import v from"./FeatureContent/FeatureContentViewModel.js";import C from"./FeatureExpression/FeatureExpressionViewModel.js";import F from"./FeatureFields/FeatureFieldsViewModel.js";import x from"./FeatureMedia/FeatureMediaViewModel.js";import V from"./FeatureRelationship/FeatureRelationshipViewModel.js";import{createCompiledExpressions as T}from"./support/arcadeFeatureUtils.js";import{createFieldInfoMap as E,getAllFieldInfos as j,getSourceLayer as P,querySourceLayer as R,isRelatableFeatureSupportedLayer as L,isAssociatedFeatureSupportedLayer as O,substituteFieldsInLinksAndAttributes as Z,isExpressionField as k,isRelatedField as N,formatEditInfo as U,graphicCallback as B,queryUpdatedFeature as S,formatAttributes as H,preLayerQueryCallback as D,preRequestCallback as G}from"./support/featureUtils.js";import{queryLayerInfos as q,queryRelatedFeatures as Q,setRelatedFeatures as z,getRelatedFieldInfo as J,createRelatedInfo as K,updateRelatedInfo as W}from"./support/relatedFeatureUtils.js";import X from"../support/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.js";var Y;const $=1,ee="content-view-models",te="relationship-view-models",ie="association-view-models",oe={attachmentsContent:!0,chartAnimation:!0,customContent:!0,expressionContent:!0,fieldsContent:!0,mediaContent:!0,textContent:!0,relationshipContent:!0,utilityNetworkAssociationsContent:!0};let re=Y=class extends(n.IdentifiableMixin(o)){constructor(e){super(e),this._error=null,this._featureAbortController=null,this._associationVMAbortController=null,this._graphicChangedThrottled=f(this._graphicChanged,$,this),this._expressionAttributes=null,this._graphicExpressionAttributes=null,this.abilities={...oe},this.content=null,this.contentViewModels=[],this.description=null,this.defaultPopupTemplateEnabled=!1,this.formattedAttributes=null,this.lastEditInfo=null,this.location=null,this.relatedInfos=new Map,this.title="",this.view=null,this._isAllowedContentType=e=>{const{abilities:t}=this;return"attachments"===e.type&&!!t.attachmentsContent||"custom"===e.type&&!!t.customContent||"fields"===e.type&&!!t.fieldsContent||"media"===e.type&&!!t.mediaContent||"text"===e.type&&!!t.textContent||"expression"===e.type&&!!t.expressionContent||"relationship"===e.type&&!!t.relationshipContent||"utility-network-associations"===e.type&&!!t.utilityNetworkAssociationsContent},this.addHandles(p((()=>[this.graphic,this._effectivePopupTemplate,this.abilities,this.timeZone]),(()=>this._graphicChangedThrottled()),h))}initialize(){this.addHandles(this._graphicChangedThrottled)}destroy(){this._clear(),this._cancelFeatureQuery(),this._error=null,this.graphic=null,this._destroyContentViewModels(),this.relatedInfos.clear()}get _effectivePopupTemplate(){return null!=this.graphic?this.graphic.getEffectivePopupTemplate(this.defaultPopupTemplateEnabled):null}get _fieldInfoMap(){return E(j(this._effectivePopupTemplate),this._sourceLayer)}get _sourceLayer(){return P(this.graphic)}castAbilities(e){return{...oe,...e}}get isTable(){return this._sourceLayer?.isTable||!1}get state(){return this.graphic?this._error?"error":this.waitingForContent?"loading":"ready":"disabled"}set graphic(e){this._featureAbortController=new AbortController,this._set("graphic",e?.clone()??null)}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get timeZone(){return this.view?.timeZone??I}set timeZone(e){this._overrideIfSome("timeZone",e)}get map(){return this.view?.map||null}set map(e){this._override("map",e)}get waitingForContent(){return!(!this._featureAbortController&&!this._associationVMAbortController)}setActiveMedia(e,t){const i=this.contentViewModels[e];i instanceof x&&i.setActiveMedia(t)}nextMedia(e){const t=this.contentViewModels[e];t instanceof x&&t.next()}previousMedia(e){const t=this.contentViewModels[e];t instanceof x&&t.previous()}async updateGeometry(){const{graphic:e,spatialReference:t,_sourceLayer:i}=this;await(i?.load());const o=i?.objectIdField;if(!o||!e||!i)return;const r=e?.attributes?.[o];if(null==r)return;const s=[r];if(!e.geometry){const o=await R({layer:i,graphic:e,outFields:[],objectIds:s,returnGeometry:!0,spatialReference:t}),r=o?.geometry;r&&(e.geometry=r)}}_clear(){this._set("title",""),this._set("content",null),this._set("formattedAttributes",null)}async _graphicChanged(){this._cancelFeatureQuery(),this._error=null,this._clear();const{graphic:e}=this;if(!e)return;const t=new AbortController;this._featureAbortController=t;try{await this._queryFeature({signal:t.signal})}catch(i){l(i)||(this._error=i,a.getLogger(this).error("error","The popupTemplate could not be displayed for this feature.",{error:i,graphic:e,popupTemplate:this._effectivePopupTemplate}))}this._featureAbortController===t&&(this._featureAbortController=null)}_cancelFeatureQuery(){const{_featureAbortController:e}=this;e&&e.abort(),this._featureAbortController=null}_compileContentElement(e,t){return"attachments"===e.type?this._compileAttachments(e,t):"custom"===e.type?this._compileCustom(e,t):"fields"===e.type?this._compileFields(e,t):"media"===e.type?this._compileMedia(e,t):"text"===e.type?this._compileText(e,t):"expression"===e.type?this._compileExpression(e,t):"relationship"===e.type?this._compileRelationship(e,t):"utility-network-associations"===e.type?this._compileUtilityNetworkAssociation(e,t):void 0}_compileContent(e){if(this._destroyContentViewModels(),this.graphic)return Array.isArray(e)?e.filter(this._isAllowedContentType).map(((e,t)=>this._compileContentElement(e,t))).filter(r):"string"==typeof e?this._compileText(new A({text:e}),0).text:e}_destroyContentViewModels(){this.removeHandles(te),this.removeHandles(ee),this.contentViewModels.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("contentViewModels",[])}_matchesFeature(e,t){const i=e?.graphic?.getObjectId(),o=t?.getObjectId();return null!=i&&null!=o&&i===o}_setRelatedFeaturesViewModels({relatedFeatureViewModels:e,relatedFeatures:t,map:i}){const{view:o,spatialReference:r,timeZone:s}=this;t?.filter(Boolean).forEach((t=>{e.some((e=>this._matchesFeature(e,t)))||e.add(new Y({abilities:{relationshipContent:!1},map:i,view:o,spatialReference:r,timeZone:s,graphic:t}))})),e.forEach((i=>{const o=t?.find((e=>this._matchesFeature(i,e)));o||e.remove(i)}))}_setExpressionContentVM(e,t){const i=this.formattedAttributes,{contentElement:o,contentElementViewModel:r}=e,s=o?.type;r&&s&&("fields"===s&&(this._createFieldsFormattedAttributes({contentElement:o,contentElementIndex:t,formattedAttributes:i}),r.set(this._createFieldsVMParams(o,t))),"media"===s&&(this._createMediaFormattedAttributes({contentElement:o,contentElementIndex:t,formattedAttributes:i}),r.set(this._createMediaVMParams(o,t))),"text"===s&&r.set(this._createTextVMParams(o)))}_compileRelationship(e,t){const{displayCount:i,orderByFields:o,relationshipId:r,title:s,description:n}=e,{_sourceLayer:a,graphic:l,map:c}=this;if(!L(a))return;const p=new V({displayCount:i,graphic:l,orderByFields:o,relationshipId:r,layer:a,map:c,...this._compileTitleAndDesc({title:s,description:n})});return this.contentViewModels[t]=p,this.addHandles(d((()=>p.relatedFeatures),"change",(()=>this._setRelatedFeaturesViewModels(p))),te),e}_matchesGlobalFeature(e,t){const i=e?.association.globalId,o=t?.association.globalId;return null!=i&&null!=o&&i===o}async _setUpUtilityNetworkAssociationsViewModels(e,t,i){const{view:o,spatialReference:r,timeZone:n}=this;e.forEach(((i,o)=>{const r=t.get(o);r?i.forEach((t=>{r.find((e=>this._matchesGlobalFeature(t,e)))||(i.remove(t),0===i.length&&e.delete(o))})):(i.removeAll(),e.delete(o))})),t.forEach(((t,a)=>{const l=e.get(a)||new s;t?.filter(Boolean).forEach((e=>{l.some((t=>this._matchesGlobalFeature(t,e)))||l.add({association:e.association,featureViewModel:new Y({abilities:{utilityNetworkAssociationsContent:!1},map:i,view:o,spatialReference:r,timeZone:n,graphic:e.feature}),terminalName:e.terminalName})})),e.set(a,l)}));const a=new AbortController;this._associationVMAbortController=a,await this._sortListObjectsByTitle(e,{signal:a.signal}),this._associationVMAbortController===a&&(this._associationVMAbortController=null)}async _sortListObjectsByTitle(e,t){for(const i of e.values()){const e=i.map((e=>u((()=>"ready"===e.featureViewModel.state),t?.signal)));await Promise.all(e),i.sort(this._compareByFeatureTitle)}}_compareByFeatureTitle(e,t){const i=w(e.featureViewModel),o=w(t.featureViewModel);return i.localeCompare(o,void 0,{numeric:!0})}_compileUtilityNetworkAssociation(e,t){const{displayCount:i,title:o,description:r,associationTypes:s}=e,{_sourceLayer:n,graphic:a,map:l}=this;if(!O(n))return;const c=new X({graphic:a,displayCount:i,associationTypes:s,layer:n,map:l,...this._compileTitleAndDesc({title:o,description:r})});return this.contentViewModels[t]=c,this.addHandles([p((()=>c.associationFeatures.values()),(()=>this._setUpUtilityNetworkAssociationsViewModels(c.associationViewModels,c.associationFeatures,c.map)))],ie),e}_compileExpression(e,t){const{expressionInfo:i}=e,{graphic:o,map:r,spatialReference:s,view:n,location:a}=this,l=new C({expressionInfo:i,graphic:o,interceptor:Y.interceptor,map:r,spatialReference:s,view:n,location:a});return this.contentViewModels[t]=l,this.addHandles(p((()=>l.contentElementViewModel),(()=>this._setExpressionContentVM(l,t)),h),ee),e}_compileAttachments(e,t){const{graphic:i}=this,{description:o,title:r}=e;return this.contentViewModels[t]=new M({graphic:i,...this._compileTitleAndDesc({title:r,description:o})}),e}_compileCustom(e,t){const{graphic:i}=this,{creator:o,destroyer:r}=e;return this.contentViewModels[t]=new v({graphic:i,creator:o,destroyer:r}),e}_compileTitleAndDesc({title:e,description:t}){const{_fieldInfoMap:i,_sourceLayer:o,graphic:r,formattedAttributes:s}=this,n=r?.attributes,a=this._expressionAttributes,l=s.global;return{title:Z({attributes:n,fieldInfoMap:i,globalAttributes:l,expressionAttributes:a,layer:o,text:e}),description:Z({attributes:n,fieldInfoMap:i,globalAttributes:l,expressionAttributes:a,layer:o,text:t})}}_createFieldsVMParams(e,t){const i=this._effectivePopupTemplate,o=this.formattedAttributes,r={...o?.global,...o?.content[t]},s=e?.fieldInfos||i?.fieldInfos,n=s?.filter((({fieldName:e})=>!!e&&(k(e)||N(e)||r.hasOwnProperty(e)))),a=i?.expressionInfos,{description:l,title:c}=e;return{attributes:r,expressionInfos:a,fieldInfos:n,...this._compileTitleAndDesc({title:c,description:l})}}_compileFields(e,t){const i=e.clone(),o=new F(this._createFieldsVMParams(e,t));return this.contentViewModels[t]=o,i.fieldInfos=o.formattedFieldInfos.slice(),i}_createMediaVMParams(e,t){const{abilities:i,graphic:o,_fieldInfoMap:r,_effectivePopupTemplate:s,relatedInfos:n,_sourceLayer:a,_expressionAttributes:l}=this,c=this.formattedAttributes,p=o?.attributes??{},{description:d,mediaInfos:u,title:h}=e;return{abilities:{chartAnimation:i.chartAnimation},activeMediaInfoIndex:e.activeMediaInfoIndex||0,attributes:p,isAggregate:o?.isAggregate,layer:a,fieldInfoMap:r,formattedAttributes:{...c?.global,...c?.content[t]},expressionAttributes:l,mediaInfos:u,popupTemplate:s,relatedInfos:n,...this._compileTitleAndDesc({title:h,description:d})}}_compileMedia(e,t){const i=e.clone(),o=new x(this._createMediaVMParams(e,t));return i.mediaInfos=o.formattedMediaInfos.slice(),this.contentViewModels[t]=o,i}_createTextVMParams(e){const{graphic:t,_fieldInfoMap:i,_sourceLayer:o,_expressionAttributes:r}=this;if(e&&e.text){const s=t?.attributes??{},n=this.formattedAttributes?.global??{};e.text=Z({attributes:s,fieldInfoMap:i,globalAttributes:n,expressionAttributes:r,layer:o,text:e.text})}return{graphic:t,creator:e.text}}_compileText(e,t){const i=e.clone();return this.contentViewModels[t]=new v(this._createTextVMParams(i)),i}_compileLastEditInfo(){const{_effectivePopupTemplate:e,_sourceLayer:t,graphic:i,timeZone:o}=this;if(!e)return;const{lastEditInfoEnabled:r}=e,s=t?.editFieldsInfo;return r&&s?U(s,i?.attributes,o,t):void 0}_compileTitle(e){const{_fieldInfoMap:t,_sourceLayer:i,graphic:o,_expressionAttributes:r}=this,s=o?.attributes??{},n=this.formattedAttributes?.global??{};return Z({attributes:s,fieldInfoMap:t,globalAttributes:n,expressionAttributes:r,layer:i,text:e})}async _getTitle(){const{_effectivePopupTemplate:e,graphic:t}=this;return t?B({type:"title",value:e?.title,event:{graphic:t}}):null}async _getContent(){const{_effectivePopupTemplate:e,graphic:t}=this;return t?B({type:"content",value:e?.content,event:{graphic:t}}):null}async _queryFeature(e){const{_featureAbortController:t,_sourceLayer:i,graphic:o,_effectivePopupTemplate:r}=this,s=this.map,n=this.view,a=this.spatialReference,l=this.location;if(t!==this._featureAbortController||!o)return;await S({graphic:o,popupTemplate:r,layer:i,spatialReference:a},e);const{content:{value:p},title:{value:d}}=await c({content:this._getContent(),title:this._getTitle()}),{expressionAttributes:{value:u}}=await c({checkForRelatedFeatures:this._checkForRelatedFeatures(e),expressionAttributes:T({expressionInfos:r?.expressionInfos,spatialReference:a,graphic:o,map:s,interceptor:Y.interceptor,view:n,options:e,location:l})});t===this._featureAbortController&&o&&(this._expressionAttributes=u,this._graphicExpressionAttributes={...o.attributes,...u},this._set("formattedAttributes",this._createFormattedAttributes(p)),this._set("title",this._compileTitle(d)),this._set("lastEditInfo",this._compileLastEditInfo()||null),this._set("content",this._compileContent(p)||null))}_createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:i}){const{_effectivePopupTemplate:o,graphic:r,relatedInfos:s,_sourceLayer:n,_fieldInfoMap:a,_graphicExpressionAttributes:l,timeZone:c}=this;i.content[t]=H({fieldInfos:o?.fieldInfos,graphic:r,attributes:{...l,...e.attributes},layer:n,fieldInfoMap:a,relatedInfos:s,timeZone:c})}_createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:i}){if(e.fieldInfos){const{graphic:o,relatedInfos:r,_sourceLayer:s,_fieldInfoMap:n,_graphicExpressionAttributes:a,timeZone:l}=this;i.content[t]=H({fieldInfos:e.fieldInfos,graphic:o,attributes:{...a,...e.attributes},layer:s,fieldInfoMap:n,relatedInfos:r,timeZone:l})}}_createFormattedAttributes(e){const{_effectivePopupTemplate:t,graphic:i,relatedInfos:o,_sourceLayer:r,_fieldInfoMap:s,_graphicExpressionAttributes:n,timeZone:a}=this,l=t?.fieldInfos,c={global:H({fieldInfos:l,graphic:i,attributes:n,layer:r,fieldInfoMap:s,relatedInfos:o,timeZone:a}),content:[]};return Array.isArray(e)&&e.forEach(((e,t)=>{"fields"===e.type&&this._createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:c}),"media"===e.type&&this._createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:c})})),c}_checkForRelatedFeatures(e){const{graphic:t,_effectivePopupTemplate:i}=this;return this._queryRelatedInfos(t,j(i),e)}async _queryRelatedInfos(e,t,i){const{relatedInfos:o,_sourceLayer:r}=this;o.clear();const s=null!=r?.associatedLayer?await(r?.associatedLayer.load(i)):r;if(!s||!e)return;const n=t.filter((e=>!!e.fieldName&&N(e.fieldName)));if(!n?.length)return;t.forEach((e=>this._configureRelatedInfo(e,s)));const a=await q({relatedInfos:o,layer:s},i);Object.keys(a).forEach((e=>{const t=o.get(e.toString()),i=a[e]?.value;t&&i&&(t.layerInfo=i.data)}));const l=await Q({graphic:e,relatedInfos:o,layer:s},i);Object.keys(l).forEach((e=>{z(l[e]?.value,o.get(e.toString()))}))}_configureRelatedInfo(e,t){const{relatedInfos:i}=this,o=J(e.fieldName||"");if(!o)return;const{layerId:r,fieldName:s}=o;if(!r)return;const n=i.get(r.toString())||K(r,t);n&&(W({relatedInfo:n,fieldName:s,fieldInfo:e}),this.relatedInfos.set(r,n))}};re.interceptor=new i(D,G),e([m()],re.prototype,"_error",void 0),e([m()],re.prototype,"_featureAbortController",void 0),e([m()],re.prototype,"_associationVMAbortController",void 0),e([m({readOnly:!0})],re.prototype,"_effectivePopupTemplate",null),e([m({readOnly:!0})],re.prototype,"_fieldInfoMap",null),e([m({readOnly:!0})],re.prototype,"_sourceLayer",null),e([m()],re.prototype,"abilities",void 0),e([_("abilities")],re.prototype,"castAbilities",null),e([m({readOnly:!0})],re.prototype,"content",void 0),e([m({readOnly:!0})],re.prototype,"contentViewModels",void 0),e([m()],re.prototype,"description",void 0),e([m({type:Boolean})],re.prototype,"defaultPopupTemplateEnabled",void 0),e([m({readOnly:!0})],re.prototype,"isTable",null),e([m({readOnly:!0})],re.prototype,"state",null),e([m({readOnly:!0})],re.prototype,"formattedAttributes",void 0),e([m({type:t,value:null})],re.prototype,"graphic",null),e([m({readOnly:!0})],re.prototype,"lastEditInfo",void 0),e([m({type:b})],re.prototype,"location",void 0),e([m({readOnly:!0})],re.prototype,"relatedInfos",void 0),e([m({type:g})],re.prototype,"spatialReference",null),e([m()],re.prototype,"timeZone",null),e([m({readOnly:!0})],re.prototype,"title",void 0),e([m()],re.prototype,"map",null),e([m({readOnly:!0})],re.prototype,"waitingForContent",null),e([m()],re.prototype,"view",void 0),re=Y=e([y("esri.widgets.Feature.FeatureViewModel")],re);const se=re;export{se as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{FeatureSetQueryInterceptor as i}from"../../arcade/featureset/support/FeatureSetQueryInterceptor.js";import s from"../../core/Accessor.js";import{isSome as o}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import n from"../../core/Identifiable.js";import l from"../../core/Logger.js";import{abortMaybe as p}from"../../core/maybe.js";import{eachAlways as c,isAbortError as d,throwIfAborted as h}from"../../core/promiseUtils.js";import{watch as u,when as f,on as m,whenOnce as _,initial as y}from"../../core/reactiveUtils.js";import{throttle as g}from"../../core/throttle.js";import{property as b}from"../../core/accessorSupport/decorators/property.js";import{cast as w}from"../../core/accessorSupport/decorators/cast.js";import"../../core/has.js";import{subclass as v}from"../../core/accessorSupport/decorators/subclass.js";import A from"../../geometry/Point.js";import I from"../../geometry/SpatialReference.js";import M from"../../popup/content/TextContent.js";import{getFeaturePopupTitle as x}from"../../support/popupUtils.js";import{system as T}from"../../time/timeZoneUtils.js";import C from"./FeatureAttachments/FeatureAttachmentsViewModel.js";import E from"./FeatureContent/FeatureContentViewModel.js";import F from"./FeatureExpression/FeatureExpressionViewModel.js";import V from"./FeatureFields/FeatureFieldsViewModel.js";import j from"./FeatureMedia/FeatureMediaViewModel.js";import k from"./FeatureRelationship/FeatureRelationshipViewModel.js";import{compileExpressionInfos as P,formatArcadeValue as R}from"./support/arcadeFeatureUtils.js";import{createFieldInfoMap as L,getAllFieldInfos as O,getSourceLayer as U,querySourceLayer as Z,isRelatableFeatureSupportedLayer as N,isAssociatedFeatureSupportedLayer as B,substituteFieldsInLinksAndAttributes as S,isExpressionField as H,isRelatedField as D,formatEditInfo as G,graphicCallback as q,formatAttributes as z,preLayerQueryCallback as Q,preRequestCallback as J,queryUpdatedFeature as K}from"./support/featureUtils.js";import{queryLayerInfos as W,queryRelatedFeatures as X,setRelatedFeatures as Y,getRelatedFieldInfo as $,createRelatedInfo as ee,updateRelatedInfo as te}from"./support/relatedFeatureUtils.js";import ie from"../support/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.js";var se;const oe=1,re="content-view-models",ae="relationship-view-models",ne="association-view-models",le={attachmentsContent:!0,chartAnimation:!0,customContent:!0,expressionContent:!0,fieldsContent:!0,mediaContent:!0,textContent:!0,relationshipContent:!0,utilityNetworkAssociationsContent:!0};let pe=se=class extends(n.IdentifiableMixin(s)){constructor(e){super(e),this._error=null,this._graphicChangedTask=null,this._evaluateExpressionAttributesTask=null,this._associationVMAbortController=null,this._expressionAttributes=null,this._graphicExpressionAttributes=null,this.abilities={...le},this.content=null,this.contentViewModels=[],this.description=null,this.defaultPopupTemplateEnabled=!1,this.formattedAttributes=null,this.lastEditInfo=null,this.location=null,this.relatedInfos=new Map,this.title="",this.view=null,this._graphicChangedThrottled=g(this._graphicChanged,(()=>this.notifyChange("waitingForContent")),oe,this),this._isAllowedContentType=e=>{const{abilities:t}=this;return"attachments"===e.type&&!!t.attachmentsContent||"custom"===e.type&&!!t.customContent||"fields"===e.type&&!!t.fieldsContent||"media"===e.type&&!!t.mediaContent||"text"===e.type&&!!t.textContent||"expression"===e.type&&!!t.expressionContent||"relationship"===e.type&&!!t.relationshipContent||"utility-network-associations"===e.type&&!!t.utilityNetworkAssociationsContent},this._evaluateExpressionAttributesThrottled=g(this._evaluateExpressionAttributes,(()=>this.notifyChange("waitingForContent")),oe,this),this.addHandles([u((()=>[this.graphic,this._effectivePopupTemplate,this.abilities,this.timeZone]),(()=>this._graphicChangedThrottled()),y),f((()=>{if(!this._graphicChangedTask?.finished||null==this._graphicChangedTask.value)return null;const e=this._graphicChangedTask.value,t=e?.expressionInfos?.dependencies;return[e,t?.has("view-scale")?this.view?.scale:null,t?.has("view-time-extent")?this.view?.timeExtent?.start:null,t?.has("view-time-extent")?this.view?.timeExtent?.end:null]}),(([e])=>this._evaluateExpressionAttributesThrottled(e)))])}initialize(){this.addHandles([this._graphicChangedThrottled,this._evaluateExpressionAttributesThrottled])}destroy(){this._clear(),this._graphicChangedTask=p(this._graphicChangedTask),this._evaluateExpressionAttributesTask=p(this._evaluateExpressionAttributesTask),this._error=null,this.graphic=null,this._destroyContentViewModels(),this.relatedInfos.clear()}get _effectivePopupTemplate(){return null!=this.graphic?this.graphic.getEffectivePopupTemplate(this.defaultPopupTemplateEnabled):null}get _fieldInfoMap(){return L(O(this._effectivePopupTemplate),this._sourceLayer)}get _sourceLayer(){return U(this.graphic)}castAbilities(e){return{...le,...e}}get isTable(){return this._sourceLayer?.isTable||!1}get state(){return this.graphic?this._error?"error":this.waitingForContent?"loading":"ready":"disabled"}set graphic(e){this._set("graphic",e?.clone()??null)}get spatialReference(){return this.view?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get timeZone(){return this.view?.timeZone??T}set timeZone(e){this._overrideIfSome("timeZone",e)}get map(){return this.view?.map||null}set map(e){this._override("map",e)}get waitingForContent(){const{_graphicChangedThrottled:e,_evaluateExpressionAttributesThrottled:t,_graphicChangedTask:i,_evaluateExpressionAttributesTask:s,_associationVMAbortController:o}=this;return e.hasPendingUpdates()||t.hasPendingUpdates()||null!=i&&!i.finished||null!=s&&!s.finished||!!o}setActiveMedia(e,t){const i=this.contentViewModels[e];i instanceof j&&i.setActiveMedia(t)}nextMedia(e){const t=this.contentViewModels[e];t instanceof j&&t.next()}previousMedia(e){const t=this.contentViewModels[e];t instanceof j&&t.previous()}async updateGeometry(){const{graphic:e,spatialReference:t,_sourceLayer:i}=this;await(i?.load());const s=i?.objectIdField;if(!s||!e||!i)return;const o=e?.attributes?.[s];if(null==o)return;const r=[o];if(!e.geometry){const s=await Z({layer:i,graphic:e,outFields:[],objectIds:r,returnGeometry:!0,spatialReference:t}),o=s?.geometry;o&&(e.geometry=o)}}_clear(){this._set("title",""),this._set("content",null),this._set("formattedAttributes",null)}_graphicChanged(){this._evaluateExpressionAttributesTask=p(this._evaluateExpressionAttributesTask),this._graphicChangedTask=p(this._graphicChangedTask),this._graphicChangedTask=r((async e=>{this._error=null,this._clear();const{graphic:t}=this;try{if(!t)return null;const{_sourceLayer:i,_effectivePopupTemplate:s}=this,o=this.spatialReference;await K({graphic:t,popupTemplate:s,layer:i,spatialReference:o},{signal:e});const[{value:r},{value:a}]=await c([this._getContent(),this._getTitle()]),[,{value:n}]=await c([this._checkForRelatedFeatures({signal:e}),P(s?.expressionInfos,t)]);return{expressionInfos:n,content:r,title:a}}catch(i){throw d(i)||(this._error=i,l.getLogger(this).error("error","The popupTemplate could not be displayed for this feature.",{error:i,graphic:t,popupTemplate:this._effectivePopupTemplate})),i}}))}_compileContentElement(e,t){return"attachments"===e.type?this._compileAttachments(e,t):"custom"===e.type?this._compileCustom(e,t):"fields"===e.type?this._compileFields(e,t):"media"===e.type?this._compileMedia(e,t):"text"===e.type?this._compileText(e,t):"expression"===e.type?this._compileExpression(e,t):"relationship"===e.type?this._compileRelationship(e,t):"utility-network-associations"===e.type?this._compileUtilityNetworkAssociation(e,t):void 0}_compileContent(e){if(this._destroyContentViewModels(),this.graphic)return Array.isArray(e)?e.filter(this._isAllowedContentType).map(((e,t)=>this._compileContentElement(e,t))).filter(o):"string"==typeof e?this._compileText(new M({text:e}),0).text:e}_destroyContentViewModels(){this.removeHandles(ae),this.removeHandles(re),this.contentViewModels.forEach((e=>e&&!e.destroyed&&e.destroy())),this._set("contentViewModels",[])}_matchesFeature(e,t){const i=e?.graphic?.getObjectId(),s=t?.getObjectId();return null!=i&&null!=s&&i===s}_setRelatedFeaturesViewModels({relatedFeatureViewModels:e,relatedFeatures:t,map:i}){const{view:s,spatialReference:o,timeZone:r}=this;t?.filter(Boolean).forEach((t=>{e.some((e=>this._matchesFeature(e,t)))||e.add(new se({abilities:{relationshipContent:!1},map:i,view:s,spatialReference:o,timeZone:r,graphic:t}))})),e.forEach((i=>{const s=t?.find((e=>this._matchesFeature(i,e)));s||e.remove(i)}))}_setExpressionContentVM(e,t){const i=this.formattedAttributes,{contentElement:s,contentElementViewModel:o}=e,r=s?.type;o&&r&&("fields"===r&&(this._createFieldsFormattedAttributes({contentElement:s,contentElementIndex:t,formattedAttributes:i}),o.set(this._createFieldsVMParams(s,t))),"media"===r&&(this._createMediaFormattedAttributes({contentElement:s,contentElementIndex:t,formattedAttributes:i}),o.set(this._createMediaVMParams(s,t))),"text"===r&&o.set(this._createTextVMParams(s)))}_compileRelationship(e,t){const{displayCount:i,orderByFields:s,relationshipId:o,title:r,description:a}=e,{_sourceLayer:n,graphic:l,map:p}=this;if(!N(n))return;const c=new k({displayCount:i,graphic:l,orderByFields:s,relationshipId:o,layer:n,map:p,...this._compileTitleAndDesc({title:r,description:a})});return this.contentViewModels[t]=c,this.addHandles(m((()=>c.relatedFeatures),"change",(()=>this._setRelatedFeaturesViewModels(c))),ae),e}_matchesGlobalFeature(e,t){const i=e?.association.globalId,s=t?.association.globalId;return null!=i&&null!=s&&i===s}async _setUpUtilityNetworkAssociationsViewModels(e,t,i){const{view:s,spatialReference:o,timeZone:r}=this;e.forEach(((i,s)=>{const o=t.get(s);o?i.forEach((t=>{o.find((e=>this._matchesGlobalFeature(t,e)))||(i.remove(t),0===i.length&&e.delete(s))})):(i.removeAll(),e.delete(s))})),t.forEach(((t,n)=>{const l=e.get(n)||new a;t?.filter(Boolean).forEach((e=>{l.some((t=>this._matchesGlobalFeature(t,e)))||l.add({association:e.association,featureViewModel:new se({abilities:{utilityNetworkAssociationsContent:!1},map:i,view:s,spatialReference:o,timeZone:r,graphic:e.feature}),terminalName:e.terminalName})})),e.set(n,l)}));const n=new AbortController;this._associationVMAbortController=n,await this._sortListObjectsByTitle(e,{signal:n.signal}),this._associationVMAbortController===n&&(this._associationVMAbortController=null)}async _sortListObjectsByTitle(e,t){for(const i of e.values()){const e=i.map((e=>_((()=>"ready"===e.featureViewModel.state),t?.signal)));await Promise.all(e),i.sort(this._compareByFeatureTitle)}}_compareByFeatureTitle(e,t){const i=x(e.featureViewModel),s=x(t.featureViewModel);return i.localeCompare(s,void 0,{numeric:!0})}_compileUtilityNetworkAssociation(e,t){const{displayCount:i,title:s,description:o,associationTypes:r}=e,{_sourceLayer:a,graphic:n,map:l}=this;if(!B(a))return;const p=new ie({graphic:n,displayCount:i,associationTypes:r,layer:a,map:l,...this._compileTitleAndDesc({title:s,description:o})});return this.contentViewModels[t]=p,this.addHandles([u((()=>p.associationFeatures.values()),(()=>this._setUpUtilityNetworkAssociationsViewModels(p.associationViewModels,p.associationFeatures,p.map)))],ne),e}_compileExpression(e,t){const{expressionInfo:i}=e,{graphic:s,map:o,spatialReference:r,view:a,location:n}=this,l=new F({expressionInfo:i,graphic:s,interceptor:se.interceptor,map:o,spatialReference:r,view:a,location:n});return this.contentViewModels[t]=l,this.addHandles(u((()=>l.contentElementViewModel),(()=>this._setExpressionContentVM(l,t)),y),re),e}_compileAttachments(e,t){const{graphic:i}=this,{description:s,title:o,orderByFields:r}=e;return this.contentViewModels[t]=new C({graphic:i,orderByFields:r,...this._compileTitleAndDesc({title:o,description:s})}),e}_compileCustom(e,t){const{graphic:i}=this,{creator:s,destroyer:o}=e;return this.contentViewModels[t]=new E({graphic:i,creator:s,destroyer:o}),e}_compileTitleAndDesc({title:e,description:t}){const{_fieldInfoMap:i,_sourceLayer:s,graphic:o,formattedAttributes:r}=this,a=o?.attributes,n=this._expressionAttributes,l=r.global;return{title:S({attributes:a,fieldInfoMap:i,globalAttributes:l,expressionAttributes:n,layer:s,text:e}),description:S({attributes:a,fieldInfoMap:i,globalAttributes:l,expressionAttributes:n,layer:s,text:t})}}_createFieldsVMParams(e,t){const i=this._effectivePopupTemplate,s=this.formattedAttributes,o={...s?.global,...s?.content[t]},r=e?.fieldInfos||i?.fieldInfos,a=r?.filter((({fieldName:e})=>!!e&&(H(e)||D(e)||o.hasOwnProperty(e)))),n=i?.expressionInfos,{description:l,title:p}=e;return{attributes:o,expressionInfos:n,fieldInfos:a,...this._compileTitleAndDesc({title:p,description:l})}}_compileFields(e,t){const i=e.clone(),s=new V(this._createFieldsVMParams(e,t));return this.contentViewModels[t]=s,i.fieldInfos=s.formattedFieldInfos.slice(),i}_createMediaVMParams(e,t){const{abilities:i,graphic:s,_fieldInfoMap:o,_effectivePopupTemplate:r,relatedInfos:a,_sourceLayer:n,_expressionAttributes:l}=this,p=this.formattedAttributes,c=s?.attributes??{},{description:d,mediaInfos:h,title:u}=e;return{abilities:{chartAnimation:i.chartAnimation},activeMediaInfoIndex:e.activeMediaInfoIndex||0,attributes:c,isAggregate:s?.isAggregate,layer:n,fieldInfoMap:o,formattedAttributes:{...p?.global,...p?.content[t]},expressionAttributes:l,mediaInfos:h,popupTemplate:r,relatedInfos:a,...this._compileTitleAndDesc({title:u,description:d})}}_compileMedia(e,t){const i=e.clone(),s=new j(this._createMediaVMParams(e,t));return i.mediaInfos=s.formattedMediaInfos.slice(),this.contentViewModels[t]=s,i}_createTextVMParams(e){const{graphic:t,_fieldInfoMap:i,_sourceLayer:s,_expressionAttributes:o}=this;if(e&&e.text){const r=t?.attributes??{},a=this.formattedAttributes?.global??{};e.text=S({attributes:r,fieldInfoMap:i,globalAttributes:a,expressionAttributes:o,layer:s,text:e.text})}return{graphic:t,creator:e.text}}_compileText(e,t){const i=e.clone();return this.contentViewModels[t]=new E(this._createTextVMParams(i)),i}_compileLastEditInfo(){const{_effectivePopupTemplate:e,_sourceLayer:t,graphic:i,timeZone:s}=this;if(!e)return;const{lastEditInfoEnabled:o}=e,r=t?.editFieldsInfo;return o&&r?G(r,i?.attributes,s,t):void 0}_compileTitle(e){const{_fieldInfoMap:t,_sourceLayer:i,graphic:s,_expressionAttributes:o}=this,r=s?.attributes??{},a=this.formattedAttributes?.global??{};return S({attributes:r,fieldInfoMap:t,globalAttributes:a,expressionAttributes:o,layer:i,text:e})}async _getTitle(){const{_effectivePopupTemplate:e,graphic:t}=this;return t?q({type:"title",value:e?.title,event:{graphic:t}}):null}async _getContent(){const{_effectivePopupTemplate:e,graphic:t}=this;return t?q({type:"content",value:e?.content,event:{graphic:t}}):null}_evaluateExpressionAttributes({title:e,content:t,expressionInfos:i}){this._evaluateExpressionAttributesTask=p(this._evaluateExpressionAttributesTask),this._evaluateExpressionAttributesTask=r((async s=>{const{graphic:o,map:r,view:a,spatialReference:n,location:p}=this;try{if(!o)return;let l;if(null!=i){const e=[];for(const[t,l]of i.expressions.entries())null!=l?e.push(l.evaluate({graphic:o,interceptor:se.interceptor,location:p,map:r,options:{signal:s},spatialReference:n,view:a}).then((e=>[t,R(e)])).catch((()=>[t,void 0]))):e.push(Promise.resolve([t,void 0]));l=Object.fromEntries(await Promise.all(e)),h(s)}this._expressionAttributes=l,this._graphicExpressionAttributes={...o.attributes,...l},this._set("formattedAttributes",this._createFormattedAttributes(t)),this._set("title",this._compileTitle(e)),this._set("lastEditInfo",this._compileLastEditInfo()||null),this._set("content",this._compileContent(t)||null)}catch(c){d(c)||(this._error=c,l.getLogger(this).error("error","The popupTemplate could not be displayed for this feature.",{error:c,graphic:o,popupTemplate:this._effectivePopupTemplate}))}}))}_createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:i}){const{_effectivePopupTemplate:s,graphic:o,relatedInfos:r,_sourceLayer:a,_fieldInfoMap:n,_graphicExpressionAttributes:l,timeZone:p}=this;i.content[t]=z({fieldInfos:s?.fieldInfos,graphic:o,attributes:{...l,...e.attributes},layer:a,fieldInfoMap:n,relatedInfos:r,timeZone:p})}_createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:i}){if(e.fieldInfos){const{graphic:s,relatedInfos:o,_sourceLayer:r,_fieldInfoMap:a,_graphicExpressionAttributes:n,timeZone:l}=this;i.content[t]=z({fieldInfos:e.fieldInfos,graphic:s,attributes:{...n,...e.attributes},layer:r,fieldInfoMap:a,relatedInfos:o,timeZone:l})}}_createFormattedAttributes(e){const{_effectivePopupTemplate:t,graphic:i,relatedInfos:s,_sourceLayer:o,_fieldInfoMap:r,_graphicExpressionAttributes:a,timeZone:n}=this,l=t?.fieldInfos,p={global:z({fieldInfos:l,graphic:i,attributes:a,layer:o,fieldInfoMap:r,relatedInfos:s,timeZone:n}),content:[]};return Array.isArray(e)&&e.forEach(((e,t)=>{"fields"===e.type&&this._createFieldsFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:p}),"media"===e.type&&this._createMediaFormattedAttributes({contentElement:e,contentElementIndex:t,formattedAttributes:p})})),p}_checkForRelatedFeatures(e){const{graphic:t,_effectivePopupTemplate:i}=this;return this._queryRelatedInfos(t,O(i),e)}async _queryRelatedInfos(e,t,i){const{relatedInfos:s,_sourceLayer:o}=this;s.clear();const r=null!=o?.associatedLayer?await(o?.associatedLayer.load(i)):o;if(!r||!e)return;const a=t.filter((e=>!!e.fieldName&&D(e.fieldName)));if(!a?.length)return;t.forEach((e=>this._configureRelatedInfo(e,r)));const n=await W({relatedInfos:s,layer:r},i);Object.keys(n).forEach((e=>{const t=s.get(e.toString()),i=n[e]?.value;t&&i&&(t.layerInfo=i.data)}));const l=await X({graphic:e,relatedInfos:s,layer:r},i);Object.keys(l).forEach((e=>{Y(l[e]?.value,s.get(e.toString()))}))}_configureRelatedInfo(e,t){const{relatedInfos:i}=this,s=$(e.fieldName||"");if(!s)return;const{layerId:o,fieldName:r}=s;if(!o)return;const a=i.get(o.toString())||ee(o,t);a&&(te({relatedInfo:a,fieldName:r,fieldInfo:e}),this.relatedInfos.set(o,a))}};pe.interceptor=new i(Q,J),e([b()],pe.prototype,"_error",void 0),e([b()],pe.prototype,"_graphicChangedTask",void 0),e([b()],pe.prototype,"_evaluateExpressionAttributesTask",void 0),e([b()],pe.prototype,"_associationVMAbortController",void 0),e([b({readOnly:!0})],pe.prototype,"_effectivePopupTemplate",null),e([b({readOnly:!0})],pe.prototype,"_fieldInfoMap",null),e([b({readOnly:!0})],pe.prototype,"_sourceLayer",null),e([b()],pe.prototype,"abilities",void 0),e([w("abilities")],pe.prototype,"castAbilities",null),e([b({readOnly:!0})],pe.prototype,"content",void 0),e([b({readOnly:!0})],pe.prototype,"contentViewModels",void 0),e([b()],pe.prototype,"description",void 0),e([b({type:Boolean})],pe.prototype,"defaultPopupTemplateEnabled",void 0),e([b({readOnly:!0})],pe.prototype,"isTable",null),e([b({readOnly:!0})],pe.prototype,"state",null),e([b({readOnly:!0})],pe.prototype,"formattedAttributes",void 0),e([b({type:t,value:null})],pe.prototype,"graphic",null),e([b({readOnly:!0})],pe.prototype,"lastEditInfo",void 0),e([b({type:A})],pe.prototype,"location",void 0),e([b({readOnly:!0})],pe.prototype,"relatedInfos",void 0),e([b({type:I})],pe.prototype,"spatialReference",null),e([b()],pe.prototype,"timeZone",null),e([b({readOnly:!0})],pe.prototype,"title",void 0),e([b()],pe.prototype,"map",null),e([b({readOnly:!0})],pe.prototype,"waitingForContent",null),e([b()],pe.prototype,"view",void 0),pe=se=e([v("esri.widgets.Feature.FeatureViewModel")],pe);const ce=pe;export{ce 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.32/esri/copyright.txt for details.
4
4
  */
5
- import{isSupportedLayer as e}from"../../../arcade/featureset/support/shared.js";import r from"../../../core/Logger.js";import{eachAlways as t}from"../../../core/promiseUtils.js";import a from"../../../layers/FeatureLayer.js";import{applyTextFormattingHTML as o,htmlEntities as i}from"./featureUtils.js";import{globalCss as n}from"../../support/globalCss.js";const s="esri.widgets.Feature.support.arcadeFeatureUtils",p=()=>r.getLogger(s);function c(e){return"string"==typeof e?o(i(e)):Array.isArray(e)?l(e):"esri.arcade.Dictionary"===e?.declaredClass?u(e):e}function l(e){return`<ul class="esri-widget__list">${e.map((e=>`<li>${"string"==typeof e?o(i(e)):e}</li>`)).join("")}</ul>`}function u(e){const r=e.keys().map((r=>{const t=e.field(r);return`<tr><th>${r}</th><td>${"string"==typeof t?o(i(t)):t}</td></tr>`})).join("");return`<table class="${n.table}">${r}</table>`}function d(){return import("../../../arcade.js")}function f(e){return"createQuery"in e&&"queryFeatures"in e}async function g({graphic:e,view:r,options:t}){const{isAggregate:a,layer:o}=e;if(!a||!o||"2d"!==r?.type)return[];const i=await r.whenLayerView(o);if(!f(i))return[];const n=i.createQuery(),s=e.getObjectId();n.aggregateIds=null!=s?[s]:[];const{features:p}=await i.queryFeatures(n,t);return p}function y({layer:e,aggregatedFeatures:r,interceptor:t}){const{fields:o,objectIdField:i,geometryType:n,spatialReference:s,displayField:p}=e;return new a({fields:o,objectIdField:i,geometryType:n,spatialReference:s,displayField:p,interceptor:t,..."feature"===e.type?{templates:e.templates,typeIdField:e.typeIdField,types:e.types}:null,source:r})}async function m({expressionInfo:r,arcade:t,interceptor:a,spatialReference:o,map:i,graphic:n,location:s,view:c,options:l}){if(!r?.expression)return null;const{isAggregate:u}=n,d=(n.sourceLayer||n.layer)??void 0,f="esri.views.3d.layers.VoxelGraphic"===n.declaredClass,m=u?"feature-reduction-popup":f?"popup-voxel":"popup",w=t.createArcadeProfile(m),h=t.createArcadeExecutor(r.expression,w).catch((e=>p().error("arcade-executor-error",{error:e,expressionInfo:r}))),[v,x]=await Promise.all([g({graphic:n,view:c,options:l}),h]);if(!x)return null;const $="feature-reduction-popup"===m?y({layer:d,aggregatedFeatures:v,interceptor:a}):void 0,F="feature-reduction-popup"===m?{$aggregatedFeatures:$}:{$datastore:d?.url,$layer:null!=d&&e(d)?d:"scene"===d?.type&&null!=d.associatedLayer?d.associatedLayer:void 0,$map:i,$userInput:s,$graph:"knowledge-graph-sublayer"===d?.type?d?.parentCompositeLayer?.knowledgeGraph:void 0};f?F.$voxel=n:F.$feature=n;const j={abortSignal:l?.signal??void 0,interceptor:a??void 0,rawOutput:!0,spatialReference:o??void 0,timeZone:c?.timeZone};return await x.executeAsync(F,j).catch((e=>p().error("arcade-execution-error",{error:e,graphic:n,expressionInfo:r}))).finally((()=>$?.destroy()))}async function w({expressionInfos:e,spatialReference:r,graphic:a,interceptor:o,map:i,view:n,location:s,options:p}){if(!e?.length)return{};const l=await d(),u={};for(const t of e)u[`expression/${t.name}`]=m({expressionInfo:t,arcade:l,interceptor:o,spatialReference:r,map:i,graphic:a,location:s,view:n,options:p});const f=await t(u),g={};for(const t in f)g[t]=c(f[t].value);return g}export{m as createCompiledExpression,w as createCompiledExpressions,d as loadArcade};
5
+ import{isSupportedLayer as e}from"../../../arcade/featureset/support/shared.js";import r from"../../../core/Logger.js";import t from"../../../layers/FeatureLayer.js";import{applyTextFormattingHTML as a,htmlEntities as n}from"./featureUtils.js";import{globalCss as s}from"../../support/globalCss.js";const o="esri.widgets.Feature.support.arcadeFeatureUtils",i=()=>r.getLogger(o);function c(e){return"string"==typeof e?a(n(e)):Array.isArray(e)?p(e):"esri.arcade.Dictionary"===e?.declaredClass?u(e):e}function p(e){return`<ul class="esri-widget__list">${e.map((e=>`<li>${"string"==typeof e?a(n(e)):e}</li>`)).join("")}</ul>`}function u(e){const r=e.keys().map((r=>{const t=e.field(r);return`<tr><th>${r}</th><td>${"string"==typeof t?a(n(t)):t}</td></tr>`})).join("");return`<table class="${s.table}">${r}</table>`}async function l(){const[e,r]=await Promise.all([import("../../../arcade.js"),import("../../../arcade/arcade.js")]);return{executor:e,syntaxUtils:r}}function d(e){return"createQuery"in e&&"queryFeatures"in e}async function y({graphic:e,view:r,options:t}){const{isAggregate:a,layer:n}=e;if(!a||!n||"2d"!==r?.type)return[];const s=await r.whenLayerView(n);if(!d(s))return[];const o=s.createQuery(),i=e.getObjectId();o.aggregateIds=null!=i?[i]:[];const{features:c}=await s.queryFeatures(o,t);return c}function f({layer:e,aggregatedFeatures:r,interceptor:a}){const{fields:n,objectIdField:s,geometryType:o,spatialReference:i,displayField:c}=e;return new t({fields:n,objectIdField:s,geometryType:o,spatialReference:i,displayField:c,interceptor:a,..."feature"===e.type?{templates:e.templates,typeIdField:e.typeIdField,types:e.types}:null,source:r})}function g(e){const r="esri.views.3d.layers.VoxelGraphic"===e.declaredClass;return e.isAggregate?"feature-reduction-popup":r?"popup-voxel":"popup"}function w(e){return{scale:e?.scale,timeProperties:{currentStart:e?.timeExtent?.start,currentEnd:e?.timeExtent?.end,startIncluded:!0,endIncluded:!0}}}function m(e){return{$voxel:e}}async function x(e,r,t,a,n){let s=null;if(n.has("$aggregatedfeatures")){const n=await y({graphic:e,view:r,options:t}),o=e.sourceLayer||e.layer;s=f({layer:o,aggregatedFeatures:n,interceptor:a})}return{vars:{$feature:e,$aggregatedFeatures:s,$view:w(r)},[Symbol.dispose]:()=>s?.[Symbol.dispose]()}}function v(r,t,a,n){const s=(r.sourceLayer||r.layer)??void 0;return{$feature:r,$layer:null!=s&&e(s)?s:"scene"===s?.type&&null!=s.associatedLayer?s.associatedLayer:void 0,$map:t,$datastore:s?.url,$userInput:a,$graph:"knowledge-graph-sublayer"===s?.type?s?.parentCompositeLayer?.knowledgeGraph:void 0,$view:w(n)}}async function h(e,{graphic:r,map:t,location:a,view:n,options:s,interceptor:o,arcadeExecutor:i}){switch(e){case"popup":return{vars:v(r,t,a,n),[Symbol.dispose](){}};case"feature-reduction-popup":{const e=new Set(i.variablesUsed);return await x(r,n,s,o,e)}case"popup-voxel":return{vars:m(r),[Symbol.dispose](){}};default:throw new Error(`Unexpected profile name ${e}`)}}async function $({expressionInfo:e,arcade:{executor:r,syntaxUtils:t},graphic:a}){const n=e?.expression;if(!n)return null;const s=g(a),o=r.createArcadeProfile(s);let c;try{c=await r.createArcadeExecutor(n,o)}catch(u){return i().error("arcade-executor-error",{error:u,expressionInfo:e}),null}const p=new Set;return c.variablesUsed.includes("$view")&&(t.scriptUsesViewProperties(c.syntaxTree,["scale"])&&p.add("view-scale"),t.scriptUsesViewProperties(c.syntaxTree,["timeProperties"])&&p.add("view-time-extent")),{dependencies:p,async evaluate({graphic:r,interceptor:t,location:a,map:n,options:o,spatialReference:p,view:l}){const d=await h(s,{graphic:r,map:n,location:a,view:l,options:o,interceptor:t,arcadeExecutor:c}),y={abortSignal:o?.signal??void 0,interceptor:t??void 0,rawOutput:!0,spatialReference:p??void 0,timeZone:l?.timeZone,console(...e){i().info(...e)}};try{return await c.executeAsync(d.vars,y)}catch(u){return void i().error("arcade-execution-error",{error:u,graphic:r,expressionInfo:e})}finally{d[Symbol.dispose]()}}}}async function b(e,r){if(!e?.length)return{dependencies:new Set,expressions:new Map};const t=await l(),a=new Set,n=new Map;for(const s of e){const e=await $({expressionInfo:s,arcade:t,graphic:r});n.set(`expression/${s.name}`,e),e?.dependencies.forEach((e=>a.add(e)))}return{dependencies:a,expressions:n}}export{$ as compileExpression,b as compileExpressionInfos,c as formatArcadeValue,l as loadArcade};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import i from"../core/Identifiable.js";import o from"../core/ReactiveMap.js";import{on as s,watch as l,initial as r}from"../core/reactiveUtils.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";import d from"./Widget.js";import{css as p}from"./LayerList/css.js";import c from"./LayerList/LayerListItem.js";import m from"./LayerList/LayerListViewModel.js";import h from"./LayerList/LayerListVisibleElements.js";import y from"./LayerList/ListItem.js";import{minDragEnabledItems as u,minFilterItems as g,getItem as _,getLayerType as L,sortLayersToIds as f,sortChildLayersToIds as I,removeDestroyedListItems as v,setFilterPredicate as b}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as w}from"./support/componentsUtils.js";import{globalCss as C}from"./support/globalCss.js";import{calciteListFilterProps as E}from"./support/listUtils.js";import{setFocus as F}from"./support/widgetUtils.js";import{messageBundle as M}from"./support/decorators/messageBundle.js";import{vmEvent as O}from"./support/decorators/vmEvent.js";import{tsx as T}from"./support/jsxFactory.js";const P=t.ofType(y),A="nested";let j=class extends(i.IdentifiableMixin(d)){constructor(e,i){super(e,i),this._rootListEl=null,this._activeItem=null,this._tooltipReferenceMap=new o,this._focusRootFlowItem=!1,this._focusPanelFlowItem=!1,this._focusLayerFlowItem=null,this._layerListMap=new o,this._lastDragDetail=null,this._selectedDragItemLayerUid=null,this._rootGroupUid=`operational-${this.uid}`,this._openedLayersController=null,this.catalogLayerList=null,this.catalogOptions=null,this.collapsed=!1,this.dragEnabled=!1,this.filterPlaceholder="",this.filterPredicate=null,this.filterText="",this.headingLevel=2,this.knowledgeGraphOptions=null,this.layerTablesEnabled=new t(["knowledge-graph"]),this.listItemCanGiveFunction=null,this.listItemCanReceiveFunction=null,this.mapImageOptions=null,this.messages=null,this.messagesCommon=null,this.minDragEnabledItems=u,this.minFilterItems=g,this.openedLayers=new t,this.openedLayerLists=new t,this.selectedItems=new P,this.selectionMode="none",this.tableList=null,this.tileOptions=null,this.viewModel=new m,this.visibilityAppearance="default",this.visibleElements=new h,this._canMove=({dragEl:e,fromEl:t,toEl:i},o)=>{const s="pull"===o?this.listItemCanGiveFunction:this.listItemCanReceiveFunction,l=_(e);if(!l?.sortable)return!1;const r=_(t),a=L(t),n=_(i),d=L(i),p=!!a&&!!d&&a===d,c={selected:l,from:r,to:n},m=t.group,h=i.group,y=r?.layer?.type??"",u=n?.layer?.type??"",g=new Set(["map-image","catalog","knowledge-graph"]),f="sublayer";return m&&h&&"function"==typeof s?s.call(null,c):p&&!g.has(y)&&!g.has(u)&&l?.layer?.type!==f},this._onCatalogOpen=e=>{this.openedLayers.push(e.layer?.parent),this._focusLayerFlowItem=e.layer?.uid},this._onTablesOpen=e=>{this.openedLayers.push(e.layer),this._focusLayerFlowItem=e.layer?.uid},this._onPanelOpen=()=>{this._focusPanelFlowItem=!0},this._onTooltipReferenceChange=(e,t)=>{t?this._tooltipReferenceMap.set(e,t):this._tooltipReferenceMap.delete(e)},this._onSelectedDragItemLayerUidChange=e=>{this._selectedDragItemLayerUid=e},this._onTriggerAction=(e,t)=>{this.triggerAction(e,t)},this._clearActiveItem=()=>{this._activeItem=null},this._setActiveItem=e=>{if("default"!==this.visibilityAppearance)return;const t=Array.from(e.composedPath()).find((e=>e.classList?.contains(p.item)));this._activeItem=_(t)},this._onCalciteListOrderChange=e=>{const{_lastDragDetail:t}=this,{toEl:i,fromEl:o,dragEl:s,newIndex:l}=e;if(o&&i&&!(t?.newIndex===l&&t?.dragEl===s&&t?.toEl===i&&t?.fromEl===o))if(this._lastDragDetail=e,this._selectedDragItemLayerUid=s.value,o!==i)this._moveLayerFromChildList({toEl:i,fromEl:o,dragEl:s,newIndex:l});else{const e=Array.from(o.children).filter((e=>e?.matches("calcite-list-item"))).map((e=>e.value));this._sortLayers(o,e)}}}initialize(){this.addHandles([s((()=>this.openedLayers),"change",(()=>this._handleOpenedLayersChange()),r),s((()=>this.viewModel.operationalItems),"change",(()=>v(this.selectedItems)),r),l((()=>[this.filterPredicate,this._rootListEl]),(()=>b(this._rootListEl,this.filterPredicate)))])}loadDependencies(){return w({button:()=>import("@esri/calcite-components/dist/components/calcite-button"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")})}destroy(){this._destroyOpenedLayerLists(),this._tooltipReferenceMap.clear()}get _totalItems(){return this.viewModel.operationalItems.flatten((e=>e.children.filter((e=>"catalog-dynamic-group"!==e.layer?.type)))).length}get _visibleItems(){return this.operationalItems?.filter((e=>!e.hidden&&(this.visibleElements.errors||!e.error)))}get _openedPanelItems(){return this._visibleItems.flatten((e=>e.children)).filter((({hidden:e,panel:t})=>!e&&t?.open&&!t.disabled&&t.flowEnabled))}get _dragEnabled(){return this._totalItems>=this.minDragEnabledItems&&this.dragEnabled}get _filterEnabled(){return this._totalItems>=this.minFilterItems&&this.visibleElements.filter}get _renderedOpenLayerFlowItems(){const{openedLayers:e}=this;return e.toArray().map(((t,i)=>this._renderLayerFlowItem(t,i===e.length-1)))}get icon(){return"layers"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get listItemCreatedFunction(){return this.viewModel.listItemCreatedFunction}set listItemCreatedFunction(e){this.viewModel.listItemCreatedFunction=e}get operationalItems(){return this.viewModel.operationalItems}set operationalItems(e){this.viewModel.operationalItems=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){const e=this.viewModel?.state,{_visibleItems:t}=this,i={[C.hidden]:"loading"===e,[C.disabled]:"disabled"===e};return T("div",{class:this.classes(p.base,C.widget,C.panel,i)},t?.length?[this._renderItemTooltips(),this._renderItems()]:this._renderNoItems())}async _createFlowList(e,t){const{_layerListMap:i}=this,o=i.get(e);if(o)return o;const s="catalog"===e.type?await this._createCatalogLayerList(e):await this._createTableList(e);return t.aborted||i.set(e,s),s}async _handleOpenedLayersChange(){const{_layerListMap:e,openedLayers:t,openedLayerLists:i}=this;this._openedLayersController?.abort();const o=new AbortController,{signal:s}=o;this._openedLayersController=o,e.forEach(((i,o)=>{t.includes(o)||(i.destroy(),e.delete(o))}));const l=await Promise.all(t.map((e=>this._createFlowList(e,s))));if(s.aborted)return;i.removeAll(),i.addMany(l);const r=i.at(-1);r?"catalogLayer"in r?(this._set("catalogLayerList",r),this._set("tableList",null)):(this._set("catalogLayerList",null),this._set("tableList",r)):(this._set("catalogLayerList",null),this._set("tableList",null))}_destroyOpenedLayerLists(){this.openedLayerLists.destroyAll(),this.openedLayers.removeAll(),this._layerListMap.clear()}_renderItemTooltip(e){const{_tooltipReferenceMap:t,messages:i}=this;return e?T("calcite-tooltip",{key:`tooltip-${e.layer?.uid}`,referenceElement:t.get(e.layer?.uid)},i.layerIncompatibleTooltip):null}_renderItemTooltipNodes(e){return e.incompatible?this._renderItemTooltip(e):e.children?.filter((e=>!e.hidden)).toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderItemTooltips(){return this._visibleItems?.toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderNoItemsMessage(){return T("div",{slot:"message"},this.messages.noItemsToDisplay)}_renderNoItems(){return T("div",{class:p.itemMessage,key:"esri-layer-list__no-items"},T("calcite-notice",{icon:"information",kind:"info",open:!0,width:"full"},this._renderNoItemsMessage()))}async _createCatalogLayerList(e){const{default:t}=await import("./CatalogLayerList.js"),{headingLevel:i,catalogOptions:o,view:s,filterPlaceholder:l,listItemCreatedFunction:r,minFilterItems:a,selectionMode:n,visibilityAppearance:d,_onCatalogOpen:p,_onTablesOpen:c,layerTablesEnabled:m}=this;return new t({headingLevel:i,view:s,filterPlaceholder:l,listItemCreatedFunction:r,minFilterItems:a,selectionMode:n,visibilityAppearance:d,...o,catalogLayer:e,layerTablesEnabled:m,onCatalogOpen:p,onTablesOpen:c})}_getTableListParams(e){switch(e.type){case"knowledge-graph":return{...this.knowledgeGraphOptions,tables:e.tables};case"map-image":return{...this.mapImageOptions,tables:e.subtables};case"tile":return{...this.tileOptions,tables:e.subtables};default:return null}}async _createTableList(e){const{default:t}=await import("./TableList.js"),{headingLevel:i,selectionMode:o,dragEnabled:s}=this;return new t({headingLevel:i,selectionMode:o,dragEnabled:s,...this._getTableListParams(e)})}_renderLayerFlowItem(e,t){const{messages:i,openedLayers:o}=this,s=e.title||this.messages.untitledLayer;return T("calcite-flow-item",{afterCreate:this._focusLayerFlowItemNode,afterUpdate:this._focusLayerFlowItemNode,bind:this,"data-layer-uid":e.uid,description:s,heading:i["catalog"===e.type?"catalogLayers":"tables"],headingLevel:this.headingLevel,key:`flow-layer-list-${e.uid}`,selected:t,onCalciteFlowItemBack:e=>{e.preventDefault(),o.pop();const t=o.at(-1);t?this._focusLayerFlowItem=t.uid:this._focusRootFlowItem=!0}},this._layerListMap.get(e)?.render())}_renderPanelFlowItems(){const{_openedPanelItems:e,openedLayers:t}=this;return e.toArray().map((({title:i,panel:o},s)=>{const l=()=>this._handlePanelFlowItemBack(o);return T("calcite-flow-item",{afterCreate:this._focusPanelFlowItemNode,afterUpdate:this._focusPanelFlowItemNode,bind:this,description:i,heading:o.title,headingLevel:this.headingLevel,key:`flow-panel-${o.uid}`,selected:!t.length&&s===e.length-1,onCalciteFlowItemBack:e=>{e.preventDefault(),l()}},o.render(),T("calcite-button",{appearance:"transparent",onclick:l,slot:"footer-actions",width:"full"},this.messagesCommon.back))}))}_handlePanelFlowItemBack(e){e.open=!1,this._focusRootFlowItem=!0}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,F(e))}_focusLayerFlowItemNode(e){this._focusLayerFlowItem===e.dataset.layerUid&&(this._focusLayerFlowItem=null,F(e))}_focusPanelFlowItemNode(e){this._focusPanelFlowItem&&(this._focusPanelFlowItem=!1,F(e))}_renderItems(){const{visible:e,collapsed:t,_visibleItems:i,_openedPanelItems:o,_filterEnabled:s,_rootGroupUid:l,visibleElements:{closeButton:r,collapseButton:a,heading:n,flow:d},_dragEnabled:c,selectionMode:m,filterText:h,openedLayers:y,filterPlaceholder:u,messages:g}=this,_=[T("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:r,closed:!e,collapsed:t,collapsible:a,heading:n?g.widgetLabel:void 0,headingLevel:this.headingLevel,key:"root-flow-item",selected:!y.length&&!o.length,onCalciteFlowItemClose:()=>this.visible=!1},T("calcite-list",{afterCreate:e=>{this._rootListEl=e,e.addEventListener("focusin",this._setActiveItem),e.addEventListener("focusout",this._clearActiveItem)},afterRemoved:e=>{this._rootListEl=null,e.removeEventListener("focusin",this._setActiveItem),e.removeEventListener("focusout",this._clearActiveItem)},canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-layer-type":l,displayMode:A,dragEnabled:c,filterEnabled:s,filterPlaceholder:u,filterProps:E,filterText:s?h:"",group:l,key:"root-list",label:g.widgetLabel,onmouseleave:this._clearActiveItem,onmouseover:this._setActiveItem,selectionAppearance:"border",selectionMode:m,onCalciteListChange:e=>this._handleCalciteListChange(e),onCalciteListDragEnd:e=>this._handleCalciteListDragEnd(e.detail),onCalciteListFilter:e=>this.filterText=e.currentTarget?.filterText??"",onCalciteListOrderChange:e=>this._onCalciteListOrderChange(e.detail)},i?.toArray().map((e=>this._renderItem(e))),i?.length&&s?T("div",{class:p.filterNoResults,slot:"filter-no-results"},T("calcite-notice",{kind:"info",open:!0,width:"full"},this._renderNoItemsMessage())):null)),this._renderPanelFlowItems(),this._renderedOpenLayerFlowItems];return e?d?T("calcite-flow",{key:"root-flow"},_):_:null}_renderItem(e,t,i){return T(c,{activeItem:this._activeItem,canMove:this._canMove,css:p,displayMode:A,dragEnabled:this.dragEnabled,item:e,key:`layerListItem-${e.layer?.uid}`,layerTablesEnabled:this.layerTablesEnabled,listModeDisabled:this.viewModel.listModeDisabled,messages:this.messages,messagesCommon:this.messagesCommon,parent:t,parentTitles:i,rootGroupUid:this._rootGroupUid,selectedDragItemLayerUid:this._selectedDragItemLayerUid,selectedItems:this.selectedItems,selectionMode:this.selectionMode,visibilityAppearance:this.visibilityAppearance,visibleElements:this.visibleElements,onAction:this._onTriggerAction,onCatalogOpen:this._onCatalogOpen,onPanelOpen:this._onPanelOpen,onSelectedDragItemLayerUidChange:this._onSelectedDragItemLayerUidChange,onTablesOpen:this._onTablesOpen,onTooltipReferenceChange:this._onTooltipReferenceChange})}_moveLayerFromChildList({toEl:e,fromEl:t,dragEl:i,newIndex:o}){const s=_(i),l=_(e),r=_(t);this.viewModel.moveListItem(s,r,l,o)}_handleCalciteListDragEnd(e){const{fromEl:t,dragEl:i,oldIndex:o}=e;t.insertBefore(i,t.children[o])}_sortLayers(e,t){if(e)if(e.group===this._rootGroupUid)f(this.view?.map?.layers,t);else{const i=_(e);if(!i)return;I(i,t)}}_handleCalciteListChange(e){const{selectionMode:t,selectedItems:i}=this;if("none"===t)return;const o=e.target.selectedItems.map((e=>_(e))).filter(Boolean);i.removeAll(),i.addMany(o)}};e([a()],j.prototype,"_rootListEl",void 0),e([a()],j.prototype,"_activeItem",void 0),e([a()],j.prototype,"_tooltipReferenceMap",void 0),e([a()],j.prototype,"_focusRootFlowItem",void 0),e([a()],j.prototype,"_focusPanelFlowItem",void 0),e([a()],j.prototype,"_focusLayerFlowItem",void 0),e([a()],j.prototype,"_layerListMap",void 0),e([a()],j.prototype,"_totalItems",null),e([a()],j.prototype,"_visibleItems",null),e([a()],j.prototype,"_openedPanelItems",null),e([a()],j.prototype,"_dragEnabled",null),e([a()],j.prototype,"_filterEnabled",null),e([a()],j.prototype,"_renderedOpenLayerFlowItems",null),e([a({readOnly:!0})],j.prototype,"catalogLayerList",void 0),e([a()],j.prototype,"catalogOptions",void 0),e([a()],j.prototype,"collapsed",void 0),e([a()],j.prototype,"dragEnabled",void 0),e([a()],j.prototype,"filterPlaceholder",void 0),e([a()],j.prototype,"filterPredicate",void 0),e([a()],j.prototype,"filterText",void 0),e([a()],j.prototype,"headingLevel",void 0),e([a()],j.prototype,"icon",null),e([a()],j.prototype,"knowledgeGraphOptions",void 0),e([a()],j.prototype,"label",null),e([a()],j.prototype,"layerTablesEnabled",void 0),e([a()],j.prototype,"listItemCanGiveFunction",void 0),e([a()],j.prototype,"listItemCanReceiveFunction",void 0),e([a()],j.prototype,"listItemCreatedFunction",null),e([a()],j.prototype,"mapImageOptions",void 0),e([a(),M("esri/widgets/LayerList/t9n/LayerList")],j.prototype,"messages",void 0),e([a(),M("esri/t9n/common")],j.prototype,"messagesCommon",void 0),e([a()],j.prototype,"minDragEnabledItems",void 0),e([a()],j.prototype,"minFilterItems",void 0),e([a({readOnly:!0})],j.prototype,"openedLayers",void 0),e([a({readOnly:!0})],j.prototype,"openedLayerLists",void 0),e([a()],j.prototype,"operationalItems",null),e([a()],j.prototype,"selectedItems",void 0),e([a()],j.prototype,"selectionMode",void 0),e([a({readOnly:!0})],j.prototype,"tableList",void 0),e([a()],j.prototype,"tileOptions",void 0),e([a()],j.prototype,"view",null),e([O("trigger-action"),a({type:m})],j.prototype,"viewModel",void 0),e([a()],j.prototype,"visibilityAppearance",void 0),e([a({type:h,nonNullable:!0})],j.prototype,"visibleElements",void 0),j=e([n("esri.widgets.LayerList")],j);const D=j;export{D as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import t from"../core/Collection.js";import i from"../core/Identifiable.js";import o from"../core/ReactiveMap.js";import{on as s,watch as l,initial as r}from"../core/reactiveUtils.js";import{property as a}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";import d from"./Widget.js";import{css as p}from"./LayerList/css.js";import c from"./LayerList/LayerListItem.js";import m from"./LayerList/LayerListViewModel.js";import h from"./LayerList/LayerListVisibleElements.js";import y from"./LayerList/ListItem.js";import{minDragEnabledItems as u,minFilterItems as g,getItem as _,getLayerType as L,sortLayersToIds as f,sortChildLayersToIds as I,removeDestroyedListItems as v,setFilterPredicate as b}from"./LayerList/support/layerListUtils.js";import{loadCalciteComponents as w}from"./support/componentsUtils.js";import{globalCss as C}from"./support/globalCss.js";import{calciteListFilterProps as E}from"./support/listUtils.js";import{setFocus as F}from"./support/widgetUtils.js";import{messageBundle as M}from"./support/decorators/messageBundle.js";import{vmEvent as O}from"./support/decorators/vmEvent.js";import{tsx as T}from"./support/jsxFactory.js";const P=t.ofType(y),A="nested";let j=class extends(i.IdentifiableMixin(d)){constructor(e,i){super(e,i),this._rootListEl=null,this._activeItem=null,this._tooltipReferenceMap=new o,this._focusRootFlowItem=!1,this._focusPanelFlowItem=!1,this._focusLayerFlowItem=null,this._layerListMap=new o,this._lastDragDetail=null,this._selectedDragItemLayerUid=null,this._rootGroupUid=`operational-${this.uid}`,this._openedLayersController=null,this.catalogLayerList=null,this.catalogOptions=null,this.collapsed=!1,this.dragEnabled=!1,this.filterPlaceholder="",this.filterPredicate=null,this.filterText="",this.headingLevel=2,this.knowledgeGraphOptions=null,this.layerTablesEnabled=new t(["knowledge-graph"]),this.listItemCanGiveFunction=null,this.listItemCanReceiveFunction=null,this.mapImageOptions=null,this.messages=null,this.messagesCommon=null,this.minDragEnabledItems=u,this.minFilterItems=g,this.openedLayers=new t,this.openedLayerLists=new t,this.selectedItems=new P,this.selectionMode="none",this.tableList=null,this.tileOptions=null,this.viewModel=new m,this.visibilityAppearance="default",this.visibleElements=new h,this._canMove=({dragEl:e,fromEl:t,toEl:i},o)=>{const s="pull"===o?this.listItemCanGiveFunction:this.listItemCanReceiveFunction,l=_(e);if(!l?.sortable)return!1;const r=_(t),a=L(t),n=_(i),d=L(i),p=!!a&&!!d&&a===d,c={selected:l,from:r,to:n},m=t.group,h=i.group,y=r?.layer?.type??"",u=n?.layer?.type??"",g=new Set(["map-image","catalog","knowledge-graph"]),f="sublayer";return m&&h&&"function"==typeof s?s.call(null,c):p&&!g.has(y)&&!g.has(u)&&l?.layer?.type!==f},this._onCatalogOpen=e=>{this.openedLayers.push(e.layer?.parent),this._focusLayerFlowItem=e.layer?.uid},this._onTablesOpen=e=>{this.openedLayers.push(e.layer),this._focusLayerFlowItem=e.layer?.uid},this._onPanelOpen=()=>{this._focusPanelFlowItem=!0},this._onTooltipReferenceChange=(e,t)=>{t?this._tooltipReferenceMap.set(e,t):this._tooltipReferenceMap.delete(e)},this._onSelectedDragItemLayerUidChange=e=>{this._selectedDragItemLayerUid=e},this._onTriggerAction=(e,t)=>{this.triggerAction(e,t)},this._clearActiveItem=()=>{this._activeItem=null},this._setActiveItem=e=>{if("default"!==this.visibilityAppearance)return;const t=Array.from(e.composedPath()).find((e=>e.classList?.contains(p.item)));this._activeItem=_(t)},this._onCalciteListOrderChange=e=>{const{_lastDragDetail:t}=this,{toEl:i,fromEl:o,dragEl:s,newIndex:l}=e;if(o&&i&&!(t?.newIndex===l&&t?.dragEl===s&&t?.toEl===i&&t?.fromEl===o))if(this._lastDragDetail=e,this._selectedDragItemLayerUid=s.value,o!==i)this._moveLayerFromChildList({toEl:i,fromEl:o,dragEl:s,newIndex:l});else{const e=Array.from(o.children).filter((e=>e?.matches("calcite-list-item"))).map((e=>e.value));this._sortLayers(o,e)}}}initialize(){this.addHandles([s((()=>this.openedLayers),"change",(()=>this._handleOpenedLayersChange()),r),s((()=>this.viewModel.operationalItems),"change",(()=>v(this.selectedItems)),r),l((()=>[this.filterPredicate,this._rootListEl]),(()=>b(this._rootListEl,this.filterPredicate)))])}loadDependencies(){return w({button:()=>import("@esri/calcite-components/dist/components/calcite-button"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")})}destroy(){this._destroyOpenedLayerLists(),this._tooltipReferenceMap.clear()}get _totalItems(){return this.viewModel.operationalItems.flatten((e=>e.children.filter((e=>"catalog-dynamic-group"!==e.layer?.type)))).length}get _visibleItems(){return this.operationalItems?.filter((e=>!e.hidden&&(this.visibleElements.errors||!e.error)))}get _openedPanelItems(){return this._visibleItems.flatten((e=>e.children)).filter((({hidden:e,panel:t})=>!e&&t?.open&&!t.disabled&&t.flowEnabled))}get _dragEnabled(){return this._totalItems>=this.minDragEnabledItems&&this.dragEnabled}get _filterEnabled(){return this._totalItems>=this.minFilterItems&&this.visibleElements.filter}get _renderedOpenLayerFlowItems(){const{openedLayers:e}=this;return e.toArray().map(((t,i)=>this._renderLayerFlowItem(t,i===e.length-1)))}get icon(){return"layers"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get listItemCreatedFunction(){return this.viewModel.listItemCreatedFunction}set listItemCreatedFunction(e){this.viewModel.listItemCreatedFunction=e}get operationalItems(){return this.viewModel.operationalItems}set operationalItems(e){this.viewModel.operationalItems=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}triggerAction(e,t){return this.viewModel.triggerAction(e,t)}render(){const e=this.viewModel?.state,{_visibleItems:t}=this,i={[C.hidden]:"loading"===e,[C.disabled]:"disabled"===e};return T("div",{class:this.classes(p.base,C.widget,C.panel,i)},t?.length?[this._renderItemTooltips(),this._renderItems()]:this._renderNoItems())}async _createFlowList(e,t){const{_layerListMap:i}=this,o=i.get(e);if(o)return o;const s="catalog"===e.type?await this._createCatalogLayerList(e):await this._createTableList(e);return t.aborted||i.set(e,s),s}async _handleOpenedLayersChange(){const{_layerListMap:e,openedLayers:t,openedLayerLists:i}=this;this._openedLayersController?.abort();const o=new AbortController,{signal:s}=o;this._openedLayersController=o,e.forEach(((i,o)=>{t.includes(o)||(i.destroy(),e.delete(o))}));const l=await Promise.all(t.map((e=>this._createFlowList(e,s))));if(s.aborted)return;i.removeAll(),i.addMany(l);const r=i.at(-1);r?"catalogLayer"in r?(this._set("catalogLayerList",r),this._set("tableList",null)):(this._set("catalogLayerList",null),this._set("tableList",r)):(this._set("catalogLayerList",null),this._set("tableList",null))}_destroyOpenedLayerLists(){this.openedLayerLists.destroyAll(),this.openedLayers.removeAll(),this._layerListMap.clear()}_renderItemTooltip(e){const{_tooltipReferenceMap:t,messages:i}=this;return e?T("calcite-tooltip",{key:`tooltip-${e.layer?.uid}`,referenceElement:t.get(e.layer?.uid)},i.layerIncompatibleTooltip):null}_renderItemTooltipNodes(e){return e.incompatible?this._renderItemTooltip(e):e.children?.filter((e=>!e.hidden)).toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderItemTooltips(){return this._visibleItems?.toArray().map((e=>this._renderItemTooltipNodes(e)))}_renderNoItemsMessage(){return T("div",{slot:"message"},this.messages.noItemsToDisplay)}_renderNoItems(){return T("div",{class:p.itemMessage,key:"esri-layer-list__no-items"},T("calcite-notice",{icon:"information",kind:"info",open:!0,width:"full"},this._renderNoItemsMessage()))}async _createCatalogLayerList(e){const{default:t}=await import("./CatalogLayerList.js"),{headingLevel:i,catalogOptions:o,view:s,filterPlaceholder:l,listItemCreatedFunction:r,minFilterItems:a,selectionMode:n,visibilityAppearance:d,_onCatalogOpen:p,_onTablesOpen:c,layerTablesEnabled:m}=this;return new t({headingLevel:i,view:s,filterPlaceholder:l,listItemCreatedFunction:r,minFilterItems:a,selectionMode:n,visibilityAppearance:d,...o,catalogLayer:e,layerTablesEnabled:m,onCatalogOpen:p,onTablesOpen:c})}_getTableListParams(e){switch(e.type){case"knowledge-graph":return{...this.knowledgeGraphOptions,tables:e.tables};case"map-image":return{...this.mapImageOptions,tables:e.subtables};case"tile":return{...this.tileOptions,tables:e.subtables};default:return null}}async _createTableList(e){const{default:t}=await import("./TableList.js"),{headingLevel:i,selectionMode:o,dragEnabled:s}=this;return new t({headingLevel:i,selectionMode:o,dragEnabled:s,...this._getTableListParams(e)})}_renderLayerFlowItem(e,t){const{messages:i,openedLayers:o}=this,s=e.title||this.messages.untitledLayer;return T("calcite-flow-item",{afterCreate:this._focusLayerFlowItemNode,afterUpdate:this._focusLayerFlowItemNode,bind:this,"data-layer-uid":e.uid,description:s,heading:i["catalog"===e.type?"catalogLayers":"tables"],headingLevel:this.headingLevel,key:`flow-layer-list-${e.uid}`,selected:t,onCalciteFlowItemBack:e=>{e.preventDefault(),o.pop();const t=o.at(-1);t?this._focusLayerFlowItem=t.uid:this._focusRootFlowItem=!0}},this._layerListMap.get(e)?.render())}_renderPanelFlowItems(){const{_openedPanelItems:e,openedLayers:t}=this;return e.toArray().map((({title:i,panel:o},s)=>{const l=()=>this._handlePanelFlowItemBack(o);return T("calcite-flow-item",{afterCreate:this._focusPanelFlowItemNode,afterUpdate:this._focusPanelFlowItemNode,bind:this,description:i,heading:o.title,headingLevel:this.headingLevel,key:`flow-panel-${o.uid}`,selected:!t.length&&s===e.length-1,onCalciteFlowItemBack:e=>{e.preventDefault(),l()}},o.render(),T("calcite-button",{appearance:"transparent",onclick:l,slot:"footer-actions",width:"full"},this.messagesCommon.back))}))}_handlePanelFlowItemBack(e){e.open=!1,this._focusRootFlowItem=!0}_focusRootFlowItemNode(e){this._focusRootFlowItem&&(this._focusRootFlowItem=!1,F(e))}_focusLayerFlowItemNode(e){this._focusLayerFlowItem===e.dataset.layerUid&&(this._focusLayerFlowItem=null,F(e))}_focusPanelFlowItemNode(e){this._focusPanelFlowItem&&(this._focusPanelFlowItem=!1,F(e))}_renderItems(){const{visible:e,collapsed:t,_visibleItems:i,_openedPanelItems:o,_filterEnabled:s,_rootGroupUid:l,visibleElements:{closeButton:r,collapseButton:a,heading:n,flow:d},_dragEnabled:c,selectionMode:m,filterText:h,openedLayers:y,filterPlaceholder:u,messages:g}=this,_=[T("calcite-flow-item",{afterCreate:this._focusRootFlowItemNode,afterUpdate:this._focusRootFlowItemNode,bind:this,closable:r,closed:!e,collapsed:t,collapsible:a,heading:n?g.widgetLabel:void 0,headingLevel:this.headingLevel,key:"root-flow-item",selected:!y.length&&!o.length,onCalciteFlowItemClose:()=>this.visible=!1},T("calcite-list",{afterCreate:e=>{this._rootListEl=e,e.addEventListener("focusin",this._setActiveItem),e.addEventListener("focusout",this._clearActiveItem)},afterRemoved:e=>{this._rootListEl=null,e.removeEventListener("focusin",this._setActiveItem),e.removeEventListener("focusout",this._clearActiveItem)},canPull:e=>this._canMove(e,"pull"),canPut:e=>this._canMove(e,"put"),"data-layer-type":l,displayMode:A,dragEnabled:c,filterEnabled:s,filterPlaceholder:u,filterProps:E,filterText:s?h:"",group:l,key:"root-list",label:g.widgetLabel,onmouseleave:this._clearActiveItem,onmouseover:this._setActiveItem,selectionAppearance:"border",selectionMode:m,onCalciteListChange:e=>this._handleCalciteListChange(e),onCalciteListDragEnd:e=>this._handleCalciteListDragEnd(e.detail),onCalciteListFilter:e=>this.filterText=e.currentTarget?.filterText??"",onCalciteListOrderChange:e=>this._onCalciteListOrderChange(e.detail)},i?.toArray().map((e=>this._renderItem(e))),i?.length&&s?T("div",{class:p.filterNoResults,slot:"filter-no-results"},T("calcite-notice",{kind:"info",open:!0,width:"full"},this._renderNoItemsMessage())):null)),this._renderPanelFlowItems(),this._renderedOpenLayerFlowItems];return e?d?T("calcite-flow",{key:"root-flow"},_):_:null}_renderItem(e,t,i){return T(c,{activeItem:this._activeItem,canMove:this._canMove,css:p,displayMode:A,dragEnabled:this.dragEnabled,item:e,key:`layerListItem-${e.layer?.uid}`,layerTablesEnabled:this.layerTablesEnabled,listModeDisabled:this.viewModel.listModeDisabled,messages:this.messages,messagesCommon:this.messagesCommon,parent:t,parentTitles:i,rootGroupUid:this._rootGroupUid,selectedDragItemLayerUid:this._selectedDragItemLayerUid,selectedItems:this.selectedItems,selectionMode:this.selectionMode,visibilityAppearance:this.visibilityAppearance,visibleElements:this.visibleElements,onAction:this._onTriggerAction,onCatalogOpen:this._onCatalogOpen,onPanelOpen:this._onPanelOpen,onSelectedDragItemLayerUidChange:this._onSelectedDragItemLayerUidChange,onTablesOpen:this._onTablesOpen,onTooltipReferenceChange:this._onTooltipReferenceChange})}_moveLayerFromChildList({toEl:e,fromEl:t,dragEl:i,newIndex:o}){const s=_(i),l=_(e),r=_(t);this.viewModel.moveListItem(s,r,l,o)}_handleCalciteListDragEnd(e){const{fromEl:t,dragEl:i,oldIndex:o}=e;t.insertBefore(i,t.children[o])}_sortLayers(e,t){if(e)if(e===this._rootListEl)f(this.view?.map?.layers,t);else{const i=_(e);if(!i)return;I(i,t)}}_handleCalciteListChange(e){const{selectionMode:t,selectedItems:i}=this;if("none"===t)return;const o=e.target.selectedItems.map((e=>_(e))).filter(Boolean);i.removeAll(),i.addMany(o)}};e([a()],j.prototype,"_rootListEl",void 0),e([a()],j.prototype,"_activeItem",void 0),e([a()],j.prototype,"_tooltipReferenceMap",void 0),e([a()],j.prototype,"_focusRootFlowItem",void 0),e([a()],j.prototype,"_focusPanelFlowItem",void 0),e([a()],j.prototype,"_focusLayerFlowItem",void 0),e([a()],j.prototype,"_layerListMap",void 0),e([a()],j.prototype,"_totalItems",null),e([a()],j.prototype,"_visibleItems",null),e([a()],j.prototype,"_openedPanelItems",null),e([a()],j.prototype,"_dragEnabled",null),e([a()],j.prototype,"_filterEnabled",null),e([a()],j.prototype,"_renderedOpenLayerFlowItems",null),e([a({readOnly:!0})],j.prototype,"catalogLayerList",void 0),e([a()],j.prototype,"catalogOptions",void 0),e([a()],j.prototype,"collapsed",void 0),e([a()],j.prototype,"dragEnabled",void 0),e([a()],j.prototype,"filterPlaceholder",void 0),e([a()],j.prototype,"filterPredicate",void 0),e([a()],j.prototype,"filterText",void 0),e([a()],j.prototype,"headingLevel",void 0),e([a()],j.prototype,"icon",null),e([a()],j.prototype,"knowledgeGraphOptions",void 0),e([a()],j.prototype,"label",null),e([a()],j.prototype,"layerTablesEnabled",void 0),e([a()],j.prototype,"listItemCanGiveFunction",void 0),e([a()],j.prototype,"listItemCanReceiveFunction",void 0),e([a()],j.prototype,"listItemCreatedFunction",null),e([a()],j.prototype,"mapImageOptions",void 0),e([a(),M("esri/widgets/LayerList/t9n/LayerList")],j.prototype,"messages",void 0),e([a(),M("esri/t9n/common")],j.prototype,"messagesCommon",void 0),e([a()],j.prototype,"minDragEnabledItems",void 0),e([a()],j.prototype,"minFilterItems",void 0),e([a({readOnly:!0})],j.prototype,"openedLayers",void 0),e([a({readOnly:!0})],j.prototype,"openedLayerLists",void 0),e([a()],j.prototype,"operationalItems",null),e([a()],j.prototype,"selectedItems",void 0),e([a()],j.prototype,"selectionMode",void 0),e([a({readOnly:!0})],j.prototype,"tableList",void 0),e([a()],j.prototype,"tileOptions",void 0),e([a()],j.prototype,"view",null),e([O("trigger-action"),a({type:m})],j.prototype,"viewModel",void 0),e([a()],j.prototype,"visibilityAppearance",void 0),e([a({type:h,nonNullable:!0})],j.prototype,"visibleElements",void 0),j=e([n("esri.widgets.LayerList")],j);const D=j;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.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import i from"../../core/Accessor.js";import r from"../../core/Collection.js";import{watch as t,initial as s,when as a}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{get as l}from"../../core/accessorSupport/get.js";import{getEffectiveFeatureReduction as y}from"../../views/2d/layers/features/layerAdapters/featureReductionUtils.js";import d from"./support/ActiveLayerInfo.js";import{onLocaleChange as h}from"../../intl/locale.js";const c={state:"state",view:"view",allLayerViews:"all-layer-views",legendProperties:"legend-properties"},L=r.ofType(d),p=new Set(["esri.layers.BuildingSceneLayer","esri.layers.CatalogLayer","esri.layers.CSVLayer","esri.layers.FeatureLayer","esri.layers.GeoJSONLayer","esri.layers.GeoRSSLayer","esri.layers.GroupLayer","esri.layers.HeatmapLayer","esri.layers.ImageryLayer","esri.layers.ImageryTileLayer","esri.layers.MapImageLayer","esri.layers.OGCFeatureLayer","esri.layers.OrientedImageryLayer","esri.layers.ParquetLayer","esri.layers.PointCloudLayer","esri.layers.StreamLayer","esri.layers.SceneLayer","esri.layers.SubtypeGroupLayer","esri.layers.TileLayer","esri.layers.VoxelLayer","esri.layers.WFSLayer","esri.layers.WMSLayer","esri.layers.WMTSLayer","esri.layers.WCSLayer","esri.layers.LinkChartLayer","esri.layers.catalog.CatalogFootprintLayer","esri.layers.catalog.CatalogDynamicGroupLayer","esri.layers.knowledgeGraph.KnowledgeGraphSublayer","esri.layers.KnowledgeGraphLayer"]),u="view.basemapView.baseLayerViews",f="view.groundView.layerViews",v="view.basemapView.referenceLayerViews",_=[u,f,"view.layerViews",v];let w=class extends i{constructor(e){super(e),this._layerViewByLayerId={},this._layerInfosByLayerViewId={},this._activeLayerInfosByLayerViewId={},this._activeLayerInfosWithNoParent=new r,this.activeLayerInfos=new L,this.basemapLegendVisible=!1,this.groundLegendVisible=!1,this.hideLayersNotInCurrentView=!1,this.keepCacheOnDestroy=!1,this.respectLayerDefinitionExpression=!1,this.respectLayerVisibility=!0,this.layerInfos=[],this.view=null}initialize(){this.addHandles(t((()=>this.view),(()=>this._viewHandles()),s),c.view),this.addHandles(h((()=>this._refresh())))}destroy(){this._destroyViewActiveLayerInfos(),this.view=null}get state(){return this.view?.ready?"ready":"disabled"}_viewHandles(){this.removeHandles(c.state),this.view&&this.addHandles(t((()=>this.state),(()=>this._stateHandles()),s),c.state)}_stateHandles(){this._resetAll(),"ready"===this.state&&this._watchPropertiesAndAllLayerViews()}_resetAll(){this.removeHandles([c.allLayerViews,c.legendProperties]),this._destroyViewActiveLayerInfos(),this.activeLayerInfos.removeAll()}_destroyViewActiveLayerInfos(){Object.keys(this._activeLayerInfosByLayerViewId).forEach(this._destroyViewActiveLayerInfo,this)}_destroyViewActiveLayerInfo(e){this.removeHandles(e);const i=this._activeLayerInfosByLayerViewId[e];delete this._activeLayerInfosByLayerViewId[e],i?.parent&&i.parent.children.remove(i)}_watchPropertiesAndAllLayerViews(){const{view:e}=this;if(!e)return;const{allLayerViews:i}=e;i.length&&this._refresh(),this.addHandles(i.on("change",(e=>this._allLayerViewsChangeHandle(e))),c.allLayerViews),this.addHandles(t((()=>[this.layerInfos,this.basemapLegendVisible,this.groundLegendVisible]),(()=>this._propertiesChangeHandle())),c.legendProperties)}_allLayerViewsChangeHandle(e){e.moved.length?this._propertiesChangeHandle():(e.removed.forEach((e=>this._destroyViewActiveLayerInfo(e.uid))),this._refresh())}_propertiesChangeHandle(){this._destroyViewActiveLayerInfos(),this._refresh()}_refresh(){this._layerInfosByLayerViewId={},this.activeLayerInfos.removeAll(),this._generateLayerViews().filter(this._filterLayerViewsByLayerInfos,this).filter(this._isLayerViewSupported,this).forEach(this._generateActiveLayerInfo,this),this._sortActiveLayerInfos(this.activeLayerInfos)}_sortActiveLayerInfos(e){const i=this.view;if(e.length<2||!i)return;const r=[];e.forEach((i=>{if(!i.parent){const t=i.layer.parent,s=t&&"uid"in t&&this._layerViewByLayerId[t.uid],a=s&&this._activeLayerInfosByLayerViewId[s.uid];a&&e.includes(a)&&(r.push(i),i.parent=a,a.children.add(i),this._sortActiveLayerInfos(a.children))}})),e.removeMany(r);const t={};i.allLayerViews.forEach(((e,i)=>t[e.layer.uid]=i)),e.sort(((e,i)=>{const r=t[e.layer.uid]||0;return(t[i.layer.uid]||0)-r}))}_generateLayerViews(){const e=[];return _.filter(this._filterLayerViews,this).map((e=>l(this,e))).filter((e=>null!=e)).forEach(this._collectLayerViews("layerViews",e)),e}_filterLayerViews(e){const i=!this.basemapLegendVisible&&(e===u||e===v),r=!this.groundLegendVisible&&e===f;return!i&&!r}_collectLayerViews(e,i){const r=t=>(t&&t.forEach((t=>{i.push(t),r(t[e])})),i);return r}_filterLayerViewsByLayerInfos(e){const i=this.layerInfos;return!i||!i.length||i.some((i=>this._hasLayerInfo(i,e)))}_hasLayerInfo(e,i){const r=this._isLayerUIDMatching(e.layer,i.layer.uid);return r&&(this._layerInfosByLayerViewId[i.uid]=e),r}_isLayerUIDMatching(e,i){return e&&(e.uid===i||this._hasLayerUID(e.layers,i))}_hasLayerUID(e,i){return e&&e.some((e=>this._isLayerUIDMatching(e,i)))}_isLayerViewSupported(e){return!!p.has(e.layer.declaredClass)&&(this._layerViewByLayerId[e.layer.uid]=e,!0)}_generateActiveLayerInfo(e){this._isLayerActive(e)?this._buildActiveLayerInfo(e):(this.removeHandles(e.uid),this.addHandles(t((()=>[e.legendEnabled,e.layer?.legendEnabled]),(()=>this._layerActiveHandle(e))),e.uid))}_layerActiveHandle(e){this._isLayerActive(e)&&(this.removeHandles(e.uid),this._buildActiveLayerInfo(e))}_isLayerActive(e){return!this.respectLayerVisibility||e.legendEnabled&&e.layer?.legendEnabled}_buildActiveLayerInfo(e){const i=e.layer,r=e.uid,n=this._layerInfosByLayerViewId[r];let o=this._activeLayerInfosByLayerViewId[r];if(!o){const t=void 0!==n?.title&&n.layer.uid===i.uid;o=new d({layer:i,layerView:e,title:t?n.title:i.title,view:this.view??void 0,respectLayerDefinitionExpression:this.respectLayerDefinitionExpression,respectLayerVisibility:this.respectLayerVisibility,hideLayersNotInCurrentView:this.hideLayersNotInCurrentView,keepCacheOnDestroy:this.keepCacheOnDestroy,sublayerIds:n?.sublayerIds||[]}),this._activeLayerInfosByLayerViewId[r]=o}const l=i.parent&&"uid"in i.parent?this._layerViewByLayerId[i.parent?.uid]:null;if(o.parent=this._activeLayerInfosByLayerViewId[l?.uid],!this.hasHandles(r)){const n=[t((()=>i.title),(e=>this._titleHandle(e,o))),t((()=>[i.opacity,"renderer"in i&&i.renderer,"pointSymbol"in i&&i.pointSymbol,"lineSymbol"in i&&i.lineSymbol,"polygonSymbol"in i&&i.polygonSymbol]),(()=>this._constructLegendElements(o))),a((()=>!0===this.view?.stationary),(()=>this._scaleHandle(o)),s),t((()=>e.layer?y(e.layer,e.view):null),(()=>this._constructLegendElements(o))),t((()=>e.updating),(()=>{if(null==e.layer)return;null!=y(e.layer,e.view)&&this._constructLegendElements(o)})),t((()=>"effect"in i&&i.effect),(()=>this._constructLegendElements(o))),a((()=>this.view?.timeZone),(()=>this._constructLegendElements(o)),s)];if(this.respectLayerVisibility){const r=t((()=>e.legendEnabled),(e=>this._legendEnabledHandle(e,o))),s=t((()=>i.legendEnabled),(e=>this._legendEnabledHandle(e,o)));n.push(r,s)}if(this.respectLayerDefinitionExpression&&"definitionExpression"in i){const e=t((()=>[i.definitionExpression,this.respectLayerDefinitionExpression]),(()=>{o.respectLayerDefinitionExpression=this.respectLayerDefinitionExpression,this._constructLegendElements(o)}));n.push(e)}this.addHandles(n,r)}o.isScaleDriven||this._constructLegendElements(o),this._addActiveLayerInfo(o)}_titleHandle(e,i){i.title=e,this._constructLegendElements(i)}_legendEnabledHandle(e,i){e?this._addActiveLayerInfo(i):this._removeActiveLayerInfo(i)}_scaleHandle(e){(e.isScaleDriven||e.hideLayersNotInCurrentView)&&this._constructLegendElements(e)}_addActiveLayerInfo(e){const{layerView:i,layer:r}=e;if(this._isLayerActive(i)&&!this.activeLayerInfos.includes(e)){const i=e.parent;if(i)i.children.includes(e)||i.children.push(e),this._sortActiveLayerInfos(i.children);else{const i=this.layerInfos?.some((e=>e.layer.uid===r.uid)),t=r.parent;(t&&"uid"in t?this._layerViewByLayerId[t.uid]:null)&&!i?this._activeLayerInfosWithNoParent.add(e):(this.activeLayerInfos.add(e),this._sortActiveLayerInfos(this.activeLayerInfos))}if(this._activeLayerInfosWithNoParent.length){const e=[];this._activeLayerInfosWithNoParent.forEach((i=>{const r=i.layer.parent,t=r&&"uid"in r?this._layerViewByLayerId[r?.uid]:null,s=this._activeLayerInfosByLayerViewId[t?.uid];s&&(e.push(i),i.parent=s)})),e.length&&(this._activeLayerInfosWithNoParent.removeMany(e),e.forEach((e=>this._addActiveLayerInfo(e))))}}}_removeActiveLayerInfo(e){const i=e.parent;i?i.children.remove(e):this.activeLayerInfos.remove(e)}_constructLegendElements(e){const i=e.layer;"featureCollections"in i&&i.featureCollections?e.buildLegendElementsForFeatureCollections(i.featureCollections):"featureReduction"in i&&i.featureReduction&&"renderer"in i.featureReduction&&("binning"===i.featureReduction.type||"cluster"===i.featureReduction.type)&&(!this.view||i.featureReduction.maxScale<=this.view.scale)?e.buildLegendElementsForFeatureReduction(i.featureReduction):"renderer"in i&&i.renderer&&!("sublayers"in i)?e.buildLegendElementsForRenderer(i.renderer):"url"in i&&i.url&&"catalog"!==i.type&&"knowledge-graph"!==i.type?e.buildLegendElementsForTools():e.children.forEach((e=>this._constructLegendElements(e)))}};e([n({type:L})],w.prototype,"activeLayerInfos",void 0),e([n()],w.prototype,"basemapLegendVisible",void 0),e([n()],w.prototype,"groundLegendVisible",void 0),e([n()],w.prototype,"hideLayersNotInCurrentView",void 0),e([n()],w.prototype,"keepCacheOnDestroy",void 0),e([n()],w.prototype,"respectLayerDefinitionExpression",void 0),e([n()],w.prototype,"respectLayerVisibility",void 0),e([n()],w.prototype,"layerInfos",void 0),e([n({readOnly:!0})],w.prototype,"state",null),e([n()],w.prototype,"view",void 0),w=e([o("esri.widgets.Legend.LegendViewModel")],w);const I=w;export{I as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import i from"../../core/Accessor.js";import r from"../../core/Collection.js";import{watch as t,initial as s,when as a}from"../../core/reactiveUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as o}from"../../core/accessorSupport/decorators/subclass.js";import{get as l}from"../../core/accessorSupport/get.js";import{getEffectiveFeatureReduction as y}from"../../views/2d/layers/features/layerAdapters/featureReductionUtils.js";import d from"./support/ActiveLayerInfo.js";import{onLocaleChange as c}from"../../intl/locale.js";const h={state:"state",view:"view",allLayerViews:"all-layer-views",legendProperties:"legend-properties"},L=r.ofType(d),p=new Set(["esri.layers.BuildingSceneLayer","esri.layers.CatalogLayer","esri.layers.CSVLayer","esri.layers.FeatureLayer","esri.layers.GeoJSONLayer","esri.layers.GeoRSSLayer","esri.layers.GroupLayer","esri.layers.HeatmapLayer","esri.layers.ImageryLayer","esri.layers.ImageryTileLayer","esri.layers.MapImageLayer","esri.layers.OGCFeatureLayer","esri.layers.OrientedImageryLayer","esri.layers.ParquetLayer","esri.layers.PointCloudLayer","esri.layers.StreamLayer","esri.layers.SceneLayer","esri.layers.SubtypeGroupLayer","esri.layers.TileLayer","esri.layers.VoxelLayer","esri.layers.WFSLayer","esri.layers.WMSLayer","esri.layers.WMTSLayer","esri.layers.WCSLayer","esri.layers.LinkChartLayer","esri.layers.catalog.CatalogFootprintLayer","esri.layers.catalog.CatalogDynamicGroupLayer","esri.layers.knowledgeGraph.KnowledgeGraphSublayer","esri.layers.KnowledgeGraphLayer"]),u="view.basemapView.baseLayerViews",f="view.groundView.layerViews",v="view.basemapView.referenceLayerViews",_=[u,f,"view.layerViews",v];let w=class extends i{constructor(e){super(e),this._layerViewByLayerId={},this._layerInfosByLayerViewId={},this._activeLayerInfosByLayerViewId={},this._activeLayerInfosWithNoParent=new r,this.activeLayerInfos=new L,this.basemapLegendVisible=!1,this.groundLegendVisible=!1,this.hideLayersNotInCurrentView=!1,this.keepCacheOnDestroy=!1,this.respectLayerDefinitionExpression=!1,this.respectLayerDisplayFilter=!1,this.respectLayerVisibility=!0,this.layerInfos=[],this.view=null}initialize(){this.addHandles(t((()=>this.view),(()=>this._viewHandles()),s),h.view),this.addHandles(c((()=>this._refresh())))}destroy(){this._destroyViewActiveLayerInfos(),this.view=null}get state(){return this.view?.ready?"ready":"disabled"}_viewHandles(){this.removeHandles(h.state),this.view&&this.addHandles(t((()=>this.state),(()=>this._stateHandles()),s),h.state)}_stateHandles(){this._resetAll(),"ready"===this.state&&this._watchPropertiesAndAllLayerViews()}_resetAll(){this.removeHandles([h.allLayerViews,h.legendProperties]),this._destroyViewActiveLayerInfos(),this.activeLayerInfos.removeAll()}_destroyViewActiveLayerInfos(){Object.keys(this._activeLayerInfosByLayerViewId).forEach(this._destroyViewActiveLayerInfo,this)}_destroyViewActiveLayerInfo(e){this.removeHandles(e);const i=this._activeLayerInfosByLayerViewId[e];delete this._activeLayerInfosByLayerViewId[e],i?.parent&&i.parent.children.remove(i)}_watchPropertiesAndAllLayerViews(){const{view:e}=this;if(!e)return;const{allLayerViews:i}=e;i.length&&this._refresh(),this.addHandles(i.on("change",(e=>this._allLayerViewsChangeHandle(e))),h.allLayerViews),this.addHandles(t((()=>[this.layerInfos,this.basemapLegendVisible,this.groundLegendVisible]),(()=>this._propertiesChangeHandle())),h.legendProperties)}_allLayerViewsChangeHandle(e){e.moved.length?this._propertiesChangeHandle():(e.removed.forEach((e=>this._destroyViewActiveLayerInfo(e.uid))),this._refresh())}_propertiesChangeHandle(){this._destroyViewActiveLayerInfos(),this._refresh()}_refresh(){this._layerInfosByLayerViewId={},this.activeLayerInfos.removeAll(),this._generateLayerViews().filter(this._filterLayerViewsByLayerInfos,this).filter(this._isLayerViewSupported,this).forEach(this._generateActiveLayerInfo,this),this._sortActiveLayerInfos(this.activeLayerInfos)}_sortActiveLayerInfos(e){const i=this.view;if(e.length<2||!i)return;const r=[];e.forEach((i=>{if(!i.parent){const t=i.layer.parent,s=t&&"uid"in t&&this._layerViewByLayerId[t.uid],a=s&&this._activeLayerInfosByLayerViewId[s.uid];a&&e.includes(a)&&(r.push(i),i.parent=a,a.children.add(i),this._sortActiveLayerInfos(a.children))}})),e.removeMany(r);const t={};i.allLayerViews.forEach(((e,i)=>t[e.layer.uid]=i)),e.sort(((e,i)=>{const r=t[e.layer.uid]||0;return(t[i.layer.uid]||0)-r}))}_generateLayerViews(){const e=[];return _.filter(this._filterLayerViews,this).map((e=>l(this,e))).filter((e=>null!=e)).forEach(this._collectLayerViews("layerViews",e)),e}_filterLayerViews(e){const i=!this.basemapLegendVisible&&(e===u||e===v),r=!this.groundLegendVisible&&e===f;return!i&&!r}_collectLayerViews(e,i){const r=t=>(t&&t.forEach((t=>{i.push(t),r(t[e])})),i);return r}_filterLayerViewsByLayerInfos(e){const i=this.layerInfos;return!i||!i.length||i.some((i=>this._hasLayerInfo(i,e)))}_hasLayerInfo(e,i){const r=this._isLayerUIDMatching(e.layer,i.layer.uid);return r&&(this._layerInfosByLayerViewId[i.uid]=e),r}_isLayerUIDMatching(e,i){return e&&(e.uid===i||this._hasLayerUID(e.layers,i))}_hasLayerUID(e,i){return e&&e.some((e=>this._isLayerUIDMatching(e,i)))}_isLayerViewSupported(e){return!!p.has(e.layer.declaredClass)&&(this._layerViewByLayerId[e.layer.uid]=e,!0)}_generateActiveLayerInfo(e){this._isLayerActive(e)?this._buildActiveLayerInfo(e):(this.removeHandles(e.uid),this.addHandles(t((()=>[e.legendEnabled,e.layer?.legendEnabled]),(()=>this._layerActiveHandle(e))),e.uid))}_layerActiveHandle(e){this._isLayerActive(e)&&(this.removeHandles(e.uid),this._buildActiveLayerInfo(e))}_isLayerActive(e){return!this.respectLayerVisibility||e.legendEnabled&&e.layer?.legendEnabled}_buildActiveLayerInfo(e){const i=e.layer,r=e.uid,n=this._layerInfosByLayerViewId[r];let o=this._activeLayerInfosByLayerViewId[r];if(!o){const t=void 0!==n?.title&&n.layer.uid===i.uid;o=new d({layer:i,layerView:e,title:t?n.title:i.title,view:this.view??void 0,respectLayerDefinitionExpression:this.respectLayerDefinitionExpression,respectLayerDisplayFilter:this.respectLayerDisplayFilter,respectLayerVisibility:this.respectLayerVisibility,hideLayersNotInCurrentView:this.hideLayersNotInCurrentView,keepCacheOnDestroy:this.keepCacheOnDestroy,sublayerIds:n?.sublayerIds||[]}),this._activeLayerInfosByLayerViewId[r]=o}const l=i.parent&&"uid"in i.parent?this._layerViewByLayerId[i.parent?.uid]:null;if(o.parent=this._activeLayerInfosByLayerViewId[l?.uid],!this.hasHandles(r)){const n=[t((()=>i.title),(e=>this._titleHandle(e,o))),t((()=>[i.opacity,"renderer"in i&&i.renderer,"pointSymbol"in i&&i.pointSymbol,"lineSymbol"in i&&i.lineSymbol,"polygonSymbol"in i&&i.polygonSymbol]),(()=>this._constructLegendElements(o))),a((()=>!0===this.view?.stationary),(()=>this._scaleHandle(o)),s),t((()=>e.layer?y(e.layer,e.view):null),(()=>this._constructLegendElements(o))),t((()=>e.updating),(()=>{if(null==e.layer)return;null!=y(e.layer,e.view)&&this._constructLegendElements(o)})),t((()=>"effect"in i&&i.effect),(()=>this._constructLegendElements(o))),a((()=>this.view?.timeZone),(()=>this._constructLegendElements(o)),s)];if(this.respectLayerVisibility){const r=t((()=>e.legendEnabled),(e=>this._legendEnabledHandle(e,o))),s=t((()=>i.legendEnabled),(e=>this._legendEnabledHandle(e,o)));n.push(r,s)}if(this.respectLayerDefinitionExpression&&"definitionExpression"in i){const e=t((()=>[i.definitionExpression,this.respectLayerDefinitionExpression]),(()=>{o.respectLayerDefinitionExpression=this.respectLayerDefinitionExpression,this._constructLegendElements(o)}));n.push(e)}if(this.respectLayerDisplayFilter&&"displayFilterInfo"in i){const e=t((()=>this.respectLayerDisplayFilter),(()=>{o.respectLayerDisplayFilter=this.respectLayerDisplayFilter,this._constructLegendElements(o)}));n.push(e)}this.addHandles(n,r)}o.isScaleDriven||this._constructLegendElements(o),this._addActiveLayerInfo(o)}_titleHandle(e,i){i.title=e,this._constructLegendElements(i)}_legendEnabledHandle(e,i){e?this._addActiveLayerInfo(i):this._removeActiveLayerInfo(i)}_scaleHandle(e){(e.isScaleDriven||e.hideLayersNotInCurrentView)&&this._constructLegendElements(e)}_addActiveLayerInfo(e){const{layerView:i,layer:r}=e;if(this._isLayerActive(i)&&!this.activeLayerInfos.includes(e)){const i=e.parent;if(i)i.children.includes(e)||i.children.push(e),this._sortActiveLayerInfos(i.children);else{const i=this.layerInfos?.some((e=>e.layer.uid===r.uid)),t=r.parent;(t&&"uid"in t?this._layerViewByLayerId[t.uid]:null)&&!i?this._activeLayerInfosWithNoParent.add(e):(this.activeLayerInfos.add(e),this._sortActiveLayerInfos(this.activeLayerInfos))}if(this._activeLayerInfosWithNoParent.length){const e=[];this._activeLayerInfosWithNoParent.forEach((i=>{const r=i.layer.parent,t=r&&"uid"in r?this._layerViewByLayerId[r?.uid]:null,s=this._activeLayerInfosByLayerViewId[t?.uid];s&&(e.push(i),i.parent=s)})),e.length&&(this._activeLayerInfosWithNoParent.removeMany(e),e.forEach((e=>this._addActiveLayerInfo(e))))}}}_removeActiveLayerInfo(e){const i=e.parent;i?i.children.remove(e):this.activeLayerInfos.remove(e)}_constructLegendElements(e){const i=e.layer;"featureCollections"in i&&i.featureCollections?e.buildLegendElementsForFeatureCollections(i.featureCollections):"featureReduction"in i&&i.featureReduction&&"renderer"in i.featureReduction&&("binning"===i.featureReduction.type||"cluster"===i.featureReduction.type)&&(!this.view||i.featureReduction.maxScale<=this.view.scale)?e.buildLegendElementsForFeatureReduction(i.featureReduction):"renderer"in i&&i.renderer&&!("sublayers"in i)?e.buildLegendElementsForRenderer(i.renderer):"url"in i&&i.url&&"catalog"!==i.type&&"knowledge-graph"!==i.type?e.buildLegendElementsForTools():e.children.forEach((e=>this._constructLegendElements(e)))}};e([n({type:L})],w.prototype,"activeLayerInfos",void 0),e([n()],w.prototype,"basemapLegendVisible",void 0),e([n()],w.prototype,"groundLegendVisible",void 0),e([n()],w.prototype,"hideLayersNotInCurrentView",void 0),e([n()],w.prototype,"keepCacheOnDestroy",void 0),e([n()],w.prototype,"respectLayerDefinitionExpression",void 0),e([n()],w.prototype,"respectLayerDisplayFilter",void 0),e([n()],w.prototype,"respectLayerVisibility",void 0),e([n()],w.prototype,"layerInfos",void 0),e([n({readOnly:!0})],w.prototype,"state",null),e([n()],w.prototype,"view",void 0),w=e([o("esri.widgets.Legend.LegendViewModel")],w);const I=w;export{I as default};