@arcgis/core 4.33.0-next.20250211 → 4.33.0-next.20250212

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 (301) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{3c23e567cfb7372c44ba.js → 0a5689348d544090006d.js} +1 -1
  3. package/assets/esri/core/workers/chunks/0b8bf1966653c326e95a.js +1 -0
  4. package/assets/esri/core/workers/chunks/{baee20c14763bef80b09.js → 1249fd2f83caeaefd8ce.js} +1 -1
  5. package/assets/esri/core/workers/chunks/135fb580d8afd8d60811.js +1 -0
  6. package/assets/esri/core/workers/chunks/{946a9890f3621d1dfbc5.js → 144e534d4ac1aafab60d.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{cee3a38b92a48a58c4d0.js → 152becae48572299b07f.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{f200dca22f9f9bbb8670.js → 17213c3fc63f580e5b73.js} +1 -1
  9. package/assets/esri/core/workers/chunks/24e6476f32ad2014d39d.js +1 -0
  10. package/assets/esri/core/workers/chunks/272662e4e28341419b4f.js +1 -0
  11. package/assets/esri/core/workers/chunks/{5fbdb5fea7d6676fcf19.js → 2c1a85a801cb4d9d737e.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{7f87cf3d6a365d987f69.js → 30bd5b3204e09f516ea2.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{c04091eea7089dc2e864.js → 35bcb0622234b38d85b4.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{92984981afcbb95828cd.js → 37cfd102b6ab5b959f9d.js} +1 -1
  15. package/assets/esri/core/workers/chunks/3835c2884c55e73dc202.js +1 -0
  16. package/assets/esri/core/workers/chunks/{6c9bb00f33649ab59dab.js → 3ba85f1d660b8887f963.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{1d51c064045e9c47bd2e.js → 3bad184751fcb26c003c.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{e468bf4ec7402942ad8c.js → 3ebdd0701e77bb28c75d.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{a559db8654b4f83fd79b.js → 3f6516af411256d90a03.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{c83b26ff96e39266adc2.js → 4300c80fa10c5d9141e8.js} +1 -1
  21. package/assets/esri/core/workers/chunks/4848a3e31632d15dc4ce.js +1 -0
  22. package/assets/esri/core/workers/chunks/{77764ca90bdd13ee2167.js → 486df1e042204b90b0dd.js} +2 -2
  23. package/assets/esri/core/workers/chunks/{77764ca90bdd13ee2167.js.LICENSE.txt → 486df1e042204b90b0dd.js.LICENSE.txt} +1 -1
  24. package/assets/esri/core/workers/chunks/52f61e1f5972a72b6b54.js +1 -0
  25. package/assets/esri/core/workers/chunks/{354531dc2f0dea2ad96f.js → 5693d9ce4472a4c5959f.js} +2 -2
  26. package/assets/esri/core/workers/chunks/{354531dc2f0dea2ad96f.js.LICENSE.txt → 5693d9ce4472a4c5959f.js.LICENSE.txt} +1 -1
  27. package/assets/esri/core/workers/chunks/{e56647e61296643c5f84.js → 5719471414810b6a9aec.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{1accbc048b74857269e4.js → 57924f4909f2cbe5d64c.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{b21b152fa15896577242.js → 5b56b271afb0fadf48b4.js} +2 -2
  30. package/assets/esri/core/workers/chunks/{b21b152fa15896577242.js.LICENSE.txt → 5b56b271afb0fadf48b4.js.LICENSE.txt} +1 -1
  31. package/assets/esri/core/workers/chunks/{b3aeda290470dcb2bdd2.js → 5cf08ee5114273163e09.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{76794184ba8c2e66745e.js → 629f4621ba6ffdcaa2f9.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{32d3657dcae89b740f8b.js → 6518954889df2e781c47.js} +2 -2
  34. package/assets/esri/core/workers/chunks/{32d3657dcae89b740f8b.js.LICENSE.txt → 6518954889df2e781c47.js.LICENSE.txt} +1 -1
  35. package/assets/esri/core/workers/chunks/{220b12654b94c94f8d8a.js → 6fa1f1e431aae1794ce3.js} +1 -1
  36. package/assets/esri/core/workers/chunks/82facb23dfaba2819bc7.js +1 -0
  37. package/assets/esri/core/workers/chunks/8722d05ae9b0aa5162a4.js +1 -0
  38. package/assets/esri/core/workers/chunks/8de4280080296adb1757.js +1 -0
  39. package/assets/esri/core/workers/chunks/{1f443b99653708470f31.js → 96d7f47ea8fbf345101c.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{e6087eda5e3b7e5ad3e1.js → a12afed58acff17708ca.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{95ad76e58452b60fb79f.js → a864ef9b584c83ebf6ae.js} +1 -1
  42. package/assets/esri/core/workers/chunks/{df3d1a8d3f11d52eb30d.js → afdbdc1569b56489c14d.js} +1 -1
  43. package/assets/esri/core/workers/chunks/{308ec51ff4a66f7fcb0d.js → b0952b81d5be214262dd.js} +2 -2
  44. package/assets/esri/core/workers/chunks/{308ec51ff4a66f7fcb0d.js.LICENSE.txt → b0952b81d5be214262dd.js.LICENSE.txt} +1 -1
  45. package/assets/esri/core/workers/chunks/{89e3f7880abd014a62c0.js → b42d26123784997c66e8.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{4040158835f9036967cd.js → b83151b03bbeba466f82.js} +2 -2
  47. package/assets/esri/core/workers/chunks/{4040158835f9036967cd.js.LICENSE.txt → b83151b03bbeba466f82.js.LICENSE.txt} +1 -1
  48. package/assets/esri/core/workers/chunks/bf0bf2b912d668575a9b.js +1 -0
  49. package/assets/esri/core/workers/chunks/{94490937dca566fe2640.js → c061cad8323f0469e7e4.js} +1 -1
  50. package/assets/esri/core/workers/chunks/{fef135e55706d84d1947.js → c4ce3c35b52b7999e877.js} +1 -1
  51. package/assets/esri/core/workers/chunks/cc8eb975a543556f88ae.js +1 -0
  52. package/assets/esri/core/workers/chunks/{6e6422eda398774acbc7.js → d60da671aba70485050e.js} +1 -1
  53. package/assets/esri/core/workers/chunks/{88a34690480d3658bad8.js → d7b260d6187f29e0c136.js} +1 -1
  54. package/assets/esri/core/workers/chunks/de638753a30c9aa41bad.js +1 -0
  55. package/assets/esri/core/workers/chunks/de87009542886fad9a2f.js +2 -0
  56. package/assets/esri/core/workers/chunks/{b765670b47d209d7655a.js.LICENSE.txt → de87009542886fad9a2f.js.LICENSE.txt} +1 -1
  57. package/assets/esri/core/workers/chunks/{bb73cd34fbae935ccbcc.js → dff4a9d656b84fe3e052.js} +1 -1
  58. package/assets/esri/core/workers/chunks/{12199e8abf377ffc27cd.js → e490f70f192780d7ad50.js} +1 -1
  59. package/assets/esri/core/workers/chunks/f088e7db4e7ac85aaff1.js +1 -0
  60. package/assets/esri/core/workers/chunks/{a38cb1fff519bad8abe3.js → f0d28fe4deb7cd894765.js} +1 -1
  61. package/assets/esri/core/workers/chunks/f52ed527b46c316eb369.js +1 -0
  62. package/assets/esri/core/workers/chunks/{140d0c4285c6978103ea.js → f5ce6af342c02a4b0d15.js} +7 -7
  63. package/assets/esri/core/workers/chunks/{1cbeac3301b6943bb28a.js → fc07d47d44c04f123650.js} +1 -1
  64. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  65. package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
  66. package/assets/esri/themes/base/_core.scss +4 -0
  67. package/assets/esri/themes/base/widgets/_BasemapGallery.scss +0 -5
  68. package/assets/esri/themes/base/widgets/_FeatureFormUtilityNetworkAssociationLayers.scss +80 -0
  69. package/assets/esri/themes/base/widgets/_FeatureFormUtilityNetworkAssociationList.scss +14 -0
  70. package/assets/esri/themes/base/widgets/_FeatureFormUtilityNetworkAssociationSettings.scss +41 -0
  71. package/assets/esri/themes/base/widgets/_FilterBuilder.scss +1 -6
  72. package/assets/esri/themes/dark/main.css +1 -1
  73. package/assets/esri/themes/light/main.css +1 -1
  74. package/assets/esri/themes/light/view.css +1 -1
  75. package/chunks/Bufferer-B-V7yYm-.js +5 -0
  76. package/chunks/Distance2DCalculator-Coa0qAFt.js +5 -0
  77. package/chunks/Envelope.js +1 -1
  78. package/chunks/{GeodeticDistanceCalculator-BsWHOuqE.js → GeodeticDistanceCalculator-D4iQ-_NX.js} +1 -1
  79. package/chunks/Geometry.js +1 -1
  80. package/chunks/OperatorClip.js +1 -1
  81. package/chunks/OperatorCut.js +1 -1
  82. package/chunks/OperatorGeneralize.js +1 -1
  83. package/chunks/OperatorGeodesicBuffer.js +1 -1
  84. package/chunks/OperatorGeodeticArea.js +1 -1
  85. package/chunks/OperatorGeodeticDistance.js +1 -1
  86. package/chunks/OperatorMultiPartToSinglePart.js +1 -1
  87. package/chunks/OperatorProximity.js +1 -1
  88. package/chunks/OperatorProximityGeodesic.js +1 -1
  89. package/chunks/OperatorShapePreservingLength.js +1 -1
  90. package/chunks/OperatorShapePreservingProject.js +1 -1
  91. package/chunks/Point2D.js +1 -1
  92. package/chunks/ProjectionTransformation.js +1 -1
  93. package/chunks/QuadraticBezier.js +1 -1
  94. package/chunks/ShadowHighlight.glsl.js +2 -4
  95. package/chunks/SideCalculator2D-BNwb5gvz.js +1 -1
  96. package/chunks/disjointOperator.js +1 -1
  97. package/chunks/distanceOperator.js +1 -1
  98. package/chunks/lyr3DWorker.js +1 -1
  99. package/core/sql.js +1 -1
  100. package/editing/sharedTemplates/SharedTemplate.d.ts +4 -0
  101. package/editing/sharedTemplates/SharedTemplate.js +1 -1
  102. package/editing/sharedTemplates/SharedTemplateMetadata.js +1 -1
  103. package/editing/sharedTemplates/SharedTemplateProvider.js +1 -1
  104. package/editing/sharedTemplates/executor/builders/bufferLineToPolygon.js +1 -1
  105. package/editing/sharedTemplates/executor/builders/bufferPointToPolygon.js +1 -1
  106. package/editing/sharedTemplates/executor/builders/bufferPolygonToPolygon.js +1 -1
  107. package/editing/sharedTemplates/executor/builders/equallySpaced.js +1 -1
  108. package/editing/sharedTemplates/executor/builders/offsetLine.js +1 -1
  109. package/editing/sharedTemplates/executor/builders/offsetPrimaryLine.js +1 -1
  110. package/editing/sharedTemplates/executor/builders/pointAtAllVerticesOfLine.js +1 -1
  111. package/editing/sharedTemplates/executor/builders/pointAtBeginningOfLine.js +1 -1
  112. package/editing/sharedTemplates/executor/builders/pointAtBeginningOfRadial.js +1 -1
  113. package/editing/sharedTemplates/executor/builders/pointAtEndOfLine.js +1 -1
  114. package/editing/sharedTemplates/executor/builders/pointAtInteriorVertices.js +1 -1
  115. package/editing/sharedTemplates/executor/builders/pointAtIntersectionVerticesOfLine.js +1 -1
  116. package/editing/sharedTemplates/executor/builders/pointAtNotBeginningOfLine.js +1 -1
  117. package/editing/sharedTemplates/executor/builders/pointAtNotEndOfLine.js +1 -1
  118. package/editing/sharedTemplates/executor/builders/pointAtPolygonCentroid.js +1 -1
  119. package/editing/sharedTemplates/executor/builders/pointAtPolygonNotStart.js +1 -1
  120. package/editing/sharedTemplates/executor/builders/pointAtPolygonStart.js +1 -1
  121. package/editing/sharedTemplates/executor/builders/pointIdentity.js +1 -1
  122. package/editing/sharedTemplates/executor/builders/pointPrimaryIdentity.js +1 -1
  123. package/editing/sharedTemplates/executor/builders/polygonBoundary.js +1 -1
  124. package/editing/sharedTemplates/executor/builders/polygonBoundaryTwoPoint.js +1 -1
  125. package/editing/sharedTemplates/executor/builders/polygonIdentity.js +1 -1
  126. package/editing/sharedTemplates/executor/builders/polygonPrimaryIdentity.js +1 -1
  127. package/editing/sharedTemplates/executor/builders/polygonVertices.js +1 -1
  128. package/editing/sharedTemplates/executor/builders/support/builderUtils.js +1 -1
  129. package/editing/sharedTemplates/executor/builders/twoPointLines.js +1 -1
  130. package/editing/sharedTemplates/executor/createTemplateExecutor.js +1 -1
  131. package/editing/sharedTemplates/executor/support/createServiceEdit.js +1 -1
  132. package/editing/sharedTemplates/executor/support/executorUtils.js +1 -1
  133. package/editing/sharedTemplates/templateDefinitions/GroupTemplateDefinition.js +1 -1
  134. package/editing/sharedTemplates/templateDefinitions/PresetTemplateDefinition.js +1 -1
  135. package/editing/sharedTemplates/templateDefinitions/parts/builders/builderUtils.js +1 -1
  136. package/editing/templateUtils.js +1 -1
  137. package/geometry/operators/extendOperator.js +1 -1
  138. package/geometry/operators/gx/operatorAlphaShape.js +1 -1
  139. package/geometry/operators/gx/operatorAutoComplete.js +1 -1
  140. package/geometry/operators/gx/operatorBuffer.js +1 -1
  141. package/geometry/operators/gx/operatorGraphicBuffer.js +1 -1
  142. package/geometry/operators/gx/operatorIntegrate.js +1 -1
  143. package/geometry/operators/gx/operatorLabelPoint.js +1 -1
  144. package/geometry/operators/gx/operatorLinesToPolygons.js +1 -1
  145. package/geometry/operators/gx/operatorOffset.js +1 -1
  146. package/geometry/operators/gx/operatorPolygonOverlay.js +1 -1
  147. package/geometry/operators/gx/operatorSimplify.js +1 -1
  148. package/geometry/operators/gx/operatorSymmetricDifference.js +1 -1
  149. package/geometry/operators/gx/operatorUnion.js +1 -1
  150. package/geometry/operators/isNearOperator.js +1 -1
  151. package/geometry/operators/json/disjointOperator.js +1 -1
  152. package/geometry/operators/projectOperator.js +1 -1
  153. package/geometry/operators/reshapeOperator.js +1 -1
  154. package/geometry/operators/shapePreservingProjectOperator.js +1 -1
  155. package/geometry/operators/support/apiConverter.js +1 -1
  156. package/geometry/operators/support/initNoPeFactory.js +1 -1
  157. package/geometry/operators/support/jsonConverter.js +1 -1
  158. package/geometry/support/DoubleArray.js +1 -1
  159. package/geometry/support/UCharArray.js +5 -0
  160. package/geometry/support/UShortArray.js +5 -0
  161. package/interfaces.d.ts +117 -67
  162. package/layers/VectorTileLayer.js +1 -1
  163. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  164. package/layers/mixins/operationalLayers.js +1 -1
  165. package/layers/save/featureLayerUtils.js +1 -1
  166. package/layers/save/utils.js +1 -1
  167. package/layers/support/SubtypeSublayer.js +1 -1
  168. package/layers/support/commonProperties.js +1 -1
  169. package/layers/support/rasterFunctions/stretchUtils.js +1 -1
  170. package/layers/support/wmsUtils.js +1 -1
  171. package/networks/Network.js +1 -1
  172. package/networks/RulesTable.js +1 -1
  173. package/networks/UtilityNetwork.js +1 -1
  174. package/networks/support/typeUtils.js +1 -1
  175. package/package.json +3 -3
  176. package/portal/Portal.js +1 -1
  177. package/renderers/support/RasterSymbolizer.js +1 -1
  178. package/rest/print.js +1 -1
  179. package/support/revision.js +1 -1
  180. package/views/2d/engine/webgl/AttributeStoreView.js +1 -1
  181. package/views/2d/engine/webgl/meshing/Mesh.js +1 -1
  182. package/views/2d/engine/webgl/shaderGraph/techniques/line/GradientStrokeTechnique.js +1 -1
  183. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  184. package/views/2d/layers/LayerView2D.js +1 -1
  185. package/views/2d/layers/MapNotesLayerView2D.js +1 -1
  186. package/views/2d/layers/RouteLayerView2D.js +1 -1
  187. package/views/2d/layers/features/FeatureContainer.js +1 -1
  188. package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
  189. package/views/2d/layers/features/sources/FeatureSource.js +1 -1
  190. package/views/2d/layers/features/sources/strategies/chunks/Overrides.js +1 -1
  191. package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
  192. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  193. package/views/2d/layers/support/HighlightCounter.js +1 -1
  194. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  195. package/views/3d/layers/I3SMeshView3D.js +1 -1
  196. package/views/3d/layers/MediaLayerView3D.js +1 -1
  197. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  198. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  199. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  200. package/views/3d/layers/graphics/Graphics3DLineCalloutSymbolLayer.js +1 -1
  201. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  202. package/views/3d/layers/graphics/GraphicsCorePerformanceInfo.js +1 -1
  203. package/views/3d/layers/i3s/I3SBinaryReader.js +1 -1
  204. package/views/3d/layers/i3s/I3SClientMaterialUtil.js +1 -1
  205. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  206. package/views/3d/layers/i3s/I3SNodeLoader.js +1 -1
  207. package/views/3d/layers/i3s/PointCloudWorkerUtil.js +1 -1
  208. package/views/3d/layers/support/DefinitionExpressionSceneLayerView.js +1 -1
  209. package/views/3d/layers/support/HeatmapFeatureProcessor.js +1 -1
  210. package/views/3d/support/DisplayQualityProfile.js +1 -1
  211. package/views/3d/support/QualitySettings.js +1 -1
  212. package/views/3d/terrain/OverlayManager.js +1 -1
  213. package/views/3d/webgl-engine/effects/haze/Haze.js +1 -1
  214. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  215. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  216. package/views/3d/webgl-engine/lib/TextTextureAtlas.js +1 -1
  217. package/views/3d/webgl-engine/lib/Texture.js +1 -1
  218. package/views/3d/webgl-engine/lib/ViewshedShadowMap.js +1 -1
  219. package/views/3d/webgl-engine/lib/lodRendering/LodResources.js +1 -1
  220. package/views/3d/webgl-engine/lib/textureUtils.js +1 -1
  221. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  222. package/views/SceneView.js +1 -1
  223. package/views/layers/LayerView.js +1 -1
  224. package/views/support/Scheduler.js +1 -1
  225. package/views/webgl/Parameters.js +1 -1
  226. package/views/webgl/RenderingContext.js +1 -1
  227. package/widgets/AreaMeasurement2D/AreaMeasurement2DTool.js +1 -1
  228. package/widgets/AreaMeasurement2D/AreaMeasurement2DViewModel.js +1 -1
  229. package/widgets/AreaMeasurement2D.js +1 -1
  230. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
  231. package/widgets/BatchAttributeForm/ReactiveGraphic.js +1 -1
  232. package/widgets/BatchAttributeForm/inputs/EditableInput.js +1 -1
  233. package/widgets/BatchAttributeForm/inputs/FieldInput.js +1 -1
  234. package/widgets/BatchAttributeForm/inputs/GroupInput.js +1 -1
  235. package/widgets/BatchAttributeForm/inputs/InputBase.js +1 -1
  236. package/widgets/BatchAttributeForm/inputs/support/inputUtils.js +1 -1
  237. package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
  238. package/widgets/BatchAttributeForm.js +1 -1
  239. package/widgets/DistanceMeasurement2D/DistanceMeasurement2DTool.js +1 -1
  240. package/widgets/DistanceMeasurement2D/DistanceMeasurement2DViewModel.js +1 -1
  241. package/widgets/DistanceMeasurement2D.js +1 -1
  242. package/widgets/Editor/AddAssociationWorkflow.js +5 -0
  243. package/widgets/Editor/AddAssociationWorkflowData.js +5 -0
  244. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  245. package/widgets/Editor/CreateFeaturesWorkflowData.js +1 -1
  246. package/widgets/Editor/EditorViewModel.js +1 -1
  247. package/widgets/Editor/UpdateWorkflow.js +1 -1
  248. package/widgets/Editor/UpdateWorkflowData.js +1 -1
  249. package/widgets/Editor/components/PendingFeatureList.js +1 -1
  250. package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
  251. package/widgets/Editor/modelUploadUtils.js +1 -1
  252. package/widgets/Editor/workflowUtils.js +1 -1
  253. package/widgets/Editor.js +1 -1
  254. package/widgets/Feature/FeatureUtilityNetworkAssociationList.js +1 -1
  255. package/widgets/Feature/FeatureUtilityNetworkAssociations.js +1 -1
  256. package/widgets/Feature/FeatureViewModel.js +1 -1
  257. package/widgets/Feature/support/featureUtils.js +1 -1
  258. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js +1 -1
  259. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js +5 -0
  260. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js +5 -0
  261. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  262. package/widgets/FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js +5 -0
  263. package/widgets/FeatureForm/UtilityNetworkAssociationInput.js +1 -1
  264. package/widgets/FeatureForm.js +1 -1
  265. package/widgets/FeatureTable/support/FeatureStore.js +1 -1
  266. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  267. package/widgets/OrientedImageryViewer/constants.js +1 -1
  268. package/widgets/OrientedImageryViewer/galleryUtils.js +5 -0
  269. package/widgets/OrientedImageryViewer/utils.js +1 -1
  270. package/widgets/OrientedImageryViewer.js +1 -1
  271. package/widgets/Sketch/support/sketchUtils.js +1 -1
  272. package/widgets/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.d.ts +2 -2
  273. package/widgets/support/FilterBuilder/FilterBuilderViewModel.js +1 -1
  274. package/widgets/support/FilterBuilder.js +1 -1
  275. package/widgets/support/FilterCondition/FilterConditionViewModel.js +1 -1
  276. package/widgets/support/FilterCondition.js +1 -1
  277. package/widgets/support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js +5 -0
  278. package/widgets/support/UtilityNetworkAssociations/UtilityNetworkAssociationList.js +1 -1
  279. package/widgets/support/UtilityNetworkAssociations/utilityNetworkUtils.js +1 -1
  280. package/assets/esri/core/workers/chunks/08c4b585290efc98ca5d.js +0 -1
  281. package/assets/esri/core/workers/chunks/117e7a12af77c761efb5.js +0 -1
  282. package/assets/esri/core/workers/chunks/324a5547c64a3bae670d.js +0 -1
  283. package/assets/esri/core/workers/chunks/4be5e453fe54f5631659.js +0 -1
  284. package/assets/esri/core/workers/chunks/5be7cf1564e756c24066.js +0 -1
  285. package/assets/esri/core/workers/chunks/6d79ec15d1858839f576.js +0 -1
  286. package/assets/esri/core/workers/chunks/7966c245a073c85f04b1.js +0 -1
  287. package/assets/esri/core/workers/chunks/8bd51b5b392dfacc922f.js +0 -1
  288. package/assets/esri/core/workers/chunks/9c6380af3bc3130658e1.js +0 -1
  289. package/assets/esri/core/workers/chunks/b18620fc15707e4413a1.js +0 -1
  290. package/assets/esri/core/workers/chunks/b765670b47d209d7655a.js +0 -2
  291. package/assets/esri/core/workers/chunks/c249ad935f54d3b49ae3.js +0 -1
  292. package/assets/esri/core/workers/chunks/c7927c2d5414f19defd5.js +0 -1
  293. package/assets/esri/core/workers/chunks/d27a199fd8e2ade69254.js +0 -1
  294. package/assets/esri/core/workers/chunks/f9070edd8e0b2a57af79.js +0 -1
  295. package/assets/esri/core/workers/chunks/faf9063420262ea40fd8.js +0 -1
  296. package/chunks/Bufferer-DjC-SKTJ.js +0 -5
  297. package/chunks/Distance2DCalculator-8-JrFGHH.js +0 -5
  298. package/editing/sharedTemplates/support/sharedTemplateUtils.js +0 -5
  299. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationSettings.js +0 -5
  300. package/widgets/support/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.d.ts +0 -4
  301. package/widgets/support/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.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{_ as e}from"../../../chunks/tslib.es6.js";import"../../../intl.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import{getFeatureFormTitle as i}from"../featureFormUtils.js";import o from"../UtilityNetworkAssociationInput.js";import{AssociationDetails as r}from"./AssociationDetails.js";import{loadCalciteComponents as a}from"../../support/componentsUtils.js";import{globalCss as n}from"../../support/globalCss.js";import{Heading as c}from"../../support/Heading.js";import"../../support/widgetUtils.js";import{messageBundle as l}from"../../support/decorators/messageBundle.js";import{tsx as p,tsxFragment as d}from"../../support/jsxFactory.js";import u from"../../support/UtilityNetworkAssociations/UtilityNetworkAssociationList.js";import m from"../../support/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.js";import{isConnectivity as h,isConnectivityMidspan as y,formatPercentAlong as g}from"../../support/UtilityNetworkAssociations/utilityNetworkUtils.js";import{substitute as F}from"../../../intl/substitute.js";const f="esri-feature-form-utility-network-association-list",_={base:f,header:`${f}__header`,headingContent:`${f}__heading-content`,listContainer:`${f}__list-container`};let L=class extends u{constructor(e,t){super(e,t),this.associationInput=null,this.headingLevel=5,this.messagesFeatureForm=null,this.onSelectLayer=()=>{},this.onSelectFeature=()=>{},this.viewModel=new m}initialize(){this.setUpObserver()}loadDependencies(){return a({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")})}get associatedFeatureCount(){const{associationInput:e}=this;if(!e)return 0;const{associatedFeatureInfos:t,associatedLayer:s}=e,i=s?t.get(s):null;return i?i.length:0}render(){const{associationInput:e}=this;if(!e)return p("div",{class:this.classes(_.base,n.widget)});const{associatedLayer:t}=e,{state:s}=this.viewModel;return p("div",{class:this.classes(_.base,n.widget)},"loading"===s||"querying"===s||"refreshing"===s?this.renderLoading():t?this._renderFeatureList(e,t):this._renderLayerList(e))}_renderLayerList(e){const{associatedFeatureInfos:t}=e;return p("div",{class:_.listContainer},p("calcite-list",{label:this.messagesFeatureForm?.associations.associatedLayers},Array.from(t.keys(),(t=>this._renderLayerItem(e,t)))))}_renderFeatureList(e,t){return p(d,null,this._renderHeader(e,t),p("div",{class:_.listContainer},this.renderFeatureCountWarning(),p("calcite-list",{label:this.messagesFeatureForm?.associations.associatedFeatures},this._renderAssociatedFeatureListPage(e,t),this.renderFeatureObserver())))}_renderLayerTitle(e){return e.title?p(c,{key:"title",level:this.headingLevel},p("div",{class:_.headingContent},p("calcite-icon",{icon:"layer"}),e.title)):null}_renderTotal(e,t){const{messagesFeature:s}=this,{associatedFeatureInfos:i}=e,o=i.get(t),r=F(s?.numberRecords,{number:o?.length??"0"});return p("div",{key:t.id},r)}_renderHeader(e,t){const{messagesFeatureForm:s}=this,{activeAssociationType:i,feature:o}=e;return p("div",{class:_.header,key:"filter"},p(r,{associationType:i?.type,feature:o,messages:s.associations}),this._renderLayerTitle(t),this.renderFilter(),this._renderTotal(e,t))}_renderAssociatedFeatureListPage(e,t){const{filterText:s,endIndex:o}=this,r=e.associatedFeatureInfos.get(t)?.filter((e=>i(e).toLowerCase().includes(s))).slice(0,o).toArray()??[];return[...this._renderTooltips(r),...this._renderAssociatedFeatureList(r)]}_renderItemTooltip(e){const{tooltipReferenceMap:t}=this,s=e.feature.uid.toString();return h(e.association)?p("calcite-tooltip",{key:`tooltip-${s}`,overlayPositioning:"fixed",referenceElement:t.get(s)},this.getConnectivityTooltip(e.association.associationType)):null}_renderAssociatedFeature(e){const t=i(e),s=e.feature.uid.toString();return p("calcite-list-item",{description:e.terminalName??"",key:`associated-feature-type-${s}`,label:t,onCalciteListItemSelect:()=>this._selectAssociation(e)},h(e.association)?this.renderConnectivityIcon(e.association.associationType,s):null,y(e.association)?p("calcite-chip",{label:g(e.association),scale:"s",slot:"content-end"},g(e.association)):null,p("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderTooltips(e){return e.map((e=>this._renderItemTooltip(e)))}_renderAssociatedFeatureList(e){return e.map((e=>this._renderAssociatedFeature(e)))}_renderLayerItem(e,t){const{associatedFeatureInfos:s}=e,i=s.get(t)?.length??0;return p("calcite-list-item",{key:`${t.id}-show-all`,label:t.title??this.messagesCommon.untitled,open:!0,value:t.id,onCalciteListItemSelect:()=>this._showAllAssociations(t)},p("calcite-chip",{label:i.toString(),scale:"s",slot:"content-end"},i),p("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}))}_selectAssociation(e){this.onSelectFeature({feature:e.feature,association:e.association})}_showAllAssociations(e){this.onSelectLayer({layer:e,associationInput:this.associationInput})}};e([t()],L.prototype,"associatedFeatureCount",null),e([t({type:o})],L.prototype,"associationInput",void 0),e([t()],L.prototype,"headingLevel",void 0),e([t(),l("esri/widgets/FeatureForm/t9n/FeatureForm")],L.prototype,"messagesFeatureForm",void 0),e([t({constructOnly:!0})],L.prototype,"onSelectLayer",void 0),e([t({constructOnly:!0})],L.prototype,"onSelectFeature",void 0),e([t({type:m})],L.prototype,"viewModel",void 0),L=e([s("esri.widgets.FeatureForm.FeatureFormUtilityNetworkAssociations.FeatureFormUtilityNetworkAssociationList")],L);const v=L;export{v as default};
5
+ import{_ as t}from"../../../chunks/tslib.es6.js";import"../../../intl.js";import{property as e}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{getFeatureFormTitle as i}from"../featureFormUtils.js";import o from"../UtilityNetworkAssociationInput.js";import{AssociationDetails as r}from"./AssociationDetails.js";import{loadCalciteComponents as a}from"../../support/componentsUtils.js";import{globalCss as n}from"../../support/globalCss.js";import{Heading as c}from"../../support/Heading.js";import"../../support/widgetUtils.js";import{messageBundle as l}from"../../support/decorators/messageBundle.js";import{tsx as d,tsxFragment as p}from"../../support/jsxFactory.js";import u from"../../support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js";import m from"../../support/UtilityNetworkAssociations/UtilityNetworkAssociationList.js";import{isConnectivity as h,isConnectivityMidspan as y,formatPercentAlong as g}from"../../support/UtilityNetworkAssociations/utilityNetworkUtils.js";import{substitute as F}from"../../../intl/substitute.js";const f="esri-feature-form-utility-network-association-list",_={base:f,header:`${f}__header`,headingContent:`${f}__heading-content`,listContainer:`${f}__list-container`};let L=class extends m{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 u}initialize(){this.setUpObserver()}loadDependencies(){return a({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 d("div",{class:this.classes(_.base,n.widget)});const{associatedLayer:e}=t,{state:s}=this.viewModel;return d("div",{class:this.classes(_.base,n.widget)},"loading"===s||"querying"===s?this.renderLoading():e?this._renderFeatureList(t,e):this._renderLayerList(t))}_renderLayerList(t){const{associatedFeatureInfos:e}=t;return d("div",{class:_.listContainer},d("calcite-list",{label:this.messagesFeatureForm?.associations.associatedLayers},Array.from(e.keys(),(e=>this._renderLayerItem(t,e)))),d("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}))}_renderFeatureList(t,e){return d(p,null,this._renderHeader(t,e),d("div",{class:_.listContainer},this.renderFeatureCountWarning(),d("calcite-list",{label:this.messagesFeatureForm?.associations.associatedFeatures},this._renderAssociatedFeatureListPage(t,e),this.renderFeatureObserver())))}_renderLayerTitle(t){return t.title?d(c,{key:"title",level:this.headingLevel},d("div",{class:_.headingContent},d("calcite-icon",{icon:"layer"}),t.title)):null}_renderTotal(t,e){const{messagesFeature:s}=this,{associatedFeatureInfos:i}=t,o=i.get(e),r=F(s?.numberRecords,{number:o?.length??"0"});return d("div",{key:e.id},r)}_renderHeader(t,e){const{messagesFeatureForm:s}=this,{activeAssociationType:i,feature:o}=t;return d("div",{class:_.header,key:"filter"},d(r,{associationType:i?.type,feature:o,messages:s.associations}),this._renderLayerTitle(e),this.renderFilter(),this._renderTotal(t,e))}_renderAssociatedFeatureListPage(t,e){const{filterText:s,endIndex:o}=this,r=t.associatedFeatureInfos.get(e)?.filter((t=>i(t).toLowerCase().includes(s))).slice(0,o).toArray()??[];return[...this._renderTooltips(r),...this._renderAssociatedFeatureList(r)]}_renderItemTooltip(t){const{tooltipReferenceMap:e}=this,s=t.feature.uid.toString();return h(t.association)?d("calcite-tooltip",{key:`tooltip-${s}`,overlayPositioning:"fixed",referenceElement:e.get(s)},this.getConnectivityTooltip(t.association.associationType)):null}_renderAssociatedFeature(t){const e=i(t),s=t.feature.uid.toString();return d("calcite-list-item",{description:t.terminalName??"",key:`associated-feature-type-${s}`,label:e,onCalciteListItemSelect:()=>this._selectAssociation(t)},h(t.association)?this.renderConnectivityIcon(t.association.associationType,s):null,y(t.association)?d("calcite-chip",{label:g(t.association),scale:"s",slot:"content-end"},g(t.association)):null,d("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 d("calcite-list-item",{key:`${e.id}-show-all`,label:e.title??this.messagesCommon.untitled,open:!0,value:e.id,onCalciteListItemSelect:()=>this._showAllAssociations(e)},d("calcite-chip",{label:i.toString(),scale:"s",slot:"content-end"},i),d("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([e()],L.prototype,"associatedFeatureCount",null),t([e({type:o})],L.prototype,"associationInput",void 0),t([e()],L.prototype,"headingLevel",void 0),t([e(),l("esri/widgets/FeatureForm/t9n/FeatureForm")],L.prototype,"messagesFeatureForm",void 0),t([e({constructOnly:!0})],L.prototype,"onSelectLayer",void 0),t([e({constructOnly:!0})],L.prototype,"onSelectFeature",void 0),t([e({constructOnly:!0})],L.prototype,"onAddAssociation",void 0),t([e({type:u})],L.prototype,"viewModel",void 0),L=t([s("esri.widgets.FeatureForm.FeatureFormUtilityNetworkAssociations.FeatureFormUtilityNetworkAssociationList")],L);const v=L;export{v as default};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
+ */
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../intl.js";import{watch as t}from"../../../core/reactiveUtils.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";import s from"../../Widget.js";import o from"../UtilityNetworkAssociationAddAssociationViewModel.js";import{loadCalciteComponents as n}from"../../support/componentsUtils.js";import l from"../../support/FilterBuilder.js";import{globalCss as a}from"../../support/globalCss.js";import{Heading as d}from"../../support/Heading.js";import"../../support/widgetUtils.js";import{messageBundle as c}from"../../support/decorators/messageBundle.js";import{tsx as u}from"../../support/jsxFactory.js";import{getFeatureTitle as p}from"../../support/UtilityNetworkAssociations/utilityNetworkUtils.js";import{substitute as m}from"../../../intl/substitute.js";const h="esri-feature-form-utility-network-association-layers",_={base:h,header:`${h}__header`,headingContent:`${h}__heading-content`,featureObserver:`${h}__feature-observer`,filterContainer:`${h}__filter-container`,filterOptionsContainer:`${h}__filter-options-container`,filterOptionsHeader:`${h}__filter-options-header`,listContainer:`${h}__list-container`,stickySpinnerContainer:`${h}__sticky-loading-container`,loadingContainer:`${h}__loading-container`};let f=class extends s{constructor(e,t){super(e,t),this.headingLevel=5,this.messagesCommon=null,this.messagesFeature=null,this.messagesFeatureForm=null,this.messagesFilterBuilder=null,this.viewModel=new o,this._filterBuilder=new l,this._filterText="",this._observer=new IntersectionObserver((([e])=>{e?.isIntersecting&&this._increaseFeaturePage()}),{root:window.document}),this._observerNode=null}initialize(){this.addHandles([t((()=>[this.viewModel.state,this._observerNode]),(()=>this._onObserverChange())),t((()=>this.selectedLayer),(e=>{this._filterBuilder.layer=e,e||(this.filterOptionsVisible=!1)}))])}loadDependencies(){return n({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader")})}get filterOptionsVisible(){return this.viewModel.filterOptionsVisible}set filterOptionsVisible(e){this.viewModel.filterOptionsVisible=e}get selectedLayer(){return this.viewModel.selectedLayer}set selectedLayer(e){this.viewModel.selectedLayer=e}get selectedFeature(){return this.viewModel.selectedFeature}set selectedFeature(e){this.viewModel.selectedFeature=e}get filterWhereClause(){return this.viewModel.filterWhereClause}set filterWhereClause(e){this.viewModel.filterWhereClause=e,e||this._filterBuilder.reset()}get _filteredFeatureItems(){const{_filterText:e}=this;return this.viewModel.featureItems.map((e=>({label:p(e),graphic:e,layer:e.sourceLayer}))).filter((t=>t.label?.toLowerCase().includes(e)??!1))}render(){const{state:e,filterOptionsVisible:t}=this.viewModel;return u("div",{class:this.classes(_.base,a.widget)},"loading"===e?this._renderLoading():t?this._renderFilterOptions():this.selectedLayer?this._renderFeatures():this._renderLayers())}applyFilterOptions(){const{selectedLayer:e}=this;this.filterOptionsVisible=!1,e&&(this.filterWhereClause=this._filterBuilder.whereClause)}async _onObserverChange(){this._observerNode&&this._observer.unobserve(this._observerNode);const{state:e}=this.viewModel;this._observerNode&&"ready"===e&&this._observer.observe(this._observerNode)}_increaseFeaturePage(){const{featureCount:e,featurePage:t,state:r}=this.viewModel;e||1===t?"ready"===r&&this.viewModel.featurePage++:this.viewModel.featurePage=1}_renderStickyLoading(){return"querying"===this.viewModel.state?u("div",{class:_.stickySpinnerContainer,key:"sticky-loader"},this._renderLoadingIcon()):null}_renderLoading(){return u("div",{class:_.loadingContainer,key:"loading-container"},this._renderLoadingIcon())}_renderLoadingIcon(){return u("calcite-loader",{inline:!0,label:this.messagesCommon.loading})}_renderFilterOptions(){return u("div",{class:_.filterOptionsContainer},u("div",{class:_.filterOptionsHeader},u("span",null,this.messagesFilterBuilder.widgetLabel),u("calcite-button",{appearance:"transparent",onclick:()=>this._filterBuilder.reset()},this.messagesCommon.clear)),this._filterBuilder.render())}_renderLayers(){const e=this.messagesFeatureForm.associations,t=e.availableLayers,r=e.filterLayers;return u("div",null,this._renderHeader({heading:t,placeholder:r,renderFilterOptions:!1,renderTotal:!1}),u("div",{class:_.listContainer},u("calcite-list",{label:e.associatedFeatures},this._renderLayerItems(),this._renderStickyLoading())))}_renderLayerItems(){const{_filterText:e,viewModel:t,messagesCommon:r}=this,{layerItems:i}=t;return i.map((e=>({label:e.title??r.untitled,layer:e}))).filter((t=>t.label?.toLowerCase().includes(e)??!1)).toArray().map((e=>this._renderLayerItem(e)))}_renderLayerItem(e){const{label:t,layer:r}=e;return u("calcite-list-item",{key:`layer-item-${r.id}`,label:t,onCalciteListItemSelect:()=>{this.selectedLayer=r}},u("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderFeatures(){const{selectedLayer:e}=this;if(!e)return;const t=this.messagesFeatureForm.associations,r=e.title??this.messagesCommon.untitled,i=t.filterFeatures;return u("div",null,this._renderHeader({heading:r,placeholder:i,renderFilterOptions:!0,renderTotal:!0}),u("div",{class:_.listContainer},u("calcite-list",{label:t.associatedFeatures},this._renderFeatureItems(),this._renderStickyLoading(),this._renderFeatureObserver())))}_renderFeatureItems(){return this._filteredFeatureItems.toArray().map((e=>this._renderFeatureItem(e)))}_renderFeatureItem(e){const{label:t,graphic:r}=e;return u("calcite-list-item",{key:`feature-item-${r.uid}`,label:t,onCalciteListItemSelect:()=>{this.selectedFeature=r}},u("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s",slot:"content-end"}))}_onObserverCreate(e){this._observerNode=e}_renderFeatureObserver(){return u("div",{afterCreate:this._onObserverCreate,bind:this,class:_.featureObserver,key:"feature-observer"})}_renderHeader(e){return u("div",{class:_.header,key:"filter"},this._renderHeading(e.heading),this._renderFilter(e.placeholder,e.renderFilterOptions),e.renderTotal?this._renderTotal():null)}_renderHeading(e){return e?u(d,{key:"title",level:this.headingLevel},u("div",{class:_.headingContent},u("calcite-icon",{icon:"layer"}),e)):null}_renderFilter(e,t){return u("div",{class:_.filterContainer,key:"filter"},u("calcite-input",{icon:"search",placeholder:e,type:"search",onCalciteInputInput:e=>{this._filterText=e.currentTarget.value.trim().toLowerCase()}},t?this._renderFilterOptionsAction():null))}_renderFilterOptionsAction(){const e=this.messagesFeatureForm.associations.filterOptions;return u("calcite-action",{appearance:"transparent",icon:"sliders",indicator:!!this._filterBuilder.whereClause,onclick:()=>{this.viewModel.filterOptionsVisible=!this.viewModel.filterOptionsVisible},scale:"s",slot:"action",text:e,title:e})}_renderTotal(){const{messagesFeature:e,viewModel:t}=this,r=m(e.numberRecords,{number:t.featureCount});return u("div",{key:"total"},r)}};e([r()],f.prototype,"filterOptionsVisible",null),e([r()],f.prototype,"headingLevel",void 0),e([r(),c("esri/t9n/common")],f.prototype,"messagesCommon",void 0),e([r(),c("esri/widgets/Feature/t9n/Feature")],f.prototype,"messagesFeature",void 0),e([r(),c("esri/widgets/FeatureForm/t9n/FeatureForm")],f.prototype,"messagesFeatureForm",void 0),e([r(),c("esri/widgets/support/FilterBuilder/t9n/FilterBuilder")],f.prototype,"messagesFilterBuilder",void 0),e([r()],f.prototype,"selectedLayer",null),e([r({type:o})],f.prototype,"viewModel",void 0),e([r()],f.prototype,"selectedFeature",null),e([r()],f.prototype,"filterWhereClause",null),e([r()],f.prototype,"_filterBuilder",void 0),e([r()],f.prototype,"_filterText",void 0),e([r()],f.prototype,"_observer",void 0),e([r()],f.prototype,"_filteredFeatureItems",null),e([r()],f.prototype,"_observerNode",void 0),f=e([i("esri.widgets.FeatureForm.FeatureFormUtilityNetworkAssociations.UtilityNetworkAssociationItemList")],f);const v=f;export{v as default};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
+ */
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import i from"../../Widget.js";import{loadCalciteComponents as n}from"../../support/componentsUtils.js";import{globalCss as s}from"../../support/globalCss.js";import"../../support/widgetUtils.js";import{messageBundle as r}from"../../support/decorators/messageBundle.js";import{tsx as c}from"../../support/jsxFactory.js";import{isFromElement as a,getFeatureTitle as l,getAssociationTitle as m}from"../../support/UtilityNetworkAssociations/utilityNetworkUtils.js";const d="esri-feature-form-utility-network-association-settings",u={base:d,infoContainer:`${d}__info-container`};let p=class extends i{constructor(e,t){super(e,t),this.association=null,this.editedAssociation=null,this.headingLevel=5,this.messagesFeature=null,this.messagesCommon=null,this.messagesFeatureForm=null,this.readOnly=!1,this.sourceFeature=null,this.targetFeature=null,this.utilityNetwork=null}loadDependencies(){return n({block:()=>import("@esri/calcite-components/dist/components/calcite-block"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch")})}get associationType(){return this.association.associationType}set associationType(e){this.association.associationType=e,"junction-edge-to-connectivity"!==e&&"junction-edge-from-connectivity"!==e||(this.association.percentAlong=void 0)}render(){return c("div",{class:this.classes(u.base,s.widget)},this._renderFromAssociationEndpoint(),this._renderToAssociationEndpoint(),this._renderAdditionalContent())}_renderFromAssociationEndpoint(){const{associationType:e,association:t,sourceFeature:o,targetFeature:i,messagesFeatureForm:n}=this,s=a(o,t)?o:i,r=l(s),c=m(t,"from",n.associations);switch(e){case"connectivity":case"junction-junction-connectivity":return this._renderAssociationEndpoint(r,c,this._renderConnectivityContent(s,t.fromNetworkElement))}return this._renderAssociationEndpoint(r,c)}_renderToAssociationEndpoint(){const{associationType:e,association:t,sourceFeature:o,targetFeature:i,messagesFeatureForm:n}=this,s=a(o,t)?i:o,r=l(s),c=m(t,"to",n.associations);switch(e){case"connectivity":case"junction-junction-connectivity":return this._renderAssociationEndpoint(r,c,this._renderConnectivityContent(s,t.toNetworkElement));case"containment":return this._renderAssociationEndpoint(r,c,this._renderContainmentContent())}return this._renderAssociationEndpoint(r,c)}_renderAssociationEndpoint(e,t,o){return c("calcite-block",{description:t,heading:e,open:!0},o)}_renderContainmentContent(){const{messagesFeatureForm:e,association:t}=this,o=t.isContentVisible??!1;return c("calcite-label",{layout:"inline"},e.associations.visible,c("calcite-switch",{checked:o,onCalciteSwitchChange:({currentTarget:e})=>{t.isContentVisible=e.checked}}))}_renderConnectivityContent(e,t){const{messagesFeatureForm:o,utilityNetwork:i}=this,n=i.getTerminalConfiguration(e),s=n?.terminals.map((e=>this._renderComboboxListItemNumber(e.id,t.terminalId,e.name)))||[];return c("calcite-label",null,o.associations.terminal,c("calcite-combobox",{allowCustomValues:!1,clearDisabled:!0,label:o.associations.terminalComboboxLabel,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxChange:({currentTarget:e})=>{t.terminalId=parseInt(e.value,10)}},...s))}_renderAdditionalContent(){const{associationType:e}=this;switch(e){case"connectivity":case"junction-junction-connectivity":case"attachment":case"containment":return}const t="junction-edge-midspan-connectivity"===e?e:"junction-edge-from-connectivity",{messagesFeatureForm:o}=this,i=[this._renderComboboxListItemString("junction-edge-midspan-connectivity",t,o.associations.midspanEdge),this._renderComboboxListItemString("junction-edge-from-connectivity",t,o.associations.endpointEdge)];return c("div",{class:u.infoContainer},c("calcite-label",{key:"additional-content"},o.associations.connectTo,c("calcite-combobox",{allowCustomValues:!1,clearDisabled:!0,label:o.associations.edgeConnectionComboboxLabel,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxChange:({currentTarget:e})=>{this.associationType=e.value}},...i)),"junction-edge-midspan-connectivity"===t?this._renderMidspanEdgeContent():this._renderEndpointEdgeContent())}_renderMidspanEdgeContent(){const{association:e,messagesFeatureForm:t}=this;return c("calcite-label",{key:"midspan-edge"},t.associations.midspanLocation,c("calcite-input-number",{max:100,min:0,numberButtonType:"vertical",suffixText:"%",value:`${e.percentAlong}`,onCalciteInputNumberInput:({currentTarget:t})=>{e.percentAlong=.01*parseFloat(t.value)}}))}_renderEndpointEdgeContent(){const{associationType:e,messagesFeatureForm:t}=this,o="junction-edge-to-connectivity"===e;return c("calcite-label",{key:"endpoint-edge"},t.associations.edgeSide,c("calcite-label",{layout:"inline"},t.associations.fromSide,c("calcite-switch",{checked:o,onCalciteSwitchChange:({currentTarget:e})=>{const t=e.checked?"junction-edge-to-connectivity":"junction-edge-from-connectivity";this.associationType=t}}),t.associations.toSide))}_renderComboboxListItemNumber(e,t,o){return c("calcite-combobox-item",{heading:o,key:`#${e}`,selected:t===e,value:`${e}`})}_renderComboboxListItemString(e,t,o){return c("calcite-combobox-item",{heading:o,key:`#${e}`,selected:t===e,value:`${e}`})}};e([t()],p.prototype,"association",void 0),e([t()],p.prototype,"associationType",null),e([t()],p.prototype,"editedAssociation",void 0),e([t()],p.prototype,"headingLevel",void 0),e([t(),r("esri/widgets/Feature/t9n/Feature")],p.prototype,"messagesFeature",void 0),e([t(),r("esri/t9n/common")],p.prototype,"messagesCommon",void 0),e([t(),r("esri/widgets/FeatureForm/t9n/FeatureForm")],p.prototype,"messagesFeatureForm",void 0),e([t()],p.prototype,"readOnly",void 0),e([t()],p.prototype,"sourceFeature",void 0),e([t()],p.prototype,"targetFeature",void 0),e([t()],p.prototype,"utilityNetwork",void 0),p=e([o("esri.widgets.FeatureForm.FeatureFormUtilityNetworkAssociations.UtilityNetworkAssociationSettings")],p);const g=p;export{g as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.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{watch as a,whenOnce as l,on as u}from"../../core/reactiveUtils.js";import{templateHasKey as p}from"../../core/string.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as d}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as h}from"../../core/support/UpdatingHandles.js";import f from"../../form/FormTemplate.js";import{isUtilityNetworkAssociationsElement as m,isGroupElement as g,isFieldElement as y,isRelationshipElement as _,isTextElement as v}from"../../form/support/formUtils.js";import I from"../../layers/support/ContingentValue.js";import{isEditableLayer as x}from"../../layers/support/editableLayers.js";import E from"../../layers/support/LayerContingentValuesCache.js";import{utc as C,unknown as F,system as b}from"../../time/timeZoneUtils.js";import{flattenAssociationInputs as V,flattenFieldInputs as w,isGroupInput as A,flattenRelationshipInputs as j,parseFormTemplateString as T,isRelationshipInput as M,isFieldInput as N,isTextElementInput as k,getNormalizedFeatureTypeInfo as L,valueIsValidContingentValue as R}from"./featureFormUtils.js";import S from"./FieldInput.js";import{FormExpressionsManager as H}from"./FormExpressionsManager.js";import U from"./GroupInput.js";import Z from"./RelationshipInput.js";import P from"./TextElementInput.js";import O from"./UtilityNetworkAssociationInput.js";import{createFormExpressionArcadeExecutor as W}from"../support/forms/expressions/FormExpressionArcadeExecutor.js";const G=new t({attributes:{}}),$={field:["editableExpression","requiredExpression","valueExpression","visibilityExpression"],group:["visibilityExpression"],relationship:["editableExpression","visibilityExpression"],text:["visibilityExpression"],utilityNetworkAssociations:["editableExpression","visibilityExpression"]},D="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",z="#JSAPI_CONTINGENT_VALUE_ANY_HASH",J="#JSAPI_CONTINGENT_VALUE_NULL_HASH",B="esri.widgets.FeatureForm.FeatureFormViewModel",K=()=>i.getLogger(B);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=G.clone(),this._initialFeature=G.clone(),this._timeZone=null,this._updatingHandles=new h,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}initialize(){const e=a((()=>[this.layer,!!this.layer?.loaded,this.formTemplate,this.feature,this.timeZone,this.arcadeEditType]),(async([e,t])=>{null!=e&&(t?this._updatingHandles.addPromise(this._updateInputs()):e.load().catch((()=>{})))}),{equals:([e,t,n,s,i,o],[r,a,l,u,p,c])=>e===r&&t===a&&n===l&&s===u&&i===p&&o===c,initial:!0}),t=a((()=>this._arcadeContextInfo),(e=>{null!=this._expressionsManager&&(this._expressionsManager.arcadeContextInfo=e,this._updatingHandles.addPromise(this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated()))))})),n=a((()=>this.layer),(e=>{const t="subtype-sublayer"===e?.type?e.parent:"feature"===e?.type?e:null;t&&this.addResolvingPromise(E.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))}get _arcadeContextInfo(){const{_initialFeature:e,arcadeEditType:t,layer:n,map:s,spatialReference:i,timeZone:o}=this;return{layer:x(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.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 V(this.inputs)}get allFieldInputs(){return w(this.inputs)}get allGroupInputs(){return this.inputs.filter(A)}get allRelationshipInputs(){return j(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():G.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?T({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?T({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)),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 C;const t=e&&"preferredTimeZone"in e&&e.preferredTimeZone;return this._timeZone===F?t||C:this._timeZone||b}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),null!=this._expressionsManager&&this._updatingHandles.addPromise(this._expressionsManager.evaluateInvalidated([i.name]).finally((()=>this._afterExpressionsEvaluated())))))}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{_expressionsManager:e,feature:t,_featureClone:n}=this;t&&(n.geometry=t.geometry,null!=e&&this._updatingHandles.addPromise(e.evaluateInvalidatedByGeometry().finally((()=>this._afterExpressionsEvaluated()))))}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 _updateInputs(){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()}async _updateInputsUsingFormElements(e,t,n){const s=new Map;for(const r of e)if(A(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(Y),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):this._makeInputFromElement(a,s,i);if(n){if(r.push(n),await l((()=>!n.updating)),this._assignExpressionExecutors(n,a,o),e)if(t.delete(a),A(n)){const{feature:e,timeZone:t}=s;n.set({feature:e,timeZone:t})}else if(M(n)){const e=this.relationshipId===a.relationshipId;n.set(s),n.set({map:this.map,showAllEnabled:e})}else m(n)?(n.set(s),n.set({map:this.map})):n.set(s);if(g(a)){const e=a.elements.filter((e=>Y(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 K().warn(this.declaredClass,"No attribute fields found."),[];const s=new Map;for(const o of e)if(A(o)){for(const e of o.inputs)e.destroy();o.inputs.length=0,o.destroy()}else M(o)?o.destroy():N(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 S({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 g(e)?Q(e,t):y(e)?this._makeFieldInputFromElement(e,t,s):_(e)?this._makeRelationshipInputFromElement(e,t,s):m(e)?this._makeUtilityNetworkAssociationInputFromElement(e,t,s):v(e)?X(e,t):m(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 S({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 Z({element:e,feature:i,group:n,layer:o,map:s,timeZone:r});return a.addHandles(u((()=>a.relatedLayer),"edits",(()=>this._expressionsManager?.evaluateAsyncExpressions()))),a}_makeUtilityNetworkAssociationInputFromElement(e,t,n=null){const{map:s}=this,{feature:i,layer:o,timeZone:r}=t;return new O({element:e,feature:i,group:n,layer:o,map:s,timeZone:r})}_assignExpressionExecutors(e,t,n){const s=$[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 k(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=W(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),await this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated()))}_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}=L(o);if((e.isSubtypeField||t===a)&&n!==r){if("subtype-sublayer"===o.type){const e=o.parent?.findSublayerForFeature(s);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&&p(n,t)&&this.notifyChange("formTitle"),e&&p(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}=L(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(z)&&o?.push(...this._findMatchingContingenciesContainingAny(t,r.get(z),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(z)&&n.push(...this._findMatchingContingenciesContainingAny(l,r.get(z),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:d,rightIsRange:h}=this._compareObjectTypes(n.objectType,o.objectType);if(l||c)continue;if(r&&p||a&&u){s.values[i]=new I({objectType:"null"});continue}if(r&&h||a&&d)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 I({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===z)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)||R(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[D,!1];const s=[];let i=!1;for(const o of t){const t=e.values[o];if("any"===t.objectType){if(n)return[z,!0];i=!0,s.push(`${o}:.*`)}else"null"===t.objectType?s.push(`${o}:${J}`):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 Y(e){return"field"===e.type||"group"===e.type||"relationship"===e.type||"text"===e.type||"utilityNetworkAssociations"===e.type||(K().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 Q(e,t){const{feature:n,layer:s}=t;return new U({element:e,inputs:[],feature:n,layer:s})}function X(e,t,n=null){const{feature:s,layer:i,timeZone:o}=t;return new P({element:e,feature:s,group:n,layer:i,timeZone:o})}e([c()],q.prototype,"_expressionInfosLookup",null),e([c()],q.prototype,"_featureClone",void 0),e([c()],q.prototype,"_timeZone",void 0),e([c()],q.prototype,"activeAssociation",void 0),e([c()],q.prototype,"activeAssociationInput",null),e([c()],q.prototype,"activeRelationshipInput",null),e([c()],q.prototype,"_arcadeContextInfo",null),e([c()],q.prototype,"associationId",null),e([c()],q.prototype,"associatedLayer",null),e([c()],q.prototype,"allAssociationInputs",null),e([c()],q.prototype,"allFieldInputs",null),e([c()],q.prototype,"allGroupInputs",null),e([c()],q.prototype,"allRelationshipInputs",null),e([c()],q.prototype,"_layerFieldsByName",null),e([c()],q.prototype,"arcadeEditType",void 0),e([c()],q.prototype,"contingencyConstraintViolations",void 0),e([c()],q.prototype,"disabled",void 0),e([c()],q.prototype,"feature",null),e([c()],q.prototype,"fieldsWithContingentValues",null),e([c({type:f})],q.prototype,"formTemplate",null),e([c()],q.prototype,"formDescription",null),e([c()],q.prototype,"formTitle",null),e([c()],q.prototype,"formHeaderVisible",null),e([c()],q.prototype,"highlightHelper",void 0),e([c()],q.prototype,"inputs",void 0),e([c()],q.prototype,"joinedContingentValues",null),e([c()],q.prototype,"layer",null),e([c()],q.prototype,"map",void 0),e([c()],q.prototype,"callbacks",void 0),e([c()],q.prototype,"relationshipId",null),e([c()],q.prototype,"spatialReference",null),e([c()],q.prototype,"state",null),e([c()],q.prototype,"strict",void 0),e([c()],q.prototype,"submittable",null),e([c()],q.prototype,"timeZone",null),e([c()],q.prototype,"updating",null),e([c()],q.prototype,"valid",null),e([c()],q.prototype,"pendingSubtypeChoice",void 0),e([c()],q.prototype,"getValues",null),e([c()],q.prototype,"submit",null),e([c()],q.prototype,"test",null),q=e([d(B)],q);const ee=q;export{ee 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 d}from"../../core/string.js";import{property as h}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 g from"../../form/FormTemplate.js";import{isUtilityNetworkAssociationsElement as y,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/timeZoneUtils.js";import{flattenAssociationInputs as A,flattenFieldInputs as j,isGroupInput as T,flattenRelationshipInputs as M,parseFormTemplateString as N,isRelationshipInput as k,isFieldInput as L,isTextElementInput as R,getNormalizedFeatureTypeInfo as S,valueIsValidContingentValue as U}from"./featureFormUtils.js";import H from"./FieldInput.js";import{FormExpressionsManager as Z}from"./FormExpressionsManager.js";import P from"./GroupInput.js";import O from"./RelationshipInput.js";import W from"./TextElementInput.js";import G from"./UtilityNetworkAssociationInput.js";import{createFormExpressionArcadeExecutor as $}from"../support/forms/expressions/FormExpressionArcadeExecutor.js";const D=new t({attributes:{}}),z={field:["editableExpression","requiredExpression","valueExpression","visibilityExpression"],group:["visibilityExpression"],relationship:["editableExpression","visibilityExpression"],text:["visibilityExpression"],utilityNetworkAssociations:["editableExpression","visibilityExpression"]},J="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",B="#JSAPI_CONTINGENT_VALUE_ANY_HASH",K="#JSAPI_CONTINGENT_VALUE_NULL_HASH",Y="esri.widgets.FeatureForm.FeatureFormViewModel",q=()=>i.getLogger(Y);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=D.clone(),this._initialFeature=D.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._updatingHandles.addPromise(this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated()))))})),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))}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():D.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?N({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?N({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)),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),null!=this._expressionsManager&&this._updatingHandles.addPromise(this._expressionsManager.evaluateInvalidated([i.name]).finally((()=>this._afterExpressionsEvaluated())))))}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{_expressionsManager:e,feature:t,_featureClone:n}=this;t&&(n.geometry=t.geometry,null!=e&&this._updatingHandles.addPromise(e.evaluateInvalidatedByGeometry().finally((()=>this._afterExpressionsEvaluated()))))}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 _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(X),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):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(k(n)){const e=this.relationshipId===a.relationshipId;n.set(s),n.set({map:this.map,showAllEnabled:e})}else y(n)?(n.set(s),n.set({map:this.map})):n.set(s);if(_(a)){const e=a.elements.filter((e=>X(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 q().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 k(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 H({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)?ee(e,t):v(e)?this._makeFieldInputFromElement(e,t,s):I(e)?this._makeRelationshipInputFromElement(e,t,s):y(e)?this._makeUtilityNetworkAssociationInputFromElement(e,t,s):x(e)?te(e,t):y(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 H({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._expressionsManager?.evaluateAsyncExpressions()))),a}_makeUtilityNetworkAssociationInputFromElement(e,t,n=null){const{map:s}=this,{feature:i,layer:o,timeZone:r}=t;return new G({element:e,feature:i,group:n,layer:o,map:s,timeZone:r})}_assignExpressionExecutors(e,t,n){const s=z[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=$(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 Z({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),await this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated()))}_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);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&&d(n,t)&&this.notifyChange("formTitle"),e&&d(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(B)&&o?.push(...this._findMatchingContingenciesContainingAny(t,r.get(B),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(B)&&n.push(...this._findMatchingContingenciesContainingAny(l,r.get(B),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:d,rightIsRange:h}=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&&h||a&&d)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===B)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[J,!1];const s=[];let i=!1;for(const o of t){const t=e.values[o];if("any"===t.objectType){if(n)return[B,!0];i=!0,s.push(`${o}:.*`)}else"null"===t.objectType?s.push(`${o}:${K}`):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 X(e){return"field"===e.type||"group"===e.type||"relationship"===e.type||"text"===e.type||"utilityNetworkAssociations"===e.type||(q().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 ee(e,t){const{feature:n,layer:s}=t;return new P({element:e,inputs:[],feature:n,layer:s})}function te(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([h()],Q.prototype,"_expressionInfosLookup",null),e([h()],Q.prototype,"_featureClone",void 0),e([h()],Q.prototype,"_timeZone",void 0),e([h()],Q.prototype,"activeAssociation",void 0),e([h()],Q.prototype,"activeAssociationInput",null),e([h()],Q.prototype,"activeRelationshipInput",null),e([h()],Q.prototype,"_arcadeContextInfo",null),e([h()],Q.prototype,"associationId",null),e([h()],Q.prototype,"associatedLayer",null),e([h()],Q.prototype,"allAssociationInputs",null),e([h()],Q.prototype,"allFieldInputs",null),e([h()],Q.prototype,"allGroupInputs",null),e([h()],Q.prototype,"allRelationshipInputs",null),e([h()],Q.prototype,"_layerFieldsByName",null),e([h()],Q.prototype,"arcadeEditType",void 0),e([h()],Q.prototype,"contingencyConstraintViolations",void 0),e([h()],Q.prototype,"disabled",void 0),e([h()],Q.prototype,"feature",null),e([h()],Q.prototype,"fieldsWithContingentValues",null),e([h({type:g})],Q.prototype,"formTemplate",null),e([h()],Q.prototype,"formDescription",null),e([h()],Q.prototype,"formTitle",null),e([h()],Q.prototype,"formHeaderVisible",null),e([h()],Q.prototype,"highlightHelper",void 0),e([h()],Q.prototype,"inputs",void 0),e([h()],Q.prototype,"joinedContingentValues",null),e([h()],Q.prototype,"layer",null),e([h()],Q.prototype,"map",void 0),e([h()],Q.prototype,"callbacks",void 0),e([h()],Q.prototype,"relationshipId",null),e([h()],Q.prototype,"spatialReference",null),e([h()],Q.prototype,"state",null),e([h()],Q.prototype,"strict",void 0),e([h()],Q.prototype,"submittable",null),e([h()],Q.prototype,"timeZone",null),e([h()],Q.prototype,"updating",null),e([h()],Q.prototype,"valid",null),e([h()],Q.prototype,"pendingSubtypeChoice",void 0),e([h()],Q.prototype,"getValues",null),e([h()],Q.prototype,"submit",null),e([h()],Q.prototype,"test",null),Q=e([f(Y)],Q);const ne=Q;export{ne as default};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
+ */
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import r from"../../core/Accessor.js";import{createTask as o}from"../../core/asyncUtils.js";import s 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 u,initial as l}from"../../core/reactiveUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as h}from"../../core/support/UpdatingHandles.js";import{isLayerFromCatalog as p}from"../../layers/catalog/catalogUtils.js";import{isSubtypeSublayer as d,isKnowledgeGraphLayer as g,isSubtypeGroupLayer as _}from"../../layers/support/layerUtils.js";import{isAssociatedFeatureSupportedLayer as m}from"../Feature/support/featureUtils.js";import{isMapImageLayer as f}from"../FeatureTable/support/tableUtils.js";import{createAssociation as C}from"../support/UtilityNetworkAssociations/utilityNetworkUtils.js";const b=100;let A=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._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 h,this._validateAssociationTask=null,this._updatingHandlesAssociation=new h,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,b),this._queryFeatureCountDebounced=n(this._queryFeatureCountController,b),this._queryPageDebounced=n(this._queryPageController,b)}initialize(){this.addHandles([u((()=>[this.graphic,this.layer,this.map,this.utilityNetwork,this.globalId,this.associationType]),(()=>this._syncLayerItems()),l),u((()=>[this.selectedLayer,this.filterWhereClause]),(()=>{this.selectedLayer&&this._setUpFeatures()})),u((()=>this.selectedFeature),(()=>{this._setUpAssociation()})),u((()=>[this.featureCount,this.featuresPerPage,this.map,this.graphic,this.associationType]),(()=>this._queryDebounced())),u((()=>this.featurePage),(()=>this._queryPageDebounced()))])}destroy(){this._setUpItemsTask=a(this._setUpItemsTask),this._updatingHandlesSetUp.destroy(),this._validateAssociationTask=a(this._validateAssociationTask),this._updatingHandlesAssociation.destroy(),this._cancelQuery(),this._cancelQueryFeatureCount(),this._cancelQueryPage()}get mapLayers(){const{map:e}=this;if(!e)return null;const t=new Set,r=e=>{!m(e)||_(e)||t.has(e)||t.add(e)},o=e=>{p(e)||"catalog-footprint"===e.type||(g(e)?(e.layers?.forEach(r),e.tables?.forEach(r)):f(e)?(e.sublayers?.forEach(r),e.subtables?.forEach(r)):_(e)?e.sublayers?.forEach(r):r(e))};return e.allLayers.forEach(o),e.allTables.forEach(o),new s([...t])}get state(){const{_queryAbortController:e,_queryPageAbortController:t,canQuery:r}=this;return this.canLoad&&this._updatingHandlesSetUp.updating?"loading":this._updatingHandlesAssociation.updating?"validating":e||t?"querying":r?"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 s}get featureItems(){return this._get("featureItems")||new s}set featurePage(e){const{featuresPerPage:t,featureCount:r}=this,o=1,s=Math.ceil(r/t)||1;this._set("featurePage",Math.min(Math.max(e,o),s))}get featurePage(){return this._get("featurePage")}get canLoad(){const{map:e,utilityNetwork:t,graphic:r,associationType:o}=this;return!!(e&&t&&r&&o)}get canQuery(){const{utilityNetwork:e,graphic:t,associationType:r,selectedLayer:o}=this;return!!(e&&t&&r&&o)}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 t?`(${t}) AND ${e}`:e}async _queryFeatureCount(e){const{selectedLayer:t,_queryFeatureCountAbortController:r}=this;if(this._set("featureCount",0),!t)return;await t.load();const o=t.createQuery();o.returnGeometry=!1,o.where=o.where?`${o.where} AND ${e}`:e;const s=await t.queryFeatureCount(o,{signal:r?.signal});s>0&&this._set("featureCount",s)}async _query(){const{canQuery:e,queryWhereClause:t,_queryAbortController:r,featureItems:o}=this;e&&(this.featurePage=1,o.destroyAll(),this.featureCount&&!this.destroyed&&o.addMany(await this._queryAssociatedFeatures(t,{signal:r?.signal})))}async _queryPage(){const{canQuery:e,queryWhereClause:t,featurePage:r,_queryPageAbortController:o,featureCount:s,featureItems:a}=this;e&&(r<2||!s||a.addMany(await this._queryAssociatedFeatures(t,{signal:o?.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,canLoad:s}=this,i=o((async o=>{if(this.selectedLayer=null,r.destroyAll(),!s)return;const a=this.mapLayers?.toArray();if(!a)return;if(o.aborted)return;const i=await this.getRulesTable(),n=this._convertTypeToDirection(t.type),u=i?.getLayersCanAssociateWith(e,a,n);o.aborted||r.addMany(u||[])}));this._updatingHandlesSetUp.addPromise(i.promise),this._setUpItemsTask=i}async _setUpFeatures(){a(this._setUpItemsTask);const{graphic:e,associationType:t,selectedLayer:r,canQuery:s}=this;if(!s)return;const i=o((async o=>{const s=await this.getRulesTable(),a=this._convertTypeToDirection(t.type),i=s?.getFeaturesCanAssociateWithClause(e,r,a);this._whereClause=i,o.aborted||this._queryFeatureCountDebounced(this.queryWhereClause)}));this._updatingHandlesSetUp.addPromise(i.promise),this._setUpItemsTask=i}_determineFromAndTo(e,t,r){return"from"===r?{fromFeature:e,toFeature:t}:{fromFeature:t,toFeature:e}}_determineJunctionEdgeConnectivity(e,t){const{utilityNetwork:r}=this,o=d(e.sourceLayer)?e.sourceLayer.parent:e.sourceLayer,s=d(t.sourceLayer)?t.sourceLayer.parent:t.sourceLayer;if(!(r&&o&&"layerId"in o&&s&&"layerId"in s))return{fromFeature:e,toFeature:t,type:"junction-junction-connectivity"};const a=r.getSourceIdByLayerId(o.layerId),i=r.getSourceIdByLayerId(s.layerId);if(!a||!i)return{fromFeature:e,toFeature:t,type:"junction-junction-connectivity"};const n="junction"===r.getSourceTypeById(a),u="junction"===r.getSourceTypeById(i);return n&&u?{fromFeature:e,toFeature:t,type:"junction-junction-connectivity"}:u?{fromFeature:t,toFeature:e,type:"junction-edge-midspan-connectivity"}:{fromFeature:e,toFeature:t,type:"junction-edge-midspan-connectivity"}}_setUpAssociation(){const{utilityNetwork:e,graphic:t,selectedFeature:r,associationType:o}=this;if(!(e&&t&&r&&o))return void(this.association=null);const s=this._convertTypeToDirection(o.type);if(s.length>1){const{fromFeature:o,toFeature:s,type:a}=this._determineJunctionEdgeConnectivity(t,r);return this.association=C({fromFeature:o,toFeature:s,utilityNetwork:e,associationType:a}),void this.validateAssociation()}const{fromFeature:a,toFeature:i}=this._determineFromAndTo(t,r,s[0].direction);this.association=C({fromFeature:a,toFeature:i,utilityNetwork:e,associationType:s[0].type}),this.validateAssociation()}async _queryAssociatedFeatures(e,t){const{featuresPerPage:r,layer:o,featurePage:s,featureCount:a,selectedLayer:i}=this,{canQuery:n,globalId:u}=this;if(!n||!o||!i||null==u)return[];const l=((s-1)*r+a)%a,c=r,{historicMoment:y,gdbVersion:h}=i,p=i.createQuery();p.where=p.where?`${p.where} AND ${e}`:e,p.start=l,p.num=c,p.returnGeometry=!1,p.historicMoment=y,p.gdbVersion=h,p.outFields=["*"];return(await i.queryFeatures(p,{signal:t?.signal})).features}validateAssociation(){a(this._validateAssociationTask);const{utilityNetwork:e,association:t}=this,r=o((async()=>{e&&t&&(this._canAssociate=await e.canAddAssociation(t))}));this._updatingHandlesAssociation.addPromise(r.promise),this._validateAssociationTask=r}};e([c({type:t})],A.prototype,"graphic",void 0),e([c()],A.prototype,"layer",void 0),e([c()],A.prototype,"map",void 0),e([c({readOnly:!0})],A.prototype,"mapLayers",null),e([c()],A.prototype,"utilityNetwork",void 0),e([c()],A.prototype,"associationType",void 0),e([c()],A.prototype,"state",null),e([c({readOnly:!0})],A.prototype,"canAddAssociation",null),e([c({readOnly:!0})],A.prototype,"globalId",null),e([c({readOnly:!0})],A.prototype,"globalIdField",null),e([c()],A.prototype,"featureCount",void 0),e([c({readOnly:!0})],A.prototype,"layerItems",null),e([c({readOnly:!0})],A.prototype,"featureItems",null),e([c()],A.prototype,"_queryAbortController",void 0),e([c()],A.prototype,"_queryPageAbortController",void 0),e([c()],A.prototype,"_queryFeatureCountAbortController",void 0),e([c({value:1})],A.prototype,"featurePage",null),e([c()],A.prototype,"featuresPerPage",void 0),e([c({readOnly:!0})],A.prototype,"canLoad",null),e([c({readOnly:!0})],A.prototype,"canQuery",null),e([c({readOnly:!0})],A.prototype,"updating",null),e([c()],A.prototype,"selectedLayer",null),e([c()],A.prototype,"selectedFeature",void 0),e([c()],A.prototype,"association",void 0),e([c()],A.prototype,"filterOptionsVisible",void 0),e([c()],A.prototype,"filterWhereClause",void 0),e([c()],A.prototype,"queryWhereClause",null),e([c()],A.prototype,"_rulesTable",void 0),e([c()],A.prototype,"_canAssociate",void 0),e([c()],A.prototype,"_whereClause",void 0),A=e([y("esri.widgets.FeatureForm.UtilityNetworkAssociationAddAssociationViewModel")],A);const F=A;export{F 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 e from"../../core/Identifiable.js";import{ignoreAbortErrors as s}from"../../core/promiseUtils.js";import{watch as i,on as o,initial as a}from"../../core/reactiveUtils.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import{isAssociatedFeatureSupportedLayer as l}from"../Feature/support/featureUtils.js";import p from"./EditableInput.js";import{parseFormTemplateString as c}from"./featureFormUtils.js";import u from"../support/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.js";let d=class extends(e.IdentifiableMixin(p)){constructor(t){super(t),this.group=null,this.type="utilityNetworkAssociations",this.addHandles([i((()=>({feature:this.feature,element:this.element,layer:this.layer})),(t=>this._createAssociationVM(t)),a),i((()=>this.associatedLayer),((t,e)=>this._updateLayerEditHandle(t,e)),a)])}destroy(){this._associationsVM?.destroy()}get activeAssociationType(){return this._associationsVM?.activeAssociationType}get associatedFeatures(){const{associatedLayer:t}=this;if(t)return this.associatedFeatureInfos.get(t)}get associatedFeatureInfos(){const{_associationsVM:t,timeZone:e}=this;if(!t?.associationFeatures?.size||!t?.utilityNetwork)return new Map;const{associationFeatures:s}=t,i=new Map;return s.forEach(((t,s)=>{const o=t.map((t=>{const i=s&&"formTemplate"in s&&s.formTemplate?s.formTemplate.title:void 0,o=i?c({label:i,attributes:t.feature.attributes,fieldsIndex:s.fieldsIndex,timeZone:e}):void 0;return{...t,title:o}}));i.set(s,o)})),i}get associatedLayer(){return this._get("associatedLayer")}set associatedLayer(t){this._associationsVM.showAllEnabled=null!=t,this._set("associatedLayer",t)}get associationsViewModel(){return this._associationsVM}get canAddAssociation(){const{editable:t,utilityNetwork:e}=this;return!(!e||!this.loaded)&&t}get editable(){return this.evaluatedEditableExpression??!0}get featureCount(){return this._associationsVM?.featureCount??0}get viewModel(){return this._associationsVM}get loaded(){return"loading"!==this._associationsVM?.state}get map(){return this._get("map")}set map(t){t&&this._associationsVM?.set("map",t),this._set("map",t)}get utilityNetwork(){return this._associationsVM?.utilityNetwork}get associationTypes(){return this._associationsVM?.associationTypes??this.element.associationTypes}get visible(){const{utilityNetwork:t}=this;return!!t&&(null!=this.evaluatedVisibilityExpression?this.evaluatedVisibilityExpression:null!=this.element)}get updating(){return"loading"===this._associationsVM?.state||"querying"===this._associationsVM?.state}async refresh(){await s(this._associationsVM.refresh())}_updateLayerEditHandle(t,e){e&&"layerId"in e&&this.removeHandles(e?.layerId),l(t)&&this.addHandles(o((()=>t),"edits",(()=>this.refresh())),t.layerId)}_createAssociationVM(t){const{feature:e,element:s,layer:i}=t;if(this._associationsVM?.destroy(),!e||!s||!i)return;const{map:o,associationTypes:a}=this;l(i)&&(this._associationsVM=new u({graphic:e,layer:i,map:o,associationTypes:a,source:"featureForm",title:this.label,description:this.description}))}};t([r()],d.prototype,"_associationsVM",void 0),t([r()],d.prototype,"activeAssociationType",null),t([r()],d.prototype,"associatedFeatures",null),t([r()],d.prototype,"associatedFeatureInfos",null),t([r()],d.prototype,"associatedLayer",null),t([r()],d.prototype,"associationsViewModel",null),t([r()],d.prototype,"canAddAssociation",null),t([r()],d.prototype,"editable",null),t([r()],d.prototype,"featureCount",null),t([r()],d.prototype,"viewModel",null),t([r()],d.prototype,"group",void 0),t([r()],d.prototype,"loaded",null),t([r()],d.prototype,"map",null),t([r()],d.prototype,"utilityNetwork",null),t([r()],d.prototype,"associationTypes",null),t([r({readOnly:!0})],d.prototype,"type",void 0),t([r()],d.prototype,"visible",null),t([r()],d.prototype,"updating",null),d=t([n("esri.widgets.FeatureForm.UtilityNetworkAssociationInput")],d);const y=d;export{y as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import s from"../../core/Identifiable.js";import{ignoreAbortErrors as e}from"../../core/promiseUtils.js";import{watch as i,on as o,initial as a}from"../../core/reactiveUtils.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import{isAssociatedFeatureSupportedLayer as l}from"../Feature/support/featureUtils.js";import p from"./EditableInput.js";import c from"../support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js";import{getFeatureTitle as u}from"../support/UtilityNetworkAssociations/utilityNetworkUtils.js";let d=class extends(s.IdentifiableMixin(p)){constructor(t){super(t),this.group=null,this.type="utilityNetworkAssociations",this.addHandles([i((()=>({feature:this.feature,element:this.element,layer:this.layer})),(t=>this._createAssociationVM(t)),a),i((()=>this.associatedLayer),((t,s)=>this._updateLayerEditHandle(t,s)),a)])}destroy(){this._associationsVM?.destroy()}get activeAssociationType(){return this._associationsVM?.activeAssociationType}get associatedFeatures(){const{associatedLayer:t}=this;if(t)return this.associatedFeatureInfos.get(t)}get associatedFeatureInfos(){const{_associationsVM:t}=this;if(!t?.associationFeatures?.size||!t?.utilityNetwork)return new Map;const{associationFeatures:s}=t,e=new Map;return s.forEach(((t,s)=>{const i=t.map((t=>{const s=u(t.feature);return{...t,title:s}}));e.set(s,i)})),e}get associatedLayer(){return this._get("associatedLayer")}set associatedLayer(t){this._associationsVM.showAllEnabled=null!=t,this._set("associatedLayer",t)}get associationsViewModel(){return this._associationsVM}get canAddAssociation(){const{editable:t,utilityNetwork:s}=this;return!(!s||!this.loaded)&&t}get editable(){return this.evaluatedEditableExpression??!0}get featureCount(){return this._associationsVM?.featureCount??0}get viewModel(){return this._associationsVM}get loaded(){return"loading"!==this._associationsVM?.state}get map(){return this._get("map")}set map(t){t&&this._associationsVM?.set("map",t),this._set("map",t)}get utilityNetwork(){return this._associationsVM?.utilityNetwork}get associationTypes(){return this._associationsVM?.associationTypes??this.element.associationTypes}get visible(){const{utilityNetwork:t}=this;return!!t&&(null!=this.evaluatedVisibilityExpression?this.evaluatedVisibilityExpression:null!=this.element)}get updating(){return"loading"===this._associationsVM?.state||"querying"===this._associationsVM?.state}async refresh(){await e(this._associationsVM.refresh())}_updateLayerEditHandle(t,s){s&&"layerId"in s&&this.removeHandles(s?.layerId),l(t)&&this.addHandles(o((()=>t),"edits",(()=>this.refresh())),t.layerId)}_createAssociationVM(t){const{feature:s,element:e,layer:i}=t;if(this._associationsVM?.destroy(),!s||!e||!i)return;const{map:o,associationTypes:a}=this;l(i)&&(this._associationsVM=new c({graphic:s,layer:i,map:o,associationTypes:a,source:"featureForm",title:this.label,description:this.description}))}};t([r()],d.prototype,"_associationsVM",void 0),t([r()],d.prototype,"activeAssociationType",null),t([r()],d.prototype,"associatedFeatures",null),t([r()],d.prototype,"associatedFeatureInfos",null),t([r()],d.prototype,"associatedLayer",null),t([r()],d.prototype,"associationsViewModel",null),t([r()],d.prototype,"canAddAssociation",null),t([r()],d.prototype,"editable",null),t([r()],d.prototype,"featureCount",null),t([r()],d.prototype,"viewModel",null),t([r()],d.prototype,"group",void 0),t([r()],d.prototype,"loaded",null),t([r()],d.prototype,"map",null),t([r()],d.prototype,"utilityNetwork",null),t([r()],d.prototype,"associationTypes",null),t([r({readOnly:!0})],d.prototype,"type",void 0),t([r()],d.prototype,"visible",null),t([r()],d.prototype,"updating",null),d=t([n("esri.widgets.FeatureForm.UtilityNetworkAssociationInput")],d);const y=d;export{y 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"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import"../core/has.js";import i from"../core/Logger.js";import{getOrCreateMapValue as o}from"../core/MapUtils.js";import{createResolver as s}from"../core/promiseUtils.js";import{watch as n,whenOnce as a}from"../core/reactiveUtils.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as d}from"../layers/support/fieldUtils.js";import{getSubtypesFromLayer as c}from"../layers/support/layerUtils.js";import{isString as u}from"../support/guards.js";import p from"./Widget.js";import{Prompt as m}from"./Editor/components/Prompt.js";import h from"./Feature/FeatureUtilityNetworkAssociations.js";import{css as v}from"./FeatureForm/css.js";import{isGroupInput as _,isFieldInput as g,isRelationshipInput as b,isTextElementInput as f,isUtilityNetworkAssociationInput as y,flattenInputs as C,isInputInGroupInput as F,isFieldElementWithInputType as w,getErrorMessageForFieldInput as R,getIconForFeature as k,isNumberFieldInput as O,subtypeChangeShouldPrompt as I}from"./FeatureForm/featureFormUtils.js";import M from"./FeatureForm/FeatureFormViewModel.js";import N from"./FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js";import{loadCalciteComponents as L}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as T,getIntlOptionsForField as x,numberingSystem as D,prepareISOFieldValueForDateComponents as V,prepareUnixFieldValueForDateComponents as A,normalizeTimeOnlyString as U,getISOFieldValueFromDateComponents as S,getUnixFieldValueFromDateComponents as E}from"./support/dateUtils.js";import{globalCss as j}from"./support/globalCss.js";import{Heading as P,incrementHeadingLevel as $}from"./support/Heading.js";import{setFocus as H}from"./support/widgetUtils.js";import{messageBundle as Z}from"./support/decorators/messageBundle.js";import{vmEvent as G}from"./support/decorators/vmEvent.js";import{tsx as W}from"./support/jsxFactory.js";import{substitute as B}from"../intl/substitute.js";const K="data-field-name";let q=class extends p{constructor(e,t){super(e,t),this._associationsWidgetsMap=new Map,this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._inputsWithChanges=new Set,this._focusedFieldName=null,this._pendingSubtypeChoice=null,this._listObserverNode=null,this._listObserver=new IntersectionObserver((e=>{e.length&&e[0].isIntersecting&&this._incrementRelatedRecordPage()}),{root:window.document}),this._prompt=null,this._featureFormUNAssociationList=null,this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.messagesFeature=null,this.messagesTemplates=null,this.viewModel=new M,this._onShowAllRelatedRecordsClick=e=>{const{feature:t,callbacks:i}=this;t&&i?.showAllRelatedRecords&&i.showAllRelatedRecords({parentFeature:t,relationshipId:e})},this._onAddRelatedRecordsClick=(e,t)=>{const{feature:i,callbacks:o}=this;i&&o?.addRelatedRecord&&o.addRelatedRecord({parentFeature:i,relatedLayer:t,relationshipId:e})},this._onFormKeyDown=this._onFormKeyDown.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onGroupToggle=this._onGroupToggle.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentKeyDown=this._onComponentKeyDown.bind(this),this._afterComponentCreate=this._afterComponentCreate.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this)}initialize(){this.addHandles([n((()=>this.feature),(()=>{this._inputsWithChanges.clear(),this._dateComponentMap.clear(),a((()=>!this.viewModel.updating)).then((()=>{const e=this._getFocusableInput("forward");this._syncGroupInputStates(),this._focusedFieldName=e?.name||null,this._attemptFocusOnNextRender=!0}))})),n((()=>this.groupDisplay),(()=>this._syncGroupInputStates())),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._inputsWithChanges.add(e))),this._focusedFieldName=t,this._attemptFocusOnNextRender=!0,this.scheduleRender()}})),n((()=>[this.viewModel.activeRelationshipInput,this._listObserverNode]),(()=>this._onObserverChange())),n((()=>this.viewModel.activeAssociationInput),(e=>{e&&this._featureFormUNAssociationList&&(this._featureFormUNAssociationList.associationInput=e,this._featureFormUNAssociationList.viewModel=e.viewModel)}))])}loadDependencies(){return L({block:()=>import("@esri/calcite-components/dist/components/calcite-block"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch"),"text-area":()=>import("@esri/calcite-components/dist/components/calcite-text-area")})}destroy(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get _relatedRecordsEnabled(){const{callbacks:e}=this;return!(!e||!(e.addRelatedRecord||e.editRelatedRecord||e.showAllRelatedRecords))}get _utilityNetworkAssociationsEnabled(){const{callbacks:e}=this;return!(!e?.viewAssociatedLayers||!e.viewAssociatedFeatures)}get _subtypes(){return c(this.layer)}get associationId(){return this.viewModel.associationId}set associationId(e){this.viewModel.associationId=e}get associatedLayer(){return this.viewModel.associatedLayer}set associatedLayer(e){this.viewModel.associatedLayer=e}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get feature(){return this.viewModel.feature}set feature(e){this.viewModel.feature=e}get formTemplate(){return this.viewModel.formTemplate}set formTemplate(e){this.viewModel.formTemplate=e}get icon(){return"form-field"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get callbacks(){return this.viewModel.callbacks}set callbacks(e){this.viewModel.callbacks=e}get relationshipId(){return this.viewModel.relationshipId}set relationshipId(e){this.viewModel.relationshipId=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get strict(){return this.viewModel.strict}set strict(e){this.viewModel.strict=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get showPrompt(){return e=>{this._prompt?.cancel?.(),this._prompt=e}}set showPrompt(e){this._overrideIfSome("showPrompt",e)}get clearPrompt(){return()=>this._prompt=null}set clearPrompt(e){this._overrideIfSome("clearPrompt",e)}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return W("div",{class:this.classes(v.base,j.widget,j.panel)},"ready"===e?this._renderForm():null)}_renderForm(){return W("div",null,W("form",{class:v.form,novalidate:!0,onkeydown:this._onFormKeyDown,onsubmit:this._onFormSubmit},this._renderHeader(),this._renderContent()),this._prompt?W(m,{...this._prompt,headingLevel:this.headingLevel}):void 0)}_renderHeader(){const e=this.viewModel,{formTitle:t,formDescription:i}=e;if(!e.formHeaderVisible)return;const o=null!=t&&W(P,{key:"title",level:this.headingLevel},t),s=null!=i&&W("p",{class:v.description,key:"description"},i);return W("div",{class:v.formHeader},o,s)}_renderContent(){const{viewModel:e}=this;return e.activeRelationshipInput?this._renderRelationshipInput(e.activeRelationshipInput):e.activeAssociationInput?this._renderFeatureFormUtilityNetworkAssociationList():e.inputs.filter(t).filter((e=>e.visible)).map((e=>this._renderInput(e)))}_renderInput(e){return _(e)?this._renderGroup(e):g(e)?this._renderLabeledField(e):b(e)?this._renderRelationshipInput(e):f(e)?this._renderTextElementInput(e):y(e)?this._renderUtilityNetworkAssociationsElementInput(e):void 0}_renderFeatureFormUtilityNetworkAssociationList(){return this._featureFormUNAssociationList?.render()}_selectAssociatedLayer(e){const{feature:t,callbacks:i}=this;t&&i?.viewAssociatedFeatures&&i.viewAssociatedFeatures({associatedLayer:e.layer})}_selectAssociatedFeature(e){const{feature:t,callbacks:i}=this;t&&i?.selectAssociatedFeature&&i.selectAssociatedFeature({parentFeature:t,feature:e.feature,association:e.association})}_setUpUtilityNetworkAssociationList(){this._featureFormUNAssociationList||(this._featureFormUNAssociationList=new N({onSelectLayer:this._selectAssociatedLayer.bind(this),onSelectFeature:this._selectAssociatedFeature.bind(this)}))}_renderUtilityNetworkAssociationsElementInput(e){if(this._utilityNetworkAssociationsEnabled)return this._setUpUtilityNetworkAssociationList(),o(this._associationsWidgetsMap,e,(()=>new h({onSelectAssociationType:({viewModel:t,listType:i})=>{t.activeAssociationType=i;const{feature:o,callbacks:s}=this;o&&s?.viewAssociatedLayers&&s.viewAssociatedLayers({associationId:e.uid})},viewModel:e.associationsViewModel}))).render()}_renderDescriptionOrEmpty(e,t){return null==e?null:W("div",{class:this.classes(v.description),id:t},e)}_renderGroup(e){const{disabled:t,formTemplate:i,headingLevel:o}=this,{description:s,id:n,inputs:a,label:r,open:l}=e,d=a.filter((e=>e.visible)),c=this.viewModel.findField(this._focusedFieldName),u=c?.group===e,p="sequential"===this.groupDisplay;return W("calcite-block",{class:this.classes(v.group,p?v.groupSequential:null,u?v.groupActive:null,t?v.inputDisabled:null),collapsible:!0,"data-group":e,description:s||void 0,disabled:t,heading:r??"",headingLevel:i?.title?$(o):o,id:n,key:n,open:l,onCalciteBlockToggle:({currentTarget:t})=>this._onGroupToggle(t,e)},d.map((e=>this._renderInput(e))))}_getFocusableInput(e,t){const i=C(this.viewModel.inputs);let o;if("backward"===e&&i.reverse(),t)if(_(t)){const e=t.inputs.find((e=>e.visible));o=e?i.indexOf(e):0}else{let s;if(F(t)&&!t.group.open){const i=t.group.inputs.filter(g);s="forward"===e?i[i.length-1]:i[0]}else s=t;o=i.indexOf(s)+1}else o=0;for(let s=o;s<i.length;s++){const e=i[s];if(e.visible&&g(e))return e}return null}_renderLabeledField(e){const{dataType:t,feature:i,label:o,layer:s,required:n}=e,a={"aria-label":n?B(this.messages.requiredFieldLabel,{name:o}):o,class:v.label,key:`${s.id}-${i.uid}-${e.name}`},r=[W("div",{class:v.labelTextContent,key:"labelTextContainer"},o,n?W("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==t?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e)];return"date"===t&&"coded-value"!==e.domain?.type?W("label",{...a},r):W("calcite-label",{...a},r)}_renderFieldInput(e){const{dataType:t,domain:i,inputType:o,name:s}=e,n=this.getCommonInputProps(e);if("coded-value"===i?.type){const t=this.viewModel.getFieldValueOptionsForField(s,this.messages.empty);return"switch"!==o||e.hasInvalidSwitchValue?"radio-buttons"===o?this._renderRadioButtonComponents(e,t.flat(),n):this._renderComboBoxComponent(e,t,n):this._renderSwitchComponent(e,n)}return"datetime-picker"===o||"date"===t?this._renderDateComponents(e,n):"number"===t?this._renderNumberComponent(e,n):this._renderStringComponent(e,n)}_renderStringComponent(e,t){return"text-area"===e.inputType?t.readOnly?W("calcite-input",{...t,loading:e.updating,type:"textarea",onCalciteInputInput:e=>this._saveValueFromComponent(e.currentTarget)}):W("calcite-text-area",{...t,resize:"vertical",onCalciteTextAreaInput:e=>this._saveValueFromComponent(e.currentTarget)}):W("calcite-input",{...t,loading:e.updating,type:"text",onCalciteInputInput:e=>this._saveValueFromComponent(e.currentTarget)})}_renderNumberComponent(e,t){const i=d(e.field),o=i&&""!==t.value?Math.round(parseFloat(t.value)).toString():t.value;return W("calcite-input-number",{...t,integer:i,loading:e.updating,type:"number",value:o,onCalciteInputNumberInput:e=>this._saveValueFromComponent(e.currentTarget)})}_renderDateComponents(e,t){const{field:i}=e;switch(i.type){case"date":return this._renderDateFieldComponents(e,t);case"date-only":return this._renderDateOnlyFieldComponent(e,t);case"time-only":return this._renderTimeOnlyFieldComponent(e,t);case"timestamp-offset":return this._renderTimestampOffsetFieldComponents(e,t);default:return this._renderReadOnlyComponent(e,T(i,t.value,{timeZone:this.timeZone,...x(i)}))}}_renderDateOnlyFieldComponent(e,t){const{range:i,valid:o,value:s}=e,{class:n,key:a,readOnly:r}=t,{rawMax:l,rawMin:d}=i;return W("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!o,class:n,"data-date-part":"date","data-field-name":t[K],key:`${a}-date-input`,max:u(l)?l:void 0,min:u(d)?d:void 0,numberingSystem:D,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:r,value:null!=s?`${s}`:void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.currentTarget)})}_renderTimeOnlyFieldComponent(e,t){const{valid:i,value:o}=e,{class:s,key:n,readOnly:a}=t;return W("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,class:s,"data-date-part":"time","data-field-name":t[K],key:`${n}-time-input`,numberingSystem:D,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:a,step:e.timeStep,value:null!=o?`${o}`:void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.currentTarget)})}_renderTimestampOffsetFieldComponents(e,t){const{name:i,range:o,timeZone:s,valid:n,value:a}=e,{class:r,key:l,readOnly:d}=t,{rawMax:c,rawMin:u}=o,p={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!n,numberingSystem:D,overlayPositioning:"fixed",readOnly:d,[K]:i,onfocus:this._onComponentFocus},m=V(c,s),h=V(u,s),_=V(a,s);return W("div",{class:v.dateInputContainer,key:`${l}-date-time-container`},W("calcite-input-date-picker",{...p,class:r,"data-date-part":"date",key:`${l}-date-input`,max:m?.date??void 0,min:h?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:_.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.currentTarget)}),W("calcite-input-time-picker",{...p,class:r,"data-date-part":"time",key:`${l}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:e.timeStep,value:_.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.currentTarget)}),e.includeTimeOffset?W("calcite-input-time-zone",{...p,class:r,"data-date-part":"timeZone",disabled:d,key:`${l}-timezone-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:_.timeZoneOffset??"0",onCalciteInputTimeZoneChange:e=>this._saveValueFromDateComponent(e.currentTarget)}):null)}_renderDateFieldComponents(e,t){const{includeTime:i,name:o,valid:s,value:n}=e,{class:a,key:r,max:l,min:d,readOnly:c}=t,{timeZone:u}=this,p={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!s,numberingSystem:D,overlayPositioning:"fixed",readOnly:c,[K]:o,onfocus:this._onComponentFocus},m=A(n,u),h=A(l,u),_=A(d,u);return W("div",{class:v.dateInputContainer,key:`${r}-date-time-container`},W("calcite-input-date-picker",{...p,class:a,"data-date-part":"date",key:`${r}-date-input`,max:h?.date??void 0,min:_?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:m.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.currentTarget)}),i?W("calcite-input-time-picker",{...p,class:a,"data-date-part":"time",key:`${r}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:1,value:m.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.currentTarget)}):null)}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return W("calcite-input",{...i,class:this.classes(v.fieldInput,v.inputDisabled),readOnly:!0,type:"text",value:null!=t?`${t}`:i.value})}_renderComboBoxComponent(e,t,i){const{value:o,name:s}=e,{viewModel:n,_inputsWithChanges:a}=this,r="INSERT"===n.arcadeEditType,l=a.has(s),d=null==o&&(!r||l),c=r&&e.showNoValueOptionEnabled&&!l?()=>{}:i.onblur;return W("calcite-combobox",{...i,allowCustomValues:!1,clearDisabled:!0,disabled:i.readOnly,onblur:c,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxChange:({currentTarget:t})=>{d&&0===t.selectedItems.length?this._ignoreDeselectionOfNoValueOption(t):e.isSubtypeField&&0===t.selectedItems.length?t.value=`${e.value}`:this._saveValueFromComponent(t)}},this.renderComboboxOptionsList(e,t))}renderComboboxOptionsList(e,t){const{value:i,name:o}=e,{messages:s,messagesTemplates:n,viewModel:a,_inputsWithChanges:r}=this,[l,d,c]=t.map((e=>e.map((({name:e,value:t})=>W("calcite-combobox-item",{key:`#${t}`,selected:i===t,textLabel:e,value:`${t}`}))))),u=[];d.length>0&&u.push(W("calcite-combobox-item-group",{key:"other",label:n.other},d)),c.length>0&&u.push(W("calcite-combobox-item-group",{key:"unsupported",label:s.subtypes.unsupportedDomainGroupTitle},c)),u.length>0?u.unshift(W("calcite-combobox-item-group",{key:"recommended",label:s.recommended},l)):u.push(...l);const p="INSERT"===a.arcadeEditType,m=r.has(o),h=null==i&&(!p||m);return e.showNoValueOptionEnabled&&u.unshift(W("calcite-combobox-item",{key:"empty-option",selected:h,textLabel:e.showNoValueLabel||s.empty,value:""})),u}_renderRadioButtonComponents(e,t,i){const{name:o,value:s}=e,n=t.map((({name:e,value:t})=>this._renderRadioButtonComponent({key:e,label:e,name:o,value:t,selected:t===s,props:i})));if(e.showNoValueOptionEnabled){const t="",a=e.showNoValueLabel||this.messages.empty,r=s===t||null===s;n.unshift(this._renderRadioButtonComponent({key:"empty-option",label:a,name:o,value:t,selected:r,props:i}))}return W("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:v.inputRadioGroup,"data-field-name":i[K],key:`${i.key}-radio-group`,layout:"vertical",name:i.key,required:i.required},n)}_renderSwitchComponent(e,t){const{value:i}=e,o=!!w(e.element,"switch")&&i===e.element.input.onValue;return W("calcite-switch",{...t,checked:o,class:v.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldName=null},onCalciteSwitchChange:e=>this._saveValueFromComponent(e.currentTarget)})}_renderRadioButtonComponent({key:e,name:t,value:i,selected:o,label:s,props:n}){return W("calcite-label",{class:v.inputRadioLabel,key:e,layout:"inline"},W("calcite-radio-button",{...n,afterCreate:void 0,afterUpdate:void 0,checked:o,class:v.inputRadio,disabled:n.readOnly,name:t,onblur:()=>{this._focusedFieldName=null},value:i,onCalciteRadioButtonChange:({currentTarget:e})=>{e.checked&&this._saveValueFromComponent(e)}}),s)}_renderAuxiliaryText(e){const t=e.name,i=this._inputsWithChanges.has(t)&&!e.submittable?R(e,this.messages,this.timeZone):null!=this.viewModel.contingencyConstraintViolations.get(t)?this.messages.validationErrors.valuesIncompatible:null!=e.valueExpressionExecutor&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return null!=i?W("calcite-input-message",{icon:!0,status:"invalid"},i):this._inputsWithChanges.has(t)&&e.valueIsOutOfDomain?W("calcite-input-message",{icon:!0,status:"idle"},this.messages.subtypes.fieldOutOfSubtypeDomainWarning):this._renderDescriptionOrEmpty(e.description)}_renderShowAllRelatedRecordsListItem(e){const{featureCount:t,relationshipId:i,showAllActionVisible:o}=e,{callbacks:s}=this;if(!o||!s?.showAllRelatedRecords)return;const n=this.messages;return W("calcite-list-item",{description:B(n.totalCount,{count:t}),label:n.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(i)},W("calcite-icon",{icon:"list",scale:"s",slot:"content-end"}))}_renderAddRelatedRecordButton(e){const{canAddRelatedFeature:t,relationshipId:i,relatedLayer:o}=e,{messages:s,callbacks:n}=this;if(t&&n?.addRelatedRecord&&o)return W("calcite-button",{alignment:"center",appearance:"outline-fill",class:v.centeredButton,disabled:e.updating||!e.originHasValidKey,iconStart:"plus",key:`${i}-add-button`,onclick:()=>{!e.updating&&e.originHasValidKey&&this._onAddRelatedRecordsClick(i,o)},round:!0,scale:"s",width:"full"},e.relatedLayerIsTable?s.addRecord:s.addFeature)}_renderRelatedRecordListItem(e,t){const{feature:i,description:o,title:s}=e,{feature:n,callbacks:a}=this,{highlightHelper:r}=this.viewModel,l=()=>{r?.removeAll(),a?.editRelatedRecord&&n&&a.editRelatedRecord({parentFeature:n,relationshipId:t,relatedFeature:i})},d=r?()=>r.add(i):void 0,c=r?()=>r.remove(i):void 0;return W("calcite-list-item",{bind:this,description:o,key:`${t}-${i.uid}`,label:s,onclick:l,onmouseenter:d,onmouseleave:c,value:s},W("calcite-icon",{icon:k(i),slot:"content-start"}),W("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderRelationshipInput(e){if(!this._relatedRecordsEnabled||!e.editable)return;const{featureCount:t,relationshipId:i,showAllEnabled:o}=e,s=o?null:this._renderDescriptionOrEmpty(e.description),n=t>0?this._renderRelatedRecordsList(e):e.loaded?e.originHasValidKey?this._renderNoRelatedRecordsNotice():this._renderNoValidOriginKeyNotice(e):void 0;return W("calcite-label",{class:this.classes(v.label,v.relatedRecordsLabel),key:`relationship-${i}-container`},W("div",null,this._renderRelatedRecordsHeaderContainer(e),s,n),this._renderAddRelatedRecordButton(e))}_renderRelatedRecordsHeaderContainer(e){const t=e.updating||!e.loaded;return W("div",{class:v.relatedRecordsHeader,key:`relationship-${e.relationshipId}-header`},W("span",null,e.label),t?W("calcite-loader",{inline:!0,key:"loader",label:this.messagesCommon?.loading,scale:"s",type:"indeterminate"}):void 0)}_renderRelatedRecordsList(e){const{relationshipId:t}=e;return W("calcite-list",{class:v.relatedRecordsList,label:this.messages?.relatedRecordsList},e.relatedFeatureInfos.map((e=>this._renderRelatedRecordListItem(e,t))),this._renderShowAllRelatedRecordsListItem(e),this._renderObserverNode())}_renderNoValidOriginKeyNotice(e){const{messages:t}=this,i=e.relatedLayerIsTable?t.noOriginKeyRecord:t.noOriginKeyFeature,o=e.relationship?.keyField,s=this.viewModel.findField(o),n=e.layer?.fieldsIndex.get(o),a=s?.label||n?.alias||o,r=B(i,{relatedLayerName:e.relatedLayer?.title,originKeyField:a});return W("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},W("div",{slot:"message"},r))}_renderNoRelatedRecordsNotice(){return W("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},W("div",{slot:"message"},this.messagesFeature.noRelatedFeatures))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return W("div",{afterCreate:this._afterListObserverCreated,afterRemoved:this._afterListObserverRemoved,bind:this,class:v.listObserver,key:"feature-observer"})}_renderTextElementInput(e){return W("div",{class:v.textElement,innerHTML:e.text,key:e.id})}getCommonInputProps(e){const{disabled:t}=this,{editable:i,hint:o,label:s,maxLength:n,minLength:a,name:r,range:{max:l,min:d},required:c,valid:u,value:p}=e,m=this._inputsWithChanges.has(r),h=!i||t;return{afterCreate:this._afterComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":u?"false":"true",class:this.classes(v.fieldInput,h?v.inputDisabled:null),status:m&&!u?"invalid":"idle",key:r,label:s,max:null!=l?l:void 0,min:null!=d?d:void 0,maxLength:n>-1?n:void 0,minLength:a>-1?a:void 0,placeholder:o??void 0,readOnly:h,required:c,value:null==p?"":`${p}`,onblur:this._onComponentBlur,onfocus:this._onComponentFocus,onkeydown:this._onComponentKeyDown,[K]:r}}_getFieldInputFromHTMLElement(e){return this.viewModel.findField(e.getAttribute(K))}_afterDateComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e),i=e.dataset.datePart,o=this._dateComponentMap.get(t.name);if("valueAsDate"in e&&null!=e.value&&null!=t.value){const i=new ResizeObserver((()=>{switch(e.value=void 0,t.field.type){case"date":e.value=A(t.value,this.timeZone).date??"";break;case"timestamp-offset":e.value=V(t.value,this.timeZone).date??"";break;default:e.value=`${t.value}`}i.unobserve(e)}));i.observe(e)}if(null!=o)switch(i){case"date":o.date=e;break;case"time":o.time=e;break;case"timeZone":o.timeZone=e}else this._dateComponentMap.set(t.name,{[i]:e});this._afterDateComponentCreateOrUpdate(e)}_afterDateComponentCreateOrUpdate(e){this._afterComponentCreateOrUpdate(e)}_afterComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e);O(t)&&null!=e.value&&"setNumberValue"in e&&e.setNumberValue({committing:!1,value:e.value,origin:"direct"}),this._afterComponentCreateOrUpdate(e)}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),o=t||i;o&&this._afterComponentCreateOrUpdate(o)}_afterComponentCreateOrUpdate(e){const{viewModel:t}=this,i=this._getFieldInputFromHTMLElement(e),o=t.findField(this._focusedFieldName);this._attemptFocusOnNextRender&&o===i&&(this._attemptFocusOnNextRender=!1,F(i)&&(i.group.open=!0),H(e))}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._focusedFieldName=i.name}_onComponentBlur(e){const t=e.target;this._focusedFieldName=null;"readOnly"in t&&t.readOnly||this._saveValueFromComponent(t)}_saveValueFromDateComponent(e){const{timeZone:t}=this,i=this._getFieldInputFromHTMLElement(e),o=i.field.type,{name:s,range:n}=i,a=this._dateComponentMap.get(s);if(!a)return;let r=this.viewModel.getValue(s),l=null;"date-only"===o?l=Array.isArray(e.value)?e.value[0]:e.value:"time-only"===o?(r=U(r),l=U(e.value)):l="timestamp-offset"===o?null!=e.value?S({dateComponent:a.date,timeComponent:a.time,timeZoneComponent:a.timeZone,oldValue:r,defaultTimeZone:t}):null:null!=e.value?E({oldValue:r,dateComponent:a.date,timeComponent:a.time,timeZone:t,max:n.max,min:n.min}):null,null!==l&&e.value?r!==l&&this._updateFieldValue(s,l):this._updateFieldValue(s,null)}_saveValueFromComponent(e){const t=this._getFieldInputFromHTMLElement(e),i=this._parseValue(e),o=t.value;t.isSubtypeField&&I(this.layer,o,i)?this._pendingSubtypeChoice||i===o||(this._pendingSubtypeChoice=this._handleSubtypeChoice(t,i)):this._updateFieldValue(t.name,i)}async _handleSubtypeChoice(e,t){const{value:i,name:o}=e,{messages:n,viewModel:a,messagesCommon:r,_subtypes:l}=this;if(this._updateFieldValue(o,t),!l?.length)return;const d=l.find((e=>e.code===t)),c=l.find((e=>e.code===i))?.name??`${i}`;if(!d)return;const u=s();a.pendingSubtypeChoice=u;let p="update-fields";const m=[{label:n.subtypes.useDefaultValuesOption,value:"update-fields"},{label:n.subtypes.keepCurrentValuesOption,value:"keep-existing"}],h={context:"info",title:n.subtypes.changeWarningTitle,message:B(n.subtypes.changeWarning,{originalType:c,newType:d.name}),radios:m,defaultRadioSelection:"update-fields",onRadioSelection:e=>p=e,actions:{primary:{label:r.apply,action:()=>u.resolve(p),type:"positive"},secondary:{label:r.cancel,type:"neutral",action:()=>u.resolve("undo")}},cancel:()=>u.reject()};try{this.showPrompt(h);switch(await u.promise){case"update-fields":a.applySubtypeDefaults(d),this._validateContingenciesForNonNullFields();break;case"keep-existing":this._validateContingenciesForNonNullFields();break;case"undo":this._updateFieldValue(e.name,i)}}finally{a.pendingSubtypeChoice=null,this.clearPrompt(),this._pendingSubtypeChoice=null}}_onComponentKeyDown({key:e,target:t}){const i=this._getFieldInputFromHTMLElement(t);"Enter"===e&&F(i)&&!i.group.open&&(i.group.open=!0)}_updateFieldValue(e,t){const i=this.viewModel.getValue(e);this.viewModel.setValue(e,t),this._inputsWithChanges.add(e);i!==t&&this.viewModel.fieldsWithContingentValues.has(e)&&this._validateContingenciesForNonNullFields()}_validateContingenciesForNonNullFields(){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>null!=t)));this.viewModel.validateContingencyConstraints(e)}_parseValue(e){const t=this._getFieldInputFromHTMLElement(e),i=e.value;return w(t.element,"switch")?e.checked?t.element.input.onValue:t.element.input.offValue:null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):"date"===t.field.type?parseFloat(i):i}_ignoreDeselectionOfNoValueOption(e){const{firstChild:t,selectedItems:o}=e;0===o.length&&t&&"selected"in t?t.selected=!0:i.getLogger(this).warnOnce("Failed to override user attempt to deselect 'No value' option.")}_onGroupToggle(e,t){e.open?(t.open=!0,this._focusedFieldName=this._getFocusableInput("forward",t)?.name||null,this._attemptFocusOnNextRender=!0,"sequential"===this.groupDisplay&&this.viewModel.allGroupInputs.forEach((e=>{e!==t&&(e.open=!1)}))):t.open=!1,this.scheduleRender()}_onFormSubmit(e){e.preventDefault()}_onFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_afterListObserverCreated(e){this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)}_afterListObserverRemoved(){this._listObserverNode=null}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);const e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_incrementRelatedRecordPage(){const e=this.viewModel.activeRelationshipInput;e?.incrementPage()}_syncGroupInputStates(){if("sequential"!==this.groupDisplay)return;const e=this.viewModel.allGroupInputs;if(!e.length)return;const t=e.filter((e=>e.open));0===t.length?e[0].open=!0:t.length>1&&t.slice(1).forEach((e=>e.open=!1))}get test(){return{inputsWithChanges:this._inputsWithChanges,updateValue:this._saveValueFromComponent.bind(this)}}};e([r()],q.prototype,"_listObserverNode",void 0),e([r()],q.prototype,"_relatedRecordsEnabled",null),e([r()],q.prototype,"_utilityNetworkAssociationsEnabled",null),e([r()],q.prototype,"_prompt",void 0),e([r()],q.prototype,"_subtypes",null),e([r()],q.prototype,"associationId",null),e([r()],q.prototype,"associatedLayer",null),e([r()],q.prototype,"disabled",null),e([r()],q.prototype,"feature",null),e([r()],q.prototype,"_featureFormUNAssociationList",void 0),e([r()],q.prototype,"formTemplate",null),e([r()],q.prototype,"groupDisplay",void 0),e([r()],q.prototype,"headingLevel",void 0),e([r()],q.prototype,"icon",null),e([r()],q.prototype,"label",null),e([r()],q.prototype,"layer",null),e([r()],q.prototype,"map",null),e([r(),Z("esri/widgets/FeatureForm/t9n/FeatureForm")],q.prototype,"messages",void 0),e([r(),Z("esri/t9n/common")],q.prototype,"messagesCommon",void 0),e([r(),Z("esri/widgets/Feature/t9n/Feature")],q.prototype,"messagesFeature",void 0),e([r(),Z("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],q.prototype,"messagesTemplates",void 0),e([r()],q.prototype,"callbacks",null),e([r()],q.prototype,"relationshipId",null),e([r()],q.prototype,"spatialReference",null),e([r()],q.prototype,"strict",null),e([r()],q.prototype,"timeZone",null),e([r()],q.prototype,"showPrompt",null),e([r()],q.prototype,"clearPrompt",null),e([r(),G(["value-change","submit"])],q.prototype,"viewModel",void 0),e([r()],q.prototype,"test",null),q=e([l("esri.widgets.FeatureForm")],q);const z=q;export{z as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import"../core/has.js";import i from"../core/Logger.js";import{getOrCreateMapValue as o}from"../core/MapUtils.js";import{createResolver as s}from"../core/promiseUtils.js";import{watch as n,whenOnce as a}from"../core/reactiveUtils.js";import{property as r}from"../core/accessorSupport/decorators/property.js";import{subclass as l}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as d}from"../layers/support/fieldUtils.js";import{getSubtypesFromLayer as c}from"../layers/support/layerUtils.js";import{isString as u}from"../support/guards.js";import p from"./Widget.js";import{Prompt as m}from"./Editor/components/Prompt.js";import h from"./Feature/FeatureUtilityNetworkAssociations.js";import{css as v}from"./FeatureForm/css.js";import{isGroupInput as _,isFieldInput as g,isRelationshipInput as b,isTextElementInput as f,isUtilityNetworkAssociationInput as y,flattenInputs as C,isInputInGroupInput as F,isFieldElementWithInputType as w,getErrorMessageForFieldInput as R,getIconForFeature as k,isNumberFieldInput as O,subtypeChangeShouldPrompt as I}from"./FeatureForm/featureFormUtils.js";import M from"./FeatureForm/FeatureFormViewModel.js";import N from"./FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js";import{loadCalciteComponents as L}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as T,getIntlOptionsForField as x,numberingSystem as A,prepareISOFieldValueForDateComponents as D,prepareUnixFieldValueForDateComponents as V,normalizeTimeOnlyString as U,getISOFieldValueFromDateComponents as S,getUnixFieldValueFromDateComponents as E}from"./support/dateUtils.js";import{globalCss as j}from"./support/globalCss.js";import{Heading as P,incrementHeadingLevel as $}from"./support/Heading.js";import{setFocus as H}from"./support/widgetUtils.js";import{messageBundle as Z}from"./support/decorators/messageBundle.js";import{vmEvent as G}from"./support/decorators/vmEvent.js";import{tsx as W}from"./support/jsxFactory.js";import{substitute as B}from"../intl/substitute.js";const K="data-field-name";let q=class extends p{constructor(e,t){super(e,t),this._associationsWidgetsMap=new Map,this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._inputsWithChanges=new Set,this._focusedFieldName=null,this._pendingSubtypeChoice=null,this._listObserverNode=null,this._listObserver=new IntersectionObserver((e=>{e.length&&e[0].isIntersecting&&this._incrementRelatedRecordPage()}),{root:window.document}),this._prompt=null,this._featureFormUNAssociationList=null,this.groupDisplay="all",this.headingLevel=2,this.messages=null,this.messagesCommon=null,this.messagesFeature=null,this.messagesTemplates=null,this.viewModel=new M,this._onShowAllRelatedRecordsClick=e=>{const{feature:t,callbacks:i}=this;t&&i?.showAllRelatedRecords&&i.showAllRelatedRecords({parentFeature:t,relationshipId:e})},this._onAddRelatedRecordsClick=(e,t)=>{const{feature:i,callbacks:o}=this;i&&o?.addRelatedRecord&&o.addRelatedRecord({parentFeature:i,relatedLayer:t,relationshipId:e})},this._onFormKeyDown=this._onFormKeyDown.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onGroupToggle=this._onGroupToggle.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentKeyDown=this._onComponentKeyDown.bind(this),this._afterComponentCreate=this._afterComponentCreate.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this)}initialize(){this.addHandles([n((()=>this.feature),(()=>{this._inputsWithChanges.clear(),this._dateComponentMap.clear(),a((()=>!this.viewModel.updating)).then((()=>{const e=this._getFocusableInput("forward");this._syncGroupInputStates(),this._focusedFieldName=e?.name||null,this._attemptFocusOnNextRender=!0}))})),n((()=>this.groupDisplay),(()=>this._syncGroupInputStates())),this.on("submit",(e=>{if(e.invalid.length>0){const[t]=e.invalid;e.invalid.forEach((e=>this._inputsWithChanges.add(e))),this._focusedFieldName=t,this._attemptFocusOnNextRender=!0,this.scheduleRender()}})),n((()=>[this.viewModel.activeRelationshipInput,this._listObserverNode]),(()=>this._onObserverChange())),n((()=>this.viewModel.activeAssociationInput),(e=>{e&&this._featureFormUNAssociationList&&(this._featureFormUNAssociationList.associationInput=e,this._featureFormUNAssociationList.viewModel=e.viewModel)}))])}loadDependencies(){return L({block:()=>import("@esri/calcite-components/dist/components/calcite-block"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch"),"text-area":()=>import("@esri/calcite-components/dist/components/calcite-text-area")})}destroy(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get _relatedRecordsEnabled(){const{callbacks:e}=this;return!(!e||!(e.addRelatedRecord||e.editRelatedRecord||e.showAllRelatedRecords))}get _utilityNetworkAssociationsEnabled(){const{callbacks:e}=this;return!(!e?.viewAssociatedLayers||!e.viewAssociatedFeatures)}get _subtypes(){return c(this.layer)}get associationId(){return this.viewModel.associationId}set associationId(e){this.viewModel.associationId=e}get associatedLayer(){return this.viewModel.associatedLayer}set associatedLayer(e){this.viewModel.associatedLayer=e}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get feature(){return this.viewModel.feature}set feature(e){this.viewModel.feature=e}get formTemplate(){return this.viewModel.formTemplate}set formTemplate(e){this.viewModel.formTemplate=e}get icon(){return"form-field"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get callbacks(){return this.viewModel.callbacks}set callbacks(e){this.viewModel.callbacks=e}get relationshipId(){return this.viewModel.relationshipId}set relationshipId(e){this.viewModel.relationshipId=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get strict(){return this.viewModel.strict}set strict(e){this.viewModel.strict=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get showPrompt(){return e=>{this._prompt?.cancel?.(),this._prompt=e}}set showPrompt(e){this._overrideIfSome("showPrompt",e)}get clearPrompt(){return()=>this._prompt=null}set clearPrompt(e){this._overrideIfSome("clearPrompt",e)}getValues(){return this.viewModel.getValues()}submit(){return this.viewModel.submit()}render(){const{state:e}=this.viewModel;return W("div",{class:this.classes(v.base,j.widget,j.panel)},"ready"===e?this._renderForm():null)}_renderForm(){return W("div",null,W("form",{class:v.form,novalidate:!0,onkeydown:this._onFormKeyDown,onsubmit:this._onFormSubmit},this._renderHeader(),this._renderContent()),this._prompt?W(m,{...this._prompt,headingLevel:this.headingLevel}):void 0)}_renderHeader(){const e=this.viewModel,{formTitle:t,formDescription:i}=e;if(!e.formHeaderVisible)return;const o=null!=t&&W(P,{key:"title",level:this.headingLevel},t),s=null!=i&&W("p",{class:v.description,key:"description"},i);return W("div",{class:v.formHeader},o,s)}_renderContent(){const{viewModel:e}=this;return e.activeRelationshipInput?this._renderRelationshipInput(e.activeRelationshipInput):e.activeAssociationInput?this._renderFeatureFormUtilityNetworkAssociationList():e.inputs.filter(t).filter((e=>e.visible)).map((e=>this._renderInput(e)))}_renderInput(e){return _(e)?this._renderGroup(e):g(e)?this._renderLabeledField(e):b(e)?this._renderRelationshipInput(e):f(e)?this._renderTextElementInput(e):y(e)?this._renderUtilityNetworkAssociationsElementInput(e):void 0}_renderFeatureFormUtilityNetworkAssociationList(){return this._featureFormUNAssociationList?.render()}_selectAssociatedLayer(e){const{feature:t,callbacks:i}=this;t&&i?.viewAssociatedFeatures&&i.viewAssociatedFeatures({associatedLayer:e.layer})}async _selectAssociatedFeature(e){const{feature:t,callbacks:i}=this;t&&i?.selectAssociatedFeature&&await i.selectAssociatedFeature({parentFeature:t,...e})}_onAddAssociation(e){const{feature:t,callbacks:i}=this;t&&i?.addAssociation&&i.addAssociation(e)}_setUpUtilityNetworkAssociationList(){this._featureFormUNAssociationList||(this._featureFormUNAssociationList=new N({onSelectLayer:this._selectAssociatedLayer.bind(this),onSelectFeature:this._selectAssociatedFeature.bind(this),onAddAssociation:this._onAddAssociation.bind(this)}))}_renderUtilityNetworkAssociationsElementInput(e){if(this._utilityNetworkAssociationsEnabled)return this._setUpUtilityNetworkAssociationList(),o(this._associationsWidgetsMap,e,(()=>new h({onSelectAssociationType:({viewModel:t,listType:i})=>{t.activeAssociationType=i;const{feature:o,callbacks:s}=this;o&&s?.viewAssociatedLayers&&s.viewAssociatedLayers({associationId:e.uid})},viewModel:e.associationsViewModel}))).render()}_renderDescriptionOrEmpty(e,t){return null==e?null:W("div",{class:this.classes(v.description),id:t},e)}_renderGroup(e){const{disabled:t,formTemplate:i,headingLevel:o}=this,{description:s,id:n,inputs:a,label:r,open:l}=e,d=a.filter((e=>e.visible)),c=this.viewModel.findField(this._focusedFieldName),u=c?.group===e,p="sequential"===this.groupDisplay;return W("calcite-block",{class:this.classes(v.group,p?v.groupSequential:null,u?v.groupActive:null,t?v.inputDisabled:null),collapsible:!0,"data-group":e,description:s||void 0,disabled:t,heading:r??"",headingLevel:i?.title?$(o):o,id:n,key:n,open:l,onCalciteBlockToggle:({currentTarget:t})=>this._onGroupToggle(t,e)},d.map((e=>this._renderInput(e))))}_getFocusableInput(e,t){const i=C(this.viewModel.inputs);let o;if("backward"===e&&i.reverse(),t)if(_(t)){const e=t.inputs.find((e=>e.visible));o=e?i.indexOf(e):0}else{let s;if(F(t)&&!t.group.open){const i=t.group.inputs.filter(g);s="forward"===e?i[i.length-1]:i[0]}else s=t;o=i.indexOf(s)+1}else o=0;for(let s=o;s<i.length;s++){const e=i[s];if(e.visible&&g(e))return e}return null}_renderLabeledField(e){const{dataType:t,feature:i,label:o,layer:s,required:n}=e,a={"aria-label":n?B(this.messages.requiredFieldLabel,{name:o}):o,class:v.label,key:`${s.id}-${i.uid}-${e.name}`},r=[W("div",{class:v.labelTextContent,key:"labelTextContainer"},o,n?W("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==t?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e)];return"date"===t&&"coded-value"!==e.domain?.type?W("label",{...a},r):W("calcite-label",{...a},r)}_renderFieldInput(e){const{dataType:t,domain:i,inputType:o,name:s}=e,n=this.getCommonInputProps(e);if("coded-value"===i?.type){const t=this.viewModel.getFieldValueOptionsForField(s,this.messages.empty);return"switch"!==o||e.hasInvalidSwitchValue?"radio-buttons"===o?this._renderRadioButtonComponents(e,t.flat(),n):this._renderComboBoxComponent(e,t,n):this._renderSwitchComponent(e,n)}return"datetime-picker"===o||"date"===t?this._renderDateComponents(e,n):"number"===t?this._renderNumberComponent(e,n):this._renderStringComponent(e,n)}_renderStringComponent(e,t){return"text-area"===e.inputType?t.readOnly?W("calcite-input",{...t,loading:e.updating,type:"textarea",onCalciteInputInput:e=>this._saveValueFromComponent(e.currentTarget)}):W("calcite-text-area",{...t,resize:"vertical",onCalciteTextAreaInput:e=>this._saveValueFromComponent(e.currentTarget)}):W("calcite-input",{...t,loading:e.updating,type:"text",onCalciteInputInput:e=>this._saveValueFromComponent(e.currentTarget)})}_renderNumberComponent(e,t){const i=d(e.field),o=i&&""!==t.value?Math.round(parseFloat(t.value)).toString():t.value;return W("calcite-input-number",{...t,integer:i,loading:e.updating,type:"number",value:o,onCalciteInputNumberInput:e=>this._saveValueFromComponent(e.currentTarget)})}_renderDateComponents(e,t){const{field:i}=e;switch(i.type){case"date":return this._renderDateFieldComponents(e,t);case"date-only":return this._renderDateOnlyFieldComponent(e,t);case"time-only":return this._renderTimeOnlyFieldComponent(e,t);case"timestamp-offset":return this._renderTimestampOffsetFieldComponents(e,t);default:return this._renderReadOnlyComponent(e,T(i,t.value,{timeZone:this.timeZone,...x(i)}))}}_renderDateOnlyFieldComponent(e,t){const{range:i,valid:o,value:s}=e,{class:n,key:a,readOnly:r}=t,{rawMax:l,rawMin:d}=i;return W("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!o,class:n,"data-date-part":"date","data-field-name":t[K],key:`${a}-date-input`,max:u(l)?l:void 0,min:u(d)?d:void 0,numberingSystem:A,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:r,value:null!=s?`${s}`:void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.currentTarget)})}_renderTimeOnlyFieldComponent(e,t){const{valid:i,value:o}=e,{class:s,key:n,readOnly:a}=t;return W("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!i,class:s,"data-date-part":"time","data-field-name":t[K],key:`${n}-time-input`,numberingSystem:A,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:a,step:e.timeStep,value:null!=o?`${o}`:void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.currentTarget)})}_renderTimestampOffsetFieldComponents(e,t){const{name:i,range:o,timeZone:s,valid:n,value:a}=e,{class:r,key:l,readOnly:d}=t,{rawMax:c,rawMin:u}=o,p={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!n,numberingSystem:A,overlayPositioning:"fixed",readOnly:d,[K]:i,onfocus:this._onComponentFocus},m=D(c,s),h=D(u,s),_=D(a,s);return W("div",{class:v.dateInputContainer,key:`${l}-date-time-container`},W("calcite-input-date-picker",{...p,class:r,"data-date-part":"date",key:`${l}-date-input`,max:m?.date??void 0,min:h?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:_.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.currentTarget)}),W("calcite-input-time-picker",{...p,class:r,"data-date-part":"time",key:`${l}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:e.timeStep,value:_.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.currentTarget)}),e.includeTimeOffset?W("calcite-input-time-zone",{...p,class:r,"data-date-part":"timeZone",disabled:d,key:`${l}-timezone-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:_.timeZoneOffset??"0",onCalciteInputTimeZoneChange:e=>this._saveValueFromDateComponent(e.currentTarget)}):null)}_renderDateFieldComponents(e,t){const{includeTime:i,name:o,valid:s,value:n}=e,{class:a,key:r,max:l,min:d,readOnly:c}=t,{timeZone:u}=this,p={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentCreateOrUpdate,"aria-invalid":!s,numberingSystem:A,overlayPositioning:"fixed",readOnly:c,[K]:o,onfocus:this._onComponentFocus},m=V(n,u),h=V(l,u),_=V(d,u);return W("div",{class:v.dateInputContainer,key:`${r}-date-time-container`},W("calcite-input-date-picker",{...p,class:a,"data-date-part":"date",key:`${r}-date-input`,max:h?.date??void 0,min:_?.date??void 0,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},value:m.date??void 0,onCalciteInputDatePickerChange:e=>this._saveValueFromDateComponent(e.currentTarget)}),i?W("calcite-input-time-picker",{...p,class:a,"data-date-part":"time",key:`${r}-time-input`,onblur:e=>{this._focusedFieldName=null,this._saveValueFromDateComponent(e.target)},step:1,value:m.time??void 0,onCalciteInputTimePickerChange:e=>this._saveValueFromDateComponent(e.currentTarget)}):null)}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return W("calcite-input",{...i,class:this.classes(v.fieldInput,v.inputDisabled),readOnly:!0,type:"text",value:null!=t?`${t}`:i.value})}_renderComboBoxComponent(e,t,i){const{value:o,name:s}=e,{viewModel:n,_inputsWithChanges:a}=this,r="INSERT"===n.arcadeEditType,l=a.has(s),d=null==o&&(!r||l),c=r&&e.showNoValueOptionEnabled&&!l?()=>{}:i.onblur;return W("calcite-combobox",{...i,allowCustomValues:!1,clearDisabled:!0,disabled:i.readOnly,onblur:c,overlayPositioning:"fixed",selectionMode:"single",onCalciteComboboxChange:({currentTarget:t})=>{d&&0===t.selectedItems.length?this._ignoreDeselectionOfNoValueOption(t):e.isSubtypeField&&0===t.selectedItems.length?t.value=`${e.value}`:this._saveValueFromComponent(t)}},this.renderComboboxOptionsList(e,t))}renderComboboxOptionsList(e,t){const{value:i,name:o}=e,{messages:s,messagesTemplates:n,viewModel:a,_inputsWithChanges:r}=this,[l,d,c]=t.map((e=>e.map((({name:e,value:t})=>W("calcite-combobox-item",{key:`#${t}`,selected:i===t,textLabel:e,value:`${t}`}))))),u=[];d.length>0&&u.push(W("calcite-combobox-item-group",{key:"other",label:n.other},d)),c.length>0&&u.push(W("calcite-combobox-item-group",{key:"unsupported",label:s.subtypes.unsupportedDomainGroupTitle},c)),u.length>0?u.unshift(W("calcite-combobox-item-group",{key:"recommended",label:s.recommended},l)):u.push(...l);const p="INSERT"===a.arcadeEditType,m=r.has(o),h=null==i&&(!p||m);return e.showNoValueOptionEnabled&&u.unshift(W("calcite-combobox-item",{key:"empty-option",selected:h,textLabel:e.showNoValueLabel||s.empty,value:""})),u}_renderRadioButtonComponents(e,t,i){const{name:o,value:s}=e,n=t.map((({name:e,value:t})=>this._renderRadioButtonComponent({key:e,label:e,name:o,value:t,selected:t===s,props:i})));if(e.showNoValueOptionEnabled){const t="",a=e.showNoValueLabel||this.messages.empty,r=s===t||null===s;n.unshift(this._renderRadioButtonComponent({key:"empty-option",label:a,name:o,value:t,selected:r,props:i}))}return W("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:v.inputRadioGroup,"data-field-name":i[K],key:`${i.key}-radio-group`,layout:"vertical",name:i.key,required:i.required},n)}_renderSwitchComponent(e,t){const{value:i}=e,o=!!w(e.element,"switch")&&i===e.element.input.onValue;return W("calcite-switch",{...t,checked:o,class:v.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldName=null},onCalciteSwitchChange:e=>this._saveValueFromComponent(e.currentTarget)})}_renderRadioButtonComponent({key:e,name:t,value:i,selected:o,label:s,props:n}){return W("calcite-label",{class:v.inputRadioLabel,key:e,layout:"inline"},W("calcite-radio-button",{...n,afterCreate:void 0,afterUpdate:void 0,checked:o,class:v.inputRadio,disabled:n.readOnly,name:t,onblur:()=>{this._focusedFieldName=null},value:i,onCalciteRadioButtonChange:({currentTarget:e})=>{e.checked&&this._saveValueFromComponent(e)}}),s)}_renderAuxiliaryText(e){const t=e.name,i=this._inputsWithChanges.has(t)&&!e.submittable?R(e,this.messages,this.timeZone):null!=this.viewModel.contingencyConstraintViolations.get(t)?this.messages.validationErrors.valuesIncompatible:null!=e.valueExpressionExecutor&&e.valueExpressionExecutor.stale?this.messages.valueExpressionError:null;return null!=i?W("calcite-input-message",{icon:!0,status:"invalid"},i):this._inputsWithChanges.has(t)&&e.valueIsOutOfDomain?W("calcite-input-message",{icon:!0,status:"idle"},this.messages.subtypes.fieldOutOfSubtypeDomainWarning):this._renderDescriptionOrEmpty(e.description)}_renderShowAllRelatedRecordsListItem(e){const{featureCount:t,relationshipId:i,showAllActionVisible:o}=e,{callbacks:s}=this;if(!o||!s?.showAllRelatedRecords)return;const n=this.messages;return W("calcite-list-item",{description:B(n.totalCount,{count:t}),label:n.showAll,value:!0,onCalciteListItemSelect:()=>this._onShowAllRelatedRecordsClick(i)},W("calcite-icon",{icon:"list",scale:"s",slot:"content-end"}))}_renderAddRelatedRecordButton(e){const{canAddRelatedFeature:t,relationshipId:i,relatedLayer:o}=e,{messages:s,callbacks:n}=this;if(t&&n?.addRelatedRecord&&o)return W("calcite-button",{alignment:"center",appearance:"outline-fill",class:v.centeredButton,disabled:e.updating||!e.originHasValidKey,iconStart:"plus",key:`${i}-add-button`,onclick:()=>{!e.updating&&e.originHasValidKey&&this._onAddRelatedRecordsClick(i,o)},round:!0,scale:"s",width:"full"},e.relatedLayerIsTable?s.addRecord:s.addFeature)}_renderRelatedRecordListItem(e,t){const{feature:i,description:o,title:s}=e,{feature:n,callbacks:a}=this,{highlightHelper:r}=this.viewModel,l=()=>{r?.removeAll(),a?.editRelatedRecord&&n&&a.editRelatedRecord({parentFeature:n,relationshipId:t,relatedFeature:i})},d=r?()=>r.add(i):void 0,c=r?()=>r.remove(i):void 0;return W("calcite-list-item",{bind:this,description:o,key:`${t}-${i.uid}`,label:s,onclick:l,onmouseenter:d,onmouseleave:c,value:s},W("calcite-icon",{icon:k(i),slot:"content-start"}),W("calcite-icon",{icon:"chevron-right",scale:"s",slot:"content-end"}))}_renderRelationshipInput(e){if(!this._relatedRecordsEnabled||!e.editable)return;const{featureCount:t,relationshipId:i,showAllEnabled:o}=e,s=o?null:this._renderDescriptionOrEmpty(e.description),n=t>0?this._renderRelatedRecordsList(e):e.loaded?e.originHasValidKey?this._renderNoRelatedRecordsNotice():this._renderNoValidOriginKeyNotice(e):void 0;return W("calcite-label",{class:this.classes(v.label,v.relatedRecordsLabel),key:`relationship-${i}-container`},W("div",null,this._renderRelatedRecordsHeaderContainer(e),s,n),this._renderAddRelatedRecordButton(e))}_renderRelatedRecordsHeaderContainer(e){const t=e.updating||!e.loaded;return W("div",{class:v.relatedRecordsHeader,key:`relationship-${e.relationshipId}-header`},W("span",null,e.label),t?W("calcite-loader",{inline:!0,key:"loader",label:this.messagesCommon?.loading,scale:"s",type:"indeterminate"}):void 0)}_renderRelatedRecordsList(e){const{relationshipId:t}=e;return W("calcite-list",{class:v.relatedRecordsList,label:this.messages?.relatedRecordsList},e.relatedFeatureInfos.map((e=>this._renderRelatedRecordListItem(e,t))),this._renderShowAllRelatedRecordsListItem(e),this._renderObserverNode())}_renderNoValidOriginKeyNotice(e){const{messages:t}=this,i=e.relatedLayerIsTable?t.noOriginKeyRecord:t.noOriginKeyFeature,o=e.relationship?.keyField,s=this.viewModel.findField(o),n=e.layer?.fieldsIndex.get(o),a=s?.label||n?.alias||o,r=B(i,{relatedLayerName:e.relatedLayer?.title,originKeyField:a});return W("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},W("div",{slot:"message"},r))}_renderNoRelatedRecordsNotice(){return W("calcite-notice",{icon:"information",kind:"brand",open:!0,scale:"s",width:"full"},W("div",{slot:"message"},this.messagesFeature.noRelatedFeatures))}_renderObserverNode(){if(this.viewModel.activeRelationshipInput?.showAllEnabled)return W("div",{afterCreate:this._afterListObserverCreated,afterRemoved:this._afterListObserverRemoved,bind:this,class:v.listObserver,key:"feature-observer"})}_renderTextElementInput(e){return W("div",{class:v.textElement,innerHTML:e.text,key:e.id})}getCommonInputProps(e){const{disabled:t}=this,{editable:i,hint:o,label:s,maxLength:n,minLength:a,name:r,range:{max:l,min:d},required:c,valid:u,value:p}=e,m=this._inputsWithChanges.has(r),h=!i||t;return{afterCreate:this._afterComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":u?"false":"true",class:this.classes(v.fieldInput,h?v.inputDisabled:null),status:m&&!u?"invalid":"idle",key:r,label:s,max:null!=l?l:void 0,min:null!=d?d:void 0,maxLength:n>-1?n:void 0,minLength:a>-1?a:void 0,placeholder:o??void 0,readOnly:h,required:c,value:null==p?"":`${p}`,onblur:this._onComponentBlur,onfocus:this._onComponentFocus,onkeydown:this._onComponentKeyDown,[K]:r}}_getFieldInputFromHTMLElement(e){return this.viewModel.findField(e.getAttribute(K))}_afterDateComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e),i=e.dataset.datePart,o=this._dateComponentMap.get(t.name);if("valueAsDate"in e&&null!=e.value&&null!=t.value){const i=new ResizeObserver((()=>{switch(e.value=void 0,t.field.type){case"date":e.value=V(t.value,this.timeZone).date??"";break;case"timestamp-offset":e.value=D(t.value,this.timeZone).date??"";break;default:e.value=`${t.value}`}i.unobserve(e)}));i.observe(e)}if(null!=o)switch(i){case"date":o.date=e;break;case"time":o.time=e;break;case"timeZone":o.timeZone=e}else this._dateComponentMap.set(t.name,{[i]:e});this._afterDateComponentCreateOrUpdate(e)}_afterDateComponentCreateOrUpdate(e){this._afterComponentCreateOrUpdate(e)}_afterComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e);O(t)&&null!=e.value&&"setNumberValue"in e&&e.setNumberValue({committing:!1,value:e.value,origin:"direct"}),this._afterComponentCreateOrUpdate(e)}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),o=t||i;o&&this._afterComponentCreateOrUpdate(o)}_afterComponentCreateOrUpdate(e){const{viewModel:t}=this,i=this._getFieldInputFromHTMLElement(e),o=t.findField(this._focusedFieldName);this._attemptFocusOnNextRender&&o===i&&(this._attemptFocusOnNextRender=!1,F(i)&&(i.group.open=!0),H(e))}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._focusedFieldName=i.name}_onComponentBlur(e){const t=e.target;this._focusedFieldName=null;"readOnly"in t&&t.readOnly||this._saveValueFromComponent(t)}_saveValueFromDateComponent(e){const{timeZone:t}=this,i=this._getFieldInputFromHTMLElement(e),o=i.field.type,{name:s,range:n}=i,a=this._dateComponentMap.get(s);if(!a)return;let r=this.viewModel.getValue(s),l=null;"date-only"===o?l=Array.isArray(e.value)?e.value[0]:e.value:"time-only"===o?(r=U(r),l=U(e.value)):l="timestamp-offset"===o?null!=e.value?S({dateComponent:a.date,timeComponent:a.time,timeZoneComponent:a.timeZone,oldValue:r,defaultTimeZone:t}):null:null!=e.value?E({oldValue:r,dateComponent:a.date,timeComponent:a.time,timeZone:t,max:n.max,min:n.min}):null,null!==l&&e.value?r!==l&&this._updateFieldValue(s,l):this._updateFieldValue(s,null)}_saveValueFromComponent(e){const t=this._getFieldInputFromHTMLElement(e),i=this._parseValue(e),o=t.value;t.isSubtypeField&&I(this.layer,o,i)?this._pendingSubtypeChoice||i===o||(this._pendingSubtypeChoice=this._handleSubtypeChoice(t,i)):this._updateFieldValue(t.name,i)}async _handleSubtypeChoice(e,t){const{value:i,name:o}=e,{messages:n,viewModel:a,messagesCommon:r,_subtypes:l}=this;if(this._updateFieldValue(o,t),!l?.length)return;const d=l.find((e=>e.code===t)),c=l.find((e=>e.code===i))?.name??`${i}`;if(!d)return;const u=s();a.pendingSubtypeChoice=u;let p="update-fields";const m=[{label:n.subtypes.useDefaultValuesOption,value:"update-fields"},{label:n.subtypes.keepCurrentValuesOption,value:"keep-existing"}],h={context:"info",title:n.subtypes.changeWarningTitle,message:B(n.subtypes.changeWarning,{originalType:c,newType:d.name}),radios:m,defaultRadioSelection:"update-fields",onRadioSelection:e=>p=e,actions:{primary:{label:r.apply,action:()=>u.resolve(p),type:"positive"},secondary:{label:r.cancel,type:"neutral",action:()=>u.resolve("undo")}},cancel:()=>u.reject()};try{this.showPrompt(h);switch(await u.promise){case"update-fields":a.applySubtypeDefaults(d),this._validateContingenciesForNonNullFields();break;case"keep-existing":this._validateContingenciesForNonNullFields();break;case"undo":this._updateFieldValue(e.name,i)}}finally{a.pendingSubtypeChoice=null,this.clearPrompt(),this._pendingSubtypeChoice=null}}_onComponentKeyDown({key:e,target:t}){const i=this._getFieldInputFromHTMLElement(t);"Enter"===e&&F(i)&&!i.group.open&&(i.group.open=!0)}_updateFieldValue(e,t){const i=this.viewModel.getValue(e);this.viewModel.setValue(e,t),this._inputsWithChanges.add(e);i!==t&&this.viewModel.fieldsWithContingentValues.has(e)&&this._validateContingenciesForNonNullFields()}_validateContingenciesForNonNullFields(){const e=Object.fromEntries(Object.entries(this.getValues()).filter((([e,t])=>null!=t)));this.viewModel.validateContingencyConstraints(e)}_parseValue(e){const t=this._getFieldInputFromHTMLElement(e),i=e.value;return w(t.element,"switch")?e.checked?t.element.input.onValue:t.element.input.offValue:null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):"date"===t.field.type?parseFloat(i):i}_ignoreDeselectionOfNoValueOption(e){const{firstChild:t,selectedItems:o}=e;0===o.length&&t&&"selected"in t?t.selected=!0:i.getLogger(this).warnOnce("Failed to override user attempt to deselect 'No value' option.")}_onGroupToggle(e,t){e.open?(t.open=!0,this._focusedFieldName=this._getFocusableInput("forward",t)?.name||null,this._attemptFocusOnNextRender=!0,"sequential"===this.groupDisplay&&this.viewModel.allGroupInputs.forEach((e=>{e!==t&&(e.open=!1)}))):t.open=!1,this.scheduleRender()}_onFormSubmit(e){e.preventDefault()}_onFormKeyDown(e){"Enter"===e.key&&this.viewModel.submit()}_afterListObserverCreated(e){this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)}_afterListObserverRemoved(){this._listObserverNode=null}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);const e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_incrementRelatedRecordPage(){const e=this.viewModel.activeRelationshipInput;e?.incrementPage()}_syncGroupInputStates(){if("sequential"!==this.groupDisplay)return;const e=this.viewModel.allGroupInputs;if(!e.length)return;const t=e.filter((e=>e.open));0===t.length?e[0].open=!0:t.length>1&&t.slice(1).forEach((e=>e.open=!1))}get test(){return{inputsWithChanges:this._inputsWithChanges,updateValue:this._saveValueFromComponent.bind(this)}}};e([r()],q.prototype,"_listObserverNode",void 0),e([r()],q.prototype,"_relatedRecordsEnabled",null),e([r()],q.prototype,"_utilityNetworkAssociationsEnabled",null),e([r()],q.prototype,"_prompt",void 0),e([r()],q.prototype,"_subtypes",null),e([r()],q.prototype,"associationId",null),e([r()],q.prototype,"associatedLayer",null),e([r()],q.prototype,"disabled",null),e([r()],q.prototype,"feature",null),e([r()],q.prototype,"_featureFormUNAssociationList",void 0),e([r()],q.prototype,"formTemplate",null),e([r()],q.prototype,"groupDisplay",void 0),e([r()],q.prototype,"headingLevel",void 0),e([r()],q.prototype,"icon",null),e([r()],q.prototype,"label",null),e([r()],q.prototype,"layer",null),e([r()],q.prototype,"map",null),e([r(),Z("esri/widgets/FeatureForm/t9n/FeatureForm")],q.prototype,"messages",void 0),e([r(),Z("esri/t9n/common")],q.prototype,"messagesCommon",void 0),e([r(),Z("esri/widgets/Feature/t9n/Feature")],q.prototype,"messagesFeature",void 0),e([r(),Z("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],q.prototype,"messagesTemplates",void 0),e([r()],q.prototype,"callbacks",null),e([r()],q.prototype,"relationshipId",null),e([r()],q.prototype,"spatialReference",null),e([r()],q.prototype,"strict",null),e([r()],q.prototype,"timeZone",null),e([r()],q.prototype,"showPrompt",null),e([r()],q.prototype,"clearPrompt",null),e([r(),G(["value-change","submit"])],q.prototype,"viewModel",void 0),e([r()],q.prototype,"test",null),q=e([l("esri.widgets.FeatureForm")],q);const z=q;export{z as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.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{equals as s,isSome as i}from"../../../core/arrayUtils.js";import a from"../../../core/Collection.js";import o from"../../../core/Error.js";import{clone as n}from"../../../core/lang.js";import u from"../../../core/Logger.js";import p from"../../../core/ReactiveMap.js";import{watch as l,when as h}from"../../../core/reactiveUtils.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{geometryTypes as y}from"../../../geometry/support/typeUtils.js";import{isSubtypeGroupLayer as m}from"../../../layers/support/layerUtils.js";import _ from"../../../rest/support/AttachmentQuery.js";import f from"../../../rest/support/RelationshipQuery.js";import g from"../../../time/TimeExtent.js";import{isIFeatureTableSupportedLayerWithAttachments as b,isIFeatureTableSupportedLayerWithAttachmentsEditing as v,isIFeatureTableSupportedLayerWithEditing as O,isIFeatureTableSupportedLayerWithRelationships as A,findRelatedLayer as I}from"./tableUtils.js";let j=class extends r{constructor(e){super(e),this._attachmentsOperationQueue=new a,this._defaultOutFields=["*"],this._editOperationQueue=new a,this._loaded=!1,this._loadError=!1,this._loading=!1,this._objectIdCache=new a,this._queryOperationQueue=new a,this.attachmentsEnabled=!1,this.count=0,this.failures=new a,this.filterGeometry=null,this.initialSize=null,this.layer=null,this.objectIds=null,this.outFields=null,this.pageCache=new p,this.pageSize=50,this.relationshipConfig=null,this.relatedRecordsEnabled=!1,this.returnGeometry=!1,this.returnZ=!1,this.returnM=!1,this.sortOrders=[],this.timeExtent=null,this.view=null,this.where=null}initialize(){this.addHandles([l((()=>[this.filterGeometry,this.layer,this.objectIds,this.outFields,this.pageSize,this.relationshipConfig,this.returnGeometry,this.returnM,this.returnZ,this.timeExtent,this.where]),(()=>this._reset())),l((()=>this.orderByFields),(()=>this._clearCaches()),{equals:s}),h((()=>this.attachmentsEnabled),(()=>this._reset())),h((()=>this.relatedRecordsEnabled),(()=>this._reset()))])}destroy(){this.layer=null,this.itemCache?.destroy(),this.failures?.destroy()}get _capabilities(){const{layer:e}=this;return e?.effectiveCapabilities??e?.capabilities}get _effectiveReturnZ(){return this.returnZ&&this.supportsZ}get _effectiveReturnM(){return this.returnM&&this.supportsM}get _layerWithAttachments(){const{layer:e}=this;return e&&this._capabilities&&this.attachmentsEnabled&&this.supportsAttachments&&b(e)?e:null}get _layerWithAttachmentsEditing(){const{_layerWithAttachments:e}=this;return e&&v(e)&&this.supportsEditing?e:null}get _layerWithEditing(){const e=this.layer;return O(e)&&this.supportsEditing?e:null}get _layerWithRelationships(){const e=this.layer;return A(e)&&this.supportsQueryRelated?e:null}get _relatedLayer(){return this.relationshipConfig?.relatedLayer}get _relatedLayerCapabilities(){const{_relatedLayer:e}=this;return e?.effectiveCapabilities??e?.capabilities}get _relatedLayerSupportsCacheHint(){return!!this._relatedLayerCapabilities?.queryRelated?.supportsCacheHint}get _relatedLayerSupportsQuery(){return!!this._relatedLayerCapabilities?.operations.supportsQuery}get _relatedLayerSupportsQueryRelated(){const{_relatedLayerCapabilities:e}=this;return!!e?.queryRelated?.supportsCount&&!!e?.queryRelated?.supportsPagination}get _sortedFieldNames(){return this.sortOrders.map((({fieldName:e})=>e))}get _canUseRelatedLayer(){return!(!this._relatedLayerSupportsQuery||!this._relatedLayerSupportsQueryRelated)}get canAddRelatedFeature(){const{state:e,relationship:t,supportsAdd:r,supportsEditing:s}=this;if("loaded"!==e||!t||!r||!s)return!1;const{count:i}=this,{cardinality:a,role:o}=t,n=i>0;return("one-to-one"!==a||!n)&&("one-to-many"!==a||"origin"!==o||!n)}get effectiveOutFields(){const{layer:e,outFields:t}=this;if(!e||!t?.length)return this._defaultOutFields;const r=[];t.forEach((t=>{const s=e.fieldsIndex.normalizeFieldName(t);s&&r.push(s)}));const{objectIdField:s}=e,i=e.fieldsIndex.normalizeFieldName(s)??s;return i&&!r.includes(i)&&r.unshift(i),r}get effectiveTimeExtent(){const{layer:e,timeExtent:t}=this;return t||e&&"timeExtent"in e&&e.timeExtent||null}get effectiveWhere(){return this.where||this.layer?.definitionExpression||"1=1"}get itemCache(){return new a({items:[...this.pageCache.values()].flat()})}get layerView(){const{layer:e,view:t}=this;if(!e||!t)return null;const r="sublayer"===e.type?e.parent:e;return t.allLayerViews.find((e=>e.layer===r))}get orderByFields(){const{_sortedFieldNames:e,layer:t,sortOrders:r}=this,s=r.filter((({fieldName:t,direction:r},s)=>e.indexOf(t)===s&&null!=r)).map((({fieldName:e,direction:t})=>`${e} ${t?.toUpperCase()}`));if(t&&!s.length&&!t.objectIdField&&t.fields?.length){const e=t.fields.find((e=>e.name));if(e){const r=t.fieldsIndex.normalizeFieldName(e.name);r&&s.push(`${r} ASC`)}}return s}get querying(){return this._queryOperationQueue.length>0}get relationship(){const{relationshipConfig:e}=this;return null==e?.relationshipId?null:this.relationships?.find((t=>t.id===e.relationshipId))}get relationshipIds(){return this.relationships?.map((e=>e.id))??[]}get relationshipInfos(){const{_layerWithRelationships:e,relatedRecordsEnabled:t,relationships:r,view:s}=this,i=[];return t&&e?.loaded&&s?.map&&r?.length?(r.forEach((t=>{const r=I(e,s,t);r&&(r.load(),i.push({layer:e,relatedLayer:r,relationshipId:t.id}))})),i):i}get relationships(){return this._layerWithRelationships?.relationships}get state(){const{layer:e,_loaded:t,_loadError:r,_loading:s}=this;return!e||e.destroyed?"disabled":r||e.loadError?"error":"loaded"===e.loadStatus&&t?"loaded":s?"loading":"ready"}get supportsAdd(){return!!this._capabilities?.operations.supportsAdd}get supportsAddingAttachments(){return!(!this._layerWithAttachmentsEditing||!this.supportsAdd)}get supportsAttachments(){const{_capabilities:e}=this;return!(!e?.data?.supportsAttachment||!e?.operations.supportsQueryAttachments)}get supportsCacheHint(){return!!this._capabilities?.query?.supportsCacheHint}get supportsCacheHintQueryRelated(){return!!this._capabilities?.queryRelated?.supportsCacheHint}get supportsDelete(){return!!this._capabilities?.operations.supportsDelete}get supportsDeletingAttachments(){return!(!this._layerWithAttachmentsEditing||!this.supportsDelete)}get supportsEditing(){return!!this._capabilities?.operations.supportsEditing}get supportsM(){return!!this.layer?.hasM&&!!this._capabilities?.data?.supportsM}get supportsOrderBy(){return!!this._capabilities?.query?.supportsOrderBy}get supportsPagination(){return!!this._capabilities?.query?.supportsPagination}get supportsQuery(){return!!this._capabilities?.operations.supportsQuery}get supportsQueryRelated(){const{_capabilities:e}=this;return!!e?.queryRelated?.supportsCount&&!!e?.queryRelated?.supportsPagination}get supportsResizeAttachments(){const{_capabilities:e}=this;return!(!this.supportsAttachments||!e?.attachment?.supportsResize)}get supportsUpdate(){return!!this._capabilities?.operations.supportsUpdate}get supportsUpdateAttachments(){return!(!this._layerWithAttachmentsEditing||!this.supportsUpdate)}get supportsZ(){return!!this.layer?.hasZ&&!!this._capabilities?.data?.supportsZ}get syncing(){return this.syncingFeatureEdits||this.syncingAttachmentEdits}get syncingAttachmentEdits(){return this._attachmentsOperationQueue.length>0}get syncingFeatureEdits(){return this._editOperationQueue.length>0}async addAttachment(e,t){const{_layerWithAttachmentsEditing:r}=this;if(!r||!this.supportsAddingAttachments)return{};const s=await this._queueAttachmentsOperation(e,(()=>r.addAttachment(this._createBaseGraphic(r,e),t)));return this._ensureArrayContent(s)}async deleteAttachments(e,t){const{_layerWithAttachmentsEditing:r}=this;if(!r||!this.supportsDeletingAttachments||!t.length)return[];const s=await this._queueAttachmentsOperation(e,(()=>r.deleteAttachments(this._createBaseGraphic(r,e),t)));return this._ensureArray(s)}async deleteRowsByObjectId(e){const{_layerWithEditing:t}=this;if(!this.supportsDelete||!t)throw new o("store:delete-error","Delete is not supported.");const r=e.map((e=>this.getItemByObjectId(e)?.feature)).filter(i);return this._queueEditOperation((()=>t.applyEdits({deleteFeatures:r})))}async fetchItems(e){const{page:t}=e,{pageSize:r}=this,s=t*r,i=s+r,{layer:a,state:o}=this;return a&&"loaded"===o?this._query({layer:a,start:s,num:i,page:t,pageSize:r}):[]}async getAttachmentsByObjectId(e,t){const r=this.getItemByObjectId(e)?.attachments??[];if(!r.length&&t){return(await this._queryAttachments([e]))[e]??[]}return r}getItemByObjectId(e){for(const t of this.pageCache.values())for(const r of t)if(r.objectId===e)return r}getItemIndexByObjectId(e){const{pageCache:t,pageSize:r}=this,s=t.entries();let i=-1;for(const[a,o]of s)if(o.some(((t,s)=>{const o=t.objectId===e;return o&&(i=a*r+s),o})),i>-1)break;return i}async load(){const{layer:e}=this;if(!this._loading&&!this._loaded&&e){this._reset(),this._loading=!0;try{await e.load(),e.parent&&m(e.parent)&&await e.parent.loadAll(),await e.when();const t=this.initialSize;this.initialSize=null,await this.refresh(t),this._loaded=!0,this._loading=!1}catch(t){throw this._reset(),this._loadError=!0,this._logError("store:load-error","An error occurred."),t}}}async query(e){const{state:t}=this;return this.supportsQuery&&"loaded"===t?this._query(e):[]}async refresh(e){this._clearCaches(),await this._syncCount(e),await this._syncObjectIdCache()}async reset(){this._reset()}async updateAttachment(e,t,r){const{_layerWithAttachmentsEditing:s}=this;if(!s||!this.supportsUpdateAttachments)return{};const i=await this._queueAttachmentsOperation(e,(()=>s.updateAttachment(this._createBaseGraphic(s,e),t,r)));return this._ensureArrayContent(i)}async updateItem(e){const{_sortedFieldNames:t}=this,r=e.updates.map((({fieldName:e})=>e)),s=await this._update(e);return!s.updateFeatureResults.find((e=>e.error))&&r.some((e=>t.includes(e)))&&this._clearCaches(),s}async verifyFeaturesByObjectId(e){const{layer:t,state:r}=this;if(!t||"loaded"!==r)return[];const{objectIdField:s}=t,i=await this._verifyFeaturesByObjectId(e);return e.map((e=>i.some((t=>{const r=t.getObjectId()??t.attributes[s];return e===r}))))}_clearCaches(){this.pageCache.clear(),this._objectIdCache.removeAll()}_createBaseGraphic(e,r){return new t({attributes:{[e.objectIdField]:r}})}_ensureArray(e){return Array.isArray(e)?e:[e]}_ensureArrayContent(e){return Array.isArray(e)?e[0]:e}_getObjectIdsForPage(e,t){const r=this._objectIdCache.toArray();return r.length>=e+t?r.slice(e,e+t):r.slice(e)}_logError(e,t){u.getLogger(this).error(e,t)}_reset(){this._clearCaches(),this.failures.removeAll(),this._attachmentsOperationQueue.removeAll(),this._editOperationQueue.removeAll(),this._queryOperationQueue.removeAll(),this._loading=!1,this._loaded=!1,this._loadError=!1,this._set("count",0)}async _syncCount(e){null==e?await this._queryCount().then((e=>this._set("count",e))):this._set("count",e)}async _syncObjectIdCache(){if(this.supportsPagination)return;const e=await this._queryObjectIds();this._objectIdCache.removeAll(),this._objectIdCache.addMany(e)}async _verifyFeaturesByObjectId(e){const{layer:t}=this;if(!t||!this.supportsQuery)throw new o("store:query-error","Layer does not support query operation.");const{effectiveTimeExtent:r,effectiveWhere:s,orderByFields:i,supportsCacheHint:a,supportsOrderBy:n}=this,u=t.createQuery();u.where=s,u.timeExtent=r,u.returnGeometry=!1,u.objectIds=e.length?e:void 0,u.outFields=[t.objectIdField],n&&(u.orderByFields=i),a&&(u.cacheHint=!0);return(await t.queryFeatures(u)).features}async _update(e){const{objectId:r,updates:s}=e,{_layerWithEditing:i}=this;if(!this.supportsUpdate||!i)throw new o("store:update-error","Update is not supported.");const a=this.getItemByObjectId(r)?.feature;if(!a)throw new o("store:update-error","Feature with provided 'objectId' not found.");const u=n(a.attributes);s.forEach((({fieldName:e,value:t})=>u[e]=t));const p=new t({attributes:u}),l=i.applyEdits({updateFeatures:[p]}).then((e=>{const{updateFeatureResults:t}=e,r=t.find((e=>!!e.error));if(r)throw r.error;return t.length&&(a.attributes=u),e}));return this._queueEditOperation((()=>l))}_prepareFeatureData(e){const{attachments:t,features:r,layer:s,relatedRecords:i}=e,a=s.objectIdField;return r.map((e=>{const r=e.getObjectId()??e.attributes[a],o=[];return e.layer||e.sourceLayer||(e.layer=s,e.sourceLayer=s),i.forEach(((e,t)=>{o.push({relationshipId:t,count:e[r]??0})})),{objectId:r,feature:e,attachments:t[r]??null,relatedRecords:o}}))}async _query(e){const{page:t,refresh:r}=e;!0===r&&await this.refresh();const s=this.pageCache.get(t);if(s)return s;const i=await this._queryPage(e);return this.pageCache.set(t,i),i}_queryAttachments(e){const{_layerWithAttachments:t,effectiveWhere:r}=this;return t?e.some((e=>"number"!=typeof e))?Promise.reject(new o("invalid-object-id","Only numeric object ids are valid to query attachments")):t.queryAttachments(new _({objectIds:e,where:r,returnMetadata:!0})):Promise.resolve({})}async _queryCount(){const{_relatedLayerSupportsCacheHint:e,layer:t,relationshipConfig:r,supportsCacheHint:s}=this;if(!t)return 0;if(r&&this._canUseRelatedLayer){const{objectId:t,relatedLayer:s,relationshipId:i}=r;return(await s.queryRelatedFeaturesCount(new f({cacheHint:e,relationshipId:i,objectIds:[t]})))[t]??0}const{effectiveTimeExtent:i,effectiveWhere:a,filterGeometry:o,objectIds:n}=this,u=t.createQuery();return u.geometry=o,u.returnGeometry=!1,u.where=a,u.timeExtent=i,u.objectIds=n?.length?n:void 0,s&&(u.cacheHint=!0),t.queryFeatureCount(u)}async _queryFeatures(e){const{relationshipConfig:t}=this;if(t&&this._canUseRelatedLayer)return this._queryRelatedFeatures(e,t);const{_effectiveReturnM:r,_effectiveReturnZ:s,effectiveOutFields:i,effectiveTimeExtent:a,effectiveWhere:o,filterGeometry:n,objectIds:u,orderByFields:p,pageSize:l,returnGeometry:h,supportsCacheHint:d,supportsOrderBy:c,supportsPagination:y}=this,{layer:m,start:_}=e,f=u?.length,g=m.createQuery();g.returnGeometry=h,g.outFields=i,g.returnM=r,g.returnZ=s,y?(g.start=_,g.num=l,g.where=o,g.timeExtent=a,g.objectIds=f?u:void 0):g.objectIds=f?u:this._getObjectIdsForPage(_,l??0),c&&(g.orderByFields=p),n&&(g.geometry=n),d&&(g.cacheHint=!0);return(await m.queryFeatures(g)).features}_queryObjectIds(){const{effectiveTimeExtent:e,effectiveWhere:t,filterGeometry:r,layer:s,objectIds:i,orderByFields:a,supportsCacheHint:o,supportsOrderBy:n}=this;if(!s)return Promise.resolve([]);const u=s.createQuery();return u.geometry=r,u.outFields=[s.objectIdField],u.returnGeometry=!1,u.where=t,u.timeExtent=e,u.objectIds=i?.length?i:void 0,n&&(u.orderByFields=a),o&&(u.cacheHint=!0),s.queryObjectIds(u)}async _queryPage(e){const{layer:t}=e;return this._queueQueryOperation((async()=>{const r=await this._queryFeatures(e),s=r.map((e=>e.getObjectId()??e.attributes[t.objectIdField])),i=await this._queryAttachments(s),a=await this._queryRelatedCounts(s);return this._prepareFeatureData({layer:t,features:r,attachments:i,relatedRecords:a})||[]}))}async _queryRelatedCounts(e){const{_layerWithRelationships:t,relationshipIds:r,supportsCacheHintQueryRelated:s}=this,i=new Map;return t&&e?.length&&r.length?(await Promise.allSettled(r.map((async r=>{const a=await t.queryRelatedFeaturesCount(new f({cacheHint:s,relationshipId:r,objectIds:e}));i.set(r,a)}))),i):i}async _queryRelatedFeatures(e,t){const{_defaultOutFields:r,_effectiveReturnM:s,_effectiveReturnZ:i,orderByFields:a,pageSize:o,returnGeometry:n,supportsCacheHint:u}=this,{layer:p,start:l}=e,{objectId:h,relatedLayer:d,relationshipId:c}=t,y=p.createQuery(),m=new f({cacheHint:u,num:o,objectIds:[h],orderByFields:a,outFields:r,relationshipId:c,returnGeometry:n,returnM:s,returnZ:i,start:l,where:y.where??void 0}),_=await d.queryRelatedFeatures(m);return _[h]?.features||[]}_queueAttachmentsOperation(e,t){return this._attachmentsOperationQueue.push(t),t().then((async r=>{this._attachmentsOperationQueue.remove(t);const s=this._ensureArray(r),i=s.some((e=>e.error)),a=this.getItemByObjectId(e);if(a&&(!i||s.length>1)){const t=await this._queryAttachments([e]);a.attachments=t[e]}return r})).catch((async r=>{this._logError("store:attachment-error","An error occurred.");const s={error:r,retry:()=>{this.failures.remove(s),this._queueAttachmentsOperation(e,t)},cancel:()=>this.failures.remove(s)};throw this.failures.add(s),this._attachmentsOperationQueue.remove(t),r}))}_queueEditOperation(e){return this._editOperationQueue.push(e),e().then((t=>(this._editOperationQueue.remove(e),t))).catch((t=>{this._logError("store:edit-error","An error occurred.");const r={error:t,retry:()=>{this.failures.remove(r),this._queueEditOperation(e)},cancel:()=>this.failures.remove(r)};throw this.failures.add(r),this._editOperationQueue.remove(e),t}))}_queueQueryOperation(e){return this._queryOperationQueue.push(e),e().then((t=>this._queryOperationQueue.includes(e)?t:[])).catch((t=>{this._logError("store:query-error","An error occurred.");const r={error:t,retry:()=>{this.failures.remove(r),this._queueQueryOperation(e)},cancel:()=>this.failures.remove(r)};return this.failures.add(r),[]})).then((t=>(this._queryOperationQueue.remove(e),t)))}};e([d()],j.prototype,"_attachmentsOperationQueue",void 0),e([d({readOnly:!0})],j.prototype,"_capabilities",null),e([d()],j.prototype,"_defaultOutFields",void 0),e([d()],j.prototype,"_editOperationQueue",void 0),e([d()],j.prototype,"_effectiveReturnZ",null),e([d()],j.prototype,"_effectiveReturnM",null),e([d({readOnly:!0})],j.prototype,"_layerWithAttachments",null),e([d({readOnly:!0})],j.prototype,"_layerWithAttachmentsEditing",null),e([d({readOnly:!0})],j.prototype,"_layerWithEditing",null),e([d({readOnly:!0})],j.prototype,"_layerWithRelationships",null),e([d()],j.prototype,"_loaded",void 0),e([d()],j.prototype,"_loadError",void 0),e([d()],j.prototype,"_loading",void 0),e([d()],j.prototype,"_objectIdCache",void 0),e([d()],j.prototype,"_queryOperationQueue",void 0),e([d({readOnly:!0})],j.prototype,"_relatedLayer",null),e([d({readOnly:!0})],j.prototype,"_relatedLayerCapabilities",null),e([d({readOnly:!0})],j.prototype,"_relatedLayerSupportsCacheHint",null),e([d()],j.prototype,"_relatedLayerSupportsQuery",null),e([d()],j.prototype,"_relatedLayerSupportsQueryRelated",null),e([d()],j.prototype,"_sortedFieldNames",null),e([d()],j.prototype,"_canUseRelatedLayer",null),e([d()],j.prototype,"attachmentsEnabled",void 0),e([d()],j.prototype,"canAddRelatedFeature",null),e([d({readOnly:!0})],j.prototype,"count",void 0),e([d()],j.prototype,"effectiveOutFields",null),e([d()],j.prototype,"effectiveTimeExtent",null),e([d()],j.prototype,"effectiveWhere",null),e([d({readOnly:!0})],j.prototype,"failures",void 0),e([d({types:y})],j.prototype,"filterGeometry",void 0),e([d()],j.prototype,"initialSize",void 0),e([d({readOnly:!0})],j.prototype,"itemCache",null),e([d()],j.prototype,"layer",void 0),e([d()],j.prototype,"layerView",null),e([d()],j.prototype,"objectIds",void 0),e([d()],j.prototype,"orderByFields",null),e([d()],j.prototype,"outFields",void 0),e([d({readOnly:!0})],j.prototype,"pageCache",void 0),e([d()],j.prototype,"pageSize",void 0),e([d({readOnly:!0})],j.prototype,"querying",null),e([d()],j.prototype,"relationship",null),e([d()],j.prototype,"relationshipConfig",void 0),e([d()],j.prototype,"relationshipIds",null),e([d()],j.prototype,"relationshipInfos",null),e([d()],j.prototype,"relationships",null),e([d()],j.prototype,"relatedRecordsEnabled",void 0),e([d()],j.prototype,"returnGeometry",void 0),e([d()],j.prototype,"returnZ",void 0),e([d()],j.prototype,"returnM",void 0),e([d()],j.prototype,"sortOrders",void 0),e([d({readOnly:!0})],j.prototype,"state",null),e([d()],j.prototype,"supportsAdd",null),e([d()],j.prototype,"supportsAddingAttachments",null),e([d()],j.prototype,"supportsAttachments",null),e([d()],j.prototype,"supportsCacheHint",null),e([d()],j.prototype,"supportsCacheHintQueryRelated",null),e([d()],j.prototype,"supportsDelete",null),e([d()],j.prototype,"supportsDeletingAttachments",null),e([d()],j.prototype,"supportsEditing",null),e([d()],j.prototype,"supportsM",null),e([d()],j.prototype,"supportsOrderBy",null),e([d()],j.prototype,"supportsPagination",null),e([d()],j.prototype,"supportsQuery",null),e([d()],j.prototype,"supportsQueryRelated",null),e([d()],j.prototype,"supportsResizeAttachments",null),e([d()],j.prototype,"supportsUpdate",null),e([d()],j.prototype,"supportsUpdateAttachments",null),e([d()],j.prototype,"supportsZ",null),e([d({readOnly:!0})],j.prototype,"syncing",null),e([d({readOnly:!0})],j.prototype,"syncingAttachmentEdits",null),e([d({readOnly:!0})],j.prototype,"syncingFeatureEdits",null),e([d({type:g})],j.prototype,"timeExtent",void 0),e([d()],j.prototype,"view",void 0),e([d()],j.prototype,"where",void 0),j=e([c("esri.widgets.FeatureTable.support.FeatureStore")],j);const w=j;export{w as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Graphic.js";import r from"../../../core/Accessor.js";import{equals as s,isSome as i}from"../../../core/arrayUtils.js";import a from"../../../core/Collection.js";import o from"../../../core/Error.js";import{clone as n}from"../../../core/lang.js";import u from"../../../core/Logger.js";import p from"../../../core/ReactiveMap.js";import{watch as l,when as h}from"../../../core/reactiveUtils.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{geometryTypes as y}from"../../../geometry/support/typeUtils.js";import{isSubtypeGroupLayer as m}from"../../../layers/support/layerUtils.js";import _ from"../../../rest/support/AttachmentQuery.js";import f from"../../../rest/support/RelationshipQuery.js";import g from"../../../time/TimeExtent.js";import{isIFeatureTableSupportedLayerWithAttachments as b,isIFeatureTableSupportedLayerWithAttachmentsEditing as v,isIFeatureTableSupportedLayerWithEditing as O,isIFeatureTableSupportedLayerWithRelationships as A,findRelatedLayer as I}from"./tableUtils.js";let j=class extends r{constructor(e){super(e),this._attachmentsOperationQueue=new a,this._defaultOutFields=["*"],this._editOperationQueue=new a,this._loaded=!1,this._loadError=!1,this._loading=!1,this._objectIdCache=new a,this._queryOperationQueue=new a,this.attachmentsEnabled=!1,this.count=0,this.failures=new a,this.filterGeometry=null,this.initialSize=null,this.layer=null,this.objectIds=null,this.outFields=null,this.pageCache=new p,this.pageSize=50,this.relationshipConfig=null,this.relatedRecordsEnabled=!1,this.returnGeometry=!1,this.returnZ=!1,this.returnM=!1,this.sortOrders=[],this.timeExtent=null,this.view=null,this.where=null}initialize(){this.addHandles([l((()=>[this.filterGeometry,this.layer,this.objectIds,this.outFields,this.pageSize,this.relationshipConfig,this.returnGeometry,this.returnM,this.returnZ,this.timeExtent,this.where]),(()=>this._reset())),l((()=>this.orderByFields),(()=>this._clearCaches()),{equals:s}),h((()=>this.attachmentsEnabled),(()=>this._reset())),h((()=>this.relatedRecordsEnabled),(()=>this._reset()))])}destroy(){this.layer=null,this.itemCache?.destroy(),this.failures?.destroy()}get _capabilities(){const{layer:e}=this;return e?.effectiveCapabilities??e?.capabilities}get _effectiveReturnZ(){return this.returnZ&&this.supportsZ}get _effectiveReturnM(){return this.returnM&&this.supportsM}get _layerWithAttachments(){const{layer:e}=this;return e&&this._capabilities&&this.attachmentsEnabled&&this.supportsAttachments&&b(e)?e:null}get _layerWithAttachmentsEditing(){const{_layerWithAttachments:e}=this;return e&&v(e)&&this.supportsEditing?e:null}get _layerWithEditing(){const e=this.layer;return O(e)&&this.supportsEditing?e:null}get _layerWithRelationships(){const e=this.layer;return A(e)&&this.supportsQueryRelated?e:null}get _relatedLayer(){return this.relationshipConfig?.relatedLayer}get _relatedLayerCapabilities(){const{_relatedLayer:e}=this;return e?.effectiveCapabilities??e?.capabilities}get _relatedLayerSupportsCacheHint(){return!!this._relatedLayerCapabilities?.queryRelated?.supportsCacheHint}get _relatedLayerSupportsQuery(){return!!this._relatedLayerCapabilities?.operations.supportsQuery}get _relatedLayerSupportsQueryRelated(){const{_relatedLayerCapabilities:e}=this;return!!e?.queryRelated?.supportsCount&&!!e?.queryRelated?.supportsPagination}get _sortedFieldNames(){return this.sortOrders.map((({fieldName:e})=>e))}get _subtypeCode(){return this.layer?.subtypeCode??null}get _subtypeField(){const{layer:e}=this;return m(e?.parent)?e.subtypeField:null}get _canUseRelatedLayer(){return!(!this._relatedLayerSupportsQuery||!this._relatedLayerSupportsQueryRelated)}get canAddRelatedFeature(){const{state:e,relationship:t,supportsAdd:r,supportsEditing:s}=this;if("loaded"!==e||!t||!r||!s)return!1;const{count:i}=this,{cardinality:a,role:o}=t,n=i>0;return("one-to-one"!==a||!n)&&("one-to-many"!==a||"origin"!==o||!n)}get effectiveOutFields(){const{layer:e,outFields:t}=this;if(!e||!t?.length)return this._defaultOutFields;const r=[];t.forEach((t=>{const s=e.fieldsIndex.normalizeFieldName(t);s&&r.push(s)}));const{objectIdField:s}=e,i=e.fieldsIndex.normalizeFieldName(s)??s;return i&&!r.includes(i)&&r.unshift(i),r}get effectiveTimeExtent(){const{layer:e,timeExtent:t}=this;return t||e&&"timeExtent"in e&&e.timeExtent||null}get effectiveWhere(){return this.where||this.layer?.definitionExpression||"1=1"}get itemCache(){return new a({items:[...this.pageCache.values()].flat()})}get layerView(){const{layer:e,view:t}=this;if(!e||!t)return null;const r="sublayer"===e.type?e.parent:e;return t.allLayerViews.find((e=>e.layer===r))}get orderByFields(){const{_sortedFieldNames:e,layer:t,sortOrders:r}=this,s=r.filter((({fieldName:t,direction:r},s)=>e.indexOf(t)===s&&null!=r)).map((({fieldName:e,direction:t})=>`${e} ${t?.toUpperCase()}`));if(t&&!s.length&&!t.objectIdField&&t.fields?.length){const e=t.fields.find((e=>e.name));if(e){const r=t.fieldsIndex.normalizeFieldName(e.name);r&&s.push(`${r} ASC`)}}return s}get querying(){return this._queryOperationQueue.length>0}get relationship(){const{relationshipConfig:e}=this;return null==e?.relationshipId?null:this.relationships?.find((t=>t.id===e.relationshipId))}get relationshipIds(){return this.relationships?.map((e=>e.id))??[]}get relationshipInfos(){const{_layerWithRelationships:e,relatedRecordsEnabled:t,relationships:r,view:s}=this,i=[];return t&&e?.loaded&&s?.map&&r?.length?(r.forEach((t=>{const r=I(e,s,t);r&&(r.load(),i.push({layer:e,relatedLayer:r,relationshipId:t.id}))})),i):i}get relationships(){return this._layerWithRelationships?.relationships}get state(){const{layer:e,_loaded:t,_loadError:r,_loading:s}=this;return!e||e.destroyed?"disabled":r||e.loadError?"error":"loaded"===e.loadStatus&&t?"loaded":s?"loading":"ready"}get supportsAdd(){return!!this._capabilities?.operations.supportsAdd}get supportsAddingAttachments(){return!(!this._layerWithAttachmentsEditing||!this.supportsAdd)}get supportsAttachments(){const{_capabilities:e}=this;return!(!e?.data?.supportsAttachment||!e?.operations.supportsQueryAttachments)}get supportsCacheHint(){return!!this._capabilities?.query?.supportsCacheHint}get supportsCacheHintQueryRelated(){return!!this._capabilities?.queryRelated?.supportsCacheHint}get supportsDelete(){return!!this._capabilities?.operations.supportsDelete}get supportsDeletingAttachments(){return!(!this._layerWithAttachmentsEditing||!this.supportsDelete)}get supportsEditing(){return!!this._capabilities?.operations.supportsEditing}get supportsM(){return!!this.layer?.hasM&&!!this._capabilities?.data?.supportsM}get supportsOrderBy(){return!!this._capabilities?.query?.supportsOrderBy}get supportsPagination(){return!!this._capabilities?.query?.supportsPagination}get supportsQuery(){return!!this._capabilities?.operations.supportsQuery}get supportsQueryRelated(){const{_capabilities:e}=this;return!!e?.queryRelated?.supportsCount&&!!e?.queryRelated?.supportsPagination}get supportsResizeAttachments(){const{_capabilities:e}=this;return!(!this.supportsAttachments||!e?.attachment?.supportsResize)}get supportsUpdate(){return!!this._capabilities?.operations.supportsUpdate}get supportsUpdateAttachments(){return!(!this._layerWithAttachmentsEditing||!this.supportsUpdate)}get supportsZ(){return!!this.layer?.hasZ&&!!this._capabilities?.data?.supportsZ}get syncing(){return this.syncingFeatureEdits||this.syncingAttachmentEdits}get syncingAttachmentEdits(){return this._attachmentsOperationQueue.length>0}get syncingFeatureEdits(){return this._editOperationQueue.length>0}async addAttachment(e,t){const{_layerWithAttachmentsEditing:r}=this;if(!r||!this.supportsAddingAttachments)return{};const s=await this._queueAttachmentsOperation(e,(()=>r.addAttachment(this._createBaseGraphic(r,e),t)));return this._ensureArrayContent(s)}async deleteAttachments(e,t){const{_layerWithAttachmentsEditing:r}=this;if(!r||!this.supportsDeletingAttachments||!t.length)return[];const s=await this._queueAttachmentsOperation(e,(()=>r.deleteAttachments(this._createBaseGraphic(r,e),t)));return this._ensureArray(s)}async deleteRowsByObjectId(e){const{_layerWithEditing:t}=this;if(!this.supportsDelete||!t)throw new o("store:delete-error","Delete is not supported.");const r=e.map((e=>this.getItemByObjectId(e)?.feature)).filter(i);return this._queueEditOperation((()=>t.applyEdits({deleteFeatures:r})))}async fetchItems(e){const{page:t}=e,{pageSize:r}=this,s=t*r,i=s+r,{layer:a,state:o}=this;return a&&"loaded"===o?this._query({layer:a,start:s,num:i,page:t,pageSize:r}):[]}async getAttachmentsByObjectId(e,t){const r=this.getItemByObjectId(e)?.attachments??[];if(!r.length&&t){return(await this._queryAttachments([e]))[e]??[]}return r}getItemByObjectId(e){for(const t of this.pageCache.values())for(const r of t)if(r.objectId===e)return r}getItemIndexByObjectId(e){const{pageCache:t,pageSize:r}=this,s=t.entries();let i=-1;for(const[a,o]of s)if(o.some(((t,s)=>{const o=t.objectId===e;return o&&(i=a*r+s),o})),i>-1)break;return i}async load(){const{layer:e}=this;if(!this._loading&&!this._loaded&&e){this._reset(),this._loading=!0;try{await e.load(),e.parent&&m(e.parent)&&await e.parent.loadAll(),await e.when();const t=this.initialSize;this.initialSize=null,await this.refresh(t),this._loaded=!0,this._loading=!1}catch(t){throw this._reset(),this._loadError=!0,this._logError("store:load-error","An error occurred."),t}}}async query(e){const{state:t}=this;return this.supportsQuery&&"loaded"===t?this._query(e):[]}async refresh(e){this._clearCaches(),await this._syncCount(e),await this._syncObjectIdCache()}async reset(){this._reset()}async updateAttachment(e,t,r){const{_layerWithAttachmentsEditing:s}=this;if(!s||!this.supportsUpdateAttachments)return{};const i=await this._queueAttachmentsOperation(e,(()=>s.updateAttachment(this._createBaseGraphic(s,e),t,r)));return this._ensureArrayContent(i)}async updateItem(e){const{_sortedFieldNames:t}=this,r=e.updates.map((({fieldName:e})=>e)),s=await this._update(e);return!s.updateFeatureResults.find((e=>e.error))&&r.some((e=>t.includes(e)))&&this._clearCaches(),s}async verifyFeaturesByObjectId(e){const{layer:t,state:r}=this;if(!t||"loaded"!==r)return[];const{objectIdField:s}=t,i=await this._verifyFeaturesByObjectId(e);return e.map((e=>i.some((t=>{const r=t.getObjectId()??t.attributes[s];return e===r}))))}_clearCaches(){this.pageCache.clear(),this._objectIdCache.removeAll()}_createBaseGraphic(e,r){const s=new t({attributes:{[e.objectIdField]:r}});return this._subtypeField&&null!=this._subtypeCode&&(s.attributes[this._subtypeField]=this._subtypeCode),s}_ensureArray(e){return Array.isArray(e)?e:[e]}_ensureArrayContent(e){return Array.isArray(e)?e[0]:e}_getObjectIdsForPage(e,t){const r=this._objectIdCache.toArray();return r.length>=e+t?r.slice(e,e+t):r.slice(e)}_logError(e,t){u.getLogger(this).error(e,t)}_reset(){this._clearCaches(),this.failures.removeAll(),this._attachmentsOperationQueue.removeAll(),this._editOperationQueue.removeAll(),this._queryOperationQueue.removeAll(),this._loading=!1,this._loaded=!1,this._loadError=!1,this._set("count",0)}async _syncCount(e){null==e?await this._queryCount().then((e=>this._set("count",e))):this._set("count",e)}async _syncObjectIdCache(){if(this.supportsPagination)return;const e=await this._queryObjectIds();this._objectIdCache.removeAll(),this._objectIdCache.addMany(e)}async _verifyFeaturesByObjectId(e){const{layer:t}=this;if(!t||!this.supportsQuery)throw new o("store:query-error","Layer does not support query operation.");const{effectiveTimeExtent:r,effectiveWhere:s,orderByFields:i,supportsCacheHint:a,supportsOrderBy:n}=this,u=t.createQuery();u.where=s,u.timeExtent=r,u.returnGeometry=!1,u.objectIds=e.length?e:void 0,u.outFields=[t.objectIdField],n&&(u.orderByFields=i),a&&(u.cacheHint=!0);return(await t.queryFeatures(u)).features}async _update(e){const{objectId:r,updates:s}=e,{_layerWithEditing:i}=this;if(!this.supportsUpdate||!i)throw new o("store:update-error","Update is not supported.");const a=this.getItemByObjectId(r)?.feature;if(!a)throw new o("store:update-error","Feature with provided 'objectId' not found.");const u=n(a.attributes);s.forEach((({fieldName:e,value:t})=>u[e]=t));const p=new t({attributes:u}),l=i.applyEdits({updateFeatures:[p]}).then((e=>{const{updateFeatureResults:t}=e,r=t.find((e=>!!e.error));if(r)throw r.error;return t.length&&(a.attributes=u),e}));return this._queueEditOperation((()=>l))}_prepareFeatureData(e){const{attachments:t,features:r,layer:s,relatedRecords:i}=e,a=s.objectIdField;return r.map((e=>{const r=e.getObjectId()??e.attributes[a],o=[];return e.layer||e.sourceLayer||(e.layer=s,e.sourceLayer=s),i.forEach(((e,t)=>{o.push({relationshipId:t,count:e[r]??0})})),{objectId:r,feature:e,attachments:t[r]??null,relatedRecords:o}}))}async _query(e){const{page:t,refresh:r}=e;!0===r&&await this.refresh();const s=this.pageCache.get(t);if(s)return s;const i=await this._queryPage(e);return this.pageCache.set(t,i),i}_queryAttachments(e){const{_layerWithAttachments:t,effectiveWhere:r}=this;return t?e.some((e=>"number"!=typeof e))?Promise.reject(new o("invalid-object-id","Only numeric object ids are valid to query attachments")):t.queryAttachments(new _({objectIds:e,where:r,returnMetadata:!0})):Promise.resolve({})}async _queryCount(){const{_relatedLayerSupportsCacheHint:e,layer:t,relationshipConfig:r,supportsCacheHint:s}=this;if(!t)return 0;if(r&&this._canUseRelatedLayer){const{objectId:t,relatedLayer:s,relationshipId:i}=r;return(await s.queryRelatedFeaturesCount(new f({cacheHint:e,relationshipId:i,objectIds:[t]})))[t]??0}const{effectiveTimeExtent:i,effectiveWhere:a,filterGeometry:o,objectIds:n}=this,u=t.createQuery();return u.geometry=o,u.returnGeometry=!1,u.where=a,u.timeExtent=i,u.objectIds=n?.length?n:void 0,s&&(u.cacheHint=!0),t.queryFeatureCount(u)}async _queryFeatures(e){const{relationshipConfig:t}=this;if(t&&this._canUseRelatedLayer)return this._queryRelatedFeatures(e,t);const{_effectiveReturnM:r,_effectiveReturnZ:s,effectiveOutFields:i,effectiveTimeExtent:a,effectiveWhere:o,filterGeometry:n,objectIds:u,orderByFields:p,pageSize:l,returnGeometry:h,supportsCacheHint:d,supportsOrderBy:c,supportsPagination:y}=this,{layer:m,start:_}=e,f=u?.length,g=m.createQuery();g.returnGeometry=h,g.outFields=i,g.returnM=r,g.returnZ=s,y?(g.start=_,g.num=l,g.where=o,g.timeExtent=a,g.objectIds=f?u:void 0):g.objectIds=f?u:this._getObjectIdsForPage(_,l??0),c&&(g.orderByFields=p),n&&(g.geometry=n),d&&(g.cacheHint=!0);return(await m.queryFeatures(g)).features}_queryObjectIds(){const{effectiveTimeExtent:e,effectiveWhere:t,filterGeometry:r,layer:s,objectIds:i,orderByFields:a,supportsCacheHint:o,supportsOrderBy:n}=this;if(!s)return Promise.resolve([]);const u=s.createQuery();return u.geometry=r,u.outFields=[s.objectIdField],u.returnGeometry=!1,u.where=t,u.timeExtent=e,u.objectIds=i?.length?i:void 0,n&&(u.orderByFields=a),o&&(u.cacheHint=!0),s.queryObjectIds(u)}async _queryPage(e){const{layer:t}=e;return this._queueQueryOperation((async()=>{const r=await this._queryFeatures(e),s=r.map((e=>e.getObjectId()??e.attributes[t.objectIdField])),i=await this._queryAttachments(s),a=await this._queryRelatedCounts(s);return this._prepareFeatureData({layer:t,features:r,attachments:i,relatedRecords:a})||[]}))}async _queryRelatedCounts(e){const{_layerWithRelationships:t,relationshipIds:r,supportsCacheHintQueryRelated:s}=this,i=new Map;return t&&e?.length&&r.length?(await Promise.allSettled(r.map((async r=>{const a=await t.queryRelatedFeaturesCount(new f({cacheHint:s,relationshipId:r,objectIds:e}));i.set(r,a)}))),i):i}async _queryRelatedFeatures(e,t){const{_defaultOutFields:r,_effectiveReturnM:s,_effectiveReturnZ:i,orderByFields:a,pageSize:o,returnGeometry:n,supportsCacheHint:u}=this,{layer:p,start:l}=e,{objectId:h,relatedLayer:d,relationshipId:c}=t,y=p.createQuery(),m=new f({cacheHint:u,num:o,objectIds:[h],orderByFields:a,outFields:r,relationshipId:c,returnGeometry:n,returnM:s,returnZ:i,start:l,where:y.where??void 0}),_=await d.queryRelatedFeatures(m);return _[h]?.features||[]}_queueAttachmentsOperation(e,t){return this._attachmentsOperationQueue.push(t),t().then((async r=>{this._attachmentsOperationQueue.remove(t);const s=this._ensureArray(r),i=s.some((e=>e.error)),a=this.getItemByObjectId(e);if(a&&(!i||s.length>1)){const t=await this._queryAttachments([e]);a.attachments=t[e]}return r})).catch((async r=>{this._logError("store:attachment-error","An error occurred.");const s={error:r,retry:()=>{this.failures.remove(s),this._queueAttachmentsOperation(e,t)},cancel:()=>this.failures.remove(s)};throw this.failures.add(s),this._attachmentsOperationQueue.remove(t),r}))}_queueEditOperation(e){return this._editOperationQueue.push(e),e().then((t=>(this._editOperationQueue.remove(e),t))).catch((t=>{this._logError("store:edit-error","An error occurred.");const r={error:t,retry:()=>{this.failures.remove(r),this._queueEditOperation(e)},cancel:()=>this.failures.remove(r)};throw this.failures.add(r),this._editOperationQueue.remove(e),t}))}_queueQueryOperation(e){return this._queryOperationQueue.push(e),e().then((t=>this._queryOperationQueue.includes(e)?t:[])).catch((t=>{this._logError("store:query-error","An error occurred.");const r={error:t,retry:()=>{this.failures.remove(r),this._queueQueryOperation(e)},cancel:()=>this.failures.remove(r)};return this.failures.add(r),[]})).then((t=>(this._queryOperationQueue.remove(e),t)))}};e([d()],j.prototype,"_attachmentsOperationQueue",void 0),e([d({readOnly:!0})],j.prototype,"_capabilities",null),e([d()],j.prototype,"_defaultOutFields",void 0),e([d()],j.prototype,"_editOperationQueue",void 0),e([d()],j.prototype,"_effectiveReturnZ",null),e([d()],j.prototype,"_effectiveReturnM",null),e([d({readOnly:!0})],j.prototype,"_layerWithAttachments",null),e([d({readOnly:!0})],j.prototype,"_layerWithAttachmentsEditing",null),e([d({readOnly:!0})],j.prototype,"_layerWithEditing",null),e([d({readOnly:!0})],j.prototype,"_layerWithRelationships",null),e([d()],j.prototype,"_loaded",void 0),e([d()],j.prototype,"_loadError",void 0),e([d()],j.prototype,"_loading",void 0),e([d()],j.prototype,"_objectIdCache",void 0),e([d()],j.prototype,"_queryOperationQueue",void 0),e([d({readOnly:!0})],j.prototype,"_relatedLayer",null),e([d({readOnly:!0})],j.prototype,"_relatedLayerCapabilities",null),e([d({readOnly:!0})],j.prototype,"_relatedLayerSupportsCacheHint",null),e([d()],j.prototype,"_relatedLayerSupportsQuery",null),e([d()],j.prototype,"_relatedLayerSupportsQueryRelated",null),e([d()],j.prototype,"_sortedFieldNames",null),e([d()],j.prototype,"_subtypeCode",null),e([d()],j.prototype,"_subtypeField",null),e([d()],j.prototype,"_canUseRelatedLayer",null),e([d()],j.prototype,"attachmentsEnabled",void 0),e([d()],j.prototype,"canAddRelatedFeature",null),e([d({readOnly:!0})],j.prototype,"count",void 0),e([d()],j.prototype,"effectiveOutFields",null),e([d()],j.prototype,"effectiveTimeExtent",null),e([d()],j.prototype,"effectiveWhere",null),e([d({readOnly:!0})],j.prototype,"failures",void 0),e([d({types:y})],j.prototype,"filterGeometry",void 0),e([d()],j.prototype,"initialSize",void 0),e([d({readOnly:!0})],j.prototype,"itemCache",null),e([d()],j.prototype,"layer",void 0),e([d()],j.prototype,"layerView",null),e([d()],j.prototype,"objectIds",void 0),e([d()],j.prototype,"orderByFields",null),e([d()],j.prototype,"outFields",void 0),e([d({readOnly:!0})],j.prototype,"pageCache",void 0),e([d()],j.prototype,"pageSize",void 0),e([d({readOnly:!0})],j.prototype,"querying",null),e([d()],j.prototype,"relationship",null),e([d()],j.prototype,"relationshipConfig",void 0),e([d()],j.prototype,"relationshipIds",null),e([d()],j.prototype,"relationshipInfos",null),e([d()],j.prototype,"relationships",null),e([d()],j.prototype,"relatedRecordsEnabled",void 0),e([d()],j.prototype,"returnGeometry",void 0),e([d()],j.prototype,"returnZ",void 0),e([d()],j.prototype,"returnM",void 0),e([d()],j.prototype,"sortOrders",void 0),e([d({readOnly:!0})],j.prototype,"state",null),e([d()],j.prototype,"supportsAdd",null),e([d()],j.prototype,"supportsAddingAttachments",null),e([d()],j.prototype,"supportsAttachments",null),e([d()],j.prototype,"supportsCacheHint",null),e([d()],j.prototype,"supportsCacheHintQueryRelated",null),e([d()],j.prototype,"supportsDelete",null),e([d()],j.prototype,"supportsDeletingAttachments",null),e([d()],j.prototype,"supportsEditing",null),e([d()],j.prototype,"supportsM",null),e([d()],j.prototype,"supportsOrderBy",null),e([d()],j.prototype,"supportsPagination",null),e([d()],j.prototype,"supportsQuery",null),e([d()],j.prototype,"supportsQueryRelated",null),e([d()],j.prototype,"supportsResizeAttachments",null),e([d()],j.prototype,"supportsUpdate",null),e([d()],j.prototype,"supportsUpdateAttachments",null),e([d()],j.prototype,"supportsZ",null),e([d({readOnly:!0})],j.prototype,"syncing",null),e([d({readOnly:!0})],j.prototype,"syncingAttachmentEdits",null),e([d({readOnly:!0})],j.prototype,"syncingFeatureEdits",null),e([d({type:g})],j.prototype,"timeExtent",void 0),e([d()],j.prototype,"view",void 0),e([d()],j.prototype,"where",void 0),j=e([c("esri.widgets.FeatureTable.support.FeatureStore")],j);const C=j;export{C as default};