@arcgis/core 6.0.0-next.53 → 6.0.0-next.55

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 (300) hide show
  1. package/WebScene.js +2 -2
  2. package/applications/Components/OrientedImageryViewer/shared/constants.js +1 -1
  3. package/applications/SceneViewer/sceneViewerUtils.js +1 -1
  4. package/arcade/arcadeAsyncRuntime.js +1 -1
  5. package/arcade/arcadeCompiler.js +1 -1
  6. package/arcade/arcadeRuntime.js +1 -1
  7. package/arcade/featureset/support/sqlUtils.js +1 -1
  8. package/arcade/validation/arcadeValidator.js +1 -1
  9. package/assets/esri/core/workers/RemoteClient.js +1 -1
  10. package/assets/esri/core/workers/chunks/0329fa3aa3403f1c243b.js +1 -0
  11. package/assets/esri/core/workers/chunks/{6602310c3fcd91fb6a2f.js → 07c8ac092e4b9e8d5b3c.js} +1 -1
  12. package/assets/esri/core/workers/chunks/0a97b1974367382cfdf5.js +1 -0
  13. package/assets/esri/core/workers/chunks/{db0a7671ab5cbe8afd72.js → 123661019bb69c53f2d3.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{d14732a57c8e63948c60.js → 14259910f44c08fd5bbd.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{1b41ba050cde068d2860.js → 193a73a2c7f4f8482c21.js} +1 -1
  16. package/assets/esri/core/workers/chunks/20acb6f3ed5140b6c6c6.js +1 -0
  17. package/assets/esri/core/workers/chunks/{e507dfc4788295d9c244.js → 249a687ce1b6d0815242.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{afb4dfb89fbc8a342cc5.js → 3354f1fa90f8ce4c8fde.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{9b458b0d1627f22fdd93.js → 3b11e4d2e69b7aea1d65.js} +1 -1
  20. package/assets/esri/core/workers/chunks/41694ee8990e799da225.js +1 -0
  21. package/assets/esri/core/workers/chunks/{e592f2483db71230e8e5.js → 4401b3f8ebb658abe789.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{12add2003631fa314f25.js → 5060be52a380fc4920f8.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{2aa6be0b047a1b25a520.js → 53bbb9aa6e4e4a0a8121.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{4707aedcc1b3bdf5e987.js → 5c34d49a6c9cc34b7626.js} +1 -1
  25. package/assets/esri/core/workers/chunks/69a09c6acb5ae03c67f6.js +1 -0
  26. package/assets/esri/core/workers/chunks/7b156905d168bf973518.js +1 -0
  27. package/assets/esri/core/workers/chunks/{e83806797979138fd22a.js → 844c593754b2692257f4.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{2d3e977f3b75474d7ebc.js → 846248697c398468d8e6.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{f7e33d37dd11fb08f3f8.js → 97107e64407fa6825620.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{032733b863426c5bde00.js → 9e508f930086d2ef5f22.js} +3 -3
  31. package/assets/esri/core/workers/chunks/{5118c7269b706089c88e.js → a05a2c2aaf0c288f9681.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{817bf487df056da1e6ec.js → a116dd204921e7464944.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{944f17e9c9f681b971fb.js → a12e2a345005189c64be.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{15b3386ad92a0b4149b8.js → a24dc5350af001db417a.js} +1 -1
  35. package/assets/esri/core/workers/chunks/{10967a36c77c5188690d.js → a66d6298236d59a615db.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{255f5b45c4d32f97f86c.js → ac0861014b3d2f1a1de2.js} +1 -1
  37. package/assets/esri/core/workers/chunks/ace210d313ce53f3ae10.js +1 -0
  38. package/assets/esri/core/workers/chunks/ae48ee283cfa5b3c14b0.js +1 -0
  39. package/assets/esri/core/workers/chunks/bbd8fcb0bbba7bde3d9b.js +1 -0
  40. package/assets/esri/core/workers/chunks/{ac8d38016e4bee37a77c.js → be0b8bb4f09aae6ff5de.js} +1 -1
  41. package/assets/esri/core/workers/chunks/d0659f1b0495734be4b3.js +1 -0
  42. package/assets/esri/core/workers/chunks/{b9a2b05ede02c305e865.js → d8ffb1502def5c85740b.js} +1 -1
  43. package/assets/esri/core/workers/chunks/{7dfe1e78d2e66de6be22.js → d9ef244019954d5a8a27.js} +1 -1
  44. package/assets/esri/core/workers/chunks/{95403bb27a4ea0a4b7b1.js → ddbfa664e69612295785.js} +1 -1
  45. package/assets/esri/core/workers/chunks/{c6d82397044e403a1f61.js → e61082f56c08abe54b3a.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{55d28d3f5b8ced061e39.js → eaf73ce60f39a48ddd2a.js} +1 -1
  47. package/assets/esri/core/workers/chunks/ed2f2a5da830d058e339.js +1 -0
  48. package/assets/esri/core/workers/chunks/{944cb751c85d3a127f49.js → f52d081bbde5c95265cf.js} +1 -1
  49. package/assets/esri/core/workers/chunks/{1de9be7b65109c207bd5.js → fbd5f3b81cd9f061824d.js} +1 -1
  50. package/assets/esri/layers/raster/formats/blosc-wasm.wasm +0 -0
  51. package/assets/esri/libs/librust-parquet/pkg/parquet_bg.wasm +0 -0
  52. package/basemapGallery/support/basemapCompatibilityUtils.js +1 -1
  53. package/chunks/CypherParser.js +1 -1
  54. package/chunks/GeodeticDistanceCalculator-zRp89-dW.js +1 -1
  55. package/chunks/MultiPathImpl.js +1 -1
  56. package/chunks/OperatorGeodesicBuffer.js +1 -1
  57. package/chunks/UnitFactory.js +1 -1
  58. package/chunks/blosc-wasm.js +2 -0
  59. package/chunks/cameraUtilsSpherical.js +1 -1
  60. package/chunks/parquet.js +1 -1
  61. package/chunks/text.js +1 -1
  62. package/config.js +1 -1
  63. package/core/sql/SqlInterval.js +1 -1
  64. package/core/urlUtils.js +1 -1
  65. package/geometry/geometryEngine.js +1 -1
  66. package/geometry/operators/gx/operatorOffset.js +1 -1
  67. package/geometry/support/Ellipsoid.js +1 -1
  68. package/geometry/support/curves/ellipticArc7Utils.js +1 -1
  69. package/geometry/support/geodesicConstants.js +1 -1
  70. package/geometry/support/meshUtils/primitives.js +1 -1
  71. package/kernel.js +1 -1
  72. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  73. package/layers/VoxelWasmPerSceneView.js +1 -1
  74. package/layers/effects/parser.js +1 -1
  75. package/layers/geospatialPDF/GeospatialPDFLayerWorker.js +1 -1
  76. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  77. package/layers/graphics/data/QueryEngineResult.js +1 -1
  78. package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
  79. package/layers/parquet.js +1 -1
  80. package/layers/raster/datasets/ZarrRaster.js +1 -1
  81. package/layers/raster/datasets/wcsCoverageParser.js +1 -1
  82. package/layers/raster/formats/RasterCodec.js +1 -1
  83. package/layers/raster/formats/blosc.js +2 -0
  84. package/layers/support/BuildingFilter.js +1 -1
  85. package/layers/support/IntegratedMeshSemantics.js +1 -1
  86. package/layers/support/fieldUtils.d.ts +23 -87
  87. package/layers/support/fieldUtils.js +1 -1
  88. package/layers/support/layersMapping.js +1 -1
  89. package/layers/video/VideoController.js +1 -1
  90. package/legend/ActiveLayerInfo.js +1 -1
  91. package/libs/ajv/ajv.bundle-wrapper.js +1 -1
  92. package/package.json +4 -4
  93. package/renderers/types.d.ts +1 -1
  94. package/rest/knowledgeGraphService.js +1 -1
  95. package/rest/query/operations/pbfFeatureServiceParser.js +1 -1
  96. package/smartMapping/statistics/support/attributeDensity.js +1 -1
  97. package/smartMapping/support/adapters/support/utils.js +1 -1
  98. package/support/tests/serviceMockDependencies.js +1 -1
  99. package/symbols/cim/CIMEffects.js +1 -1
  100. package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
  101. package/symbols/cim/effects/EffectControlMeasureLine.js +1 -1
  102. package/symbols/cim/placements/PlacementInsidePolygon.js +1 -1
  103. package/symbols/cim/rasterizingUtils.js +1 -1
  104. package/views/2d/PaddedViewState.js +1 -1
  105. package/views/2d/engine/vectorTiles/buckets/FillBucket.js +1 -1
  106. package/views/2d/engine/vectorTiles/constants.js +1 -1
  107. package/views/2d/engine/vectorTiles/style/geoJSONVectorTileUtils.js +1 -1
  108. package/views/2d/engine/webgl/effects/HighlightEffect.js +1 -1
  109. package/views/2d/engine/webgl/mesh/templates/segmentUtils.js +1 -1
  110. package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
  111. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/constants.js +1 -1
  112. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
  113. package/views/2d/interactive/editingTools/ControlPointsTransformTool.js +1 -1
  114. package/views/2d/interactive/editingTools/TransformTool.js +1 -1
  115. package/views/2d/layers/FeatureLikeLayerView2D.js +1 -1
  116. package/views/2d/layers/ParquetLayerView2D.js +1 -1
  117. package/views/2d/layers/features/Processor.js +1 -1
  118. package/views/2d/layers/features/aggregation/GridSpatialIndex.js +1 -1
  119. package/views/2d/layers/features/support/AttributeStore.js +1 -1
  120. package/views/2d/layers/features/support/FeatureSetReaderPBF.js +1 -1
  121. package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
  122. package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementPathHelper.js +1 -1
  123. package/views/3d/analysis/Dimension/DimensionTool.js +1 -1
  124. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  125. package/views/3d/analysis/ElevationProfile/ElevationProfileLineSceneComputation.js +1 -1
  126. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  127. package/views/3d/analysis/LineOfSight/LineOfSightItemManipulatedObject3D.js +1 -1
  128. package/views/3d/analysis/LineOfSight/LineOfSightRayIntersector.js +1 -1
  129. package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
  130. package/views/3d/analysis/Slice/SliceTool.js +1 -1
  131. package/views/3d/analysis/Viewshed/ViewshedObserverManipulatedObject3D.js +1 -1
  132. package/views/3d/analysis/Viewshed/ViewshedSnappingController.js +1 -1
  133. package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
  134. package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
  135. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillComputation.js +1 -1
  136. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementVisualization.js +1 -1
  137. package/views/3d/animation/pointToPoint/Camera.js +1 -1
  138. package/views/3d/camera/constraintUtils.js +1 -1
  139. package/views/3d/camera/intersectionUtils.js +1 -1
  140. package/views/3d/environment/EnvironmentView.js +1 -1
  141. package/views/3d/focusAreaUtils.js +1 -1
  142. package/views/3d/interactive/editingTools/ManipulatedObject3DGraphic.js +1 -1
  143. package/views/3d/interactive/editingTools/dragEventPipeline3D.js +1 -1
  144. package/views/3d/interactive/editingTools/manipulations/config.js +1 -1
  145. package/views/3d/interactive/editingTools/media/MediaElementControllerControlPoints.js +1 -1
  146. package/views/3d/interactive/editingTools/media/MediaElementControllerShape.js +1 -1
  147. package/views/3d/interactive/editingTools/move/MoveTool3D.js +1 -1
  148. package/views/3d/interactive/editingTools/transform/ScaleRotateMeshAdapter.js +1 -1
  149. package/views/3d/interactive/editingTools/transform/TransformTool3D.js +1 -1
  150. package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js +1 -1
  151. package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DView.js +1 -1
  152. package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
  153. package/views/3d/layers/I3SMeshView3D.js +1 -1
  154. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  155. package/views/3d/layers/TiledLayerView3D.js +1 -1
  156. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  157. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  158. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  159. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  160. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  161. package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
  162. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  163. package/views/3d/layers/graphics/Graphics3DSymbolFactory.js +1 -1
  164. package/views/3d/layers/graphics/LabelInfo.js +1 -1
  165. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  166. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  167. package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
  168. package/views/3d/layers/i3s/I3SMeshViewFilter.js +1 -1
  169. package/views/3d/layers/i3s/I3SNode.js +1 -1
  170. package/views/3d/layers/i3s/I3SOverrides.js +1 -1
  171. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  172. package/views/3d/layers/i3s/LayerElevationProvider.js +1 -1
  173. package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
  174. package/views/3d/layers/support/FeatureTileFetcher3DContext.js +1 -1
  175. package/views/3d/layers/support/FeatureTileMeasurements3D.js +1 -1
  176. package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
  177. package/views/3d/layers/support/StageLayerElevationProvider.js +1 -1
  178. package/views/3d/layers/support/Tiles3DLayerViewRegistration.js +1 -1
  179. package/views/3d/layers/support/selectTiles3DSpatialReference.js +1 -1
  180. package/views/3d/layers/support/uvUtils.js +1 -1
  181. package/views/3d/state/Constraints.js +1 -1
  182. package/views/3d/state/ConstraintsManager.js +1 -1
  183. package/views/3d/state/NearFarHeuristic.js +1 -1
  184. package/views/3d/state/ViewState.js +1 -1
  185. package/views/3d/state/ViewStateManager.js +1 -1
  186. package/views/3d/state/controllers/PinchAndPanControllerGlobal.js +1 -1
  187. package/views/3d/state/controllers/PinchAndPanControllerLocal.js +1 -1
  188. package/views/3d/state/controllers/PointToPointAnimationController.js +1 -1
  189. package/views/3d/state/controllers/ZoomStepControllerGlobal.js +1 -1
  190. package/views/3d/state/controllers/ZoomStepControllerLocal.js +1 -1
  191. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  192. package/views/3d/state/utils/OffsetCorrectionController.js +1 -1
  193. package/views/3d/state/utils/groundNavigationUtils.js +1 -1
  194. package/views/3d/state/utils/navigationUtils.js +1 -1
  195. package/views/3d/support/FrustumExtentIntersection.js +1 -1
  196. package/views/3d/support/RenderCoordsHelper.js +1 -1
  197. package/views/3d/support/SweptSphereVolume.js +1 -1
  198. package/views/3d/support/cameraUtils.js +1 -1
  199. package/views/3d/support/elevationUpdateExtentUtils.js +1 -1
  200. package/views/3d/support/engineContent/line.js +1 -1
  201. package/views/3d/support/engineContent/marker.js +1 -1
  202. package/views/3d/support/hitTest.js +1 -1
  203. package/views/3d/support/orientedBoundingBox.js +1 -1
  204. package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
  205. package/views/3d/support/pointsOfInterest/PointsOfInterest.js +1 -1
  206. package/views/3d/support/pointsOfInterest/SurfaceGeometryUpdates.js +1 -1
  207. package/views/3d/support/sunUtils.js +1 -1
  208. package/views/3d/terrain/ExtentHelper.js +1 -1
  209. package/views/3d/terrain/OverlayManager.js +1 -1
  210. package/views/3d/terrain/OverlayRenderer.js +1 -1
  211. package/views/3d/terrain/PatchGeometryFactory.js +1 -1
  212. package/views/3d/terrain/TerrainRenderer.js +1 -1
  213. package/views/3d/terrain/TerrainSurface.js +1 -1
  214. package/views/3d/terrain/Tile.js +1 -1
  215. package/views/3d/terrain/TilingSchemeLogic.js +1 -1
  216. package/views/3d/terrain/terrainUtils.js +1 -1
  217. package/views/3d/webgl/RenderCamera.js +1 -1
  218. package/views/3d/webgl-engine/Stage.js +1 -1
  219. package/views/3d/webgl-engine/collections/Component/ComponentObject.js +1 -1
  220. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  221. package/views/3d/webgl-engine/collections/Component/ComponentObjectElevationAgnosticBVH.js +1 -1
  222. package/views/3d/webgl-engine/collections/Component/ComponentObjectElevationAgnosticComponentGeometryBVH.js +1 -1
  223. package/views/3d/webgl-engine/collections/Component/ElevationAgnosticBVH.js +1 -1
  224. package/views/3d/webgl-engine/collections/Component/IntersectionGeometry.js +1 -1
  225. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  226. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterialRepository.js +1 -1
  227. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  228. package/views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js +1 -1
  229. package/views/3d/webgl-engine/effects/atmosphere/MarsAtmosphere.js +1 -1
  230. package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
  231. package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
  232. package/views/3d/webgl-engine/effects/laserlines/LaserlinePathData.js +1 -1
  233. package/views/3d/webgl-engine/effects/shadowAccumulation/ShadowAccumulator.js +1 -1
  234. package/views/3d/webgl-engine/lib/Intersector.js +1 -1
  235. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  236. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  237. package/views/3d/webgl-engine/lib/TextRenderParameters.js +1 -1
  238. package/views/3d/webgl-engine/lib/TextRenderer.js +1 -1
  239. package/views/3d/webgl-engine/lib/TriangleIntersectionData.js +1 -1
  240. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  241. package/views/3d/webgl-engine/lib/edgeRendering/strokes.js +1 -1
  242. package/views/3d/webgl-engine/lib/verticalOffsetUtils.js +1 -1
  243. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  244. package/views/3d/webgl-engine/materials/PolygonOffset.js +1 -1
  245. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  246. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  247. package/views/MapView.d.ts +1 -0
  248. package/views/SceneView.js +1 -1
  249. package/views/View2D.js +1 -1
  250. package/views/ViewingMode.js +1 -1
  251. package/views/analysis/ElevationProfile/elevationProfileChartBoundsUtils.js +1 -1
  252. package/views/analysis/ElevationProfile/elevationProfileGeometryUtils.js +1 -1
  253. package/views/draw/DrawAction.js +1 -1
  254. package/views/draw/DrawOperation.js +1 -1
  255. package/views/draw/DrawTool.js +1 -1
  256. package/views/draw/SegmentDrawAction.js +1 -1
  257. package/views/draw/support/Reshape.js +1 -1
  258. package/views/draw/support/helpMessageUtils.js +1 -1
  259. package/views/draw/support/managers/EditSessionManager.js +1 -1
  260. package/views/interactive/dragEventPipeline.js +1 -1
  261. package/views/interactive/editGeometry/EditGeometry.js +1 -1
  262. package/views/interactive/editGeometry/EditGeometryOperations.js +1 -1
  263. package/views/interactive/editGeometry/operations/AddOrUpdatePart.js +1 -1
  264. package/views/layers/support/editableLayerViews.js +1 -1
  265. package/views/overlay/TextOverlayItem.js +1 -1
  266. package/views/support/DefaultsFromMap.js +1 -1
  267. package/views/support/Scheduler.js +1 -1
  268. package/views/support/spatialReferenceSupport.js +1 -1
  269. package/views/webgl/ShaderTranspiler.js +2 -2
  270. package/widgets/AreaMeasurement2D/AreaMeasurement2DTool.js +1 -1
  271. package/widgets/BasemapGallery/support/basemapCompatibilityUtils.js +1 -1
  272. package/widgets/BatchAttributeForm.js +1 -1
  273. package/widgets/DistanceMeasurement2D/DistanceMeasurement2DTool.js +1 -1
  274. package/widgets/Editor/workflowUtils.js +1 -1
  275. package/widgets/ElevationProfile/ElevationProfileLineView.js +1 -1
  276. package/widgets/ElevationProfile/support/chartUtils.js +1 -1
  277. package/widgets/ElevationProfile/support/geometryUtils.js +1 -1
  278. package/widgets/FeatureForm.js +1 -1
  279. package/widgets/Legend/styles/card/ColorRamp.js +1 -1
  280. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  281. package/widgets/Measurement.js +1 -1
  282. package/widgets/OrientedImageryViewer/components/ImageLocationWidget.js +1 -1
  283. package/widgets/OrientedImageryViewer/components/ImageMeasurementWidget.js +1 -1
  284. package/widgets/Search/support/layerSearchUtils.js +1 -1
  285. package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
  286. package/widgets/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.js +1 -1
  287. package/widgets/UtilityNetworkAssociations.js +1 -1
  288. package/widgets/Weather/WeatherViewModel.js +1 -1
  289. package/widgets/Weather/css.js +1 -1
  290. package/widgets/Weather.js +1 -1
  291. package/assets/esri/core/workers/chunks/021bd07b9a3e70598840.js +0 -1
  292. package/assets/esri/core/workers/chunks/170e68624b71ac96de4a.js +0 -1
  293. package/assets/esri/core/workers/chunks/8a820e303941b351de81.js +0 -1
  294. package/assets/esri/core/workers/chunks/90d567e920b6982b402d.js +0 -1
  295. package/assets/esri/core/workers/chunks/97cdcedfe853280f6258.js +0 -1
  296. package/assets/esri/core/workers/chunks/9ebc6026934400fc1e1f.js +0 -1
  297. package/assets/esri/core/workers/chunks/b4a325dcf50e276751d7.js +0 -1
  298. package/assets/esri/core/workers/chunks/be5857b0d1b00faf430b.js +0 -1
  299. package/assets/esri/core/workers/chunks/cd9100a7c8309dfa7569.js +0 -1
  300. package/assets/esri/core/workers/chunks/e58f51618251f74aaafd.js +0 -1
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{property as t,subclass as n}from"../core/accessorSupport/decorators.js";import{deprecateWidget as r}from"../core/deprecate.js";import i from"../core/Logger.js";import{getOrCreateMapValue as a}from"../core/MapUtils.js";import{destroyMaybe as o}from"../core/maybe.js";import s from"../core/ReactiveMap.js";import{watch as c,when as l,on as u,sync as d}from"../core/reactiveUtils.js";import{formatFileSize as f}from"../core/unitFormatUtils.js";import{substitute as p}from"../intl.js";import{formatDate as m}from"../intl/date.js";import{isIntegerField as h}from"../layers/support/fieldUtils.js";import{isString as g}from"../support/guards.js";import{getAttachmentTypeCategory as _,getCalciteIconForAttachment as v}from"./Attachments/support/attachmentUtils.js";import{getAttachmentKey as y,isImageAttachment as b,getAttachmentFilenameParts as ee}from"./BatchAttributeForm/attachmentUtils.js";import{getHiddenFieldsValidationErrorMessage as te,getMessageString as ne,isElementTemplateWithInputType as x,subtypeChangeShouldPrompt as re,flattenInputs as ie}from"./BatchAttributeForm/batchAttributeFormUtils.js";import S from"./BatchAttributeForm/BatchAttributeFormViewModel.js";import{css as C}from"./BatchAttributeForm/css.js";import{isDynamicChoiceController as ae,isMultipleChoiceController as w}from"./BatchAttributeForm/inputs/support/controllerUtils.js";import{isGroupInput as T,isFieldInput as E,isTextElementInput as oe,isRelationshipElementInput as D,isAttachmentElementInput as O,isUtilityNetworkAssociationsElementInput as se,differentValuesString as k,getNormalizedFieldName as A,isGroupedInput as ce}from"./BatchAttributeForm/inputs/support/inputUtils.js";import{otherChoiceCheckedPlaceholderValue as le,canRestoreMultipleChoiceOtherChoiceDraftValue as ue,clearMultipleChoiceOtherChoiceStateForViewModel as j}from"./BatchAttributeForm/inputs/support/multipleChoiceInputUtils.js";import{makeViewingEditedAttachmentFooterButtons as M,makeViewingAttachmentFooterButtons as N,makeCancelFooterButton as P,makeDefaultFooterButtons as F}from"./BatchAttributeForm/interfaceUtils.js";import{loadRelationshipDetailsComponents as I,RelationshipDetails as L}from"./BatchAttributeForm/rendered-content/RelationshipDetails.js";import R from"./BatchAttributeForm/VisibleElements.js";import{Prompt as z}from"./Editor/components/Prompt.js";import{downloadAttachmentInfo as B}from"./FeatureTable/support/exportUtils.js";import{loadCalciteComponents as V}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as H,getIntlOptionsForField as de,prepareISOFieldValueForDateComponents as U,prepareUnixFieldValueForDateComponents as W,normalizeTimeOnlyString as G,getISOFieldValueFromDateComponents as fe,getUnixFieldValueFromDateComponents as pe}from"./support/dateUtils.js";import{isEmptyValue as K,ContingentValuesValidationError as q}from"./support/forms/formUtils.js";import{globalCss as J}from"./support/globalCss.js";import{Heading as me}from"./support/Heading.js";import{calciteListFilterProps as he}from"./support/listUtils.js";import{messageBundle as Y,vmEvent as ge,tsx as X}from"./support/widget.js";import{setFocus as _e}from"./support/widgetUtils.js";import ve from"./Widget.js";const Z=`data-element-id`,Q=`data-field-name`;let $=class extends ve{constructor(e){let{suppressDeprecationWarning:t,...n}=e??{};super(n),this.headingLevel=2,this.messagesCommon=null,this.messages=null,this.featureFormMessages=null,this.featureTableMessages=null,this.messagesUnits=null,this.viewModel=new S,this.visibleElements=new R,this.groupDisplay=`all`,this._associationsList=null,this._associationsWidgetsMap=new s,this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._touchedInputs=new Set,this._dynamicChoiceItemSelections=new WeakSet,this._focusedFieldInput=null,this._pendingSubtypeChoice=null,this._batchSwitchInputInitialValues=new Map,this._listObserverNode=null,this._listObserver=new IntersectionObserver(e=>{e.length&&e[0].isIntersecting&&this.viewModel.activeRelationshipInput?.incrementPage()},{root:window.document}),this._attachmentDialogInfo=null,this._attachmentListFilterText=``,this._attachmentFileInputMap=new Map,this._prompt=null,this._selectedAttachmentReplaceFileInput=null,this._afterListObserverCreated=e=>{this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)},this._afterListObserverRemoved=()=>{this._listObserverNode=null},this._maximizeSelectedAttachment=()=>{this._attachmentDialogInfo=this.selectedAttachmentDetails},this._enterAttachmentReplaceView=()=>{let e=this.selectedAttachmentDetails;this._canReplaceSelectedAttachment()&&e&&(e.input.clearValidationCriteriaState(),this.viewModel.setShowingSelectedAttachmentReplacePage(!0))},this._setSelectedAttachmentReplaceFileInput=e=>{this._selectedAttachmentReplaceFileInput=e},this._openSelectedAttachmentReplaceFilePicker=()=>{this._canReplaceSelectedAttachment()&&this._selectedAttachmentReplaceFileInput?.click()},this._resetSelectedAttachmentName=()=>{let e=this.selectedAttachmentDetails;if(!e?.attachment)return;let t=e.input.getAttachmentEditState(e.attachment).initialName;if(t==null)return;let n=e.input.template.elementId,r=y(e.attachment);this.viewModel.stageRenameAttachment(n,r,t)},this._closeAttachmentDialog=()=>{this.hideAttachmentDialog()},this._saveInputFromElement=this._saveInputFromElement.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this),t||(this.announceDeprecation=()=>{r(i.getLogger(this),`Editor`,`arcgis-editor`,{version:`5.0`})})}initialize(){this.addHandles([c(()=>this.features.toArray(),()=>{this._dateComponentMap.clear(),j(this.viewModel,{includeDraftValues:!0})}),c(()=>this.viewModel.activeForm,()=>{this._batchSwitchInputInitialValues.clear(),this._resetTransientFormState(),j(this.viewModel),this._setFocusableInput()}),c(()=>this.viewModel.selectedAttachmentAddElementId,()=>{this.hideAttachmentDialog()}),l(()=>!this.selectedAttachmentDetails,()=>this.hideAttachmentDialog()),c(()=>this.viewModel.selectedAttachmentListElementId,()=>{this._attachmentListFilterText=``}),c(()=>[this.viewModel.activeRelationshipInput,this._listObserverNode],()=>this._onObserverChange()),u(()=>this.viewModel,`submit`,()=>{this.valid||this.goToFirstError()}),c(()=>[this._associationsEnabled,this.viewModel.activeForm.allUtilityNetworkAssociationsElementInputs],()=>this._setUpAssociationsWidgets(),d),c(()=>this.viewModel.activeAssociationsInput,e=>this._onActiveAssociationsInputChange(e)),c(()=>this.groupDisplay,()=>this._syncGroupInputStates())])}loadDependencies(){return Promise.all([V({action:()=>import(`@esri/calcite-components/dist/components/calcite-action`),autocomplete:()=>import(`@esri/calcite-components/dist/components/calcite-autocomplete`),"autocomplete-item":()=>import(`@esri/calcite-components/dist/components/calcite-autocomplete-item`),block:()=>import(`@esri/calcite-components/dist/components/calcite-block`),button:()=>import(`@esri/calcite-components/dist/components/calcite-button`),checkbox:()=>import(`@esri/calcite-components/dist/components/calcite-checkbox`),chip:()=>import(`@esri/calcite-components/dist/components/calcite-chip`),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`),dialog:()=>import(`@esri/calcite-components/dist/components/calcite-dialog`),dropdown:()=>import(`@esri/calcite-components/dist/components/calcite-dropdown`),"dropdown-group":()=>import(`@esri/calcite-components/dist/components/calcite-dropdown-group`),"dropdown-item":()=>import(`@esri/calcite-components/dist/components/calcite-dropdown-item`),icon:()=>import(`@esri/calcite-components/dist/components/calcite-icon`),input:()=>import(`@esri/calcite-components/dist/components/calcite-input`),"input-date-picker":()=>import(`@esri/calcite-components/dist/components/calcite-input-date-picker`),"input-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`),switch:()=>import(`@esri/calcite-components/dist/components/calcite-switch`),"text-area":()=>import(`@esri/calcite-components/dist/components/calcite-text-area`),"radio-button":()=>import(`@esri/calcite-components/dist/components/calcite-radio-button`),"radio-button-group":()=>import(`@esri/calcite-components/dist/components/calcite-radio-button-group`)}),I()])}destroy(){this._destroyAssociationsWidgets(),this._associationsList=o(this._associationsList),this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get activeFeatureIndex(){return this.viewModel.activeFeatureIndex}set activeFeatureIndex(e){this.viewModel.activeFeatureIndex=e}get attachmentsEnabled(){return this.viewModel.attachmentsEnabled}set attachmentsEnabled(e){this.viewModel.attachmentsEnabled=e}get callbacks(){return this.viewModel.callbacks}set callbacks(e){this.viewModel.callbacks=e}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get effectiveTitle(){let{features:e,messages:t,page:n}=this;return t?n===`replacing-attachment`?t.titles.replaceAttachment:n===`viewing-attachment-details`?t.titles.editAttachment:n===`adding-attachments`?t.titles.addAttachments:n===`viewing-attachments`?t.titles.attachments:e.length===1||this.activeFeatureIndex>-1?t.titles.editFeature:e.length>1?t.titles.editFeatures:``:``}get effectiveDisabled(){return this.disabledOrReadOnly||this.viewModel.updating}get disabledOrReadOnly(){return this.disabled||this.readOnly}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get footerButtonInfos(){if(!this.features.length||!this.messages||!this.messagesCommon)return[];let{messages:e,messagesCommon:t,page:n}=this,r=this.effectiveDisabled;if(n===`adding-attachments`||n===`replacing-attachment`)return[];if(n===`viewing-attachment-details`){let t=this.selectedAttachmentDetails,n=t?.input?.getAttachmentEditState(t.attachment);return!t?.input||!n?[]:n.isRenamed||n.isReplaced?M({doneOnclick:()=>this._setSelectedAttachment(null),messages:e.footerButtons,resetOnclick:()=>this._resetSelectedAttachmentChanges(),resetDisabled:this._disableAttachmentModification(t.input)}):N({deleteDisabled:this._disableAttachmentModification(t.input),deleteOnclick:()=>this._deleteSelectedAttachment(),doneOnclick:()=>this._setSelectedAttachment(null),messages:e.footerButtons})}return n===`viewing-associated-features`?P({messages:t,purpose:`cancel-viewing-associated-features`,onclick:()=>this.goBack()}):n===`viewing-associated-layers`?P({messages:t,purpose:`cancel-viewing-associated-layers`,onclick:()=>this.goBack()}):n===`viewing-attachments`||n===`viewing-related-records`?[]:F({disabled:r||!this.valid,formId:this._formId,messages:e,callback:()=>this.submit()})}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get maximumFeatureCount(){return this.viewModel.maximumFeatureCount}set maximumFeatureCount(e){this.viewModel.maximumFeatureCount=e}get maximumFeatureCountWithComplexForms(){return this.viewModel.maximumFeatureCountWithComplexForms}set maximumFeatureCountWithComplexForms(e){this.viewModel.maximumFeatureCountWithComplexForms=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get icon(){return`edit-attributes`}set icon(e){this._overrideIfSome(`icon`,e)}get page(){return this.viewModel.page}get readOnly(){return this.viewModel.readOnly}set readOnly(e){this.viewModel.readOnly=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)}get selectedAttachment(){return this.viewModel.selectedAttachment}get selectedAttachmentDetails(){return this.viewModel.selectedAttachmentDetails}get valid(){return this.viewModel.valid}get _formHeaderVisible(){return this.viewModel.mode===`batch`||!this.viewModel.activeFeature?!1:!!(this.viewModel.formDescription||this.viewModel.formTitle)}get _associationsEnabled(){let{callbacks:e}=this;return!!(e?.addAssociation||e?.editAssociatedFeature)}get _formId(){return`${this.id}-form`}get _relatedRecordsEnabled(){let{callbacks:e}=this;return!!(e&&(e.addRelatedRecord||e.editRelatedRecord))}async goBack(){return this.viewModel.goBack()}async goHome(){return this.viewModel.goHome()}goToFirstError(){let e=this.viewModel.getFirstVisibleInvalidFieldInput();if(!e)return;let{groupInput:t}=e;t&&(t.open||=!0),this._setFocusableInput(e.input),this.scheduleRender()}render(){return X(`div`,{class:this.classes(C.base,J.widget,J.panel),ondragover:this._handleDragAndDrop,ondrop:this._handleDragAndDrop},this._renderContent(),this._renderAttachmentDialog(),this._prompt?X(z,{...this._prompt,headingLevel:this.headingLevel}):void 0)}setActiveAssociationsInput(e){this.viewModel.setActiveAssociationsInput(e)}setActiveAssociationsLayer(e){this.viewModel.setActiveAssociationsLayer(e)}setActiveAssociationType(e){this.viewModel.setActiveAssociationType(e)}submit(){return this.viewModel.submit()}get test(){return{saveInput:this._saveInput.bind(this),pendingSubtypeChoice:this._pendingSubtypeChoice,touchedInputs:this._touchedInputs}}_setDateTimeTimeZoneMap(e){let{datePart:t,elementId:n}=e.dataset,r=a(this._dateComponentMap,`${n}`,()=>({}));switch(t){case`date`:r.date=e;break;case`time`:r.time=e;break;case`timeZone`:r.timeZone=e}}_renderContent(){let{messages:e,viewModel:t}=this,{status:n}=t;if(n===`failed`)return t.hasTooManyComplexFeatures?this._renderErrorNotice(p(e.formFailedToLoadTooManyComplexFeatures,{num:t.maximumFeatureCountWithComplexForms})):t.hasTooManyFeatures?this._renderErrorNotice(p(e.formFailedToLoadTooManyFeatures,{num:t.maximumFeatureCount})):e.formFailedToLoad;if(t.hasLayersWithContingentValues&&this.viewModel.features.length>1)return this._renderErrorNotice(e.unsupportedContingentValues);if(n===`loading`&&this.visibleElements.loadingIndicator)return X(`calcite-loader`,{key:`loader`,label:this.messagesCommon?.loading});if(this.features.length!==0)return this._renderForm()}_renderErrorNotice(e,t=`warning`){return X(`calcite-notice`,{class:C.noticeError,icon:!0,kind:t,open:!0},X(`div`,{slot:`message`},e))}_renderForm(){return X(`form`,{class:C.form,id:this._formId,inert:!!this._prompt,onsubmit:this._onFormSubmit},this.viewModel.expressionEvaluationFailed&&this.visibleElements.expressionsErrorNotice&&this._renderErrorNotice(this.messages.expressionEvaluationFailed),this._renderInvisibleFieldsError(),this._renderPage())}_renderPage(){switch(this.page){case`adding-attachments`:return this._renderAttachmentAddPage();case`viewing-attachment-details`:case`replacing-attachment`:return this._renderAttachmentDetailPage();case`viewing-attachments`:return this._renderAttachmentListPage();case`viewing-associated-layers`:case`viewing-associated-features`:return this._renderViewingAssociationsPage();case`viewing-related-categories`:case`viewing-related-records`:return this._renderRelationshipListPage();default:return this._renderDefaultPage()}}_renderInvisibleFieldsError(){let{viewModel:e}=this,{hasNonActiveInvalidFeatures:t,activeForm:n}=e,r;if(!e.submitHasBeenAttempted)return null;if(n.invalidHiddenInputs.length>0){if(r=te(n,e.mode,this.messages),this.viewModel.mode===`batch`){let e=n.invalidHiddenInputs.filter(e=>e.effectiveVisibilityCode===`hidden:group-visibility-expression:all-features`||e.visibilityCode===`hidden:visibility-expression:all-features`);e.length>0?r+=` (${e.map(e=>e.label).join(`, `)})`:r=null}else r=null}else if(t)return null;return r?this._renderErrorNotice(r,`danger`):null}_renderDefaultPage(){return[this._renderReadOnlyNotice(),this._renderFormHeader(),this._renderFormContent()]}_renderReadOnlyNotice(){if((this.disabled||this.readOnly)&&this.visibleElements.readOnlyNotice)return X(`calcite-notice`,{class:C.disabledNotice,"data-testid":`read-only-notice`,icon:`read-only-non-editable`,kind:`brand`,open:!0,scale:`s`,width:`full`},X(`div`,{slot:`message`},this.featureFormMessages.disabledForm))}_renderFormHeader(){let{formTitle:e,formDescription:t}=this.viewModel;if(!this._formHeaderVisible)return;let n=e?X(me,{key:`title`,level:this.headingLevel},e):void 0,r=t?X(`p`,{class:C.description,key:`description`},t):void 0;return X(`div`,{class:C.formHeader},n,r)}_renderFormContent(){return this.viewModel.hasVisibleInputs?this.viewModel.activeForm.inputs.filter(e=>e.visible).map(e=>this._renderInput(e)):this._renderErrorNotice(this.messages.noVisibleFields[this.viewModel.noVisibleElementsReason])}_renderInput(e){if(T(e))return this._renderGroupInput(e);if(E(e))return this._renderLabeledField(e);if(oe(e))return this._renderTextComponent(e);if(D(e))return this._renderRelationshipElementInput(e);if(O(e))return this._renderAttachmentElementInput(e);if(se(e))return this._renderUtilityNetworkAssociationsElementInput(e)}_renderGroupInput(e){let{inputs:t,template:n,open:r}=e,i=t.filter(e=>e.visible),a=e.label??``,o=this._focusedFieldInput?.group===e,s=this.groupDisplay===`sequential`;return X(`calcite-block`,{class:this.classes(C.group,s?C.groupSequential:null,o?C.groupActive:null,this.disabled?C.inputDisabled:null),description:e.description??void 0,expandable:!0,expanded:r,heading:a,headingLevel:this.headingLevel,key:`{${n.elementId}-key}`,label:a,onCalciteBlockCollapse:({currentTarget:t})=>{e.open=!1,this._onGroupToggle(t,e)},onCalciteBlockExpand:({currentTarget:t})=>{e.open=!0,this._onGroupToggle(t,e)}},i.map(e=>this._renderInput(e)))}_renderLabeledField(e){let{elementId:t}=e.template,{label:n,required:r,dataType:i}=e,a=r?p(this.messages.requiredFieldLabel,{name:n}):n;return X(`calcite-label`,{"aria-label":a,class:C.label,key:`field--${t}`},X(`div`,{class:C.labelTextContent,key:`labelTextContainer`},n,r?X(`span`,{"aria-hidden":`true`,title:this.messagesCommon.required},`*`):void 0),i===`unsupported`?this._renderReadOnlyComponent(e):this._renderFieldInput(e),this._renderAuxiliaryText(e))}_renderFieldInput(e){let t=this.getCommonInputProps(e),{dataType:n}=e;return ae(e.inputController)?this._renderDynamicChoiceComponent({input:e,props:t,controller:e.inputController}):e.domain?.type===`coded-value`?this._renderCodedInputs({input:e,props:t}):w(e.inputController)?this._renderMultipleChoiceComponent({input:e,props:t}):n===`date`?this._renderDateComponents(e,t):(t.disabled=this.disabled,t.readOnly=t.readOnly||this.viewModel.updating,n===`number`?this._renderNumberComponent(e,t):this._renderStringComponent(e,t))}_renderAuxiliaryText(e){let{description:t}=e,n=this._getErrorToDisplay(e),r=n?ne(e,n,this.messages):null;return r?X(`calcite-input-message`,{icon:!0,status:`invalid`},r):e.valueIsOutOfDomain&&(this._touchedInputs.has(e.template.elementId)||this.viewModel.submitHasBeenAttempted)?X(`calcite-input-message`,{icon:!0,status:`idle`},this.messages.subtypes.fieldOutOfSubtypeDomainWarning):t?X(`calcite-input-message`,{class:C.description,icon:!1,status:`idle`},t):null}_renderCodedInputs({input:e,props:t}){let n=e.input?.type??null,r=e.codedValueOptions;switch(n){case`switch`:return this._renderSwitchField({input:e,props:t});case`radio-buttons`:return this._renderRadioButtonGroupComponent({input:e,options:r,props:t});default:return this._renderComboBoxComponent({options:r,props:t,input:e})}}_renderDynamicChoiceComponent({input:e,props:t,controller:n}){let r=n.filteredChoices,i=t.readOnly||t.disabled,a=e.showNoValueLabel||this.messages.empty,o=n.evaluated&&!n.evaluating&&!n.choices.length&&X(`calcite-notice`,{appearance:`transparent`,kind:`neutral`,open:!0,scale:`s`,slot:`content-bottom`,width:`full`},X(`div`,{slot:`message`},e.showNoValueOptionEnabled?this.messages.noDynamicChoicesWithNoValue:this.messages.noDynamicChoices)),s=t=>{this._saveInput(e,t)},c=(e,t)=>{this._dynamicChoiceItemSelections.delete(n);let r=e.closest(`calcite-autocomplete`);if(r){let e=t==null?``:n.getLabel(t);n.filterValue=``,r.inputValue=e}s(t)},u=({currentTarget:t})=>{let r=t.inputValue??``;n.filterValue=r,!r&&e.value!=null&&s(null)},d=e.showNoValueOptionEnabled?X(`calcite-autocomplete-item`,{disabled:i,heading:a,key:`dynamic-choice-empty`,selected:e.value==null,value:``,onCalciteAutocompleteItemSelect:({currentTarget:e})=>c(e,null),onpointerdown:()=>{this._dynamicChoiceItemSelections.add(n)}}):null,f=t=>{this.addHandles(l(()=>!n.initialEvaluationInProgress,()=>{t.inputValue=e.value===k?this.messages.differentValuesPlaceholder:e.value==null?``:n.inputValue},{once:!0,initial:!0}))};return X(`calcite-autocomplete`,{...t,afterCreate:f,disabled:i&&!n.interactionActive,loading:n.initialEvaluationInProgress,placeholder:e.value==null?a:t.placeholder,value:t.value===k?this.messages.differentValuesPlaceholder:String(t.value),onblur:e=>this._onDynamicChoiceBlur(e,n),onCalciteAutocompleteBeforeOpen:()=>n.beginInteraction(),onCalciteAutocompleteTextInput:u},n.evaluating?X(`calcite-loader`,{key:`dynamic-choice-loader`,label:this.messagesCommon.loading,scale:`s`,slot:`content-top`}):[o,d,...r.map(t=>X(`calcite-autocomplete-item`,{disabled:i,heading:t.name,key:`dynamic-choice-${t.code}`,selected:t.code===e.value,value:String(t.code),onCalciteAutocompleteItemSelect:({currentTarget:e})=>c(e,t.code),onpointerdown:()=>{this._dynamicChoiceItemSelections.add(n)}}))])}_renderMultipleChoiceComponent({input:e,props:t}){let{messages:n}=this,r=this._getMultipleChoiceController(e);if(!r)return null;let{input:i}=r,a=i.includeSelectAllChoices===!0,{checkboxStatesByValue:o,selectAllState:s}=r.selectionState,c=s.checked?n.deselectAllLabel:n.selectAllLabel,l=r.otherChoiceRenderState;return X(`div`,{class:C.multipleChoiceInput,key:`${t.key}-multiple-choice-group`},a?this._renderMultipleChoiceSelectAllCheckbox({props:t,selectAllState:s,selectAllLabel:c,handleSelectAllCheckboxChange:t=>{this._saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t,isSelectAllCheckbox:!0})}}):null,this._renderMultipleChoiceChoiceCheckboxes({input:e,props:t,checkboxStatesByValue:o,handleChoiceCheckboxChange:t=>{this._saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t})}}),l.shouldShow?this._renderMultipleChoiceOtherChoice({props:t,includeSelectAllChoices:a,otherChoiceRenderState:l,handleOtherChoiceCheckboxChange:t=>{let{fieldName:n}=l;n&&this._saveOtherChoiceCheckboxValue({input:e,isChecked:t.checked,otherChoiceFieldName:n})},handleOtherChoiceInputChange:t=>{this._saveValueFromMultipleChoiceTextInput({input:e,textInput:t,otherChoiceFieldName:l.fieldName??void 0})},differentValuesPlaceholder:n.differentValuesPlaceholder}):null)}_renderMultipleChoiceSelectAllCheckbox({props:e,selectAllState:t,selectAllLabel:n,handleSelectAllCheckboxChange:r}){return X(`calcite-checkbox`,{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e[`aria-invalid`],checked:t.checked,class:C.multipleChoiceSelectAll,"data-element-id":e[Z],disabled:e.readOnly||e.disabled,indeterminate:t.indeterminate,key:`${e.key}-select-all`,label:n,labelText:n,value:`esri_BatchAttributeForm_select_all`,onblur:e.onblur,onCalciteCheckboxChange:({currentTarget:e})=>r(e),onfocus:e.onfocus})}_renderMultipleChoiceChoiceCheckboxes({input:e,props:t,checkboxStatesByValue:n,handleChoiceCheckboxChange:r}){let i=this._getMultipleChoiceController(e);if(!i)return[];let{choices:a}=i;return a.map(e=>{let i=n.get(e.value)??{checked:!1,indeterminate:!1};return X(`calcite-checkbox`,{afterCreate:t.afterCreate,afterUpdate:t.afterUpdate,"aria-invalid":t[`aria-invalid`],checked:i.checked,class:t.class,"data-element-id":t[Z],disabled:t.readOnly||t.disabled,indeterminate:i.indeterminate,key:`${t.key}-${e.value}`,label:e.label,labelText:e.label,value:e.value,onblur:t.onblur,onCalciteCheckboxChange:({currentTarget:e})=>r(e),onfocus:t.onfocus})})}_renderMultipleChoiceOtherChoice({props:e,includeSelectAllChoices:t,otherChoiceRenderState:n,handleOtherChoiceCheckboxChange:r,handleOtherChoiceInputChange:i,differentValuesPlaceholder:a}){let o=n.label??this.messages.otherOptionLabel;return X(`div`,{class:this.classes(C.multipleChoiceOtherChoice,t?C.multipleChoiceOtherChoiceWithSelectAll:null),key:`${e.key}-other-choice`},X(`calcite-checkbox`,{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e[`aria-invalid`],checked:n.checkboxState.checked,class:e.class,"data-element-id":e[Z],disabled:e.readOnly||e.disabled,indeterminate:n.checkboxState.indeterminate,key:`${e.key}-other-choice-checkbox`,label:o,labelText:o,value:`esri_BatchAttributeForm_other_choice`,onblur:e.onblur,onCalciteCheckboxChange:({currentTarget:e})=>r(e),onfocus:e.onfocus}),n.checkboxState.checked?X(`calcite-input`,{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e[`aria-invalid`],"aria-label":o,class:C.textElementInput,"data-element-id":e[Z],disabled:e.readOnly||e.disabled,key:`${e.key}-other-choice-input`,maxLength:n.maxLength,placeholder:n.value===k?a:n.hint,status:n.status,type:`text`,value:n.normalizedValue===k?``:n.normalizedValue?String(n.normalizedValue):``,onblur:e.onblur,onCalciteInputInput:({currentTarget:e})=>i(e),onfocus:e.onfocus}):null)}async _saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t,isSelectAllCheckbox:n=!1}){this._markInputTouched(e);let r=this._getMultipleChoiceController(e);if(!r)return;if(r.input&&!n&&this.viewModel.mode===`batch`){await this._saveMultipleChoiceCheckboxValueByFeature({input:e,checkbox:t});return}let i=e.value,a=this._parseValue(t,e,n);a!==i&&await this.viewModel.setValue(e.template.elementId,a)}async _saveValueFromMultipleChoiceTextInput({input:e,textInput:t,otherChoiceFieldName:n}){if(!n)return;let r=t.value,i=r==null||r===``?null:r,a=this._getMultipleChoiceController(e);if(!a)return;a.initializeExplicitOtherChoiceCheckedState(),a.stashOtherChoiceDraftValueForFeatures(e.features,i);let o=A(e,n);o&&await this.viewModel.setValueForFieldName(o,i,Array.from(e.features,e=>e.source))}async _saveOtherChoiceCheckboxValue({input:e,isChecked:t,otherChoiceFieldName:n}){let r=this._getMultipleChoiceController(e);if(!r)return;r.setExplicitOtherChoiceCheckedState(t),this._markInputTouched(e),t||r.setOtherChoiceDraftValuesFromFeatures(e.features.toArray());let i=A(e,n);if(!i)return;let a=new Map;for(let i of e.features){let e=i.getAttribute(n);if(t){if(!K(e))continue;let t=r.getOtherChoiceDraftValue(i),n=ue(t)?t:le;a.set(i,n)}else e!=null&&a.set(i,null)}a.size!==0&&await this.viewModel.setValuePerFeatureForFieldName(i,new Map(Array.from(a,([e,t])=>[e.source,t])))}async _saveMultipleChoiceCheckboxValueByFeature({input:e,checkbox:t}){let n=this._getMultipleChoiceController(e);if(!n)return;let r=new Map(e.features.map(r=>[r,n.getUpdatedValueForFeature({choiceValue:t.value,currentValue:r.getAttribute(e.fieldName),isChecked:t.checked})]));r.size!==0&&await this.viewModel.setFieldInputValuePerFeature(e,r)}_renderSwitchField({input:e,props:t}){if((this._batchSwitchInputInitialValues.get(e)===k||e.value===k)&&this.viewModel.mode===`batch`){let n={dropdown:{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,disabled:t.readOnly,open:!1,onblur:t.onblur,onfocus:t.onfocus,[Z]:t[Z]},trigger:{appearance:`transparent`,iconEnd:`chevron-down`,kind:`neutral`,slot:`trigger`,label:t.label},group:{mode:`single`}};return this._renderDropdownComponent({buttonValue:e.value,dropdownProps:n,options:[{name:this.messages.differentValuesPlaceholder,value:k,disabled:!0},...e.codedValueDomainOptions]})}return this._renderSwitchComponent({input:e,props:t})}_renderSwitchComponent({input:e,props:t}){return X(`calcite-switch`,{...t,checked:x(e.template,`switch`)?e.value===e.template.input.onValue:!1,class:C.inputSwitch,disabled:t.readOnly||t.disabled,onCalciteSwitchChange:({currentTarget:e})=>this._saveInputFromElement(e)})}_renderDropdownComponent({buttonValue:e,options:t,dropdownProps:n}){let{trigger:r,dropdown:i,group:a}=n;return X(`calcite-dropdown`,{...i,topLayerDisabled:this.topLayerDisabled,onCalciteDropdownSelect:({currentTarget:e})=>this._saveInputFromElement(e)},X(`calcite-button`,{...r},e===k?this.messages.differentValuesPlaceholder:e),X(`calcite-dropdown-group`,{selectionMode:a.mode},t.map(t=>X(`calcite-dropdown-item`,{disabled:t.disabled,label:String(t.name),selected:e===t.value},t.name))))}_renderComboBoxComponent({input:e,options:t,props:n}){let r=this.viewModel.editType===`INSERT`,i=this._touchedInputs.has(e?.template.elementId),a=r&&e.showNoValueOptionEnabled&&!i?()=>{}:n.onblur,o={...n,onblur:a};return X(`calcite-combobox`,{...o,clearDisabled:e.isSubtypeField,selectionMode:`single`,topLayerDisabled:this.topLayerDisabled,value:n.placeholder===this.messages.differentValuesPlaceholder?k:String(n.value),onCalciteComboboxChange:({currentTarget:t})=>{t.value!==k&&(e.isSubtypeField&&t.selectedItems.length===0?t.value=`${e.value}`:this._saveInputFromElement(t))}},this.renderComboboxOptionsList({input:e,options:t,props:n}))}renderComboboxOptionsList({input:e,options:t,props:n}){let r=e=>e.map(e=>{let{value:t}=e,r=K(e.value)?this.messages.empty:e.name;return X(`calcite-combobox-item`,{heading:r,key:`#${t}`,selected:n.value===t,value:`${t}`})}),i=[],{messages:a}=this;t.other.length>0&&i.push(X(`calcite-combobox-item-group`,{key:`other`,label:a.other},r(t.other))),t.unsupported.length>0&&i.push(X(`calcite-combobox-item-group`,{key:`unsupported`,label:a.unsupported},r(t.unsupported)));let o=r(t.recommended);i.length>0?i.unshift(X(`calcite-combobox-item-group`,{key:`recommended`,label:a.recommended},o)):i=o;let s=n.placeholder===this.messages.differentValuesPlaceholder,c=!s&&K(n.value);return e.showNoValueOptionEnabled&&!t.containsEmptyOption&&i.unshift(X(`calcite-combobox-item`,{heading:e.showNoValueLabel||this.messages.empty,key:`empty-option`,selected:c,value:``})),s&&i.unshift(X(`calcite-combobox-item`,{heading:this.messages.differentValuesPlaceholder,key:k,selected:!0,value:k})),i}_renderRadioButtonGroupComponent({input:e,options:t,props:n}){let r=[...t.recommended,...t.other,...t.unsupported].map(({name:t,value:r})=>this._renderRadioButtons({label:t,value:r,selected:r===e.value,props:n}));if(e.showNoValueOptionEnabled&&!t.containsEmptyOption){let t=e.showNoValueLabel||this.messages.empty,i=K(e.value);r.unshift(this._renderRadioButtons({label:t,value:``,selected:i,props:n}))}return X(`calcite-radio-button-group`,{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:C.inputRadioGroup,"data-field-name":n[Q],disabled:n.readOnly||n.disabled,key:`${n.key}-radio-group`,layout:`vertical`,name:`${n.name}-${this.id}`,required:n.required},r,n.placeholder===this.messages.differentValuesPlaceholder?X(`calcite-label`,{class:C.placeholderRadio,key:n.label,layout:`inline`},X(`calcite-radio-button`,{checked:!0,class:C.inputRadio,disabled:!0,value:n.placeholder}),n.placeholder):null)}_renderRadioButtons({value:e,selected:t,label:n,props:r}){return X(`calcite-label`,{class:C.inputRadioLabel,key:r.label,layout:`inline`},X(`calcite-radio-button`,{...r,afterCreate:void 0,afterUpdate:void 0,checked:t,class:C.inputRadio,disabled:r.readOnly||r.disabled,name:void 0,value:e,onCalciteRadioButtonChange:({currentTarget:e})=>{e.checked&&this._saveInputFromElement(e)}}),n)}_renderStringComponent(e,t){let{template:n}=e;return!n.field.editable||this.readOnly?this._renderReadOnlyComponent(e):n.input?.type===`text-area`?X(`calcite-text-area`,{...t,class:this.classes(C.individualElement),resize:`vertical`,value:t.value?String(t.value):``,onblur:n=>{t.onblur(n),e.userHasChangedValue&&this._saveInputFromElement(n.currentTarget)},onCalciteTextAreaInput:t=>{e.userHasChangedValue=!0,t.currentTarget.value===``&&this._saveInputFromElement(t.currentTarget)}}):X(`calcite-input`,{...t,class:this.classes(C.individualElement),type:`text`,value:t.value?String(t.value):``,onblur:n=>{t.onblur(n),e.userHasChangedValue&&this._saveInputFromElement(n.currentTarget)},onCalciteInputInput:t=>{e.userHasChangedValue=!0,t.currentTarget.value===``&&this._saveInputFromElement(t.currentTarget)}})}_renderNumberComponent(e,t){let n=h(e.field);return X(`calcite-input-number`,{...t,integer:n,step:n?1:`any`,type:`number`,value:n&&t.value!==``?Math.round(parseFloat(String(t.value))).toString():String(t.value),onblur:n=>{t.onblur(n),e.userHasChangedValue&&this._saveInputFromElement(n.currentTarget)},onCalciteInputNumberInput:t=>{e.userHasChangedValue=!0,t.currentTarget.value===``&&this._saveInputFromElement(t.currentTarget)}})}_renderReadOnlyComponent(e,t){let n=this.getCommonInputProps(e);return X(`calcite-input`,{...n,class:this.classes(C.fieldInput,C.inputDisabled,C.individualElement),readOnly:!0,type:`text`,value:String(t??n.value??``)})}_renderDateComponents(e,t){let{field:n}=e,r;switch(n.type){case`date`:r=this._renderDateFieldComponents(e,t);break;case`date-only`:r=this._renderDateOnlyFieldComponent(e,t);break;case`time-only`:r=this._renderTimeOnlyFieldComponent(e,t);break;case`timestamp-offset`:r=this._renderTimestampOffsetFieldComponents(e,t);break;default:r=this._renderReadOnlyComponent(e,H(n,t.value,{timeZone:e.effectiveTimeZone,...de(e.template.field)}))}return e.value===k?[r,X(`calcite-input-message`,{icon:`information`,key:`diff-values-message`,status:`idle`},this.messages.differentValues)]:r}_renderDateOnlyFieldComponent(e,t){let{class:n,disabled:r,key:i,readOnly:a}=t,{rawMax:o,rawMin:s}=e.range;return X(`calcite-input-date-picker`,{afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,class:n,"data-date-part":`date`,"data-element-id":t[Z],"data-field-name":t[Q],disabled:r,key:`${i}-date-input`,max:g(o)?o:void 0,min:g(s)?s:void 0,overlayPositioning:`fixed`,readOnly:a,topLayerDisabled:this.topLayerDisabled,value:e.value===k?``:e.value?String(e.value):``,onblur:t.onblur,onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget),onfocus:t.onfocus})}_renderTimeOnlyFieldComponent(e,t){let{class:n,disabled:r,key:i,readOnly:a}=t;return X(`calcite-input-time-picker`,{afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,class:n,"data-date-part":`time`,"data-element-id":t[Z],"data-field-name":t[Q],disabled:r,key:`${i}-time-input`,overlayPositioning:`fixed`,readOnly:a,step:e.timeStep,value:e.value===k?``:e.value?String(e.value):``,onblur:t.onblur,onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget),onfocus:t.onfocus})}_renderTimestampOffsetFieldComponents(e,t){let{class:n,disabled:r,key:i,readOnly:a,onblur:o,onfocus:s}=t,{rawMax:c,rawMin:l}=e.range,u=e.effectiveTimeZone,d=U(c,u),f=U(l,u),p=U(e.value===k?``:e.value,u),m=e.includeTimeOffset,h={afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,disabled:r,[Z]:t[Z],[Q]:t[Q],onblur:o,onfocus:s,overlayPositioning:`fixed`,readOnly:a};return X(`div`,{class:C.dateInputContainer,key:`${i}-date-time-container`},X(`calcite-input-date-picker`,{...h,class:n,"data-date-part":`date`,key:`${i}-date-input`,max:d?.date??void 0,min:f?.date??void 0,topLayerDisabled:this.topLayerDisabled,value:p.date??``,onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),X(`calcite-input-time-picker`,{...h,class:n,"data-date-part":`time`,key:`${i}-time-input`,step:e.timeStep,value:p.time??``,onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),m?X(`calcite-input-time-zone`,{...h,class:n,clearable:e.value===k||e.value==null,"data-date-part":`timeZone`,key:`${i}-timezone-input`,value:p.timeZoneOffset||``,onCalciteInputTimeZoneChange:t=>this._saveValueFromDateComponent(e,t.target)}):null)}_renderDateFieldComponents(e,t){let{class:n,disabled:r,key:i,readOnly:a,min:o,max:s}=t,c=e.effectiveTimeZone,l=W(e.value===k?``:e.value,c),u=W(s,c),d=W(o,c),f=e.includeTime,p={afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,disabled:r,[Z]:t[Z],[Q]:t[Q],onblur:t.onblur,onfocus:t.onfocus,overlayPositioning:`fixed`,readOnly:a};return X(`div`,{class:C.dateInputContainer,key:`${i}-date-time-container`},X(`calcite-input-date-picker`,{...p,class:n,"data-date-part":`date`,key:`${i}-date-input`,max:u?.date??void 0,min:d?.date??void 0,topLayerDisabled:this.topLayerDisabled,value:l.date??``,onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),f?X(`calcite-input-time-picker`,{...p,"data-date-part":`time`,key:`${i}-time-input`,step:1,value:l.time??``,onCalciteInputTimePickerChange:t=>{this._saveValueFromDateComponent(e,t.target)}}):null)}_renderRelationshipElementInput(e){return this._relatedRecordsEnabled?X(L,{afterObserverCreated:this._afterListObserverCreated,afterObserverRemoved:this._afterListObserverRemoved,input:e,messages:this.messages,messagesCommon:this.messagesCommon,viewModel:this.viewModel}):null}_renderRelationshipListPage(){let{activeRelationshipInput:e}=this.viewModel;if(e)return this._renderRelationshipElementInput(e)}_renderAttachmentElementInput(e){if(!this.attachmentsEnabled)return;let{allAttachmentsVisibleOnDefaultPage:t,attachments:n,defaultPageAttachments:r,template:{description:i,elementId:a,label:o}}=e,s=t?n:r;return X(`div`,{class:C.attachmentElementInput,"data-testid":`attachment-element-${a}`,key:`attachment-element-${a}`},o?X(`div`,{class:C.attachmentElementLabel,key:`attachment-element-label-${a}`},o):null,i?X(`div`,{class:C.description,key:`attachment-element-description-${a}`},i):null,n.length?this._renderAttachmentList(e,s,{label:o||this.messagesCommon.details,viewAllCount:t?null:n.length}):X(`div`,{class:C.attachmentElementEmptyState,key:`attachment-element-empty-state-${a}`},this.messages.attachments.noAttachments),this._renderAttachmentAddAction(e))}_renderAttachmentListPage(){let e=this.viewModel.selectedAttachmentListInput;if(e)return X(`div`,{class:C.attachmentElementAllPanel,key:`attachment-element-all-panel-${e.template.elementId}`},this._renderAttachmentList(e,e.attachments,{filterEnabled:!0,label:this.messages.titles.attachments}))}_renderAttachmentList(e,t,n){let{filterEnabled:r,label:i,viewAllCount:a}=n;return X(`calcite-list`,{class:C.attachmentElementList,filterEnabled:r,filterPlaceholder:r?this.messages.attachments.searchAttachments:void 0,filterProps:r?he:void 0,filterText:r?this._attachmentListFilterText:void 0,label:i,selectionAppearance:`border`,selectionMode:`none`,onCalciteListFilter:r?e=>{this._attachmentListFilterText=e.currentTarget.filterText??``}:void 0},this._renderAttachmentListItems(e,t),a==null?null:this._renderViewAllAttachmentsItem(e,a))}_renderAttachmentListItems(e,t){let{elementId:n}=e.template;return t.map((t,r)=>{let i=this._formatAttachmentSize(t.size),a=this._getAttachmentLabel(t,r,i,e.displayFilename),o=a===i?void 0:i,s=y(t),c=e.isStagedAttachmentAddition(t),l=e.getAttachmentEditState(t),u=l.isDeleted,d=!u&&(c||l.isRenamed||l.isReplaced);return X(`calcite-list-item`,{class:C.attachmentElementListItem,description:o,key:`attachment-item-${s}`,label:a,onCalciteListItemSelect:c||u?void 0:()=>this._setSelectedAttachment({attachmentKey:s,elementId:n})},X(`div`,{class:C.attachmentElementListItemStart,slot:`content-start`},this._renderAttachmentPreviewThumbnail(t,a,e)),d?X(`span`,{class:C.attachmentElementListItemStagedIndicator,slot:`content-end`}):null,c?[X(`calcite-action`,{disabled:this._disableAttachmentModification(e),icon:`x`,scale:`s`,slot:`actions-end`,text:this.messagesCommon.delete,title:this.messagesCommon.delete,onclick:()=>this.viewModel.stageDeleteAttachment(n,y(t))})]:u?X(`calcite-chip`,{label:this.messages.attachments.deleted,scale:`s`,slot:`content-end`},this.messages.attachments.deleted):X(`calcite-icon`,{flipRtl:!0,icon:`chevron-right`,scale:`s`,slot:`content-end`}))})}_renderViewAllAttachmentsItem(e,t){let{elementId:n}=e.template,{viewAll:r}=this.messages.attachments;return X(`calcite-list-item`,{class:C.attachmentElementListItem,description:p(this.messages.attachments.count,{count:t}),key:`attachment-item-view-all-${n}`,label:r,onCalciteListItemSelect:()=>this._setAttachmentListElementId(n)},X(`calcite-icon`,{flipRtl:!0,icon:`chevron-right`,scale:`s`,slot:`content-end`}))}_renderAttachmentAddAction(e){let{elementId:t}=e.template,n=this.effectiveDisabled||e.addDisabled,r=this._renderAttachmentCountLimitsLabel(e),i=this._getAttachmentNoticeMessage(e),a=e.hasMinimumAttachmentCountNotMet||e.hasExceededAttachmentLimit?`danger`:`info`,o=e.canUploadFiles,s=e.isCaptureOnly&&!this.effectiveDisabled&&!i;return X(`div`,{class:C.attachmentElementAddActions,key:`attachment-element-add-actions-${t}`},o?X(`calcite-button`,{appearance:`outline`,disabled:n,iconStart:`attachment`,kind:`neutral`,round:!0,scale:`s`,onclick:()=>this._setAttachmentAddElementId(t)},this.messages.attachments.attach):null,this._renderAttachmentCaptureButton(e),s?this._renderAttachmentCaptureDisabledNotice(t):null,r?X(`div`,{class:C.attachmentElementEmptyActionHint},r):null,!this.effectiveDisabled&&i?X(`calcite-notice`,{closable:!1,icon:a===`danger`?`exclamation-mark-circle`:`lightbulb`,kind:a,open:!0,scale:`s`,width:`full`},X(`div`,{slot:`message`},i)):null)}_renderAttachmentCaptureButton(e){if(!e.hasCaptureInputs)return null;let t=e.captureMediaType;return X(`calcite-button`,{appearance:`outline`,disabled:!0,iconStart:ye(t),kind:`neutral`,round:!0,scale:`s`},this._getCaptureButtonLabel(t))}_getAttachmentNoticeMessage(e){let t=this.messages.attachments;return e.hasUnsupportedFileTypeValidationError?this._getUnsupportedFileTypeMessage():e.hasMinimumAttachmentCountNotMet&&this._shouldShowMinimumAttachmentNotice(e)?t.minimumNotMet:e.hasExceededAttachmentLimit?t.attachmentLimitExceeded:e.hasReachedAttachmentLimit?t.attachmentLimitReached:null}_shouldShowMinimumAttachmentNotice(e){return e.hasAttachmentChanges||this.viewModel.submitHasBeenAttempted||this._touchedInputs.has(e.template.elementId)}_getCaptureButtonLabel(e){let{capture:t,recordAudio:n,takePhoto:r,takeVideo:i}=this.messages.attachments;switch(e){case`image`:return r||t;case`video`:return i||t;case`audio`:return n||t;default:return t}}_renderAttachmentAddPage(){let e=this.viewModel.selectedAttachmentAddInput;return e?this._renderAttachmentAddPanel(e):null}_renderAttachmentAddPanel(e){let{maxAttachmentCount:t}=e,{elementId:n}=e.template;if(e.isCaptureOnly)return this._renderAttachmentCaptureDisabledNotice(n);let r=t==null||t-e.attachments.length>1,i=this.effectiveDisabled||e.addDisabled,a=this.messages.attachments,o=a.dragAndDropFile,s=e=>{this._attachmentFileInputMap.set(n,e)};return X(`div`,{class:C.attachmentElementAddPanel,key:`attachment-element-add-panel-${n}`},X(`input`,{accept:e.accept,afterCreate:s,afterRemoved:()=>{this._attachmentFileInputMap.delete(n)},afterUpdate:s,class:C.attachmentElementFileInput,"data-element-id":n,disabled:i,multiple:r,type:`file`,onchange:e=>{let t=e.currentTarget,r=t.files?Array.from(t.files):[];this._stageAttachmentFiles(n,r),t.value=``}}),X(`div`,{class:C.attachmentElementAddDropzone,"data-disabled":i?`true`:`false`,ondragover:e=>{e.stopPropagation(),e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`)},ondrop:e=>{if(e.preventDefault(),e.stopPropagation(),i)return;let t=e.dataTransfer?.files?Array.from(e.dataTransfer.files):[];this._stageAttachmentFiles(n,t)}},X(`calcite-icon`,{class:C.attachmentElementAddDropzoneIcon,icon:`upload`,scale:`l`}),X(`div`,{class:C.attachmentElementAddDropzoneHeading},a.addFile),X(`div`,{class:C.attachmentElementAddDropzoneDetail,title:o},o),X(`calcite-button`,{appearance:`transparent`,disabled:i,iconStart:`folder-open`,kind:`brand`,scale:`s`,type:`button`,onclick:e=>{e.stopPropagation(),this._openAttachmentFilePicker(n,i)}},a.selectFile)),this._renderAttachmentValidationCriteria(e,{includeCountCriteria:!0}))}_renderAttachmentCaptureDisabledNotice(e){return X(`calcite-notice`,{class:C.attachmentElementCaptureNotice,icon:!0,key:`attachment-element-capture-disabled-notice-${e}`,kind:`warning`,open:!0,scale:`s`},X(`div`,{slot:`message`},this.messages.attachments.captureMethodNotSupported))}async _stageAttachmentFiles(e,t){if(t.length===0)return;let n=this.viewModel.selectedAttachmentAddInput,r=!0;try{r=(await this.viewModel.stageAddAttachments(e,t)).length>0&&!n?.hasInvalidValidationCriteria&&!n?.hasUnsupportedFileTypeValidationError}finally{r&&this.viewModel.setSelectedAttachmentAddElementId(null)}}_openAttachmentFilePicker(e,t){t||this._attachmentFileInputMap.get(e)?.click()}_renderAttachmentDetailPage(){let e=this.selectedAttachmentDetails;if(!e)return;if(this.page===`replacing-attachment`)return this._renderAttachmentReplacePanel(e);let{attachment:t,input:n}=e,r=y(t),i=!!n.getAttachmentPreviewUrl(t),a=!this._disableAttachmentModification(n)&&n.canUploadFiles,o=n.getAttachmentEditState(t);return X(`div`,{class:C.attachmentElementDetail,key:`attachment-detail-panel-${n.template.elementId}-${r}`},X(`div`,{class:C.attachmentElementDetailPreview},this._renderAttachmentPreviewImageForInput(t,n)),X(`div`,{class:C.attachmentElementDetailActions},b(t)?X(`calcite-button`,{appearance:`outline`,disabled:!i,iconStart:`expand`,kind:`neutral`,label:this.messages.attachments.maximize,scale:`m`,title:this.messages.attachments.maximize,onclick:this._maximizeSelectedAttachment}):null,X(`calcite-button`,{appearance:`outline`,disabled:!i||o.isReplaced,iconStart:`download`,kind:`neutral`,label:this.messages.attachments.download,scale:`m`,title:this.messages.attachments.download,onclick:()=>{this._downloadAttachment(t)}}),X(`calcite-button`,{appearance:`outline`,disabled:!a,iconStart:`upload-to`,kind:`neutral`,label:this.messages.attachments.replace,scale:`m`,title:this.messages.attachments.replace,onclick:this._enterAttachmentReplaceView})),X(`div`,{class:C.attachmentElementDetailMetadata},X(`div`,{class:C.attachmentElementDetailMetadataGroup},X(`span`,{class:C.attachmentElementDetailMetadataLabel},this.messages.attachments.fileName),this._renderFileNameContent(t,n)),X(`div`,{class:C.attachmentElementDetailMetadataGroup},X(`span`,{class:C.attachmentElementDetailMetadataLabel},this.messages.attachments.size),X(`span`,{class:C.attachmentElementDetailMetadataValue},this._formatAttachmentSize(t.size))),X(`div`,{class:C.attachmentElementDetailMetadataGroup},X(`span`,{class:C.attachmentElementDetailMetadataLabel},this.messages.attachments.type),X(`span`,{class:C.attachmentElementDetailMetadataValue},this._getLabelForAttachmentType(t)))))}_renderFileNameContent(e,t){if(!t.allowUserRename)return X(`span`,{class:C.attachmentElementDetailMetadataValue},e.name);let n=t.getAttachmentEditState(e),{baseName:r,extension:i}=ee(e.name),a=this._disableAttachmentModification(t),o=!a&&e.name.trim().length===0;return[X(`div`,{class:C.attachmentElementDetailFileNameRow,key:`file-name-row`},X(`calcite-input`,{class:C.attachmentElementDetailFileNameInput,disabled:a,scale:`m`,status:o?`invalid`:`idle`,suffixText:i,value:r,onCalciteInputInput:({currentTarget:e})=>this._renameSelectedAttachment(e.value)}),X(`calcite-button`,{appearance:`transparent`,disabled:a||n.initialName==null||!n.isRenamed,iconStart:`reset`,kind:`neutral`,label:this.messages.footerButtons.reset,scale:`m`,title:this.messages.footerButtons.reset,onclick:this._resetSelectedAttachmentName})),o?X(`calcite-input-message`,{icon:!0,key:`file-name-message`,status:`invalid`},this.messages.validationErrors.cannotBeNull):null]}_renderAttachmentReplacePanel(e){let{attachment:t,input:n}=e,r=this._disableAttachmentModification(n)||!n.canUploadFiles,i=n.template.elementId;return X(`div`,{class:C.attachmentElementAddPanel,key:`attachment-replace-panel-${i}-${y(t)}`},X(`input`,{accept:n.accept,afterCreate:this._setSelectedAttachmentReplaceFileInput,afterRemoved:()=>{this._selectedAttachmentReplaceFileInput=null},afterUpdate:this._setSelectedAttachmentReplaceFileInput,class:C.attachmentElementFileInput,disabled:r,type:`file`,onchange:e=>{let t=e.currentTarget,n=t.files?.[0];n&&this._stageSelectedAttachmentReplacement(n),t.value=``}}),X(`div`,{class:C.attachmentElementAddDropzone,"data-disabled":r?`true`:`false`,ondragover:e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`)},ondrop:e=>{if(e.preventDefault(),e.stopPropagation(),r)return;let t=e.dataTransfer?.files?.[0];t&&this._stageSelectedAttachmentReplacement(t)}},X(`calcite-icon`,{class:C.attachmentElementAddDropzoneIcon,icon:`refresh`,scale:`l`}),X(`div`,{class:C.attachmentElementAddDropzoneHeading},this.messages.attachments.replace),X(`div`,{class:C.attachmentElementAddDropzoneDetail,title:this.messages.attachments.dragAndDropFile},this.messages.attachments.dragAndDropFile),X(`calcite-button`,{appearance:`transparent`,disabled:r,iconStart:`folder-open`,kind:`brand`,scale:`s`,onclick:e=>{e.stopPropagation(),this._openSelectedAttachmentReplaceFilePicker()}},this.messages.attachments.selectFile)),this._renderAttachmentValidationCriteria(n,{includeCountCriteria:!1}),X(`div`,{class:C.attachmentElementDetailMetadata},X(`div`,{class:C.attachmentElementDetailMetadataGroup},X(`span`,{class:C.attachmentElementDetailMetadataLabel},this.messages.attachments.fileToBeReplaced),X(`span`,{class:C.attachmentElementDetailMetadataValue},t.name))))}_renderAttachmentDialog(){let e=this._attachmentDialogInfo;if(!e)return null;let{attachment:t,input:n}=e;return X(`calcite-dialog`,{heading:t.name||this.messagesCommon.details,key:`attachment-preview-dialog`,modal:!0,open:!0,placement:`cover`,width:`l`,onCalciteDialogClose:this._closeAttachmentDialog},X(`div`,{class:C.attachmentElementDialogPreview},this._renderAttachmentPreviewImageForInput(t,n)))}_setSelectedAttachment(e,t){this._markInputTouched(t),this.viewModel.setSelectedAttachment(e),e||this.hideAttachmentDialog()}_setAttachmentAddElementId(e){let{viewModel:t}=this;t.setSelectedAttachmentAddElementId(e),this._markInputTouched(t.selectedAttachmentAddInput),t.selectedAttachmentAddInput?.clearValidationCriteriaState(),this.hideAttachmentDialog()}_setAttachmentListElementId(e){let{viewModel:t}=this;t.setSelectedAttachmentListElementId(e),this._markInputTouched(t.selectedAttachmentListInput),this.hideAttachmentDialog()}_getAttachmentLabel(e,t,n,r){return r!==!1&&g(e.name)&&e.name.length>0?e.name:n===this.messagesCommon.notApplicable?p(this.messages.attachments.attachmentNumberedLabel,{index:t+1}):n}_renderAttachmentCountLimitsLabel(e){let t=this.messages.attachments,n=e.minAttachmentCount!=null&&e.minAttachmentCount>0?this._renderAttachmentCountLimitLabel(t.minAttachmentsShort,e.minAttachmentCount,`min`):null,r=e.maxAttachmentCount==null?null:this._renderAttachmentCountLimitLabel(t.maxAttachmentsShort,e.maxAttachmentCount,`max`);return!n&&!r?null:[n,n&&r?X(`span`,{key:`attachment-count-limits-separator`},`, `):null,r]}_renderAttachmentCountLimitLabel(e,t,n){let r=`__count__`,[i,a]=p(e,{count:r}).split(r);return X(`span`,{key:n},i,X(`span`,{class:C.attachmentElementEmptyActionHintValue},t),a)}_renderAttachmentValidationCriteria(e,{includeCountCriteria:t}){let n=this._getAttachmentValidationCriteria(e,{includeCountCriteria:t}),r=`attachment-validation-criteria-${e.template.elementId}`;return n.length===0?null:X(`div`,{class:C.attachmentElementValidationCriteria,key:r},n.map(({key:e,message:t,state:n})=>X(`calcite-notice`,{appearance:n===`danger`?`outline-fill`:`transparent`,closable:!1,icon:!0,key:e,kind:n,open:!0,scale:`s`,width:`full`},X(`div`,{slot:`message`},t))))}_getAttachmentValidationCriteria(e,{includeCountCriteria:t}){let n=[],r=e.validationCriterionStates,i=this.messages.attachments,a=this._getNestableAttachmentInputs(e.input);e.hasUnsupportedFileTypeValidationError&&n.push({key:`unsupported-file-type`,message:this._getUnsupportedFileTypeMessage(),state:`danger`});for(let e of a)e.type===`document`&&e.maxFileSize!=null&&n.push({key:`maximum-file-size`,message:p(i.maximumFileSize,{maxSize:this._formatAttachmentSizeLimitInMegabytes(e.maxFileSize)}),state:r.get(`maximum-file-size`)??`info`}),e.type===`audio`&&e.maxDuration!=null&&n.push({key:`maximum-audio-length`,message:p(i.maximumAudioLength,{maxDuration:this._formatAttachmentDurationLimit(e.maxDuration)}),state:r.get(`maximum-audio-length`)??`info`}),e.type===`video`&&e.maxDuration!=null&&n.push({key:`maximum-video-length`,message:p(i.maximumVideoLength,{maxDuration:this._formatAttachmentDurationLimit(e.maxDuration)}),state:r.get(`maximum-video-length`)??`info`}),e.type===`image`&&e.maxImageSize!=null&&n.push({key:`maximum-image-size`,message:p(i.attachmentMustBeSmallerThan,{maxSize:`${e.maxImageSize}px`}),state:r.get(`maximum-image-size`)??`info`});return t&&e.minAttachmentCount!=null&&e.minAttachmentCount>0&&n.push({key:`minimum-number-of-files`,message:p(i.minimumNumberOfFiles,{count:e.minAttachmentCount}),state:r.get(`minimum-number-of-files`)??`info`}),t&&e.maxAttachmentCount!=null&&n.push({key:`maximum-number-of-files`,message:p(i.maximumNumberOfFiles,{count:e.maxAttachmentCount}),state:r.get(`maximum-number-of-files`)??`info`}),n}_getNestableAttachmentInputs(e){return e==null?[]:e.type===`attachment`?e.inputTypes?.slice()??[]:[e]}_getUnsupportedFileTypeMessage(){return this.featureTableMessages.errorFileUnsupported}_formatAttachmentSize(e){return e==null||Number.isNaN(e)?this.messagesCommon.notApplicable:f(this.messagesUnits,e)}_formatAttachmentSizeLimitInMegabytes(e){return f(this.messagesUnits,e*1048576)}_formatAttachmentDurationLimit(e){return m(Math.round(e)*1e3,{...e>=3600?{hour:`2-digit`,hourCycle:`h23`}:{},minute:`2-digit`,second:`2-digit`,timeZone:`UTC`})}_getLabelForAttachmentType({contentType:e}){if(!e)return this.messagesCommon.notApplicable;let t=this.messages.attachments.attachmentTypes,n=_(e);return t?.[n]||e}_renderAttachmentPreviewThumbnail(e,t,n){let r=n.getAttachmentPreviewUrl(e,64);return r&&b(e)?X(`img`,{alt:t,class:C.attachmentElementListItemThumb,src:r}):X(`calcite-icon`,{class:C.attachmentElementListItemIcon,icon:v(e.contentType),scale:`s`})}_renderAttachmentPreviewImageForInput(e,t){let n=t.getAttachmentPreviewUrl(e),r=e.name||this.messagesCommon.details;return n&&b(e)?X(`img`,{alt:r,class:C.attachmentElementDetailPreviewImage,src:n,title:r}):[X(`calcite-icon`,{class:C.attachmentElementDetailPreviewIcon,icon:v(e.contentType),scale:`l`,textLabel:r,title:r}),this.messages.attachments.noPreviewAvailable]}async _downloadAttachment(e){await B(e)}_canReplaceSelectedAttachment(){return!this.effectiveDisabled&&!!this.selectedAttachmentDetails?.input.canUploadFiles}_exitAttachmentReplaceView(){this.viewModel.setShowingSelectedAttachmentReplacePage(!1),this._selectedAttachmentReplaceFileInput=null}async _stageSelectedAttachmentReplacement(e){let t=this.selectedAttachmentDetails;if(!t?.attachment)return;let n=t.input.template.elementId,r=y(t.attachment),i=!1;try{i=await this.viewModel.stageReplaceAttachment(n,r,e)}finally{i&&this._exitAttachmentReplaceView()}}_renameSelectedAttachment(e){let t=this.selectedAttachmentDetails;if(!t?.attachment)return;let n=t.input.template.elementId,r=y(t.attachment);this.viewModel.stageRenameAttachment(n,r,e)}_resetSelectedAttachmentChanges(){let e=this.selectedAttachmentDetails;e?.attachment&&this.viewModel.resetAttachmentChanges(e.input.template.elementId,y(e.attachment))}_deleteSelectedAttachment(){let e=this.selectedAttachmentDetails;if(!e?.attachment||this._disableAttachmentModification(e.input))return;let t=e.input.template.elementId,n=y(e.attachment);this.viewModel.stageDeleteAttachment(t,n),this._setSelectedAttachment(null)}_disableAttachmentModification(e){return this.disabledOrReadOnly||!e.editable}hideAttachmentDialog(){this._attachmentDialogInfo=null}_renderTextComponent(e){let{elementId:t}=e.template;return X(`div`,{class:C.textElementInput,"data-testid":`text-element-${t}`,innerHTML:e.text,key:`text-element-${t}`})}_renderUtilityNetworkAssociationsElementInput(e){if(!this._associationsEnabled)return;let{elementId:t}=e.template;return X(`div`,{class:C.utilityNetworkAssociationsElementInput,"data-testid":t,key:t},this._associationsWidgetsMap.get(e)?.render())}getCommonInputProps(e){let{template:t,valid:n,value:r,minLength:i,maxLength:a,required:o,fieldName:s,editable:c,range:{max:l,min:u}}=e,d=!c||this.readOnly,f=this.disabled||this.viewModel.updating,p=this._getErrorToDisplay(e)?`invalid`:`idle`,m=t.hint??void 0,h=!1;return r===k&&(m=this.messages.differentValuesPlaceholder,h=!0),{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":n?`false`:`true`,class:this.classes(C.fieldInput,d?C.inputDisabled:null),status:p,maxLength:a&&a>-1?a:void 0,minLength:i&&i>-1?i:void 0,key:t.elementId,label:s,name:s,max:l??void 0,min:u??void 0,disabled:f,readOnly:d,onblur:this._onComponentBlur,required:o,placeholder:m,value:h?``:r??``,[Z]:t.elementId,[Q]:s,onfocus:this._onComponentFocus}}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);let e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_onFormSubmit(e){e.preventDefault()}_handleDragAndDrop(e){e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`none`)}_getFieldInputFromHTMLElement(e){return this.viewModel.findFieldInput(e.getAttribute(Z))}_afterRadioGroupCreateOrUpdate(e){let t=e.selectedItem,n=e.querySelector(`calcite-radio-button`),r=t||n;r&&this._afterComponentCreateOrUpdate(r)}_onComponentFocus(e){let t=e.target,n=this._getFieldInputFromHTMLElement(t);this._focusedFieldInput=n}_markInputTouched(e){e&&this._touchedInputs.add(e.template.elementId)}_isMultipleChoiceCheckbox(e,t){let n=this._getMultipleChoiceController(t);return e.tagName===`CALCITE-CHECKBOX`&&n?.input!=null}_afterComponentCreateOrUpdate(e){let t=this._getFieldInputFromHTMLElement(e),n=this._focusedFieldInput;this._attemptFocusOnNextRender&&n===t&&(this._attemptFocusOnNextRender=!1,_e(e))}_onComponentBlur(e){let t=e.target,n=this._getFieldInputFromHTMLElement(t);this._isMultipleChoiceCheckbox(t,n)||this._markInputTouched(n),this._focusedFieldInput=null}_onDynamicChoiceBlur(e,t){let n=e.currentTarget;if(this._dynamicChoiceItemSelections.delete(t))return;let r=e.relatedTarget;r instanceof Node&&n.contains(r)||(t.endInteraction(),n.inputValue=t.fieldInput.value===k?this.messages.differentValuesPlaceholder:t.inputValue,this._onComponentBlur(e))}_resetTransientFormState(){this._attemptFocusOnNextRender=!1,this._focusedFieldInput=null,this._attachmentDialogInfo=null,this._selectedAttachmentReplaceFileInput=null,this._attachmentListFilterText=``,this._attachmentFileInputMap.clear()}_parseValue(e,t,n=!1){let r=this._getMultipleChoiceController(t);if(r){let{input:t,values:i}=r;if(t&&i){let t=e;return r.getValueFromCheckboxChange({choiceValue:t.value,isChecked:t.checked,isSelectAllCheckbox:n})}}if(x(t.template,`switch`)){if(e.localName===`calcite-dropdown`&&t.domain){for(let n of t.domain.codedValues)if(n.name===e.selectedItems[0].textContent)return n.code}return e.checked?t.template.input.onValue:t.template.input.offValue}let i=e.value;return i==null||i===``?null:t.dataType===`number`?i===`-0`||i===`-0.`||i===`-0,`?i:parseFloat(i):t.field.type===`date`?parseFloat(i):i}_getMultipleChoiceController(e){return w(e.inputController)?e.inputController:null}_saveInputFromElement(e){let t=this._getFieldInputFromHTMLElement(e);if(!t)return;let n=this._parseValue(e,t);this._saveInput(t,n)}_saveInput(e,t){let{elementId:n}=e.template,r=e?.value,{viewModel:i}=this;if(x(e.template,`switch`)&&i.mode!==`single`){let t=a(this._batchSwitchInputInitialValues,e,()=>e.value);this._batchSwitchInputInitialValues.set(e,t===null?r:t)}t!==r&&(this._markInputTouched(e),!e.isSubtypeField||i.mode===`batch`||!re(i.activeLayer,r,t)?i.setValue(n,t):this._pendingSubtypeChoice||=this._handleSubtypeChoice(e,t))}async _handleSubtypeChoice(e,t){let{value:n,template:r}=e,{elementId:i}=r,{messages:a,viewModel:o,messagesCommon:s}=this,{subtypes:c,activeFeatureIndex:l}=o;if(await o.setValue(i,t),!c?.length)return;let u=c.find(e=>e.code===t),d=c.find(e=>e.code===n)?.name??`${n}`;if(!u)return;let f=Promise.withResolvers();o.pendingSubtypeChoice=f;let m=`update-fields`,h=[{label:a.subtypes.useDefaultValuesOption,value:`update-fields`},{label:a.subtypes.keepCurrentValuesOption,value:`keep-existing`}],g={context:`info`,title:a.subtypes.changeWarningTitle,message:p(a.subtypes.changeWarning,{originalType:d,newType:u.name}),radios:h,defaultRadioSelection:`update-fields`,onRadioSelection:e=>{m=e},actions:{primary:{label:s.apply,action:()=>f.resolve(m),type:`positive`},secondary:{label:s.cancel,type:`neutral`,action:()=>f.resolve(`undo`)}},cancel:()=>f.reject()};try{switch(this.showPrompt(g),await f.promise){case`update-fields`:await o.applySubtypeDefaults(u),await o.handleSubtypeChanged(l);break;case`keep-existing`:await o.handleSubtypeChanged(l);break;case`undo`:await this.viewModel.setValue(i,n)}}finally{o.pendingSubtypeChoice=null,this.clearPrompt(),this._pendingSubtypeChoice=null}}_afterDateComponentCreateOrUpdate(e){this._setDateTimeTimeZoneMap(e),this._afterComponentCreateOrUpdate(e)}_saveValueFromDateComponent(e,t){let{elementId:n}=e.template,r=e.field.type,i=this._dateComponentMap.get(`${n}`);if(!i)return;let a=e.effectiveTimeZone,o=e.value===k?void 0:e.value,s=null;r===`date-only`?s=Array.isArray(t.value)?t.value[0]:t.value:r===`time-only`?(o=G(o),s=G(t.value)):s=r===`timestamp-offset`?t.value==null?null:fe({dateComponent:i.date,timeComponent:i.time,oldValue:o,timeZoneComponent:i.timeZone,defaultTimeZone:a}):t.value==null?null:pe({oldValue:o,dateComponent:i.date,timeZone:a,timeComponent:i.time?.value===k?void 0:i.time}),o!==s&&(this._markInputTouched(e),s===null||!t.value?this.viewModel.setValue(n,null):this.viewModel.setValue(n,s))}_getErrorToDisplay(e){let t=e.compositeError;return e.valid||!t?null:t===q.CONTINGENCY_VIOLATION_ERROR||t===q.CONTINGENCY_VIOLATION_WARNING?t:!this._touchedInputs.has(e.template.elementId)&&!this.viewModel.submitHasBeenAttempted?null:t}_renderViewingAssociationsPage(){return this._associationsList?.render()}_onActiveAssociationsInputChange(e){let t=this._associationsList;t&&(e?(t.associationInput=e,t.viewModel=e.viewModel):t.associationInput=null)}async _setUpAssociationsWidgets(){let e=this.viewModel.activeForm.allUtilityNetworkAssociationsElementInputs;if(this._associationsEnabled&&e.length!==0){await this._setUpUtilityNetworkAssociationList();for(let t of e)this._associationsWidgetsMap.set(t,await this._createAssociationsWidget(t))}}async _setUpUtilityNetworkAssociationList(){if(this._associationsList)return;let e=(await import(`./FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js`)).default;this._associationsList=new e({onSelectLayer:this._onSelectAssociatedLayer.bind(this),onSelectFeature:this._onEditAssociatedFeature.bind(this),onAddAssociation:this._onAddAssociation.bind(this)});let t=this.viewModel.activeAssociationsInput;t&&(this._associationsList.associationInput=t,this._associationsList.viewModel=t.viewModel)}async _createAssociationsWidget(e){return new(await(import(`./Feature/FeatureUtilityNetworkAssociations.js`))).default({viewModel:e.viewModel,onSelectAssociationType:t=>this._onSelectAssociationType(e,t)})}_destroyAssociationsWidgets(){this._associationsWidgetsMap.forEach(e=>o(e)),this._associationsWidgetsMap.clear()}_onSelectAssociationType(e,{listType:t}){this.setActiveAssociationsInput(e),this.setActiveAssociationType(t)}_onSelectAssociatedLayer({layer:e}){this.setActiveAssociationsLayer(e)}async _onEditAssociatedFeature(e){let t=this.callbacks?.editAssociatedFeature,n=this.viewModel.activeAssociationsInput;if(!t||!n?.feature)return;let{association:r,feature:i}=e;await t({parentFeature:n.feature.plainGraphic,association:r,feature:i})}_onAddAssociation(e){let t=this.callbacks?.addAssociation,n=this.viewModel.activeAssociationsInput;if(!t||!n?.feature)return;let{associationType:r,utilityNetwork:i}=e;t({feature:n.feature.plainGraphic,associationType:r,utilityNetwork:i})}_setFocusableInput(e){let t=e&&E(e)?e:this._findFocusableInput(e);this._syncGroupInputStates(),this._focusedFieldInput=t,this._attemptFocusOnNextRender=!0}_findFocusableInput(e){let t=this.viewModel.activeForm.inputs;if(!t.length)return;let n=ie(t),r;if(!e)r=0;else if(T(e)){let t=e.inputs.find(e=>e.visible);r=t?n.indexOf(t):0}else{let i;i=ce(e)&&!e.group.open?e.group.inputs.filter(E)[t.length-1]:e,r=n.indexOf(i)+1}for(let e=r;e<n.length;e++){let t=n[e];if(t.visible&&E(t)){if(this.disabledOrReadOnly&&(t?.inputType===`switch`||t?.inputType===`radio-buttons`))continue;return t}}return null}_onGroupToggle(e,t){e.expanded?(t.open=!0,this._setFocusableInput(t),this.groupDisplay===`sequential`&&this.viewModel.activeForm.allGroupInputs.forEach(e=>{e!==t&&(e.open=!1)})):t.open=!1,this.scheduleRender()}_syncGroupInputStates(){if(this.groupDisplay!==`sequential`)return;let e=this.viewModel.activeForm?.allGroupInputs;if(!e.length)return;let t=e.filter(e=>e.open);t.length===0?e[0].open=!0:t.length>1&&t.slice(1).forEach(e=>e.open=!1)}};e([t()],$.prototype,`activeFeatureIndex`,null),e([t()],$.prototype,`attachmentsEnabled`,null),e([t()],$.prototype,`callbacks`,null),e([t()],$.prototype,`disabled`,null),e([t()],$.prototype,`effectiveTitle`,null),e([t()],$.prototype,`effectiveDisabled`,null),e([t()],$.prototype,`disabledOrReadOnly`,null),e([t()],$.prototype,`features`,null),e([t()],$.prototype,`footerButtonInfos`,null),e([t()],$.prototype,`map`,null),e([t()],$.prototype,`maximumFeatureCount`,null),e([t()],$.prototype,`maximumFeatureCountWithComplexForms`,null),e([t()],$.prototype,`spatialReference`,null),e([t()],$.prototype,`layerInfos`,null),e([t()],$.prototype,`timeZone`,null),e([t()],$.prototype,`headingLevel`,void 0),e([t()],$.prototype,`icon`,null),e([t(),Y(`esri/t9n/common`)],$.prototype,`messagesCommon`,void 0),e([t(),Y(`esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm`)],$.prototype,`messages`,void 0),e([t(),Y(`esri/widgets/FeatureForm/t9n/FeatureForm`)],$.prototype,`featureFormMessages`,void 0),e([t(),Y(`esri/widgets/FeatureTable/t9n/FeatureTable`)],$.prototype,`featureTableMessages`,void 0),e([t(),Y(`esri/core/t9n/Units`)],$.prototype,`messagesUnits`,void 0),e([t()],$.prototype,`page`,null),e([t()],$.prototype,`readOnly`,null),e([t()],$.prototype,`showPrompt`,null),e([t()],$.prototype,`clearPrompt`,null),e([t()],$.prototype,`selectedAttachment`,null),e([t()],$.prototype,`selectedAttachmentDetails`,null),e([t()],$.prototype,`valid`,null),e([t({type:S}),ge([`attachments-change`,`value-change`,`values-change`,`submit`])],$.prototype,`viewModel`,void 0),e([t({type:R,nonNullable:!0})],$.prototype,`visibleElements`,void 0),e([t()],$.prototype,`groupDisplay`,void 0),e([t()],$.prototype,`_formHeaderVisible`,null),e([t()],$.prototype,`_associationsEnabled`,null),e([t()],$.prototype,`_associationsList`,void 0),e([t()],$.prototype,`_attemptFocusOnNextRender`,void 0),e([t()],$.prototype,`_formId`,null),e([t()],$.prototype,`_focusedFieldInput`,void 0),e([t()],$.prototype,`_pendingSubtypeChoice`,void 0),e([t()],$.prototype,`_relatedRecordsEnabled`,null),e([t()],$.prototype,`_listObserverNode`,void 0),e([t()],$.prototype,`_attachmentDialogInfo`,void 0),e([t()],$.prototype,`_attachmentListFilterText`,void 0),e([t()],$.prototype,`_prompt`,void 0),e([t()],$.prototype,`test`,null),$=e([n(`esri.widgets.BatchAttributeForm`)],$);function ye(e){switch(e){case`audio`:return v(`audio/mpeg`);case`video`:return v(`video/mp4`);case`image`:return v(`image/png`);default:return`camera`}}const be=$;export{be as default};
2
+ import{__decorate as e}from"tslib";import{property as t,subclass as n}from"../core/accessorSupport/decorators.js";import{deprecateWidget as r}from"../core/deprecate.js";import i from"../core/Logger.js";import{getOrCreateMapValue as a}from"../core/MapUtils.js";import{destroyMaybe as o}from"../core/maybe.js";import s from"../core/ReactiveMap.js";import{watch as c,when as l,on as u,sync as d}from"../core/reactiveUtils.js";import{formatFileSize as f}from"../core/unitFormatUtils.js";import{substitute as p}from"../intl.js";import{formatDate as m}from"../intl/date.js";import{isIntegerField as h}from"../layers/support/fieldUtils.js";import{isString as g}from"../support/guards.js";import{getAttachmentTypeCategory as _,getCalciteIconForAttachment as v}from"./Attachments/support/attachmentUtils.js";import{getAttachmentKey as y,isImageAttachment as b,getAttachmentFilenameParts as ee}from"./BatchAttributeForm/attachmentUtils.js";import{getHiddenFieldsValidationErrorMessage as te,getMessageString as ne,isElementTemplateWithInputType as x,subtypeChangeShouldPrompt as re,flattenInputs as ie}from"./BatchAttributeForm/batchAttributeFormUtils.js";import S from"./BatchAttributeForm/BatchAttributeFormViewModel.js";import{css as C}from"./BatchAttributeForm/css.js";import{isDynamicChoiceController as ae,isMultipleChoiceController as w}from"./BatchAttributeForm/inputs/support/controllerUtils.js";import{isGroupInput as T,isFieldInput as E,isTextElementInput as oe,isRelationshipElementInput as se,isAttachmentElementInput as D,isUtilityNetworkAssociationsElementInput as O,differentValuesString as k,getNormalizedFieldName as A,isGroupedInput as j}from"./BatchAttributeForm/inputs/support/inputUtils.js";import{otherChoiceCheckedPlaceholderValue as ce,canRestoreMultipleChoiceOtherChoiceDraftValue as le,clearMultipleChoiceOtherChoiceStateForViewModel as M}from"./BatchAttributeForm/inputs/support/multipleChoiceInputUtils.js";import{makeViewingEditedAttachmentFooterButtons as ue,makeViewingAttachmentFooterButtons as N,makeCancelFooterButton as P,makeDefaultFooterButtons as F}from"./BatchAttributeForm/interfaceUtils.js";import{loadRelationshipDetailsComponents as I,RelationshipDetails as L}from"./BatchAttributeForm/rendered-content/RelationshipDetails.js";import R from"./BatchAttributeForm/VisibleElements.js";import{Prompt as z}from"./Editor/components/Prompt.js";import{downloadAttachmentInfo as B}from"./FeatureTable/support/exportUtils.js";import{loadCalciteComponents as V}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as H,getIntlOptionsForField as de,prepareISOFieldValueForDateComponents as U,prepareUnixFieldValueForDateComponents as W,normalizeTimeOnlyString as G,getISOFieldValueFromDateComponents as fe,getUnixFieldValueFromDateComponents as pe}from"./support/dateUtils.js";import{isEmptyValue as K,ContingentValuesValidationError as q}from"./support/forms/formUtils.js";import{globalCss as J}from"./support/globalCss.js";import{Heading as me}from"./support/Heading.js";import{calciteListFilterProps as he}from"./support/listUtils.js";import{messageBundle as Y,vmEvent as ge,tsx as X}from"./support/widget.js";import{setFocus as _e}from"./support/widgetUtils.js";import ve from"./Widget.js";const Z=`data-element-id`,Q=`data-field-name`;let $=class extends ve{constructor(e){let{suppressDeprecationWarning:t,...n}=e??{};super(n),this.headingLevel=2,this.messagesCommon=null,this.messages=null,this.featureFormMessages=null,this.featureTableMessages=null,this.messagesUnits=null,this.viewModel=new S,this.visibleElements=new R,this.groupDisplay=`all`,this._associationsList=null,this._associationsWidgetsMap=new s,this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._touchedInputs=new Set,this._dynamicChoiceItemSelections=new WeakSet,this._focusedFieldInput=null,this._pendingSubtypeChoice=null,this._batchSwitchInputInitialValues=new Map,this._listObserverNode=null,this._listObserver=new IntersectionObserver(e=>{e.length&&e[0].isIntersecting&&this.viewModel.activeRelationshipInput?.incrementPage()},{root:window.document}),this._attachmentDialogInfo=null,this._attachmentListFilterText=``,this._attachmentFileInputMap=new Map,this._prompt=null,this._selectedAttachmentReplaceFileInput=null,this._afterListObserverCreated=e=>{this.viewModel.activeRelationshipInput&&(this._listObserverNode=e)},this._afterListObserverRemoved=()=>{this._listObserverNode=null},this._maximizeSelectedAttachment=()=>{this._attachmentDialogInfo=this.selectedAttachmentDetails},this._enterAttachmentReplaceView=()=>{let e=this.selectedAttachmentDetails;this._canReplaceSelectedAttachment()&&e&&(e.input.clearValidationCriteriaState(),this.viewModel.setShowingSelectedAttachmentReplacePage(!0))},this._setSelectedAttachmentReplaceFileInput=e=>{this._selectedAttachmentReplaceFileInput=e},this._openSelectedAttachmentReplaceFilePicker=()=>{this._canReplaceSelectedAttachment()&&this._selectedAttachmentReplaceFileInput?.click()},this._resetSelectedAttachmentName=()=>{let e=this.selectedAttachmentDetails;if(!e?.attachment)return;let t=e.input.getAttachmentEditState(e.attachment).initialName;if(t==null)return;let n=e.input.template.elementId,r=y(e.attachment);this.viewModel.stageRenameAttachment(n,r,t)},this._closeAttachmentDialog=()=>{this.hideAttachmentDialog()},this._saveInputFromElement=this._saveInputFromElement.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreateOrUpdate=this._afterDateComponentCreateOrUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this),t||(this.announceDeprecation=()=>{r(i.getLogger(this),`Editor`,`arcgis-editor`,{version:`5.0`})})}initialize(){this.addHandles([c(()=>this.features.toArray(),()=>{this._dateComponentMap.clear(),M(this.viewModel,{includeDraftValues:!0})}),c(()=>this.viewModel.activeForm,()=>{this._batchSwitchInputInitialValues.clear(),this._resetTransientFormState(),M(this.viewModel),this._syncGroupInputInitialStates(),this._setFocusableInput()}),c(()=>this.viewModel.selectedAttachmentAddElementId,()=>{this.hideAttachmentDialog()}),l(()=>!this.selectedAttachmentDetails,()=>this.hideAttachmentDialog()),c(()=>this.viewModel.selectedAttachmentListElementId,()=>{this._attachmentListFilterText=``}),c(()=>[this.viewModel.activeRelationshipInput,this._listObserverNode],()=>this._onObserverChange()),u(()=>this.viewModel,`submit`,()=>{this.valid||this.goToFirstError()}),c(()=>[this._associationsEnabled,this.viewModel.activeForm.allUtilityNetworkAssociationsElementInputs],()=>this._setUpAssociationsWidgets(),d),c(()=>this.viewModel.activeAssociationsInput,e=>this._onActiveAssociationsInputChange(e)),c(()=>this.groupDisplay,()=>this._syncGroupInputInitialStates())])}loadDependencies(){return Promise.all([V({action:()=>import(`@esri/calcite-components/dist/components/calcite-action`),autocomplete:()=>import(`@esri/calcite-components/dist/components/calcite-autocomplete`),"autocomplete-item":()=>import(`@esri/calcite-components/dist/components/calcite-autocomplete-item`),block:()=>import(`@esri/calcite-components/dist/components/calcite-block`),button:()=>import(`@esri/calcite-components/dist/components/calcite-button`),checkbox:()=>import(`@esri/calcite-components/dist/components/calcite-checkbox`),chip:()=>import(`@esri/calcite-components/dist/components/calcite-chip`),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`),dialog:()=>import(`@esri/calcite-components/dist/components/calcite-dialog`),dropdown:()=>import(`@esri/calcite-components/dist/components/calcite-dropdown`),"dropdown-group":()=>import(`@esri/calcite-components/dist/components/calcite-dropdown-group`),"dropdown-item":()=>import(`@esri/calcite-components/dist/components/calcite-dropdown-item`),icon:()=>import(`@esri/calcite-components/dist/components/calcite-icon`),input:()=>import(`@esri/calcite-components/dist/components/calcite-input`),"input-date-picker":()=>import(`@esri/calcite-components/dist/components/calcite-input-date-picker`),"input-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`),switch:()=>import(`@esri/calcite-components/dist/components/calcite-switch`),"text-area":()=>import(`@esri/calcite-components/dist/components/calcite-text-area`),"radio-button":()=>import(`@esri/calcite-components/dist/components/calcite-radio-button`),"radio-button-group":()=>import(`@esri/calcite-components/dist/components/calcite-radio-button-group`)}),I()])}destroy(){this._destroyAssociationsWidgets(),this._associationsList=o(this._associationsList),this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode)}get activeFeatureIndex(){return this.viewModel.activeFeatureIndex}set activeFeatureIndex(e){this.viewModel.activeFeatureIndex=e}get attachmentsEnabled(){return this.viewModel.attachmentsEnabled}set attachmentsEnabled(e){this.viewModel.attachmentsEnabled=e}get callbacks(){return this.viewModel.callbacks}set callbacks(e){this.viewModel.callbacks=e}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get effectiveTitle(){let{features:e,messages:t,page:n}=this;return t?n===`replacing-attachment`?t.titles.replaceAttachment:n===`viewing-attachment-details`?t.titles.editAttachment:n===`adding-attachments`?t.titles.addAttachments:n===`viewing-attachments`?t.titles.attachments:e.length===1||this.activeFeatureIndex>-1?t.titles.editFeature:e.length>1?t.titles.editFeatures:``:``}get effectiveDisabled(){return this.disabledOrReadOnly||this.viewModel.updating}get disabledOrReadOnly(){return this.disabled||this.readOnly}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get footerButtonInfos(){if(!this.features.length||!this.messages||!this.messagesCommon)return[];let{messages:e,messagesCommon:t,page:n}=this,r=this.effectiveDisabled;if(n===`adding-attachments`||n===`replacing-attachment`)return[];if(n===`viewing-attachment-details`){let t=this.selectedAttachmentDetails,n=t?.input?.getAttachmentEditState(t.attachment);return!t?.input||!n?[]:n.isRenamed||n.isReplaced?ue({doneOnclick:()=>this._setSelectedAttachment(null),messages:e.footerButtons,resetOnclick:()=>this._resetSelectedAttachmentChanges(),resetDisabled:this._disableAttachmentModification(t.input)}):N({deleteDisabled:this._disableAttachmentModification(t.input),deleteOnclick:()=>this._deleteSelectedAttachment(),doneOnclick:()=>this._setSelectedAttachment(null),messages:e.footerButtons})}return n===`viewing-associated-features`?P({messages:t,purpose:`cancel-viewing-associated-features`,onclick:()=>this.goBack()}):n===`viewing-associated-layers`?P({messages:t,purpose:`cancel-viewing-associated-layers`,onclick:()=>this.goBack()}):n===`viewing-attachments`||n===`viewing-related-records`?[]:F({disabled:r||!this.valid,formId:this._formId,messages:e,callback:()=>this.submit()})}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get maximumFeatureCount(){return this.viewModel.maximumFeatureCount}set maximumFeatureCount(e){this.viewModel.maximumFeatureCount=e}get maximumFeatureCountWithComplexForms(){return this.viewModel.maximumFeatureCountWithComplexForms}set maximumFeatureCountWithComplexForms(e){this.viewModel.maximumFeatureCountWithComplexForms=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get icon(){return`edit-attributes`}set icon(e){this._overrideIfSome(`icon`,e)}get page(){return this.viewModel.page}get readOnly(){return this.viewModel.readOnly}set readOnly(e){this.viewModel.readOnly=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)}get selectedAttachment(){return this.viewModel.selectedAttachment}get selectedAttachmentDetails(){return this.viewModel.selectedAttachmentDetails}get valid(){return this.viewModel.valid}get _formHeaderVisible(){return this.viewModel.mode===`batch`||!this.viewModel.activeFeature?!1:!!(this.viewModel.formDescription||this.viewModel.formTitle)}get _associationsEnabled(){let{callbacks:e}=this;return!!(e?.addAssociation||e?.editAssociatedFeature)}get _formId(){return`${this.id}-form`}get _relatedRecordsEnabled(){let{callbacks:e}=this;return!!(e&&(e.addRelatedRecord||e.editRelatedRecord))}async goBack(){return this.viewModel.goBack()}async goHome(){return this.viewModel.goHome()}goToFirstError(){let e=this.viewModel.getFirstVisibleInvalidFieldInput();if(!e)return;let{groupInput:t}=e;t&&(t.open||=!0),this._setFocusableInput(e.input),this.scheduleRender()}render(){return X(`div`,{class:this.classes(C.base,J.widget,J.panel),ondragover:this._handleDragAndDrop,ondrop:this._handleDragAndDrop},this._renderContent(),this._renderAttachmentDialog(),this._prompt?X(z,{...this._prompt,headingLevel:this.headingLevel}):void 0)}setActiveAssociationsInput(e){this.viewModel.setActiveAssociationsInput(e)}setActiveAssociationsLayer(e){this.viewModel.setActiveAssociationsLayer(e)}setActiveAssociationType(e){this.viewModel.setActiveAssociationType(e)}submit(){return this.viewModel.submit()}get test(){return{saveInput:this._saveInput.bind(this),pendingSubtypeChoice:this._pendingSubtypeChoice,touchedInputs:this._touchedInputs}}_setDateTimeTimeZoneMap(e){let{datePart:t,elementId:n}=e.dataset,r=a(this._dateComponentMap,`${n}`,()=>({}));switch(t){case`date`:r.date=e;break;case`time`:r.time=e;break;case`timeZone`:r.timeZone=e}}_renderContent(){let{messages:e,viewModel:t}=this,{status:n}=t;if(n===`failed`)return t.hasTooManyComplexFeatures?this._renderErrorNotice(p(e.formFailedToLoadTooManyComplexFeatures,{num:t.maximumFeatureCountWithComplexForms})):t.hasTooManyFeatures?this._renderErrorNotice(p(e.formFailedToLoadTooManyFeatures,{num:t.maximumFeatureCount})):e.formFailedToLoad;if(t.hasLayersWithContingentValues&&this.viewModel.features.length>1)return this._renderErrorNotice(e.unsupportedContingentValues);if(n===`loading`&&this.visibleElements.loadingIndicator)return X(`calcite-loader`,{key:`loader`,label:this.messagesCommon?.loading});if(this.features.length!==0)return this._renderForm()}_renderErrorNotice(e,t=`warning`){return X(`calcite-notice`,{class:C.noticeError,icon:!0,kind:t,open:!0},X(`div`,{slot:`message`},e))}_renderForm(){return X(`form`,{class:C.form,id:this._formId,inert:!!this._prompt,onsubmit:this._onFormSubmit},this.viewModel.expressionEvaluationFailed&&this.visibleElements.expressionsErrorNotice&&this._renderErrorNotice(this.messages.expressionEvaluationFailed),this._renderInvisibleFieldsError(),this._renderPage())}_renderPage(){switch(this.page){case`adding-attachments`:return this._renderAttachmentAddPage();case`viewing-attachment-details`:case`replacing-attachment`:return this._renderAttachmentDetailPage();case`viewing-attachments`:return this._renderAttachmentListPage();case`viewing-associated-layers`:case`viewing-associated-features`:return this._renderViewingAssociationsPage();case`viewing-related-categories`:case`viewing-related-records`:return this._renderRelationshipListPage();default:return this._renderDefaultPage()}}_renderInvisibleFieldsError(){let{viewModel:e}=this,{hasNonActiveInvalidFeatures:t,activeForm:n}=e,r;if(!e.submitHasBeenAttempted)return null;if(n.invalidHiddenInputs.length>0){if(r=te(n,e.mode,this.messages),this.viewModel.mode===`batch`){let e=n.invalidHiddenInputs.filter(e=>e.effectiveVisibilityCode===`hidden:group-visibility-expression:all-features`||e.visibilityCode===`hidden:visibility-expression:all-features`);e.length>0?r+=` (${e.map(e=>e.label).join(`, `)})`:r=null}else r=null}else if(t)return null;return r?this._renderErrorNotice(r,`danger`):null}_renderDefaultPage(){return[this._renderReadOnlyNotice(),this._renderFormHeader(),this._renderFormContent()]}_renderReadOnlyNotice(){if((this.disabled||this.readOnly)&&this.visibleElements.readOnlyNotice)return X(`calcite-notice`,{class:C.disabledNotice,"data-testid":`read-only-notice`,icon:`read-only-non-editable`,kind:`brand`,open:!0,scale:`s`,width:`full`},X(`div`,{slot:`message`},this.featureFormMessages.disabledForm))}_renderFormHeader(){let{formTitle:e,formDescription:t}=this.viewModel;if(!this._formHeaderVisible)return;let n=e?X(me,{key:`title`,level:this.headingLevel},e):void 0,r=t?X(`p`,{class:C.description,key:`description`},t):void 0;return X(`div`,{class:C.formHeader},n,r)}_renderFormContent(){return this.viewModel.hasVisibleInputs?this.viewModel.activeForm.inputs.filter(e=>e.visible).map(e=>this._renderInput(e)):this._renderErrorNotice(this.messages.noVisibleFields[this.viewModel.noVisibleElementsReason])}_renderInput(e){if(T(e))return this._renderGroupInput(e);if(E(e))return this._renderLabeledField(e);if(oe(e))return this._renderTextComponent(e);if(se(e))return this._renderRelationshipElementInput(e);if(D(e))return this._renderAttachmentElementInput(e);if(O(e))return this._renderUtilityNetworkAssociationsElementInput(e)}_renderGroupInput(e){let{inputs:t,template:n,open:r}=e,i=t.filter(e=>e.visible),a=e.label??``,o=this._focusedFieldInput?.group===e,s=this.groupDisplay===`sequential`;return X(`calcite-block`,{class:this.classes(C.group,s?C.groupSequential:null,o?C.groupActive:null,this.disabled?C.inputDisabled:null),description:e.description??void 0,expandable:!0,expanded:r,heading:a,headingLevel:this.headingLevel,key:`{${n.elementId}-key}`,label:a,onCalciteBlockCollapse:()=>{e.open=!1},onCalciteBlockExpand:()=>{this._onGroupExpand(e)}},i.map(e=>this._renderInput(e)))}_renderLabeledField(e){let{elementId:t}=e.template,{label:n,required:r,dataType:i}=e,a=r?p(this.messages.requiredFieldLabel,{name:n}):n;return X(`calcite-label`,{"aria-label":a,class:C.label,key:`field--${t}`},X(`div`,{class:C.labelTextContent,key:`labelTextContainer`},n,r?X(`span`,{"aria-hidden":`true`,title:this.messagesCommon.required},`*`):void 0),i===`unsupported`?this._renderReadOnlyComponent(e):this._renderFieldInput(e),this._renderAuxiliaryText(e))}_renderFieldInput(e){let t=this.getCommonInputProps(e),{dataType:n}=e;return ae(e.inputController)?this._renderDynamicChoiceComponent({input:e,props:t,controller:e.inputController}):e.domain?.type===`coded-value`?this._renderCodedInputs({input:e,props:t}):w(e.inputController)?this._renderMultipleChoiceComponent({input:e,props:t}):n===`date`?this._renderDateComponents(e,t):(t.disabled=this.disabled,t.readOnly=t.readOnly||this.viewModel.updating,n===`number`?this._renderNumberComponent(e,t):this._renderStringComponent(e,t))}_renderAuxiliaryText(e){let{description:t}=e,n=this._getErrorToDisplay(e),r=n?ne(e,n,this.messages):null;return r?X(`calcite-input-message`,{icon:!0,status:`invalid`},r):e.valueIsOutOfDomain&&(this._touchedInputs.has(e.template.elementId)||this.viewModel.submitHasBeenAttempted)?X(`calcite-input-message`,{icon:!0,status:`idle`},this.messages.subtypes.fieldOutOfSubtypeDomainWarning):t?X(`calcite-input-message`,{class:C.description,icon:!1,status:`idle`},t):null}_renderCodedInputs({input:e,props:t}){let n=e.input?.type??null,r=e.codedValueOptions;switch(n){case`switch`:return this._renderSwitchField({input:e,props:t});case`radio-buttons`:return this._renderRadioButtonGroupComponent({input:e,options:r,props:t});default:return this._renderComboBoxComponent({options:r,props:t,input:e})}}_renderDynamicChoiceComponent({input:e,props:t,controller:n}){let r=n.filteredChoices,i=t.readOnly||t.disabled,a=e.showNoValueLabel||this.messages.empty,o=n.evaluated&&!n.evaluating&&!n.choices.length&&X(`calcite-notice`,{appearance:`transparent`,kind:`neutral`,open:!0,scale:`s`,slot:`content-bottom`,width:`full`},X(`div`,{slot:`message`},e.showNoValueOptionEnabled?this.messages.noDynamicChoicesWithNoValue:this.messages.noDynamicChoices)),s=t=>{this._saveInput(e,t)},c=(e,t)=>{this._dynamicChoiceItemSelections.delete(n);let r=e.closest(`calcite-autocomplete`);if(r){let e=t==null?``:n.getLabel(t);n.filterValue=``,r.inputValue=e}s(t)},u=({currentTarget:t})=>{let r=t.inputValue??``;n.filterValue=r,!r&&e.value!=null&&s(null)},d=e.showNoValueOptionEnabled?X(`calcite-autocomplete-item`,{disabled:i,heading:a,key:`dynamic-choice-empty`,selected:e.value==null,value:``,onCalciteAutocompleteItemSelect:({currentTarget:e})=>c(e,null),onpointerdown:()=>{this._dynamicChoiceItemSelections.add(n)}}):null,f=t=>{this.addHandles(l(()=>!n.initialEvaluationInProgress,()=>{t.inputValue=e.value===k?this.messages.differentValuesPlaceholder:e.value==null?``:n.inputValue},{once:!0,initial:!0}))};return X(`calcite-autocomplete`,{...t,afterCreate:f,disabled:i&&!n.interactionActive,loading:n.initialEvaluationInProgress,placeholder:e.value==null?a:t.placeholder,value:t.value===k?this.messages.differentValuesPlaceholder:String(t.value),onblur:e=>this._onDynamicChoiceBlur(e,n),onCalciteAutocompleteBeforeOpen:()=>n.beginInteraction(),onCalciteAutocompleteTextInput:u},n.evaluating?X(`calcite-loader`,{key:`dynamic-choice-loader`,label:this.messagesCommon.loading,scale:`s`,slot:`content-top`}):[o,d,...r.map(t=>X(`calcite-autocomplete-item`,{disabled:i,heading:t.name,key:`dynamic-choice-${t.code}`,selected:t.code===e.value,value:String(t.code),onCalciteAutocompleteItemSelect:({currentTarget:e})=>c(e,t.code),onpointerdown:()=>{this._dynamicChoiceItemSelections.add(n)}}))])}_renderMultipleChoiceComponent({input:e,props:t}){let{messages:n}=this,r=this._getMultipleChoiceController(e);if(!r)return null;let{input:i}=r,a=i.includeSelectAllChoices===!0,{checkboxStatesByValue:o,selectAllState:s}=r.selectionState,c=s.checked?n.deselectAllLabel:n.selectAllLabel,l=r.otherChoiceRenderState;return X(`div`,{class:C.multipleChoiceInput,key:`${t.key}-multiple-choice-group`},a?this._renderMultipleChoiceSelectAllCheckbox({props:t,selectAllState:s,selectAllLabel:c,handleSelectAllCheckboxChange:t=>{this._saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t,isSelectAllCheckbox:!0})}}):null,this._renderMultipleChoiceChoiceCheckboxes({input:e,props:t,checkboxStatesByValue:o,handleChoiceCheckboxChange:t=>{this._saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t})}}),l.shouldShow?this._renderMultipleChoiceOtherChoice({props:t,includeSelectAllChoices:a,otherChoiceRenderState:l,handleOtherChoiceCheckboxChange:t=>{let{fieldName:n}=l;n&&this._saveOtherChoiceCheckboxValue({input:e,isChecked:t.checked,otherChoiceFieldName:n})},handleOtherChoiceInputChange:t=>{this._saveValueFromMultipleChoiceTextInput({input:e,textInput:t,otherChoiceFieldName:l.fieldName??void 0})},differentValuesPlaceholder:n.differentValuesPlaceholder}):null)}_renderMultipleChoiceSelectAllCheckbox({props:e,selectAllState:t,selectAllLabel:n,handleSelectAllCheckboxChange:r}){return X(`calcite-checkbox`,{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e[`aria-invalid`],checked:t.checked,class:C.multipleChoiceSelectAll,"data-element-id":e[Z],disabled:e.readOnly||e.disabled,indeterminate:t.indeterminate,key:`${e.key}-select-all`,label:n,labelText:n,value:`esri_BatchAttributeForm_select_all`,onblur:e.onblur,onCalciteCheckboxChange:({currentTarget:e})=>r(e),onfocus:e.onfocus})}_renderMultipleChoiceChoiceCheckboxes({input:e,props:t,checkboxStatesByValue:n,handleChoiceCheckboxChange:r}){let i=this._getMultipleChoiceController(e);if(!i)return[];let{choices:a}=i;return a.map(e=>{let i=n.get(e.value)??{checked:!1,indeterminate:!1};return X(`calcite-checkbox`,{afterCreate:t.afterCreate,afterUpdate:t.afterUpdate,"aria-invalid":t[`aria-invalid`],checked:i.checked,class:t.class,"data-element-id":t[Z],disabled:t.readOnly||t.disabled,indeterminate:i.indeterminate,key:`${t.key}-${e.value}`,label:e.label,labelText:e.label,value:e.value,onblur:t.onblur,onCalciteCheckboxChange:({currentTarget:e})=>r(e),onfocus:t.onfocus})})}_renderMultipleChoiceOtherChoice({props:e,includeSelectAllChoices:t,otherChoiceRenderState:n,handleOtherChoiceCheckboxChange:r,handleOtherChoiceInputChange:i,differentValuesPlaceholder:a}){let o=n.label??this.messages.otherOptionLabel;return X(`div`,{class:this.classes(C.multipleChoiceOtherChoice,t?C.multipleChoiceOtherChoiceWithSelectAll:null),key:`${e.key}-other-choice`},X(`calcite-checkbox`,{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e[`aria-invalid`],checked:n.checkboxState.checked,class:e.class,"data-element-id":e[Z],disabled:e.readOnly||e.disabled,indeterminate:n.checkboxState.indeterminate,key:`${e.key}-other-choice-checkbox`,label:o,labelText:o,value:`esri_BatchAttributeForm_other_choice`,onblur:e.onblur,onCalciteCheckboxChange:({currentTarget:e})=>r(e),onfocus:e.onfocus}),n.checkboxState.checked?X(`calcite-input`,{afterCreate:e.afterCreate,afterUpdate:e.afterUpdate,"aria-invalid":e[`aria-invalid`],"aria-label":o,class:C.textElementInput,"data-element-id":e[Z],disabled:e.readOnly||e.disabled,key:`${e.key}-other-choice-input`,maxLength:n.maxLength,placeholder:n.value===k?a:n.hint,status:n.status,type:`text`,value:n.normalizedValue===k?``:n.normalizedValue?String(n.normalizedValue):``,onblur:e.onblur,onCalciteInputInput:({currentTarget:e})=>i(e),onfocus:e.onfocus}):null)}async _saveValueFromMultipleChoiceCheckbox({input:e,checkbox:t,isSelectAllCheckbox:n=!1}){this._markInputTouched(e);let r=this._getMultipleChoiceController(e);if(!r)return;if(r.input&&!n&&this.viewModel.mode===`batch`){await this._saveMultipleChoiceCheckboxValueByFeature({input:e,checkbox:t});return}let i=e.value,a=this._parseValue(t,e,n);a!==i&&await this.viewModel.setValue(e.template.elementId,a)}async _saveValueFromMultipleChoiceTextInput({input:e,textInput:t,otherChoiceFieldName:n}){if(!n)return;let r=t.value,i=r==null||r===``?null:r,a=this._getMultipleChoiceController(e);if(!a)return;a.initializeExplicitOtherChoiceCheckedState(),a.stashOtherChoiceDraftValueForFeatures(e.features,i);let o=A(e,n);o&&await this.viewModel.setValueForFieldName(o,i,Array.from(e.features,e=>e.source))}async _saveOtherChoiceCheckboxValue({input:e,isChecked:t,otherChoiceFieldName:n}){let r=this._getMultipleChoiceController(e);if(!r)return;r.setExplicitOtherChoiceCheckedState(t),this._markInputTouched(e),t||r.setOtherChoiceDraftValuesFromFeatures(e.features.toArray());let i=A(e,n);if(!i)return;let a=new Map;for(let i of e.features){let e=i.getAttribute(n);if(t){if(!K(e))continue;let t=r.getOtherChoiceDraftValue(i),n=le(t)?t:ce;a.set(i,n)}else e!=null&&a.set(i,null)}a.size!==0&&await this.viewModel.setValuePerFeatureForFieldName(i,new Map(Array.from(a,([e,t])=>[e.source,t])))}async _saveMultipleChoiceCheckboxValueByFeature({input:e,checkbox:t}){let n=this._getMultipleChoiceController(e);if(!n)return;let r=new Map(e.features.map(r=>[r,n.getUpdatedValueForFeature({choiceValue:t.value,currentValue:r.getAttribute(e.fieldName),isChecked:t.checked})]));r.size!==0&&await this.viewModel.setFieldInputValuePerFeature(e,r)}_renderSwitchField({input:e,props:t}){if((this._batchSwitchInputInitialValues.get(e)===k||e.value===k)&&this.viewModel.mode===`batch`){let n={dropdown:{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,disabled:t.readOnly,open:!1,onblur:t.onblur,onfocus:t.onfocus,[Z]:t[Z]},trigger:{appearance:`transparent`,iconEnd:`chevron-down`,kind:`neutral`,slot:`trigger`,label:t.label},group:{mode:`single`}};return this._renderDropdownComponent({buttonValue:e.value,dropdownProps:n,options:[{name:this.messages.differentValuesPlaceholder,value:k,disabled:!0},...e.codedValueDomainOptions]})}return this._renderSwitchComponent({input:e,props:t})}_renderSwitchComponent({input:e,props:t}){return X(`calcite-switch`,{...t,checked:x(e.template,`switch`)?e.value===e.template.input.onValue:!1,class:C.inputSwitch,disabled:t.readOnly||t.disabled,onCalciteSwitchChange:({currentTarget:e})=>this._saveInputFromElement(e)})}_renderDropdownComponent({buttonValue:e,options:t,dropdownProps:n}){let{trigger:r,dropdown:i,group:a}=n;return X(`calcite-dropdown`,{...i,topLayerDisabled:this.topLayerDisabled,onCalciteDropdownSelect:({currentTarget:e})=>this._saveInputFromElement(e)},X(`calcite-button`,{...r},e===k?this.messages.differentValuesPlaceholder:e),X(`calcite-dropdown-group`,{selectionMode:a.mode},t.map(t=>X(`calcite-dropdown-item`,{disabled:t.disabled,label:String(t.name),selected:e===t.value},t.name))))}_renderComboBoxComponent({input:e,options:t,props:n}){let r=this.viewModel.editType===`INSERT`,i=this._touchedInputs.has(e?.template.elementId),a=r&&e.showNoValueOptionEnabled&&!i?()=>{}:n.onblur,o={...n,onblur:a};return X(`calcite-combobox`,{...o,clearDisabled:e.isSubtypeField,selectionMode:`single`,topLayerDisabled:this.topLayerDisabled,value:n.placeholder===this.messages.differentValuesPlaceholder?k:String(n.value),onCalciteComboboxChange:({currentTarget:t})=>{t.value!==k&&(e.isSubtypeField&&t.selectedItems.length===0?t.value=`${e.value}`:this._saveInputFromElement(t))}},this.renderComboboxOptionsList({input:e,options:t,props:n}))}renderComboboxOptionsList({input:e,options:t,props:n}){let r=e=>e.map(e=>{let{value:t}=e,r=K(e.value)?this.messages.empty:e.name;return X(`calcite-combobox-item`,{heading:r,key:`#${t}`,selected:n.value===t,value:`${t}`})}),i=[],{messages:a}=this;t.other.length>0&&i.push(X(`calcite-combobox-item-group`,{key:`other`,label:a.other},r(t.other))),t.unsupported.length>0&&i.push(X(`calcite-combobox-item-group`,{key:`unsupported`,label:a.unsupported},r(t.unsupported)));let o=r(t.recommended);i.length>0?i.unshift(X(`calcite-combobox-item-group`,{key:`recommended`,label:a.recommended},o)):i=o;let s=n.placeholder===this.messages.differentValuesPlaceholder,c=!s&&K(n.value);return e.showNoValueOptionEnabled&&!t.containsEmptyOption&&i.unshift(X(`calcite-combobox-item`,{heading:e.showNoValueLabel||this.messages.empty,key:`empty-option`,selected:c,value:``})),s&&i.unshift(X(`calcite-combobox-item`,{heading:this.messages.differentValuesPlaceholder,key:k,selected:!0,value:k})),i}_renderRadioButtonGroupComponent({input:e,options:t,props:n}){let r=[...t.recommended,...t.other,...t.unsupported].map(({name:t,value:r})=>this._renderRadioButtons({label:t,value:r,selected:r===e.value,props:n}));if(e.showNoValueOptionEnabled&&!t.containsEmptyOption){let t=e.showNoValueLabel||this.messages.empty,i=K(e.value);r.unshift(this._renderRadioButtons({label:t,value:``,selected:i,props:n}))}return X(`calcite-radio-button-group`,{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:C.inputRadioGroup,"data-field-name":n[Q],disabled:n.readOnly||n.disabled,key:`${n.key}-radio-group`,layout:`vertical`,name:`${n.name}-${this.id}`,required:n.required},r,n.placeholder===this.messages.differentValuesPlaceholder?X(`calcite-label`,{class:C.placeholderRadio,key:n.label,layout:`inline`},X(`calcite-radio-button`,{checked:!0,class:C.inputRadio,disabled:!0,value:n.placeholder}),n.placeholder):null)}_renderRadioButtons({value:e,selected:t,label:n,props:r}){return X(`calcite-label`,{class:C.inputRadioLabel,key:r.label,layout:`inline`},X(`calcite-radio-button`,{...r,afterCreate:void 0,afterUpdate:void 0,checked:t,class:C.inputRadio,disabled:r.readOnly||r.disabled,name:void 0,value:e,onCalciteRadioButtonChange:({currentTarget:e})=>{e.checked&&this._saveInputFromElement(e)}}),n)}_renderStringComponent(e,t){let{template:n}=e;return!n.field.editable||this.readOnly?this._renderReadOnlyComponent(e):n.input?.type===`text-area`?X(`calcite-text-area`,{...t,class:this.classes(C.individualElement),resize:`vertical`,value:t.value?String(t.value):``,onblur:n=>{t.onblur(n),e.userHasChangedValue&&this._saveInputFromElement(n.currentTarget)},onCalciteTextAreaInput:t=>{e.userHasChangedValue=!0,t.currentTarget.value===``&&this._saveInputFromElement(t.currentTarget)}}):X(`calcite-input`,{...t,class:this.classes(C.individualElement),type:`text`,value:t.value?String(t.value):``,onblur:n=>{t.onblur(n),e.userHasChangedValue&&this._saveInputFromElement(n.currentTarget)},onCalciteInputInput:t=>{e.userHasChangedValue=!0,t.currentTarget.value===``&&this._saveInputFromElement(t.currentTarget)}})}_renderNumberComponent(e,t){let n=h(e.field);return X(`calcite-input-number`,{...t,integer:n,step:n?1:`any`,type:`number`,value:n&&t.value!==``?Math.round(parseFloat(String(t.value))).toString():String(t.value),onblur:n=>{t.onblur(n),e.userHasChangedValue&&this._saveInputFromElement(n.currentTarget)},onCalciteInputNumberInput:t=>{e.userHasChangedValue=!0,t.currentTarget.value===``&&this._saveInputFromElement(t.currentTarget)}})}_renderReadOnlyComponent(e,t){let n=this.getCommonInputProps(e);return X(`calcite-input`,{...n,class:this.classes(C.fieldInput,C.inputDisabled,C.individualElement),readOnly:!0,type:`text`,value:String(t??n.value??``)})}_renderDateComponents(e,t){let{field:n}=e,r;switch(n.type){case`date`:r=this._renderDateFieldComponents(e,t);break;case`date-only`:r=this._renderDateOnlyFieldComponent(e,t);break;case`time-only`:r=this._renderTimeOnlyFieldComponent(e,t);break;case`timestamp-offset`:r=this._renderTimestampOffsetFieldComponents(e,t);break;default:r=this._renderReadOnlyComponent(e,H(n,t.value,{timeZone:e.effectiveTimeZone,...de(e.template.field)}))}return e.value===k?[r,X(`calcite-input-message`,{icon:`information`,key:`diff-values-message`,status:`idle`},this.messages.differentValues)]:r}_renderDateOnlyFieldComponent(e,t){let{class:n,disabled:r,key:i,readOnly:a}=t,{rawMax:o,rawMin:s}=e.range;return X(`calcite-input-date-picker`,{afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,class:n,"data-date-part":`date`,"data-element-id":t[Z],"data-field-name":t[Q],disabled:r,key:`${i}-date-input`,max:g(o)?o:void 0,min:g(s)?s:void 0,overlayPositioning:`fixed`,readOnly:a,topLayerDisabled:this.topLayerDisabled,value:e.value===k?``:e.value?String(e.value):``,onblur:t.onblur,onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget),onfocus:t.onfocus})}_renderTimeOnlyFieldComponent(e,t){let{class:n,disabled:r,key:i,readOnly:a}=t;return X(`calcite-input-time-picker`,{afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,class:n,"data-date-part":`time`,"data-element-id":t[Z],"data-field-name":t[Q],disabled:r,key:`${i}-time-input`,overlayPositioning:`fixed`,readOnly:a,step:e.timeStep,value:e.value===k?``:e.value?String(e.value):``,onblur:t.onblur,onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget),onfocus:t.onfocus})}_renderTimestampOffsetFieldComponents(e,t){let{class:n,disabled:r,key:i,readOnly:a,onblur:o,onfocus:s}=t,{rawMax:c,rawMin:l}=e.range,u=e.effectiveTimeZone,d=U(c,u),f=U(l,u),p=U(e.value===k?``:e.value,u),m=e.includeTimeOffset,h={afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,disabled:r,[Z]:t[Z],[Q]:t[Q],onblur:o,onfocus:s,overlayPositioning:`fixed`,readOnly:a};return X(`div`,{class:C.dateInputContainer,key:`${i}-date-time-container`},X(`calcite-input-date-picker`,{...h,class:n,"data-date-part":`date`,key:`${i}-date-input`,max:d?.date??void 0,min:f?.date??void 0,topLayerDisabled:this.topLayerDisabled,value:p.date??``,onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),X(`calcite-input-time-picker`,{...h,class:n,"data-date-part":`time`,key:`${i}-time-input`,step:e.timeStep,value:p.time??``,onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),m?X(`calcite-input-time-zone`,{...h,class:n,clearable:e.value===k||e.value==null,"data-date-part":`timeZone`,key:`${i}-timezone-input`,value:p.timeZoneOffset||``,onCalciteInputTimeZoneChange:t=>this._saveValueFromDateComponent(e,t.target)}):null)}_renderDateFieldComponents(e,t){let{class:n,disabled:r,key:i,readOnly:a,min:o,max:s}=t,c=e.effectiveTimeZone,l=W(e.value===k?``:e.value,c),u=W(s,c),d=W(o,c),f=e.includeTime,p={afterCreate:this._afterDateComponentCreateOrUpdate,afterUpdate:this._afterDateComponentCreateOrUpdate,disabled:r,[Z]:t[Z],[Q]:t[Q],onblur:t.onblur,onfocus:t.onfocus,overlayPositioning:`fixed`,readOnly:a};return X(`div`,{class:C.dateInputContainer,key:`${i}-date-time-container`},X(`calcite-input-date-picker`,{...p,class:n,"data-date-part":`date`,key:`${i}-date-input`,max:u?.date??void 0,min:d?.date??void 0,topLayerDisabled:this.topLayerDisabled,value:l.date??``,onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),f?X(`calcite-input-time-picker`,{...p,"data-date-part":`time`,key:`${i}-time-input`,step:1,value:l.time??``,onCalciteInputTimePickerChange:t=>{this._saveValueFromDateComponent(e,t.target)}}):null)}_renderRelationshipElementInput(e){return this._relatedRecordsEnabled?X(L,{afterObserverCreated:this._afterListObserverCreated,afterObserverRemoved:this._afterListObserverRemoved,input:e,messages:this.messages,messagesCommon:this.messagesCommon,viewModel:this.viewModel}):null}_renderRelationshipListPage(){let{activeRelationshipInput:e}=this.viewModel;if(e)return this._renderRelationshipElementInput(e)}_renderAttachmentElementInput(e){if(!this.attachmentsEnabled)return;let{allAttachmentsVisibleOnDefaultPage:t,attachments:n,defaultPageAttachments:r,template:{description:i,elementId:a,label:o}}=e,s=t?n:r;return X(`div`,{class:C.attachmentElementInput,"data-testid":`attachment-element-${a}`,key:`attachment-element-${a}`},o?X(`div`,{class:C.attachmentElementLabel,key:`attachment-element-label-${a}`},o):null,i?X(`div`,{class:C.description,key:`attachment-element-description-${a}`},i):null,n.length?this._renderAttachmentList(e,s,{label:o||this.messagesCommon.details,viewAllCount:t?null:n.length}):X(`div`,{class:C.attachmentElementEmptyState,key:`attachment-element-empty-state-${a}`},this.messages.attachments.noAttachments),this._renderAttachmentAddAction(e))}_renderAttachmentListPage(){let e=this.viewModel.selectedAttachmentListInput;if(e)return X(`div`,{class:C.attachmentElementAllPanel,key:`attachment-element-all-panel-${e.template.elementId}`},this._renderAttachmentList(e,e.attachments,{filterEnabled:!0,label:this.messages.titles.attachments}))}_renderAttachmentList(e,t,n){let{filterEnabled:r,label:i,viewAllCount:a}=n;return X(`calcite-list`,{class:C.attachmentElementList,filterEnabled:r,filterPlaceholder:r?this.messages.attachments.searchAttachments:void 0,filterProps:r?he:void 0,filterText:r?this._attachmentListFilterText:void 0,label:i,selectionAppearance:`border`,selectionMode:`none`,onCalciteListFilter:r?e=>{this._attachmentListFilterText=e.currentTarget.filterText??``}:void 0},this._renderAttachmentListItems(e,t),a==null?null:this._renderViewAllAttachmentsItem(e,a))}_renderAttachmentListItems(e,t){let{elementId:n}=e.template;return t.map((t,r)=>{let i=this._formatAttachmentSize(t.size),a=this._getAttachmentLabel(t,r,i,e.displayFilename),o=a===i?void 0:i,s=y(t),c=e.isStagedAttachmentAddition(t),l=e.getAttachmentEditState(t),u=l.isDeleted,d=!u&&(c||l.isRenamed||l.isReplaced);return X(`calcite-list-item`,{class:C.attachmentElementListItem,description:o,key:`attachment-item-${s}`,label:a,onCalciteListItemSelect:c||u?void 0:()=>this._setSelectedAttachment({attachmentKey:s,elementId:n})},X(`div`,{class:C.attachmentElementListItemStart,slot:`content-start`},this._renderAttachmentPreviewThumbnail(t,a,e)),d?X(`span`,{class:C.attachmentElementListItemStagedIndicator,slot:`content-end`}):null,c?[X(`calcite-action`,{disabled:this._disableAttachmentModification(e),icon:`x`,scale:`s`,slot:`actions-end`,text:this.messagesCommon.delete,title:this.messagesCommon.delete,onclick:()=>this.viewModel.stageDeleteAttachment(n,y(t))})]:u?X(`calcite-chip`,{label:this.messages.attachments.deleted,scale:`s`,slot:`content-end`},this.messages.attachments.deleted):X(`calcite-icon`,{flipRtl:!0,icon:`chevron-right`,scale:`s`,slot:`content-end`}))})}_renderViewAllAttachmentsItem(e,t){let{elementId:n}=e.template,{viewAll:r}=this.messages.attachments;return X(`calcite-list-item`,{class:C.attachmentElementListItem,description:p(this.messages.attachments.count,{count:t}),key:`attachment-item-view-all-${n}`,label:r,onCalciteListItemSelect:()=>this._setAttachmentListElementId(n)},X(`calcite-icon`,{flipRtl:!0,icon:`chevron-right`,scale:`s`,slot:`content-end`}))}_renderAttachmentAddAction(e){let{elementId:t}=e.template,n=this.effectiveDisabled||e.addDisabled,r=this._renderAttachmentCountLimitsLabel(e),i=this._getAttachmentNoticeMessage(e),a=e.hasMinimumAttachmentCountNotMet||e.hasExceededAttachmentLimit?`danger`:`info`,o=e.canUploadFiles,s=e.isCaptureOnly&&!this.effectiveDisabled&&!i;return X(`div`,{class:C.attachmentElementAddActions,key:`attachment-element-add-actions-${t}`},o?X(`calcite-button`,{appearance:`outline`,disabled:n,iconStart:`attachment`,kind:`neutral`,round:!0,scale:`s`,onclick:()=>this._setAttachmentAddElementId(t)},this.messages.attachments.attach):null,this._renderAttachmentCaptureButton(e),s?this._renderAttachmentCaptureDisabledNotice(t):null,r?X(`div`,{class:C.attachmentElementEmptyActionHint},r):null,!this.effectiveDisabled&&i?X(`calcite-notice`,{closable:!1,icon:a===`danger`?`exclamation-mark-circle`:`lightbulb`,kind:a,open:!0,scale:`s`,width:`full`},X(`div`,{slot:`message`},i)):null)}_renderAttachmentCaptureButton(e){if(!e.hasCaptureInputs)return null;let t=e.captureMediaType;return X(`calcite-button`,{appearance:`outline`,disabled:!0,iconStart:ye(t),kind:`neutral`,round:!0,scale:`s`},this._getCaptureButtonLabel(t))}_getAttachmentNoticeMessage(e){let t=this.messages.attachments;return e.hasUnsupportedFileTypeValidationError?this._getUnsupportedFileTypeMessage():e.hasMinimumAttachmentCountNotMet&&this._shouldShowMinimumAttachmentNotice(e)?t.minimumNotMet:e.hasExceededAttachmentLimit?t.attachmentLimitExceeded:e.hasReachedAttachmentLimit?t.attachmentLimitReached:null}_shouldShowMinimumAttachmentNotice(e){return e.hasAttachmentChanges||this.viewModel.submitHasBeenAttempted||this._touchedInputs.has(e.template.elementId)}_getCaptureButtonLabel(e){let{capture:t,recordAudio:n,takePhoto:r,takeVideo:i}=this.messages.attachments;switch(e){case`image`:return r||t;case`video`:return i||t;case`audio`:return n||t;default:return t}}_renderAttachmentAddPage(){let e=this.viewModel.selectedAttachmentAddInput;return e?this._renderAttachmentAddPanel(e):null}_renderAttachmentAddPanel(e){let{maxAttachmentCount:t}=e,{elementId:n}=e.template;if(e.isCaptureOnly)return this._renderAttachmentCaptureDisabledNotice(n);let r=t==null||t-e.attachments.length>1,i=this.effectiveDisabled||e.addDisabled,a=this.messages.attachments,o=a.dragAndDropFile,s=e=>{this._attachmentFileInputMap.set(n,e)};return X(`div`,{class:C.attachmentElementAddPanel,key:`attachment-element-add-panel-${n}`},X(`input`,{accept:e.accept,afterCreate:s,afterRemoved:()=>{this._attachmentFileInputMap.delete(n)},afterUpdate:s,class:C.attachmentElementFileInput,"data-element-id":n,disabled:i,multiple:r,type:`file`,onchange:e=>{let t=e.currentTarget,r=t.files?Array.from(t.files):[];this._stageAttachmentFiles(n,r),t.value=``}}),X(`div`,{class:C.attachmentElementAddDropzone,"data-disabled":i?`true`:`false`,ondragover:e=>{e.stopPropagation(),e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`)},ondrop:e=>{if(e.preventDefault(),e.stopPropagation(),i)return;let t=e.dataTransfer?.files?Array.from(e.dataTransfer.files):[];this._stageAttachmentFiles(n,t)}},X(`calcite-icon`,{class:C.attachmentElementAddDropzoneIcon,icon:`upload`,scale:`l`}),X(`div`,{class:C.attachmentElementAddDropzoneHeading},a.addFile),X(`div`,{class:C.attachmentElementAddDropzoneDetail,title:o},o),X(`calcite-button`,{appearance:`transparent`,disabled:i,iconStart:`folder-open`,kind:`brand`,scale:`s`,type:`button`,onclick:e=>{e.stopPropagation(),this._openAttachmentFilePicker(n,i)}},a.selectFile)),this._renderAttachmentValidationCriteria(e,{includeCountCriteria:!0}))}_renderAttachmentCaptureDisabledNotice(e){return X(`calcite-notice`,{class:C.attachmentElementCaptureNotice,icon:!0,key:`attachment-element-capture-disabled-notice-${e}`,kind:`warning`,open:!0,scale:`s`},X(`div`,{slot:`message`},this.messages.attachments.captureMethodNotSupported))}async _stageAttachmentFiles(e,t){if(t.length===0)return;let n=this.viewModel.selectedAttachmentAddInput,r=!0;try{r=(await this.viewModel.stageAddAttachments(e,t)).length>0&&!n?.hasInvalidValidationCriteria&&!n?.hasUnsupportedFileTypeValidationError}finally{r&&this.viewModel.setSelectedAttachmentAddElementId(null)}}_openAttachmentFilePicker(e,t){t||this._attachmentFileInputMap.get(e)?.click()}_renderAttachmentDetailPage(){let e=this.selectedAttachmentDetails;if(!e)return;if(this.page===`replacing-attachment`)return this._renderAttachmentReplacePanel(e);let{attachment:t,input:n}=e,r=y(t),i=!!n.getAttachmentPreviewUrl(t),a=!this._disableAttachmentModification(n)&&n.canUploadFiles,o=n.getAttachmentEditState(t);return X(`div`,{class:C.attachmentElementDetail,key:`attachment-detail-panel-${n.template.elementId}-${r}`},X(`div`,{class:C.attachmentElementDetailPreview},this._renderAttachmentPreviewImageForInput(t,n)),X(`div`,{class:C.attachmentElementDetailActions},b(t)?X(`calcite-button`,{appearance:`outline`,disabled:!i,iconStart:`expand`,kind:`neutral`,label:this.messages.attachments.maximize,scale:`m`,title:this.messages.attachments.maximize,onclick:this._maximizeSelectedAttachment}):null,X(`calcite-button`,{appearance:`outline`,disabled:!i||o.isReplaced,iconStart:`download`,kind:`neutral`,label:this.messages.attachments.download,scale:`m`,title:this.messages.attachments.download,onclick:()=>{this._downloadAttachment(t)}}),X(`calcite-button`,{appearance:`outline`,disabled:!a,iconStart:`upload-to`,kind:`neutral`,label:this.messages.attachments.replace,scale:`m`,title:this.messages.attachments.replace,onclick:this._enterAttachmentReplaceView})),X(`div`,{class:C.attachmentElementDetailMetadata},X(`div`,{class:C.attachmentElementDetailMetadataGroup},X(`span`,{class:C.attachmentElementDetailMetadataLabel},this.messages.attachments.fileName),this._renderFileNameContent(t,n)),X(`div`,{class:C.attachmentElementDetailMetadataGroup},X(`span`,{class:C.attachmentElementDetailMetadataLabel},this.messages.attachments.size),X(`span`,{class:C.attachmentElementDetailMetadataValue},this._formatAttachmentSize(t.size))),X(`div`,{class:C.attachmentElementDetailMetadataGroup},X(`span`,{class:C.attachmentElementDetailMetadataLabel},this.messages.attachments.type),X(`span`,{class:C.attachmentElementDetailMetadataValue},this._getLabelForAttachmentType(t)))))}_renderFileNameContent(e,t){if(!t.allowUserRename)return X(`span`,{class:C.attachmentElementDetailMetadataValue},e.name);let n=t.getAttachmentEditState(e),{baseName:r,extension:i}=ee(e.name),a=this._disableAttachmentModification(t),o=!a&&e.name.trim().length===0;return[X(`div`,{class:C.attachmentElementDetailFileNameRow,key:`file-name-row`},X(`calcite-input`,{class:C.attachmentElementDetailFileNameInput,disabled:a,scale:`m`,status:o?`invalid`:`idle`,suffixText:i,value:r,onCalciteInputInput:({currentTarget:e})=>this._renameSelectedAttachment(e.value)}),X(`calcite-button`,{appearance:`transparent`,disabled:a||n.initialName==null||!n.isRenamed,iconStart:`reset`,kind:`neutral`,label:this.messages.footerButtons.reset,scale:`m`,title:this.messages.footerButtons.reset,onclick:this._resetSelectedAttachmentName})),o?X(`calcite-input-message`,{icon:!0,key:`file-name-message`,status:`invalid`},this.messages.validationErrors.cannotBeNull):null]}_renderAttachmentReplacePanel(e){let{attachment:t,input:n}=e,r=this._disableAttachmentModification(n)||!n.canUploadFiles,i=n.template.elementId;return X(`div`,{class:C.attachmentElementAddPanel,key:`attachment-replace-panel-${i}-${y(t)}`},X(`input`,{accept:n.accept,afterCreate:this._setSelectedAttachmentReplaceFileInput,afterRemoved:()=>{this._selectedAttachmentReplaceFileInput=null},afterUpdate:this._setSelectedAttachmentReplaceFileInput,class:C.attachmentElementFileInput,disabled:r,type:`file`,onchange:e=>{let t=e.currentTarget,n=t.files?.[0];n&&this._stageSelectedAttachmentReplacement(n),t.value=``}}),X(`div`,{class:C.attachmentElementAddDropzone,"data-disabled":r?`true`:`false`,ondragover:e=>{e.preventDefault(),e.stopPropagation(),e.dataTransfer&&(e.dataTransfer.dropEffect=`copy`)},ondrop:e=>{if(e.preventDefault(),e.stopPropagation(),r)return;let t=e.dataTransfer?.files?.[0];t&&this._stageSelectedAttachmentReplacement(t)}},X(`calcite-icon`,{class:C.attachmentElementAddDropzoneIcon,icon:`refresh`,scale:`l`}),X(`div`,{class:C.attachmentElementAddDropzoneHeading},this.messages.attachments.replace),X(`div`,{class:C.attachmentElementAddDropzoneDetail,title:this.messages.attachments.dragAndDropFile},this.messages.attachments.dragAndDropFile),X(`calcite-button`,{appearance:`transparent`,disabled:r,iconStart:`folder-open`,kind:`brand`,scale:`s`,onclick:e=>{e.stopPropagation(),this._openSelectedAttachmentReplaceFilePicker()}},this.messages.attachments.selectFile)),this._renderAttachmentValidationCriteria(n,{includeCountCriteria:!1}),X(`div`,{class:C.attachmentElementDetailMetadata},X(`div`,{class:C.attachmentElementDetailMetadataGroup},X(`span`,{class:C.attachmentElementDetailMetadataLabel},this.messages.attachments.fileToBeReplaced),X(`span`,{class:C.attachmentElementDetailMetadataValue},t.name))))}_renderAttachmentDialog(){let e=this._attachmentDialogInfo;if(!e)return null;let{attachment:t,input:n}=e;return X(`calcite-dialog`,{heading:t.name||this.messagesCommon.details,key:`attachment-preview-dialog`,modal:!0,open:!0,placement:`cover`,width:`l`,onCalciteDialogClose:this._closeAttachmentDialog},X(`div`,{class:C.attachmentElementDialogPreview},this._renderAttachmentPreviewImageForInput(t,n)))}_setSelectedAttachment(e,t){this._markInputTouched(t),this.viewModel.setSelectedAttachment(e),e||this.hideAttachmentDialog()}_setAttachmentAddElementId(e){let{viewModel:t}=this;t.setSelectedAttachmentAddElementId(e),this._markInputTouched(t.selectedAttachmentAddInput),t.selectedAttachmentAddInput?.clearValidationCriteriaState(),this.hideAttachmentDialog()}_setAttachmentListElementId(e){let{viewModel:t}=this;t.setSelectedAttachmentListElementId(e),this._markInputTouched(t.selectedAttachmentListInput),this.hideAttachmentDialog()}_getAttachmentLabel(e,t,n,r){return r!==!1&&g(e.name)&&e.name.length>0?e.name:n===this.messagesCommon.notApplicable?p(this.messages.attachments.attachmentNumberedLabel,{index:t+1}):n}_renderAttachmentCountLimitsLabel(e){let t=this.messages.attachments,n=e.minAttachmentCount!=null&&e.minAttachmentCount>0?this._renderAttachmentCountLimitLabel(t.minAttachmentsShort,e.minAttachmentCount,`min`):null,r=e.maxAttachmentCount==null?null:this._renderAttachmentCountLimitLabel(t.maxAttachmentsShort,e.maxAttachmentCount,`max`);return!n&&!r?null:[n,n&&r?X(`span`,{key:`attachment-count-limits-separator`},`, `):null,r]}_renderAttachmentCountLimitLabel(e,t,n){let r=`__count__`,[i,a]=p(e,{count:r}).split(r);return X(`span`,{key:n},i,X(`span`,{class:C.attachmentElementEmptyActionHintValue},t),a)}_renderAttachmentValidationCriteria(e,{includeCountCriteria:t}){let n=this._getAttachmentValidationCriteria(e,{includeCountCriteria:t}),r=`attachment-validation-criteria-${e.template.elementId}`;return n.length===0?null:X(`div`,{class:C.attachmentElementValidationCriteria,key:r},n.map(({key:e,message:t,state:n})=>X(`calcite-notice`,{appearance:n===`danger`?`outline-fill`:`transparent`,closable:!1,icon:!0,key:e,kind:n,open:!0,scale:`s`,width:`full`},X(`div`,{slot:`message`},t))))}_getAttachmentValidationCriteria(e,{includeCountCriteria:t}){let n=[],r=e.validationCriterionStates,i=this.messages.attachments,a=this._getNestableAttachmentInputs(e.input);e.hasUnsupportedFileTypeValidationError&&n.push({key:`unsupported-file-type`,message:this._getUnsupportedFileTypeMessage(),state:`danger`});for(let e of a)e.type===`document`&&e.maxFileSize!=null&&n.push({key:`maximum-file-size`,message:p(i.maximumFileSize,{maxSize:this._formatAttachmentSizeLimitInMegabytes(e.maxFileSize)}),state:r.get(`maximum-file-size`)??`info`}),e.type===`audio`&&e.maxDuration!=null&&n.push({key:`maximum-audio-length`,message:p(i.maximumAudioLength,{maxDuration:this._formatAttachmentDurationLimit(e.maxDuration)}),state:r.get(`maximum-audio-length`)??`info`}),e.type===`video`&&e.maxDuration!=null&&n.push({key:`maximum-video-length`,message:p(i.maximumVideoLength,{maxDuration:this._formatAttachmentDurationLimit(e.maxDuration)}),state:r.get(`maximum-video-length`)??`info`}),e.type===`image`&&e.maxImageSize!=null&&n.push({key:`maximum-image-size`,message:p(i.attachmentMustBeSmallerThan,{maxSize:`${e.maxImageSize}px`}),state:r.get(`maximum-image-size`)??`info`});return t&&e.minAttachmentCount!=null&&e.minAttachmentCount>0&&n.push({key:`minimum-number-of-files`,message:p(i.minimumNumberOfFiles,{count:e.minAttachmentCount}),state:r.get(`minimum-number-of-files`)??`info`}),t&&e.maxAttachmentCount!=null&&n.push({key:`maximum-number-of-files`,message:p(i.maximumNumberOfFiles,{count:e.maxAttachmentCount}),state:r.get(`maximum-number-of-files`)??`info`}),n}_getNestableAttachmentInputs(e){return e==null?[]:e.type===`attachment`?e.inputTypes?.slice()??[]:[e]}_getUnsupportedFileTypeMessage(){return this.featureTableMessages.errorFileUnsupported}_formatAttachmentSize(e){return e==null||Number.isNaN(e)?this.messagesCommon.notApplicable:f(this.messagesUnits,e)}_formatAttachmentSizeLimitInMegabytes(e){return f(this.messagesUnits,e*1048576)}_formatAttachmentDurationLimit(e){return m(Math.round(e)*1e3,{...e>=3600?{hour:`2-digit`,hourCycle:`h23`}:{},minute:`2-digit`,second:`2-digit`,timeZone:`UTC`})}_getLabelForAttachmentType({contentType:e}){if(!e)return this.messagesCommon.notApplicable;let t=this.messages.attachments.attachmentTypes,n=_(e);return t?.[n]||e}_renderAttachmentPreviewThumbnail(e,t,n){let r=n.getAttachmentPreviewUrl(e,64);return r&&b(e)?X(`img`,{alt:t,class:C.attachmentElementListItemThumb,src:r}):X(`calcite-icon`,{class:C.attachmentElementListItemIcon,icon:v(e.contentType),scale:`s`})}_renderAttachmentPreviewImageForInput(e,t){let n=t.getAttachmentPreviewUrl(e),r=e.name||this.messagesCommon.details;return n&&b(e)?X(`img`,{alt:r,class:C.attachmentElementDetailPreviewImage,src:n,title:r}):[X(`calcite-icon`,{class:C.attachmentElementDetailPreviewIcon,icon:v(e.contentType),scale:`l`,textLabel:r,title:r}),this.messages.attachments.noPreviewAvailable]}async _downloadAttachment(e){await B(e)}_canReplaceSelectedAttachment(){return!this.effectiveDisabled&&!!this.selectedAttachmentDetails?.input.canUploadFiles}_exitAttachmentReplaceView(){this.viewModel.setShowingSelectedAttachmentReplacePage(!1),this._selectedAttachmentReplaceFileInput=null}async _stageSelectedAttachmentReplacement(e){let t=this.selectedAttachmentDetails;if(!t?.attachment)return;let n=t.input.template.elementId,r=y(t.attachment),i=!1;try{i=await this.viewModel.stageReplaceAttachment(n,r,e)}finally{i&&this._exitAttachmentReplaceView()}}_renameSelectedAttachment(e){let t=this.selectedAttachmentDetails;if(!t?.attachment)return;let n=t.input.template.elementId,r=y(t.attachment);this.viewModel.stageRenameAttachment(n,r,e)}_resetSelectedAttachmentChanges(){let e=this.selectedAttachmentDetails;e?.attachment&&this.viewModel.resetAttachmentChanges(e.input.template.elementId,y(e.attachment))}_deleteSelectedAttachment(){let e=this.selectedAttachmentDetails;if(!e?.attachment||this._disableAttachmentModification(e.input))return;let t=e.input.template.elementId,n=y(e.attachment);this.viewModel.stageDeleteAttachment(t,n),this._setSelectedAttachment(null)}_disableAttachmentModification(e){return this.disabledOrReadOnly||!e.editable}hideAttachmentDialog(){this._attachmentDialogInfo=null}_renderTextComponent(e){let{elementId:t}=e.template;return X(`div`,{class:C.textElementInput,"data-testid":`text-element-${t}`,innerHTML:e.text,key:`text-element-${t}`})}_renderUtilityNetworkAssociationsElementInput(e){if(!this._associationsEnabled)return;let{elementId:t}=e.template;return X(`div`,{class:C.utilityNetworkAssociationsElementInput,"data-testid":t,key:t},this._associationsWidgetsMap.get(e)?.render())}getCommonInputProps(e){let{template:t,valid:n,value:r,minLength:i,maxLength:a,required:o,fieldName:s,editable:c,range:{max:l,min:u}}=e,d=!c||this.readOnly,f=this.disabled||this.viewModel.updating,p=this._getErrorToDisplay(e)?`invalid`:`idle`,m=t.hint??void 0,h=!1;return r===k&&(m=this.messages.differentValuesPlaceholder,h=!0),{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":n?`false`:`true`,class:this.classes(C.fieldInput,d?C.inputDisabled:null),status:p,maxLength:a&&a>-1?a:void 0,minLength:i&&i>-1?i:void 0,key:t.elementId,label:s,name:s,max:l??void 0,min:u??void 0,disabled:f,readOnly:d,onblur:this._onComponentBlur,required:o,placeholder:m,value:h?``:r??``,[Z]:t.elementId,[Q]:s,onfocus:this._onComponentFocus}}_onObserverChange(){this._listObserverNode&&this._listObserver.unobserve(this._listObserverNode);let e=this.viewModel.activeRelationshipInput;e&&this._listObserverNode&&e.showAllEnabled&&this._listObserver.observe(this._listObserverNode)}_onFormSubmit(e){e.preventDefault()}_handleDragAndDrop(e){e.preventDefault(),e.dataTransfer&&(e.dataTransfer.dropEffect=`none`)}_getFieldInputFromHTMLElement(e){return this.viewModel.findFieldInput(e.getAttribute(Z))}_afterRadioGroupCreateOrUpdate(e){let t=e.selectedItem,n=e.querySelector(`calcite-radio-button`),r=t||n;r&&this._afterComponentCreateOrUpdate(r)}_onComponentFocus(e){let t=e.target,n=this._getFieldInputFromHTMLElement(t);this._focusedFieldInput=n}_markInputTouched(e){e&&this._touchedInputs.add(e.template.elementId)}_isMultipleChoiceCheckbox(e,t){let n=this._getMultipleChoiceController(t);return e.tagName===`CALCITE-CHECKBOX`&&n?.input!=null}_afterComponentCreateOrUpdate(e){let t=this._getFieldInputFromHTMLElement(e),n=this._focusedFieldInput;this._attemptFocusOnNextRender&&n===t&&(this._attemptFocusOnNextRender=!1,_e(e))}_onComponentBlur(e){let t=e.target,n=this._getFieldInputFromHTMLElement(t);this._isMultipleChoiceCheckbox(t,n)||this._markInputTouched(n),this._focusedFieldInput=null}_onDynamicChoiceBlur(e,t){let n=e.currentTarget;if(this._dynamicChoiceItemSelections.delete(t))return;let r=e.relatedTarget;r instanceof Node&&n.contains(r)||(t.endInteraction(),n.inputValue=t.fieldInput.value===k?this.messages.differentValuesPlaceholder:t.inputValue,this._onComponentBlur(e))}_resetTransientFormState(){this._attemptFocusOnNextRender=!1,this._focusedFieldInput=null,this._attachmentDialogInfo=null,this._selectedAttachmentReplaceFileInput=null,this._attachmentListFilterText=``,this._attachmentFileInputMap.clear()}_parseValue(e,t,n=!1){let r=this._getMultipleChoiceController(t);if(r){let{input:t,values:i}=r;if(t&&i){let t=e;return r.getValueFromCheckboxChange({choiceValue:t.value,isChecked:t.checked,isSelectAllCheckbox:n})}}if(x(t.template,`switch`)){if(e.localName===`calcite-dropdown`&&t.domain){for(let n of t.domain.codedValues)if(n.name===e.selectedItems[0].textContent)return n.code}return e.checked?t.template.input.onValue:t.template.input.offValue}let i=e.value;return i==null||i===``?null:t.dataType===`number`?i===`-0`||i===`-0.`||i===`-0,`?i:parseFloat(i):t.field.type===`date`?parseFloat(i):i}_getMultipleChoiceController(e){return w(e.inputController)?e.inputController:null}_saveInputFromElement(e){let t=this._getFieldInputFromHTMLElement(e);if(!t)return;let n=this._parseValue(e,t);this._saveInput(t,n)}_saveInput(e,t){let{elementId:n}=e.template,r=e?.value,{viewModel:i}=this;if(x(e.template,`switch`)&&i.mode!==`single`){let t=a(this._batchSwitchInputInitialValues,e,()=>e.value);this._batchSwitchInputInitialValues.set(e,t===null?r:t)}t!==r&&(this._markInputTouched(e),!e.isSubtypeField||i.mode===`batch`||!re(i.activeLayer,r,t)?i.setValue(n,t):this._pendingSubtypeChoice||=this._handleSubtypeChoice(e,t))}async _handleSubtypeChoice(e,t){let{value:n,template:r}=e,{elementId:i}=r,{messages:a,viewModel:o,messagesCommon:s}=this,{subtypes:c,activeFeatureIndex:l}=o;if(await o.setValue(i,t),!c?.length)return;let u=c.find(e=>e.code===t),d=c.find(e=>e.code===n)?.name??`${n}`;if(!u)return;let f=Promise.withResolvers();o.pendingSubtypeChoice=f;let m=`update-fields`,h=[{label:a.subtypes.useDefaultValuesOption,value:`update-fields`},{label:a.subtypes.keepCurrentValuesOption,value:`keep-existing`}],g={context:`info`,title:a.subtypes.changeWarningTitle,message:p(a.subtypes.changeWarning,{originalType:d,newType:u.name}),radios:h,defaultRadioSelection:`update-fields`,onRadioSelection:e=>{m=e},actions:{primary:{label:s.apply,action:()=>f.resolve(m),type:`positive`},secondary:{label:s.cancel,type:`neutral`,action:()=>f.resolve(`undo`)}},cancel:()=>f.reject()};try{switch(this.showPrompt(g),await f.promise){case`update-fields`:await o.applySubtypeDefaults(u),await o.handleSubtypeChanged(l);break;case`keep-existing`:await o.handleSubtypeChanged(l);break;case`undo`:await this.viewModel.setValue(i,n)}}finally{o.pendingSubtypeChoice=null,this.clearPrompt(),this._pendingSubtypeChoice=null}}_afterDateComponentCreateOrUpdate(e){this._setDateTimeTimeZoneMap(e),this._afterComponentCreateOrUpdate(e)}_saveValueFromDateComponent(e,t){let{elementId:n}=e.template,r=e.field.type,i=this._dateComponentMap.get(`${n}`);if(!i)return;let a=e.effectiveTimeZone,o=e.value===k?void 0:e.value,s=null;r===`date-only`?s=Array.isArray(t.value)?t.value[0]:t.value:r===`time-only`?(o=G(o),s=G(t.value)):s=r===`timestamp-offset`?t.value==null?null:fe({dateComponent:i.date,timeComponent:i.time,oldValue:o,timeZoneComponent:i.timeZone,defaultTimeZone:a}):t.value==null?null:pe({oldValue:o,dateComponent:i.date,timeZone:a,timeComponent:i.time?.value===k?void 0:i.time}),o!==s&&(this._markInputTouched(e),s===null||!t.value?this.viewModel.setValue(n,null):this.viewModel.setValue(n,s))}_getErrorToDisplay(e){let t=e.compositeError;return e.valid||!t?null:t===q.CONTINGENCY_VIOLATION_ERROR||t===q.CONTINGENCY_VIOLATION_WARNING?t:!this._touchedInputs.has(e.template.elementId)&&!this.viewModel.submitHasBeenAttempted?null:t}_renderViewingAssociationsPage(){return this._associationsList?.render()}_onActiveAssociationsInputChange(e){let t=this._associationsList;t&&(e?(t.associationInput=e,t.viewModel=e.viewModel):t.associationInput=null)}async _setUpAssociationsWidgets(){let e=this.viewModel.activeForm.allUtilityNetworkAssociationsElementInputs;if(this._associationsEnabled&&e.length!==0){await this._setUpUtilityNetworkAssociationList();for(let t of e)this._associationsWidgetsMap.set(t,await this._createAssociationsWidget(t))}}async _setUpUtilityNetworkAssociationList(){if(this._associationsList)return;let e=(await import(`./FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js`)).default;this._associationsList=new e({onSelectLayer:this._onSelectAssociatedLayer.bind(this),onSelectFeature:this._onEditAssociatedFeature.bind(this),onAddAssociation:this._onAddAssociation.bind(this)});let t=this.viewModel.activeAssociationsInput;t&&(this._associationsList.associationInput=t,this._associationsList.viewModel=t.viewModel)}async _createAssociationsWidget(e){return new(await(import(`./Feature/FeatureUtilityNetworkAssociations.js`))).default({viewModel:e.viewModel,onSelectAssociationType:t=>this._onSelectAssociationType(e,t)})}_destroyAssociationsWidgets(){this._associationsWidgetsMap.forEach(e=>o(e)),this._associationsWidgetsMap.clear()}_onSelectAssociationType(e,{listType:t}){this.setActiveAssociationsInput(e),this.setActiveAssociationType(t)}_onSelectAssociatedLayer({layer:e}){this.setActiveAssociationsLayer(e)}async _onEditAssociatedFeature(e){let t=this.callbacks?.editAssociatedFeature,n=this.viewModel.activeAssociationsInput;if(!t||!n?.feature)return;let{association:r,feature:i}=e;await t({parentFeature:n.feature.plainGraphic,association:r,feature:i})}_onAddAssociation(e){let t=this.callbacks?.addAssociation,n=this.viewModel.activeAssociationsInput;if(!t||!n?.feature)return;let{associationType:r,utilityNetwork:i}=e;t({feature:n.feature.plainGraphic,associationType:r,utilityNetwork:i})}_setFocusableInput(e){let t=e&&E(e)?e:this._findFocusableInput(e);this._focusedFieldInput=t,this._attemptFocusOnNextRender=!0}_findFocusableInput(e){let t=this.viewModel.activeForm.inputs;if(!t.length)return;let n=ie(t),r;if(!e)r=0;else if(T(e)){let t=e.inputs.find(e=>e.visible);r=t?n.indexOf(t):0}else{let i;i=j(e)&&!e.group.open?e.group.inputs.filter(E)[t.length-1]:e,r=n.indexOf(i)+1}for(let e=r;e<n.length;e++){let t=n[e],r=j(t)&&!t.group.open;if(t.visible&&E(t)&&!r){if(this.disabledOrReadOnly&&(t?.inputType===`switch`||t?.inputType===`radio-buttons`))continue;return t}}return null}_onGroupExpand(e){e.open=!0,this.groupDisplay===`sequential`&&this.viewModel.activeForm.allGroupInputs.forEach(t=>{t!==e&&(t.open=!1)}),this._focusedFieldInput?.group!==e&&this._setFocusableInput(e)}_syncGroupInputInitialStates(){if(this.groupDisplay!==`sequential`)return;let e=this.viewModel.activeForm?.allGroupInputs;if(!e.length)return;let t=e.filter(e=>e.open);t.length===0?e[0].open=!0:t.length>1&&t.slice(1).forEach(e=>e.open=!1)}};e([t()],$.prototype,`activeFeatureIndex`,null),e([t()],$.prototype,`attachmentsEnabled`,null),e([t()],$.prototype,`callbacks`,null),e([t()],$.prototype,`disabled`,null),e([t()],$.prototype,`effectiveTitle`,null),e([t()],$.prototype,`effectiveDisabled`,null),e([t()],$.prototype,`disabledOrReadOnly`,null),e([t()],$.prototype,`features`,null),e([t()],$.prototype,`footerButtonInfos`,null),e([t()],$.prototype,`map`,null),e([t()],$.prototype,`maximumFeatureCount`,null),e([t()],$.prototype,`maximumFeatureCountWithComplexForms`,null),e([t()],$.prototype,`spatialReference`,null),e([t()],$.prototype,`layerInfos`,null),e([t()],$.prototype,`timeZone`,null),e([t()],$.prototype,`headingLevel`,void 0),e([t()],$.prototype,`icon`,null),e([t(),Y(`esri/t9n/common`)],$.prototype,`messagesCommon`,void 0),e([t(),Y(`esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm`)],$.prototype,`messages`,void 0),e([t(),Y(`esri/widgets/FeatureForm/t9n/FeatureForm`)],$.prototype,`featureFormMessages`,void 0),e([t(),Y(`esri/widgets/FeatureTable/t9n/FeatureTable`)],$.prototype,`featureTableMessages`,void 0),e([t(),Y(`esri/core/t9n/Units`)],$.prototype,`messagesUnits`,void 0),e([t()],$.prototype,`page`,null),e([t()],$.prototype,`readOnly`,null),e([t()],$.prototype,`showPrompt`,null),e([t()],$.prototype,`clearPrompt`,null),e([t()],$.prototype,`selectedAttachment`,null),e([t()],$.prototype,`selectedAttachmentDetails`,null),e([t()],$.prototype,`valid`,null),e([t({type:S}),ge([`attachments-change`,`value-change`,`values-change`,`submit`])],$.prototype,`viewModel`,void 0),e([t({type:R,nonNullable:!0})],$.prototype,`visibleElements`,void 0),e([t()],$.prototype,`groupDisplay`,void 0),e([t()],$.prototype,`_formHeaderVisible`,null),e([t()],$.prototype,`_associationsEnabled`,null),e([t()],$.prototype,`_associationsList`,void 0),e([t()],$.prototype,`_attemptFocusOnNextRender`,void 0),e([t()],$.prototype,`_formId`,null),e([t()],$.prototype,`_focusedFieldInput`,void 0),e([t()],$.prototype,`_pendingSubtypeChoice`,void 0),e([t()],$.prototype,`_relatedRecordsEnabled`,null),e([t()],$.prototype,`_listObserverNode`,void 0),e([t()],$.prototype,`_attachmentDialogInfo`,void 0),e([t()],$.prototype,`_attachmentListFilterText`,void 0),e([t()],$.prototype,`_prompt`,void 0),e([t()],$.prototype,`test`,null),$=e([n(`esri.widgets.BatchAttributeForm`)],$);function ye(e){switch(e){case`audio`:return v(`audio/mpeg`);case`video`:return v(`video/mp4`);case`image`:return v(`image/png`);default:return`camera`}}const be=$;export{be as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{property as t,subclass as n}from"../../core/accessorSupport/decorators.js";import{getContrast as r,multiplyOpacity as i}from"../../core/colorUtils.js";import{handlesGroup as a}from"../../core/handleUtils.js";import{destroyMaybe as o}from"../../core/maybe.js";import{watch as s,initial as c}from"../../core/reactiveUtils.js";import{UpdatingHandles as l}from"../../core/support/UpdatingHandles.js";import{formatDecimal as u,formatImperialLength as d,formatMetricLength as f}from"../../core/unitFormatUtils.js";import{convertUnit as p}from"../../core/units.js";import{isSupported as m,geodesicLengths as h,geodesicDensify as g}from"../../geometry/geodesicUtils.js";import{geodeticDensifyExecute as _,geodeticDensifyLoad as v}from"../../geometry/operators/geodeticDensifyOperator.js";import{geodeticLengthExecute as y,geodeticLengthLoad as b}from"../../geometry/operators/geodeticLengthOperator.js";import{lengthExecute as x}from"../../geometry/operators/lengthOperator.js";import S from"../../geometry/Point.js";import C from"../../geometry/Polyline.js";import w from"../../Graphic.js";import{fetchMessageBundle as T,onLocaleChange as E}from"../../intl.js";import D from"../../layers/GraphicsLayer.js";import O from"../../symbols/CIMSymbol.js";import k from"../../symbols/Font.js";import A from"../../symbols/SimpleMarkerSymbol.js";import j from"../../symbols/TextSymbol.js";import{SnappingVisualizer2D as M}from"../../views/2d/interactive/SnappingVisualizer2D.js";import N from"../../views/draw/Draw.js";import{createCoordinateHelper as P}from"../../views/interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as F,screenToMap as I,dragManipulatedObject as L}from"../../views/interactive/dragEventPipeline.js";import{EditGeometry as R}from"../../views/interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as z}from"../../views/interactive/editGeometry/EditGeometryOperations.js";import{GraphicManipulator as B}from"../../views/interactive/GraphicManipulator.js";import{InteractiveToolBase as V}from"../../views/interactive/InteractiveToolBase.js";import{SnappingContext as H}from"../../views/interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as U}from"../../views/interactive/snapping/SnappingDragPipelineStep.js";import{setupSnappingToggleHandles as W}from"../../views/interactive/snapping/snappingUtils.js";const G=1e5;let K=class extends V{constructor(e){super(e),this._measurementLayer=new D({internal:!0,listMode:`hide`,visible:!1,title:`DistanceMeasurement2DTool measurement layer`}),this._manipulatorLayer=new D({internal:!0,listMode:`hide`,visible:!1,title:`DistanceMeasurement2DTool manipulator layer`}),this._snappingLayer=new D({internal:!0,listMode:`hide`,visible:!1,title:`DistanceMeasurement2DTool snapping layer`}),this._updatingHandles=new l,this._vertices=[],this._drawActive=!1,this.measurement=null,this.measurementLabel=null}initialize(){T(`esri/core/t9n/Units`).then(e=>{this.messages=e});let e=this.view;this._draw=new N({view:e}),e.map.addMany([this._measurementLayer,this._manipulatorLayer,this._snappingLayer]),e.focus(),this.addHandles([E(async()=>{this.messages=await T(`esri/core/t9n/Units`)}),s(()=>[this.unit,this.messages],()=>{this._updatePolylines()},c),s(()=>[this.view.effectiveTheme.accentColor,this.view.effectiveTheme.textColor],()=>{if(!this._vertices.length)return;let e=this._vertices.map(({coord:e})=>e);for(let{handle:e}of this._vertices)e.remove();this._vertices=[],this._measurementLayer.removeAll(),this._manipulatorLayer.removeAll(),this._snappingLayer.removeAll(),this.manipulators.removeAll(),this._updateSketch(e)})]),W(this)}destroy(){let{map:e}=this.view;this._draw.view=null,this._draw=o(this._draw),e.removeMany([this._measurementLayer,this._manipulatorLayer,this._snappingLayer]),this._measurementLayer.removeAll(),this._manipulatorLayer.removeAll(),this._snappingLayer.removeAll(),this._set(`measurement`,null),this._set(`measurementLabel`,null),this._measurementLayer=o(this._measurementLayer),this._manipulatorLayer=o(this._manipulatorLayer),this._snappingLayer=o(this._snappingLayer),this._updatingHandles=o(this._updatingHandles),this._resetVertices()}get cursor(){return this._drawActive?`crosshair`:null}set editable(e){this._set(`editable`,e),e||this._draw.reset()}get snappingOptions(){return this.snappingManager.options}get updating(){return this._updatingHandles.updating||this.snappingManager.updating}onActivate(){!this._drawActive&&this._vertices.length===0&&this._startSketch()}onShow(){this._measurementLayer.visible=!0,this._manipulatorLayer.visible=!0,this._snappingLayer.visible=!0}onHide(){this._measurementLayer.visible=!1,this._manipulatorLayer.visible=!1,this._snappingLayer.visible=!1}_getSnappingContext(e){return new H({elevationInfo:{mode:`on-the-ground`,offset:0},pointer:e,editGeometryOperations:new z(new R(`point`,P(!1,!1,this.view.spatialReference)),2),visualizer:new M(this._snappingLayer)})}_resetVertices(){for(let{handle:e}of this._vertices)e.remove();this._vertices=[]}_startSketch(){this._drawActive=!0;let{snappingManager:e}=this;this._draw.create(`polyline`,{mode:`click`,snappingManager:e}).on([`draw-complete`,`vertex-add`,`vertex-update`,`vertex-remove`,`cursor-update`,`undo`,`redo`],e=>{this._updateSketch(e.vertices),e.type===`draw-complete`&&this._stopSketch()})}_stopSketch(){this.manipulators.forEach(({manipulator:e})=>{e.interactive=!0}),this._drawActive=!1,this.finishToolCreation()}_updateSketch(e){let{spatialReference:t}=this.view;for(;this._vertices.length>e.length;){let{handle:e,manipulator:t}=this._vertices.pop();e.remove(),this.manipulators.remove(t)}for(let n=this._vertices.length;n<e.length;n++){let[r,i]=e[n],o=new S({x:r,y:i,spatialReference:t}),s=q(o,this.view,this._manipulatorLayer);this.manipulators.add(s);let c=z.fromGeometry(o,2),l=[c.on(`vertex-update`,e=>{let t=e.vertices.at(0);t&&(this._vertices[n].coord=[t.pos[0],t.pos[1]],this._updatePolylines())}),F(s,(e,t,n,r)=>{let i=this._getSnappingContext(r),{snappingManager:a}=this,o=this._updatingHandles,{snappingStep:s}=U({snappingContext:i,snappingManager:a,updatingHandles:o});t.next(I(this.view)).next(t=>{if(t.action===`start`){let n=new S(t.mapStart);e.graphic.geometry=n,c.trySetGeometry(n)}return t}).next(...s).next(L({operations:c})).next(()=>{e.graphic.geometry=c.data.geometry})})];this._vertices.push({manipulator:s,coord:[r,i],handle:a(l)})}let n=this._vertices.length-1,r=this._vertices[n],[i,o]=e[n];(r.coord[0]!==i||r.coord[1]!==o)&&(r.coord=[i,o],r.manipulator.graphic.geometry=new S({x:i,y:o,spatialReference:t}));let s=this._drawActive?this._vertices[n].manipulator:null;this.manipulators.forEach(({manipulator:e})=>{e.interactive=s==null||e!==s}),this._updatePolylines()}_updatePolylines(){if(this._vertices.length<2){this._measurementLayer.removeAll();return}let e=J(this._vertices.map(({coord:e})=>e),this.view.spatialReference);if(!e)return;let{measurement:t,drawing:n,original:a}=e;this._set(`measurement`,t);let o=Z(this.messages,t,this.unit);this._set(`measurementLabel`,o);let s,c,{graphics:l}=this._measurementLayer,u=l.length===2,{effectiveTheme:d}=this.view;u?(s=l.at(0),c=l.at(1)):(s=new w({symbol:new O({data:{type:`CIMSymbolReference`,symbol:{type:`CIMLineSymbol`,symbolLayers:[{type:`CIMSolidStroke`,effects:[{type:`CIMGeometricEffectDashes`,dashTemplate:[14,12],lineDashEnding:`FullGap`,controlPointEnding:`NoConstraint`}],enable:!0,capStyle:`Butt`,joinStyle:`Round`,width:3.5,color:r(d.accentColor).toArray()},{type:`CIMSolidStroke`,enable:!0,capStyle:`Butt`,joinStyle:`Round`,width:5,color:d.accentColor.toArray()}]}}})}),c=new w({symbol:new j({color:d.textColor,haloColor:i(r(d.textColor,160),.5),haloSize:2,font:new k({size:14,family:`sans-serif`})})}),l.removeAll(),l.addMany([s,c])),s.geometry=n,c.geometry=a.extent?.center,c.symbol.text=o}};e([t()],K.prototype,`_drawActive`,void 0),e([t({readOnly:!0})],K.prototype,`cursor`,null),e([t({value:!0})],K.prototype,`editable`,null),e([t({readOnly:!0})],K.prototype,`measurement`,void 0),e([t({readOnly:!0})],K.prototype,`measurementLabel`,void 0),e([t()],K.prototype,`messages`,void 0),e([t({constructOnly:!0})],K.prototype,`snappingManager`,void 0),e([t()],K.prototype,`unit`,void 0),e([t()],K.prototype,`updating`,null),e([t({constructOnly:!0})],K.prototype,`view`,void 0),K=e([n(`esri.widgets.DistanceMeasurement2D.DistanceMeasurement2DTool`)],K);function q(e,t,n){let r=i(t.effectiveTheme.accentColor,.5),a={type:`simple-line`,width:0},o=new A({style:`circle`,color:r,size:8,outline:a}),s=new A({style:`circle`,color:r,size:12,outline:a}),c=new w({geometry:e,symbol:o});return new B({view:t,layer:n,graphic:c,focusedSymbol:s,consumesClicks:!1})}function J(e,t){let n=new C({paths:[e],spatialReference:t}),r,i;return t.isGeographic?m(t)?(r=h([n],`meters`)[0],i=g(n,G)):(r=y(n,{unit:`meters`}),i=_(n,G,{unit:`meters`})):t.isWebMercator?(r=y(n,{unit:`meters`}),i=_(n,G,{unit:`meters`})):(r=x(n,{unit:`meters`}),i=n),{measurement:{geometry:i,length:r},original:n,drawing:i}}function Y(e){return e!=null}async function X(e){(e?.isGeographic&&!m(e)||e?.isWebMercator)&&await Promise.all([v(),b()])}function Z(e,t,n){if(!t||!e)return``;switch(n){case`metric`:return f(e,t.length,`meters`);case`imperial`:return d(e,t.length,`meters`);default:return u(e,p(t.length,`meters`,n),n)}}export{K as DistanceMeasurement2DTool,J as createDistanceMeasurementInfo2D,Z as createDistanceMeasurementLabel,Y as isSupported,X as loadGeometryOperators};
2
+ import{__decorate as e}from"tslib";import{property as t,subclass as n}from"../../core/accessorSupport/decorators.js";import{getContrast as r,multiplyOpacity as i}from"../../core/colorUtils.js";import{handlesGroup as a}from"../../core/handleUtils.js";import{destroyMaybe as o}from"../../core/maybe.js";import{watch as s,initial as c}from"../../core/reactiveUtils.js";import{UpdatingHandles as l}from"../../core/support/UpdatingHandles.js";import{formatDecimal as u,formatImperialLength as d,formatMetricLength as f}from"../../core/unitFormatUtils.js";import{convertUnit as p}from"../../core/units.js";import{isSupported as m,geodesicLengths as h,geodesicDensify as g}from"../../geometry/geodesicUtils.js";import{geodeticDensifyExecute as _,geodeticDensifyLoad as v}from"../../geometry/operators/geodeticDensifyOperator.js";import{geodeticLengthExecute as y,geodeticLengthLoad as b}from"../../geometry/operators/geodeticLengthOperator.js";import{lengthExecute as x}from"../../geometry/operators/lengthOperator.js";import S from"../../geometry/Point.js";import C from"../../geometry/Polyline.js";import w from"../../Graphic.js";import{fetchMessageBundle as T,onLocaleChange as E}from"../../intl.js";import D from"../../layers/GraphicsLayer.js";import O from"../../symbols/CIMSymbol.js";import k from"../../symbols/Font.js";import A from"../../symbols/SimpleMarkerSymbol.js";import j from"../../symbols/TextSymbol.js";import{SnappingVisualizer2D as M}from"../../views/2d/interactive/SnappingVisualizer2D.js";import N from"../../views/draw/Draw.js";import{createCoordinateHelper as P}from"../../views/interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as F,screenToMap as I,dragManipulatedObject as L}from"../../views/interactive/dragEventPipeline.js";import{EditGeometry as R}from"../../views/interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as z}from"../../views/interactive/editGeometry/EditGeometryOperations.js";import{GraphicManipulator as B}from"../../views/interactive/GraphicManipulator.js";import{InteractiveToolBase as V}from"../../views/interactive/InteractiveToolBase.js";import{SnappingContext as H}from"../../views/interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as U}from"../../views/interactive/snapping/SnappingDragPipelineStep.js";import{setupSnappingToggleHandles as W}from"../../views/interactive/snapping/snappingUtils.js";const G=1e5;let K=class extends V{constructor(e){super(e),this._measurementLayer=new D({internal:!0,listMode:`hide`,visible:!1,title:`DistanceMeasurement2DTool measurement layer`}),this._manipulatorLayer=new D({internal:!0,listMode:`hide`,visible:!1,title:`DistanceMeasurement2DTool manipulator layer`}),this._snappingLayer=new D({internal:!0,listMode:`hide`,visible:!1,title:`DistanceMeasurement2DTool snapping layer`}),this._updatingHandles=new l,this._vertices=[],this._drawActive=!1,this.measurement=null,this.measurementLabel=null}initialize(){T(`esri/core/t9n/Units`).then(e=>{this.messages=e});let e=this.view;this._draw=new N({view:e}),e.map.addMany([this._measurementLayer,this._manipulatorLayer,this._snappingLayer]),e.focus(),this.addHandles([E(async()=>{this.messages=await T(`esri/core/t9n/Units`)}),s(()=>[this.unit,this.messages],()=>{this._updatePolylines()},c),s(()=>[this.view.effectiveTheme.accentColor,this.view.effectiveTheme.textColor],()=>{if(!this._vertices.length)return;let e=this._vertices.map(({coord:e})=>e);for(let{handle:e}of this._vertices)e.remove();this._vertices=[],this._measurementLayer.removeAll(),this._manipulatorLayer.removeAll(),this._snappingLayer.removeAll(),this.manipulators.removeAll(),this._updateSketch(e)})]),W(this)}destroy(){let{map:e}=this.view;this._draw.view=null,this._draw=o(this._draw),e.removeMany([this._measurementLayer,this._manipulatorLayer,this._snappingLayer]),this._measurementLayer.removeAll(),this._manipulatorLayer.removeAll(),this._snappingLayer.removeAll(),this._set(`measurement`,null),this._set(`measurementLabel`,null),this._measurementLayer=o(this._measurementLayer),this._manipulatorLayer=o(this._manipulatorLayer),this._snappingLayer=o(this._snappingLayer),this._updatingHandles=o(this._updatingHandles),this._resetVertices()}get cursor(){return this._drawActive?`crosshair`:null}set editable(e){this._set(`editable`,e),e||this._draw.reset()}get snappingOptions(){return this.snappingManager.options}get updating(){return this._updatingHandles.updating||this.snappingManager.updating}onActivate(){!this._drawActive&&this._vertices.length===0&&this._startSketch()}onShow(){this._measurementLayer.visible=!0,this._manipulatorLayer.visible=!0,this._snappingLayer.visible=!0}onHide(){this._measurementLayer.visible=!1,this._manipulatorLayer.visible=!1,this._snappingLayer.visible=!1}_getSnappingContext(e){return new H({elevationInfo:{mode:`on-the-ground`,offset:0},pointer:e,editGeometryOperations:new z(new R(`point`,P(!1,!1,this.view.spatialReference)),this.view.state.isGlobal),visualizer:new M(this._snappingLayer)})}_resetVertices(){for(let{handle:e}of this._vertices)e.remove();this._vertices=[]}_startSketch(){this._drawActive=!0;let{snappingManager:e}=this;this._draw.create(`polyline`,{mode:`click`,snappingManager:e}).on([`draw-complete`,`vertex-add`,`vertex-update`,`vertex-remove`,`cursor-update`,`undo`,`redo`],e=>{this._updateSketch(e.vertices),e.type===`draw-complete`&&this._stopSketch()})}_stopSketch(){this.manipulators.forEach(({manipulator:e})=>{e.interactive=!0}),this._drawActive=!1,this.finishToolCreation()}_updateSketch(e){let{spatialReference:t}=this.view;for(;this._vertices.length>e.length;){let{handle:e,manipulator:t}=this._vertices.pop();e.remove(),this.manipulators.remove(t)}for(let n=this._vertices.length;n<e.length;n++){let[r,i]=e[n],o=new S({x:r,y:i,spatialReference:t}),s=q(o,this.view,this._manipulatorLayer);this.manipulators.add(s);let c=z.fromGeometry(o,this.view.state.isGlobal),l=[c.on(`vertex-update`,e=>{let t=e.vertices.at(0);t&&(this._vertices[n].coord=[t.pos[0],t.pos[1]],this._updatePolylines())}),F(s,(e,t,n,r)=>{let i=this._getSnappingContext(r),{snappingManager:a}=this,o=this._updatingHandles,{snappingStep:s}=U({snappingContext:i,snappingManager:a,updatingHandles:o});t.next(I(this.view)).next(t=>{if(t.action===`start`){let n=new S(t.mapStart);e.graphic.geometry=n,c.trySetGeometry(n)}return t}).next(...s).next(L({operations:c})).next(()=>{e.graphic.geometry=c.data.geometry})})];this._vertices.push({manipulator:s,coord:[r,i],handle:a(l)})}let n=this._vertices.length-1,r=this._vertices[n],[i,o]=e[n];(r.coord[0]!==i||r.coord[1]!==o)&&(r.coord=[i,o],r.manipulator.graphic.geometry=new S({x:i,y:o,spatialReference:t}));let s=this._drawActive?this._vertices[n].manipulator:null;this.manipulators.forEach(({manipulator:e})=>{e.interactive=s==null||e!==s}),this._updatePolylines()}_updatePolylines(){if(this._vertices.length<2){this._measurementLayer.removeAll();return}let e=J(this._vertices.map(({coord:e})=>e),this.view.spatialReference);if(!e)return;let{measurement:t,drawing:n,original:a}=e;this._set(`measurement`,t);let o=Z(this.messages,t,this.unit);this._set(`measurementLabel`,o);let s,c,{graphics:l}=this._measurementLayer,u=l.length===2,{effectiveTheme:d}=this.view;u?(s=l.at(0),c=l.at(1)):(s=new w({symbol:new O({data:{type:`CIMSymbolReference`,symbol:{type:`CIMLineSymbol`,symbolLayers:[{type:`CIMSolidStroke`,effects:[{type:`CIMGeometricEffectDashes`,dashTemplate:[14,12],lineDashEnding:`FullGap`,controlPointEnding:`NoConstraint`}],enable:!0,capStyle:`Butt`,joinStyle:`Round`,width:3.5,color:r(d.accentColor).toArray()},{type:`CIMSolidStroke`,enable:!0,capStyle:`Butt`,joinStyle:`Round`,width:5,color:d.accentColor.toArray()}]}}})}),c=new w({symbol:new j({color:d.textColor,haloColor:i(r(d.textColor,160),.5),haloSize:2,font:new k({size:14,family:`sans-serif`})})}),l.removeAll(),l.addMany([s,c])),s.geometry=n,c.geometry=a.extent?.center,c.symbol.text=o}};e([t()],K.prototype,`_drawActive`,void 0),e([t({readOnly:!0})],K.prototype,`cursor`,null),e([t({value:!0})],K.prototype,`editable`,null),e([t({readOnly:!0})],K.prototype,`measurement`,void 0),e([t({readOnly:!0})],K.prototype,`measurementLabel`,void 0),e([t()],K.prototype,`messages`,void 0),e([t({constructOnly:!0})],K.prototype,`snappingManager`,void 0),e([t()],K.prototype,`unit`,void 0),e([t()],K.prototype,`updating`,null),e([t({constructOnly:!0})],K.prototype,`view`,void 0),K=e([n(`esri.widgets.DistanceMeasurement2D.DistanceMeasurement2DTool`)],K);function q(e,t,n){let r=i(t.effectiveTheme.accentColor,.5),a={type:`simple-line`,width:0},o=new A({style:`circle`,color:r,size:8,outline:a}),s=new A({style:`circle`,color:r,size:12,outline:a}),c=new w({geometry:e,symbol:o});return new B({view:t,layer:n,graphic:c,focusedSymbol:s,consumesClicks:!1})}function J(e,t){let n=new C({paths:[e],spatialReference:t}),r,i;return t.isGeographic?m(t)?(r=h([n],`meters`)[0],i=g(n,G)):(r=y(n,{unit:`meters`}),i=_(n,G,{unit:`meters`})):t.isWebMercator?(r=y(n,{unit:`meters`}),i=_(n,G,{unit:`meters`})):(r=x(n,{unit:`meters`}),i=n),{measurement:{geometry:i,length:r},original:n,drawing:i}}function Y(e){return e!=null}async function X(e){(e?.isGeographic&&!m(e)||e?.isWebMercator)&&await Promise.all([v(),b()])}function Z(e,t,n){if(!t||!e)return``;switch(n){case`metric`:return f(e,t.length,`meters`);case`imperial`:return d(e,t.length,`meters`);default:return u(e,p(t.length,`meters`,n),n)}}export{K as DistanceMeasurement2DTool,J as createDistanceMeasurementInfo2D,Z as createDistanceMeasurementLabel,Y as isSupported,X as loadGeometryOperators};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import e from"../../Color.js";import{isSome as t,addMany as n,equals as r}from"../../core/arrayUtils.js";import i from"../../core/Error.js";import{handlesGroup as a,abortHandle as o,makeHandle as s}from"../../core/handleUtils.js";import{clone as c}from"../../core/lang.js";import l from"../../core/Logger.js";import{getOrCreateMapValue as u}from"../../core/MapUtils.js";import{debounce as d,whenOrAbort as f,isPromiseLike as p}from"../../core/promiseUtils.js";import{whenOnce as m,when as h,watch as g,on as _}from"../../core/reactiveUtils.js";import{onePixelInPoints as v,px2pt as y}from"../../core/screenUtils.js";import{addMany as b}from"../../core/SetUtils.js";import{isSharedTemplateOrMetadata as x,isSharedGroupTemplate as S,getCreationAttributes as ee,isSharedPresetTemplate as C}from"../../editing/templateUtils.js";import{isCurvedGeometry as w,hasUnsupportedCurve as te}from"../../geometry/support/curves/curveUtils.js";import T from"../../Graphic.js";import ne from"../../layers/GraphicsLayer.js";import{featureHasFields as re,fixFields as E,getDisplayFieldName as ie}from"../../layers/support/fieldUtils.js";import{isSubtypeSublayer as ae}from"../../layers/support/layerUtils.js";import{calculateTolerance as oe}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as se}from"../../renderers/support/lengthUtils.js";import{isRenderer as ce}from"../../renderers/support/typeUtils.js";import{getTransformationType as le}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{isGraphic as ue}from"../../support/graphicInstanceUtils.js";import de from"../../symbols/SimpleFillSymbol.js";import D from"../../symbols/SimpleLineSymbol.js";import fe from"../../symbols/SimpleMarkerSymbol.js";import{to3D as pe}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as O}from"../../symbols/support/symbolUtils.js";import{getServices as me}from"../../undoredo/support/Services.js";import{defaultDrawingMode as he}from"../../views/draw/drawingModes.js";import{updateGraphicSymbolWhenRequired as k,fetchFullFeaturesByObjectId as ge}from"../../views/draw/support/editingSessionUtils.js";import{createQueryGeometry as _e}from"../../views/support/drapedUtils.js";import{filterGraphicHits as ve,hitTestSelectSimilarDistance as ye}from"../../views/support/hitTestSelectUtils.js";import{isDrawGraphicTool as be,isDrawTool as xe}from"../Sketch/support/sketchUtils.js";import{isNextOrLegacyUpdateWorkflow as Se,isNextOrLegacyUpdateFeaturesWorkflow as Ce}from"./compatibilityAdapters.js";import{dependencySort as we}from"./support/dependencySort.js";const Te=()=>l.getLogger(`esri.widgets.Editor.workflowUtils`);function Ee(e){return ke(e)||Oe(e)}function De(e){return!!e&&`features`in e}function Oe(e){return e!=null&&e.type===`update-features`}function ke(e){return e!=null&&e.type.includes(`update-`)&&`fullFeature`in e}function A(e){return e!=null&&e.type===`merge-features`}function j(e){return e!=null&&e.type===`split-feature`}function Ae(e){let t=e?.type;return t===`update-feature`||t===`update-table-record`||t===`update-features`||t===`split-feature`}function je(e){return e?.type===`merge`}function Me(e){return e?.type===`split`}function Ne(e){return A(e)||j(e)}function Pe(e){return e?.type===`update-multiple`}function M(e){let t=e&&`renderer`in e?e.renderer:null;if(!L(t))return{rotation:null,size:null};let n=t.getVisualVariablesForType(`rotation`).filter(e=>(!e.axis||e.axis===`heading`)&&e.field&&!e.valueExpression),r=t.getVisualVariablesForType(`size`).filter(e=>e.field&&!e.useSymbolValue&&!e.valueExpression&&le(e)===`real-world-size`);return{rotation:n.length===1?n[0]:null,size:r.length===1?r[0]:null}}function N(e){let t=e.sourceLayer;if(!(t&&`renderer`in t&&L(t.renderer)))return{rotation:null,size:null};let{rotation:n,size:r}=M(t),i=null,a=null;if(n){let e=t.fields?.filter(e=>e.name===n.field);i=P(n,e?.length===1?e[0]:null)}if(r){let e=t.fields?.filter(e=>e.name===r.field);a=F(r,e?.length===1?e[0]:null)}return{rotation:i,size:a}}function P(e,t){let n=(e.axis||`heading`)===`heading`&&e.rotationType===`arithmetic`?-1:1,r=t?.type??`double`,i={initial:0,current:0};return{field:e.field,fieldType:r,getDefaultValue:()=>Promise.resolve(0),getValue:e=>(i.current=i.initial-n*e,I((i.current+360)%360,r)),setInitialValue:e=>{i.initial=e,i.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??`geographic`}}function Fe(e,t){switch(t){case`width`:return e[0];case`depth`:return e[1];case`height`:return e[2];default:return e[2]||e[1]||e[0]}}async function Ie(e,t,n){if(t==null)return 0;let{symbol:r}=pe(t);if(r==null||r.type===`web-style`||r.type===`cim`)return 0;let i=r.symbolLayers.at(0);if(!i)return 0;switch(i.type){case`icon`:{let{computeIconLayerResourceSize:e}=await import(`../../symbols/support/symbolLayerUtils.js`);return Math.min(Z.icon,(await e(i,Z.icon))[0])||Z.icon}case`text`:return Z.text;case`line`:return Z.line;case`object`:{let{computeObjectLayerResourceSize:t}=await import(`../../symbols/support/symbolLayerUtils.js`);return Fe(await t(i,e.scale/Z.viewScaleSizeFactor),n)}case`path`:case`extrude`:return e.scale/Z.viewScaleSizeFactor;default:return 0}}function F(e,t){let n=e.axis,r=t?.type??`double`,i={initial:0,current:0},a=se[e.valueUnit]??1,o;return o=e.valueRepresentation===`area`?e=>(e*a/2)**2*Math.PI:e.valueRepresentation===`radius`||e.valueRepresentation===`distance`?e=>e*a/2:e=>e*a,{field:e.field,fieldType:r,getDefaultValue:async(e,t)=>I(o(await Ie(t,e,n)),r),getValue:(e,t)=>(i.initial||=t.pixelSizeAt(t.center),i.current=i.initial*e,I(i.current,r)),setInitialValue:e=>{i.initial=e,i.current=0},isUpdatingInteractively:!1,displayUnit:ct(e.valueUnit),axis:e.axis}}function I(e,t){switch(t){case`small-integer`:case`integer`:case`long`:return Math.round(e);case`double`:case`single`:return e;default:return 0}}function L(e){if(!ce(e))return!1;switch(e?.type){case`class-breaks`:case`simple`:case`unique-value`:case`dot-density`:case`dictionary`:case`pie-chart`:return!0;default:return!1}}function R(e,t){if(!e||!t)throw Error(`no geometry type`);if(e===`multipatch`)return{tool:`mesh`,createOptions:{mode:`hybrid`}};let n=new Map;n.set(`circle`,{mode:`freehand`}),n.set(`rectangle`,{mode:`freehand`});let r={mode:he,optionsPerTool:n};if(x(t)){let i=t.defaultTool,a=S(t)?t.definition?.inputGeometryType??e:e;switch(i){case`freehand`:case`stream-line`:return{tool:a===`polyline`?`freehandPolyline`:`freehandPolygon`,createOptions:r};case`autocomplete-freehand-polygons`:case`stream-polygon`:return{tool:`freehandPolygon`,createOptions:r};case`autocomplete-polygons`:case`difference-polygon`:case`create-structures`:case`polygon`:case`trace`:return{tool:a===`polygon`?`polygon`:`polyline`,createOptions:r};case`circle`:return n.get(`circle`).preserveAspectRatio=!0,{tool:`circle`,createOptions:r};case`ellipse`:return n.get(`circle`).preserveAspectRatio=!1,{tool:`circle`,createOptions:r};case`create-points-along-line`:case`multipoint`:return{tool:`multipoint`,createOptions:r};case`line`:case`radial-line`:case`right-angle-line`:case`split`:case`two-point-line`:return{tool:`polyline`,createOptions:r};case`rectangle`:case`regular-polygon`:case`right-angle-polygon`:return{tool:`rectangle`,createOptions:r};case`elevation-point-from-contour`:case`elevation-point-from-dem`:case`parcel-seed`:case`point`:case`point-and-rotation`:case`point-at-end-of-line`:return{tool:`point`,createOptions:r}}}else{let i=t.drawingTool;if(i===`circle`||i===`ellipse`)return n.get(`circle`).preserveAspectRatio=i===`circle`,{tool:`circle`,createOptions:r};if(i===`rectangle`)return{tool:`rectangle`,createOptions:r};if(i===`freehand`)return{tool:e===`polygon`?`freehandPolygon`:`freehandPolyline`,createOptions:r}}return{tool:e,createOptions:r}}async function Le(e,t,n){let{creationInfo:r,fullTemplate:a}=n;if(!r)throw new i(`featureworkflow`,`No creation info provided.`);let o=r.layer,s=ee(a,r.attributeOverrides,r.layer),{view:c}=e,l=c?.type===`2d`;!S(a)&&!C(a)&&await J(e,o,s,l?c.scale:null);let{capabilities:u}=o;t.elevationInfo=o.elevationInfo;let d=R(o.geometryType,a);e.defaultCreateOptions={graphicProperties:{attributes:s,sourceLayer:o},mode:d.createOptions.mode,optionsPerTool:d.createOptions.optionsPerTool,preserveAspectRatio:d.createOptions.preserveAspectRatio,hasZ:u.data.supportsZ,defaultZ:(l?u.editing.zDefault:null)??e.defaultCreateOptions.defaultZ},r.geometryToPlace==null?await e.create(d.tool):await e.place(r.geometryToPlace,{graphicProperties:{attributes:s,sourceLayer:o}})}async function Re(e){return a([ze(e),Be(e)])}function ze({creationAttributes:e,data:t,sketchViewModel:n,view:r}){let{creationInfo:i}=t,{fullTemplate:a}=t;if(!i||r?.type!==`2d`||S(a)||C(a))return null;let o=d(t=>J(n,i.layer,e,t));return g(()=>r.scale,e=>o(e))}function Be({data:t,sketchViewModel:n,view:r}){let{templateExecutorInfo:o}=t;if(!o)return null;let c=n.activeComponent;if(!r||!be(c)&&!xe(c))return Te().error(new i(`featureworkflow`,`Failed to set up template feedback.`)),null;let l=new ne({effect:`saturate(0.6) opacity(0.8)`,listMode:`hide`,title:`Shared Template Feedback Graphics`});r.map?.add(l);let{executor:u,serviceLayersById:d}=o,f=r.theme?.accentColor??new e([255,165,0,1]);return a([_(()=>c,[`cursor-update`,`vertex-add`],()=>{l.removeAll();let e=be(c)?c.graphic?.geometry:c.unprocessedGeometry;if(!e||!Ve(e))return;let t=u(e,`digitizing`);if(!p(t))for(let e of t.edits){let t=d.get(e.id);if(t&&e.addFeatures&&e.addFeatures.length!==0){for(let n of t)if(!n.isTable)for(let t of e.addFeatures){let e=He(t,f);e&&l.add(e)}}}}),s(()=>{r.map.remove(l),l.destroy()})])}function Ve(e){switch(e.type){case`point`:case`multipoint`:return!0;case`polyline`:{if(w(e))return e.curvePaths[0].length>1;let t=e.paths[0];return t?t.length>1:!1}case`polygon`:{if(w(e))return e.curveRings[0].length>2;let t=e.rings[0];return t?r(t.at(0),t.at(-1))?t.length>2:t.length>1:!1}default:return!1}}function He(e,t){let n=null;switch(e.geometry?.type){case`point`:case`multipoint`:n=new fe({angle:0,color:t,outline:new D({cap:`round`,color:t,join:`round`,miterLimit:1,style:`solid`,width:1}),path:`undefined`,size:8,style:`circle`,xoffset:0,yoffset:0});break;case`polygon`:n=new de({color:t,outline:new D({cap:`round`,color:t,join:`round`,miterLimit:1,style:`solid`,width:3}),style:`none`});break;case`polyline`:n=new D({cap:`round`,color:t,join:`round`,miterLimit:1,style:`solid`,width:2});break;default:return null}return new T({geometry:e.geometry,symbol:n,attributes:{...e.attributes}})}function z(e,t){let n=me(t),r=ae(e)?e.parent:e;return n.tablesAndLayersLookup.get(r)}function Ue(e,t){let n=z(e,t);if(!n)return new Map;let r=new Map;for(let e of n.layersAndTables)u(r,e.layerId,()=>[]).push(e);return r}function B(e){let t=e.objectIdField,n=e.globalIdField??``;return{id:e.layerId,identifierFields:{objectIdField:t,globalIdField:n},addFeatures:[],deleteAttachments:[],addAttachments:[],deleteFeatures:[],updateFeatures:[]}}function We(e){let{edits:n,serviceInfo:r,view:i,findOriginalFeature:a}=e,o=V(r.layersAndTables),s=r.layersAndTables.toArray(),{allEditData:c,editDataByLayerIdMap:l,editDataByIdMap:u}=Ge(n,o,a),d=U(c,H(s,l),l);if(i&&K(c,d,i),d.length===0)return n;let f=we(d,{continueOnCircularDependency:!0}).map(e=>u.get(e)).filter(t),p=new Map;for(let e of f)p.set(e.uniqueId,e);let m=[];for(let e of c)p.has(e.uniqueId)||m.push(e);let h=[],g=null;for(let e of f){let{layer:t}=e;switch(g==null?g=B(t):g.id!==t.layerId&&(h.push(g),g=B(t)),e.operationType){case`add`:case`modify`:g.addFeatures.push(e.after);break;case`delete`:g.deleteFeatures.push(e.before)}}g!==null&&h.push(g);for(let e of m){let t=e.layer.layerId,n=h.find(e=>e.id===t)??B(e.layer);switch(h.includes(n)||h.push(n),e.operationType){case`add`:n.addFeatures.push(e.after);break;case`modify`:n.updateFeatures.push(e.after);break;case`delete`:n.deleteFeatures.push(e.before);break;case`deleteAttachment`:n.deleteAttachments.push(e.attachmentId);break;case`addAttachment`:n.addAttachments.push(e.attachment)}}for(let e of h)e.deleteAttachments!==void 0&&e.deleteAttachments.length===0&&delete e.deleteAttachments,e.addAttachments!==void 0&&e.addAttachments.length===0&&delete e.addAttachments;return h}function V(e){let t=new Map;for(let n of e)t.set(n.layerId,n);return t}function H(e,t){let n=new Map;for(let r of e)for(let e of r.relationships??[])if(n.set(W(r,e),``),t.has(e.relatedTableId)){let i=t.get(e.relatedTableId);if(i.length>0){for(let t of i[0].layer.relationships??[])if(t.id===e.id){n.set(W(r,e),t.keyField);break}}}return n}function Ge(e,t,n){let r=new Map,a=[],o=new Map,s=1;for(let c of e){let e=[],l=t.get(c.id);if(!l)throw new i(`featureworkflow`,`Failed to prepare applyEdits payload. Layer with id ${c.id} not found.`);for(let t of c.addFeatures??[])e.push({uniqueId:`T${s++}`,operationType:`add`,layer:l,after:t});for(let t of c.deleteFeatures??[])e.push({uniqueId:`T${s++}`,operationType:`delete`,before:t,layer:l});for(let t of c.deleteAttachments??[])e.push({uniqueId:`T${s++}`,operationType:`deleteAttachment`,attachmentId:t,layer:l});for(let t of c.addAttachments??[])e.push({uniqueId:`T${s++}`,operationType:`addAttachment`,attachment:t,layer:l});for(let t of c.updateFeatures??[])e.push({uniqueId:`T${s++}`,operationType:`modify`,before:n(t),after:t,layer:l});r.set(l.layerId,e);for(let t of e)a.push(t),o.set(t.uniqueId,t)}return{allEditData:a,editDataByIdMap:o,editDataByLayerIdMap:r}}function U(e,t,n){let r=[];for(let i of e){let e=i.layer.relationships??[],{uniqueId:a}=i;for(let o of e){let e=o.keyField;if(o.role===`origin`){let s=n.get(o.relatedTableId);if(!s||s.length===0)continue;let c=W(i.layer,o),l=t.get(c);if(l===void 0||l===``)continue;switch(i.operationType){case`add`:for(let t of s)t!==i&&(t.operationType===`add`||t.operationType===`modify`)&&t.after.attributes[l]===i.after.attributes[e]&&r.push([a,t.uniqueId]);break;case`modify`:if(i.before.attributes[e]!==i.after.attributes[e])for(let t of s){let n=t.uniqueId;t!==i&&(t.operationType===`delete`?t.before.attributes[l]===i.before.attributes[e]?r.push([n,a]):t.before.attributes[l]===i.after.attributes[e]&&r.push([a,n]):t.operationType===`add`?t.after.attributes[l]===i.after.attributes[e]?r.push([a,n]):t.after.attributes[l]===i.before.attributes[e]&&r.push([n,a]):t.operationType===`modify`&&(t.before.attributes[l]===t.after.attributes[l]||t.after.attributes[l]===i.after.attributes[e]?r.push([a,n]):r.push([n,a])))}break;case`delete`:for(let t of s)t!==i&&(t.operationType===`delete`||t.operationType===`modify`)&&t.before.attributes[l]===i.before.attributes[e]&&r.push([t.uniqueId,a])}}}}return r}function W(e,t){return`${e.layerId}:${t.id}`}function G(e,t){return!!(t?.map&&`utilityNetworks`in t.map&&t.map.utilityNetworks?.length&&t.map.utilityNetworks.some(t=>!!(t.loaded&&e.url?.startsWith(t.featureServiceUrl)&&e.layerId===t.networkSystemLayers.associationsTableId)))}function K(e,t,n){let r=[];for(let t of e)G(t.layer,n)&&r.push(t);if(r.length===0)return;let i=[];for(let n of r){let r=n.layer;switch(n.operationType){case`delete`:i=[...q(n.before.attributes[r.fieldsIndex.get(`fromglobalid`).name],e),...q(n.before.attributes[r.fieldsIndex.get(`toglobalid`).name],e)];for(let e of i)t.push([n.uniqueId,e.uniqueId]);break;case`add`:i=[...q(n.after.attributes[r.fieldsIndex.get(`fromglobalid`).name],e),...q(n.after.attributes[r.fieldsIndex.get(`toglobalid`).name],e)];for(let e of i)t.push([e.uniqueId,n.uniqueId])}}}function q(e,t){let n=[],r=t.filter(({layer:e})=>e.globalIdField!==``&&e.globalIdField!=null);for(let t of r){let r=t.layer.globalIdField;(`before`in t&&t.before?.attributes[r]===e||`after`in t&&t.after?.attributes[r]===e)&&n.push(t)}return n}async function J(e,t,n,r){let i=new T({sourceLayer:t,attributes:n}),{rotation:a,size:o}=N(i),s=await O(i,{useSourceLayer:!0,scale:r}),c=!1;for(let t of[o,a])t!=null&&(n[t.field]??(n[t.field]=await t.getDefaultValue(s,e.view),c=!0));switch(c&&(s=await O(i,{useSourceLayer:!0,scale:r})),s?.type){case`simple-fill`:case`polygon-3d`:e.polygonSymbol=s;break;case`simple-line`:case`line-3d`:e.polylineSymbol=s;break;case`simple-marker`:case`picture-marker`:case`point-3d`:case`cim`:e.pointSymbol=s;break;case`mesh-3d`:e.meshSymbol=s}Y(e.tooltipOptions,o,a)}function Y(e,t,n){e.visualVariables=t!=null||n!=null?{size:t==null?null:{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType},rotation:n==null?null:{valueType:n.fieldType,rotationType:n.rotationType??`geographic`}}:null}function Ke(e,t){return e.find(e=>e.layer===t)}function qe(e,t){let n=Ke(e,t);if(n==null)throw new i(`no-editorItem-found`,`The EditorViewModel provided did not have an EditorItem associated with the specified layer`);return n}function Je(e,t){return e?.find(e=>e.layer===t)}async function Ye(e,t,n,r){switch(t.type){case`3d`:return Xe(e,t,n,r);case`2d`:return Ze(e,t,n,r)}}async function Xe(e,t,r,i){if(e.length===0)return[];let{updatable:a,graphicsByLayer:o}=await r.defer(async()=>{let{results:n}=await f(ye(t,r),i),a=new Map,o=e=>{let t=e.layer,n=a.get(t);if(!n){let e=[];return a.set(t,e),e}return n};ve(n).forEach(({graphic:e})=>o(e).push(e));let s=e.filter(({capabilities:e,layer:t})=>e.update.enabled&&a.has(t));return s.length!==0&&r.stopPropagation(),{updatable:s,graphicsByLayer:a}});return f(Promise.allSettled(a.map(async({layer:e})=>{let t=o.get(e),r=Qe(e);if(t.every(e=>re(e,r)))return t;let a=[];for(let e of t){a.push(e.getObjectId());let t=Object.keys(e.attributes);n(r,t)}let s=e.createQuery();return s.returnGeometry=!1,s.objectIds=a,s.outFields=E(e.fieldsIndex,r),e.queryFeatures(s,{signal:i}).then(({features:e})=>e)})),i)}async function Ze(e,t,n,r){if(e.length===0)return[];let{mapPoint:i}=n;if(i==null)return[];let a=null,o=await n.defer(async()=>{let{results:i}=await f(t.hitTest(n),r);if(i.length===0)return[];let o=new Set;a=ve(i),a.forEach(({graphic:e})=>e&&o.add(e.layer));let s=e.filter(e=>o.has(e.layer)&&e.supportsUpdateWorkflow);return s.length>0&&n.stopPropagation(),s});return f(Promise.allSettled(o.map(async({layer:e})=>{let o=e.createQuery();o.returnGeometry=!0,o.outFields=Qe(e);let s=`renderer`in e?oe({renderer:e.renderer,pointerType:n.pointerType}):0;o.geometry=_e(i,s,t),o.outSpatialReference=t.spatialReference;let{features:c}=await e.queryFeatures(o,{signal:r});return a?.forEach(({graphic:t})=>{t.layer===e&&!c.some(e=>e.getObjectId()===t.getObjectId())&&c.push(t)}),c})),r)}function Qe(e){return E(e.fieldsIndex,[e.objectIdField,ie({displayField:`displayField`in e?e.displayField:null,fields:e.fields})])}async function $e(e,n,r,i){let a=e.map(e=>e.getObjectId()??e.attributes[n.objectIdField]).filter(t);return await ge(a,n,r,i)}async function X(e){let{graphic:t,sketchViewModel:n,sourceLayer:r,updateOptions:i,visualVariables:a}=e;await tt(e);let o={multipleSelectionEnabled:!1,...i};return r.geometryType===`point`&&(o.enableRotation=a.rotation!=null,o.enableScaling=a.size!=null),n.update(t,o)}function et(e,t){let{activeUpdateOptions:n}=e;n&&(e.activeUpdateOptions={...n,...t,reshapeOptions:{...n.reshapeOptions,...t.reshapeOptions},highlightOptions:{...n.highlightOptions,...t.highlightOptions}})}async function tt(e){let{graphic:t,sketchLayer:n,sketchViewModel:r,sourceLayer:i,visualVariables:a}=e,o=!1,{rotation:s,size:c}=a;for(let e of[s,c]){if(e==null)continue;let n=t.getAttribute(e.field);if(n!=null)e.setInitialValue(n);else{let n=await e.getDefaultValue(t.symbol,r.view);e.setInitialValue(n),t.setAttribute(e.field,n),o=!0}}if(o){let e=r.view?.type===`2d`?r.view.scale:null;await k(t,e)}Y(r.tooltipOptions,c,s),n.elevationInfo=i.elevationInfo}function nt(e){return e!=null&&(e.type===`rotate-start`||e.type===`rotate`||e.type===`rotate-stop`)?e:null}function rt(e){return e!=null&&(e.type===`scale-start`||e.type===`scale`||e.type===`scale-stop`)?e:null}function it(e,t,n,r){if(t.geometry==null||t.geometry?.type!==`point`)return!1;let i=t.attributes,a=!1,o=r.rotation,s=nt(n.toolEventInfo);if(o!=null&&s!=null){let{field:n,getValue:r}=o;if(s.type===`rotate-stop`)o.isUpdatingInteractively=!1,o.setInitialValue(t.getAttribute(n));else{o.isUpdatingInteractively=!0;let c=r(s.angle,e);c!==i[n]&&t.setAttribute(n,c),a=!0}}let c=r.size,l=rt(n.toolEventInfo);if(c!=null&&l!=null){let{field:n,getValue:r}=c;if(l.type===`scale-stop`)c.isUpdatingInteractively=!1,c.setInitialValue(t.getAttribute(n));else{c.isUpdatingInteractively=!0;let o=r(l.xScale,e);o!==i[n]&&t.setAttribute(n,o),a=!0}}return a}async function at({feature:e,featureClone:t,sketchLayer:n,sketchViewModel:r,getUpdateOptions:i,view:c,visualVariableAttributes:l,addHandle:u,updatingHandles:f,onUpdate:p}){await k(t,c.type===`2d`?c.scale:null);let g=null;if(r?.view?.type===`2d`){let e=d(e=>k(t,e));g=f.add(()=>r?.view?.scale,t=>f.consumePromise(e(t)))}let _=t.sourceLayer,v=ut(c,_);await X({graphic:t,sketchLayer:n,sketchViewModel:r,sourceLayer:_,updateOptions:i(),visualVariables:l});let y=null;v.then(e=>y=e).catch(()=>{});let b=l.size,x=l.rotation,S=f.add(()=>e.attributes,async e=>{let n=!1;for(let r in e){let i=e[r];i!==t.getAttribute(r)&&(t.setAttribute(r,i),b!=null&&!b.isUpdatingInteractively&&b.field===r&&b.setInitialValue(i),x!=null&&!x.isUpdatingInteractively&&x.field===r&&x.setInitialValue(i),(y==null||y.requiredFields.includes(r))&&(n=!0))}n&&await f.addPromise(k(t,c.type===`2d`?c.scale:null))}),ee=r.on(`update`,async e=>{let t=e.graphics[0],a={graphic:t,sketchLayer:n,sketchViewModel:r,sourceLayer:_,updateOptions:i(),visualVariables:l};if(e.state===`complete`){let e=new AbortController;u(o(e)),f.consumePromise(m(()=>c.activeTool===null,e.signal).then(async()=>{if(!e.signal.aborted)return e.abort(),X(a)}))}else it(c,t,e,l)&&await f.addPromise(k(t,c.type===`2d`?c.scale:null)),p(Q(t),e)}),C=h(()=>c.activeTool!=null&&c.activeTool!==r.activeComponent,()=>r.cancel()),w=r.on([`undo`,`redo`],e=>{p(Q(e.graphics[0]),e)});return a([w,ee,C,s(()=>r.cancel()),S,g])}const Z={icon:y(24),text:y(12),line:v,viewScaleSizeFactor:100};function ot(e,t,n){let r=!1;return e.filter(e=>r?!0:(r=e===t,r)).map(e=>n[e]())}function st(e,t){e.viewModel.syncFeatureTemplates();let n=e.creationInfo;if(t[0].id===`awaiting-feature-creation-info`&&n){let r=n.layer,i=e.viewModel.getTemplatesForLayer(r);i.length===1&&r.type!==`scene`&&(n.template=i[0],t.shift())}return t}function ct(e){switch(e){case`unknown`:return null;default:return e}}const lt=e=>e.includes(`-stop`)||e.includes(`vertex-`),ut=(e,t)=>{let n=t.type===`subtype-sublayer`?t.parent:t;return e.whenLayerView(n)};function dt(e){return`createInteractiveEditSession`in e}function Q(e){let t=e.geometry;if(t?.type===`mesh`){let n=e.cloneShallow();return n.attributes=c(e.attributes),n.geometry=t.cloneShallow(),n.geometry.transform=t.transform?.clone()??null,n}return e.clone()}function ft(e){return e.acquireCursor(`progress`)}function $(e){for(let t of e){let{destinationGraphic:e,destinationField:n,sourceGraphic:r,sourceField:i}=t;e.setAttribute(n,r.getAttribute(i))}}function pt(e){let t=e.templateExecutorInfo?.completionResults;return t?.length?(t.forEach(e=>$(e.relationships)),t.flatMap(e=>e.edits)):null}function mt(e){let t=Se(e)?e.activeWorkflow:e;if(t==null)return[];if(Ce(t))return t.data.layers;let n=t.layer;return n?[n]:[]}function ht({attributes:e},t){let n=new Set;n.add(t.objectIdField),`uniqueIdFields`in t&&t.uniqueIdFields&&t.uniqueIdFields.length>0&&b(n,t.uniqueIdFields);let r={};for(let t of n)e[t]!=null&&(r[t]=e[t]);if(t.type===`scene`&&t.infoFor3D!=null){let n=t.associatedLayer?.globalIdField;n!=null&&(e[n]=e[n])}return r}function gt(e){if(!_t(e))return e;let t=new Map;for(let n of e){let e=n.getObjectId();if(e!=null){let r=n.sourceLayer??n.layer;u(t,r,()=>[]).push(e)}}return Array.from(t.entries()).map(([e,t])=>({layer:e,objectIds:t}))}function _t(e){return e.length===0||ue(e[0])}function vt({drawTool:e},t){let n=e?.mostDownstreamPlugin?.configuration?.curveTypes;if(!t||!n||n.length===0)return!1;let r=new Set(t.capabilities.supportedCurveTypes);return n.some(e=>!r.has(e))}function yt(e,t){let n=new Set(t.capabilities.supportedCurveTypes);return e.some(({geometry:e})=>e&&w(e)&&te(e,n))}function bt({filter:e,forEachFeature:t,forEachValueChange:n}){return r=>{for(let{feature:i,changes:a}of r.data)if(!e||e(i)){for(let{fieldName:e,value:t}of a)n?.(e,t,i);t?.(i,a)}}}export{vt as activeSketchToolDrawsUnsupportedCurve,K as appendAllUtilityNetworkAssociationRelationships,st as avoidFeatureTemplateSelectionWithOnlyOneItem,dt as canCreateInteractiveEditSession,Q as cloneGraphicExceptMesh,yt as containsUnsupportedCurve,V as createLayerIdMap,H as createRelationshipKeyMap,R as createToolFromGeometryType,ot as createWorkflowSteps,Ye as fetchCandidates,$e as fetchFullFeatures,U as findAllDependencies,q as findChangesByGlobalId,Ke as findEditorItemForLayer,qe as findEditorItemForLayerOrThrow,Je as findLayerInfo,W as generateHashForRelationship,mt as getLayersFromWorkflow,P as getRotationVariableAttribute,pt as getServiceEditsFromWorkflowData,z as getServiceInfoForLayer,Ue as getServiceLayersById,F as getSizeVariableAttribute,N as getVisualVariableAttributes,M as getVisualVariablesForLayer,bt as handleFormValuesChangeEvent,Ee as isAnyUpdateLeafWorkflow,De as isBatchAttributeFormViewModel,_t as isGraphicsArray,A as isMergeFeaturesWorkflow,je as isMergeWorkflowOptions,Ae as isParentWorkflow,j as isSplitFeatureWorkflow,Me as isSplitWorkflowOptions,lt as isTerminalUpdateEventType,Oe as isUpdateFeaturesWorkflow,Pe as isUpdateFeaturesWorkflowOptions,ke as isUpdateRecordWorkflow,G as isUtilityNetworkAssociationsTable,ht as makeMinimalAttributes,We as orderEditsByRelationshipDependencies,$ as setRelationshipFields,at as setUpGeometryUpdate,Re as setUpSketchCreateWatchers,tt as setVisualVariablesAndElevationInfoForUpdate,ft as showProgressCursor,Z as sizeDefaults,ct as sizeVariableUnitToLengthUnit,Le as startCreatingNewFeature,X as startUpdatingFeatureGeometry,et as syncUpdateOptions,gt as toFeatureInfos,it as visualVariableInteractiveUpdate,ut as whenEditorLayerView,Ne as workflowInfluencesOutcomeOfParent};
2
+ import e from"../../Color.js";import{isSome as t,addMany as n,equals as r}from"../../core/arrayUtils.js";import i from"../../core/Error.js";import{handlesGroup as a,abortHandle as o,makeHandle as s}from"../../core/handleUtils.js";import{clone as c}from"../../core/lang.js";import l from"../../core/Logger.js";import{getOrCreateMapValue as u}from"../../core/MapUtils.js";import{debounce as d,whenOrAbort as f,isPromiseLike as p}from"../../core/promiseUtils.js";import{whenOnce as m,when as h,watch as g,on as _}from"../../core/reactiveUtils.js";import{onePixelInPoints as v,px2pt as y}from"../../core/screenUtils.js";import{addMany as b}from"../../core/SetUtils.js";import{isSharedTemplateOrMetadata as x,isSharedGroupTemplate as S,getCreationAttributes as ee,isSharedPresetTemplate as C}from"../../editing/templateUtils.js";import{isCurvedGeometry as w,hasUnsupportedCurve as te}from"../../geometry/support/curves/curveUtils.js";import T from"../../Graphic.js";import ne from"../../layers/GraphicsLayer.js";import{featureHasFields as re,fixFields as E,getDisplayFieldName as ie}from"../../layers/support/fieldUtils.js";import{isSubtypeSublayer as ae}from"../../layers/support/layerUtils.js";import{calculateTolerance as oe}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as se}from"../../renderers/support/lengthUtils.js";import{isRenderer as ce}from"../../renderers/support/typeUtils.js";import{getTransformationType as le}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{isGraphic as ue}from"../../support/graphicInstanceUtils.js";import de from"../../symbols/SimpleFillSymbol.js";import D from"../../symbols/SimpleLineSymbol.js";import fe from"../../symbols/SimpleMarkerSymbol.js";import{to3D as pe}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as O}from"../../symbols/support/symbolUtils.js";import{getServices as me}from"../../undoredo/support/Services.js";import{defaultDrawingMode as he}from"../../views/draw/drawingModes.js";import{updateGraphicSymbolWhenRequired as k,fetchFullFeaturesByObjectId as ge}from"../../views/draw/support/editingSessionUtils.js";import{createQueryGeometry as _e}from"../../views/support/drapedUtils.js";import{filterGraphicHits as ve,hitTestSelectSimilarDistance as ye}from"../../views/support/hitTestSelectUtils.js";import{isDrawGraphicTool as be,isDrawTool as xe}from"../Sketch/support/sketchUtils.js";import{isNextOrLegacyUpdateWorkflow as Se,isNextOrLegacyUpdateFeaturesWorkflow as Ce}from"./compatibilityAdapters.js";import{dependencySort as we}from"./support/dependencySort.js";const Te=()=>l.getLogger(`esri.widgets.Editor.workflowUtils`);function Ee(e){return ke(e)||Oe(e)}function De(e){return!!e&&`features`in e}function Oe(e){return e!=null&&e.type===`update-features`}function ke(e){return e!=null&&e.type.includes(`update-`)&&`fullFeature`in e}function A(e){return e!=null&&e.type===`merge-features`}function j(e){return e!=null&&e.type===`split-feature`}function Ae(e){let t=e?.type;return t===`update-feature`||t===`update-table-record`||t===`update-features`||t===`split-feature`}function je(e){return e?.type===`merge`}function Me(e){return e?.type===`split`}function Ne(e){return A(e)||j(e)}function Pe(e){return e?.type===`update-multiple`}function M(e){let t=e&&`renderer`in e?e.renderer:null;if(!L(t))return{rotation:null,size:null};let n=t.getVisualVariablesForType(`rotation`).filter(e=>(!e.axis||e.axis===`heading`)&&e.field&&!e.valueExpression),r=t.getVisualVariablesForType(`size`).filter(e=>e.field&&!e.useSymbolValue&&!e.valueExpression&&le(e)===`real-world-size`);return{rotation:n.length===1?n[0]:null,size:r.length===1?r[0]:null}}function N(e){let t=e.sourceLayer;if(!(t&&`renderer`in t&&L(t.renderer)))return{rotation:null,size:null};let{rotation:n,size:r}=M(t),i=null,a=null;if(n){let e=t.fields?.filter(e=>e.name===n.field);i=P(n,e?.length===1?e[0]:null)}if(r){let e=t.fields?.filter(e=>e.name===r.field);a=F(r,e?.length===1?e[0]:null)}return{rotation:i,size:a}}function P(e,t){let n=(e.axis||`heading`)===`heading`&&e.rotationType===`arithmetic`?-1:1,r=t?.type??`double`,i={initial:0,current:0};return{field:e.field,fieldType:r,getDefaultValue:()=>Promise.resolve(0),getValue:e=>(i.current=i.initial-n*e,I((i.current+360)%360,r)),setInitialValue:e=>{i.initial=e,i.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??`geographic`}}function Fe(e,t){switch(t){case`width`:return e[0];case`depth`:return e[1];case`height`:return e[2];default:return e[2]||e[1]||e[0]}}async function Ie(e,t,n){if(t==null)return 0;let{symbol:r}=pe(t);if(r==null||r.type===`web-style`||r.type===`cim`)return 0;let i=r.symbolLayers.at(0);if(!i)return 0;switch(i.type){case`icon`:{let{computeIconLayerResourceSize:e}=await import(`../../symbols/support/symbolLayerUtils.js`);return Math.min(Z.icon,(await e(i,Z.icon))[0])||Z.icon}case`text`:return Z.text;case`line`:return Z.line;case`object`:{let{computeObjectLayerResourceSize:t}=await import(`../../symbols/support/symbolLayerUtils.js`);return Fe(await t(i,e.scale/Z.viewScaleSizeFactor),n)}case`path`:case`extrude`:return e.scale/Z.viewScaleSizeFactor;default:return 0}}function F(e,t){let n=e.axis,r=t?.type??`double`,i={initial:0,current:0},a=se[e.valueUnit]??1,o;return o=e.valueRepresentation===`area`?e=>(e*a/2)**2*Math.PI:e.valueRepresentation===`radius`||e.valueRepresentation===`distance`?e=>e*a/2:e=>e*a,{field:e.field,fieldType:r,getDefaultValue:async(e,t)=>I(o(await Ie(t,e,n)),r),getValue:(e,t)=>(i.initial||=t.pixelSizeAt(t.center),i.current=i.initial*e,I(i.current,r)),setInitialValue:e=>{i.initial=e,i.current=0},isUpdatingInteractively:!1,displayUnit:ct(e.valueUnit),axis:e.axis}}function I(e,t){switch(t){case`small-integer`:case`integer`:case`long`:return Math.round(e);case`double`:case`single`:return e;default:return 0}}function L(e){if(!ce(e))return!1;switch(e?.type){case`class-breaks`:case`simple`:case`unique-value`:case`dot-density`:case`dictionary`:case`pie-chart`:return!0;default:return!1}}function R(e,t){if(!e||!t)throw Error(`no geometry type`);if(e===`multipatch`)return{tool:`mesh`,createOptions:{mode:`hybrid`}};let n=new Map;n.set(`circle`,{mode:`freehand`}),n.set(`rectangle`,{mode:`freehand`});let r={mode:he,optionsPerTool:n};if(x(t)){let i=t.defaultTool,a=S(t)?t.definition?.inputGeometryType??e:e;switch(i){case`freehand`:case`stream-line`:return{tool:a===`polyline`?`freehandPolyline`:`freehandPolygon`,createOptions:r};case`autocomplete-freehand-polygons`:case`stream-polygon`:return{tool:`freehandPolygon`,createOptions:r};case`autocomplete-polygons`:case`difference-polygon`:case`create-structures`:case`polygon`:case`trace`:return{tool:a===`polygon`?`polygon`:`polyline`,createOptions:r};case`circle`:return n.get(`circle`).preserveAspectRatio=!0,{tool:`circle`,createOptions:r};case`ellipse`:return n.get(`circle`).preserveAspectRatio=!1,{tool:`circle`,createOptions:r};case`create-points-along-line`:case`multipoint`:return{tool:`multipoint`,createOptions:r};case`line`:case`radial-line`:case`right-angle-line`:case`split`:case`two-point-line`:return{tool:`polyline`,createOptions:r};case`rectangle`:case`regular-polygon`:case`right-angle-polygon`:return{tool:`rectangle`,createOptions:r};case`elevation-point-from-contour`:case`elevation-point-from-dem`:case`parcel-seed`:case`point`:case`point-and-rotation`:case`point-at-end-of-line`:return{tool:`point`,createOptions:r}}}else{let i=t.drawingTool;if(i===`circle`||i===`ellipse`)return n.get(`circle`).preserveAspectRatio=i===`circle`,{tool:`circle`,createOptions:r};if(i===`rectangle`)return{tool:`rectangle`,createOptions:r};if(i===`freehand`)return{tool:e===`polygon`?`freehandPolygon`:`freehandPolyline`,createOptions:r}}return{tool:e,createOptions:r}}async function Le(e,t,n){let{creationInfo:r,fullTemplate:a}=n;if(!r)throw new i(`featureworkflow`,`No creation info provided.`);let o=r.layer,s=ee(a,r.attributeOverrides,r.layer),{view:c}=e,l=c?.type===`2d`;!S(a)&&!C(a)&&await J(e,o,s,l?c.scale:null);let{capabilities:u}=o;t.elevationInfo=o.elevationInfo;let d=R(o.geometryType,a);e.defaultCreateOptions={graphicProperties:{attributes:s,sourceLayer:o},mode:d.createOptions.mode,optionsPerTool:d.createOptions.optionsPerTool,preserveAspectRatio:d.createOptions.preserveAspectRatio,hasZ:u.data.supportsZ,defaultZ:(l?u.editing.zDefault:null)??e.defaultCreateOptions.defaultZ},r.geometryToPlace==null?await e.create(d.tool):await e.place(r.geometryToPlace,{graphicProperties:{attributes:s,sourceLayer:o}})}async function Re(e){return a([ze(e),Be(e)])}function ze({creationAttributes:e,data:t,sketchViewModel:n,view:r}){let{creationInfo:i}=t,{fullTemplate:a}=t;if(!i||r?.type!==`2d`||S(a)||C(a))return null;let o=d(t=>J(n,i.layer,e,t));return g(()=>r.scale,e=>o(e))}function Be({data:t,sketchViewModel:n,view:r}){let{templateExecutorInfo:o}=t;if(!o)return null;let c=n.activeComponent;if(!r||!be(c)&&!xe(c))return Te().error(new i(`featureworkflow`,`Failed to set up template feedback.`)),null;let l=new ne({effect:`saturate(0.6) opacity(0.8)`,listMode:`hide`,title:`Shared Template Feedback Graphics`});r.map?.add(l);let{executor:u,serviceLayersById:d}=o,f=r.theme?.accentColor??new e([255,165,0,1]);return a([_(()=>c,[`cursor-update`,`vertex-add`],()=>{l.removeAll();let e=be(c)?c.graphic?.geometry:c.unprocessedGeometry;if(!e||!Ve(e))return;let t=u(e,`digitizing`);if(!p(t))for(let e of t.edits){let t=d.get(e.id);if(t&&e.addFeatures&&e.addFeatures.length!==0){for(let n of t)if(!n.isTable)for(let t of e.addFeatures){let e=He(t,f);e&&l.add(e)}}}}),s(()=>{r.map.remove(l),l.destroy()})])}function Ve(e){switch(e.type){case`point`:case`multipoint`:return!0;case`polyline`:{if(w(e))return e.curvePaths[0].length>1;let t=e.paths[0];return t?t.length>1:!1}case`polygon`:{if(w(e))return e.curveRings[0].length>2;let t=e.rings[0];return t?r(t.at(0),t.at(-1))?t.length>2:t.length>1:!1}default:return!1}}function He(e,t){let n=null;switch(e.geometry?.type){case`point`:case`multipoint`:n=new fe({angle:0,color:t,outline:new D({cap:`round`,color:t,join:`round`,miterLimit:1,style:`solid`,width:1}),path:`undefined`,size:8,style:`circle`,xoffset:0,yoffset:0});break;case`polygon`:n=new de({color:t,outline:new D({cap:`round`,color:t,join:`round`,miterLimit:1,style:`solid`,width:3}),style:`none`});break;case`polyline`:n=new D({cap:`round`,color:t,join:`round`,miterLimit:1,style:`solid`,width:2});break;default:return null}return new T({geometry:e.geometry,symbol:n,attributes:{...e.attributes}})}function z(e,t){let n=me(t),r=ae(e)?e.parent:e;return n.tablesAndLayersLookup.get(r)}function Ue(e,t){let n=z(e,t);if(!n)return new Map;let r=new Map;for(let e of n.layersAndTables)u(r,e.layerId,()=>[]).push(e);return r}function B(e){let t=e.objectIdField,n=e.globalIdField??``;return{id:e.layerId,identifierFields:{objectIdField:t,globalIdField:n},addFeatures:[],deleteAttachments:[],addAttachments:[],deleteFeatures:[],updateFeatures:[]}}function We(e){let{edits:n,serviceInfo:r,view:i,findOriginalFeature:a}=e,o=V(r.layersAndTables),s=r.layersAndTables.toArray(),{allEditData:c,editDataByLayerIdMap:l,editDataByIdMap:u}=Ge(n,o,a),d=U(c,H(s,l),l);if(i&&K(c,d,i),d.length===0)return n;let f=we(d,{continueOnCircularDependency:!0}).map(e=>u.get(e)).filter(t),p=new Map;for(let e of f)p.set(e.uniqueId,e);let m=[];for(let e of c)p.has(e.uniqueId)||m.push(e);let h=[],g=null;for(let e of f){let{layer:t}=e;switch(g==null?g=B(t):g.id!==t.layerId&&(h.push(g),g=B(t)),e.operationType){case`add`:case`modify`:g.addFeatures.push(e.after);break;case`delete`:g.deleteFeatures.push(e.before)}}g!==null&&h.push(g);for(let e of m){let t=e.layer.layerId,n=h.find(e=>e.id===t)??B(e.layer);switch(h.includes(n)||h.push(n),e.operationType){case`add`:n.addFeatures.push(e.after);break;case`modify`:n.updateFeatures.push(e.after);break;case`delete`:n.deleteFeatures.push(e.before);break;case`deleteAttachment`:n.deleteAttachments.push(e.attachmentId);break;case`addAttachment`:n.addAttachments.push(e.attachment)}}for(let e of h)e.deleteAttachments!==void 0&&e.deleteAttachments.length===0&&delete e.deleteAttachments,e.addAttachments!==void 0&&e.addAttachments.length===0&&delete e.addAttachments;return h}function V(e){let t=new Map;for(let n of e)t.set(n.layerId,n);return t}function H(e,t){let n=new Map;for(let r of e)for(let e of r.relationships??[])if(n.set(W(r,e),``),t.has(e.relatedTableId)){let i=t.get(e.relatedTableId);if(i.length>0){for(let t of i[0].layer.relationships??[])if(t.id===e.id){n.set(W(r,e),t.keyField);break}}}return n}function Ge(e,t,n){let r=new Map,a=[],o=new Map,s=1;for(let c of e){let e=[],l=t.get(c.id);if(!l)throw new i(`featureworkflow`,`Failed to prepare applyEdits payload. Layer with id ${c.id} not found.`);for(let t of c.addFeatures??[])e.push({uniqueId:`T${s++}`,operationType:`add`,layer:l,after:t});for(let t of c.deleteFeatures??[])e.push({uniqueId:`T${s++}`,operationType:`delete`,before:t,layer:l});for(let t of c.deleteAttachments??[])e.push({uniqueId:`T${s++}`,operationType:`deleteAttachment`,attachmentId:t,layer:l});for(let t of c.addAttachments??[])e.push({uniqueId:`T${s++}`,operationType:`addAttachment`,attachment:t,layer:l});for(let t of c.updateFeatures??[])e.push({uniqueId:`T${s++}`,operationType:`modify`,before:n(t),after:t,layer:l});r.set(l.layerId,e);for(let t of e)a.push(t),o.set(t.uniqueId,t)}return{allEditData:a,editDataByIdMap:o,editDataByLayerIdMap:r}}function U(e,t,n){let r=[];for(let i of e){let e=i.layer.relationships??[],{uniqueId:a}=i;for(let o of e){let e=o.keyField;if(o.role===`origin`){let s=n.get(o.relatedTableId);if(!s||s.length===0)continue;let c=W(i.layer,o),l=t.get(c);if(l===void 0||l===``)continue;switch(i.operationType){case`add`:for(let t of s)t!==i&&(t.operationType===`add`||t.operationType===`modify`)&&t.after.attributes[l]===i.after.attributes[e]&&r.push([a,t.uniqueId]);break;case`modify`:if(i.before.attributes[e]!==i.after.attributes[e])for(let t of s){let n=t.uniqueId;t!==i&&(t.operationType===`delete`?t.before.attributes[l]===i.before.attributes[e]?r.push([n,a]):t.before.attributes[l]===i.after.attributes[e]&&r.push([a,n]):t.operationType===`add`?t.after.attributes[l]===i.after.attributes[e]?r.push([a,n]):t.after.attributes[l]===i.before.attributes[e]&&r.push([n,a]):t.operationType===`modify`&&(t.before.attributes[l]===t.after.attributes[l]||t.after.attributes[l]===i.after.attributes[e]?r.push([a,n]):r.push([n,a])))}break;case`delete`:for(let t of s)t!==i&&(t.operationType===`delete`||t.operationType===`modify`)&&t.before.attributes[l]===i.before.attributes[e]&&r.push([t.uniqueId,a])}}}}return r}function W(e,t){return`${e.layerId}:${t.id}`}function G(e,t){return!!(t?.map&&`utilityNetworks`in t.map&&t.map.utilityNetworks?.length&&t.map.utilityNetworks.some(t=>!!(t.loaded&&e.url?.startsWith(t.featureServiceUrl)&&e.layerId===t.networkSystemLayers.associationsTableId)))}function K(e,t,n){let r=[];for(let t of e)G(t.layer,n)&&r.push(t);if(r.length===0)return;let i=[];for(let n of r){let r=n.layer;switch(n.operationType){case`delete`:i=[...q(n.before.attributes[r.fieldsIndex.get(`fromglobalid`).name],e),...q(n.before.attributes[r.fieldsIndex.get(`toglobalid`).name],e)];for(let e of i)t.push([n.uniqueId,e.uniqueId]);break;case`add`:i=[...q(n.after.attributes[r.fieldsIndex.get(`fromglobalid`).name],e),...q(n.after.attributes[r.fieldsIndex.get(`toglobalid`).name],e)];for(let e of i)t.push([e.uniqueId,n.uniqueId])}}}function q(e,t){let n=[],r=t.filter(({layer:e})=>e.globalIdField!==``&&e.globalIdField!=null);for(let t of r){let r=t.layer.globalIdField;(`before`in t&&t.before?.attributes[r]===e||`after`in t&&t.after?.attributes[r]===e)&&n.push(t)}return n}async function J(e,t,n,r){let i=new T({sourceLayer:t,attributes:n}),{rotation:a,size:o}=N(i),s=await O(i,{useSourceLayer:!0,scale:r}),c=!1;for(let t of[o,a])t!=null&&(n[t.field]??(n[t.field]=await t.getDefaultValue(s,e.view),c=!0));switch(c&&(s=await O(i,{useSourceLayer:!0,scale:r})),s?.type){case`simple-fill`:case`polygon-3d`:e.polygonSymbol=s;break;case`simple-line`:case`line-3d`:e.polylineSymbol=s;break;case`simple-marker`:case`picture-marker`:case`point-3d`:case`cim`:e.pointSymbol=s;break;case`mesh-3d`:e.meshSymbol=s}Y(e.tooltipOptions,o,a)}function Y(e,t,n){e.visualVariables=t!=null||n!=null?{size:t==null?null:{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType},rotation:n==null?null:{valueType:n.fieldType,rotationType:n.rotationType??`geographic`}}:null}function Ke(e,t){return e.find(e=>e.layer===t)}function qe(e,t){let n=Ke(e,t);if(n==null)throw new i(`no-editorItem-found`,`The EditorViewModel provided did not have an EditorItem associated with the specified layer`);return n}function Je(e,t){return e?.find(e=>e.layer===t)}async function Ye(e,t,n,r){switch(t.type){case`3d`:return Xe(e,t,n,r);case`2d`:return Ze(e,t,n,r)}}async function Xe(e,t,r,i){if(e.length===0)return[];let{updatable:a,graphicsByLayer:o}=await r.defer(async()=>{let{results:n}=await f(ye(t,r),i),a=new Map,o=e=>{let t=e.layer,n=a.get(t);if(!n){let e=[];return a.set(t,e),e}return n};ve(n).forEach(({graphic:e})=>o(e).push(e));let s=e.filter(({capabilities:e,layer:t})=>e.update.enabled&&a.has(t));return s.length!==0&&r.stopPropagation(),{updatable:s,graphicsByLayer:a}});return f(Promise.allSettled(a.map(async({layer:e})=>{let t=o.get(e),r=Qe(e);if(t.every(e=>re(e,r)))return t;let a=[];for(let e of t){a.push(e.getObjectId());let t=Object.keys(e.attributes);n(r,t)}let s=e.createQuery();return s.returnGeometry=!1,s.objectIds=a,s.outFields=E(e.fieldsIndex,r),e.queryFeatures(s,{signal:i}).then(({features:e})=>e)})),i)}async function Ze(e,t,n,r){if(e.length===0)return[];let{mapPoint:i}=n;if(i==null)return[];let a=null,o=await n.defer(async()=>{let{results:i}=await f(t.hitTest(n),r);if(i.length===0)return[];let o=new Set;a=ve(i),a.forEach(({graphic:e})=>e&&o.add(e.layer));let s=e.filter(e=>o.has(e.layer)&&e.supportsUpdateWorkflow);return s.length>0&&n.stopPropagation(),s});return f(Promise.allSettled(o.map(async({layer:e})=>{let o=e.createQuery();o.returnGeometry=!0,o.outFields=Qe(e);let s=`renderer`in e?oe({renderer:e.renderer,pointerType:n.pointerType}):0;o.geometry=_e(i,s,t),o.outSpatialReference=t.spatialReference;let{features:c}=await e.queryFeatures(o,{signal:r});return a?.forEach(({graphic:t})=>{t.layer===e&&!c.some(e=>e.getObjectId()===t.getObjectId())&&c.push(t)}),c})),r)}function Qe(e){return E(e.fieldsIndex,[e.objectIdField,ie({displayField:`displayField`in e?e.displayField:null,fields:e.fields})])}async function $e(e,n,r,i){let a=e.map(e=>e.getObjectId()??e.attributes[n.objectIdField]).filter(t);return await ge(a,n,r,i)}async function X(e){let{graphic:t,sketchViewModel:n,sourceLayer:r,updateOptions:i,visualVariables:a}=e;await tt(e);let o={multipleSelectionEnabled:!1,...i};return r.geometryType===`point`&&(o.enableRotation=a.rotation!=null,o.enableScaling=a.size!=null),n.update(t,o)}function et(e,t){let{activeUpdateOptions:n}=e;n&&(e.activeUpdateOptions={...n,...t,reshapeOptions:{...n.reshapeOptions,...t.reshapeOptions},highlightOptions:{...n.highlightOptions,...t.highlightOptions}})}async function tt(e){let{graphic:t,sketchLayer:n,sketchViewModel:r,sourceLayer:i,visualVariables:a}=e,o=!1,{rotation:s,size:c}=a;for(let e of[s,c]){if(e==null)continue;let n=t.getAttribute(e.field);if(n!=null)e.setInitialValue(n);else{let n=await e.getDefaultValue(t.symbol,r.view);e.setInitialValue(n),t.setAttribute(e.field,n),o=!0}}if(o){let e=r.view?.type===`2d`?r.view.scale:null;await k(t,e)}Y(r.tooltipOptions,c,s),n.elevationInfo=i.elevationInfo}function nt(e){return e!=null&&(e.type===`rotate-start`||e.type===`rotate`||e.type===`rotate-stop`)?e:null}function rt(e){return e!=null&&(e.type===`scale-start`||e.type===`scale`||e.type===`scale-stop`)?e:null}function it(e,t,n,r){if(t.geometry==null||t.geometry?.type!==`point`)return!1;let i=t.attributes,a=!1,o=r.rotation,s=nt(n.toolEventInfo);if(o!=null&&s!=null){let{field:n,getValue:r}=o;if(s.type===`rotate-stop`)o.isUpdatingInteractively=!1,o.setInitialValue(t.getAttribute(n));else{o.isUpdatingInteractively=!0;let c=r(s.angle,e);c!==i[n]&&t.setAttribute(n,c),a=!0}}let c=r.size,l=rt(n.toolEventInfo);if(c!=null&&l!=null){let{field:n,getValue:r}=c;if(l.type===`scale-stop`)c.isUpdatingInteractively=!1,c.setInitialValue(t.getAttribute(n));else{c.isUpdatingInteractively=!0;let o=r(l.xScale,e);o!==i[n]&&t.setAttribute(n,o),a=!0}}return a}async function at({feature:e,featureClone:t,sketchLayer:n,sketchViewModel:r,getUpdateOptions:i,view:c,visualVariableAttributes:l,addHandle:u,updatingHandles:f,onUpdate:p}){await k(t,c.type===`2d`?c.scale:null);let g=null;if(r?.view?.type===`2d`){let e=d(e=>k(t,e));g=f.add(()=>r?.view?.scale,t=>f.consumePromise(e(t)))}let _=t.sourceLayer,v=ut(c,_);await X({graphic:t,sketchLayer:n,sketchViewModel:r,sourceLayer:_,updateOptions:i(),visualVariables:l});let y=null;v.then(e=>y=e).catch(()=>{});let b=l.size,x=l.rotation,S=f.add(()=>e.attributes,async e=>{let n=!1;for(let r in e){let i=e[r];i!==t.getAttribute(r)&&(t.setAttribute(r,i),b!=null&&!b.isUpdatingInteractively&&b.field===r&&b.setInitialValue(i),x!=null&&!x.isUpdatingInteractively&&x.field===r&&x.setInitialValue(i),(y==null||y.requiredFields.includes(r))&&(n=!0))}n&&await f.addPromise(k(t,c.type===`2d`?c.scale:null))}),ee=r.on(`update`,async e=>{let t=e.graphics[0],a={graphic:t,sketchLayer:n,sketchViewModel:r,sourceLayer:_,updateOptions:i(),visualVariables:l};if(e.state===`complete`){let e=new AbortController;u(o(e)),f.consumePromise(m(()=>c.activeTool===null,e.signal).then(async()=>{if(!e.signal.aborted)return e.abort(),X(a)}))}else it(c,t,e,l)&&await f.addPromise(k(t,c.type===`2d`?c.scale:null)),p(Q(t),e)}),C=h(()=>c.activeTool!=null&&c.activeTool!==r.activeComponent,()=>r.cancel()),w=r.on([`undo`,`redo`],e=>{p(Q(e.graphics[0]),e)});return a([w,ee,C,s(()=>r.cancel()),S,g])}const Z={icon:y(24),text:y(12),line:v,viewScaleSizeFactor:100};function ot(e,t,n){let r=!1;return e.filter(e=>r?!0:(r=e===t,r)).map(e=>n[e]())}function st(e,t){e.viewModel.syncFeatureTemplates();let n=e.creationInfo;if(t[0].id===`awaiting-feature-creation-info`&&n){let r=n.layer,i=e.viewModel.getTemplatesForLayer(r);i.length===1&&r.type!==`scene`&&(n.template=i[0],t.shift())}return t}function ct(e){return e===`unknown`?null:e}const lt=e=>e.includes(`-stop`)||e.includes(`vertex-`),ut=(e,t)=>{let n=t.type===`subtype-sublayer`?t.parent:t;return e.whenLayerView(n)};function dt(e){return`createInteractiveEditSession`in e}function Q(e){let t=e.geometry;if(t?.type===`mesh`){let n=e.cloneShallow();return n.attributes=c(e.attributes),n.geometry=t.cloneShallow(),n.geometry.transform=t.transform?.clone()??null,n}return e.clone()}function ft(e){return e.acquireCursor(`progress`)}function $(e){for(let t of e){let{destinationGraphic:e,destinationField:n,sourceGraphic:r,sourceField:i}=t;e.setAttribute(n,r.getAttribute(i))}}function pt(e){let t=e.templateExecutorInfo?.completionResults;return t?.length?(t.forEach(e=>$(e.relationships)),t.flatMap(e=>e.edits)):null}function mt(e){let t=Se(e)?e.activeWorkflow:e;if(t==null)return[];if(Ce(t))return t.data.layers;let n=t.layer;return n?[n]:[]}function ht({attributes:e},t){let n=new Set;n.add(t.objectIdField),`uniqueIdFields`in t&&t.uniqueIdFields&&t.uniqueIdFields.length>0&&b(n,t.uniqueIdFields);let r={};for(let t of n)e[t]!=null&&(r[t]=e[t]);if(t.type===`scene`&&t.infoFor3D!=null){let n=t.associatedLayer?.globalIdField;n!=null&&(e[n]=e[n])}return r}function gt(e){if(!_t(e))return e;let t=new Map;for(let n of e){let e=n.getObjectId();if(e!=null){let r=n.sourceLayer??n.layer;u(t,r,()=>[]).push(e)}}return Array.from(t.entries()).map(([e,t])=>({layer:e,objectIds:t}))}function _t(e){return e.length===0||ue(e[0])}function vt({drawTool:e},t){let n=e?.mostDownstreamPlugin?.configuration?.curveTypes;if(!t||!n||n.length===0)return!1;let r=new Set(t.capabilities.supportedCurveTypes);return n.some(e=>!r.has(e))}function yt(e,t){let n=new Set(t.capabilities.supportedCurveTypes);return e.some(({geometry:e})=>e&&w(e)&&te(e,n))}function bt({filter:e,forEachFeature:t,forEachValueChange:n}){return r=>{for(let{feature:i,changes:a}of r.data)if(!e||e(i)){for(let{fieldName:e,value:t}of a)n?.(e,t,i);t?.(i,a)}}}export{vt as activeSketchToolDrawsUnsupportedCurve,K as appendAllUtilityNetworkAssociationRelationships,st as avoidFeatureTemplateSelectionWithOnlyOneItem,dt as canCreateInteractiveEditSession,Q as cloneGraphicExceptMesh,yt as containsUnsupportedCurve,V as createLayerIdMap,H as createRelationshipKeyMap,R as createToolFromGeometryType,ot as createWorkflowSteps,Ye as fetchCandidates,$e as fetchFullFeatures,U as findAllDependencies,q as findChangesByGlobalId,Ke as findEditorItemForLayer,qe as findEditorItemForLayerOrThrow,Je as findLayerInfo,W as generateHashForRelationship,mt as getLayersFromWorkflow,P as getRotationVariableAttribute,pt as getServiceEditsFromWorkflowData,z as getServiceInfoForLayer,Ue as getServiceLayersById,F as getSizeVariableAttribute,N as getVisualVariableAttributes,M as getVisualVariablesForLayer,bt as handleFormValuesChangeEvent,Ee as isAnyUpdateLeafWorkflow,De as isBatchAttributeFormViewModel,_t as isGraphicsArray,A as isMergeFeaturesWorkflow,je as isMergeWorkflowOptions,Ae as isParentWorkflow,j as isSplitFeatureWorkflow,Me as isSplitWorkflowOptions,lt as isTerminalUpdateEventType,Oe as isUpdateFeaturesWorkflow,Pe as isUpdateFeaturesWorkflowOptions,ke as isUpdateRecordWorkflow,G as isUtilityNetworkAssociationsTable,ht as makeMinimalAttributes,We as orderEditsByRelationshipDependencies,$ as setRelationshipFields,at as setUpGeometryUpdate,Re as setUpSketchCreateWatchers,tt as setVisualVariablesAndElevationInfoForUpdate,ft as showProgressCursor,Z as sizeDefaults,ct as sizeVariableUnitToLengthUnit,Le as startCreatingNewFeature,X as startUpdatingFeatureGeometry,et as syncUpdateOptions,gt as toFeatureInfos,it as visualVariableInteractiveUpdate,ut as whenEditorLayerView,Ne as workflowInfluencesOutcomeOfParent};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../Color.js";import{property as n,subclass as r}from"../../core/accessorSupport/decorators.js";import{handlesGroup as i}from"../../core/handleUtils.js";import{isIterable as a}from"../../core/iteratorUtils.js";import{set as o}from"../../core/libs/gl-matrix-2/math/vec3.js";import{create as s}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{memoize as c}from"../../core/memoize.js";import{watch as l,on as u}from"../../core/reactiveUtils.js";import{getMetersPerVerticalUnitForSR as d}from"../../core/units.js";import{getReferenceEllipsoid as f}from"../../geometry/ellipsoidUtils.js";import{create as p,fromPoints as m}from"../../geometry/support/ray.js";import{GeometryDescriptor as h}from"../../layers/support/GeometryDescriptor.js";import{externalToInternalIntersectOptions as g}from"../../views/3d/support/hitTest.js";import{Intersector as _}from"../../views/3d/webgl-engine/lib/Intersector.js";import{toGraphic as v}from"../../views/3d/webgl-engine/lib/intersectorUtilsConversions.js";import y from"./ElevationProfileLine.js";let b=class extends y{constructor(e){super(e),this.type=`view`,this.color=new t(`#cf4ccf`),this.viewVisualizationEnabled=!0,this.include=null,this.exclude=null,this.numSamplesForPreview=50,this.numSamplesPerChunk=25,this._getQueryElevationDependencies=c((e,t,n,r,i,a,o)=>({inputGraphicUid:e==null?null:S(e),visibleLayers:t,maxIntersectionDistance:n,intersectOptions:r,view:i,stationary:a,spatialReference:o})),this._vecA=s(),this._vecB=s(),this._ray=p()}get minDemResolution(){let e=this._viewModel?.view;if(e==null||e.type!==`3d`)return null;let t=e.pointsOfInterest?.focus?.worldUnitsPerContentPixel;return t==null?null:t*d(e.spatialReference)}get queryElevationDependencies(){let e=this._view;return e?this._getQueryElevationDependencies(this._viewModel?.input,this._visibleLayers,this._maxIntersectionDistance,this._intersectOptions,e,e.stationary,e.spatialReference):null}get _visibleLayers(){return this._view?.map?.allLayers?.filter(e=>e.visible).toArray()??[]}get _intersectOptions(){let e=this._view;return e==null||e.destroyed?{}:g(e,{include:this.include,exclude:[...this._pointCloudLayers,...a(this.exclude)?this.exclude:this.exclude?[this.exclude]:[]]})}get _pointCloudLayers(){let e=this._view;return e==null?[]:e.allLayerViews.toArray().filter(e=>e.layer?.type===`point-cloud`).map(e=>e.layer)}get _view(){let e=this._viewModel?.view;return e!=null&&e.type===`3d`?e:null}get _maxIntersectionDistance(){let e=this._view;return e==null?1/0:f(e.spatialReference).radius/e.renderCoordsHelper.unitInMeters}get _intersector(){let e=this._view;if(e==null)return null;let t=new _(e.state.viewingMode),n=t.options;return n.hud=!1,n.invisibleTerrain=!1,n.backfacesTerrain=!1,n.selectionMode=!1,n.store=2,t}async queryElevation(e,{noDataValue:t,signal:n}){let r=this.queryElevationDependencies;if(r==null)throw Error(`ElevationProfileLineInput: no dependencies`);let i=this._intersector;if(i==null)throw Error(`ElevationProfileLineInput: no view`);let{intersectOptions:a,view:s,spatialReference:c}=r,l=s.renderCoordsHelper,u=s.sceneIntersectionHelper,d=this._vecA,f=this._vecA,p=this._vecB,g=this._ray;if(!c)return{geometry:e,noDataValue:t};let _=await h.fromGeometry(e).project(c,n);if(!_)return{geometry:e,noDataValue:t};let v=_.coordinates,y=v.length;for(let e=0;e<y;++e){let n=v[e];o(p,n.x,n.y,n.z??0),l.toRenderCoords(p,c,p),l.setAltitude(d,2e5,p);let s=m(d,p,g);u.computeIntersection(s,i,!0,a);let h=x(r,i.results.all);h?(h.getIntersectionPoint(f),l.fromRenderCoords(f,f,c),n.z=f[2]):n.z=t}return{geometry:_.export(),noDataValue:t}}attach(e){let t=()=>this._onChange();return i([super.attach(e),l(()=>this.queryElevationDependencies,t),u(()=>e.elevationProvider,`elevation-change`,t,{onListenerAdd:t,onListenerRemove:t})])}};e([n({type:t,nonNullable:!0})],b.prototype,`color`,void 0),e([n()],b.prototype,`viewVisualizationEnabled`,void 0),e([n()],b.prototype,`include`,void 0),e([n()],b.prototype,`exclude`,void 0),e([n({readOnly:!0})],b.prototype,`minDemResolution`,null),e([n()],b.prototype,`queryElevationDependencies`,null),e([n()],b.prototype,`_visibleLayers`,null),e([n()],b.prototype,`_intersectOptions`,null),e([n()],b.prototype,`_pointCloudLayers`,null),e([n()],b.prototype,`_view`,null),e([n()],b.prototype,`_maxIntersectionDistance`,null),e([n()],b.prototype,`_intersector`,null),b=e([r(`esri.widgets.ElevationProfile.ElevationProfileLineView`)],b);function x({view:e,inputGraphicUid:t,maxIntersectionDistance:n},r){for(let i of r){if(!i.withinDistance(n))continue;let r=v(i,e);if(r==null||S(r)!==t)return i}return null}function S(e){if(e.layer&&`objectIdField`in e.layer){let t=e.attributes[e.layer.objectIdField];if(t)return`o-${e.layer.id}-${t}`}return`u-${e.uid}`}const C=b;export{C as default};
2
+ import{__decorate as e}from"tslib";import t from"../../Color.js";import{property as n,subclass as r}from"../../core/accessorSupport/decorators.js";import{handlesGroup as i}from"../../core/handleUtils.js";import{isIterable as a}from"../../core/iteratorUtils.js";import{set as o}from"../../core/libs/gl-matrix-2/math/vec3.js";import{create as s}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{memoize as c}from"../../core/memoize.js";import{watch as l,on as u}from"../../core/reactiveUtils.js";import{getMetersPerVerticalUnitForSR as d}from"../../core/units.js";import{getReferenceEllipsoid as f}from"../../geometry/ellipsoidUtils.js";import{create as p,fromPoints as m}from"../../geometry/support/ray.js";import{GeometryDescriptor as h}from"../../layers/support/GeometryDescriptor.js";import{externalToInternalIntersectOptions as g}from"../../views/3d/support/hitTest.js";import{Intersector as _}from"../../views/3d/webgl-engine/lib/Intersector.js";import{toGraphic as v}from"../../views/3d/webgl-engine/lib/intersectorUtilsConversions.js";import y from"./ElevationProfileLine.js";let b=class extends y{constructor(e){super(e),this.type=`view`,this.color=new t(`#cf4ccf`),this.viewVisualizationEnabled=!0,this.include=null,this.exclude=null,this.numSamplesForPreview=50,this.numSamplesPerChunk=25,this._getQueryElevationDependencies=c((e,t,n,r,i,a,o)=>({inputGraphicUid:e==null?null:S(e),visibleLayers:t,maxIntersectionDistance:n,intersectOptions:r,view:i,stationary:a,spatialReference:o})),this._vecA=s(),this._vecB=s(),this._ray=p()}get minDemResolution(){let e=this._viewModel?.view;if(e==null||e.type!==`3d`)return null;let t=e.pointsOfInterest?.focus?.worldUnitsPerContentPixel;return t==null?null:t*d(e.spatialReference)}get queryElevationDependencies(){let e=this._view;return e?this._getQueryElevationDependencies(this._viewModel?.input,this._visibleLayers,this._maxIntersectionDistance,this._intersectOptions,e,e.stationary,e.spatialReference):null}get _visibleLayers(){return this._view?.map?.allLayers?.filter(e=>e.visible).toArray()??[]}get _intersectOptions(){let e=this._view;return e==null||e.destroyed?{}:g(e,{include:this.include,exclude:[...this._pointCloudLayers,...a(this.exclude)?this.exclude:this.exclude?[this.exclude]:[]]})}get _pointCloudLayers(){let e=this._view;return e==null?[]:e.allLayerViews.toArray().filter(e=>e.layer?.type===`point-cloud`).map(e=>e.layer)}get _view(){let e=this._viewModel?.view;return e!=null&&e.type===`3d`?e:null}get _maxIntersectionDistance(){let e=this._view;return e==null?1/0:f(e.spatialReference).radius/e.renderCoordsHelper.unitInMeters}get _intersector(){let e=this._view;if(e==null)return null;let t=new _(e.state.isGlobal),n=t.options;return n.hud=!1,n.invisibleTerrain=!1,n.backfacesTerrain=!1,n.selectionMode=!1,n.store=2,t}async queryElevation(e,{noDataValue:t,signal:n}){let r=this.queryElevationDependencies;if(r==null)throw Error(`ElevationProfileLineInput: no dependencies`);let i=this._intersector;if(i==null)throw Error(`ElevationProfileLineInput: no view`);let{intersectOptions:a,view:s,spatialReference:c}=r,l=s.renderCoordsHelper,u=s.sceneIntersectionHelper,d=this._vecA,f=this._vecA,p=this._vecB,g=this._ray;if(!c)return{geometry:e,noDataValue:t};let _=await h.fromGeometry(e).project(c,n);if(!_)return{geometry:e,noDataValue:t};let v=_.coordinates,y=v.length;for(let e=0;e<y;++e){let n=v[e];o(p,n.x,n.y,n.z??0),l.toRenderCoords(p,c,p),l.setAltitude(d,2e5,p);let s=m(d,p,g);u.computeIntersection(s,i,!0,a);let h=x(r,i.results.all);h?(h.getIntersectionPoint(f),l.fromRenderCoords(f,f,c),n.z=f[2]):n.z=t}return{geometry:_.export(),noDataValue:t}}attach(e){let t=()=>this._onChange();return i([super.attach(e),l(()=>this.queryElevationDependencies,t),u(()=>e.elevationProvider,`elevation-change`,t,{onListenerAdd:t,onListenerRemove:t})])}};e([n({type:t,nonNullable:!0})],b.prototype,`color`,void 0),e([n()],b.prototype,`viewVisualizationEnabled`,void 0),e([n()],b.prototype,`include`,void 0),e([n()],b.prototype,`exclude`,void 0),e([n({readOnly:!0})],b.prototype,`minDemResolution`,null),e([n()],b.prototype,`queryElevationDependencies`,null),e([n()],b.prototype,`_visibleLayers`,null),e([n()],b.prototype,`_intersectOptions`,null),e([n()],b.prototype,`_pointCloudLayers`,null),e([n()],b.prototype,`_view`,null),e([n()],b.prototype,`_maxIntersectionDistance`,null),e([n()],b.prototype,`_intersector`,null),b=e([r(`esri.widgets.ElevationProfile.ElevationProfileLineView`)],b);function x({view:e,inputGraphicUid:t,maxIntersectionDistance:n},r){for(let i of r){if(!i.withinDistance(n))continue;let r=v(i,e);if(r==null||S(r)!==t)return i}return null}function S(e){if(e.layer&&`objectIdField`in e.layer){let t=e.attributes[e.layer.objectIdField];if(t)return`o-${e.layer.id}-${t}`}return`u-${e.uid}`}const C=b;export{C as default};