@arcgis/core 4.33.0-next.20250423 → 4.33.0-next.20250425

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 (294) hide show
  1. package/Graphic.js +1 -1
  2. package/WebScene.js +1 -1
  3. package/analysis/Analysis.d.ts +4 -0
  4. package/analysis/Analysis.js +1 -1
  5. package/analysis/SliceAnalysis.js +1 -1
  6. package/analysis/SlicePlane.js +1 -1
  7. package/analysis/support/AnalysisOriginWebScene.d.ts +4 -0
  8. package/analysis/support/AnalysisOriginWebScene.js +5 -0
  9. package/analysis/support/SliceAnalysisExcludedLayer.js +5 -0
  10. package/assets/esri/core/workers/RemoteClient.js +1 -1
  11. package/assets/esri/core/workers/chunks/{d4d011eea16a89a5aad9.js → 0219c3f9408d3fa3c9a0.js} +1 -1
  12. package/assets/esri/core/workers/chunks/070839cb71c8e764b8d7.js +1 -0
  13. package/assets/esri/core/workers/chunks/19084a293694c5a00cae.js +1 -0
  14. package/assets/esri/core/workers/chunks/{8ba7d44eff348004f084.js → 1a6d2d090b643a87408a.js} +1 -1
  15. package/assets/esri/core/workers/chunks/1b8cc83aa1179245b2dc.js +1 -0
  16. package/assets/esri/core/workers/chunks/{5e5225623977e61fd0ef.js → 213adc87c843d627c5d6.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{fa8a3c75f9b41d31559b.js → 265f69d153b7b6f07e42.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{769b66cca8347f0f84db.js → 279bbd61b32577693a4a.js} +1 -1
  19. package/assets/esri/core/workers/chunks/290b065b377f9d2ee058.js +1 -0
  20. package/assets/esri/core/workers/chunks/29d3245261a7223124ed.js +1 -0
  21. package/assets/esri/core/workers/chunks/2bed8a5ed9ae3760fa2f.js +1 -0
  22. package/assets/esri/core/workers/chunks/2e3019ce49e972a815ca.js +1 -0
  23. package/assets/esri/core/workers/chunks/335b539893569e3d7b82.js +1 -0
  24. package/assets/esri/core/workers/chunks/38f5e6a202ce292edd9f.js +1 -0
  25. package/assets/esri/core/workers/chunks/415903f481392c72870f.js +1 -0
  26. package/assets/esri/core/workers/chunks/4351b3e54b309935faed.js +1 -0
  27. package/assets/esri/core/workers/chunks/4da99f058cca83937e9b.js +1 -0
  28. package/assets/esri/core/workers/chunks/5acdd49c5f1a49fdc6e7.js +1 -0
  29. package/assets/esri/core/workers/chunks/60f7cd05e88701f43d3f.js +1 -0
  30. package/assets/esri/core/workers/chunks/{26e0a0a13060cd3e4291.js → 626ba3a7dee952308566.js} +1 -1
  31. package/assets/esri/core/workers/chunks/7cd32b10ed0e18e44ef2.js +1 -0
  32. package/assets/esri/core/workers/chunks/9661ee8569ee208e6237.js +1 -0
  33. package/assets/esri/core/workers/chunks/968f2f841c011095a6d2.js +1 -0
  34. package/assets/esri/core/workers/chunks/974742af7beb000c4b4a.js +1 -0
  35. package/assets/esri/core/workers/chunks/{e27fa1e84f16b7f19a90.js → 9850ff14bd9c7da81c65.js} +1 -1
  36. package/assets/esri/core/workers/chunks/a0c51c4c30a5f749dfc6.js +1 -0
  37. package/assets/esri/core/workers/chunks/a2676f3f135ad5fdf872.js +1 -0
  38. package/assets/esri/core/workers/chunks/a8430e1e2142f1ce9b92.js +1 -0
  39. package/assets/esri/core/workers/chunks/{fdcbd28f38bc485ac5e3.js → ab6ecd8eeec5ff761b34.js} +1 -1
  40. package/assets/esri/core/workers/chunks/b53300b46646cfad2526.js +319 -0
  41. package/assets/esri/core/workers/chunks/bf543bdec3da0fe278fb.js +1 -0
  42. package/assets/esri/core/workers/chunks/{5bdd5ae2d2f23ef6b331.js → c87e2a63b96e0da77dfe.js} +1 -1
  43. package/assets/esri/core/workers/chunks/cc4dd739c4c7e3ccea3f.js +1 -0
  44. package/assets/esri/core/workers/chunks/d3a74087e076a3ae76ca.js +1 -0
  45. package/assets/esri/core/workers/chunks/{7c42281188b874ffcdad.js → db5913824d5e5a2a8365.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{48a1bb1e171dd06a7c6e.js → dd94585508f49863dc15.js} +1 -1
  47. package/assets/esri/core/workers/chunks/{9408a72968cbd985dd24.js → f2cef954b58c6604642c.js} +34 -34
  48. package/assets/esri/core/workers/chunks/f52e597dca4b32a81881.js +1 -0
  49. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  50. package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
  51. package/chunks/BloomBlur.glsl.js +7 -7
  52. package/chunks/BloomComposition.glsl.js +24 -25
  53. package/chunks/ShadowCastAccumulate.glsl.js +13 -9
  54. package/chunks/ShadowCastVisualize.glsl.js +24 -9
  55. package/chunks/cameraUtilsSpherical.js +1 -1
  56. package/chunks/lyr3DMain.js +1 -1
  57. package/chunks/lyr3DWorker.js +1 -1
  58. package/chunks/sphere.js +1 -1
  59. package/core/Collection.js +1 -1
  60. package/core/JSONSupport.js +1 -1
  61. package/core/SetUtils.js +1 -1
  62. package/{views/webgl/GLObjectType.js → core/support/jsonUtils.js} +1 -1
  63. package/core/urlUtils.js +1 -1
  64. package/geometry/Mesh.js +1 -1
  65. package/geometry/support/normalizeUtilsSync.js +1 -1
  66. package/geometry/support/sphere.js +1 -1
  67. package/interfaces.d.ts +544 -116
  68. package/layers/DimensionLayer.js +1 -1
  69. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  70. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  71. package/layers/ParquetLayer.js +1 -1
  72. package/layers/RouteLayer.js +1 -1
  73. package/layers/SubtypeGroupLayer.js +1 -1
  74. package/layers/ViewshedLayer.js +1 -1
  75. package/layers/graphics/data/QueryEngine.js +1 -1
  76. package/layers/mixins/ImageryTileMixin.js +1 -1
  77. package/layers/orientedImagery/transformations/imageToWorld.js +1 -1
  78. package/layers/orientedImagery/transformations/utils.js +1 -1
  79. package/layers/support/FieldsIndex.js +1 -1
  80. package/layers/support/ParquetEncodingLocation.d.ts +4 -0
  81. package/layers/support/ParquetEncodingLocation.js +1 -1
  82. package/layers/support/ParquetEncodingWkb.d.ts +4 -0
  83. package/layers/support/ParquetEncodingWkb.js +1 -1
  84. package/layers/support/RasterStorageInfo.js +1 -1
  85. package/layers/support/VideoElement.js +1 -1
  86. package/layers/support/layerUtils.js +1 -1
  87. package/layers/support/parquetUtils.d.ts +3 -0
  88. package/layers/support/parquetUtils.js +1 -1
  89. package/layers/support/rasterDatasets/BaseRaster.js +1 -1
  90. package/layers/support/rasterDatasets/FunctionRaster.js +1 -1
  91. package/layers/support/rasterDatasets/ImageServerRaster.js +1 -1
  92. package/layers/support/rasterDatasets/RawBlockCache.js +1 -1
  93. package/layers/support/rasterDatasets/TIFFRaster.js +1 -1
  94. package/layers/support/rasterFormats/TiffDecoder.js +1 -1
  95. package/layers/support/rasterFormats/pixelRangeUtils.js +1 -1
  96. package/layers/support/rasterFormats/{TiffTags.js → tiffTag.js} +1 -1
  97. package/layers/support/rasterFunctions/BandArithmeticFunction.js +1 -1
  98. package/layers/support/rasterFunctions/BaseRasterFunction.js +1 -1
  99. package/layers/support/rasterFunctions/ExtractBandFunction.js +1 -1
  100. package/layers/support/rasterFunctions/NDVIFunction.js +1 -1
  101. package/layers/support/rasterFunctions/RemapFunction.js +1 -1
  102. package/layers/support/rasterFunctions/rasterFunctionHelper.js +1 -1
  103. package/layers/support/videoUtils.js +5 -0
  104. package/package.json +2 -2
  105. package/portal/schemas/definitions.js +1 -1
  106. package/portal/schemas/integratedMesh3DTilesLayerItem.js +1 -1
  107. package/renderers/UniqueValueRenderer.js +1 -1
  108. package/renderers/support/colorRampUtils.js +1 -1
  109. package/support/revision.js +1 -1
  110. package/symbols/IconSymbol3DLayer.js +1 -1
  111. package/symbols/cim/effects/EffectTaperedPolygon.js +1 -1
  112. package/views/2d/engine/webgl/meshing/Mesh.js +1 -1
  113. package/views/2d/engine/webgl/shaderGraph/typed/TypedShaderProgram.js +1 -1
  114. package/views/2d/engine/webgl/textureUtils.js +1 -1
  115. package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
  116. package/views/2d/layers/MediaLayerView2D.js +1 -1
  117. package/views/2d/layers/TileLayerView2D.js +1 -1
  118. package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
  119. package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
  120. package/views/2d/layers/support/DebugOverlay.js +1 -1
  121. package/views/2d/layers/support/MediaLayerInteraction.js +1 -1
  122. package/views/3d/analysis/DirectLineMeasurementAnalysisView3D.js +1 -1
  123. package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
  124. package/views/3d/analysis/LineOfSightAnalysisView3D.js +1 -1
  125. package/views/3d/analysis/Slice/SliceTool.js +1 -1
  126. package/views/3d/analysis/Slice/SliceVisualization.js +1 -1
  127. package/views/3d/analysis/SliceAnalysisView3D.js +1 -1
  128. package/views/3d/analysis/Viewshed/ViewshedAnalysisVisualization.js +1 -1
  129. package/views/3d/analysis/Viewshed/ViewshedVisualization.js +1 -1
  130. package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
  131. package/views/3d/camera/constraintUtils/distance.js +1 -1
  132. package/views/3d/camera/intersectionUtils.js +1 -1
  133. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  134. package/views/3d/environment/atmosphereUtils.js +1 -1
  135. package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
  136. package/views/3d/interactive/visualElements/DrapedVisualElementResources.js +1 -1
  137. package/views/3d/interactive/visualElements/EngineVisualElement.js +1 -1
  138. package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
  139. package/views/3d/interactive/visualElements/LabelVisualElement.js +1 -1
  140. package/views/3d/interactive/visualElements/LaserlineVisualElement.js +1 -1
  141. package/views/3d/interactive/visualElements/LineVisualElement.js +1 -1
  142. package/views/3d/interactive/visualElements/MarkerVisualElement.js +1 -1
  143. package/views/3d/interactive/visualElements/MeasurementAreaVisualElement.js +1 -1
  144. package/views/3d/interactive/visualElements/MeasurementArrowVisualElement.js +1 -1
  145. package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
  146. package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
  147. package/views/3d/interactive/visualElements/PointVisualElement.js +1 -1
  148. package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
  149. package/views/3d/interactive/visualElements/SlicePlaneVisualElement.js +1 -1
  150. package/views/3d/interactive/visualElements/VerticesVisualElement.js +1 -1
  151. package/views/3d/interactive/visualElements/ViewshedShapeVisualElement.js +1 -1
  152. package/views/3d/interactive/visualElements/VisualElement.js +1 -1
  153. package/views/3d/interactive/visualElements/VisualElementResources.js +1 -1
  154. package/views/3d/layers/I3SMeshView3D.js +1 -1
  155. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  156. package/views/3d/layers/Lyr3DWorker.js +1 -1
  157. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  158. package/views/3d/layers/graphics/pipeline/Feature3DPipeline.js +1 -1
  159. package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorker.js +1 -1
  160. package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorkerHandle.js +1 -1
  161. package/views/3d/layers/graphics/pipeline/PipelineCommand.js +1 -1
  162. package/views/3d/layers/graphics/pipeline/Tile3DManager.js +1 -1
  163. package/views/3d/layers/graphics/pipeline/rendering/FeaturePipelineRenderManager.js +1 -1
  164. package/views/3d/layers/graphics/pipeline/rendering/RenderCommandContext.js +1 -1
  165. package/views/3d/layers/graphics/pipeline/symbolization/Factory.js +5 -0
  166. package/views/3d/layers/graphics/pipeline/symbolization/SimpleFeatureRenderer.js +5 -0
  167. package/views/3d/layers/graphics/pipeline/symbolization/TestObjectSymbol.js +1 -1
  168. package/views/3d/layers/graphics/pipeline/symbolization/TestSymbol.js +1 -1
  169. package/views/3d/layers/graphics/pipeline/symbolization/UniqueValueFeatureRenderer.js +1 -1
  170. package/views/3d/layers/i3s/I3SMeshViewFilter.js +1 -1
  171. package/views/3d/layers/support/MediaLayerInteraction.js +1 -1
  172. package/views/3d/state/ConstraintsManager.js +1 -1
  173. package/views/3d/state/NearFarHeuristic.js +1 -1
  174. package/views/3d/state/ViewState.js +1 -1
  175. package/views/3d/state/ViewStateManager.js +1 -1
  176. package/views/3d/state/utils/navigationUtils.js +1 -1
  177. package/views/3d/support/cameraUtilsSpherical.js +1 -1
  178. package/views/3d/support/geometryUtils/sphere.js +1 -1
  179. package/views/3d/terrain/OverlayRenderTargets.js +1 -1
  180. package/views/3d/webgl/ManagedDepthTexture.js +1 -1
  181. package/views/3d/webgl/ManagedFBO.js +1 -1
  182. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  183. package/views/3d/webgl-engine/core/FBOCacheFormats.js +5 -0
  184. package/views/3d/webgl-engine/core/shaderLibrary/Laserline.glsl.js +12 -20
  185. package/views/3d/webgl-engine/core/shaderLibrary/output/Emissions.glsl.js +1 -1
  186. package/views/3d/webgl-engine/core/shaderLibrary/util/BlendColorsPremultiplied.glsl.js +5 -0
  187. package/views/3d/webgl-engine/effects/bloom/BloomRenderNode.js +1 -1
  188. package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
  189. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskNode.js +1 -1
  190. package/views/3d/webgl-engine/effects/geometry/RenderOccludedRenderNode.js +1 -1
  191. package/views/3d/webgl-engine/effects/haze/Haze.js +1 -1
  192. package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
  193. package/views/3d/webgl-engine/effects/laserlines/LaserLineRenderer.js +1 -1
  194. package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
  195. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  196. package/views/3d/webgl-engine/lib/DepthRange.js +1 -1
  197. package/views/3d/webgl-engine/lib/MainFramebuffer.js +1 -1
  198. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  199. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  200. package/views/3d/webgl-engine/lib/ShadowCastRenderer.js +1 -1
  201. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  202. package/views/3d/webgl-engine/lib/Texture.js +1 -1
  203. package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
  204. package/views/3d/webgl-engine/lib/ViewshedShadowMap.js +1 -1
  205. package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
  206. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  207. package/views/3d/webgl-engine/shaders/ShadowCastAccumulate.glsl.js +1 -1
  208. package/views/3d/webgl-engine/shaders/ShadowCastAccumulateTechnique.js +1 -1
  209. package/views/3d/webgl-engine/shaders/ShadowCastAccumulateTechniqueConfiguration.js +5 -0
  210. package/views/3d/webgl-engine/shaders/ShadowCastVisualize.glsl.js +1 -1
  211. package/views/3d/webgl-engine/shaders/ShadowCastVisualizeTechnique.js +1 -1
  212. package/views/3d/webgl-engine/shaders/ShadowCastVisualizeTechniqueConfiguration.js +1 -1
  213. package/views/PopupView.js +1 -1
  214. package/views/SceneView.js +1 -1
  215. package/views/SelectionManager.js +1 -1
  216. package/views/VideoView.js +1 -1
  217. package/views/analysis/analysisViewUtils.js +1 -1
  218. package/views/input/InputManager.js +1 -1
  219. package/views/input/ViewEvents.js +1 -1
  220. package/views/support/selectionUtils.js +1 -1
  221. package/views/webgl/FBOAttachmentType.js +5 -0
  222. package/views/webgl/FramebufferObject.js +1 -1
  223. package/views/webgl/Renderbuffer.js +1 -1
  224. package/views/webgl/RenderbufferDescriptor.js +1 -1
  225. package/views/webgl/Texture.js +1 -1
  226. package/views/webgl/TextureDescriptor.js +1 -1
  227. package/views/webgl/textureUtils.js +1 -1
  228. package/webscene/InitialViewProperties.js +1 -1
  229. package/webscene/Presentation.js +1 -1
  230. package/webscene/Slide.js +1 -1
  231. package/webscene/SlideLegendInfo.js +1 -1
  232. package/webscene/background/ColorBackground.js +1 -1
  233. package/webscene/spec-certification/api.js +1 -1
  234. package/webscene/spec-certification/compare.js +1 -1
  235. package/webscene/spec-certification/index.js +1 -1
  236. package/webscene/spec-certification/spec.js +1 -1
  237. package/webscene/spec-certification/utils.js +1 -1
  238. package/webscene/support/Description.js +1 -1
  239. package/webscene/support/SlideElements.js +1 -1
  240. package/webscene/support/SlideEnvironment.js +1 -1
  241. package/webscene/support/SlideGround.js +1 -1
  242. package/webscene/support/SlideVisibleLayer.js +1 -1
  243. package/webscene/support/Title.js +1 -1
  244. package/webscene/support/analysisUtils.js +5 -0
  245. package/widgets/BatchAttributeForm/expressions/ExpressionsManager.js +1 -1
  246. package/widgets/DirectLineMeasurement3D/DirectLineMeasurement3DViewModel.js +1 -1
  247. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  248. package/widgets/Editor/EditorViewModel.js +1 -1
  249. package/widgets/Editor/UpdateWorkflow.js +1 -1
  250. package/widgets/Editor/support/SketchController.js +5 -0
  251. package/widgets/Editor/workflowUtils.js +1 -1
  252. package/widgets/ElevationProfile/ElevationProfileInteraction.js +1 -1
  253. package/widgets/Feature/FeatureUtilityNetworkAssociationList.js +1 -1
  254. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js +1 -1
  255. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  256. package/widgets/FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js +1 -1
  257. package/widgets/FeatureTable/support/tableUtils.js +1 -1
  258. package/widgets/FeatureTable.js +1 -1
  259. package/widgets/LayerList/LayerListItem.js +1 -1
  260. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  261. package/widgets/OrientedImageryViewer/components/ImageViewerViewModel.js +1 -1
  262. package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
  263. package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
  264. package/widgets/ShadowCast/ThresholdOptions.js +1 -1
  265. package/widgets/Sketch/SketchViewModel.js +1 -1
  266. package/widgets/VideoPlayer.js +1 -1
  267. package/widgets/Widget.js +1 -1
  268. package/widgets/support/AnalysisViewModel.js +1 -1
  269. package/widgets/support/SelectionList.js +1 -1
  270. package/widgets/support/SnappingControls.js +1 -1
  271. package/assets/esri/core/workers/chunks/184d7c8ea818bec5c462.js +0 -1
  272. package/assets/esri/core/workers/chunks/22f604726529ee6f8c25.js +0 -1
  273. package/assets/esri/core/workers/chunks/244d2196bac5ef279436.js +0 -1
  274. package/assets/esri/core/workers/chunks/26fcbe053194bd78fcc3.js +0 -1
  275. package/assets/esri/core/workers/chunks/32f2e0c88046b39916cc.js +0 -1
  276. package/assets/esri/core/workers/chunks/388a763da712ca71ccf4.js +0 -1
  277. package/assets/esri/core/workers/chunks/4f8782b3b6ad414409e8.js +0 -1
  278. package/assets/esri/core/workers/chunks/5ffc3ca6c6a4d32e1282.js +0 -1
  279. package/assets/esri/core/workers/chunks/642a595353a86f3717e3.js +0 -1
  280. package/assets/esri/core/workers/chunks/8dd26b12c625d20196ed.js +0 -319
  281. package/assets/esri/core/workers/chunks/931275cfa2c55eb0f504.js +0 -1
  282. package/assets/esri/core/workers/chunks/93e9dfd1ba8f393c6c47.js +0 -1
  283. package/assets/esri/core/workers/chunks/95379fdd6917c8a84c71.js +0 -1
  284. package/assets/esri/core/workers/chunks/9b21dc4659922cc577cb.js +0 -1
  285. package/assets/esri/core/workers/chunks/a197c86d42cc9ce21924.js +0 -1
  286. package/assets/esri/core/workers/chunks/a276980c06d5d311a37e.js +0 -1
  287. package/assets/esri/core/workers/chunks/b42ecc7c3eb2fd8d1308.js +0 -1
  288. package/assets/esri/core/workers/chunks/ccc50f28f217e50cc2c3.js +0 -1
  289. package/assets/esri/core/workers/chunks/d04efa51da9b4eb3a8a7.js +0 -1
  290. package/assets/esri/core/workers/chunks/d81bebbb6fe000200d35.js +0 -1
  291. package/assets/esri/core/workers/chunks/dd8e72d6784a8ebc115d.js +0 -1
  292. package/assets/esri/core/workers/chunks/e9fba86036b8fe700a41.js +0 -1
  293. package/assets/esri/core/workers/chunks/ed3d1d0465f4a4d8df4a.js +0 -1
  294. package/views/webgl/formats.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../Color.js";import t from"../../Graphic.js";import{isSome as r,addMany as a,equals as o}from"../../core/arrayUtils.js";import{createTask as n}from"../../core/asyncUtils.js";import"../../core/has.js";import i from"../../core/Error.js";import{handlesGroup as s,makeHandle as l,abortHandle as c}from"../../core/handleUtils.js";import{clone as u}from"../../core/lang.js";import p from"../../core/Logger.js";import{getOrCreateMapValue as d}from"../../core/MapUtils.js";import{whenOrAbort as f,throwIfAborted as y,debounce as m,isPromiseLike as h}from"../../core/promiseUtils.js";import{watch as g,on as b,whenOnce as w}from"../../core/reactiveUtils.js";import{px2pt as v}from"../../core/screenUtils.js";import{diff as I}from"../../core/accessorSupport/diffUtils.js";import{isSharedTemplateOrMetadata as T,isSharedGroupTemplate as S,isSharedPresetTemplate as j,isStandardFeatureTemplate as F,isSharedFeatureTemplate as k,isSharedTemplate as A}from"../../editing/templateUtils.js";import{getSharedTemplateProvider as V}from"../../editing/sharedTemplates/SharedTemplateProvider.js";import U from"../../layers/GraphicsLayer.js";import{featureHasFields as L,fixFields as M,getDisplayFieldName as O}from"../../layers/support/fieldUtils.js";import{isSubtypeSublayer as x}from"../../layers/support/layerUtils.js";import{calculateTolerance as q}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as P}from"../../renderers/support/lengthUtils.js";import{getTransformationType as z,TransformationType as E}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import C from"../../symbols/SimpleFillSymbol.js";import R from"../../symbols/SimpleLineSymbol.js";import D from"../../symbols/SimpleMarkerSymbol.js";import{to3D as G}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as B}from"../../symbols/support/symbolUtils.js";import{getServices as N}from"../../undoredo/support/Services.js";import{GraphicState as Z}from"../../views/3d/layers/graphics/GraphicState.js";import{defaultDrawingMode as Q}from"../../views/draw/DrawingMode.js";import{createQueryGeometry as W}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as $,filterGraphicHits as J}from"../../views/support/hitTestSelectUtils.js";import{dependencySort as H}from"./support/dependencySort.js";import{isDrawGraphicTool as K}from"../Sketch/support/sketchUtils.js";const X=()=>p.getLogger("esri.widgets.Editor.workflowUtils");function Y(e){return"update"===e.type}function _(e){const t=e.sourceLayer;if(!t||"feature"!==t.type||!ne(t.renderer))return{rotation:null,size:null};let r=null,a=null;const o=t.renderer.getVisualVariablesForType("rotation").filter((e=>(!e.axis||"heading"===e.axis)&&e.field&&!e.valueExpression));1===o.length&&(r=ee(o[0],t));const n=t.renderer.getVisualVariablesForType("size").filter((e=>e.field&&!e.useSymbolValue&&!e.valueExpression&&z(e)===E.RealWorldSize));return 1===n.length&&(a=ae(n[0],t)),{rotation:r,size:a}}function ee(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,a=e.field,o=t.fields&&t.fields.filter((e=>e.name===a)),n=o&&1===o.length?o[0].type:"double",i={initial:0,current:0};return{field:a,fieldType:n,getDefaultValue:()=>Promise.resolve(0),getValue:e=>(i.current=i.initial-r*e,oe((i.current+360)%360,n)),setInitialValue:e=>{i.initial=e,i.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function te(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function re(e,t,r){if(null==t)return 0;const{symbol:a}=G(t);if(null==a||"web-style"===a.type||"cim"===a.type)return 0;const o=a.symbolLayers.at(0);if(!o)return 0;switch(o.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return Math.min(Qe.icon,(await e(o,Qe.icon))[0])||Qe.icon}case"text":return Qe.text;case"line":return Qe.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return te(await t(o,e.scale/Qe.viewScaleSizeFactor),r)}case"path":case"extrude":return e.scale/Qe.viewScaleSizeFactor;default:return 0}}function ae(e,t){const r=e.field,a=e.axis,o=t.fields&&t.fields.filter((e=>e.name===r)),n=o&&1===o.length?o[0].type:"double",i={initial:0,current:0},s=P[e.valueUnit]??1;let l;return l="area"===e.valueRepresentation?e=>(e*s/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*s/2:e=>e*s,{field:r,fieldType:n,getDefaultValue:async(e,t)=>oe(l(await re(t,e,a)),n),getValue:(e,t)=>(i.initial||(i.initial=t.pixelSizeAt(t.center)),i.current=i.initial*e,oe(i.current,n)),setInitialValue:e=>{i.initial=e,i.current=0},isUpdatingInteractively:!1,displayUnit:Je(e.valueUnit),axis:e.axis}}function oe(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function ne(e){switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function ie(e,t,r){const a=await B(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t,scale:r});null!=I(e.symbol,a)&&(e.symbol=a)}function se(e,t){if(!e||!t)throw new Error("no geometry type");if("multipatch"===e)return{tool:"mesh",createOptions:{mode:"hybrid"}};const r=new Map;r.set("circle",{mode:"freehand"}),r.set("rectangle",{mode:"freehand"});const a={mode:Q,optionsPerTool:r};if(T(t)){const o=t.defaultTool,n=S(t)?t.definition?.inputGeometryType??e:e;switch(o){case"freehand":case"stream-line":return{tool:"polyline"===n?"freehandPolyline":"freehandPolygon",createOptions:a};case"autocomplete-freehand-polygons":case"stream-polygon":return{tool:"freehandPolygon",createOptions:a};case"autocomplete-polygons":case"difference-polygon":case"create-structures":case"polygon":case"trace":return{tool:"polygon"===n?"polygon":"polyline",createOptions:a};case"circle":return r.get("circle").preserveAspectRatio=!0,{tool:"circle",createOptions:a};case"ellipse":return r.get("circle").preserveAspectRatio=!1,{tool:"circle",createOptions:a};case"create-points-along-line":case"multipoint":return{tool:"multipoint",createOptions:a};case"line":case"radial-line":case"right-angle-line":case"split":case"two-point-line":return{tool:"polyline",createOptions:a};case"rectangle":case"regular-polygon":case"right-angle-polygon":return{tool:"rectangle",createOptions:a};case"elevation-point-from-contour":case"elevation-point-from-dem":case"parcel-seed":case"point":case"point-and-rotation":case"point-at-end-of-line":return{tool:"point",createOptions:a}}}else{const o=t.drawingTool;if("circle"===o||"ellipse"===o)return r.get("circle").preserveAspectRatio="circle"===o,{tool:"circle",createOptions:a};if("rectangle"===o)return{tool:"rectangle",createOptions:a};if("freehand"===o)return{tool:"polygon"===e?"freehandPolygon":"freehandPolyline",createOptions:a}}return{tool:e,createOptions:a}}async function le(e,t,r){const{creationInfo:a,fullTemplate:o}=t;if(!a)throw new i("featureworkflow","No creation info provided.");const n=a.layer,s=ke(o,a.attributeOverrides),{view:l}=e,c="2d"===l?.type;S(o)||j(o)||await Ae(e,n,s,r,c?l.scale:null);const{capabilities:u}=n;e.layer.elevationInfo=n.elevationInfo;const p=se(n.geometryType,o);e.defaultCreateOptions={graphicProperties:{attributes:s,sourceLayer:n},mode:p.createOptions.mode,optionsPerTool:p.createOptions.optionsPerTool,preserveAspectRatio:p.createOptions.preserveAspectRatio,hasZ:u.data.supportsZ,defaultZ:(c?u.editing.zDefault:null)??e.defaultCreateOptions.defaultZ},null==a.geometryToPlace?await e.create(p.tool):await e.place(a.geometryToPlace,{graphicProperties:{attributes:s,sourceLayer:n}})}async function ce(e){return s([await ue(e),await pe(e)])}async function ue({creationAttributes:e,data:t,sketchViewModel:r,view:a,webStyleCache:o}){const{creationInfo:n}=t,{fullTemplate:i}=t;if(!n||"2d"!==a?.type||S(i)||j(i))return null;const s=m((t=>Ae(r,n.layer,e,o,t)));return g((()=>a.scale),(e=>s(e)))}async function pe({data:t,sketchViewModel:r,view:a}){const{templateExecutorInfo:o}=t;if(!o)return null;const n=r.activeComponent;if(!a||!K(n))return X().error(new i("featureworkflow","Failed to set up template feedback.")),null;const c=new U({effect:"saturate(0.6) opacity(0.8)",listMode:"hide",title:"Shared Template Feedback Graphics"});a.map?.add(c);const{executor:u,serviceLayersById:p}=o,d=a.theme?.accentColor??new e([255,165,0,1]);return s([b((()=>n),["cursor-update","vertex-add"],(()=>{c.removeAll();const e=n.graphic?.geometry;if(!e||!de(e))return;const t=u(e,"digitizing");if(!h(t))for(const r of t.edits){const e=p.get(r.id);if(e&&r.addFeatures&&0!==r.addFeatures.length)for(const t of e)if(!t.isTable)for(const e of r.addFeatures){const t=fe(e,d);t&&c.add(t)}}})),l((()=>{a.map.remove(c),c.destroy()}))])}function de(e){switch(e.type){case"point":case"multipoint":return!0;case"polyline":return e.paths[0].length>1;case"polygon":{const t=e.rings[0];return o(t.at(0),t.at(-1))?t.length>2:t.length>1}default:return!1}}function fe(e,r){let a=null;switch(e.geometry?.type){case"point":case"multipoint":a=new D({angle:0,color:r,outline:new R({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:1}),path:"undefined",size:8,style:"circle",xoffset:0,yoffset:0});break;case"polygon":a=new C({color:r,outline:new R({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:3}),style:"none"});break;case"polyline":a=new R({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:2});break;default:return null}return new t({geometry:e.geometry,symbol:a,attributes:{...e.attributes}})}async function ye(e,t){const r=await N(t).load(),a=x(e)?e.parent:e;return r.tablesAndLayersLookup.get(a)}async function me(e,t){const r=await ye(e,t);if(!r)return new Map;const a=new Map;for(const o of r.layersAndTables)d(a,o.layerId,(()=>[])).push(o);return a}function he(e){const t=e.objectIdField,r=e.globalIdField??"";return{id:e.layerId,identifierFields:{objectIdField:t,globalIdField:r},addFeatures:[],deleteAttachments:[],addAttachments:[],deleteFeatures:[],updateFeatures:[]}}function ge(e){const{edits:t,serviceInfo:a,view:o,findOriginalFeature:n}=e,i=be(a.layersAndTables),s=a.layersAndTables.toArray(),{allEditData:l,editDataByLayerIdMap:c,editDataByIdMap:u}=ve(t,i,n),p=Ie(l,we(s,c),c);if(je(l,p,o),0===p.length)return t;const d=H(p,{continueOnCircularDependency:!0}).map((e=>u.get(e))).filter(r),f=new Map;for(const r of d)f.set(r.uniqueId,r);const y=[];for(const r of l)f.has(r.uniqueId)||y.push(r);const m=[];let h=null;for(const r of d){const{layer:e}=r;switch(null==h?h=he(e):h.id!==e.layerId&&(m.push(h),h=he(e)),r.operationType){case"add":case"modify":h.addFeatures.push(r.after);break;case"delete":h.deleteFeatures.push(r.before)}}null!==h&&m.push(h);for(const r of y){const e=r.layer.layerId,t=m.find((t=>t.id===e))??he(r.layer);switch(m.includes(t)||m.push(t),r.operationType){case"add":t.addFeatures.push(r.after);break;case"modify":t.updateFeatures.push(r.after);break;case"delete":t.deleteFeatures.push(r.before);break;case"deleteAttachment":t.deleteAttachments.push(r.attachmentId);break;case"addAttachment":t.addAttachments.push(r.attachment)}}for(const r of m)void 0!==r.deleteAttachments&&0===r.deleteAttachments.length&&delete r.deleteAttachments,void 0!==r.addAttachments&&0===r.addAttachments.length&&delete r.addAttachments;return m}function be(e){const t=new Map;for(const r of e)t.set(r.layerId,r);return t}function we(e,t){const r=new Map;for(const a of e)for(const e of a.relationships??[])if(r.set(Te(a,e),""),t.has(e.relatedTableId)){const o=t.get(e.relatedTableId);if(o.length>0)for(const t of o[0].layer.relationships??[])if(t.id===e.id){r.set(Te(a,e),t.keyField);break}}return r}function ve(e,t,r){const a=new Map,o=[],n=new Map;let s=1;for(const l of e){const e=[],c=t.get(l.id);if(!c)throw new i("featureworkflow",`Failed to prepare applyEdits payload. Layer with id ${l.id} not found.`);for(const t of l.addFeatures??[])e.push({uniqueId:"T"+s++,operationType:"add",layer:c,after:t});for(const t of l.deleteFeatures??[])e.push({uniqueId:"T"+s++,operationType:"delete",before:t,layer:c});for(const t of l.deleteAttachments??[])e.push({uniqueId:"T"+s++,operationType:"deleteAttachment",attachmentId:t,layer:c});for(const t of l.addAttachments??[])e.push({uniqueId:"T"+s++,operationType:"addAttachment",attachment:t,layer:c});for(const t of l.updateFeatures??[])e.push({uniqueId:"T"+s++,operationType:"modify",before:r(t),after:t,layer:c});a.set(c.layerId,e);for(const t of e)o.push(t),n.set(t.uniqueId,t)}return{allEditData:o,editDataByIdMap:n,editDataByLayerIdMap:a}}function Ie(e,t,r){const a=[];for(const o of e){const e=o.layer.relationships??[],{uniqueId:n}=o;for(const i of e){const e=i.keyField;if("origin"===i.role){const s=r.get(i.relatedTableId);if(!s||0===s.length)continue;const l=Te(o.layer,i),c=t.get(l);if(void 0===c||""===c)continue;switch(o.operationType){case"add":for(const t of s)t!==o&&("add"!==t.operationType&&"modify"!==t.operationType||t.after.attributes[c]===o.after.attributes[e]&&a.push([n,t.uniqueId]));break;case"modify":if(o.before.attributes[e]!==o.after.attributes[e])for(const t of s){const r=t.uniqueId;t!==o&&("delete"===t.operationType?t.before.attributes[c]===o.before.attributes[e]?a.push([r,n]):t.before.attributes[c]===o.after.attributes[e]&&a.push([n,r]):"add"===t.operationType?t.after.attributes[c]===o.after.attributes[e]?a.push([n,r]):t.after.attributes[c]===o.before.attributes[e]&&a.push([r,n]):"modify"===t.operationType&&(t.before.attributes[c]!==t.after.attributes[c]?t.after.attributes[c]===o.after.attributes[e]?a.push([n,r]):a.push([r,n]):a.push([n,r])))}break;case"delete":for(const t of s)t!==o&&("delete"!==t.operationType&&"modify"!==t.operationType||t.before.attributes[c]===o.before.attributes[e]&&a.push([t.uniqueId,n]))}}}}return a}function Te(e,t){return`${e.layerId}:${t.id}`}function Se(e,t){return!!(t?.map&&"utilityNetworks"in t.map&&t.map.utilityNetworks?.length&&t.map.utilityNetworks.some((t=>!(!t.loaded||!e.url?.startsWith(t.featureServiceUrl)||e.layerId!==t.networkSystemLayers.associationsTableId))))}function je(e,t,r){const a=[];for(const n of e)Se(n.layer,r)&&a.push(n);if(0===a.length)return;let o=[];for(const n of a){const r=n.layer;switch(n.operationType){case"delete":o=[...Fe(n.before.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Fe(n.before.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of o)t.push([n.uniqueId,e.uniqueId]);break;case"add":o=[...Fe(n.after.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Fe(n.after.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of o)t.push([e.uniqueId,n.uniqueId])}}}function Fe(e,t){const r=[],a=t.filter((({layer:e})=>""!==e.globalIdField&&null!=e.globalIdField));for(const o of a){const t=o.layer.globalIdField;("before"in o&&o.before?.attributes[t]===e||"after"in o&&o.after?.attributes[t]===e)&&r.push(o)}return r}function ke(e,t={}){return S(e)||j(e)?{}:F(e)?{...e.prototype.attributes,...t}:k(e)?{...e.definition?.defaultValues,...t}:{...t}}async function Ae(e,r,a,o,n){const i=new t({sourceLayer:r,attributes:a}),{rotation:s,size:l}=_(i);let c=await B(i,{useSourceLayer:!0,webStyleCache:o,scale:n}),u=!1;for(const t of[l,s]){if(null==t)continue;null==a[t.field]&&(a[t.field]=await t.getDefaultValue(c,e.view),u=!0)}switch(u&&(c=await B(i,{useSourceLayer:!0,webStyleCache:o,scale:n})),c?.type){case"simple-fill":case"polygon-3d":e.polygonSymbol=c;break;case"simple-line":case"line-3d":e.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":e.pointSymbol=c;break;case"mesh-3d":e.meshSymbol=c}Ve(e.tooltipOptions,l,s)}function Ve(e,t,r){e.visualVariables=null!=t||null!=r?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=r?{valueType:r.fieldType,rotationType:r.rotationType??"geographic"}:null}:null}function Ue(e,t){return e?.find((e=>e.layer===t))}async function Le(e,t,r,a){switch(t.type){case"3d":return Me(e,t,r,a);case"2d":return Oe(e,t,r,a)}}async function Me(e,t,r,o){if(0===e.length)return[];const{updatable:n,graphicsByLayer:i}=await r.async((async()=>{const{results:a}=await f($(t,r),o),n=new Map,i=e=>{const t=e.layer,r=n.get(t);if(!r){const e=new Array;return n.set(t,e),e}return r};J(a).forEach((({graphic:e})=>i(e).push(e)));const s=e.filter((({capabilities:e,layer:t})=>e.update.enabled&&n.has(t)));return 0!==s.length&&r.stopPropagation(),{updatable:s,graphicsByLayer:n}}));return f(Promise.allSettled(n.map((async({layer:e})=>{const t=i.get(e),r=xe(e);if(t.every((e=>L(r,e))))return t;const n=[];for(const o of t){n.push(o.getObjectId());const e=Object.keys(o.attributes);a(r,e)}const s=e.createQuery();return s.returnGeometry=!1,s.objectIds=n,s.outFields=M(e.fieldsIndex,r),e.queryFeatures(s,{signal:o}).then((({features:e})=>e))}))),o)}async function Oe(e,t,r,a){if(0===e.length)return[];const{mapPoint:o}=r;if(null==o)return[];let n=null;const i=await r.async((async()=>{const{results:o}=await f(t.hitTest(r),a);if(0===o.length)return[];const i=new Set;n=J(o),n.forEach((({graphic:e})=>e&&i.add(e.layer)));const s=e.filter((e=>i.has(e.layer)&&e.supportsUpdateWorkflow));return s.length>0&&r.stopPropagation(),s}));return f(Promise.allSettled(i.map((async({layer:e})=>{const i=e.createQuery();i.returnGeometry=!0,i.outFields=xe(e);const s="renderer"in e?q({renderer:e.renderer,pointerType:r.pointerType}):0;i.geometry=W(o,s,t),i.outSpatialReference=t.spatialReference;const{features:l}=await e.queryFeatures(i,{signal:a});return n?.forEach((({graphic:t})=>{t.layer!==e||l.some((e=>e.getObjectId()===t.getObjectId()))||l.push(t)})),l}))),a)}function xe(e){return M(e.fieldsIndex,[e.objectIdField,O({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function qe(e,t,a,o){const n=t.createQuery();n.objectIds=e.map((e=>e.getObjectId())).filter(r),n.outFields=["*"],n.returnM=t.capabilities.data.supportsM,n.returnZ=t.capabilities.data.supportsZ,"scene"===t.type&&null!=t.infoFor3D||(n.outSpatialReference=a);const i=await t.queryFeatures(n,{signal:o});return y(o),i.features}function Pe(e){const t=new Map;for(const r of e){const e=r.sourceLayer,a=x(e)?e.parent:e;d(t,a,(()=>[])).push(r)}return t}async function ze(e){const{graphic:t,sketchViewModel:r,sourceLayer:a,visualVariables:o}=e;await Ee(e);const n={multipleSelectionEnabled:!1};return"point"===a.geometryType&&(n.enableRotation=null!=o.rotation,n.enableScaling=null!=o.size),r.update(t,n)}async function Ee(e){const{graphic:t,sketchViewModel:r,sourceLayer:a,visualVariables:o,webStyleCache:n}=e;let i=!1;const{rotation:s,size:l}=o;for(const c of[s,l]){if(null==c)continue;const e=t.getAttribute(c.field);if(null!=e)c.setInitialValue(e);else{const e=await c.getDefaultValue(t.symbol,r.view);c.setInitialValue(e),t.setAttribute(c.field,e),i=!0}}if(i){const e="2d"===r.view?.type?r.view.scale:null;await ie(t,n,e)}Ve(r.tooltipOptions,l,s),r.layer.elevationInfo=a.elevationInfo}function Ce(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function Re(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function De(e,t,r,a,o){if(null==t.geometry||"point"!==t.geometry?.type)return;const n=a.rotation,i=Ce(r.toolEventInfo);if(null!=n&&null!=i){const{field:r,getValue:a}=n;"rotate-stop"===i.type?(n.isUpdatingInteractively=!1,n.setInitialValue(t.getAttribute(r))):(n.isUpdatingInteractively=!0,t.setAttribute(r,a(i.angle,e)))}const s=a.size,l=Re(r.toolEventInfo);if(null!=s&&null!=l){const{field:r,getValue:a}=s;"scale-stop"===l.type?(s.isUpdatingInteractively=!1,s.setInitialValue(t.getAttribute(r))):(s.isUpdatingInteractively=!0,t.setAttribute(r,a(l.xScale,e)))}await ie(t,o,"2d"===e.type?e.scale:null)}async function Ge({feature:e,featureClone:t,visualVariableAttributes:r,sketchViewModel:a,view:o,onUpdate:n,webStyleCache:i,addUpdatingPromise:u,addHandle:p}){await ie(t,i,"2d"===o.type?o.scale:null);let d=null;if("2d"===a?.view?.type){const e=m((e=>ie(t,i,e)));d=g((()=>a?.view?.scale),(t=>e(t)))}const f=t.sourceLayer,y=Xe(o,f);await ze({graphic:t,sketchViewModel:a,sourceLayer:f,visualVariables:r,webStyleCache:i});let h=null;y.then((e=>h=e)).catch((()=>{}));const b=r.size,v=r.rotation,I=g((()=>e.attributes),(async e=>{let r=!1;for(const a in e){const o=e[a];o!==t.getAttribute(a)&&(t.setAttribute(a,o),null==b||b.isUpdatingInteractively||b.field!==a||b.setInitialValue(o),null==v||v.isUpdatingInteractively||v.field!==a||v.setInitialValue(o),(null==h||h.requiredFields.includes(a))&&(r=!0))}r&&await ie(t,i,"2d"===o.type?o.scale:null)})),T=a.on("update",(async e=>{const t=e.graphics[0],s={graphic:t,sketchViewModel:a,sourceLayer:f,visualVariables:r,webStyleCache:i};if("complete"===e.state){if(null===o.activeTool)return ze(s);const e=new AbortController,t=c(e);return p(t),u(w((()=>null===o.activeTool),e.signal).then((()=>(e.abort(),ze(s)))))}await De(o,t,e,r,i),n(_e(t),e)})),S=a.on(["undo","redo"],(async e=>{n(_e(e.graphics[0]),e)}));return s([S,T,l((()=>a.cancel())),I,d])}async function Be(e,t,r){const a=e.view;e.layer.add(r);const o=t.sourceLayer,i=t.layer,c=t.getAttribute(i.objectIdField);let u=null;function p(e){u?.abort(),u=n((async t=>{const r=await Xe(a,o);y(t),r.setVisibility?.(c,e)}))}return await Ze(a,r),p(!1),s([Ne(a,r,(e=>p(!e))),l((async()=>{p(!0);try{const e=await Xe(a,o);await w((()=>!e.updating))}finally{e.layer.remove(r)}}))])}function Ne(e,t,r){if("3d"===e.type){const a=new Z({graphic:t});return s([e.trackGraphicState(a),g((()=>a.displaying),r)])}return g((()=>t.visible),r)}async function Ze(e,t){if("3d"===e.type){const r=new Z({graphic:t}),a=e.trackGraphicState(r);await w((()=>r.displaying||r.error)),a.remove()}else await w((()=>t.visible))}const Qe={icon:v(24),text:v(12),line:v(1),viewScaleSizeFactor:100};function We(e,t,r){let a=!1;return e.filter((e=>!!a||(a=e===t,a))).map((e=>r[e]()))}function $e(e,t){e.viewModel.syncFeatureTemplates();const r=e.creationInfo;if("awaiting-feature-creation-info"===t[0].id&&r){const a=r.layer,o=e.viewModel.getTemplatesForLayer(a);1===o.length&&"scene"!==a.type&&(r.template=o[0],t.shift())}return t}function Je(e){return"unknown"===e?null:e}function He(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}const Ke=e=>/-stop/.test(e)||/vertex-/.test(e),Xe=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function Ye(e){return"createInteractiveEditSession"in e}function _e(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=u(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function et(e){const t=e.cursor;return e.cursor="progress",l((()=>e.cursor=t))}async function tt(e,t){const{template:r}=e;if(null==r)return null;if(A(r))return r.load();if(T(r)){const e=(await import("../../editing/sharedTemplates/SharedTemplate.js")).default,a=V(t,{makeSharedTemplateFromJSON:t=>e.fromJSON(t)}),o=await a.getTemplates({templateIds:[r.templateId],featureService:r.featureService});if(0===o.length)throw new i("editor:failed-to-load-template","Unable to load the provided template");return o[0].load()}return r}function rt(e){for(const t of e){const{destinationGraphic:e,destinationField:r,sourceGraphic:a,sourceField:o}=t;e.setAttribute(r,a.getAttribute(o))}}function at(e){const t=e.templateExecutorInfo?.completionResults;return t?.length?(t.forEach((e=>rt(e.relationships))),t.flatMap((e=>e.edits))):null}export{je as appendAllUtilityNetworkAssociationRelationships,$e as avoidFeatureTemplateSelectionWithOnlyOneItem,Ye as canCreateInteractiveEditSession,_e as cloneGraphicExceptMesh,be as createLayerIdMap,we as createRelationshipKeyMap,se as createToolFromGeometryType,We as createWorkflowSteps,Le as fetchCandidates,qe as fetchFullFeatures,Ie as findAllDependencies,Fe as findChangesByGlobalId,Ue as findLayerInfo,Te as generateHashForRelationship,ke as getCreationAttributes,tt as getFullTemplateForCreationInfo,at as getServiceEditsFromWorkflowData,ye as getServiceInfoForLayer,me as getServiceLayersById,_ as getVisualVariableAttributes,Pe as groupFeaturesByLayer,Ke as isTerminalUpdateEventType,Y as isUpdateWorkflow,Se as isUtilityNetworkAssociationsTable,ge as orderEditsByRelationshipDependencies,He as prepareAttachmentsForCreateFeaturesWorkflow,rt as setRelationshipFields,Ge as setUpGeometryUpdate,ce as setUpSketchCreateWatchers,Ee as setVisualVariablesAndElevationInfoForUpdate,et as showProgressCursor,Qe as sizeDefaults,Je as sizeVariableUnitToLengthUnit,le as startCreatingNewFeature,ze as startUpdatingFeatureGeometry,Be as swapForEditingSession,ie as updateGraphicSymbolWhenRequired,De as visualVariableInteractiveUpdate,Xe as whenEditorLayerView,Ze as whenGraphicDisplayed};
5
+ import e from"../../Color.js";import t from"../../Graphic.js";import{isSome as r,addMany as a,equals as n}from"../../core/arrayUtils.js";import{createTask as o}from"../../core/asyncUtils.js";import"../../core/has.js";import i from"../../core/Error.js";import{handlesGroup as s,makeHandle as l,abortHandle as c}from"../../core/handleUtils.js";import{clone as u}from"../../core/lang.js";import p from"../../core/Logger.js";import{getOrCreateMapValue as d}from"../../core/MapUtils.js";import{whenOrAbort as f,throwIfAborted as y,debounce as m,isPromiseLike as h}from"../../core/promiseUtils.js";import{watch as g,on as b,whenOnce as w}from"../../core/reactiveUtils.js";import{px2pt as v}from"../../core/screenUtils.js";import{diff as I}from"../../core/accessorSupport/diffUtils.js";import{isSharedTemplateOrMetadata as T,isSharedGroupTemplate as S,isSharedPresetTemplate as j,isStandardFeatureTemplate as F,isSharedFeatureTemplate as k,isSharedTemplate as A}from"../../editing/templateUtils.js";import{getSharedTemplateProvider as U}from"../../editing/sharedTemplates/SharedTemplateProvider.js";import V from"../../layers/GraphicsLayer.js";import{featureHasFields as L,fixFields as M,getDisplayFieldName as O}from"../../layers/support/fieldUtils.js";import{isSubtypeSublayer as x}from"../../layers/support/layerUtils.js";import{calculateTolerance as z}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as q}from"../../renderers/support/lengthUtils.js";import{isRenderer as P}from"../../renderers/support/typeUtils.js";import{getTransformationType as E,TransformationType as C}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import R from"../../symbols/SimpleFillSymbol.js";import D from"../../symbols/SimpleLineSymbol.js";import G from"../../symbols/SimpleMarkerSymbol.js";import{to3D as B}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as N}from"../../symbols/support/symbolUtils.js";import{getServices as Z}from"../../undoredo/support/Services.js";import{GraphicState as Q}from"../../views/3d/layers/graphics/GraphicState.js";import{defaultDrawingMode as W}from"../../views/draw/DrawingMode.js";import{createQueryGeometry as $}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as J,filterGraphicHits as H}from"../../views/support/hitTestSelectUtils.js";import{dependencySort as K}from"./support/dependencySort.js";import{isDrawGraphicTool as X}from"../Sketch/support/sketchUtils.js";const Y=()=>p.getLogger("esri.widgets.Editor.workflowUtils");function _(e){return"update"===e.type}function ee(e){if(!(e&&"renderer"in e&&se(e.renderer)))return{rotation:null,size:null};const t=e.renderer.getVisualVariablesForType("rotation").filter((e=>(!e.axis||"heading"===e.axis)&&e.field&&!e.valueExpression)),r=e.renderer.getVisualVariablesForType("size").filter((e=>e.field&&!e.useSymbolValue&&!e.valueExpression&&E(e)===C.RealWorldSize));return{rotation:1===t.length?t[0]:null,size:1===r.length?r[0]:null}}function te(e){const t=e.sourceLayer;if(!(t&&"renderer"in t&&se(t.renderer)))return{rotation:null,size:null};const{rotation:r,size:a}=ee(t);let n=null,o=null;if(r){const e=t.fields?.filter((e=>e.name===r.field)),a=1===e?.length?e[0]:null;n=re(r,a)}if(a){const e=t.fields?.filter((e=>e.name===a.field)),r=1===e?.length?e[0]:null;o=oe(a,r)}return{rotation:n,size:o}}function re(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,a=t?.type??"double",n={initial:0,current:0};return{field:e.field,fieldType:a,getDefaultValue:()=>Promise.resolve(0),getValue:e=>(n.current=n.initial-r*e,ie((n.current+360)%360,a)),setInitialValue:e=>{n.initial=e,n.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function ae(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function ne(e,t,r){if(null==t)return 0;const{symbol:a}=B(t);if(null==a||"web-style"===a.type||"cim"===a.type)return 0;const n=a.symbolLayers.at(0);if(!n)return 0;switch(n.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return Math.min($e.icon,(await e(n,$e.icon))[0])||$e.icon}case"text":return $e.text;case"line":return $e.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return ae(await t(n,e.scale/$e.viewScaleSizeFactor),r)}case"path":case"extrude":return e.scale/$e.viewScaleSizeFactor;default:return 0}}function oe(e,t){const r=e.axis,a=t?.type??"double",n={initial:0,current:0},o=q[e.valueUnit]??1;let i;return i="area"===e.valueRepresentation?e=>(e*o/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*o/2:e=>e*o,{field:e.field,fieldType:a,getDefaultValue:async(e,t)=>ie(i(await ne(t,e,r)),a),getValue:(e,t)=>(n.initial||(n.initial=t.pixelSizeAt(t.center)),n.current=n.initial*e,ie(n.current,a)),setInitialValue:e=>{n.initial=e,n.current=0},isUpdatingInteractively:!1,displayUnit:Ke(e.valueUnit),axis:e.axis}}function ie(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function se(e){if(!P(e))return!1;switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function le(e,t,r){const a=await N(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t,scale:r});null!=I(e.symbol,a)&&(e.symbol=a)}function ce(e,t){if(!e||!t)throw new Error("no geometry type");if("multipatch"===e)return{tool:"mesh",createOptions:{mode:"hybrid"}};const r=new Map;r.set("circle",{mode:"freehand"}),r.set("rectangle",{mode:"freehand"});const a={mode:W,optionsPerTool:r};if(T(t)){const n=t.defaultTool,o=S(t)?t.definition?.inputGeometryType??e:e;switch(n){case"freehand":case"stream-line":return{tool:"polyline"===o?"freehandPolyline":"freehandPolygon",createOptions:a};case"autocomplete-freehand-polygons":case"stream-polygon":return{tool:"freehandPolygon",createOptions:a};case"autocomplete-polygons":case"difference-polygon":case"create-structures":case"polygon":case"trace":return{tool:"polygon"===o?"polygon":"polyline",createOptions:a};case"circle":return r.get("circle").preserveAspectRatio=!0,{tool:"circle",createOptions:a};case"ellipse":return r.get("circle").preserveAspectRatio=!1,{tool:"circle",createOptions:a};case"create-points-along-line":case"multipoint":return{tool:"multipoint",createOptions:a};case"line":case"radial-line":case"right-angle-line":case"split":case"two-point-line":return{tool:"polyline",createOptions:a};case"rectangle":case"regular-polygon":case"right-angle-polygon":return{tool:"rectangle",createOptions:a};case"elevation-point-from-contour":case"elevation-point-from-dem":case"parcel-seed":case"point":case"point-and-rotation":case"point-at-end-of-line":return{tool:"point",createOptions:a}}}else{const n=t.drawingTool;if("circle"===n||"ellipse"===n)return r.get("circle").preserveAspectRatio="circle"===n,{tool:"circle",createOptions:a};if("rectangle"===n)return{tool:"rectangle",createOptions:a};if("freehand"===n)return{tool:"polygon"===e?"freehandPolygon":"freehandPolyline",createOptions:a}}return{tool:e,createOptions:a}}async function ue(e,t,r){const{creationInfo:a,fullTemplate:n}=t;if(!a)throw new i("featureworkflow","No creation info provided.");const o=a.layer,s=Ue(n,a.attributeOverrides),{view:l}=e,c="2d"===l?.type;S(n)||j(n)||await Ve(e,o,s,r,c?l.scale:null);const{capabilities:u}=o;e.layer.elevationInfo=o.elevationInfo;const p=ce(o.geometryType,n);e.defaultCreateOptions={graphicProperties:{attributes:s,sourceLayer:o},mode:p.createOptions.mode,optionsPerTool:p.createOptions.optionsPerTool,preserveAspectRatio:p.createOptions.preserveAspectRatio,hasZ:u.data.supportsZ,defaultZ:(c?u.editing.zDefault:null)??e.defaultCreateOptions.defaultZ},null==a.geometryToPlace?await e.create(p.tool):await e.place(a.geometryToPlace,{graphicProperties:{attributes:s,sourceLayer:o}})}async function pe(e){return s([await de(e),await fe(e)])}async function de({creationAttributes:e,data:t,sketchViewModel:r,view:a,webStyleCache:n}){const{creationInfo:o}=t,{fullTemplate:i}=t;if(!o||"2d"!==a?.type||S(i)||j(i))return null;const s=m((t=>Ve(r,o.layer,e,n,t)));return g((()=>a.scale),(e=>s(e)))}async function fe({data:t,sketchViewModel:r,view:a}){const{templateExecutorInfo:n}=t;if(!n)return null;const o=r.activeComponent;if(!a||!X(o))return Y().error(new i("featureworkflow","Failed to set up template feedback.")),null;const c=new V({effect:"saturate(0.6) opacity(0.8)",listMode:"hide",title:"Shared Template Feedback Graphics"});a.map?.add(c);const{executor:u,serviceLayersById:p}=n,d=a.theme?.accentColor??new e([255,165,0,1]);return s([b((()=>o),["cursor-update","vertex-add"],(()=>{c.removeAll();const e=o.graphic?.geometry;if(!e||!ye(e))return;const t=u(e,"digitizing");if(!h(t))for(const r of t.edits){const e=p.get(r.id);if(e&&r.addFeatures&&0!==r.addFeatures.length)for(const t of e)if(!t.isTable)for(const e of r.addFeatures){const t=me(e,d);t&&c.add(t)}}})),l((()=>{a.map.remove(c),c.destroy()}))])}function ye(e){switch(e.type){case"point":case"multipoint":return!0;case"polyline":return e.paths[0].length>1;case"polygon":{const t=e.rings[0];return n(t.at(0),t.at(-1))?t.length>2:t.length>1}default:return!1}}function me(e,r){let a=null;switch(e.geometry?.type){case"point":case"multipoint":a=new G({angle:0,color:r,outline:new D({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:1}),path:"undefined",size:8,style:"circle",xoffset:0,yoffset:0});break;case"polygon":a=new R({color:r,outline:new D({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:3}),style:"none"});break;case"polyline":a=new D({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:2});break;default:return null}return new t({geometry:e.geometry,symbol:a,attributes:{...e.attributes}})}async function he(e,t){const r=await Z(t).load(),a=x(e)?e.parent:e;return r.tablesAndLayersLookup.get(a)}async function ge(e,t){const r=await he(e,t);if(!r)return new Map;const a=new Map;for(const n of r.layersAndTables)d(a,n.layerId,(()=>[])).push(n);return a}function be(e){const t=e.objectIdField,r=e.globalIdField??"";return{id:e.layerId,identifierFields:{objectIdField:t,globalIdField:r},addFeatures:[],deleteAttachments:[],addAttachments:[],deleteFeatures:[],updateFeatures:[]}}function we(e){const{edits:t,serviceInfo:a,view:n,findOriginalFeature:o}=e,i=ve(a.layersAndTables),s=a.layersAndTables.toArray(),{allEditData:l,editDataByLayerIdMap:c,editDataByIdMap:u}=Te(t,i,o),p=Se(l,Ie(s,c),c);if(ke(l,p,n),0===p.length)return t;const d=K(p,{continueOnCircularDependency:!0}).map((e=>u.get(e))).filter(r),f=new Map;for(const r of d)f.set(r.uniqueId,r);const y=[];for(const r of l)f.has(r.uniqueId)||y.push(r);const m=[];let h=null;for(const r of d){const{layer:e}=r;switch(null==h?h=be(e):h.id!==e.layerId&&(m.push(h),h=be(e)),r.operationType){case"add":case"modify":h.addFeatures.push(r.after);break;case"delete":h.deleteFeatures.push(r.before)}}null!==h&&m.push(h);for(const r of y){const e=r.layer.layerId,t=m.find((t=>t.id===e))??be(r.layer);switch(m.includes(t)||m.push(t),r.operationType){case"add":t.addFeatures.push(r.after);break;case"modify":t.updateFeatures.push(r.after);break;case"delete":t.deleteFeatures.push(r.before);break;case"deleteAttachment":t.deleteAttachments.push(r.attachmentId);break;case"addAttachment":t.addAttachments.push(r.attachment)}}for(const r of m)void 0!==r.deleteAttachments&&0===r.deleteAttachments.length&&delete r.deleteAttachments,void 0!==r.addAttachments&&0===r.addAttachments.length&&delete r.addAttachments;return m}function ve(e){const t=new Map;for(const r of e)t.set(r.layerId,r);return t}function Ie(e,t){const r=new Map;for(const a of e)for(const e of a.relationships??[])if(r.set(je(a,e),""),t.has(e.relatedTableId)){const n=t.get(e.relatedTableId);if(n.length>0)for(const t of n[0].layer.relationships??[])if(t.id===e.id){r.set(je(a,e),t.keyField);break}}return r}function Te(e,t,r){const a=new Map,n=[],o=new Map;let s=1;for(const l of e){const e=[],c=t.get(l.id);if(!c)throw new i("featureworkflow",`Failed to prepare applyEdits payload. Layer with id ${l.id} not found.`);for(const t of l.addFeatures??[])e.push({uniqueId:"T"+s++,operationType:"add",layer:c,after:t});for(const t of l.deleteFeatures??[])e.push({uniqueId:"T"+s++,operationType:"delete",before:t,layer:c});for(const t of l.deleteAttachments??[])e.push({uniqueId:"T"+s++,operationType:"deleteAttachment",attachmentId:t,layer:c});for(const t of l.addAttachments??[])e.push({uniqueId:"T"+s++,operationType:"addAttachment",attachment:t,layer:c});for(const t of l.updateFeatures??[])e.push({uniqueId:"T"+s++,operationType:"modify",before:r(t),after:t,layer:c});a.set(c.layerId,e);for(const t of e)n.push(t),o.set(t.uniqueId,t)}return{allEditData:n,editDataByIdMap:o,editDataByLayerIdMap:a}}function Se(e,t,r){const a=[];for(const n of e){const e=n.layer.relationships??[],{uniqueId:o}=n;for(const i of e){const e=i.keyField;if("origin"===i.role){const s=r.get(i.relatedTableId);if(!s||0===s.length)continue;const l=je(n.layer,i),c=t.get(l);if(void 0===c||""===c)continue;switch(n.operationType){case"add":for(const t of s)t!==n&&("add"!==t.operationType&&"modify"!==t.operationType||t.after.attributes[c]===n.after.attributes[e]&&a.push([o,t.uniqueId]));break;case"modify":if(n.before.attributes[e]!==n.after.attributes[e])for(const t of s){const r=t.uniqueId;t!==n&&("delete"===t.operationType?t.before.attributes[c]===n.before.attributes[e]?a.push([r,o]):t.before.attributes[c]===n.after.attributes[e]&&a.push([o,r]):"add"===t.operationType?t.after.attributes[c]===n.after.attributes[e]?a.push([o,r]):t.after.attributes[c]===n.before.attributes[e]&&a.push([r,o]):"modify"===t.operationType&&(t.before.attributes[c]!==t.after.attributes[c]?t.after.attributes[c]===n.after.attributes[e]?a.push([o,r]):a.push([r,o]):a.push([o,r])))}break;case"delete":for(const t of s)t!==n&&("delete"!==t.operationType&&"modify"!==t.operationType||t.before.attributes[c]===n.before.attributes[e]&&a.push([t.uniqueId,o]))}}}}return a}function je(e,t){return`${e.layerId}:${t.id}`}function Fe(e,t){return!!(t?.map&&"utilityNetworks"in t.map&&t.map.utilityNetworks?.length&&t.map.utilityNetworks.some((t=>!(!t.loaded||!e.url?.startsWith(t.featureServiceUrl)||e.layerId!==t.networkSystemLayers.associationsTableId))))}function ke(e,t,r){const a=[];for(const o of e)Fe(o.layer,r)&&a.push(o);if(0===a.length)return;let n=[];for(const o of a){const r=o.layer;switch(o.operationType){case"delete":n=[...Ae(o.before.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Ae(o.before.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of n)t.push([o.uniqueId,e.uniqueId]);break;case"add":n=[...Ae(o.after.attributes[r.fieldsIndex.get("fromglobalid").name],e),...Ae(o.after.attributes[r.fieldsIndex.get("toglobalid").name],e)];for(const e of n)t.push([e.uniqueId,o.uniqueId])}}}function Ae(e,t){const r=[],a=t.filter((({layer:e})=>""!==e.globalIdField&&null!=e.globalIdField));for(const n of a){const t=n.layer.globalIdField;("before"in n&&n.before?.attributes[t]===e||"after"in n&&n.after?.attributes[t]===e)&&r.push(n)}return r}function Ue(e,t={}){return S(e)||j(e)?{}:F(e)?{...e.prototype.attributes,...t}:k(e)?{...e.definition?.defaultValues,...t}:{...t}}async function Ve(e,r,a,n,o){const i=new t({sourceLayer:r,attributes:a}),{rotation:s,size:l}=te(i);let c=await N(i,{useSourceLayer:!0,webStyleCache:n,scale:o}),u=!1;for(const t of[l,s]){if(null==t)continue;null==a[t.field]&&(a[t.field]=await t.getDefaultValue(c,e.view),u=!0)}switch(u&&(c=await N(i,{useSourceLayer:!0,webStyleCache:n,scale:o})),c?.type){case"simple-fill":case"polygon-3d":e.polygonSymbol=c;break;case"simple-line":case"line-3d":e.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":e.pointSymbol=c;break;case"mesh-3d":e.meshSymbol=c}Le(e.tooltipOptions,l,s)}function Le(e,t,r){e.visualVariables=null!=t||null!=r?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=r?{valueType:r.fieldType,rotationType:r.rotationType??"geographic"}:null}:null}function Me(e,t){return e?.find((e=>e.layer===t))}async function Oe(e,t,r,a){switch(t.type){case"3d":return xe(e,t,r,a);case"2d":return ze(e,t,r,a)}}async function xe(e,t,r,n){if(0===e.length)return[];const{updatable:o,graphicsByLayer:i}=await r.defer((async()=>{const{results:a}=await f(J(t,r),n),o=new Map,i=e=>{const t=e.layer,r=o.get(t);if(!r){const e=new Array;return o.set(t,e),e}return r};H(a).forEach((({graphic:e})=>i(e).push(e)));const s=e.filter((({capabilities:e,layer:t})=>e.update.enabled&&o.has(t)));return 0!==s.length&&r.stopPropagation(),{updatable:s,graphicsByLayer:o}}));return f(Promise.allSettled(o.map((async({layer:e})=>{const t=i.get(e),r=qe(e);if(t.every((e=>L(r,e))))return t;const o=[];for(const n of t){o.push(n.getObjectId());const e=Object.keys(n.attributes);a(r,e)}const s=e.createQuery();return s.returnGeometry=!1,s.objectIds=o,s.outFields=M(e.fieldsIndex,r),e.queryFeatures(s,{signal:n}).then((({features:e})=>e))}))),n)}async function ze(e,t,r,a){if(0===e.length)return[];const{mapPoint:n}=r;if(null==n)return[];let o=null;const i=await r.defer((async()=>{const{results:n}=await f(t.hitTest(r),a);if(0===n.length)return[];const i=new Set;o=H(n),o.forEach((({graphic:e})=>e&&i.add(e.layer)));const s=e.filter((e=>i.has(e.layer)&&e.supportsUpdateWorkflow));return s.length>0&&r.stopPropagation(),s}));return f(Promise.allSettled(i.map((async({layer:e})=>{const i=e.createQuery();i.returnGeometry=!0,i.outFields=qe(e);const s="renderer"in e?z({renderer:e.renderer,pointerType:r.pointerType}):0;i.geometry=$(n,s,t),i.outSpatialReference=t.spatialReference;const{features:l}=await e.queryFeatures(i,{signal:a});return o?.forEach((({graphic:t})=>{t.layer!==e||l.some((e=>e.getObjectId()===t.getObjectId()))||l.push(t)})),l}))),a)}function qe(e){return M(e.fieldsIndex,[e.objectIdField,O({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function Pe(e,t,a,n){const o=t.createQuery();o.objectIds=e.map((e=>e.getObjectId())).filter(r),o.outFields=["*"],o.returnM=t.capabilities.data.supportsM,o.returnZ=t.capabilities.data.supportsZ,"scene"===t.type&&null!=t.infoFor3D||(o.outSpatialReference=a);const i=await t.queryFeatures(o,{signal:n});return y(n),i.features}function Ee(e){const t=new Map;for(const r of e){const e=r.sourceLayer,a=x(e)?e.parent:e;d(t,a,(()=>[])).push(r)}return t}async function Ce(e){const{graphic:t,sketchViewModel:r,sourceLayer:a,visualVariables:n}=e;await Re(e);const o={multipleSelectionEnabled:!1};return"point"===a.geometryType&&(o.enableRotation=null!=n.rotation,o.enableScaling=null!=n.size),r.update(t,o)}async function Re(e){const{graphic:t,sketchViewModel:r,sourceLayer:a,visualVariables:n,webStyleCache:o}=e;let i=!1;const{rotation:s,size:l}=n;for(const c of[s,l]){if(null==c)continue;const e=t.getAttribute(c.field);if(null!=e)c.setInitialValue(e);else{const e=await c.getDefaultValue(t.symbol,r.view);c.setInitialValue(e),t.setAttribute(c.field,e),i=!0}}if(i){const e="2d"===r.view?.type?r.view.scale:null;await le(t,o,e)}Le(r.tooltipOptions,l,s),r.layer.elevationInfo=a.elevationInfo}function De(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function Ge(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}function Be(e,t,r,a){if(null==t.geometry||"point"!==t.geometry?.type)return!1;const n=t.attributes;let o=!1;const i=a.rotation,s=De(r.toolEventInfo);if(null!=i&&null!=s){const{field:r,getValue:a}=i;if("rotate-stop"===s.type)i.isUpdatingInteractively=!1,i.setInitialValue(t.getAttribute(r));else{i.isUpdatingInteractively=!0;const l=a(s.angle,e);l!==n[r]&&(t.setAttribute(r,l),o=!0)}}const l=a.size,c=Ge(r.toolEventInfo);if(null!=l&&null!=c){const{field:r,getValue:a}=l;if("scale-stop"===c.type)l.isUpdatingInteractively=!1,l.setInitialValue(t.getAttribute(r));else{l.isUpdatingInteractively=!0;const i=a(c.xScale,e);i!==n[r]&&(t.setAttribute(r,i),o=!0)}}return o}async function Ne({feature:e,featureClone:t,visualVariableAttributes:r,sketchViewModel:a,view:n,onUpdate:o,webStyleCache:i,addUpdatingPromise:u,addHandle:p}){await le(t,i,"2d"===n.type?n.scale:null);let d=null;if("2d"===a?.view?.type){const e=m((e=>le(t,i,e)));d=g((()=>a?.view?.scale),(t=>e(t)))}const f=t.sourceLayer,y=_e(n,f);await Ce({graphic:t,sketchViewModel:a,sourceLayer:f,visualVariables:r,webStyleCache:i});let h=null;y.then((e=>h=e)).catch((()=>{}));const b=r.size,v=r.rotation,I=g((()=>e.attributes),(async e=>{let r=!1;for(const a in e){const n=e[a];n!==t.getAttribute(a)&&(t.setAttribute(a,n),null==b||b.isUpdatingInteractively||b.field!==a||b.setInitialValue(n),null==v||v.isUpdatingInteractively||v.field!==a||v.setInitialValue(n),(null==h||h.requiredFields.includes(a))&&(r=!0))}r&&await le(t,i,"2d"===n.type?n.scale:null)})),T=a.on("update",(async e=>{const t=e.graphics[0],s={graphic:t,sketchViewModel:a,sourceLayer:f,visualVariables:r,webStyleCache:i};if("complete"===e.state){if(null===n.activeTool)return Ce(s);const e=new AbortController,t=c(e);return p(t),u(w((()=>null===n.activeTool),e.signal).then((async()=>{if(!e.signal.aborted)return e.abort(),Ce(s)})))}Be(n,t,e,r)&&await le(t,i,"2d"===n.type?n.scale:null),o(tt(t),e)})),S=a.on(["undo","redo"],(async e=>{o(tt(e.graphics[0]),e)}));return s([S,T,l((()=>a.cancel())),I,d])}async function Ze(e,t,r){const a=e.view;e.layer.add(r);const n=t.sourceLayer,i=t.layer,c=t.getAttribute(i.objectIdField);let u=null;function p(e){u?.abort(),u=o((async t=>{const r=await _e(a,n);y(t),r.setVisibility?.(c,e)}))}return await We(a,r),p(!1),s([Qe(a,r,(e=>p(!e))),l((async()=>{p(!0);try{const e=await _e(a,n);await w((()=>!e.updating))}finally{e.layer.remove(r)}}))])}function Qe(e,t,r){if("3d"===e.type){const a=new Q({graphic:t});return s([e.trackGraphicState(a),g((()=>a.displaying),r)])}return g((()=>t.visible),r)}async function We(e,t){if("3d"===e.type){const r=new Q({graphic:t}),a=e.trackGraphicState(r);await w((()=>r.displaying||r.error)),a.remove()}else await w((()=>t.visible))}const $e={icon:v(24),text:v(12),line:v(1),viewScaleSizeFactor:100};function Je(e,t,r){let a=!1;return e.filter((e=>!!a||(a=e===t,a))).map((e=>r[e]()))}function He(e,t){e.viewModel.syncFeatureTemplates();const r=e.creationInfo;if("awaiting-feature-creation-info"===t[0].id&&r){const a=r.layer,n=e.viewModel.getTemplatesForLayer(a);1===n.length&&"scene"!==a.type&&(r.template=n[0],t.shift())}return t}function Ke(e){return"unknown"===e?null:e}function Xe(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}const Ye=e=>/-stop/.test(e)||/vertex-/.test(e),_e=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function et(e){return"createInteractiveEditSession"in e}function tt(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=u(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function rt(e){const t=e.cursor;return e.cursor="progress",l((()=>e.cursor=t))}async function at(e,t){const{template:r}=e;if(null==r)return null;if(A(r))return r.load();if(T(r)){const e=(await import("../../editing/sharedTemplates/SharedTemplate.js")).default,a=U(t,{makeSharedTemplateFromJSON:t=>e.fromJSON(t)}),n=await a.getTemplates({templateIds:[r.templateId],featureService:r.featureService});if(0===n.length)throw new i("editor:failed-to-load-template","Unable to load the provided template");return n[0].load()}return r}function nt(e){for(const t of e){const{destinationGraphic:e,destinationField:r,sourceGraphic:a,sourceField:n}=t;e.setAttribute(r,a.getAttribute(n))}}function ot(e){const t=e.templateExecutorInfo?.completionResults;return t?.length?(t.forEach((e=>nt(e.relationships))),t.flatMap((e=>e.edits))):null}export{ke as appendAllUtilityNetworkAssociationRelationships,He as avoidFeatureTemplateSelectionWithOnlyOneItem,et as canCreateInteractiveEditSession,tt as cloneGraphicExceptMesh,ve as createLayerIdMap,Ie as createRelationshipKeyMap,ce as createToolFromGeometryType,Je as createWorkflowSteps,Oe as fetchCandidates,Pe as fetchFullFeatures,Se as findAllDependencies,Ae as findChangesByGlobalId,Me as findLayerInfo,je as generateHashForRelationship,Ue as getCreationAttributes,at as getFullTemplateForCreationInfo,re as getRotationVariableAttribute,ot as getServiceEditsFromWorkflowData,he as getServiceInfoForLayer,ge as getServiceLayersById,oe as getSizeVariableAttribute,te as getVisualVariableAttributes,ee as getVisualVariablesForLayer,Ee as groupFeaturesByLayer,Ye as isTerminalUpdateEventType,_ as isUpdateWorkflow,Fe as isUtilityNetworkAssociationsTable,we as orderEditsByRelationshipDependencies,Xe as prepareAttachmentsForCreateFeaturesWorkflow,nt as setRelationshipFields,Ne as setUpGeometryUpdate,pe as setUpSketchCreateWatchers,Re as setVisualVariablesAndElevationInfoForUpdate,rt as showProgressCursor,$e as sizeDefaults,Ke as sizeVariableUnitToLengthUnit,ue as startCreatingNewFeature,Ce as startUpdatingFeatureGeometry,Ze as swapForEditingSession,le as updateGraphicSymbolWhenRequired,Be as visualVariableInteractiveUpdate,_e as whenEditorLayerView,We as whenGraphicDisplayed};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../Graphic.js";import i from"../../core/Accessor.js";import{createTask as s}from"../../core/asyncUtils.js";import{makeHandle as o}from"../../core/handleUtils.js";import"../../core/has.js";import{destroyMaybe as n,abortMaybe as a}from"../../core/maybe.js";import{ignoreAbortErrors as r,throwIfAborted as l}from"../../core/promiseUtils.js";import{watch as h,syncAndInitial as c,when as p}from"../../core/reactiveUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";import _ from"../../layers/GraphicsLayer.js";import m from"../../symbols/CIMSymbol.js";import g from"../../symbols/SimpleLineSymbol.js";import{ViewEventPriorities as v}from"../../views/input/InputManager.js";import{isPolyline as y}from"./support/geometryUtils.js";import I from"../Sketch/SketchViewModel.js";var S,f;function b(t){return"2d"===t?new m({data:{type:"CIMSymbolReference",symbol:{type:"CIMLineSymbol",symbolLayers:[{type:"CIMSolidStroke",effects:[{type:"CIMGeometricEffectDashes",dashTemplate:[5,4],lineDashEnding:"FullGap",controlPointEnding:"NoConstraint"}],enable:!0,capStyle:"Butt",joinStyle:"Round",width:1.5,color:[0,0,0,255]},{type:"CIMSolidStroke",enable:!0,capStyle:"Butt",joinStyle:"Round",width:1.5,color:[255,255,255,255]}]}}}):new g({color:[0,0,0,0]})}!function(t){t.Ready="ready",t.Creating="creating",t.Reshaping="reshaping",t.ReshapingDisabled="reshaping-disabled",t.Selecting="selecting",t.Selected="selected"}(S||(S={})),function(t){t.View="view",t.Main="main",t.Interaction="interaction"}(f||(f={}));let k=class extends i{constructor(t){super(t),this.state=S.Ready,this._pendingStartOptions=null,this._previousInputInfo=null,this._shouldRemoveLastPoint=!1,this._sketchedGraphics=new WeakSet,this._creationToolPromise=null,this._updateToolPromise=null,this._updateDisabled=!1}initialize(){this.addHandles(h((()=>({view:this.tool.viewModel.view,visible:this.tool.visible})),(({view:t,visible:e})=>{null!=t&&e?this._attach(t):this._detach()}),c),f.View)}destroy(){this._detach()}get canStopCreating(){const t=this._geometry,e=this._shouldRemoveLastPoint?3:2;return y(t)&&t.paths.length>0&&t.paths[0].length>=e}get _input(){return this.tool.viewModel.input}set _input(t){this.tool.viewModel.input=t}get _geometry(){return this._input?.geometry}get _visibleAndEditable(){return this.tool.visible&&this.tool.editable}get _view(){return this.tool.viewModel.view}get test(){}start(t={mode:"sketch"}){if(!this.tool.editable)return;const e=this._view;if(null!=e&&e.ready)switch(this._pendingStartOptions=null,this._stopInteraction(),null==this._previousInputInfo&&this._storePreviousInput(this._input),this._setSketchedGraphic(null),t.mode){case"sketch":this._set("state",S.Creating),this._startCreationInteraction();break;case"select":this._set("state",S.Selecting),this._startSelectionInteraction()}else this._pendingStartOptions=t}stop(){this._pendingStartOptions=null,this._stopInteractionAndUpdate(),this._clearPreviousInput()}cancel(){this._pendingStartOptions=null,this._stopInteractionAndUpdate(),this._restorePreviousInput()}clear(){this._stopInteractionAndUpdate(),this._set("state",S.Ready),this._clearPreviousInput(),this._input=null,this._pendingStartOptions=null}isSketchedGraphic(t){return null!=t&&this._sketchedGraphics.has(t)}_attach(t){this._detach();const e={mode:"3d"===t.type?"relative-to-ground":"on-the-ground",offset:null};this._graphicsLayer=new _({listMode:"hide",internal:!0,elevationInfo:e});const i=b(t.type);this._sketchVM=new I({layer:this._graphicsLayer,view:t,defaultCreateOptions:{mode:"click",hasZ:!1},updateOnGraphicClick:!1,defaultUpdateOptions:{reshapeOptions:{shapeOperation:"none"},enableRotation:!1,enableScaling:!1,enableMoveAllGraphics:!1,enableZ:!1,multipleSelectionEnabled:!1,toggleToolOnClick:!1,tool:"reshape"},polylineSymbol:i,activeLineSymbol:i}),this.addHandles([p((()=>t.ready),(()=>{const t=this._pendingStartOptions;t&&this.start(t)}),c),h((()=>[this._input,this._visibleAndEditable]),(()=>this._update()),c),h((()=>({map:t.map,graphicsLayer:this._graphicsLayer})),(({map:t,graphicsLayer:e})=>{null!=t&&null!=e&&t.add(e),this._update()}),c)],f.Main)}_detach(){this.removeHandles(f.Main),this._sketchVM=n(this._sketchVM),this._creationToolPromise=null,this._updateToolPromise=null;const t=this._view?.map,e=this._graphicsLayer;null!=t&&null!=e&&t.remove(e),this._graphicsLayer=n(this._graphicsLayer),this._shouldRemoveLastPoint=!1,this._set("state",S.Ready)}_startCreationInteraction(){this._stopInteractionAndUpdate();const t=this._view,i=this._sketchVM;if(null==t||null==i)return;this._shouldRemoveLastPoint=!1;const s=i.on("create",(t=>{const e=t.graphic;switch(t.state){case"complete":this._shouldRemoveLastPoint=!1,this._setSketchedGraphic(e),this._stopInteractionAndUpdate(),this._clearPreviousInput();break;case"cancel":this.cancel();break;case"active":this._setSketchedGraphic(e),"cursor-update"===t.toolEventInfo?.type&&(this._shouldRemoveLastPoint=!0);break;case"start":this._setSketchedGraphic(e)}})),n=()=>{s.remove();const t=this.canStopCreating,o=this._geometry?.clone();i.cancel(),this._creationToolPromise=null,null!=o&&t?this._shouldRemoveLastPoint&&this._setSketchedGraphic(new e({geometry:w(o)})):this._input=null};this.removeHandles(f.Interaction),this.addHandles(o(n),f.Interaction),this._creationToolPromise=r(i.create("polyline"))}_startReshapeInteraction(){this._stopInteraction();const t=this._view,e=this._sketchVM;if(null==t||null==e)return;const i=e.on("update",(t=>{const e=t.graphics[0];switch(t.state){case"complete":this._setSketchedGraphic(e),this._stopInteractionAndUpdate(),this._clearPreviousInput();break;case"active":case"start":this._setSketchedGraphic(e)}})),s=()=>{i.remove(),e.cancel(),this._updateToolPromise=null};this.removeHandles(f.Interaction),this.addHandles(o(s),f.Interaction);const n=this._input;n&&(n.visible=!0,this._updateToolPromise=r(e.update(n,{tool:"reshape"})))}_startSelectionInteraction(){this._stopInteraction();const t=this._view;if(null==t)return;const e=t.cursor,i=o((()=>t.cursor=e));t.cursor="crosshair",t.closePopup();let n=null;const r=o((()=>a(n))),h=t.on("immediate-click",(e=>{e.async((async()=>{a(n),n=s((async i=>{const{results:s}=await t.hitTest(e);l(i);const o=s.filter((t=>"graphic"===t.type)).map((t=>t.graphic)).find((t=>null!=t.geometry&&"polyline"===t.geometry.type));o&&(e.preventDefault(),e.stopPropagation(),this._input=o,this._clearPreviousInput(),this._stopInteractionAndUpdate())})),await n.promise}))}),v.TOOL),c=t.on("key-down",(t=>{"Escape"===t.key&&this.cancel()}));this.removeHandles(f.Interaction),this.addHandles([h,c,r,i],f.Interaction),t.ready&&t.focus()}_stopInteraction(){this.removeHandles(f.Interaction)}_stopInteractionAndUpdate(){this.hasHandles(f.Interaction)&&(this._updateDisabled=!0,this._stopInteraction(),this._updateDisabled=!1,this._triggerUpdate())}_triggerUpdate(){this._set("state",S.Ready),this._update()}_update(){if(this._updateDisabled)return;const t=this.state;if(t!==S.Selecting){if(this._visibleAndEditable){if(t===S.Creating||t===S.Reshaping&&this.isSketchedGraphic(this._input))return}else this.cancel();this._set("state",this._getNextState()),this._updateVisuals()}else this.stop()}_getNextState(){return null==this._input?S.Ready:this.isSketchedGraphic(this._input)?this.state===S.Creating?S.Creating:this._visibleAndEditable?S.Reshaping:S.ReshapingDisabled:S.Selected}_updateVisuals(){switch(this.state){case S.Creating:break;case S.Reshaping:this._startReshapeInteraction();break;case S.ReshapingDisabled:{this._stopInteractionAndUpdate();const t=this._input;null!=t&&this.isSketchedGraphic(t)&&(t.visible=!1);break}case S.Ready:case S.Selected:this._stopInteractionAndUpdate();case S.Selecting:}this._updateSketchedGraphic()}_storePreviousInput(t){this._previousInputInfo={graphic:t}}_restorePreviousInput(){const t=this._previousInputInfo;null!=t&&(this._clearPreviousInput(),this._input=t.graphic,this._triggerUpdate())}_clearPreviousInput(){this._previousInputInfo=null}_updateSketchedGraphic(){const t=this._graphicsLayer;if(null==t)return;const e=t.graphics,i=this._input;if(null==i||!this.isSketchedGraphic(i))return void e.removeAll();if(-1===e.indexOf(i))e.removeAll(),e.add(i);else if(1!==e.length){const t=e.filter((t=>t!==i));e.removeMany(t)}}_setSketchedGraphic(t){null!=t&&this._sketchedGraphics.add(t),this._input=t,this._updateSketchedGraphic()}};function w(t){if(y(t)){const e=t.clone();return e.paths=[e.paths[0].slice(0,-1)],e}return t}t([d({nonNullable:!0})],k.prototype,"state",void 0),t([d({nonNullable:!0})],k.prototype,"tool",void 0),t([d()],k.prototype,"canStopCreating",null),t([d()],k.prototype,"_graphicsLayer",void 0),t([d()],k.prototype,"_sketchVM",void 0),t([d()],k.prototype,"_input",null),t([d()],k.prototype,"_geometry",null),t([d()],k.prototype,"_visibleAndEditable",null),t([d()],k.prototype,"_view",null),t([d()],k.prototype,"_shouldRemoveLastPoint",void 0),k=t([u("esri.widgets.ElevationProfile.ElevationProfileInteraction")],k);export{k as ElevationProfileInteraction,S as State};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../Graphic.js";import i from"../../core/Accessor.js";import{createTask as s}from"../../core/asyncUtils.js";import{makeHandle as o}from"../../core/handleUtils.js";import"../../core/has.js";import{destroyMaybe as n,abortMaybe as a}from"../../core/maybe.js";import{ignoreAbortErrors as r,throwIfAborted as l}from"../../core/promiseUtils.js";import{watch as h,syncAndInitial as c,when as p}from"../../core/reactiveUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as u}from"../../core/accessorSupport/decorators/subclass.js";import _ from"../../layers/GraphicsLayer.js";import m from"../../symbols/CIMSymbol.js";import g from"../../symbols/SimpleLineSymbol.js";import{ViewEventPriorities as v}from"../../views/input/InputManager.js";import{isPolyline as y}from"./support/geometryUtils.js";import I from"../Sketch/SketchViewModel.js";var f,S;function b(t){return"2d"===t?new m({data:{type:"CIMSymbolReference",symbol:{type:"CIMLineSymbol",symbolLayers:[{type:"CIMSolidStroke",effects:[{type:"CIMGeometricEffectDashes",dashTemplate:[5,4],lineDashEnding:"FullGap",controlPointEnding:"NoConstraint"}],enable:!0,capStyle:"Butt",joinStyle:"Round",width:1.5,color:[0,0,0,255]},{type:"CIMSolidStroke",enable:!0,capStyle:"Butt",joinStyle:"Round",width:1.5,color:[255,255,255,255]}]}}}):new g({color:[0,0,0,0]})}!function(t){t.Ready="ready",t.Creating="creating",t.Reshaping="reshaping",t.ReshapingDisabled="reshaping-disabled",t.Selecting="selecting",t.Selected="selected"}(f||(f={})),function(t){t.View="view",t.Main="main",t.Interaction="interaction"}(S||(S={}));let k=class extends i{constructor(t){super(t),this.state=f.Ready,this._pendingStartOptions=null,this._previousInputInfo=null,this._shouldRemoveLastPoint=!1,this._sketchedGraphics=new WeakSet,this._creationToolPromise=null,this._updateToolPromise=null,this._updateDisabled=!1}initialize(){this.addHandles(h((()=>({view:this.tool.viewModel.view,visible:this.tool.visible})),(({view:t,visible:e})=>{null!=t&&e?this._attach(t):this._detach()}),c),S.View)}destroy(){this._detach()}get canStopCreating(){const t=this._geometry,e=this._shouldRemoveLastPoint?3:2;return y(t)&&t.paths.length>0&&t.paths[0].length>=e}get _input(){return this.tool.viewModel.input}set _input(t){this.tool.viewModel.input=t}get _geometry(){return this._input?.geometry}get _visibleAndEditable(){return this.tool.visible&&this.tool.editable}get _view(){return this.tool.viewModel.view}get test(){}start(t={mode:"sketch"}){if(!this.tool.editable)return;const e=this._view;if(null!=e&&e.ready)switch(this._pendingStartOptions=null,this._stopInteraction(),null==this._previousInputInfo&&this._storePreviousInput(this._input),this._setSketchedGraphic(null),t.mode){case"sketch":this._set("state",f.Creating),this._startCreationInteraction();break;case"select":this._set("state",f.Selecting),this._startSelectionInteraction()}else this._pendingStartOptions=t}stop(){this._pendingStartOptions=null,this._stopInteractionAndUpdate(),this._clearPreviousInput()}cancel(){this._pendingStartOptions=null,this._stopInteractionAndUpdate(),this._restorePreviousInput()}clear(){this._stopInteractionAndUpdate(),this._set("state",f.Ready),this._clearPreviousInput(),this._input=null,this._pendingStartOptions=null}isSketchedGraphic(t){return null!=t&&this._sketchedGraphics.has(t)}_attach(t){this._detach();const e={mode:"3d"===t.type?"relative-to-ground":"on-the-ground",offset:null};this._graphicsLayer=new _({listMode:"hide",internal:!0,elevationInfo:e});const i=b(t.type);this._sketchVM=new I({layer:this._graphicsLayer,view:t,defaultCreateOptions:{mode:"click",hasZ:!1},updateOnGraphicClick:!1,defaultUpdateOptions:{reshapeOptions:{shapeOperation:"none"},enableRotation:!1,enableScaling:!1,enableMoveAllGraphics:!1,enableZ:!1,multipleSelectionEnabled:!1,toggleToolOnClick:!1,tool:"reshape"},polylineSymbol:i,activeLineSymbol:i}),this.addHandles([p((()=>t.ready),(()=>{const t=this._pendingStartOptions;t&&this.start(t)}),c),h((()=>[this._input,this._visibleAndEditable]),(()=>this._update()),c),h((()=>({map:t.map,graphicsLayer:this._graphicsLayer})),(({map:t,graphicsLayer:e})=>{null!=t&&null!=e&&t.add(e),this._update()}),c)],S.Main)}_detach(){this.removeHandles(S.Main),this._sketchVM=n(this._sketchVM),this._creationToolPromise=null,this._updateToolPromise=null;const t=this._view?.map,e=this._graphicsLayer;null!=t&&null!=e&&t.remove(e),this._graphicsLayer=n(this._graphicsLayer),this._shouldRemoveLastPoint=!1,this._set("state",f.Ready)}_startCreationInteraction(){this._stopInteractionAndUpdate();const t=this._view,i=this._sketchVM;if(null==t||null==i)return;this._shouldRemoveLastPoint=!1;const s=i.on("create",(t=>{const e=t.graphic;switch(t.state){case"complete":this._shouldRemoveLastPoint=!1,this._setSketchedGraphic(e),this._stopInteractionAndUpdate(),this._clearPreviousInput();break;case"cancel":this.cancel();break;case"active":this._setSketchedGraphic(e),"cursor-update"===t.toolEventInfo?.type&&(this._shouldRemoveLastPoint=!0);break;case"start":this._setSketchedGraphic(e)}})),n=()=>{s.remove();const t=this.canStopCreating,o=this._geometry?.clone();i.cancel(),this._creationToolPromise=null,null!=o&&t?this._shouldRemoveLastPoint&&this._setSketchedGraphic(new e({geometry:w(o)})):this._input=null};this.removeHandles(S.Interaction),this.addHandles(o(n),S.Interaction),this._creationToolPromise=r(i.create("polyline"))}_startReshapeInteraction(){this._stopInteraction();const t=this._view,e=this._sketchVM;if(null==t||null==e)return;const i=e.on("update",(t=>{const e=t.graphics[0];switch(t.state){case"complete":this._setSketchedGraphic(e),this._stopInteractionAndUpdate(),this._clearPreviousInput();break;case"active":case"start":this._setSketchedGraphic(e)}})),s=()=>{i.remove(),e.cancel(),this._updateToolPromise=null};this.removeHandles(S.Interaction),this.addHandles(o(s),S.Interaction);const n=this._input;n&&(n.visible=!0,this._updateToolPromise=r(e.update(n,{tool:"reshape"})))}_startSelectionInteraction(){this._stopInteraction();const t=this._view;if(null==t)return;const e=t.cursor,i=o((()=>t.cursor=e));t.cursor="crosshair",t.closePopup();let n=null;const r=o((()=>a(n))),h=t.on("immediate-click",(e=>{e.defer((async()=>{a(n),n=s((async i=>{const{results:s}=await t.hitTest(e);l(i);const o=s.filter((t=>"graphic"===t.type)).map((t=>t.graphic)).find((t=>null!=t.geometry&&"polyline"===t.geometry.type));o&&(e.preventDefault(),e.stopPropagation(),this._input=o,this._clearPreviousInput(),this._stopInteractionAndUpdate())})),await n.promise}))}),v.TOOL),c=t.on("key-down",(t=>{"Escape"===t.key&&this.cancel()}));this.removeHandles(S.Interaction),this.addHandles([h,c,r,i],S.Interaction),t.ready&&t.focus()}_stopInteraction(){this.removeHandles(S.Interaction)}_stopInteractionAndUpdate(){this.hasHandles(S.Interaction)&&(this._updateDisabled=!0,this._stopInteraction(),this._updateDisabled=!1,this._triggerUpdate())}_triggerUpdate(){this._set("state",f.Ready),this._update()}_update(){if(this._updateDisabled)return;const t=this.state;if(t!==f.Selecting){if(this._visibleAndEditable){if(t===f.Creating||t===f.Reshaping&&this.isSketchedGraphic(this._input))return}else this.cancel();this._set("state",this._getNextState()),this._updateVisuals()}else this.stop()}_getNextState(){return null==this._input?f.Ready:this.isSketchedGraphic(this._input)?this.state===f.Creating?f.Creating:this._visibleAndEditable?f.Reshaping:f.ReshapingDisabled:f.Selected}_updateVisuals(){switch(this.state){case f.Creating:break;case f.Reshaping:this._startReshapeInteraction();break;case f.ReshapingDisabled:{this._stopInteractionAndUpdate();const t=this._input;null!=t&&this.isSketchedGraphic(t)&&(t.visible=!1);break}case f.Ready:case f.Selected:this._stopInteractionAndUpdate();case f.Selecting:}this._updateSketchedGraphic()}_storePreviousInput(t){this._previousInputInfo={graphic:t}}_restorePreviousInput(){const t=this._previousInputInfo;null!=t&&(this._clearPreviousInput(),this._input=t.graphic,this._triggerUpdate())}_clearPreviousInput(){this._previousInputInfo=null}_updateSketchedGraphic(){const t=this._graphicsLayer;if(null==t)return;const e=t.graphics,i=this._input;if(null==i||!this.isSketchedGraphic(i))return void e.removeAll();if(-1===e.indexOf(i))e.removeAll(),e.add(i);else if(1!==e.length){const t=e.filter((t=>t!==i));e.removeMany(t)}}_setSketchedGraphic(t){null!=t&&this._sketchedGraphics.add(t),this._input=t,this._updateSketchedGraphic()}};function w(t){if(y(t)){const e=t.clone();return e.paths=[e.paths[0].slice(0,-1)],e}return t}t([d({nonNullable:!0})],k.prototype,"state",void 0),t([d({nonNullable:!0})],k.prototype,"tool",void 0),t([d()],k.prototype,"canStopCreating",null),t([d()],k.prototype,"_graphicsLayer",void 0),t([d()],k.prototype,"_sketchVM",void 0),t([d()],k.prototype,"_input",null),t([d()],k.prototype,"_geometry",null),t([d()],k.prototype,"_visibleAndEditable",null),t([d()],k.prototype,"_view",null),t([d()],k.prototype,"_shouldRemoveLastPoint",void 0),k=t([u("esri.widgets.ElevationProfile.ElevationProfileInteraction")],k);export{k as ElevationProfileInteraction,f as State};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import{stripHTML as t}from"../../core/string.js";import{property as i}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{getFeaturePopupTitle as o}from"../../support/popupUtils.js";import l from"./FeatureUtilityNetworkAssociations/VisibleElements.js";import{loadCalciteComponents as r}from"../support/componentsUtils.js";import{globalCss as n}from"../support/globalCss.js";import"../support/widgetUtils.js";import{tsx as a,tsxFragment as c}from"../support/jsxFactory.js";import d from"../support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js";import p from"../support/UtilityNetworkAssociations/UtilityNetworkAssociationList.js";import{formatPercentAlong as u}from"../support/UtilityNetworkAssociations/utils/formatPercentAlong.js";import{isConnectivity as m}from"../support/UtilityNetworkAssociations/utils/isConnectivity.js";import{isConnectivityMidspan as h}from"../support/UtilityNetworkAssociations/utils/isConnectivityMidspan.js";import{substitute as w}from"../../intl/substitute.js";var f;const y="esri-feature-utility-network-associations",b={base:y,listItemHidden:`${y}__list-item--hidden`},v="nested";let g=f=class extends p{constructor(e,t){super(e,t),this.description=null,this.flowItems=null,this.flowType="feature-utility-network-association-type",this.listType=null,this.parentFeatureViewModel=null,this.title=null,this.viewModel=new d,this.visibleElements=new l}initialize(){this.setUpObserver()}loadDependencies(){return r({chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")})}destroy(){this.tooltipReferenceMap.clear()}render(){const e=this.viewModel.associationViewModels,{state:t,showAllEnabled:i}=this.viewModel,{state:s}=this.parentFeatureViewModel??{};return a("div",{class:this.classes(b.base,n.widget)},"loading"===t||"querying"===t||"loading"===s?this.renderLoading():a("calcite-list",{displayMode:v,label:this.selectedLayer?.title??this.messagesCommon.untitled},i&&this.selectedLayer?a(c,null,this.renderFilter(),this.renderFeatureCountWarning(),this._renderAssociatedFeatureListPage(),this.renderFeatureObserver()):Array.from(e.keys(),(t=>this._renderTypeList(t,e.get(t))))))}_showAllAssociations(e){const{flowItems:t,viewModel:i,description:s}=this;if(!t||!e)return;i.showAllEnabled=!0;const o=new f({selectedLayer:e,title:e?.title,flowItems:t,parentFeatureViewModel:this.parentFeatureViewModel,featureVisibleElements:this.featureVisibleElements,description:s,visibleElements:new l({title:!1,description:!1}),viewModel:i});t.push(o)}_renderAssociatedFeatureListPage(){const e=this.viewModel.associationViewModels.get(this.selectedLayer).filter((e=>o(e.featureViewModel).toLowerCase().includes(this.filterText))).slice(0,this.endIndex);return[...this._renderTooltips(e),...this._renderAssociatedFeatureList(e)]}_renderItemTooltip(e){const{tooltipReferenceMap:t}=this;return m(e.association)?a("calcite-tooltip",{key:`tooltip-${e.featureViewModel.uid}`,overlayPositioning:"fixed",referenceElement:t.get(e.featureViewModel.uid)},this.getConnectivityTooltip(e.association.associationType)):null}_renderAssociatedFeature(e){const{featureViewModel:i}=e,s=o(i),l="loading"===i.state,r=this._findFlowItem(i),n=r<0&&this._isParentFeature(i),c=n||r>=0;return a("calcite-list-item",{class:l?b.listItemHidden:void 0,description:t(e.terminalName??""),key:`associated-feature-type-${i.uid}`,label:t(s),onCalciteListItemSelect:()=>this._handleFeatureClick(n,r,i)},m(e.association)?this.renderConnectivityIcon(e.association.associationType,e.featureViewModel.uid):null,h(e.association)?a("calcite-chip",{label:u(e.association),scale:"s",slot:"content-end"},u(e.association)):null,this._renderChevronIconNode(c))}async _selectAssociation(e){const{flowItems:t,featureVisibleElements:i}=this;if(!t)return;e.abilities={utilityNetworkAssociationsContent:!0};const{default:s}=await import("../Feature.js");t.push(new s({flowItems:t,flowType:"feature-association",viewModel:e,visibleElements:i}))}_handleFeatureClick(e,t,i){if(e)this.flowItems.drain((e=>{"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy()}));else if(t<0||!this.flowItems)this._selectAssociation(i);else for(;this.flowItems.length>t+1;){const e=this.flowItems.pop();e&&("showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy())}}_featureViewModelMatch(e,t){const i=e.graphic,s=i?.layer;let o=null;"subtype-sublayer"===s?.type&&s.parent?o=s.parent.globalIdField??null:s&&"globalIdField"in s&&(o=s.globalIdField);const l=o?i?.attributes[o]:null,r=t.graphic,n=r?.layer;let a=null;"subtype-sublayer"===n?.type&&n.parent?a=n.parent.globalIdField??null:n&&"globalIdField"in n&&(a=n.globalIdField);const c=a?r?.attributes[a]:null;return l&&c&&l===c}_isParentFeature(e){const t=this.flowItems?.getItemAt(0);if(!t)return!1;const i=t.parentFeatureViewModel;return this._featureViewModelMatch(i,e)}_findFlowItem(e){return this.flowItems?.findIndex((t=>{if("feature-association"!==t.flowType)return!1;const i=t.viewModel;return this._featureViewModelMatch(i,e)}))??-1}_renderTooltips(e){return e.toArray().map((e=>this._renderItemTooltip(e)))}_renderAssociatedFeatureList(e){return e.toArray().map((e=>this._renderAssociatedFeature(e)))}_renderChevronIconNode(e){return a("calcite-icon",{flipRtl:!0,icon:e?"move-up":"chevron-right",scale:"s",slot:"content-end"})}_renderTypeList(e,t){const{messagesFeature:i}=this,{displayCount:s}=this.viewModel,o=t.slice(0,s),l=o.length<t.length;return a("calcite-list-item",{key:"show-all",label:e.title,open:!0,value:e.id},a("calcite-chip",{label:String(t.length),scale:"s",slot:"content-end"},t.length),a("calcite-list",{group:e.id,label:e.title??""},[this._renderTooltips(o),this._renderAssociatedFeatureList(o)],l?a("calcite-list-item",{description:w(i?.numberRecords,{number:t.length.toString()}),key:"show-all-item",label:i.showAll,onCalciteListItemSelect:()=>this._showAllAssociations(e)},a("calcite-icon",{icon:"list",scale:"s",slot:"content-end"})):null))}};e([i()],g.prototype,"description",void 0),e([i()],g.prototype,"featureVisibleElements",void 0),e([i()],g.prototype,"flowItems",void 0),e([i()],g.prototype,"flowType",void 0),e([i()],g.prototype,"listType",void 0),e([i()],g.prototype,"parentFeatureViewModel",void 0),e([i()],g.prototype,"title",void 0),e([i({type:d})],g.prototype,"viewModel",void 0),e([i({type:l,nonNullable:!0})],g.prototype,"visibleElements",void 0),g=f=e([s("esri.widgets.Feature.FeatureUtilityNetworkAssociationList")],g);const M=g;export{M as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../intl.js";import{stripHTML as t}from"../../core/string.js";import{property as i}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{getFeaturePopupTitle as o}from"../../support/popupUtils.js";import l from"./FeatureUtilityNetworkAssociations/VisibleElements.js";import{loadCalciteComponents as r}from"../support/componentsUtils.js";import{globalCss as n}from"../support/globalCss.js";import"../support/widgetUtils.js";import{tsx as a,tsxFragment as c}from"../support/jsxFactory.js";import d from"../support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js";import p from"../support/UtilityNetworkAssociations/UtilityNetworkAssociationList.js";import{formatPercentAlong as u}from"../support/UtilityNetworkAssociations/utils/formatPercentAlong.js";import{isConnectivity as m}from"../support/UtilityNetworkAssociations/utils/isConnectivity.js";import{isConnectivityMidspan as h}from"../support/UtilityNetworkAssociations/utils/isConnectivityMidspan.js";import{substitute as w}from"../../intl/substitute.js";var f;const y="esri-feature-utility-network-associations",b={base:y,listItemHidden:`${y}__list-item--hidden`},v="nested";let g=f=class extends p{constructor(e,t){super(e,t),this.description=null,this.flowItems=null,this.flowType="feature-utility-network-association-type",this.listType=null,this.parentFeatureViewModel=null,this.title=null,this.viewModel=new d,this.visibleElements=new l}initialize(){this.setUpObserver()}loadDependencies(){return r({chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")})}destroy(){this.tooltipReferenceMap.clear()}render(){const e=this.viewModel.associationViewModels,{state:t,showAllEnabled:i}=this.viewModel,{state:s}=this.parentFeatureViewModel??{};return a("div",{class:this.classes(b.base,n.widget)},"loading"===t||"querying"===t||"loading"===s?this.renderLoading():a("calcite-list",{displayMode:v,label:this.selectedLayer?.title??this.messagesCommon.untitled},i&&this.selectedLayer?a(c,null,this.renderFilter(),this.renderFeatureCountWarning(),this._renderAssociatedFeatureListPage(),this.renderFeatureObserver()):Array.from(e.keys(),(t=>this._renderTypeList(t,e.get(t))))))}_showAllAssociations(e){const{flowItems:t,viewModel:i,description:s}=this;if(!t||!e)return;i.showAllEnabled=!0;const o=new f({selectedLayer:e,title:e?.title,flowItems:t,parentFeatureViewModel:this.parentFeatureViewModel,featureVisibleElements:this.featureVisibleElements,description:s,visibleElements:new l({title:!1,description:!1}),viewModel:i});t.push(o)}_renderAssociatedFeatureListPage(){const e=this.viewModel.associationViewModels.get(this.selectedLayer).filter((e=>o(e.featureViewModel).toLowerCase().includes(this.filterText))).slice(0,this.endIndex);return[...this._renderTooltips(e),...this._renderAssociatedFeatureList(e)]}_renderItemTooltip(e){const{tooltipReferenceMap:t}=this;return m(e.association)?a("calcite-tooltip",{key:`tooltip-${e.featureViewModel.uid}`,overlayPositioning:"fixed",referenceElement:t.get(e.featureViewModel.uid)},this.getConnectivityTooltip(e.association.associationType)):null}_renderAssociatedFeature(e){const{featureViewModel:i}=e,s=o(i),l="loading"===i.state,r=this._findFlowItem(i),n=r<0&&this._isParentFeature(i),c=n||r>=0;return a("calcite-list-item",{class:l?b.listItemHidden:void 0,description:t(e.terminalName??""),key:`associated-feature-type-${i.uid}`,label:t(s),onCalciteListItemSelect:()=>this._handleFeatureClick(n,r,i)},m(e.association)?this.renderConnectivityIcon(e.association.associationType,e.featureViewModel.uid):null,h(e.association)?a("calcite-chip",{label:u(e.association),scale:"s",slot:"content-end"},u(e.association)):null,this._renderChevronIconNode(c))}async _selectAssociation(e){const{flowItems:t,featureVisibleElements:i}=this;if(!t)return;e.abilities={utilityNetworkAssociationsContent:!0};const{default:s}=await import("../Feature.js");t.push(new s({flowItems:t,flowType:"feature-association",viewModel:e,visibleElements:i}))}_handleFeatureClick(e,t,i){if(e)this.flowItems.drain((e=>{"showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy()}));else if(t<0||!this.flowItems)this._selectAssociation(i);else for(;this.flowItems.length>t+1;){const e=this.flowItems.pop();e&&("showAllEnabled"in e.viewModel&&(e.viewModel.showAllEnabled=!1),e.viewModel=null,e.destroy())}}_featureViewModelMatch(e,t){const i=e.graphic,s=i?.layer;let o=null;"subtype-sublayer"===s?.type&&s.parent?o=s.parent.globalIdField??null:s&&"globalIdField"in s&&(o=s.globalIdField);const l=o?i?.attributes[o]:null,r=t.graphic,n=r?.layer;let a=null;"subtype-sublayer"===n?.type&&n.parent?a=n.parent.globalIdField??null:n&&"globalIdField"in n&&(a=n.globalIdField);const c=a?r?.attributes[a]:null;return l&&c&&l===c}_isParentFeature(e){const t=this.flowItems?.getItemAt(0);if(!t)return!1;const i=t.parentFeatureViewModel;return this._featureViewModelMatch(i,e)}_findFlowItem(e){return this.flowItems?.findIndex((t=>{if("feature-association"!==t.flowType)return!1;const i=t.viewModel;return this._featureViewModelMatch(i,e)}))??-1}_renderTooltips(e){return e.toArray().map((e=>this._renderItemTooltip(e)))}_renderAssociatedFeatureList(e){return e.toArray().map((e=>this._renderAssociatedFeature(e)))}_renderChevronIconNode(e){return a("calcite-icon",{flipRtl:!0,icon:e?"move-up":"chevron-right",scale:"s",slot:"content-end"})}_renderTypeList(e,t){const{messagesFeature:i}=this,{displayCount:s}=this.viewModel,o=t.slice(0,s),l=o.length<t.length;return a("calcite-list-item",{expanded:!0,key:"show-all",label:e.title,value:e.id},a("calcite-chip",{label:String(t.length),scale:"s",slot:"content-end"},t.length),a("calcite-list",{group:e.id,label:e.title??""},[this._renderTooltips(o),this._renderAssociatedFeatureList(o)],l?a("calcite-list-item",{description:w(i?.numberRecords,{number:t.length.toString()}),key:"show-all-item",label:i.showAll,onCalciteListItemSelect:()=>this._showAllAssociations(e)},a("calcite-icon",{icon:"list",scale:"s",slot:"content-end"})):null))}};e([i()],g.prototype,"description",void 0),e([i()],g.prototype,"featureVisibleElements",void 0),e([i()],g.prototype,"flowItems",void 0),e([i()],g.prototype,"flowType",void 0),e([i()],g.prototype,"listType",void 0),e([i()],g.prototype,"parentFeatureViewModel",void 0),e([i()],g.prototype,"title",void 0),e([i({type:d})],g.prototype,"viewModel",void 0),e([i({type:l,nonNullable:!0})],g.prototype,"visibleElements",void 0),g=f=e([s("esri.widgets.Feature.FeatureUtilityNetworkAssociationList")],g);const M=g;export{M 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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../chunks/tslib.es6.js";import"../../../intl.js";import{stripHTML as e}from"../../../core/string.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 i}from"../../../core/accessorSupport/decorators/subclass.js";import{getFeatureFormTitle as o}from"../featureFormUtils.js";import r from"../UtilityNetworkAssociationInput.js";import{AssociationDetails as a}from"./AssociationDetails.js";import n from"./VisibleElements.js";import{loadCalciteComponents as c}from"../../support/componentsUtils.js";import{globalCss as l}from"../../support/globalCss.js";import{Heading as d}from"../../support/Heading.js";import"../../support/widgetUtils.js";import{messageBundle as p}from"../../support/decorators/messageBundle.js";import{tsx as u,tsxFragment as m}from"../../support/jsxFactory.js";import h from"../../support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js";import y from"../../support/UtilityNetworkAssociations/UtilityNetworkAssociationList.js";import{formatPercentAlong as g}from"../../support/UtilityNetworkAssociations/utils/formatPercentAlong.js";import{isConnectivity as f}from"../../support/UtilityNetworkAssociations/utils/isConnectivity.js";import{isConnectivityMidspan as F}from"../../support/UtilityNetworkAssociations/utils/isConnectivityMidspan.js";import{substitute as v}from"../../../intl/substitute.js";const _="esri-feature-form-utility-network-association-list",L={base:_,header:`${_}__header`,headingContent:`${_}__heading-content`,listContainer:`${_}__list-container`};let A=class extends y{constructor(t,e){super(t,e),this._isLoadingSelectFeature=!1,this.associationInput=null,this.headingLevel=5,this.messagesFeatureForm=null,this.onSelectLayer=()=>{},this.onSelectFeature=async()=>{},this.onAddAssociation=()=>{},this.viewModel=new h,this.visibleElements=new n}initialize(){this.setUpObserver()}loadDependencies(){return c({chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),fab:()=>import("@esri/calcite-components/dist/components/calcite-fab"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")})}get associatedFeatureCount(){const{associationInput:t}=this;if(!t)return 0;const{associatedFeatureInfos:e,associatedLayer:s}=t,i=s?e.get(s):null;return i?i.length:0}render(){const{associationInput:t}=this;if(!t)return u("div",{class:this.classes(L.base,l.widget)});const{associatedLayer:e}=t,{state:s}=this.viewModel;return u("div",{class:this.classes(L.base,l.widget)},"loading"===s||"querying"===s?this.renderLoading():e?this._renderFeatureList(t,e):this._renderLayerList(t))}_renderLayerList(t){const{associatedFeatureInfos:e,editable:s}=t;return u("div",{class:L.listContainer},u("calcite-list",{label:this.messagesFeatureForm?.associations.associatedLayers},Array.from(e.keys(),(e=>this._renderLayerItem(t,e)))),s?u("calcite-fab",{appearance:"outline-fill",icon:"plus",key:`${t.uid}-add-button`,kind:"neutral",onclick:()=>this.onAddAssociation({feature:t.feature,associationType:t.activeAssociationType,utilityNetwork:t.utilityNetwork}),text:this.messagesCommon.add,textEnabled:!0}):null)}_renderFeatureList(t,e){return u(m,null,this._renderHeader(t,e),u("div",{class:L.listContainer},this.renderFeatureCountWarning(),u("calcite-list",{label:this.messagesFeatureForm?.associations.associatedFeatures},this._renderAssociatedFeatureListPage(t,e),this.renderFeatureObserver())))}_renderLayerTitle(t){return t.title?u(d,{key:"title",level:this.headingLevel},u("div",{class:L.headingContent},u("calcite-icon",{icon:"layer"}),t.title)):null}_renderTotal(t,e){const{messagesFeature:s}=this,{associatedFeatureInfos:i}=t,o=i.get(e),r=v(s?.numberRecords,{number:o?.length??"0"});return u("div",{key:e.id},r)}_renderHeader(t,e){const{messagesFeatureForm:s}=this,{activeAssociationType:i,featureItem:o,feature:r}=t;return u("div",{class:L.header,key:"filter"},this.visibleElements.associationDetails?u(a,{associationType:i?.type,feature:r,heading:o?.label,messages:s.associations}):void 0,this._renderLayerTitle(e),this.renderFilter(),this._renderTotal(t,e))}_renderAssociatedFeatureListPage(t,e){const{filterText:s,endIndex:i}=this,r=this.messagesCommon.untitled,a=t.associatedFeatureInfos.get(e)?.filter((t=>o(t,r).toLowerCase().includes(s)??!1)).slice(0,i).toArray()??[];return[...this._renderTooltips(a),...this._renderAssociatedFeatureList(a)]}_renderItemTooltip(t){const{tooltipReferenceMap:e}=this,s=t.feature.uid.toString();return f(t.association)?u("calcite-tooltip",{key:`tooltip-${s}`,overlayPositioning:"fixed",referenceElement:e.get(s)},this.getConnectivityTooltip(t.association.associationType)):null}_renderAssociatedFeature(t){const s=this.messagesCommon.untitled,i=o(t,s),r=t.feature.uid.toString();return u("calcite-list-item",{description:e(t.terminalName??""),key:`associated-feature-type-${r}`,label:e(i),onCalciteListItemSelect:()=>this._selectAssociation(t)},f(t.association)?this.renderConnectivityIcon(t.association.associationType,r):null,F(t.association)?u("calcite-chip",{label:g(t.association),scale:"s",slot:"content-end"},g(t.association)):null,u("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderTooltips(t){return t.map((t=>this._renderItemTooltip(t)))}_renderAssociatedFeatureList(t){return t.map((t=>this._renderAssociatedFeature(t)))}_renderLayerItem(t,e){const{associatedFeatureInfos:s}=t,i=s.get(e)?.length??0;return u("calcite-list-item",{key:`${e.id}-show-all`,label:e.title??this.messagesCommon.untitled,open:!0,value:e.id,onCalciteListItemSelect:()=>this._showAllAssociations(e)},u("calcite-chip",{label:i.toString(),scale:"s",slot:"content-end"},i),u("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}))}async _selectAssociation(t){this._isLoadingSelectFeature||(this._isLoadingSelectFeature=!0,await this.onSelectFeature({feature:t.feature,association:t.association}),this._isLoadingSelectFeature=!1)}_showAllAssociations(t){this.onSelectLayer({layer:t,associationInput:this.associationInput})}};t([s()],A.prototype,"associatedFeatureCount",null),t([s({type:r})],A.prototype,"associationInput",void 0),t([s()],A.prototype,"headingLevel",void 0),t([s(),p("esri/widgets/FeatureForm/t9n/FeatureForm")],A.prototype,"messagesFeatureForm",void 0),t([s({constructOnly:!0})],A.prototype,"onSelectLayer",void 0),t([s({constructOnly:!0})],A.prototype,"onSelectFeature",void 0),t([s({constructOnly:!0})],A.prototype,"onAddAssociation",void 0),t([s({type:h})],A.prototype,"viewModel",void 0),t([s({type:n,nonNullable:!0})],A.prototype,"visibleElements",void 0),A=t([i("esri.widgets.FeatureForm.FeatureFormUtilityNetworkAssociations.FeatureFormUtilityNetworkAssociationList")],A);const b=A;export{b as default};
5
+ import{_ as t}from"../../../chunks/tslib.es6.js";import"../../../intl.js";import{stripHTML as e}from"../../../core/string.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 i}from"../../../core/accessorSupport/decorators/subclass.js";import{getFeatureFormTitle as o}from"../featureFormUtils.js";import r from"../UtilityNetworkAssociationInput.js";import{AssociationDetails as a}from"./AssociationDetails.js";import n from"./VisibleElements.js";import{loadCalciteComponents as c}from"../../support/componentsUtils.js";import{globalCss as l}from"../../support/globalCss.js";import{Heading as d}from"../../support/Heading.js";import"../../support/widgetUtils.js";import{messageBundle as p}from"../../support/decorators/messageBundle.js";import{tsx as u,tsxFragment as m}from"../../support/jsxFactory.js";import h from"../../support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js";import y from"../../support/UtilityNetworkAssociations/UtilityNetworkAssociationList.js";import{formatPercentAlong as g}from"../../support/UtilityNetworkAssociations/utils/formatPercentAlong.js";import{isConnectivity as f}from"../../support/UtilityNetworkAssociations/utils/isConnectivity.js";import{isConnectivityMidspan as F}from"../../support/UtilityNetworkAssociations/utils/isConnectivityMidspan.js";import{substitute as v}from"../../../intl/substitute.js";const _="esri-feature-form-utility-network-association-list",L={base:_,header:`${_}__header`,headingContent:`${_}__heading-content`,listContainer:`${_}__list-container`};let A=class extends y{constructor(t,e){super(t,e),this._isLoadingSelectFeature=!1,this.associationInput=null,this.headingLevel=5,this.messagesFeatureForm=null,this.onSelectLayer=()=>{},this.onSelectFeature=async()=>{},this.onAddAssociation=()=>{},this.viewModel=new h,this.visibleElements=new n}initialize(){this.setUpObserver()}loadDependencies(){return c({chip:()=>import("@esri/calcite-components/dist/components/calcite-chip"),fab:()=>import("@esri/calcite-components/dist/components/calcite-fab"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")})}get associatedFeatureCount(){const{associationInput:t}=this;if(!t)return 0;const{associatedFeatureInfos:e,associatedLayer:s}=t,i=s?e.get(s):null;return i?i.length:0}render(){const{associationInput:t}=this;if(!t)return u("div",{class:this.classes(L.base,l.widget)});const{associatedLayer:e}=t,{state:s}=this.viewModel;return u("div",{class:this.classes(L.base,l.widget)},"loading"===s||"querying"===s?this.renderLoading():e?this._renderFeatureList(t,e):this._renderLayerList(t))}_renderLayerList(t){const{associatedFeatureInfos:e,editable:s}=t;return u("div",{class:L.listContainer},u("calcite-list",{label:this.messagesFeatureForm?.associations.associatedLayers},Array.from(e.keys(),(e=>this._renderLayerItem(t,e)))),s?u("calcite-fab",{appearance:"outline-fill",icon:"plus",key:`${t.uid}-add-button`,kind:"neutral",onclick:()=>this.onAddAssociation({feature:t.feature,associationType:t.activeAssociationType,utilityNetwork:t.utilityNetwork}),text:this.messagesCommon.add,textEnabled:!0}):null)}_renderFeatureList(t,e){return u(m,null,this._renderHeader(t,e),u("div",{class:L.listContainer},this.renderFeatureCountWarning(),u("calcite-list",{label:this.messagesFeatureForm?.associations.associatedFeatures},this._renderAssociatedFeatureListPage(t,e),this.renderFeatureObserver())))}_renderLayerTitle(t){return t.title?u(d,{key:"title",level:this.headingLevel},u("div",{class:L.headingContent},u("calcite-icon",{icon:"layer"}),t.title)):null}_renderTotal(t,e){const{messagesFeature:s}=this,{associatedFeatureInfos:i}=t,o=i.get(e),r=v(s?.numberRecords,{number:o?.length??"0"});return u("div",{key:e.id},r)}_renderHeader(t,e){const{messagesFeatureForm:s}=this,{activeAssociationType:i,featureItem:o,feature:r}=t;return u("div",{class:L.header,key:"filter"},this.visibleElements.associationDetails?u(a,{associationType:i?.type,feature:r,heading:o?.label,messages:s.associations}):void 0,this._renderLayerTitle(e),this.renderFilter(),this._renderTotal(t,e))}_renderAssociatedFeatureListPage(t,e){const{filterText:s,endIndex:i}=this,r=this.messagesCommon.untitled,a=t.associatedFeatureInfos.get(e)?.filter((t=>o(t,r).toLowerCase().includes(s)??!1)).slice(0,i).toArray()??[];return[...this._renderTooltips(a),...this._renderAssociatedFeatureList(a)]}_renderItemTooltip(t){const{tooltipReferenceMap:e}=this,s=t.feature.uid.toString();return f(t.association)?u("calcite-tooltip",{key:`tooltip-${s}`,overlayPositioning:"fixed",referenceElement:e.get(s)},this.getConnectivityTooltip(t.association.associationType)):null}_renderAssociatedFeature(t){const s=this.messagesCommon.untitled,i=o(t,s),r=t.feature.uid.toString();return u("calcite-list-item",{description:e(t.terminalName??""),key:`associated-feature-type-${r}`,label:e(i),onCalciteListItemSelect:()=>this._selectAssociation(t)},f(t.association)?this.renderConnectivityIcon(t.association.associationType,r):null,F(t.association)?u("calcite-chip",{label:g(t.association),scale:"s",slot:"content-end"},g(t.association)):null,u("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderTooltips(t){return t.map((t=>this._renderItemTooltip(t)))}_renderAssociatedFeatureList(t){return t.map((t=>this._renderAssociatedFeature(t)))}_renderLayerItem(t,e){const{associatedFeatureInfos:s}=t,i=s.get(e)?.length??0;return u("calcite-list-item",{expanded:!0,key:`${e.id}-show-all`,label:e.title??this.messagesCommon.untitled,value:e.id,onCalciteListItemSelect:()=>this._showAllAssociations(e)},u("calcite-chip",{label:i.toString(),scale:"s",slot:"content-end"},i),u("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}))}async _selectAssociation(t){this._isLoadingSelectFeature||(this._isLoadingSelectFeature=!0,await this.onSelectFeature({feature:t.feature,association:t.association}),this._isLoadingSelectFeature=!1)}_showAllAssociations(t){this.onSelectLayer({layer:t,associationInput:this.associationInput})}};t([s()],A.prototype,"associatedFeatureCount",null),t([s({type:r})],A.prototype,"associationInput",void 0),t([s()],A.prototype,"headingLevel",void 0),t([s(),p("esri/widgets/FeatureForm/t9n/FeatureForm")],A.prototype,"messagesFeatureForm",void 0),t([s({constructOnly:!0})],A.prototype,"onSelectLayer",void 0),t([s({constructOnly:!0})],A.prototype,"onSelectFeature",void 0),t([s({constructOnly:!0})],A.prototype,"onAddAssociation",void 0),t([s({type:h})],A.prototype,"viewModel",void 0),t([s({type:n,nonNullable:!0})],A.prototype,"visibleElements",void 0),A=t([i("esri.widgets.FeatureForm.FeatureFormUtilityNetworkAssociations.FeatureFormUtilityNetworkAssociationList")],A);const b=A;export{b 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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{neverReached as n}from"../../core/compilerUtils.js";import s from"../../core/Evented.js";import i from"../../core/Logger.js";import{destroyMaybe as o}from"../../core/maybe.js";import r from"../../core/Promise.js";import{debounce as a}from"../../core/promiseUtils.js";import{watch as l,whenOnce as u,on as p,syncAndInitial as c}from"../../core/reactiveUtils.js";import{templateHasKey as h}from"../../core/string.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as m}from"../../core/support/UpdatingHandles.js";import y from"../../form/FormTemplate.js";import{isUtilityNetworkAssociationsElement as g,isGroupElement as _,isFieldElement as v,isRelationshipElement as I,isTextElement as x}from"../../form/support/formUtils.js";import E from"../../layers/support/ContingentValue.js";import{isEditableLayer as C}from"../../layers/support/editableLayers.js";import F from"../../layers/support/LayerContingentValuesCache.js";import{utc as b,unknown as V,system as w}from"../../time/constants.js";import{flattenAssociationInputs as A,flattenFieldInputs as j,isGroupInput as T,flattenRelationshipInputs as M,parseFormTemplateString as k,isRelationshipInput as N,isFieldInput as L,isTextElementInput as R,getNormalizedFeatureTypeInfo as S,valueIsValidContingentValue as U}from"./featureFormUtils.js";import Z from"./FieldInput.js";import{FormExpressionsManager as H}from"./FormExpressionsManager.js";import P from"./GroupInput.js";import O from"./RelationshipInput.js";import W from"./TextElementInput.js";import{createFormExpressionArcadeExecutor as G}from"../support/forms/expressions/FormExpressionArcadeExecutor.js";const $=new t({attributes:{}}),D={field:["editableExpression","requiredExpression","valueExpression","visibilityExpression"],group:["visibilityExpression"],relationship:["editableExpression","visibilityExpression"],text:["visibilityExpression"],utilityNetworkAssociations:["editableExpression","visibilityExpression"]},z="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",J="#JSAPI_CONTINGENT_VALUE_ANY_HASH",B="#JSAPI_CONTINGENT_VALUE_NULL_HASH",K="esri.widgets.FeatureForm.FeatureFormViewModel",Y=()=>i.getLogger(K);let q=class extends(r.EsriPromiseMixin(s.EventedAccessor)){constructor(e){super(e),this._expressionExecutorsInUse=new Set,this._expressionExecutorLookup=new Map,this._expressionsManager=null,this._contingentValuesCache=null,this._featureClone=$.clone(),this._initialFeature=$.clone(),this._timeZone=null,this._updatingHandles=new m,this.activeAssociation=null,this.arcadeEditType="NA",this.contingencyConstraintViolations=new Map,this.disabled=!1,this.highlightHelper=null,this.inputs=[],this.map=null,this.callbacks=null,this.strict=!1,this.pendingSubtypeChoice=null,this._updateInputs=a((async()=>{this._stopExpressions();const{_featureClone:e,_initialFeature:t,arcadeEditType:n,formTemplate:s,inputs:i,layer:o,timeZone:r}=this;if(!o)return;const a={arcadeEditType:n,feature:e,initialFeature:t,layer:o,timeZone:r},l=i.slice(),u=s?.elements&&s.elements.length>0?await this._updateInputsUsingFormElements(l,s.elements,a):this._updateInputsUsingLayerFields(l,o?.fields,a);this.inputs=u,await this._startExpressions()}))}initialize(){const e=l((()=>[this.layer,!!this.layer?.loaded,this.formTemplate,this.feature,this.timeZone,this.arcadeEditType]),(([e,t])=>{null!=e&&(t?this._updatingHandles.addPromise(this._updateInputs()):e.load().catch((()=>{})))}),c),t=l((()=>this._arcadeContextInfo),(e=>{null!=this._expressionsManager&&(this._expressionsManager.arcadeContextInfo=e,this._evaluateExpressions((e=>e.evaluateAll())))})),n=l((()=>this.layer),(e=>{const t="subtype-sublayer"===e?.type?e.parent:"feature"===e?.type?e:null;t&&this.addResolvingPromise(F.createLoadedLayerContingentValuesCache(t).then((e=>{this._contingentValuesCache=e,this.notifyChange("fieldsWithContingentValues")})))}),{initial:!0});this.addHandles([e,t,n])}destroy(){this.feature=null,this.layer=null,this._contingentValuesCache=o(this._contingentValuesCache),this.highlightHelper?.removeAll(),this._updatingHandles.destroy()}get _expressionInfosLookup(){return new Map(this.formTemplate?.expressionInfos?.map((e=>[e.name,e])))}get activeAssociationInput(){return this.allAssociationInputs.find((e=>e.uid===this.associationId))}get activeRelationshipInput(){return this.allRelationshipInputs.find((e=>e.relationshipId===this.relationshipId||e.activeCategory||e.showAllEnabled))}get _arcadeContextInfo(){const{_initialFeature:e,arcadeEditType:t,layer:n,map:s,spatialReference:i,timeZone:o}=this;return{layer:C(n)?n:null,originalFeature:e,editType:t,map:s,spatialReference:i,timeZone:o}}get associationId(){return this._get("associationId")}set associationId(e){null==e&&this.activeAssociationInput?.viewModel&&(this.activeAssociationInput.associatedLayer=null,this.activeAssociationInput.viewModel.activeAssociationType=null),this._set("associationId",e)}get associatedLayer(){return this.activeAssociationInput?.associatedLayer}set associatedLayer(e){this.activeAssociationInput&&(this.activeAssociationInput.associatedLayer=e)}get allAssociationInputs(){return A(this.inputs)}get allFieldInputs(){return j(this.inputs)}get allGroupInputs(){return this.inputs.filter(T)}get allRelationshipInputs(){return M(this.inputs)}get _layerFieldsByName(){return new Map(this.layer?.fields.map((e=>[e.name,e])))}get feature(){return this._get("feature")}set feature(e){const t=this._get("feature");this._featureClone=e?e.clone():$.clone(),this._initialFeature=this._featureClone.clone(),this._expressionsManager&&(this._expressionsManager.feature=this._featureClone),e?(this._resetFieldInputValues(this._featureClone),this.allRelationshipInputs.forEach((t=>t.feature=e))):(this.inputs.forEach((e=>e.destroy())),this.inputs.length=0),t!==e&&(this.pendingSubtypeChoice=null),this.contingencyConstraintViolations.clear(),this._set("feature",e)}get fieldsWithContingentValues(){if(null==this._contingentValuesCache)return new Set;const e=this._contingentValuesCache.fieldGroups.flatMap((e=>e.fields));return new Set(e)}get formTemplate(){return this.layer&&"formTemplate"in this.layer?this.layer.formTemplate:null}set formTemplate(e){void 0===e?this._clearOverride("formTemplate"):this._override("formTemplate",e)}get formDescription(){const{formTemplate:e,layer:t}=this;return e?.description&&t?k({label:e.description,attributes:this.getValues(),fieldsIndex:t.fieldsIndex,timeZone:this.timeZone}):null}get formTitle(){const{formTemplate:e,layer:t}=this;return e?.title&&t?k({label:e.title,attributes:this.getValues(),fieldsIndex:t.fieldsIndex,timeZone:this.timeZone}):null}get formHeaderVisible(){const{activeRelationshipInput:e,activeAssociationInput:t,formDescription:n,formTitle:s}=this;return!(e||t||!n&&!s)}get joinedContingentValues(){return this._joinContingentValues()}get layer(){return this.feature?.sourceLayer&&"applyEdits"in this.feature.sourceLayer?this.feature.sourceLayer:null}set layer(e){this._override("layer",e)}get relationshipId(){return this._get("relationshipId")}set relationshipId(e){const t=this.allRelationshipInputs;if(null!=e&&e===this.relationshipId||t.forEach((e=>{e.showAllEnabled=!1,e.activeCategory=null})),null!=e){const n=t.find((t=>t.relationshipId===e));n&&(n.showAllEnabled=!0)}this._set("relationshipId",e)}get spatialReference(){return this.layer?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){return this.layer?.loaded?"ready":"disabled"}get submittable(){return!!this.valid||this.allFieldInputs.filter((e=>!e.valid)).every((({submittable:e})=>e))}get timeZone(){const{layer:e}=this;if(e&&"datesInUnknownTimezone"in e&&e.datesInUnknownTimezone)return b;const t=e&&"preferredTimeZone"in e&&e.preferredTimeZone;return this._timeZone===V?t||b:this._timeZone||w}set timeZone(e){this._timeZone=e}get updating(){return this._updatingHandles.updating}get valid(){const e=this.allFieldInputs;return e.length>0&&e.every((({valid:e})=>e))}findField(e){return this.allFieldInputs.find((t=>t.name===e))}getFieldValueOptionsForField(e,t){const n=this.findField(e);if(!n)return[[],[],[]];const s="coded-value"===n.domain?.type?n.domain.codedValues.map((({name:e,code:t})=>({name:e,value:t}))):[],i=null==n.value||s.some((e=>e.value===n.value))?[]:[{name:`${n.value}`,value:n.value}],o=this.fieldsWithContingentValues.has(e)?this._getContingentValueOptionsForField(e,t):[];if(o.length>0){const e=new Set(o.map((e=>e.value)));return[o,s.filter((t=>!e.has(t.value))),i]}return[s,[],i]}getValue(e){const t=this.layer?.getField(e);if(null!=t)return this._featureClone.getAttribute(t.name)??null}setValue(e,t){const{_featureClone:n,strict:s}=this,i=this.findField(e);t=""===t?null:t,i&&n.getAttribute(e)!==t&&(i.value=t,s&&!i.valid||(this._afterValueChange(i),this._evaluateExpressions((t=>t.evaluateInvalidated([e])))))}getValues(){return{...this._featureClone.attributes}}overrideInitialFeature(e){this._initialFeature=e}submit(){const e=this.allFieldInputs,t=new Set(e.filter((e=>e.valid)).map((({name:e})=>e))),n=e.filter((e=>!e.valid)).map((({name:e})=>e)),s=this.getValues();if(this.validateContingencyConstraints(s,{includeIncompleteViolations:!0}).length>0)for(const[i,o]of this.contingencyConstraintViolations.entries())"error"===o.type&&(t.delete(i),n.push(i));this.notifyChange("submittable"),this.notifyChange("valid"),this.emit("submit",{valid:[...t],invalid:n,values:s})}validateContingencyConstraints(e,t){const{_contingentValuesCache:n}=this,s=new Map;if(this.contingencyConstraintViolations=s,null==n)return[];const{invalid:i,incomplete:o}=n.validateContingencyConstraints(e),r=[...i,...t?.includeIncompleteViolations?o:[]];for(const a of r)for(const e of a.fieldGroup.fields)s.set(e,a);return r}notifyFeatureGeometryChanged(){const{feature:e,_featureClone:t}=this;e&&(t.geometry=e.geometry,this._evaluateExpressions((e=>e.evaluateInvalidatedByGeometry())))}applySubtypeDefaults(e){const{defaultValues:t}=e,{allFieldInputs:n}=this;for(const{name:s}of n){const e=t[s];null!=e&&this.setValue(s,e)}}_emitChangeEvent({name:e,valid:t,value:n}){this.emit("value-change",{layer:this.layer,feature:this.feature,fieldName:e,value:n,valid:t})}async _evaluateExpressions(e){const t=this._expressionsManager;null!=t&&await this._updatingHandles.addPromise(e(t).finally((()=>this._afterExpressionsEvaluated())))}async _updateInputsUsingFormElements(e,t,n){const s=new Map;for(const r of e)if(T(r)){s.set(r.element,r);for(const e of r.inputs)e.element&&s.set(e.element,e)}else r.element&&s.set(r.element,r);const i=new Map,o=await this._updateInputsUsingFormElementsRecursive({existingInputsByElement:s,updatedElements:t.filter(Q),sharedInitializationProperties:n,group:null,newExpressionExecutorPromises:i});for(const[r,a]of s.entries())s.delete(r),a.destroy();return await Promise.all(Array.from(i.values())),o}async _updateInputsUsingFormElementsRecursive(e){const{existingInputsByElement:t,updatedElements:n,sharedInitializationProperties:s,group:i,newExpressionExecutorPromises:o}=e,r=[];for(const a of n){const e=t.has(a),n=e?t.get(a):g(a)?await this._makeUtilityNetworkAssociationInputFromElement(a,s,i):this._makeInputFromElement(a,s,i);if(n){if(r.push(n),await u((()=>!n.updating)),this._assignExpressionExecutors(n,a,o),e)if(t.delete(a),T(n)){const{feature:e,timeZone:t}=s;n.set({feature:e,timeZone:t})}else if(N(n)){const e=this.relationshipId===a.relationshipId;n.set(s),n.set({map:this.map,showAllEnabled:e})}else g(n)?(n.set(s),n.set({map:this.map})):n.set(s);if(_(a)){const e=a.elements.filter((e=>Q(e)));n.inputs=await this._updateInputsUsingFormElementsRecursive({existingInputsByElement:t,updatedElements:e,sharedInitializationProperties:s,group:n,newExpressionExecutorPromises:o})}}}return r}_updateInputsUsingLayerFields(e,t,n){if(!Array.isArray(t))return Y().warn(this.declaredClass,"No attribute fields found."),[];const s=new Map;for(const o of e)if(T(o)){for(const e of o.inputs)e.destroy();o.inputs.length=0,o.destroy()}else N(o)?o.destroy():L(o)&&(null!==o.element?o.destroy():s.set(o.field,o));const i=[];for(const o of t){const e=n.feature?.getAttribute(o.name)??null,t=s.get(o)??new Z({field:o,preservesValueWhenHidden:this.formTemplate?.preserveFieldValuesWhenHidden});i.push(t.set({...n,value:e})),s.delete(o)}for(const[o,r]of s.entries())s.delete(o),r.destroy();return i}_resetFieldInputValues(e){for(const t of this.allFieldInputs)t.value=e.getAttribute(t.name)}_makeInputFromElement(e,t,s){return _(e)?X(e,t):v(e)?this._makeFieldInputFromElement(e,t,s):I(e)?this._makeRelationshipInputFromElement(e,t,s):g(e)?this._makeUtilityNetworkAssociationInputFromElement(e,t,s):x(e)?ee(e,t):g(e)?this._makeUtilityNetworkAssociationInputFromElement(e,t,s):n()}_makeFieldInputFromElement(e,t,n){const{arcadeEditType:s,feature:i,initialFeature:o,layer:r,timeZone:a}=t,{fieldName:l}=e,u=l&&this._layerFieldsByName.get(l);return u?new Z({arcadeEditType:s,element:e,field:u,value:i?.getAttribute(e.fieldName)??null,feature:i,initialFeature:o,layer:r,group:n,preservesValueWhenHidden:this.formTemplate?.preserveFieldValuesWhenHidden,timeZone:a}):null}_makeRelationshipInputFromElement(e,t,n=null){const{map:s}=this,{feature:i,layer:o,timeZone:r}=t,a=new O({element:e,feature:i,group:n,layer:o,map:s,timeZone:r});return a.addHandles(p((()=>a.relatedLayer),"edits",(()=>this._evaluateExpressions((e=>e.evaluateAsyncExpressions()))))),a}async _makeUtilityNetworkAssociationInputFromElement(e,t,n=null){const{map:s}=this,{feature:i,layer:o,timeZone:r}=t;return new(0,(await import("./UtilityNetworkAssociationInput.js")).default)({element:e,feature:i,group:n,layer:o,map:s,timeZone:r})}_assignExpressionExecutors(e,t,n){const s=D[t.type],i=[];for(const o of s){const s=`${o}Executor`;if(e[s]){this._useExecutor(e[s]);continue}const r=t[o];if(null!=r&&""!==r){const t=this._expressionInfosLookup.get(r)?.expression??r;i.push(this._getOrCreateExecutorForExpression(t,n).then((t=>{e[s]=this._useExecutor(t)})))}}return R(e)&&i.push(...this._assignTextElementExpressionExecutors(e,n)),i}_assignTextElementExpressionExecutors(e,t){const{_expressionInfosLookup:n}=this,s=[];for(const o of e.expressionsUsed){const r=n.get(o);null!=r?s.push(this._getOrCreateExecutorForExpression(r.expression,t).then((t=>e.setExpressionExecutor(o,this._useExecutor(t))))):i.getLogger(this).error("feature-form:expression-not-found",`Could not find expressionInfo object with name '${o}'`)}for(const i of e.fieldsUsed){const n=`return $feature['${i}'];`;s.push(this._getOrCreateExecutorForExpression(n,t).then((t=>e.setFieldExecutor(i,this._useExecutor(t)))))}return s}async _getOrCreateExecutorForExpression(e,t){const{_expressionExecutorLookup:n}=this;if(n.has(e))return n.get(e);if(t.has(e))return t.get(e);const s=G(e,this.layer);t.set(e,s);const i=await s;return n.set(e,i),i}_createExpressionsManager(e){const{_arcadeContextInfo:t,_featureClone:n,allFieldInputs:s,formTemplate:i}=this;this._expressionsManager=new H({executors:e,feature:n,arcadeContextInfo:t,fieldInputs:s,preserveFieldValuesWhenHidden:!0===i?.preserveFieldValuesWhenHidden})}async _startExpressions(){if(0===this._expressionExecutorsInUse.size)return;const e=Array.from(this._expressionExecutorsInUse);this._createExpressionsManager(e),this._evaluateExpressions((e=>e.evaluateAll()))}_stopExpressions(){this._expressionsManager=o(this._expressionsManager),this._expressionExecutorsInUse.clear()}_useExecutor(e){return this._expressionExecutorsInUse.add(e),e}_afterValueChange(e){const{name:t,value:n}=e,{_featureClone:s,formTemplate:i,layer:o}=this;if(!o)return;const r=s.getAttribute(t);s.setAttribute(t,n);const{typeFieldName:a,types:l}=S(o);if((e.isSubtypeField||t===a)&&n!==r){if("subtype-sublayer"===o.type){const e=o.parent?.findSublayerForFeature(s);e&&(this.feature&&(this.feature.sourceLayer=e),s.sourceLayer=e)}const e=new Set;for(const t of l)if(t.domains&&"object"==typeof t.domains)for(const n of Object.keys(t.domains))e.add(n);for(const t of e){const e=this.findField(t);e&&e.notifyChange("domain")}this.notifyChange("joinedContingentValues")}if(null!=i){const{description:e,title:n}=i;n&&h(n,t)&&this.notifyChange("formTitle"),e&&h(e,t)&&this.notifyChange("formDescription")}this._emitChangeEvent(e)}_afterExpressionsEvaluated(){const{_featureClone:e}=this;for(const t of this.allFieldInputs)t.value!==e.getAttribute(t.name)&&this._afterValueChange(t)}_joinContingentValues(){const e=this._contingentValuesCache;if(null==e)return[];const{typeFieldName:t}=S(this.layer),n=t?this.getValue(t):null,s=[];for(const r of e.fieldGroups){const{contingencies:e,fields:t,name:i}=r,o=[];for(const s of e)s.isRetired||null!=s.subtype&&s.subtype.code!==n||o.push({values:s.values});o.length>0&&s.push({name:i,fields:t,contingencies:o})}const[i,o]=this._generateJoinPlan(s);return[...i.flatMap((e=>this._joinFieldGroupContingencies(e))),...o.flatMap((e=>e.contingencies))]}_generateJoinPlan(e){const t=new Map,n=[],s=new Set;for(const l of e)for(const e of l.fields)if(t.has(e)){const i=t.get(e),o=l,r=[i.name,o.name].sort().join("|");if(s.has(r))continue;n.push([i,o]),s.add(r),t.set(e,o)}else t.set(e,l);const i=new Set(n.flat()),o=new Set(e);for(const l of i)o.delete(l);const r=new Map,a=new Map;for(const l of new Set(n.flat())){const e=Symbol(l.name);r.set(e,new Set([l])),a.set(l,e)}for(const[l,u]of n){const e=a.get(l),t=a.get(u);if(e===t)continue;const n=r.get(e),s=r.get(t);for(const i of s)n.add(i),a.set(i,e);r.delete(t)}return[[...r.values()].map((e=>[...e])),[...o]]}_joinFieldGroupContingencies(e){const t=e.slice(),n=t.shift();let s=t.shift(),i=this._generateJoinKey(n.fields,s.fields),o=new Set([...n.fields,...s.fields]),r=new Map;for(const l of n.contingencies){const[e]=this._hashContingency(l,i.codedValueFields,!0);r.has(e)?r.get(e)?.push(l):r.set(e,[l])}for(;t.length>0;){const e=new Map,n=t.shift(),a=this._generateJoinKey(o,n.fields);for(const t of s.contingencies){const[n,s]=this._hashContingency(t,i.codedValueFields),o=s?this._findMatchingContingenciesWithAnyHashMask(r,n):r.get(n);if(r.has(J)&&o?.push(...this._findMatchingContingenciesContainingAny(t,r.get(J),i.codedValueFields)),null!=o)for(const r of o){const n=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(r,t,i.rangeFields):this._joinContingencies(r,t);if(null==n)break;const[s]=this._hashContingency(n,a.codedValueFields,!0);e.has(s)?e.get(s)?.push(n):e.set(s,[n])}}r=e,s=n,i=a,o=new Set([...o,...s.fields])}const a=[];for(const l of s.contingencies){const[e,t]=this._hashContingency(l,i.codedValueFields),n=t?this._findMatchingContingenciesWithAnyHashMask(r,e):r.get(e);if(r.has(J)&&n.push(...this._findMatchingContingenciesContainingAny(l,r.get(J),i.codedValueFields)),null!=n)for(const s of n){const e=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(s,l,i.rangeFields):this._joinContingencies(s,l);null!=e&&a.push(e)}}return a}_joinContingencies(e,t){const n={values:{...e.values,...t.values}};for(const[s,i]of Object.entries(n.values))"any"===i.objectType&&null!=e.values[s]&&(n.values[s]=e.values[s]);return n}_joinContingenciesWithRangeDomains(e,t,n){const s=this._joinContingencies(e,t);for(const i of n){const n=e.values[i],o=t.values[i],{leftIsNull:r,rightIsNull:a,bothAreNull:l,leftIsAny:u,rightIsAny:p,bothAreAny:c,leftIsRange:h,rightIsRange:d}=this._compareObjectTypes(n.objectType,o.objectType);if(l||c)continue;if(r&&p||a&&u){s.values[i]=new E({objectType:"null"});continue}if(r&&d||a&&h)return null;u?(n.minValue=-1/0,n.maxValue=1/0):p&&(o.minValue=-1/0,o.maxValue=1/0);const f=Math.max(n.minValue,o.minValue),m=Math.min(n.maxValue,o.maxValue);if(f>m)return null;s.values[i]=new E({objectType:"range",minValue:f,maxValue:m})}return s}_findMatchingContingenciesContainingAny(e,t,n){return t.filter((t=>n.every((n=>{const s=t.values[n],i=e.values[n];return"any"===s.objectType||"any"===i.objectType||s.codedValue?.code===i.codedValue?.code}))))}_findMatchingContingenciesWithAnyHashMask(e,t){const n=RegExp(`${t}$`),s=[];for(const[i,o]of e){if(i===J)break;n.test(i)&&s.push(...o)}return s}_generateJoinKey(e,t){const n=Array.isArray(e)?new Set(e):e,s=Array.isArray(t)?new Set(t):t,i=n.size<s.size?n:s,o=i===n?s:n,{feature:r}=this,a=new Set,l=new Set;for(const u of i)if(o.has(u)){const e=this.layer?.getFieldDomain(u,{feature:r??void 0,excludeImpliedDomains:!0});if(null==e)continue;switch(e.type){case"coded-value":a.add(u);break;case"range":l.add(u)}}return{codedValueFields:[...a],rangeFields:[...l]}}_contingencyIsValid(e,t){const n={};for(const{name:s,value:i}of this.allFieldInputs)this.fieldsWithContingentValues.has(s)&&null!=i&&s!==e&&(n[s]=i);return Object.entries(n).every((([e,n])=>!t.values.hasOwnProperty(e)||U(n,t.values[e])))}_getContingentValueOptionsForField(e,t){const n=this.joinedContingentValues.slice(),s=new Map,i={code:"",name:t??"No value"};for(const o of n){const t=o.values[e];if("code"===t?.objectType||"null"===t?.objectType){const{code:n,name:r}=t.codedValue&&"null"!==t.objectType?t.codedValue:i;!s.has(n)&&this._contingencyIsValid(e,o)&&s.set(n,{name:r,value:n})}}return[...s.values()]}_hashContingency(e,t,n=!1){if(t.length<1)return[z,!1];const s=[];let i=!1;for(const o of t){const t=e.values[o];if("any"===t.objectType){if(n)return[J,!0];i=!0,s.push(`${o}:.*`)}else"null"===t.objectType?s.push(`${o}:${B}`):s.push(`${o}:${t.codedValue?.code}`)}return[s.sort().join("&"),i]}_compareObjectTypes(e,t){return{leftIsNull:"null"===e,rightIsNull:"null"===t,bothAreNull:"null"===e&&"null"===t,leftIsAny:"any"===e,rightIsAny:"any"===t,bothAreAny:"any"===e&&"any"===t,leftIsRange:"range"===e,rightIsRange:"range"===t}}get test(){return{featureClone:this._featureClone}}};function Q(e){return"field"===e.type||"group"===e.type||"relationship"===e.type||"text"===e.type||"utilityNetworkAssociations"===e.type||(Y().warn("form-info::unsupported-element-type","Only element types 'field', 'group' and 'relationship' are supported",`Element ${e.label} has unsupported type '${e.type}'`),!1)}function X(e,t){const{feature:n,layer:s}=t;return new P({element:e,inputs:[],feature:n,layer:s})}function ee(e,t,n=null){const{feature:s,layer:i,timeZone:o}=t;return new W({element:e,feature:s,group:n,layer:i,timeZone:o})}e([d()],q.prototype,"_expressionInfosLookup",null),e([d()],q.prototype,"_featureClone",void 0),e([d()],q.prototype,"_timeZone",void 0),e([d()],q.prototype,"activeAssociation",void 0),e([d()],q.prototype,"activeAssociationInput",null),e([d()],q.prototype,"activeRelationshipInput",null),e([d()],q.prototype,"_arcadeContextInfo",null),e([d()],q.prototype,"associationId",null),e([d()],q.prototype,"associatedLayer",null),e([d()],q.prototype,"allAssociationInputs",null),e([d()],q.prototype,"allFieldInputs",null),e([d()],q.prototype,"allGroupInputs",null),e([d()],q.prototype,"allRelationshipInputs",null),e([d()],q.prototype,"_layerFieldsByName",null),e([d()],q.prototype,"arcadeEditType",void 0),e([d()],q.prototype,"contingencyConstraintViolations",void 0),e([d()],q.prototype,"disabled",void 0),e([d()],q.prototype,"feature",null),e([d()],q.prototype,"fieldsWithContingentValues",null),e([d({type:y})],q.prototype,"formTemplate",null),e([d()],q.prototype,"formDescription",null),e([d()],q.prototype,"formTitle",null),e([d()],q.prototype,"formHeaderVisible",null),e([d()],q.prototype,"highlightHelper",void 0),e([d()],q.prototype,"inputs",void 0),e([d()],q.prototype,"joinedContingentValues",null),e([d()],q.prototype,"layer",null),e([d()],q.prototype,"map",void 0),e([d()],q.prototype,"callbacks",void 0),e([d()],q.prototype,"relationshipId",null),e([d()],q.prototype,"spatialReference",null),e([d()],q.prototype,"state",null),e([d()],q.prototype,"strict",void 0),e([d()],q.prototype,"submittable",null),e([d()],q.prototype,"timeZone",null),e([d()],q.prototype,"updating",null),e([d()],q.prototype,"valid",null),e([d()],q.prototype,"pendingSubtypeChoice",void 0),e([d()],q.prototype,"getValues",null),e([d()],q.prototype,"submit",null),e([d()],q.prototype,"test",null),q=e([f(K)],q);const te=q;export{te as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{neverReached as n}from"../../core/compilerUtils.js";import s from"../../core/Evented.js";import i from"../../core/Logger.js";import{destroyMaybe as o}from"../../core/maybe.js";import r from"../../core/Promise.js";import{debounce as a}from"../../core/promiseUtils.js";import{watch as l,whenOnce as u,on as p,syncAndInitial as c}from"../../core/reactiveUtils.js";import{templateHasKey as h}from"../../core/string.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as m}from"../../core/support/UpdatingHandles.js";import y from"../../form/FormTemplate.js";import{isUtilityNetworkAssociationsElement as g,isGroupElement as _,isFieldElement as v,isRelationshipElement as I,isTextElement as E}from"../../form/support/formUtils.js";import x from"../../layers/support/ContingentValue.js";import{isEditableLayer as C}from"../../layers/support/editableLayers.js";import F from"../../layers/support/LayerContingentValuesCache.js";import{utc as b,unknown as V,system as w}from"../../time/constants.js";import{flattenAssociationInputs as A,flattenFieldInputs as j,isGroupInput as T,flattenRelationshipInputs as M,parseFormTemplateString as k,isRelationshipInput as N,isFieldInput as S,isTextElementInput as L,getNormalizedFeatureTypeInfo as R,valueIsValidContingentValue as U}from"./featureFormUtils.js";import Z from"./FieldInput.js";import{FormExpressionsManager as H}from"./FormExpressionsManager.js";import P from"./GroupInput.js";import O from"./RelationshipInput.js";import W from"./TextElementInput.js";import{createFormExpressionArcadeExecutor as G}from"../support/forms/expressions/FormExpressionArcadeExecutor.js";const $=new t({attributes:{}}),D={field:["editableExpression","requiredExpression","valueExpression","visibilityExpression"],group:["visibilityExpression"],relationship:["editableExpression","visibilityExpression"],text:["visibilityExpression"],utilityNetworkAssociations:["editableExpression","visibilityExpression"]},z="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",J="#JSAPI_CONTINGENT_VALUE_ANY_HASH",B="#JSAPI_CONTINGENT_VALUE_NULL_HASH";let K=class extends(r.EsriPromiseMixin(s.EventedAccessor)){constructor(e){super(e),this._expressionExecutorsInUse=new Set,this._expressionExecutorLookup=new Map,this._expressionsManager=null,this._contingentValuesCache=null,this._featureClone=$.clone(),this._initialFeature=$.clone(),this._timeZone=null,this._updatingHandles=new m,this.activeAssociation=null,this.arcadeEditType="NA",this.contingencyConstraintViolations=new Map,this.disabled=!1,this.highlightHelper=null,this.inputs=[],this.map=null,this.callbacks=null,this.strict=!1,this.pendingSubtypeChoice=null,this._updateInputs=a((async()=>{this._stopExpressions();const{_featureClone:e,_initialFeature:t,arcadeEditType:n,formTemplate:s,inputs:i,layer:o,timeZone:r}=this;if(!o)return;const a={arcadeEditType:n,feature:e,initialFeature:t,layer:o,timeZone:r},l=i.slice(),u=s?.elements&&s.elements.length>0?await this._updateInputsUsingFormElements(l,s.elements,a):this._updateInputsUsingLayerFields(l,o?.fields,a);this.inputs=u,await this._startExpressions()}))}initialize(){const e=l((()=>[this.layer,!!this.layer?.loaded,this.formTemplate,this.feature,this.timeZone,this.arcadeEditType]),(([e,t])=>{null!=e&&(t?this._updatingHandles.addPromise(this._updateInputs()):e.load().catch((()=>{})))}),c),t=l((()=>this._arcadeContextInfo),(e=>{null!=this._expressionsManager&&(this._expressionsManager.arcadeContextInfo=e,this._evaluateExpressions((e=>e.evaluateAll())))})),n=l((()=>this.layer),(e=>{const t="subtype-sublayer"===e?.type?e.parent:"feature"===e?.type?e:null;t&&this.addResolvingPromise(F.createLoadedLayerContingentValuesCache(t).then((e=>{this._contingentValuesCache=e,this.notifyChange("fieldsWithContingentValues")})))}),{initial:!0});this.addHandles([e,t,n])}destroy(){this.feature=null,this.layer=null,this._contingentValuesCache=o(this._contingentValuesCache),this.highlightHelper?.removeAll(),this._updatingHandles.destroy()}get _expressionInfosLookup(){return new Map(this.formTemplate?.expressionInfos?.map((e=>[e.name,e])))}get activeAssociationInput(){return this.allAssociationInputs.find((e=>e.uid===this.associationId))}get activeRelationshipInput(){return this.allRelationshipInputs.find((e=>e.relationshipId===this.relationshipId||e.activeCategory||e.showAllEnabled))}get _arcadeContextInfo(){const{_initialFeature:e,arcadeEditType:t,layer:n,map:s,spatialReference:i,timeZone:o}=this;return{layer:C(n)?n:null,originalFeature:e,editType:t,map:s,spatialReference:i,timeZone:o}}get associationId(){return this._get("associationId")}set associationId(e){null==e&&this.activeAssociationInput?.viewModel&&(this.activeAssociationInput.associatedLayer=null,this.activeAssociationInput.viewModel.activeAssociationType=null),this._set("associationId",e)}get associatedLayer(){return this.activeAssociationInput?.associatedLayer}set associatedLayer(e){this.activeAssociationInput&&(this.activeAssociationInput.associatedLayer=e)}get allAssociationInputs(){return A(this.inputs)}get allFieldInputs(){return j(this.inputs)}get allGroupInputs(){return this.inputs.filter(T)}get allRelationshipInputs(){return M(this.inputs)}get _layerFieldsByName(){return new Map(this.layer?.fields.map((e=>[e.name,e])))}get feature(){return this._get("feature")}set feature(e){const t=this._get("feature");this._featureClone=e?e.clone():$.clone(),this._initialFeature=this._featureClone.clone(),this._expressionsManager&&(this._expressionsManager.feature=this._featureClone),e?(this._resetFieldInputValues(this._featureClone),this.allRelationshipInputs.forEach((t=>t.feature=e))):(this.inputs.forEach((e=>e.destroy())),this.inputs.length=0),t!==e&&(this.pendingSubtypeChoice=null),this.contingencyConstraintViolations.clear(),this._set("feature",e)}get fieldsWithContingentValues(){if(null==this._contingentValuesCache)return new Set;const e=this._contingentValuesCache.fieldGroups.flatMap((e=>e.fields));return new Set(e)}get formTemplate(){return this.layer&&"formTemplate"in this.layer?this.layer.formTemplate:null}set formTemplate(e){void 0===e?this._clearOverride("formTemplate"):this._override("formTemplate",e)}get formDescription(){const{formTemplate:e,layer:t}=this;return e?.description&&t?k({label:e.description,attributes:this.getValues(),fieldsIndex:t.fieldsIndex,timeZone:this.timeZone}):null}get formTitle(){const{formTemplate:e,layer:t}=this;return e?.title&&t?k({label:e.title,attributes:this.getValues(),fieldsIndex:t.fieldsIndex,timeZone:this.timeZone}):null}get formHeaderVisible(){const{activeRelationshipInput:e,activeAssociationInput:t,formDescription:n,formTitle:s}=this;return!(e||t||!n&&!s)}get joinedContingentValues(){return this._joinContingentValues()}get layer(){return this.feature?.sourceLayer&&"applyEdits"in this.feature.sourceLayer?this.feature.sourceLayer:null}set layer(e){this._override("layer",e)}get relationshipId(){return this._get("relationshipId")}set relationshipId(e){const t=this.allRelationshipInputs;if(null!=e&&e===this.relationshipId||t.forEach((e=>{e.showAllEnabled=!1,e.activeCategory=null})),null!=e){const n=t.find((t=>t.relationshipId===e));n&&(n.showAllEnabled=!0)}this._set("relationshipId",e)}get spatialReference(){return this.layer?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){return this.layer?.loaded?"ready":"disabled"}get submittable(){return!!this.valid||this.allFieldInputs.filter((e=>!e.valid)).every((({submittable:e})=>e))}get timeZone(){const{layer:e}=this;if(e&&"datesInUnknownTimezone"in e&&e.datesInUnknownTimezone)return b;const t=e&&"preferredTimeZone"in e&&e.preferredTimeZone;return this._timeZone===V?t||b:this._timeZone||w}set timeZone(e){this._timeZone=e}get updating(){return this._updatingHandles.updating}get valid(){const e=this.allFieldInputs;return e.length>0&&e.every((({valid:e})=>e))}findField(e){return this.allFieldInputs.find((t=>t.name===e))}getFieldValueOptionsForField(e,t){const n=this.findField(e);if(!n)return[[],[],[]];const s="coded-value"===n.domain?.type?n.domain.codedValues.map((({name:e,code:t})=>({name:e,value:t}))):[],i=null==n.value||s.some((e=>e.value===n.value))?[]:[{name:`${n.value}`,value:n.value}],o=this.fieldsWithContingentValues.has(e)?this._getContingentValueOptionsForField(e,t):[];if(o.length>0){const e=new Set(o.map((e=>e.value)));return[o,s.filter((t=>!e.has(t.value))),i]}return[s,[],i]}getValue(e){const t=this.layer?.getField(e);if(null!=t)return this._featureClone.getAttribute(t.name)??null}setValue(e,t){const{_featureClone:n,strict:s}=this,i=this.findField(e);t=""===t?null:t,i&&n.getAttribute(e)!==t&&(i.value=t,s&&!i.valid||(this._afterValueChange(i),this._evaluateExpressions((t=>t.evaluateInvalidated([e])))))}getValues(){return{...this._featureClone.attributes}}overrideInitialFeature(e){this._initialFeature=e}submit(){const e=this.allFieldInputs,t=new Set(e.filter((e=>e.valid)).map((({name:e})=>e))),n=e.filter((e=>!e.valid)).map((({name:e})=>e)),s=this.getValues();if(this.validateContingencyConstraints(s,{includeIncompleteViolations:!0}).length>0)for(const[i,o]of this.contingencyConstraintViolations.entries())"error"===o.type&&(t.delete(i),n.push(i));this.notifyChange("submittable"),this.notifyChange("valid"),this.emit("submit",{valid:[...t],invalid:n,values:s})}validateContingencyConstraints(e,t){const{_contingentValuesCache:n}=this,s=new Map;if(this.contingencyConstraintViolations=s,null==n)return[];const{invalid:i,incomplete:o}=n.validateContingencyConstraints(e),r=[...i,...t?.includeIncompleteViolations?o:[]];for(const a of r)for(const e of a.fieldGroup.fields)s.set(e,a);return r}notifyFeatureGeometryChanged(){const{feature:e,_featureClone:t}=this;e&&(t.geometry=e.geometry,this._evaluateExpressions((e=>e.evaluateInvalidatedByGeometry())))}applySubtypeDefaults(e){const{defaultValues:t}=e,{allFieldInputs:n}=this;for(const{name:s}of n){const e=t[s];null!=e&&this.setValue(s,e)}}_emitChangeEvent({name:e,valid:t,value:n}){this.emit("value-change",{layer:this.layer,feature:this.feature,fieldName:e,value:n,valid:t})}async _evaluateExpressions(e){const t=this._expressionsManager;null!=t&&await this._updatingHandles.addPromise(e(t).finally((()=>this._afterExpressionsEvaluated())))}async _updateInputsUsingFormElements(e,t,n){const s=new Map;for(const r of e)if(T(r)){s.set(r.element,r);for(const e of r.inputs)e.element&&s.set(e.element,e)}else r.element&&s.set(r.element,r);const i=new Map,o=await this._updateInputsUsingFormElementsRecursive({existingInputsByElement:s,updatedElements:t.filter((e=>this._isSupportedElement(e))),sharedInitializationProperties:n,group:null,newExpressionExecutorPromises:i});for(const[r,a]of s.entries())s.delete(r),a.destroy();return await Promise.all(Array.from(i.values())),o}async _updateInputsUsingFormElementsRecursive(e){const{existingInputsByElement:t,updatedElements:n,sharedInitializationProperties:s,group:i,newExpressionExecutorPromises:o}=e,r=[];for(const a of n){const e=t.has(a),n=e?t.get(a):g(a)?await this._makeUtilityNetworkAssociationInputFromElement(a,s,i):this._makeInputFromElement(a,s,i);if(n){if(r.push(n),await u((()=>!n.updating)),this._assignExpressionExecutors(n,a,o),e)if(t.delete(a),T(n)){const{feature:e,timeZone:t}=s;n.set({feature:e,timeZone:t})}else if(N(n)){const e=this.relationshipId===a.relationshipId;n.set(s),n.set({map:this.map,showAllEnabled:e})}else g(n)?(n.set(s),n.set({map:this.map})):n.set(s);if(_(a)){const e=a.elements.filter((e=>this._isSupportedElement(e)));n.inputs=await this._updateInputsUsingFormElementsRecursive({existingInputsByElement:t,updatedElements:e,sharedInitializationProperties:s,group:n,newExpressionExecutorPromises:o})}}}return r}_updateInputsUsingLayerFields(e,t,n){if(!Array.isArray(t))return i.getLogger(this).warn(this.declaredClass,"No attribute fields found."),[];const s=new Map;for(const i of e)if(T(i)){for(const e of i.inputs)e.destroy();i.inputs.length=0,i.destroy()}else N(i)?i.destroy():S(i)&&(null!==i.element?i.destroy():s.set(i.field,i));const o=[];for(const i of t){const e=n.feature?.getAttribute(i.name)??null,t=s.get(i)??new Z({field:i,preservesValueWhenHidden:this.formTemplate?.preserveFieldValuesWhenHidden});o.push(t.set({...n,value:e})),s.delete(i)}for(const[i,r]of s.entries())s.delete(i),r.destroy();return o}_resetFieldInputValues(e){for(const t of this.allFieldInputs)t.value=e.getAttribute(t.name)}_makeInputFromElement(e,t,s){return _(e)?Y(e,t):v(e)?this._makeFieldInputFromElement(e,t,s):I(e)?this._makeRelationshipInputFromElement(e,t,s):g(e)?this._makeUtilityNetworkAssociationInputFromElement(e,t,s):E(e)?q(e,t):g(e)?this._makeUtilityNetworkAssociationInputFromElement(e,t,s):n()}_makeFieldInputFromElement(e,t,n){const{arcadeEditType:s,feature:i,initialFeature:o,layer:r,timeZone:a}=t,{fieldName:l}=e,u=l&&this._layerFieldsByName.get(l);return u?new Z({arcadeEditType:s,element:e,field:u,value:i?.getAttribute(e.fieldName)??null,feature:i,initialFeature:o,layer:r,group:n,preservesValueWhenHidden:this.formTemplate?.preserveFieldValuesWhenHidden,timeZone:a}):null}_makeRelationshipInputFromElement(e,t,n=null){const{map:s}=this,{feature:i,layer:o,timeZone:r}=t,a=new O({element:e,feature:i,group:n,layer:o,map:s,timeZone:r});return a.addHandles(p((()=>a.relatedLayer),"edits",(()=>this._evaluateExpressions((e=>e.evaluateAsyncExpressions()))))),a}async _makeUtilityNetworkAssociationInputFromElement(e,t,n=null){const{map:s}=this,{feature:i,layer:o,timeZone:r}=t;return new(0,(await import("./UtilityNetworkAssociationInput.js")).default)({element:e,feature:i,group:n,layer:o,map:s,timeZone:r})}_assignExpressionExecutors(e,t,n){const s=D[t.type],i=[];for(const o of s){const s=`${o}Executor`;if(e[s]){this._useExecutor(e[s]);continue}const r=t[o];if(null!=r&&""!==r){const t=this._expressionInfosLookup.get(r)?.expression??r;i.push(this._getOrCreateExecutorForExpression(t,n).then((t=>{e[s]=this._useExecutor(t)})))}}return L(e)&&i.push(...this._assignTextElementExpressionExecutors(e,n)),i}_assignTextElementExpressionExecutors(e,t){const{_expressionInfosLookup:n}=this,s=[];for(const o of e.expressionsUsed){const r=n.get(o);null!=r?s.push(this._getOrCreateExecutorForExpression(r.expression,t).then((t=>e.setExpressionExecutor(o,this._useExecutor(t))))):i.getLogger(this).error("feature-form:expression-not-found",`Could not find expressionInfo object with name '${o}'`)}for(const i of e.fieldsUsed){const n=`return $feature['${i}'];`;s.push(this._getOrCreateExecutorForExpression(n,t).then((t=>e.setFieldExecutor(i,this._useExecutor(t)))))}return s}async _getOrCreateExecutorForExpression(e,t){const{_expressionExecutorLookup:n}=this;if(n.has(e))return n.get(e);if(t.has(e))return t.get(e);const s=G(e,this.layer);t.set(e,s);const i=await s;return n.set(e,i),i}_createExpressionsManager(e){const{_arcadeContextInfo:t,_featureClone:n,allFieldInputs:s,formTemplate:i}=this;this._expressionsManager=new H({executors:e,feature:n,arcadeContextInfo:t,fieldInputs:s,preserveFieldValuesWhenHidden:!0===i?.preserveFieldValuesWhenHidden})}async _startExpressions(){if(0===this._expressionExecutorsInUse.size)return;const e=Array.from(this._expressionExecutorsInUse);this._createExpressionsManager(e),this._evaluateExpressions((e=>e.evaluateAll()))}_stopExpressions(){this._expressionsManager=o(this._expressionsManager),this._expressionExecutorsInUse.clear()}_useExecutor(e){return this._expressionExecutorsInUse.add(e),e}_afterValueChange(e){const{name:t,value:n}=e,{_featureClone:s,formTemplate:i,layer:o}=this;if(!o)return;const r=s.getAttribute(t);s.setAttribute(t,n);const{typeFieldName:a,types:l}=R(o);if((e.isSubtypeField||t===a)&&n!==r){if("subtype-sublayer"===o.type){const e=o.parent?.findSublayerForFeature(s);e&&(this.feature&&(this.feature.sourceLayer=e),s.sourceLayer=e)}const e=new Set;for(const t of l)if(t.domains&&"object"==typeof t.domains)for(const n of Object.keys(t.domains))e.add(n);for(const t of e){const e=this.findField(t);e&&e.notifyChange("domain")}this.notifyChange("joinedContingentValues")}if(null!=i){const{description:e,title:n}=i;n&&h(n,t)&&this.notifyChange("formTitle"),e&&h(e,t)&&this.notifyChange("formDescription")}this._emitChangeEvent(e)}_afterExpressionsEvaluated(){const{_featureClone:e}=this;for(const t of this.allFieldInputs)t.value!==e.getAttribute(t.name)&&this._afterValueChange(t)}_joinContingentValues(){const e=this._contingentValuesCache;if(null==e)return[];const{typeFieldName:t}=R(this.layer),n=t?this.getValue(t):null,s=[];for(const r of e.fieldGroups){const{contingencies:e,fields:t,name:i}=r,o=[];for(const s of e)s.isRetired||null!=s.subtype&&s.subtype.code!==n||o.push({values:s.values});o.length>0&&s.push({name:i,fields:t,contingencies:o})}const[i,o]=this._generateJoinPlan(s);return[...i.flatMap((e=>this._joinFieldGroupContingencies(e))),...o.flatMap((e=>e.contingencies))]}_generateJoinPlan(e){const t=new Map,n=[],s=new Set;for(const l of e)for(const e of l.fields)if(t.has(e)){const i=t.get(e),o=l,r=[i.name,o.name].sort().join("|");if(s.has(r))continue;n.push([i,o]),s.add(r),t.set(e,o)}else t.set(e,l);const i=new Set(n.flat()),o=new Set(e);for(const l of i)o.delete(l);const r=new Map,a=new Map;for(const l of new Set(n.flat())){const e=Symbol(l.name);r.set(e,new Set([l])),a.set(l,e)}for(const[l,u]of n){const e=a.get(l),t=a.get(u);if(e===t)continue;const n=r.get(e),s=r.get(t);for(const i of s)n.add(i),a.set(i,e);r.delete(t)}return[[...r.values()].map((e=>[...e])),[...o]]}_joinFieldGroupContingencies(e){const t=e.slice(),n=t.shift();let s=t.shift(),i=this._generateJoinKey(n.fields,s.fields),o=new Set([...n.fields,...s.fields]),r=new Map;for(const l of n.contingencies){const[e]=this._hashContingency(l,i.codedValueFields,!0);r.has(e)?r.get(e)?.push(l):r.set(e,[l])}for(;t.length>0;){const e=new Map,n=t.shift(),a=this._generateJoinKey(o,n.fields);for(const t of s.contingencies){const[n,s]=this._hashContingency(t,i.codedValueFields),o=s?this._findMatchingContingenciesWithAnyHashMask(r,n):r.get(n);if(r.has(J)&&o?.push(...this._findMatchingContingenciesContainingAny(t,r.get(J),i.codedValueFields)),null!=o)for(const r of o){const n=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(r,t,i.rangeFields):this._joinContingencies(r,t);if(null==n)break;const[s]=this._hashContingency(n,a.codedValueFields,!0);e.has(s)?e.get(s)?.push(n):e.set(s,[n])}}r=e,s=n,i=a,o=new Set([...o,...s.fields])}const a=[];for(const l of s.contingencies){const[e,t]=this._hashContingency(l,i.codedValueFields),n=t?this._findMatchingContingenciesWithAnyHashMask(r,e):r.get(e);if(r.has(J)&&n.push(...this._findMatchingContingenciesContainingAny(l,r.get(J),i.codedValueFields)),null!=n)for(const s of n){const e=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(s,l,i.rangeFields):this._joinContingencies(s,l);null!=e&&a.push(e)}}return a}_joinContingencies(e,t){const n={values:{...e.values,...t.values}};for(const[s,i]of Object.entries(n.values))"any"===i.objectType&&null!=e.values[s]&&(n.values[s]=e.values[s]);return n}_joinContingenciesWithRangeDomains(e,t,n){const s=this._joinContingencies(e,t);for(const i of n){const n=e.values[i],o=t.values[i],{leftIsNull:r,rightIsNull:a,bothAreNull:l,leftIsAny:u,rightIsAny:p,bothAreAny:c,leftIsRange:h,rightIsRange:d}=this._compareObjectTypes(n.objectType,o.objectType);if(l||c)continue;if(r&&p||a&&u){s.values[i]=new x({objectType:"null"});continue}if(r&&d||a&&h)return null;u?(n.minValue=-1/0,n.maxValue=1/0):p&&(o.minValue=-1/0,o.maxValue=1/0);const f=Math.max(n.minValue,o.minValue),m=Math.min(n.maxValue,o.maxValue);if(f>m)return null;s.values[i]=new x({objectType:"range",minValue:f,maxValue:m})}return s}_findMatchingContingenciesContainingAny(e,t,n){return t.filter((t=>n.every((n=>{const s=t.values[n],i=e.values[n];return"any"===s.objectType||"any"===i.objectType||s.codedValue?.code===i.codedValue?.code}))))}_findMatchingContingenciesWithAnyHashMask(e,t){const n=RegExp(`${t}$`),s=[];for(const[i,o]of e){if(i===J)break;n.test(i)&&s.push(...o)}return s}_generateJoinKey(e,t){const n=Array.isArray(e)?new Set(e):e,s=Array.isArray(t)?new Set(t):t,i=n.size<s.size?n:s,o=i===n?s:n,{feature:r}=this,a=new Set,l=new Set;for(const u of i)if(o.has(u)){const e=this.layer?.getFieldDomain(u,{feature:r??void 0,excludeImpliedDomains:!0});if(null==e)continue;switch(e.type){case"coded-value":a.add(u);break;case"range":l.add(u)}}return{codedValueFields:[...a],rangeFields:[...l]}}_contingencyIsValid(e,t){const n={};for(const{name:s,value:i}of this.allFieldInputs)this.fieldsWithContingentValues.has(s)&&null!=i&&s!==e&&(n[s]=i);return Object.entries(n).every((([e,n])=>!t.values.hasOwnProperty(e)||U(n,t.values[e])))}_getContingentValueOptionsForField(e,t){const n=this.joinedContingentValues.slice(),s=new Map,i={code:"",name:t??"No value"};for(const o of n){const t=o.values[e];if("code"===t?.objectType||"null"===t?.objectType){const{code:n,name:r}=t.codedValue&&"null"!==t.objectType?t.codedValue:i;!s.has(n)&&this._contingencyIsValid(e,o)&&s.set(n,{name:r,value:n})}}return[...s.values()]}_hashContingency(e,t,n=!1){if(t.length<1)return[z,!1];const s=[];let i=!1;for(const o of t){const t=e.values[o];if("any"===t.objectType){if(n)return[J,!0];i=!0,s.push(`${o}:.*`)}else"null"===t.objectType?s.push(`${o}:${B}`):s.push(`${o}:${t.codedValue?.code}`)}return[s.sort().join("&"),i]}_compareObjectTypes(e,t){return{leftIsNull:"null"===e,rightIsNull:"null"===t,bothAreNull:"null"===e&&"null"===t,leftIsAny:"any"===e,rightIsAny:"any"===t,bothAreAny:"any"===e&&"any"===t,leftIsRange:"range"===e,rightIsRange:"range"===t}}_isSupportedElement(e){return"field"===e.type||"group"===e.type||"relationship"===e.type||"text"===e.type||"utilityNetworkAssociations"===e.type||(i.getLogger(this).warn("form-info::unsupported-element-type","Only element types 'field', 'group' and 'relationship' are supported",`Element ${e.label} has unsupported type '${e.type}'`),!1)}get test(){return{featureClone:this._featureClone}}};function Y(e,t){const{feature:n,layer:s}=t;return new P({element:e,inputs:[],feature:n,layer:s})}function q(e,t,n=null){const{feature:s,layer:i,timeZone:o}=t;return new W({element:e,feature:s,group:n,layer:i,timeZone:o})}e([d()],K.prototype,"_expressionInfosLookup",null),e([d()],K.prototype,"_featureClone",void 0),e([d()],K.prototype,"_timeZone",void 0),e([d()],K.prototype,"activeAssociation",void 0),e([d()],K.prototype,"activeAssociationInput",null),e([d()],K.prototype,"activeRelationshipInput",null),e([d()],K.prototype,"_arcadeContextInfo",null),e([d()],K.prototype,"associationId",null),e([d()],K.prototype,"associatedLayer",null),e([d()],K.prototype,"allAssociationInputs",null),e([d()],K.prototype,"allFieldInputs",null),e([d()],K.prototype,"allGroupInputs",null),e([d()],K.prototype,"allRelationshipInputs",null),e([d()],K.prototype,"_layerFieldsByName",null),e([d()],K.prototype,"arcadeEditType",void 0),e([d()],K.prototype,"contingencyConstraintViolations",void 0),e([d()],K.prototype,"disabled",void 0),e([d()],K.prototype,"feature",null),e([d()],K.prototype,"fieldsWithContingentValues",null),e([d({type:y})],K.prototype,"formTemplate",null),e([d()],K.prototype,"formDescription",null),e([d()],K.prototype,"formTitle",null),e([d()],K.prototype,"formHeaderVisible",null),e([d()],K.prototype,"highlightHelper",void 0),e([d()],K.prototype,"inputs",void 0),e([d()],K.prototype,"joinedContingentValues",null),e([d()],K.prototype,"layer",null),e([d()],K.prototype,"map",void 0),e([d()],K.prototype,"callbacks",void 0),e([d()],K.prototype,"relationshipId",null),e([d()],K.prototype,"spatialReference",null),e([d()],K.prototype,"state",null),e([d()],K.prototype,"strict",void 0),e([d()],K.prototype,"submittable",null),e([d()],K.prototype,"timeZone",null),e([d()],K.prototype,"updating",null),e([d()],K.prototype,"valid",null),e([d()],K.prototype,"pendingSubtypeChoice",void 0),e([d()],K.prototype,"getValues",null),e([d()],K.prototype,"submit",null),e([d()],K.prototype,"test",null),K=e([f("esri.widgets.FeatureForm.FeatureFormViewModel")],K);const Q=K;export{Q 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.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import r from"../../core/Accessor.js";import{createTask as s}from"../../core/asyncUtils.js";import o from"../../core/Collection.js";import{abortMaybe as a}from"../../core/maybe.js";import{ignoreAbortErrors as i,debounce as n}from"../../core/promiseUtils.js";import{watch as l,initial as u}from"../../core/reactiveUtils.js";import{sqlAnd as c}from"../../core/sql.js";import{property as y}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as p}from"../../core/support/UpdatingHandles.js";import{isLayerFromCatalog as d}from"../../layers/catalog/catalogUtils.js";import{isSubtypeGroupLayer as g,isKnowledgeGraphLayer as m,isSubtypeSublayer as _}from"../../layers/support/layerUtils.js";import{isAssociatedFeatureSupportedLayer as f}from"../Feature/support/featureUtils.js";import{isMapImageLayer as b}from"../FeatureTable/support/tableUtils.js";import{createAssociation as C}from"../support/UtilityNetworkAssociations/utils/createAssociation.js";import{getFeatureTitle as F}from"../support/UtilityNetworkAssociations/utils/getFeatureTitle.js";const A=100,q="association-key";let w=class extends r{constructor(e){super(e),this.graphic=null,this.layer=null,this.map=null,this.utilityNetwork=null,this.associationType=null,this.featureCount=0,this.featureSpatialItems=new o,this.highlightHelper=null,this._queryAbortController=null,this._queryPageAbortController=null,this._queryFeatureCountAbortController=null,this.featuresPerPage=30,this.selectedFeature=null,this.association=null,this.filterOptionsVisible=!1,this.filterWhereClause=null,this._rulesTable=null,this._canAssociate=!1,this._whereClause=null,this._setUpItemsTask=null,this._updatingHandlesSetUp=new p,this._queryFeaturesTask=null,this._updatingHandlesQueryFeatures=new p,this._validateAssociationTask=null,this._updatingHandlesAssociation=new p,this._featureIsNotSelected=e=>(this.globalIdField?e.attributes?.[this.globalIdField]??null:null)!==this.globalId,this._cancelQuery=()=>{const{_queryAbortController:e}=this;e&&e.abort(),this._queryAbortController=null},this._cancelQueryFeatureCount=()=>{const{_queryFeatureCountAbortController:e}=this;e&&e.abort(),this._queryFeatureCountAbortController=null},this._cancelQueryPage=()=>{const{_queryPageAbortController:e}=this;e&&e.abort(),this._queryPageAbortController=null},this._queryController=async()=>{this._cancelQuery();const e=new AbortController;this._queryAbortController=e,await i(this._query()).catch((()=>this._cancelQuery())),this._queryAbortController===e&&(this._queryAbortController=null)},this._queryFeatureCountController=async e=>{this._cancelQueryFeatureCount();const t=new AbortController;this._queryFeatureCountAbortController=t,await i(this._queryFeatureCount(e)).catch((()=>this._cancelQueryFeatureCount())),this._queryFeatureCountAbortController===t&&(this._queryFeatureCountAbortController=null)},this._queryPageController=async()=>{const e=new AbortController;this._queryPageAbortController=e,await i(this._queryPage()).catch((()=>this._cancelQueryPage())),this._queryPageAbortController===e&&(this._queryPageAbortController=null)},this._queryDebounced=n(this._queryController,A),this._queryFeatureCountDebounced=n(this._queryFeatureCountController,A),this._queryPageDebounced=n(this._queryPageController,A)}initialize(){this.addHandles([l((()=>[this.graphic,this.layer,this.map,this.utilityNetwork,this.globalId,this.associationType]),(()=>this._syncLayerItems()),u),l((()=>[this.selectedLayer,this.filterWhereClause,this.featuresPerPage]),(()=>{this.selectedLayer&&this._setUpFeatures()})),l((()=>this.selectedFeature),(()=>{this._setUpAssociation()})),l((()=>this.featurePage),(()=>this._queryPageDebounced()))])}destroy(){this._setUpItemsTask=a(this._setUpItemsTask),this._updatingHandlesSetUp.destroy(),this._queryFeaturesTask=a(this._queryFeaturesTask),this._updatingHandlesQueryFeatures.destroy(),this._validateAssociationTask=a(this._validateAssociationTask),this._updatingHandlesAssociation.destroy(),this._cancelQuery(),this._cancelQueryFeatureCount(),this._cancelQueryPage()}get mapTables(){const{map:e}=this;if(!e)return null;const t=new Set;return e.allTables.forEach((e=>this._collectIfValidParent(e,t))),new o([...t])}get mapLayers(){const{map:e}=this;if(!e)return null;const t=new Set;return e.allLayers.forEach((e=>this._collectIfValidParent(e,t))),new o([...t])}get state(){const{canLoadLayers:e,_queryAbortController:t,_queryPageAbortController:r}=this;return e?t||r||this._updatingHandlesQueryFeatures.updating?"querying":this._updatingHandlesSetUp.updating?"loading":"ready":"disabled"}get canAddAssociation(){return!(this.updating||!this.association)&&this._canAssociate}get globalId(){return(this.globalIdField&&this.graphic?.attributes?.[this.globalIdField])??null}get globalIdField(){const{layer:e}=this;return e?.globalIdField??null}get layerItems(){return this._get("layerItems")||new o}get tableItems(){return this._get("tableItems")||new o}get featureItems(){return this._get("featureItems")||new o}set featurePage(e){const{featuresPerPage:t,featureCount:r,featureSpatialItems:s}=this,o=s.length||r,a=1,i=Math.ceil(o/t)||1;this._set("featurePage",Math.min(Math.max(e,a),i))}get featurePage(){return this._get("featurePage")}get canLoadLayers(){const{map:e,utilityNetwork:t,graphic:r,associationType:s}=this;return!!(e&&t&&r&&s)}get canQuery(){const{utilityNetwork:e,graphic:t,associationType:r,selectedLayer:s}=this;return!!(e&&t&&r&&s)}get updating(){return this._updatingHandlesSetUp.updating||this._updatingHandlesAssociation.updating}get selectedLayer(){return this._get("selectedLayer")}set selectedLayer(e){e!==this.selectedLayer&&(this.filterWhereClause=null),this._set("selectedLayer",e)}get queryWhereClause(){const{_whereClause:e,filterWhereClause:t}=this;return c(e,t)}async handleSelectionComplete(e){const{associationType:t,featureSpatialItems:r,graphic:s,_rulesTable:o}=this,{selection:a}=e;if(r.removeAll(),!(t&&s&&o&&a?.length))return;const i=this._convertTypeToDirection(t.type),n=a.filter(this._featureIsNotSelected),l=o.getFeaturesCanAssociateWith(s,n,i),u=await this._processFeatures(l);r.addMany(u)}reset(){this.highlightHelper?.removeAll(),this.featureSpatialItems.removeAll(),this.featurePage=1}_collectIfValidLayer(e,t){f(e)&&!g(e)&&t.add(e)}_collectIfValidParent(e,t){const r=e=>this._collectIfValidLayer(e,t);d(e)||"catalog-footprint"===e.type||(m(e)?(e.layers?.forEach(r),e.tables?.forEach(r)):b(e)?(e.sublayers?.forEach(r),e.subtables?.forEach(r)):g(e)?e.sublayers?.forEach(r):this._collectIfValidLayer(e,t))}async _queryFeatureCount(e){const{selectedLayer:t,_queryFeatureCountAbortController:r}=this;if(this._set("featureCount",0),!t)return;await t.load();const s=t.createQuery();s.returnGeometry=!1,s.where=c(s.where,e);const o=await t.queryFeatureCount(s,{signal:r?.signal});o>0&&this._set("featureCount",o)}async _query(){const{canQuery:e,queryWhereClause:t,_queryAbortController:r,featureItems:s}=this;e&&(this.featurePage=1,s.destroyAll(),this.featureCount&&!this.destroyed&&s.addMany(await this._queryAssociatedFeatures(t,{signal:r?.signal})))}async _queryPage(){const{canQuery:e,queryWhereClause:t,featurePage:r,_queryPageAbortController:s,featureCount:o,featureItems:a}=this;e&&(r<2||!o||a.addMany(await this._queryAssociatedFeatures(t,{signal:s?.signal})))}_convertTypeToDirection(e){switch(e){case"attachment":return[{type:"attachment",direction:"from"}];case"connectivity":return[{type:"junction-junction-connectivity"},{type:"junction-edge-from-connectivity"},{type:"junction-edge-midspan-connectivity"},{type:"junction-edge-to-connectivity"}];case"container":return[{type:"containment",direction:"to"}];case"content":return[{type:"containment",direction:"from"}];case"structure":return[{type:"attachment",direction:"to"}]}}async getRulesTable(){const{utilityNetwork:e}=this;if(!e)return null;if(this._rulesTable)return this._rulesTable;const t=await e.getRulesTable();return await(t?.load()),this._rulesTable=t,t}async _syncLayerItems(){a(this._setUpItemsTask);const{graphic:e,associationType:t,layerItems:r,tableItems:o,canLoadLayers:i}=this,n=s((async s=>{if(this.selectedLayer=null,r.removeAll(),o.removeAll(),!i)return;const a=this.mapLayers?.toArray(),n=this.mapTables?.toArray();if(!a&&!n)return;if(s.aborted)return;const l=await this.getRulesTable(),u=this._convertTypeToDirection(t.type);if(a?.length){const t=l?.getLayersCanAssociateWith(e,a,u);if(s.aborted)return;r.addMany(t||[])}if(n?.length){const t=l?.getLayersCanAssociateWith(e,n,u);if(s.aborted)return;o.addMany(t||[])}}));this._updatingHandlesSetUp.addPromise(n.promise),this._setUpItemsTask=n}async _setUpFeatures(){a(this._queryFeaturesTask);const{graphic:e,associationType:t,selectedLayer:r,canQuery:o}=this;if(!o)return;const i=s((async s=>{const o=await this.getRulesTable(),a=this._convertTypeToDirection(t.type),i=o?.getFeaturesCanAssociateWithClause(e,r,a);this._whereClause=i,s.aborted||(await this._queryFeatureCountDebounced(this.queryWhereClause),await this._queryDebounced())}));this._updatingHandlesQueryFeatures.addPromise(i.promise),this._queryFeaturesTask=i}_determineFromAndTo(e,t,r){return"from"===r?{fromFeature:e,toFeature:t}:{fromFeature:t,toFeature:e}}_determineJunctionEdgeConnectivity(e,t){const{utilityNetwork:r}=this,s=_(e.sourceLayer)?e.sourceLayer.parent:e.sourceLayer,o=_(t.sourceLayer)?t.sourceLayer.parent:t.sourceLayer;if(!(r&&s&&"layerId"in s&&o&&"layerId"in o))return{fromFeature:e,toFeature:t,type:"junction-junction-connectivity"};const a=r.getSourceIdByLayerId(s.layerId),i=r.getSourceIdByLayerId(o.layerId);if(!a||!i)return{fromFeature:e,toFeature:t,type:"junction-junction-connectivity"};const n="junction"===r.getSourceTypeById(a),l="junction"===r.getSourceTypeById(i);return n&&l?{fromFeature:e,toFeature:t,type:"junction-junction-connectivity"}:l?{fromFeature:t,toFeature:e,type:"junction-edge-midspan-connectivity"}:{fromFeature:e,toFeature:t,type:"junction-edge-midspan-connectivity"}}_setUpAssociationHandles(){this.removeHandles(q),this.association&&this.addHandles(l((()=>[this.association?.associationType,this.association?.fromNetworkElement,this.association?.fromNetworkElement?.terminalId,this.association?.toNetworkElement,this.association?.toNetworkElement?.terminalId]),(()=>this.validateAssociation()),u),q)}_setUpAssociation(){const{utilityNetwork:e,graphic:t,selectedFeature:r,associationType:s}=this;if(!(e&&t&&r&&s))return void(this.association=null);const o=this._convertTypeToDirection(s.type);if(o.length>1){const{fromFeature:s,toFeature:o,type:a}=this._determineJunctionEdgeConnectivity(t,r.feature);return this.association=C({fromFeature:s,toFeature:o,utilityNetwork:e,associationType:a}),void this._setUpAssociationHandles()}const{fromFeature:a,toFeature:i}=this._determineFromAndTo(t,r.feature,o[0].direction);this.association=C({fromFeature:a,toFeature:i,utilityNetwork:e,associationType:o[0].type}),this._setUpAssociationHandles()}async _processFeatures(e){return Promise.all(e.map((async e=>{const{sourceLayer:t}=e;if(t&&"getFeatureTitle"in t){return{label:await t.getFeatureTitle(e)||F(e),feature:e}}return{label:F(e),feature:e}})))}async _queryAssociatedFeatures(e,t){const{featuresPerPage:r,layer:s,featurePage:o,featureCount:a,selectedLayer:i}=this,{canQuery:n,globalId:l}=this;if(!n||!s||!i||null==l)return[];const u=((o-1)*r+a)%a,y=r,{historicMoment:h,gdbVersion:p}=i,d=i.createQuery();d.where=c(d.where,e),d.start=u,d.num=y,d.returnGeometry=!1,d.historicMoment=h,d.gdbVersion=p,d.outFields=["*"];const g=await i.queryFeatures(d,{signal:t?.signal});return await this._processFeatures(g.features)}validateAssociation(){a(this._validateAssociationTask);const{utilityNetwork:e,association:t}=this,r=s((async()=>{e&&t&&(this._canAssociate=await e.canAddAssociation(t))}));this._updatingHandlesAssociation.addPromise(r.promise),this._validateAssociationTask=r}};e([y({type:t})],w.prototype,"graphic",void 0),e([y()],w.prototype,"layer",void 0),e([y()],w.prototype,"map",void 0),e([y({readOnly:!0})],w.prototype,"mapTables",null),e([y({readOnly:!0})],w.prototype,"mapLayers",null),e([y()],w.prototype,"utilityNetwork",void 0),e([y()],w.prototype,"associationType",void 0),e([y()],w.prototype,"state",null),e([y({readOnly:!0})],w.prototype,"canAddAssociation",null),e([y({readOnly:!0})],w.prototype,"globalId",null),e([y({readOnly:!0})],w.prototype,"globalIdField",null),e([y()],w.prototype,"featureCount",void 0),e([y({readOnly:!0})],w.prototype,"layerItems",null),e([y({readOnly:!0})],w.prototype,"tableItems",null),e([y({readOnly:!0})],w.prototype,"featureItems",null),e([y()],w.prototype,"featureSpatialItems",void 0),e([y()],w.prototype,"highlightHelper",void 0),e([y()],w.prototype,"_queryAbortController",void 0),e([y()],w.prototype,"_queryPageAbortController",void 0),e([y()],w.prototype,"_queryFeatureCountAbortController",void 0),e([y({value:1})],w.prototype,"featurePage",null),e([y()],w.prototype,"featuresPerPage",void 0),e([y({readOnly:!0})],w.prototype,"canLoadLayers",null),e([y({readOnly:!0})],w.prototype,"canQuery",null),e([y({readOnly:!0})],w.prototype,"updating",null),e([y()],w.prototype,"selectedLayer",null),e([y()],w.prototype,"selectedFeature",void 0),e([y()],w.prototype,"association",void 0),e([y()],w.prototype,"filterOptionsVisible",void 0),e([y()],w.prototype,"filterWhereClause",void 0),e([y()],w.prototype,"queryWhereClause",null),e([y()],w.prototype,"_rulesTable",void 0),e([y()],w.prototype,"_canAssociate",void 0),e([y()],w.prototype,"_whereClause",void 0),w=e([h("esri.widgets.FeatureForm.UtilityNetworkAssociationAddAssociationViewModel")],w);const T=w;export{T as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import r from"../../core/Accessor.js";import{createTask as s}from"../../core/asyncUtils.js";import o from"../../core/Collection.js";import{abortMaybe as a}from"../../core/maybe.js";import{ignoreAbortErrors as i,debounce as n}from"../../core/promiseUtils.js";import{watch as l,initial as u}from"../../core/reactiveUtils.js";import{sqlAnd as c}from"../../core/sql.js";import{property as y}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as p}from"../../core/support/UpdatingHandles.js";import{isLayerFromCatalog as d}from"../../layers/catalog/catalogUtils.js";import{isSubtypeGroupLayer as g,isKnowledgeGraphLayer as _,isMapImageLayer as m,isSubtypeSublayer as f}from"../../layers/support/layerUtils.js";import{isAssociatedFeatureSupportedLayer as b}from"../Feature/support/featureUtils.js";import{createAssociation as C}from"../support/UtilityNetworkAssociations/utils/createAssociation.js";import{getFeatureTitle as F}from"../support/UtilityNetworkAssociations/utils/getFeatureTitle.js";const A=100,q="association-key";let w=class extends r{constructor(e){super(e),this.graphic=null,this.layer=null,this.map=null,this.utilityNetwork=null,this.associationType=null,this.featureCount=0,this.featureSpatialItems=new o,this.highlightHelper=null,this._queryAbortController=null,this._queryPageAbortController=null,this._queryFeatureCountAbortController=null,this.featuresPerPage=30,this.selectedFeature=null,this.association=null,this.filterOptionsVisible=!1,this.filterWhereClause=null,this._rulesTable=null,this._canAssociate=!1,this._whereClause=null,this._setUpItemsTask=null,this._updatingHandlesSetUp=new p,this._queryFeaturesTask=null,this._updatingHandlesQueryFeatures=new p,this._validateAssociationTask=null,this._updatingHandlesAssociation=new p,this._featureIsNotSelected=e=>(this.globalIdField?e.attributes?.[this.globalIdField]??null:null)!==this.globalId,this._cancelQuery=()=>{const{_queryAbortController:e}=this;e&&e.abort(),this._queryAbortController=null},this._cancelQueryFeatureCount=()=>{const{_queryFeatureCountAbortController:e}=this;e&&e.abort(),this._queryFeatureCountAbortController=null},this._cancelQueryPage=()=>{const{_queryPageAbortController:e}=this;e&&e.abort(),this._queryPageAbortController=null},this._queryController=async()=>{this._cancelQuery();const e=new AbortController;this._queryAbortController=e,await i(this._query()).catch((()=>this._cancelQuery())),this._queryAbortController===e&&(this._queryAbortController=null)},this._queryFeatureCountController=async e=>{this._cancelQueryFeatureCount();const t=new AbortController;this._queryFeatureCountAbortController=t,await i(this._queryFeatureCount(e)).catch((()=>this._cancelQueryFeatureCount())),this._queryFeatureCountAbortController===t&&(this._queryFeatureCountAbortController=null)},this._queryPageController=async()=>{const e=new AbortController;this._queryPageAbortController=e,await i(this._queryPage()).catch((()=>this._cancelQueryPage())),this._queryPageAbortController===e&&(this._queryPageAbortController=null)},this._queryDebounced=n(this._queryController,A),this._queryFeatureCountDebounced=n(this._queryFeatureCountController,A),this._queryPageDebounced=n(this._queryPageController,A)}initialize(){this.addHandles([l((()=>[this.graphic,this.layer,this.map,this.utilityNetwork,this.globalId,this.associationType]),(()=>this._syncLayerItems()),u),l((()=>[this.selectedLayer,this.filterWhereClause,this.featuresPerPage]),(()=>{this.selectedLayer&&this._setUpFeatures()})),l((()=>this.selectedFeature),(()=>{this._setUpAssociation()})),l((()=>this.featurePage),(()=>this._queryPageDebounced()))])}destroy(){this._setUpItemsTask=a(this._setUpItemsTask),this._updatingHandlesSetUp.destroy(),this._queryFeaturesTask=a(this._queryFeaturesTask),this._updatingHandlesQueryFeatures.destroy(),this._validateAssociationTask=a(this._validateAssociationTask),this._updatingHandlesAssociation.destroy(),this._cancelQuery(),this._cancelQueryFeatureCount(),this._cancelQueryPage()}get mapTables(){const{map:e}=this;if(!e)return null;const t=new Set;return e.allTables.forEach((e=>this._collectIfValidParent(e,t))),new o([...t])}get mapLayers(){const{map:e}=this;if(!e)return null;const t=new Set;return e.allLayers.forEach((e=>this._collectIfValidParent(e,t))),new o([...t])}get state(){const{canLoadLayers:e,_queryAbortController:t,_queryPageAbortController:r}=this;return e?t||r||this._updatingHandlesQueryFeatures.updating?"querying":this._updatingHandlesSetUp.updating?"loading":"ready":"disabled"}get canAddAssociation(){return!(this.updating||!this.association)&&this._canAssociate}get globalId(){return(this.globalIdField&&this.graphic?.attributes?.[this.globalIdField])??null}get globalIdField(){const{layer:e}=this;return e?.globalIdField??null}get layerItems(){return this._get("layerItems")||new o}get tableItems(){return this._get("tableItems")||new o}get featureItems(){return this._get("featureItems")||new o}set featurePage(e){const{featuresPerPage:t,featureCount:r,featureSpatialItems:s}=this,o=s.length||r,a=1,i=Math.ceil(o/t)||1;this._set("featurePage",Math.min(Math.max(e,a),i))}get featurePage(){return this._get("featurePage")}get canLoadLayers(){const{map:e,utilityNetwork:t,graphic:r,associationType:s}=this;return!!(e&&t&&r&&s)}get canQuery(){const{utilityNetwork:e,graphic:t,associationType:r,selectedLayer:s}=this;return!!(e&&t&&r&&s)}get updating(){return this._updatingHandlesSetUp.updating||this._updatingHandlesAssociation.updating}get selectedLayer(){return this._get("selectedLayer")}set selectedLayer(e){e!==this.selectedLayer&&(this.filterWhereClause=null),this._set("selectedLayer",e)}get queryWhereClause(){const{_whereClause:e,filterWhereClause:t}=this;return c(e,t)}async handleSelectionComplete(e){const{associationType:t,featureSpatialItems:r,graphic:s,_rulesTable:o}=this,{selection:a}=e;if(r.removeAll(),!(t&&s&&o&&a?.length))return;const i=this._convertTypeToDirection(t.type),n=a.filter(this._featureIsNotSelected),l=o.getFeaturesCanAssociateWith(s,n,i),u=await this._processFeatures(l);r.addMany(u)}reset(){this.highlightHelper?.removeAll(),this.featureSpatialItems.removeAll(),this.featurePage=1}_collectIfValidLayer(e,t){b(e)&&!g(e)&&t.add(e)}_collectIfValidParent(e,t){const r=e=>this._collectIfValidLayer(e,t);d(e)||"catalog-footprint"===e.type||(_(e)?(e.layers?.forEach(r),e.tables?.forEach(r)):m(e)?(e.sublayers?.forEach(r),e.subtables?.forEach(r)):g(e)?e.sublayers?.forEach(r):this._collectIfValidLayer(e,t))}async _queryFeatureCount(e){const{selectedLayer:t,_queryFeatureCountAbortController:r}=this;if(this._set("featureCount",0),!t)return;await t.load();const s=t.createQuery();s.returnGeometry=!1,s.where=c(s.where,e);const o=await t.queryFeatureCount(s,{signal:r?.signal});o>0&&this._set("featureCount",o)}async _query(){const{canQuery:e,queryWhereClause:t,_queryAbortController:r,featureItems:s}=this;e&&(this.featurePage=1,s.destroyAll(),this.featureCount&&!this.destroyed&&s.addMany(await this._queryAssociatedFeatures(t,{signal:r?.signal})))}async _queryPage(){const{canQuery:e,queryWhereClause:t,featurePage:r,_queryPageAbortController:s,featureCount:o,featureItems:a}=this;e&&(r<2||!o||a.addMany(await this._queryAssociatedFeatures(t,{signal:s?.signal})))}_convertTypeToDirection(e){switch(e){case"attachment":return[{type:"attachment",direction:"from"}];case"connectivity":return[{type:"junction-junction-connectivity"},{type:"junction-edge-from-connectivity"},{type:"junction-edge-midspan-connectivity"},{type:"junction-edge-to-connectivity"}];case"container":return[{type:"containment",direction:"to"}];case"content":return[{type:"containment",direction:"from"}];case"structure":return[{type:"attachment",direction:"to"}]}}async getRulesTable(){const{utilityNetwork:e}=this;if(!e)return null;if(this._rulesTable)return this._rulesTable;const t=await e.getRulesTable();return await(t?.load()),this._rulesTable=t,t}async _syncLayerItems(){a(this._setUpItemsTask);const{graphic:e,associationType:t,layerItems:r,tableItems:o,canLoadLayers:i}=this,n=s((async s=>{if(this.selectedLayer=null,r.removeAll(),o.removeAll(),!i)return;const a=this.mapLayers?.toArray(),n=this.mapTables?.toArray();if(!a&&!n)return;if(s.aborted)return;const l=await this.getRulesTable(),u=this._convertTypeToDirection(t.type);if(a?.length){const t=l?.getLayersCanAssociateWith(e,a,u);if(s.aborted)return;r.addMany(t||[])}if(n?.length){const t=l?.getLayersCanAssociateWith(e,n,u);if(s.aborted)return;o.addMany(t||[])}}));this._updatingHandlesSetUp.addPromise(n.promise),this._setUpItemsTask=n}async _setUpFeatures(){a(this._queryFeaturesTask);const{graphic:e,associationType:t,selectedLayer:r,canQuery:o}=this;if(!o)return;const i=s((async s=>{const o=await this.getRulesTable(),a=this._convertTypeToDirection(t.type),i=o?.getFeaturesCanAssociateWithClause(e,r,a);this._whereClause=i,s.aborted||(await this._queryFeatureCountDebounced(this.queryWhereClause),await this._queryDebounced())}));this._updatingHandlesQueryFeatures.addPromise(i.promise),this._queryFeaturesTask=i}_determineFromAndTo(e,t,r){return"from"===r?{fromFeature:e,toFeature:t}:{fromFeature:t,toFeature:e}}_determineJunctionEdgeConnectivity(e,t){const{utilityNetwork:r}=this,s=f(e.sourceLayer)?e.sourceLayer.parent:e.sourceLayer,o=f(t.sourceLayer)?t.sourceLayer.parent:t.sourceLayer;if(!(r&&s&&"layerId"in s&&o&&"layerId"in o))return{fromFeature:e,toFeature:t,type:"junction-junction-connectivity"};const a=r.getSourceIdByLayerId(s.layerId),i=r.getSourceIdByLayerId(o.layerId);if(!a||!i)return{fromFeature:e,toFeature:t,type:"junction-junction-connectivity"};const n="junction"===r.getSourceTypeById(a),l="junction"===r.getSourceTypeById(i);return n&&l?{fromFeature:e,toFeature:t,type:"junction-junction-connectivity"}:l?{fromFeature:t,toFeature:e,type:"junction-edge-midspan-connectivity"}:{fromFeature:e,toFeature:t,type:"junction-edge-midspan-connectivity"}}_setUpAssociationHandles(){this.removeHandles(q),this.association&&this.addHandles(l((()=>[this.association?.associationType,this.association?.fromNetworkElement,this.association?.fromNetworkElement?.terminalId,this.association?.toNetworkElement,this.association?.toNetworkElement?.terminalId]),(()=>this.validateAssociation()),u),q)}_setUpAssociation(){const{utilityNetwork:e,graphic:t,selectedFeature:r,associationType:s}=this;if(!(e&&t&&r&&s))return void(this.association=null);const o=this._convertTypeToDirection(s.type);if(o.length>1){const{fromFeature:s,toFeature:o,type:a}=this._determineJunctionEdgeConnectivity(t,r.feature);return this.association=C({fromFeature:s,toFeature:o,utilityNetwork:e,associationType:a}),void this._setUpAssociationHandles()}const{fromFeature:a,toFeature:i}=this._determineFromAndTo(t,r.feature,o[0].direction);this.association=C({fromFeature:a,toFeature:i,utilityNetwork:e,associationType:o[0].type}),this._setUpAssociationHandles()}async _processFeatures(e){return Promise.all(e.map((async e=>{const{sourceLayer:t}=e;if(t&&"getFeatureTitle"in t){return{label:await t.getFeatureTitle(e)||F(e),feature:e}}return{label:F(e),feature:e}})))}async _queryAssociatedFeatures(e,t){const{featuresPerPage:r,layer:s,featurePage:o,featureCount:a,selectedLayer:i}=this,{canQuery:n,globalId:l}=this;if(!n||!s||!i||null==l)return[];const u=((o-1)*r+a)%a,y=r,{historicMoment:h,gdbVersion:p}=i,d=i.createQuery();d.where=c(d.where,e),d.start=u,d.num=y,d.returnGeometry=!1,d.historicMoment=h,d.gdbVersion=p,d.outFields=["*"];const g=await i.queryFeatures(d,{signal:t?.signal});return await this._processFeatures(g.features)}validateAssociation(){a(this._validateAssociationTask);const{utilityNetwork:e,association:t}=this,r=s((async()=>{e&&t&&(this._canAssociate=await e.canAddAssociation(t))}));this._updatingHandlesAssociation.addPromise(r.promise),this._validateAssociationTask=r}};e([y({type:t})],w.prototype,"graphic",void 0),e([y()],w.prototype,"layer",void 0),e([y()],w.prototype,"map",void 0),e([y({readOnly:!0})],w.prototype,"mapTables",null),e([y({readOnly:!0})],w.prototype,"mapLayers",null),e([y()],w.prototype,"utilityNetwork",void 0),e([y()],w.prototype,"associationType",void 0),e([y()],w.prototype,"state",null),e([y({readOnly:!0})],w.prototype,"canAddAssociation",null),e([y({readOnly:!0})],w.prototype,"globalId",null),e([y({readOnly:!0})],w.prototype,"globalIdField",null),e([y()],w.prototype,"featureCount",void 0),e([y({readOnly:!0})],w.prototype,"layerItems",null),e([y({readOnly:!0})],w.prototype,"tableItems",null),e([y({readOnly:!0})],w.prototype,"featureItems",null),e([y()],w.prototype,"featureSpatialItems",void 0),e([y()],w.prototype,"highlightHelper",void 0),e([y()],w.prototype,"_queryAbortController",void 0),e([y()],w.prototype,"_queryPageAbortController",void 0),e([y()],w.prototype,"_queryFeatureCountAbortController",void 0),e([y({value:1})],w.prototype,"featurePage",null),e([y()],w.prototype,"featuresPerPage",void 0),e([y({readOnly:!0})],w.prototype,"canLoadLayers",null),e([y({readOnly:!0})],w.prototype,"canQuery",null),e([y({readOnly:!0})],w.prototype,"updating",null),e([y()],w.prototype,"selectedLayer",null),e([y()],w.prototype,"selectedFeature",void 0),e([y()],w.prototype,"association",void 0),e([y()],w.prototype,"filterOptionsVisible",void 0),e([y()],w.prototype,"filterWhereClause",void 0),e([y()],w.prototype,"queryWhereClause",null),e([y()],w.prototype,"_rulesTable",void 0),e([y()],w.prototype,"_canAssociate",void 0),e([y()],w.prototype,"_whereClause",void 0),w=e([h("esri.widgets.FeatureForm.UtilityNetworkAssociationAddAssociationViewModel")],w);const T=w;export{T 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.33/esri/copyright.txt for details.
4
4
  */
5
- import{isGroupColumn as t}from"./columnUtils.js";import{loadCalciteComponents as e}from"../../support/componentsUtils.js";const n={action:"EsriFeatureTableActionColumn",attachments:"EsriFeatureTableAttachmentsColumn",relationship:"EsriFeatureTableRelationshipColumn"},i=()=>e({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon")}),o=()=>Promise.all([e({input:()=>import("@esri/calcite-components/dist/components/calcite-input"),option:()=>import("@esri/calcite-components/dist/components/calcite-option"),select:()=>import("@esri/calcite-components/dist/components/calcite-select"),"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")}),i()]),r=()=>Promise.all([e({"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar")}),o()]);function c(t){return null!=t&&"object"==typeof t&&"createQuery"in t&&"getField"in t&&"queryFeatureCount"in t&&"queryFeatures"in t&&"queryObjectIds"in t&&"capabilities"in t&&"fields"in t&&"fieldsIndex"in t&&"id"in t&&"load"in t&&"objectIdField"in t&&"type"in t&&"when"in t}function s(t){return c(t)&&"queryAttachments"in t}function a(t){return s(t)&&"addAttachment"in t&&"deleteAttachments"in t&&"updateAttachment"in t}function l(t){return c(t)&&"editingEnabled"in t&&"applyEdits"in t}function p(t){return c(t)&&"relationships"in t&&"queryRelatedFeatures"in t&&"queryRelatedFeaturesCount"in t}function u(t){return null!=t&&"object"==typeof t&&"type"in t&&"map-image"===t.type}function m(t,e,n){if(e?.map)return d(t,[...e.map.allLayers,...e.map.allTables],n)}function d(t,e,{relatedTableId:n}){const i="scene"===t.type&&t.associatedLayer?t.associatedLayer.url:t.url,o=e=>!(!p(e)||e===t)&&("sublayer"===e.type&&e.layer?.url===t.url?e.id===n:i===e.url&&e.layerId===n);if("sublayer"===t.type&&u(t.parent)){const e=e=>p(e)&&e!==t&&e.id===n,i=t.parent,o=i.sublayers?.find(e)||i.subtables?.find(e);if(p(o))return o}let r=null;for(const c of e)if(u(c)){const t=c.sublayers?.find(o)||c.subtables?.find(o);if(t){r=t;break}}else if(o(c)){r=c;break}if(p(r))return r}function f(t,e){return null!=t&&Number.isInteger(t)&&t>-1&&t<e}function y(t){return null==t||0===t.trim().length}function b(t,e){return(t.relationships??[]).filter((t=>!(t.id===e&&"one-to-one"===t.cardinality))).map((({id:t})=>({relationshipId:t})))}function h(t,e){return t.relationships?.find((({id:t})=>t===e))}function w(t,e){return null==e?null:t?.fields?.find((t=>e.toLowerCase()===t.name?.toLowerCase()))}function F(t,e){return e.some((e=>!("group"!==e.type||!F(t,e.columnTemplates))||e.fieldName===t))}function g(e,n){return n?.some((n=>!(!t(n)||!g(e,n.columns))||n.fieldName===e))??!1}function C(t,e){return`${t.id}-${e}`}export{w as findField,m as findRelatedLayer,d as findRelatedLayerInSources,h as findRelationship,b as getRelationshipIdsToShow,C as getTableHighlightKey,g as hasColumnForField,F as hasTemplateForField,y as isEmptyStringOrWhitespace,c as isIFeatureTableSupportedLayer,s as isIFeatureTableSupportedLayerWithAttachments,a as isIFeatureTableSupportedLayerWithAttachmentsEditing,l as isIFeatureTableSupportedLayerWithEditing,p as isIFeatureTableSupportedLayerWithRelationships,u as isMapImageLayer,f as isPageIndexValid,i as loadColumnComponents,o as loadEditorColumnComponents,r as loadFieldColumnComponents,n as uniqueColumnNames};
5
+ import{isMapImageLayer as t}from"../../../layers/support/layerUtils.js";import{isGroupColumn as e}from"./columnUtils.js";import{loadCalciteComponents as n}from"../../support/componentsUtils.js";const i={action:"EsriFeatureTableActionColumn",attachments:"EsriFeatureTableAttachmentsColumn",relationship:"EsriFeatureTableRelationshipColumn"},o=()=>n({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon")}),r=()=>Promise.all([n({input:()=>import("@esri/calcite-components/dist/components/calcite-input"),option:()=>import("@esri/calcite-components/dist/components/calcite-option"),select:()=>import("@esri/calcite-components/dist/components/calcite-select"),"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")}),o()]),c=()=>Promise.all([n({"action-bar":()=>import("@esri/calcite-components/dist/components/calcite-action-bar")}),r()]);function s(t){return null!=t&&"object"==typeof t&&"createQuery"in t&&"getField"in t&&"queryFeatureCount"in t&&"queryFeatures"in t&&"queryObjectIds"in t&&"capabilities"in t&&"fields"in t&&"fieldsIndex"in t&&"id"in t&&"load"in t&&"objectIdField"in t&&"type"in t&&"when"in t}function a(t){return s(t)&&"queryAttachments"in t}function l(t){return a(t)&&"addAttachment"in t&&"deleteAttachments"in t&&"updateAttachment"in t}function p(t){return s(t)&&"editingEnabled"in t&&"applyEdits"in t}function u(t){return s(t)&&"relationships"in t&&"queryRelatedFeatures"in t&&"queryRelatedFeaturesCount"in t}function m(t,e,n){if(e?.map)return d(t,[...e.map.allLayers,...e.map.allTables],n)}function d(e,n,{relatedTableId:i}){const o="scene"===e.type&&e.associatedLayer?e.associatedLayer.url:e.url,r=t=>!(!u(t)||t===e)&&("sublayer"===t.type&&t.layer?.url===e.url?t.id===i:o===t.url&&t.layerId===i);if("sublayer"===e.type&&t(e.parent)){const t=t=>u(t)&&t!==e&&t.id===i,n=e.parent,o=n.sublayers?.find(t)||n.subtables?.find(t);if(u(o))return o}let c=null;for(const s of n)if(t(s)){const t=s.sublayers?.find(r)||s.subtables?.find(r);if(t){c=t;break}}else if(r(s)){c=s;break}if(u(c))return c}function f(t,e){return null!=t&&Number.isInteger(t)&&t>-1&&t<e}function y(t){return null==t||0===t.trim().length}function b(t,e){return(t.relationships??[]).filter((t=>!(t.id===e&&"one-to-one"===t.cardinality))).map((({id:t})=>({relationshipId:t})))}function h(t,e){return t.relationships?.find((({id:t})=>t===e))}function w(t,e){return null==e?null:t?.fields?.find((t=>e.toLowerCase()===t.name?.toLowerCase()))}function F(t,e){return e.some((e=>!("group"!==e.type||!F(t,e.columnTemplates))||e.fieldName===t))}function g(t,n){return n?.some((n=>!(!e(n)||!g(t,n.columns))||n.fieldName===t))??!1}function C(t,e){return`${t.id}-${e}`}export{w as findField,m as findRelatedLayer,d as findRelatedLayerInSources,h as findRelationship,b as getRelationshipIdsToShow,C as getTableHighlightKey,g as hasColumnForField,F as hasTemplateForField,y as isEmptyStringOrWhitespace,s as isIFeatureTableSupportedLayer,a as isIFeatureTableSupportedLayerWithAttachments,l as isIFeatureTableSupportedLayerWithAttachmentsEditing,p as isIFeatureTableSupportedLayerWithEditing,u as isIFeatureTableSupportedLayerWithRelationships,f as isPageIndexValid,o as loadColumnComponents,r as loadEditorColumnComponents,c as loadFieldColumnComponents,i as uniqueColumnNames};