@arcgis/core 6.0.0-next.14 → 6.0.0-next.16

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 (398) hide show
  1. package/analysis/LineOfSightAnalysis.d.ts +49 -32
  2. package/analysis/LineOfSightAnalysisObserver.d.ts +19 -3
  3. package/analysis/LineOfSightAnalysisTarget.d.ts +19 -3
  4. package/analysis/Viewshed.d.ts +23 -3
  5. package/analysis/ViewshedAnalysis.d.ts +33 -13
  6. package/arcade/geometry/operatorsWorkerConnection.js +1 -1
  7. package/assets/esri/core/workers/RemoteClient.js +1 -1
  8. package/assets/esri/core/workers/chunks/00d66e3fba5ab4d2aa3c.js +1 -0
  9. package/assets/esri/core/workers/chunks/{d994bcf0a65d1c07160f.js → 0320cbd825f9a4222042.js} +1 -1
  10. package/assets/esri/core/workers/chunks/08fe248e412bb170210d.js +1 -0
  11. package/assets/esri/core/workers/chunks/{fb444954be74c1962ced.js → 10d80e793019dfb45ca2.js} +1 -1
  12. package/assets/esri/core/workers/chunks/14d5d219e7fe017f23f0.js +1 -0
  13. package/assets/esri/core/workers/chunks/164e74d586297946a717.js +1 -0
  14. package/assets/esri/core/workers/chunks/{1bca39e0e651426bdbb5.js → 1b1d3f6916d2cb751435.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{ed6e9d7f71bfd2691717.js → 1c77de1e79860f8d2228.js} +1 -1
  16. package/assets/esri/core/workers/chunks/1e40a26dcce4d1dadc28.js +1 -0
  17. package/assets/esri/core/workers/chunks/237a1f68a0efbfe5b77c.js +1 -0
  18. package/assets/esri/core/workers/chunks/23c43f09c4a4749516e1.js +1 -0
  19. package/assets/esri/core/workers/chunks/{3418877328f4f0830300.js → 24dac4970526a4e0ae63.js} +1 -1
  20. package/assets/esri/core/workers/chunks/26ceb0ff8d93dbb9b84f.js +1 -0
  21. package/assets/esri/core/workers/chunks/2acf2952cef69e382a35.js +1 -0
  22. package/assets/esri/core/workers/chunks/{481589c3eddad6e026ad.js → 369780276b2755361f7d.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{4df6cb1bee5d0720a43e.js → 36cbd614454581aaf334.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{1e0d2715d603f48a7e0b.js → 370aad23df597db80d65.js} +1 -1
  25. package/assets/esri/core/workers/chunks/3baa4a9c52f41bfd6abb.js +1 -0
  26. package/assets/esri/core/workers/chunks/42d44c7d532df5ee70e9.js +1 -0
  27. package/assets/esri/core/workers/chunks/42e985a576d7aaeed0cf.js +1 -0
  28. package/assets/esri/core/workers/chunks/{6400446b7615b97c3521.js → 45f826554499c38968c6.js} +1 -1
  29. package/assets/esri/core/workers/chunks/48cc58890fddbcf69cef.js +1 -0
  30. package/assets/esri/core/workers/chunks/494bd434fee9032e1d02.js +1 -0
  31. package/assets/esri/core/workers/chunks/{33e4ff228a8c81b99022.js → 4abd3753cd9b80e4d937.js} +1 -1
  32. package/assets/esri/core/workers/chunks/4bbe1f28f5f16a6bef05.js +1 -0
  33. package/assets/esri/core/workers/chunks/4c389472b8cdb0c55154.js +1 -0
  34. package/assets/esri/core/workers/chunks/4e4f747de424941a0bfa.js +1 -0
  35. package/assets/esri/core/workers/chunks/5529831dd891382c79df.js +1 -0
  36. package/assets/esri/core/workers/chunks/5736feefa261589b6273.js +1 -0
  37. package/assets/esri/core/workers/chunks/576248e9ae2654569420.js +1 -0
  38. package/assets/esri/core/workers/chunks/5acb422fe3cf693d9d4f.js +1 -0
  39. package/assets/esri/core/workers/chunks/{aeaaff7a4b1a99540f52.js → 5cb26bbaa08114aec5ce.js} +1 -1
  40. package/assets/esri/core/workers/chunks/661c6324529dd17b297e.js +1 -0
  41. package/assets/esri/core/workers/chunks/68dd1fd2025c7125ead1.js +1 -0
  42. package/assets/esri/core/workers/chunks/{89e76de5ae3328d821a4.js → 69f6d5997b8ff1326e39.js} +1 -1
  43. package/assets/esri/core/workers/chunks/6a8dd8b18b0b825b0c1b.js +1 -0
  44. package/assets/esri/core/workers/chunks/{a40b6d8b5c73e06e14d4.js → 6c255c029d67423e4dac.js} +1 -1
  45. package/assets/esri/core/workers/chunks/7446d0dfebf93e86c098.js +1 -0
  46. package/assets/esri/core/workers/chunks/{688f2dbf784e66082308.js → 74c866e0b66e61751861.js} +1 -1
  47. package/assets/esri/core/workers/chunks/{3ffda5bf0b91700dc308.js → 78643f116677950ea29a.js} +1 -1
  48. package/assets/esri/core/workers/chunks/{916b363c342b61ba5461.js → 787c1a8bda7d745633f2.js} +1 -1
  49. package/assets/esri/core/workers/chunks/7b5f3c79e0605c32b267.js +1 -0
  50. package/assets/esri/core/workers/chunks/7bbfe9ff352afc566367.js +1 -0
  51. package/assets/esri/core/workers/chunks/{ac5a6603f7fa78d3e4c8.js → 7e8611cb709f105946f5.js} +1 -1
  52. package/assets/esri/core/workers/chunks/{05cd33d41d91f8d09633.js → 7fb7493f483cd9878bfa.js} +1 -1
  53. package/assets/esri/core/workers/chunks/{acfa03c65ba3ca6c5685.js → 8715661a838361d4211a.js} +1 -1
  54. package/assets/esri/core/workers/chunks/{601e1d020b8115497944.js → 8a485130781b49dbf608.js} +1 -1
  55. package/assets/esri/core/workers/chunks/{0ccab50877b24f862d6e.js → 8ac2098ecdc40ad41055.js} +1 -1
  56. package/assets/esri/core/workers/chunks/{a655ebdb4bf0660615a2.js → 8b4e9fd88c0c313416d4.js} +1 -1
  57. package/assets/esri/core/workers/chunks/{4e544de61f07ca660236.js → 8c12269d26f5a4c753cb.js} +1 -1
  58. package/assets/esri/core/workers/chunks/8e19629899a5becf8e19.js +1 -0
  59. package/assets/esri/core/workers/chunks/91dd65cf877c8f2e01a7.js +1 -0
  60. package/assets/esri/core/workers/chunks/{46b4fb6a7fe4877b0efc.js → 94baa354e50c03b82b25.js} +2 -2
  61. package/assets/esri/core/workers/chunks/950d4578dc450467404c.js +1 -0
  62. package/assets/esri/core/workers/chunks/{68be3fb88ca61f82fb90.js → 95dbbddac6581b9d671f.js} +1 -1
  63. package/assets/esri/core/workers/chunks/98be2f621801e230aa01.js +1 -0
  64. package/assets/esri/core/workers/chunks/9b051745d24d1f43480b.js +1 -0
  65. package/assets/esri/core/workers/chunks/9d61740ef8bdcc162be1.js +1 -0
  66. package/assets/esri/core/workers/chunks/{eb04e1717a1002cda3ab.js → 9f06ec95bdf0d0b52b41.js} +1 -1
  67. package/assets/esri/core/workers/chunks/{fafb92ca2c5e4b0b2c23.js → a09d2e1e2540921e4717.js} +1 -1
  68. package/assets/esri/core/workers/chunks/{3b3e519f15ed52c83f0c.js → a49fe94933b65b4b64f8.js} +1 -1
  69. package/assets/esri/core/workers/chunks/{1819c45655c836b9a8d7.js → a4d3944700f1cc240176.js} +1 -1
  70. package/assets/esri/core/workers/chunks/{90bdf86f553e2742d67c.js → a7bd5ba4d7d97411fd33.js} +1 -1
  71. package/assets/esri/core/workers/chunks/{900181f68449d8f82eeb.js → aa1ac7954e4f0fefe15b.js} +1 -1
  72. package/assets/esri/core/workers/chunks/ac24b4370dc7194a3107.js +1 -0
  73. package/assets/esri/core/workers/chunks/{b8337492e2b753aefac4.js → ace41659a5ca0e5abfc3.js} +1 -1
  74. package/assets/esri/core/workers/chunks/{3c0ed15b544df6fb0903.js → b48952e1fb4cb7360dd0.js} +1 -1
  75. package/assets/esri/core/workers/chunks/b5e7475cc5fbf31289d3.js +1 -0
  76. package/assets/esri/core/workers/chunks/{f3da30d7300b92bd8bb0.js → befa32b9e7b3fbdd431e.js} +1 -1
  77. package/assets/esri/core/workers/chunks/{0f617980c7dd9ad0444f.js → bf35927979fc5e7e0478.js} +1 -1
  78. package/assets/esri/core/workers/chunks/c4ddac23bd649d24f3f2.js +1 -0
  79. package/assets/esri/core/workers/chunks/{4e6f40cbdb8c508e6df1.js → c5a9e77977e867a75ff2.js} +1 -1
  80. package/assets/esri/core/workers/chunks/{25f19fc929f25ddd628c.js → c79934cd6883307203f8.js} +1 -1
  81. package/assets/esri/core/workers/chunks/cddc3e285f763ccf33c2.js +1 -0
  82. package/assets/esri/core/workers/chunks/d08ff41e2a9bcd58b64a.js +1 -0
  83. package/assets/esri/core/workers/chunks/d311ff96a5a2791d8cfc.js +1 -0
  84. package/assets/esri/core/workers/chunks/d62afb71f4ece4283994.js +1 -0
  85. package/assets/esri/core/workers/chunks/dc1761cba0454fda3cf9.js +1 -0
  86. package/assets/esri/core/workers/chunks/{4ac1d3e49e242e373a92.js → e0650b1408197d3ac862.js} +1 -1
  87. package/assets/esri/core/workers/chunks/{3ff6d1ed3c0f1285f3e7.js → e0d9dc97985561320bd4.js} +1 -1
  88. package/assets/esri/core/workers/chunks/eaddffcc7004101fc230.js +1 -0
  89. package/assets/esri/core/workers/chunks/eb2652ec48faa78de3c5.js +1 -0
  90. package/assets/esri/core/workers/chunks/eca44e53bcee9b08d70a.js +1 -0
  91. package/assets/esri/core/workers/chunks/f00458654c7c34c369ef.js +1 -0
  92. package/assets/esri/core/workers/chunks/f3cd610084e3f4d8656b.js +1 -0
  93. package/assets/esri/core/workers/chunks/f47fe4433b05fca5c3ad.js +1 -0
  94. package/assets/esri/core/workers/chunks/f7bfa3d33b05b250ce33.js +1 -0
  95. package/assets/esri/core/workers/chunks/f91bc1cb1014e05be763.js +1 -0
  96. package/assets/esri/core/workers/chunks/{aadfe34a99c9ec7a0e11.js → f9c5aa0bbf23e780fecc.js} +1 -1
  97. package/assets/esri/core/workers/chunks/f9ff27cfcf0538ac5e26.js +1 -0
  98. package/assets/esri/core/workers/chunks/{19676b2c5f8b0a5ee680.js → facd1ff23203fed67686.js} +1 -1
  99. package/assets/esri/core/workers/chunks/{40a584cb952e94326e9e.js → fcb86d24fc7e0666b564.js} +1 -1
  100. package/assets/esri/libs/pdfjs/wasm/openjpeg_nowasm_fallback.js +1 -0
  101. package/chunks/Distance2DCalculator-DjIp2uQi.js +1 -1
  102. package/chunks/Envelope.js +1 -1
  103. package/chunks/MultiPathImpl.js +1 -1
  104. package/chunks/OperatorGeodeticArea.js +1 -1
  105. package/chunks/OperatorShapePreservingLength.js +1 -1
  106. package/chunks/OperatorShapePreservingProject.js +1 -1
  107. package/chunks/UnitFactory.js +1 -1
  108. package/chunks/basis_encoder.js +1 -1
  109. package/chunks/basis_transcoder.js +1 -1
  110. package/chunks/index.js +1 -1
  111. package/chunks/lclayout.js +1 -1
  112. package/config.d.ts +2 -0
  113. package/config.js +1 -1
  114. package/core/ObjectPool.js +1 -1
  115. package/core/PooledArray.js +1 -1
  116. package/core/accessorSupport/DefaultsStore.js +1 -1
  117. package/core/accessorSupport/MultiOriginStore.js +1 -1
  118. package/core/accessorSupport/Store.js +1 -1
  119. package/core/accessorSupport/decorators/reader.js +1 -1
  120. package/core/accessorSupport/decorators/writer.js +1 -1
  121. package/core/accessorSupport/tracking/SimpleTrackingTarget.js +1 -1
  122. package/core/workers/WorkerOwner.js +1 -1
  123. package/core/workers/workerFactory.js +1 -1
  124. package/core/workers/workers.js +2 -2
  125. package/core/workers.d.ts +9 -0
  126. package/form/elements/inputs/DynamicChoiceInput.d.ts +4 -2
  127. package/geometry/Mesh.js +1 -1
  128. package/geometry/operators/gx/operatorAlphaShape.js +1 -1
  129. package/geometry/operators/gx/operatorOffset.js +1 -1
  130. package/geometry/operators/gx/operatorPolygonSlicer.js +1 -1
  131. package/geometry/operators/support/jsonConverter.js +1 -1
  132. package/geometry/support/buffer/BufferPool.js +1 -1
  133. package/geometry/support/coordsUtils.js +1 -1
  134. package/geometry/support/curves/bezierCurveUtils.js +1 -1
  135. package/geometry/support/curves/ellipticArc7Utils.js +1 -1
  136. package/geometry/support/meshUtils/merge.js +1 -1
  137. package/geometry/support/meshUtils/rotate.js +1 -1
  138. package/geometry/support/meshUtils.d.ts +5 -6
  139. package/geometry/support/polygonExtentClipping.js +1 -1
  140. package/identity/Credential.js +1 -1
  141. package/interfaces.d.ts +18 -9
  142. package/kernel.js +1 -1
  143. package/layers/AnnotationFeatureLayer.d.ts +2 -2
  144. package/layers/AnnotationFeatureLayer.js +1 -1
  145. package/layers/CatalogLayer.d.ts +2 -2
  146. package/layers/CatalogLayer.js +1 -1
  147. package/layers/DimensionFeatureLayer.d.ts +2 -2
  148. package/layers/DimensionFeatureLayer.js +1 -1
  149. package/layers/FeatureLayer.d.ts +4 -4
  150. package/layers/FeatureLayer.js +1 -1
  151. package/layers/GeospatialPDFLayer.d.ts +154 -4
  152. package/layers/ImageryTileLayer.js +1 -1
  153. package/layers/Layer.d.ts +2 -0
  154. package/layers/LineOfSightLayer.d.ts +10 -8
  155. package/layers/SceneLayer.js +1 -1
  156. package/layers/SubtypeGroupLayer.d.ts +2 -2
  157. package/layers/SubtypeGroupLayer.js +1 -1
  158. package/layers/ViewshedLayer.d.ts +1 -1
  159. package/layers/VoxelLayer.js +1 -1
  160. package/layers/WMSLayer.js +1 -1
  161. package/layers/geospatialPDF/GeospatialPDFFrame.js +1 -1
  162. package/layers/geospatialPDF/GeospatialPDFLayerWorker.js +9 -9
  163. package/layers/geospatialPDF/GeospatialPDFWorkerClient.js +1 -1
  164. package/layers/geospatialPDF/LGIDictMapFrame.js +1 -1
  165. package/layers/geospatialPDF/ViewportMeasureFrame.js +1 -1
  166. package/layers/geospatialPDF/geospatialPDFParserUtils.js +1 -1
  167. package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
  168. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  169. package/layers/graphics/data/QueryEngineResult.js +1 -1
  170. package/layers/graphics/sources/connections/WebSocketConnection.js +1 -1
  171. package/layers/graphics/sources/parquet/FileProvider.js +1 -1
  172. package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
  173. package/layers/mixins/{FeatureLayerReload.d.ts → ReloadableLayer.d.ts} +5 -3
  174. package/layers/mixins/ReloadableLayer.js +2 -0
  175. package/layers/raster/datasets/BaseRaster.js +1 -1
  176. package/layers/raster/datasets/GeospatialPDFRaster.js +1 -1
  177. package/layers/raster/datasets/ImageAuxRaster.js +2 -2
  178. package/layers/raster/datasets/ImageServerRaster.js +1 -1
  179. package/layers/raster/datasets/InMemoryRaster.js +1 -1
  180. package/layers/raster/datasets/MRFRaster.js +1 -1
  181. package/layers/raster/datasets/TIFFRaster.js +1 -1
  182. package/layers/raster/datasets/WCSRaster.js +1 -1
  183. package/layers/raster/formats/ImageCanvasDecoder.js +1 -1
  184. package/layers/raster/formats/RasterCodec.js +1 -1
  185. package/layers/raster/formats/TiffDecoder.js +1 -1
  186. package/layers/raster/formats/Zlib.js +1 -1
  187. package/layers/raster/functions/stretchUtils.js +1 -1
  188. package/layers/raster/functions/vectorFieldUtils.js +1 -1
  189. package/layers/support/FieldsIndex.js +1 -1
  190. package/layers/support/LabelClass.d.ts +3 -2
  191. package/layers/support/PortalItemData.d.ts +31 -8
  192. package/layers/support/RasterWorker.js +1 -1
  193. package/layers/support/featureReductionProperties.js +1 -1
  194. package/layers/support/kmlUtils.js +1 -1
  195. package/layers/support/types.d.ts +4 -1
  196. package/layers/video/VideoController.js +10 -10
  197. package/libs/maquette/projection.js +1 -1
  198. package/networks/UtilityNetworkTraceAnalysis.js +1 -1
  199. package/package.json +5 -5
  200. package/popup/FeatureModel.js +1 -1
  201. package/popup/FeaturesModel.js +1 -1
  202. package/portal/Portal.js +1 -1
  203. package/request/process.js +1 -1
  204. package/request/types.d.ts +7 -0
  205. package/rest/knowledgeGraph/ObjectValue.js +1 -1
  206. package/rest/knowledgeGraphService.js +1 -1
  207. package/rest/networks/trace.js +1 -1
  208. package/rest/query/executeQuery.js +1 -1
  209. package/smartMapping/raster/renderers/shadedRelief.js +1 -1
  210. package/smartMapping/renderers/univariateColorSize.js +1 -1
  211. package/smartMapping/statistics/support/statsWorker.js +1 -1
  212. package/smartMapping/statistics/support/utils.js +1 -1
  213. package/smartMapping/support/clusterUtils.js +1 -1
  214. package/statistics/utils.js +1 -1
  215. package/symbols/cim/CIMCursor.js +1 -1
  216. package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
  217. package/symbols/cim/cimAnalyzer.js +1 -1
  218. package/symbols/support/ElevationInfo.d.ts +4 -3
  219. package/undoredo/support/Services.js +1 -1
  220. package/views/2d/engine/vectorTiles/buckets/SymbolBucket.js +2 -2
  221. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
  222. package/views/2d/grid/GridView2D.js +1 -1
  223. package/views/2d/layers/FeatureLikeLayerView2D.js +1 -1
  224. package/views/2d/layers/features/sources/strategies/FeatureHybridTileLoadStrategy.js +1 -1
  225. package/views/2d/layers/features/sources/strategies/FeaturePagedTileLoadStrategy.js +1 -1
  226. package/views/2d/layers/features/sources/strategies/FeatureSnapshotLoadStrategy.js +1 -1
  227. package/views/2d/viewpointUtils.js +1 -1
  228. package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
  229. package/views/3d/analysis/DirectLineMeasurementAnalysisView3D.js +1 -1
  230. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  231. package/views/3d/analysis/LineOfSight/LineOfSightItemTool.js +1 -1
  232. package/views/3d/analysis/LineOfSight/LineOfSightPlacementController.js +1 -1
  233. package/views/3d/analysis/LineOfSight/{LineOfSightRootPlugin.js → LineOfSightPlacementRootPlugin.js} +1 -1
  234. package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
  235. package/views/3d/analysis/LineOfSight/types.d.ts +14 -3
  236. package/views/3d/analysis/LineOfSightAnalysisView3D.d.ts +39 -13
  237. package/views/3d/analysis/Viewshed/ViewshedEditTool.js +1 -1
  238. package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
  239. package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
  240. package/views/3d/analysis/Viewshed/types.d.ts +7 -0
  241. package/views/3d/analysis/ViewshedAnalysisView3D.d.ts +43 -15
  242. package/views/3d/input/handlers/KeyboardNavigation.js +1 -1
  243. package/views/3d/interactive/editingTools/ManipulatedObject3DGraphic.js +1 -1
  244. package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
  245. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  246. package/views/3d/interactive/editingTools/transform/ExtentTransformTool.js +1 -1
  247. package/views/3d/interactive/editingTools/transform/ScaleRotateTransform.js +1 -1
  248. package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
  249. package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
  250. package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
  251. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  252. package/views/3d/layers/graphics/Graphics3DElevationAlignment.js +1 -1
  253. package/views/3d/layers/graphics/Graphics3DGraphic.js +1 -1
  254. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  255. package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
  256. package/views/3d/layers/graphics/SpatialIndex2D.js +1 -1
  257. package/views/3d/layers/i3s/I3SNode.js +1 -1
  258. package/views/3d/layers/i3s/I3SUtil.js +1 -1
  259. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  260. package/views/3d/layers/i3s/LayerElevationProvider.js +1 -1
  261. package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
  262. package/views/3d/layers/support/FeatureTileFetcher3DDebugger.js +1 -1
  263. package/views/3d/layers/support/ImageHighlightHelper3D.js +1 -1
  264. package/views/3d/layers/support/StageLayerElevationProvider.js +1 -1
  265. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  266. package/views/3d/support/MemoryController.js +1 -1
  267. package/views/3d/support/elevationUpdateExtentUtils.js +1 -1
  268. package/views/3d/support/elevationUpdateUtils.js +1 -1
  269. package/views/3d/support/pointsOfInterest/Focus.js +1 -1
  270. package/views/3d/support/sphereExtentUtils.js +2 -0
  271. package/views/3d/terrain/OverlayFramebufferObject.js +1 -1
  272. package/views/3d/terrain/OverlayRenderer.js +1 -1
  273. package/views/3d/terrain/PatchRenderData.js +1 -1
  274. package/views/3d/terrain/TerrainData.js +1 -1
  275. package/views/3d/terrain/terrainUtils.js +1 -1
  276. package/views/3d/webgl-engine/effects/RenderPluginManager.js +1 -1
  277. package/views/3d/webgl-engine/effects/geometry/RenderOccluded.js +1 -1
  278. package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
  279. package/views/3d/webgl-engine/lib/ManagedTexture.js +1 -1
  280. package/views/3d/webgl-engine/lib/PathBuilder.js +1 -1
  281. package/views/3d/webgl-engine/lib/PathCapBuilder.js +1 -1
  282. package/views/3d/webgl-engine/lib/PathEvaluator.js +1 -1
  283. package/views/3d/webgl-engine/lib/PathExtruder.js +1 -1
  284. package/views/3d/webgl-engine/lib/PathProfile.js +1 -1
  285. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  286. package/views/3d/webgl-engine/lib/ViewshedShadowMap.js +1 -1
  287. package/views/3d/webgl-engine/lib/pathGeometryUtils.js +1 -1
  288. package/views/3d/webgl-engine/materials/internal/MaterialUtil.js +1 -1
  289. package/views/3d/webgl-engine/materials/renderers/PerBufferData.js +1 -1
  290. package/views/SceneView.js +1 -1
  291. package/views/ToolViewManager.js +1 -1
  292. package/views/draw/DrawOperation.js +1 -1
  293. package/views/draw/support/InteractiveHandle.js +1 -1
  294. package/views/draw/support/Reshape.js +1 -1
  295. package/views/draw/support/createUtils.js +1 -1
  296. package/views/draw/support/editingSessionUtils.js +1 -1
  297. package/views/draw/support/managers/InteractiveHandleManager.js +1 -1
  298. package/views/interactive/SegmentLabels.js +1 -1
  299. package/views/interactive/editGeometry/EditGeometry.js +1 -1
  300. package/views/interactive/editGeometry/EditGeometryOperations.js +1 -1
  301. package/views/interactive/editGeometry/operations/SetAllVertexPositions.js +1 -1
  302. package/views/interactive/editGeometry/operations/UndoGroup.js +1 -1
  303. package/views/interactive/options/TooltipOptions.d.ts +2 -0
  304. package/views/interactive/sketch/SketchTooltipOptions.d.ts +2 -0
  305. package/views/interactive/sketch/constraintUtils.js +1 -1
  306. package/views/interactive/snapping/SnappingDragPipelineStep.js +1 -1
  307. package/views/interactive/tooltip/components/TooltipEditableField.js +1 -1
  308. package/views/layers/LayerView.js +1 -1
  309. package/views/layers/LineOfSightLayerView.d.ts +35 -13
  310. package/views/layers/SketchLayerView.d.ts +1 -0
  311. package/views/layers/ViewshedLayerView.d.ts +36 -12
  312. package/views/webgl/Program.js +1 -1
  313. package/views/webgl/Texture.js +1 -1
  314. package/widgets/BasemapToggle/BasemapToggleViewModel.js +1 -1
  315. package/widgets/BatchAttributeForm/inputs/support/DynamicChoiceController.js +1 -1
  316. package/widgets/BatchAttributeForm.js +1 -1
  317. package/widgets/Directions.js +1 -1
  318. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  319. package/widgets/Editor/EditorViewModel.d.ts +10 -1
  320. package/widgets/Editor/legacy/CreateFeaturesWorkflow.js +1 -1
  321. package/widgets/Editor.d.ts +10 -1
  322. package/widgets/ElevationProfile/support/chartUtils.js +1 -1
  323. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  324. package/widgets/FeatureTable/support/FeatureStore.js +1 -1
  325. package/widgets/FeatureTable/support/GroupColumnTemplate.js +1 -1
  326. package/widgets/FeatureTable/support/TableTemplate.js +1 -1
  327. package/widgets/HistogramRangeSlider.d.ts +2 -2
  328. package/widgets/HistogramRangeSlider.js +1 -1
  329. package/widgets/Legend.d.ts +1 -0
  330. package/widgets/Print.js +1 -1
  331. package/widgets/ScaleRangeSlider/ScaleRangeSliderViewModel.d.ts +5 -2
  332. package/widgets/ScaleRangeSlider/ScaleRangeSliderViewModel.js +1 -1
  333. package/widgets/ScaleRangeSlider.js +1 -1
  334. package/widgets/Slice.js +1 -1
  335. package/widgets/UtilityNetworkTraceAnalysis/UtilityNetworkTraceAnalysisViewModel.js +1 -1
  336. package/widgets/ValuePicker/ValuePickerBaseComponent.d.ts +5 -1
  337. package/widgets/ValuePicker/ValuePickerCollection.d.ts +2 -0
  338. package/widgets/ValuePicker/ValuePickerCombobox.d.ts +7 -1
  339. package/widgets/ValuePicker/ValuePickerLabel.d.ts +7 -1
  340. package/widgets/ValuePicker/ValuePickerSlider.d.ts +2 -0
  341. package/widgets/ValuePicker/ValuePickerSliderVisibleElements.d.ts +5 -1
  342. package/widgets/ValuePicker/ValuePickerVisibleElements.d.ts +5 -1
  343. package/widgets/ValuePicker/types.d.ts +2 -0
  344. package/widgets/support/SelectionList/SelectionListViewModel.js +1 -1
  345. package/widgets/support/SelectionList.js +1 -1
  346. package/widgets/support/componentsUtils.js +1 -1
  347. package/assets/esri/core/workers/chunks/024b44c0c8876627f904.js +0 -1
  348. package/assets/esri/core/workers/chunks/02c5d027bdaee67869cf.js +0 -1
  349. package/assets/esri/core/workers/chunks/03261b9451e293a0fac8.js +0 -1
  350. package/assets/esri/core/workers/chunks/037a8cc19debbaaa4e10.js +0 -1
  351. package/assets/esri/core/workers/chunks/0c8c01097847617261b9.js +0 -1
  352. package/assets/esri/core/workers/chunks/0d931c7579b6409a696d.js +0 -1
  353. package/assets/esri/core/workers/chunks/12c154342fff876f2f1e.js +0 -1
  354. package/assets/esri/core/workers/chunks/1c65ab9ed611c322ce27.js +0 -1
  355. package/assets/esri/core/workers/chunks/1e11d2e97d17685b878a.js +0 -1
  356. package/assets/esri/core/workers/chunks/1f339247b68b061ab0a4.js +0 -1
  357. package/assets/esri/core/workers/chunks/21ddb26526bcb2b122c3.js +0 -1
  358. package/assets/esri/core/workers/chunks/22e8c0aad2fe75943865.js +0 -1
  359. package/assets/esri/core/workers/chunks/2eae542fe7f0f6576ac1.js +0 -1
  360. package/assets/esri/core/workers/chunks/408e81c8f1eff8a7b379.js +0 -1
  361. package/assets/esri/core/workers/chunks/444e5f214abce3d607cd.js +0 -1
  362. package/assets/esri/core/workers/chunks/46a7da93a63663878583.js +0 -1
  363. package/assets/esri/core/workers/chunks/4a1e23e021bac37a88ab.js +0 -1
  364. package/assets/esri/core/workers/chunks/4c4117e28ea358a32088.js +0 -1
  365. package/assets/esri/core/workers/chunks/54b18559280a7d2a8d93.js +0 -1
  366. package/assets/esri/core/workers/chunks/59b216b60464611742d4.js +0 -1
  367. package/assets/esri/core/workers/chunks/5bfea0c55aca826de536.js +0 -1
  368. package/assets/esri/core/workers/chunks/62ac588f7dd1d24d0c9d.js +0 -1
  369. package/assets/esri/core/workers/chunks/62c8c9ad09e0166207fd.js +0 -1
  370. package/assets/esri/core/workers/chunks/62d6e101e9bd9557a410.js +0 -1
  371. package/assets/esri/core/workers/chunks/6558488ea96620439f34.js +0 -1
  372. package/assets/esri/core/workers/chunks/665e31c494d2af505acc.js +0 -1
  373. package/assets/esri/core/workers/chunks/6f4e6022a52de0c54aab.js +0 -1
  374. package/assets/esri/core/workers/chunks/7267b17de212207142c9.js +0 -1
  375. package/assets/esri/core/workers/chunks/7ef182e24cad50815b4e.js +0 -1
  376. package/assets/esri/core/workers/chunks/8293600f94553afc8c38.js +0 -1
  377. package/assets/esri/core/workers/chunks/8431ca60ad33d594e323.js +0 -1
  378. package/assets/esri/core/workers/chunks/876f7633c15f1e31078d.js +0 -1
  379. package/assets/esri/core/workers/chunks/8ca9648eacb894283513.js +0 -1
  380. package/assets/esri/core/workers/chunks/91ebb2ccab1889eb7e81.js +0 -1
  381. package/assets/esri/core/workers/chunks/9ce91a909eccc4dfe388.js +0 -1
  382. package/assets/esri/core/workers/chunks/9e1a3b6a08c96dcefdde.js +0 -1
  383. package/assets/esri/core/workers/chunks/9e3e442a9874ed23a043.js +0 -1
  384. package/assets/esri/core/workers/chunks/ad76f7ab2f3e6d5a5b3c.js +0 -1
  385. package/assets/esri/core/workers/chunks/aff32980d91dab07dfb7.js +0 -1
  386. package/assets/esri/core/workers/chunks/bbf993dba74850bbf9d7.js +0 -1
  387. package/assets/esri/core/workers/chunks/d8f1cefcad02d7353d4b.js +0 -1
  388. package/assets/esri/core/workers/chunks/d938987344bce83cc660.js +0 -1
  389. package/assets/esri/core/workers/chunks/ddf0671976648f621269.js +0 -1
  390. package/assets/esri/core/workers/chunks/de02f60258e6985ef676.js +0 -1
  391. package/assets/esri/core/workers/chunks/e10b57aefcc89671116e.js +0 -1
  392. package/assets/esri/core/workers/chunks/e65dfa19f030ec298437.js +0 -1
  393. package/assets/esri/core/workers/chunks/f122c18af10e56f9ec2b.js +0 -1
  394. package/assets/esri/core/workers/chunks/f92364afaefbac7e8f77.js +0 -1
  395. package/assets/esri/core/workers/chunks/fd9663952d5a94f3a83f.js +0 -1
  396. package/assets/esri/core/workers/chunks/fe9879ecd69ac4329291.js +0 -1
  397. package/layers/mixins/FeatureLayerReload.js +0 -2
  398. /package/views/3d/analysis/LineOfSight/{lineOfSightPlacementUtils.js → placementUtils.js} +0 -0
@@ -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"../../Graphic.js";import n from"../../core/Collection.js";import r from"../../core/Error.js";import{makeHandle as i,handlesGroup as a,abortHandle as o}from"../../core/handleUtils.js";import"../../core/has.js";import s from"../../core/Logger.js";import{removeMaybe as c,destroyMaybe as l}from"../../core/maybe.js";import{isPromiseLike as u,debounce as d}from"../../core/promiseUtils.js";import{whenOnce as f,watch as p,initial as m,sync as h,syncAndInitial as g}from"../../core/reactiveUtils.js";import{generateBracedUUID as _}from"../../core/uuid.js";import{property as v,subclass as y}from"../../core/accessorSupport/decorators.js";import{isSharedTemplateOrMetadata as b,isSharedTemplate as x,getCreationAttributes as S,isStandardFeatureTemplate as C}from"../../editing/templateUtils.js";import{getFullTemplate as w}from"../../editing/sharedTemplates/templateLoader.js";import T from"../../layers/GraphicsLayer.js";import{isSceneLayer as E,isTable as D}from"../../layers/support/layerUtils.js";import{isNumber as ee}from"../../support/guards.js";import{getDisplayedSymbol as O}from"../../symbols/support/symbolUtils.js";import{updateGraphicSymbolWhenRequired as k}from"../../views/draw/support/editingSessionUtils.js";import{getDrawHelpMessage as A}from"../../views/draw/support/helpMessageUtils.js";import j from"../../views/draw/support/HighlightHelper.js";import M from"../../views/interactive/sketch/SketchOptions.js";import te from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as ne}from"../../views/support/HighlightDefaults.js";import re from"../BatchAttributeForm/BatchAttributeFormViewModel.js";import ie from"./CreateFeaturesWorkflowData.js";import{isModelUpload as N,handleModelUpload as ae}from"./modelUploadUtils.js";import P from"./Workflow.js";import{activeSketchToolDrawsUnsupportedCurve as F,createToolFromGeometryType as I,containsUnsupportedCurve as L,findEditorItemForLayer as R,getServiceEditsFromWorkflowData as z,getServiceInfoForLayer as B,orderEditsByRelationshipDependencies as V,getServiceLayersById as H,startCreatingNewFeature as U,syncUpdateOptions as W,findLayerInfo as G,handleFormValuesChangeEvent as K,isTerminalUpdateEventType as q,getVisualVariableAttributes as J,startUpdatingFeatureGeometry as oe,createWorkflowSteps as se,avoidFeatureTemplateSelectionWithOnlyOneItem as ce,setUpSketchCreateWatchers as le,setRelationshipFields as ue,showProgressCursor as de,setVisualVariablesAndElevationInfoForUpdate as fe,visualVariableInteractiveUpdate as pe}from"./workflowUtils.js";import{makeServiceEditsWithAttachments as me,makeEditsWithAttachments as he,parseEditResultsAndCollectAddAttachmentData as ge}from"./support/attachmentUtils.js";import _e from"../Sketch/SketchViewModel.js";var Y;const ve=Symbol(),X=Symbol(),Z=Symbol(),Q=Symbol(),ye={point:[`point`],multipoint:[`multipoint`],polygon:[`polygon`,`freehandPolygon`,`rectangle`,`circle`],polyline:[`polyline`,`freehandPolyline`],mesh:[],multipatch:[]};let $=Y=class extends P{constructor(e){super(e),this.type=`create-features`,this.createFeatureState=`create-new`,this.data=void 0,this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._formViewModel=new re({attachmentsEnabled:!0}),this._sketchLayer=null,this._sketchViewModel=null,this._isActive=!0}initialize(){this.isNested&&(this._isActive=!1),this._initializeSketchViewModel()}destroy(){this._sketchViewModel.destroy()}get allowSave(){return!this.updating}get curveResizeDisabled(){return this.data.curveResizeDisabled}get curveUpdatesDisabled(){return this.data.curveUpdatesDisabled}get formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return!!this.data.editorItem?.hasInvalidFormTemplate}get hasPendingEdits(){if(this.pendingFeatures.some(e=>!!this.data.getEditsForPendingFeature(e)?.modified))return!0;let{creationInfo:e,upload:t}=this.data,{activeComponent:n,createGraphic:r}=this._sketchViewModel,i=r?.geometry?.type;return!!((i===`polyline`||i===`polygon`||i===`multipoint`)&&(n?.type===`draw-2d`||n?.type===`draw-3d`)&&n.drawOperation.committedVertices.length>0||t&&(t.state===`pending`||t.state===`success`)||e?.geometryToPlace)}get hasPreviousStep(){return this.formViewModel.canGoBack||this._stepIndex>0||this.createFeatureState===`update-pending`&&!!this.data.selectedPendingFeature&&!this.parent&&!N(this.data.creationInfo)}get helpMessage(){let{creationInfo:e,viewModel:t}=this.data;if(this.stepId!==`creating-features`||!e)return;let{_sketchViewModel:n}=this,{drawTool:r,isUsingLegacyCreateTools:i}=n;if(!i)return r?.helpMessageKey??`noTool`;let a=e.layer.geometryType,o=n.createGraphic;if(a===`mesh`){this._getDrawMeshHelpMessage||import(`../../views/draw/support/helpMessageUtils3d.js`).then(e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage});let{view:e}=t;return e?.type===`3d`?this._getDrawMeshHelpMessage?.(o,e):void 0}let{activeCreateToolDrawMode:s,activeTool:c}=n;return A(c===`rectangle`||c===`circle`?c:a,o?.geometry,s)}get noticeMessage(){if(F(this._sketchViewModel,this.data.editorItem))return`curveToolDensifyWarning`}get layer(){return this.data.creationInfo?.layer}get numPendingFeatures(){return this.pendingFeatures.length}get numPendingFeaturesExcludingHidden(){return this.pendingFeatures.filter(e=>this.data.isDisplayable(e)).length}get parent(){return this.data.parent}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return this.numPendingFeatures===0}get reliesOnOwnerAdminPrivileges(){return this.data.editorItem?.capabilities.create.reliesOnOwnerAdminPrivileges??!1}get saveActionLabel(){return`create`}get shouldShowAttachments(){return(this.data.selectedPendingFeature&&this.data.editorItem?.capabilities.create.attachments.enabled)??!1}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get sketchUpdateOptions(){let{editorItem:e}=this.data;return{enableScaling:!this.curveResizeDisabled,multipleSelectionEnabled:!1,reshapeOptions:{enableCreateCurveFromStraightEdge:!E(e?.layer)&&!!e?.capabilities.supportsTrueCurve}}}get sketchViewModel(){return this._sketchViewModel}get test(){}get availableCreateTools(){let e=this.data.creationInfo?.layer.geometryType,t=this.data.viewModel.view;if(!e||this.data.creationInfo?.maxFeatures&&this.data.creationInfo.maxFeatures<=this.numPendingFeatures)return[];if(b(this.data.fullTemplate)){let{tool:t}=I(e,this.data.fullTemplate);return[t]}return t?.type!==`2d`&&e===`multipoint`?[]:[...ye[e]]}getUpdating(){return!!this._sketchViewModel?.updating}async enter(){this._isActive=!0,this.stepId!==`awaiting-feature-creation-info`&&await this._updatingHandles.addPromise(this._setUpCreatingFeaturesStep())}exit(){this._isActive=!1,this.removeHandles([Z])}async updatePendingFeature(e){if(e!==this.data.selectedPendingFeature)return this._sketchViewModel.cancel(),this._startUpdating({feature:e})}async start(){return await super.start(),D(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}async save(e){let{formViewModel:t}=this;if(t.pendingSubtypeChoice)return;await t.submit(),this._stashValidationState();let n=this.data.selectedPendingFeature,r=this._hasValidationErrors(n)?n:this.data.pendingFeatures.find(e=>this._hasValidationErrors(e));if(r){await this._startUpdating({feature:r}),await t?.submit();return}let{pendingFeatures:i,editorItem:a}=this.data;return a&&e&&L(i.toArray(),a)&&!await e(`curveEditingDensifyPrompt`)?this.reset():super.save()}back(e){return this._formViewModel.canGoBack?this._formViewModel.goBack():this.createFeatureState===`update-pending`&&this.data.selectedPendingFeature&&!N(this.data.creationInfo)&&!this.parent?this._clearSelectedFeature():super.back(e)}previous(e){return this._formViewModel.canGoBack?this._formViewModel.goBack():this.createFeatureState===`update-pending`&&this.data.selectedPendingFeature&&!N(this.data.creationInfo)?this._clearSelectedFeature():super.previous(e)}cancelFeature(e){this.data.isSharedTemplateWorkflow?s.getLogger(this).warn(`Cannot cancel individual features created by shared templates.`):(this.data.removePendingFeature(e),this.sketchViewModel.removeGraphic(e))}static create(e){let{applyEdits:t,applyEditsFeatureService:n,addAttachmentsCallback:r,isNested:i,creationInfo:a,parent:o,snappingManager:s,startAt:c,viewModel:l}=e,u=e.sketchOptions??new M,d=a?.layer,f=d?R(l.editorItems,d):void 0,p=new Y({data:new ie({creationInfo:a,editorItem:f,parent:o,sketchOptions:u,snappingManager:s,viewModel:l}),isNested:i,onCommit:async e=>{let{creationInfo:i}=e;if(!i)return;p._sketchViewModel.cancel();let a=e.pendingFeatures.toArray(),{layer:o}=i,s=o.capabilities?.editing.supportsGlobalId&&`globalIdField`in o,{fullTemplate:c}=e,u=z(p.data),d=x(c)&&u;if(s){if(Se(a),d){let t=me(u,e),r=await B(o,l.view)?.load();r&&(t=V({edits:t,serviceInfo:r,view:l.view,findOriginalFeature:t=>e.getEditsForPendingFeature(t)?.initialFeature??t})),await n(c.featureService,t,{globalIdUsed:!0,honorSequenceOfEdits:!0,gdbVersion:c.layer.gdbVersion??void 0})}else await t(o,he(a,e),{globalIdUsed:!0});return}let f=d?await n(c.featureService,u,{gdbVersion:c.layer.gdbVersion??void 0}):[await t(o,{addFeatures:a})];f?.length&&e.attachmentsModified&&!s&&await Promise.all(f.map(t=>{if(!t?.addFeatureResults)return;let n=ge(a,t.addFeatureResults,o,e);return r(o,n)}))}});return p._set(`steps`,this._createWorkflowSteps(p,c)),p}_fadeExistingFeatures(e){if(`effect`in e){let t=e.effect;return e.effect=`saturate(0.6) opacity(0.8)`,i(()=>e.effect=t)}let t=e.opacity;return e.opacity=.7,i(()=>e.opacity=t)}async _initializeFullTemplateAndExecutorInfo(e){let{creationInfo:t}=e,{view:n}=e.viewModel;if(!t||!n)return null;let r=await w(n,t.template);if(e.fullTemplate=r,r&&x(r)){let{createTemplateExecutor:i}=await import(`../../editing/sharedTemplates/executor/createTemplateExecutor.js`);e.templateExecutorInfo={completionResults:[],executor:await i(r),serviceLayersById:H(t.layer,n)}}return r}async _startCreating(){this.removeHandles(X);let{data:e}=this;if(!e.creationInfo)return;let t=this.data.creationInfo?.maxFeatures;t&&this.numPendingFeatures>=t?(this.sketchViewModel.cancel(),this.numPendingFeatures&&await this._startUpdating({feature:this.pendingFeatures.at(-1)})):(this.createFeatureState=`create-new`,await U(this._sketchViewModel,this._sketchLayer,e))}async _clearSelectedFeature(){let e=this._formViewModel.pendingSubtypeChoice;e&&(e.resolve(`undo`),await e.promise),this._stashValidationState(),this.sketchViewModel.cancel(),this.data.selectedPendingFeature=null,this._featureFormHandle=c(this._featureFormHandle),this._formViewModel.features=new n,this._formViewModel.activeFeatureIndex=-1}_stashValidationState(){let e=this._formViewModel.activeFeature,t=e&&this.data.getEditsForPendingFeature(e);t&&(t.submittable=this._formViewModel.valid)}async _selectFeatureForUpdate({feature:e,initialFeature:t=e}){this._stashValidationState();let{data:r,pendingFeatures:i}=this;i.includes(e)||r.addPendingFeature(e,t),r.selectedPendingFeature=e;let{_formViewModel:o,_sketchViewModel:s,sketchUpdateOptions:l}=this,{creationInfo:u,viewModel:d}=r,{layerInfos:m,view:h}=d;if(!h||!u)return;W(s,l),c(this._featureFormHandle);let g=e.sourceLayer,_=G(m,g),v=h.spatialReference;o.set({editType:`INSERT`,features:new n([e]),activeFeatureIndex:0,layerInfos:_?[_]:null,spatialReference:v,view:h}),await f(()=>o.updating===!1),await k(e,h.type===`2d`?h.scale:null);let y=r.getEditsForPendingFeature(e);y?.attachmentsModified&&o.applyStashedAttachmentEdits(y.attachmentEdits),this._featureFormHandle=a([o.on(`values-change`,K({filter:e=>e===y?.feature,forEachValueChange:(e,t)=>{if(ee(t)){let n=this._visualVariableAttributes;n.size&&!n.size.isUpdatingInteractively&&e===n.size.field&&n.size.setInitialValue(t),n.rotation&&!n.rotation.isUpdatingInteractively&&e===n.rotation.field&&n.rotation.setInitialValue(t)}},forEachFeature:e=>{y?.updateAttributes(o.getValues(e)),k(e,h.type===`2d`?h.scale:null)}})),o.on(`attachments-change`,e=>y?.setAttachmentEdits(e.attachmentEdits)),s.on([`update`,`undo`,`redo`],t=>{(t.type===`undo`||t.type===`redo`||t.type===`update`&&t.toolEventInfo!=null&&q(t.toolEventInfo.type))&&o.notifyGeometriesChanged([e])}),p(()=>o.activeFeature?.sourceLayer,t=>e.sourceLayer=t),p(()=>[o.activeFeature,o.valid],()=>this._stashValidationState())]),this.createFeatureState=`update-pending`}async _startUpdating({feature:e,initialFeature:t=e}){await this._selectFeatureForUpdate({feature:e,initialFeature:t});let{_sketchLayer:n,_sketchViewModel:r,data:i}=this,{creationInfo:a,viewModel:o}=i,{view:s}=o;if(!s||!a)return;let c=e.sourceLayer??a.layer;if(!D(c))return this._visualVariableAttributes=J(e),oe({graphic:e,sketchLayer:n,sketchViewModel:r,sourceLayer:c,updateOptions:this.sketchUpdateOptions,visualVariables:this._visualVariableAttributes})}static _createWorkflowSteps(e,t=`awaiting-feature-creation-info`){let{data:n}=e,r=n.creationInfo?.layer,i=se([`awaiting-feature-creation-info`,`creating-features`,`adding-attachment`,`editing-attachment`],t,{"awaiting-feature-creation-info":()=>({id:`awaiting-feature-creation-info`,async setUp(){let{creationInfo:t,viewModel:i}=n,{view:a}=i;a&&(N(t)?e.addHandles(await ae({view:a,data:n,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(r&&e.addHandles(i.restrictFeatureTemplatesViewModelToLayer(r),this.id),e.addHandles(i.featureTemplatesViewModel.on(`select`,({item:t})=>{t&&(n.creationInfo={...n.creationInfo,layer:t.layer,template:t.template},e.next())}),this.id)))},async tearDown(){e.removeHandles(this.id)}}),"creating-features":()=>({id:`creating-features`,async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){t.canceled&&e.removeHandles([Z,ve,X,Q])}}),"adding-attachment":()=>({id:`adding-attachment`,parent:`creating-features`,async setUp(){},async tearDown(){}}),"editing-attachment":()=>({id:`editing-attachment`,parent:`creating-features`,async setUp(){},async tearDown(){}})});return ce(n,i)}static _configureSketchViewModel(e){let{data:t,_sketchLayer:n,_sketchViewModel:r}=e,{creationInfo:o,viewModel:s}=t,{view:c}=s,l=[];if(!c)return i();if(c.type===`2d`){o&&l.push(e._fadeExistingFeatures(o.layer));let t=d((e,t)=>Promise.all(e.map(e=>k(e,t))));l.push(p(()=>c.scale,e=>t(n.graphics,e)))}let u=S(t.fullTemplate,o?.attributeOverrides,o?.layer),f=p(()=>r.createGraphic&&r.activeComponent,()=>{r.createGraphic&&r.activeComponent&&!e.hasHandles(X)&&e._updatingHandles.consumePromise(le({creationAttributes:u,data:t,sketchViewModel:r,view:c}).then(t=>e.addHandles(t,X)))}),m=async t=>{if((t.state===`cancel`||t.state===`complete`)&&e.removeHandles(X),t.state===`cancel`&&c.activeTool!==null&&c.activeTool!==e.sketchViewModel.activeComponent&&(await e._waitForActiveToolCleared(),await e._startCreating()),t.state===`complete`&&t.graphic){let n=await e._processEdits(t.graphic,{scale:c.type===`2d`?c.scale:null,useSourceLayer:!0});n&&(await e._waitForActiveToolCleared(),await e._startUpdating({feature:n}))}},h=async i=>{let{_formViewModel:a}=e;if(i.graphics.length>1){await e._clearSelectedFeature();return}let s=i.graphics[0];if(i.state===`complete`){if((e.numPendingFeatures===o?.maxFeatures||!a.valid)&&a.activeForm.touchAll(),await e._clearSelectedFeature(),e.data.selectedPendingFeature==null&&(c.activeTool==null||c.activeTool===e.sketchViewModel.activeComponent)&&(await e.sketchViewModel.wait(),e.sketchViewModel.state===`ready`&&e.data.creationInfo?.layer.geometryType!==`mesh`))return e._startCreating()}else if(i.state===`start`)return s.sourceLayer??=t.creationInfo?.layer,await fe({graphic:s,sketchLayer:n,sketchViewModel:r,visualVariables:e._visualVariableAttributes,sourceLayer:s.sourceLayer}),e._selectFeatureForUpdate({feature:s});else if(i.state===`active`){await e.updatePendingFeature(s);let t=e._visualVariableAttributes;pe(c,s,i,t)&&await k(s,c.type===`2d`?c.scale:null);let n=s.attributes,{rotation:r,size:o}=t;if(r!=null){let{field:t}=r;e._updatingHandles.consumePromise(a.setFieldValue(t,n[t]))}if(o!=null){let{field:t}=o;e._updatingHandles.consumePromise(a.setFieldValue(t,n[t]))}}},g=async n=>{if(n.graphics.forEach(e=>{t.removePendingFeature(e)}),!N(t.creationInfo))return e._startCreating()},_=async()=>{if(N(t.creationInfo))try{await e.data.viewModel.back()}catch{}return e._startCreating()};l.push(f,r.on(`create`,t=>e._updatingHandles.addPromise(m(t))),r.on(`update`,t=>e._updatingHandles.addPromise(h(t))),r.on(`delete`,t=>e._updatingHandles.addPromise(g(t))),e._updatingHandles.addWhen(()=>!e.numPendingFeatures,()=>e._updatingHandles.addPromise(_())),i(()=>{r.cancel()}),be(r,n,t),...xe(t));let v=a(l);return r.addHandles(v),v}_initializeSketchViewModel(){let{data:e}=this,{view:t}=e.viewModel,n=new T({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:`hide`,title:`createFeaturesWorkflow-internal`}),r=new _e({layer:n,creationMode:`single`,sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,useLegacyCreateTools:e.viewModel.useLegacyCreateTools,updateOnGraphicClick:!1,defaultUpdateOptions:this.sketchUpdateOptions,view:t});this._sketchLayer=n,this._sketchViewModel=r,t?.map.add(n),this.addHandles([i(()=>{t?.destroyed||t?.map.remove(n),l(n)}),p(()=>this.numPendingFeatures>0,e=>this._sketchViewModel.updateOnGraphicClick=e,m),p(()=>this.sketchUpdateOptions,e=>{r.defaultUpdateOptions=e,W(r,e)},h)])}_hasValidationErrors(e){return e?!this.data.isSubmittable(e):!1}async _processEdits(e,t){let{data:r,_formViewModel:i,_sketchLayer:a}=this,{layerInfos:o,view:s}=r.viewModel;i.editType=`INSERT`,i.spatialReference=s?.spatialReference,i.view=s;let{templateExecutorInfo:c}=r;if(!c){let t=e.clone();return t.geometry=null,await this._addAndInitializeEdits(e,t),e}a.remove(e);let{executor:l}=c,d=l(e.geometry,`completion`),p=u(d)?await d:d;c.completionResults.push(p),ue(p.relationships),i.editType=`INSERT`,i.spatialReference=s?.spatialReference,i.view=s,p.primary&&r.creationInfo?.attributeOverrides&&(p.primary.graphic.attributes={...p.primary.graphic.attributes,...r.creationInfo.attributeOverrides});for(let e of p.edits){let n=null;if(e.addFeatures)for(let r of e.addFeatures){let e=r.clone();e.geometry=null,r.geometry!=null&&(r.symbol=await O(r,t),a.add(r)),r.sourceLayer!==n?.layer&&(n=G(o,r.sourceLayer));let i=!!p.associationGraphics?.has(r);await this._addAndInitializeEdits(r,e,n,i)}}return i.features=new n,i.activeFeatureIndex=-1,await f(()=>!i.updating),p.edits.reduce((e,t)=>e+(t.addFeatures?.length??0),0)>1?null:p.primary?.graphic}async _addAndInitializeEdits(e,t,r,i=!1){let{data:a,_formViewModel:o}=this,{layerInfos:s}=a.viewModel,c=a.addPendingFeature(e,t,{isAssociation:i});r??=G(s,e.sourceLayer),o.features=new n([e]),o.activeFeatureIndex=0,o.layerInfos=r?[r]:null,await f(()=>!o.updating),c.updateAttributes(o.getValues(e)),c.submittable=o.valid}async _setUpCreatingFeaturesStep(){if(this.hasHandles(Z))return;let{data:e,sketchViewModel:n}=this,{creationInfo:o,viewModel:s}=e,{view:l}=s;if(!l||!o?.layer)throw new r(`missing-parameters`,`CreateFeaturesWorkflow requires a view and creationInfo.`);let{initialFeature:u,layer:d}=o,f=[],h=[];this._featureFormHandle=c(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},e.editorItem=R(s.editorItems,o.layer),o.template&&(e.fullTemplate??await this._initializeFullTemplateAndExecutorInfo(e),h.push(i(()=>{e.templateExecutorInfo&&(e.templateExecutorInfo.completionResults=[])}))),n.allowDeleteKey=!e.isSharedTemplateWorkflow;let g=de(l);f.push(g);let _=D(o.layer),{template:v}=o,y=!v||C(v)||b(v)&&v.type===`feature`,x=_&&y;try{if(x){let n=u??new t({attributes:S(e.fullTemplate,o.attributeOverrides,d),sourceLayer:d}),r=await this._processEdits(n);r&&await this._startUpdating({feature:r})}else f.push(Y._configureSketchViewModel(this)),u?(N(o)&&o.geometryToPlace&&(u.attributes=S(e.fullTemplate,o.attributeOverrides,d)),n.addGraphic(u),await this._startUpdating({feature:u})):await this._startCreating()}finally{g.remove()}let w=i(()=>{for(let t of e.pendingFeatures)n.removeGraphic(t),e.removePendingFeature(t)}),T=p(()=>l?.timeZone,e=>this.data.timeZone=e,m),E=i(()=>{N(o)&&s.cancelWorkflow({warnIfNoWorkflow:!1})});this._featureFormHandle&&f.push(this._featureFormHandle),this.addHandles(f,this._handleKeys.beforeCommit),this.addHandles(h,this._handleKeys.afterCommit),this.addHandles([a(f),a(h),E,w,T],Z)}async _waitForActiveToolCleared(){let e=this.data.viewModel.view;if(e?.activeTool==null)return;let t=new AbortController;this.addHandles(o(t),Q),await f(()=>e?.activeTool==null,t.signal),t.abort()}};e([v()],$.prototype,`allowSave`,null),e([v()],$.prototype,`createFeatureState`,void 0),e([v()],$.prototype,`curveResizeDisabled`,null),e([v()],$.prototype,`curveUpdatesDisabled`,null),e([v()],$.prototype,`data`,void 0),e([v({constructOnly:!0})],$.prototype,`isNested`,void 0),e([v()],$.prototype,`formViewModel`,null),e([v()],$.prototype,`hasInvalidFormTemplate`,null),e([v()],$.prototype,`hasPendingEdits`,null),e([v()],$.prototype,`hasPreviousStep`,null),e([v()],$.prototype,`_getDrawMeshHelpMessage`,void 0),e([v()],$.prototype,`helpMessage`,null),e([v()],$.prototype,`noticeMessage`,null),e([v()],$.prototype,`layer`,null),e([v()],$.prototype,`parent`,null),e([v()],$.prototype,`keyboardCancellationEnabled`,null),e([v()],$.prototype,`reliesOnOwnerAdminPrivileges`,null),e([v()],$.prototype,`saveActionLabel`,null),e([v()],$.prototype,`shouldShowAttachments`,null),e([v()],$.prototype,`shouldAllowAttachmentEditing`,null),e([v()],$.prototype,`sketchUpdateOptions`,null),e([v()],$.prototype,`sketchViewModel`,null),e([v()],$.prototype,`availableCreateTools`,null),$=Y=e([y(`esri.widgets.Editor.CreateFeaturesWorkflow`)],$);function be(e,t,n){let r=null,o=()=>e.snappingOptions.featureSources,s=()=>(r=new te({layer:t}),o().add(r),r),c=()=>{r!=null&&(o().remove(r),r=l(r))};return a([p(()=>{let e=n.creationInfo?.layer,t=o().find(t=>t.layer===e);return{hasFeatureLayerSource:!!t,enabled:t?.enabled??!1}},({hasFeatureLayerSource:e,enabled:t})=>{if(e)r??=s(),r.enabled=t;else return c()},g),i(c)])}function xe(e){let t=e.viewModel.view;if(!t)return[];let n=[];if(t.type===`3d`){let r=new j({view:t});n.push(p(()=>e.selectedPendingFeature,(e,t)=>{r.remove(e),r.add(t)}),i(()=>r.destroy()))}let r=new j({view:t,highlightName:ne});return n.push(p(()=>e.temporaryHighlightFeature,e=>{r.removeAll(),r.add(e)}),i(()=>r.destroy())),n}function Se(e){for(let t of e){let{sourceLayer:e}=t;e&&`globalIdField`in e&&e.globalIdField!=null&&(t.attributes[e.globalIdField]??=_())}}const Ce=$;export{Ce as default};
2
+ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import n from"../../core/Collection.js";import r from"../../core/Error.js";import{makeHandle as i,handlesGroup as a,abortHandle as o}from"../../core/handleUtils.js";import"../../core/has.js";import s from"../../core/Logger.js";import{removeMaybe as c,destroyMaybe as l}from"../../core/maybe.js";import{isPromiseLike as u,debounce as d}from"../../core/promiseUtils.js";import{whenOnce as f,watch as p,initial as m,sync as h,syncAndInitial as g}from"../../core/reactiveUtils.js";import{generateBracedUUID as _}from"../../core/uuid.js";import{property as v,subclass as y}from"../../core/accessorSupport/decorators.js";import{isSharedTemplateOrMetadata as b,isSharedTemplate as x,getCreationAttributes as S,isStandardFeatureTemplate as C}from"../../editing/templateUtils.js";import{getFullTemplate as w}from"../../editing/sharedTemplates/templateLoader.js";import T from"../../layers/GraphicsLayer.js";import{isSceneLayer as E,isTable as D}from"../../layers/support/layerUtils.js";import{isNumber as ee}from"../../support/guards.js";import{getDisplayedSymbol as O}from"../../symbols/support/symbolUtils.js";import{updateGraphicSymbolWhenRequired as k}from"../../views/draw/support/editingSessionUtils.js";import{getDrawHelpMessage as A}from"../../views/draw/support/helpMessageUtils.js";import j from"../../views/draw/support/HighlightHelper.js";import M from"../../views/interactive/sketch/SketchOptions.js";import te from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as ne}from"../../views/support/HighlightDefaults.js";import re from"../BatchAttributeForm/BatchAttributeFormViewModel.js";import ie from"./CreateFeaturesWorkflowData.js";import{isModelUpload as N,handleModelUpload as ae}from"./modelUploadUtils.js";import P from"./Workflow.js";import{activeSketchToolDrawsUnsupportedCurve as F,createToolFromGeometryType as I,containsUnsupportedCurve as L,findEditorItemForLayer as R,getServiceEditsFromWorkflowData as z,getServiceInfoForLayer as B,orderEditsByRelationshipDependencies as V,getServiceLayersById as H,startCreatingNewFeature as U,syncUpdateOptions as W,findLayerInfo as G,handleFormValuesChangeEvent as K,isTerminalUpdateEventType as q,getVisualVariableAttributes as J,startUpdatingFeatureGeometry as oe,createWorkflowSteps as se,avoidFeatureTemplateSelectionWithOnlyOneItem as ce,setUpSketchCreateWatchers as le,setRelationshipFields as ue,showProgressCursor as de,setVisualVariablesAndElevationInfoForUpdate as fe,visualVariableInteractiveUpdate as pe}from"./workflowUtils.js";import{makeServiceEditsWithAttachments as me,makeEditsWithAttachments as he,parseEditResultsAndCollectAddAttachmentData as ge}from"./support/attachmentUtils.js";import _e from"../Sketch/SketchViewModel.js";var Y;const ve=Symbol(),X=Symbol(),Z=Symbol(),Q=Symbol(),ye={point:[`point`],multipoint:[`multipoint`],polygon:[`polygon`,`freehandPolygon`,`rectangle`,`circle`],polyline:[`polyline`,`freehandPolyline`],mesh:[],multipatch:[]};let $=Y=class extends P{constructor(e){super(e),this.type=`create-features`,this.createFeatureState=`create-new`,this.data=void 0,this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._formViewModel=new re({attachmentsEnabled:!0}),this._sketchLayer=null,this._sketchViewModel=null,this._isActive=!0}initialize(){this.isNested&&(this._isActive=!1),this._initializeSketchViewModel()}destroy(){this._sketchViewModel.destroy()}get allowSave(){return!this.updating}get curveResizeDisabled(){return this.data.curveResizeDisabled}get curveUpdatesDisabled(){return this.data.curveUpdatesDisabled}get formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return!!this.data.editorItem?.hasInvalidFormTemplate}get hasPendingEdits(){if(this.pendingFeatures.some(e=>!!this.data.getEditsForPendingFeature(e)?.modified))return!0;let{creationInfo:e,upload:t}=this.data,{activeComponent:n,createGraphic:r}=this._sketchViewModel,i=r?.geometry?.type;return!!((i===`polyline`||i===`polygon`||i===`multipoint`)&&(n?.type===`draw-2d`||n?.type===`draw-3d`)&&n.drawOperation.committedVertices.length>0||t&&(t.state===`pending`||t.state===`success`)||e?.geometryToPlace)}get hasPreviousStep(){return this.formViewModel.canGoBack||this._stepIndex>0||this.createFeatureState===`update-pending`&&!!this.data.selectedPendingFeature&&!this.parent&&!N(this.data.creationInfo)}get helpMessage(){let{creationInfo:e,viewModel:t}=this.data;if(this.stepId!==`creating-features`||!e)return;let{_sketchViewModel:n}=this,{drawTool:r,isUsingLegacyCreateTools:i}=n;if(!i)return r?.helpMessageKey??`noTool`;let a=e.layer.geometryType,o=n.createGraphic;if(a===`mesh`){this._getDrawMeshHelpMessage||import(`../../views/draw/support/helpMessageUtils3d.js`).then(e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage});let{view:e}=t;return e?.type===`3d`?this._getDrawMeshHelpMessage?.(o,e):void 0}let{activeCreateToolDrawMode:s,activeTool:c}=n;return A(c===`rectangle`||c===`circle`?c:a,o?.geometry,s)}get noticeMessage(){if(F(this._sketchViewModel,this.data.editorItem))return`curveToolDensifyWarning`}get layer(){return this.data.creationInfo?.layer}get numPendingFeatures(){return this.pendingFeatures.length}get numPendingFeaturesExcludingHidden(){return this.pendingFeatures.filter(e=>this.data.isDisplayable(e)).length}get parent(){return this.data.parent}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return this.numPendingFeatures===0}get reliesOnOwnerAdminPrivileges(){return this.data.editorItem?.capabilities.create.reliesOnOwnerAdminPrivileges??!1}get saveActionLabel(){return`create`}get shouldShowAttachments(){return(this.data.selectedPendingFeature&&this.data.editorItem?.capabilities.create.attachments.enabled)??!1}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get sketchUpdateOptions(){let{editorItem:e}=this.data;return{enableScaling:!this.curveResizeDisabled,multipleSelectionEnabled:!1,reshapeOptions:{enableCreateCurveFromStraightEdge:!E(e?.layer)&&!!e?.capabilities.supportsTrueCurve}}}get sketchViewModel(){return this._sketchViewModel}get test(){}get availableCreateTools(){let e=this.data.creationInfo?.layer.geometryType,t=this.data.viewModel.view;if(!e||this.data.creationInfo?.maxFeatures&&this.data.creationInfo.maxFeatures<=this.numPendingFeatures)return[];if(b(this.data.fullTemplate)){let{tool:t}=I(e,this.data.fullTemplate);return[t]}return t?.type!==`2d`&&e===`multipoint`?[]:[...ye[e]]}getUpdating(){return!!this._sketchViewModel?.updating}async enter(){this._isActive=!0,this.stepId!==`awaiting-feature-creation-info`&&await this._updatingHandles.addPromise(this._setUpCreatingFeaturesStep())}exit(){this._isActive=!1,this.removeHandles([Z])}async updatePendingFeature(e){if(e!==this.data.selectedPendingFeature)return this._sketchViewModel.cancel(),this._startUpdating({feature:e})}async start(){return await super.start(),D(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}async save(e){let{formViewModel:t}=this;if(t.pendingSubtypeChoice)return;await t.submit(),this._stashValidationState();let n=this.data.selectedPendingFeature,r=this._hasValidationErrors(n)?n:this.data.pendingFeatures.find(e=>this._hasValidationErrors(e));if(r){await this._startUpdating({feature:r}),await t?.submit();return}let{pendingFeatures:i,editorItem:a}=this.data;return a&&e&&L(i.toArray(),a)&&!await e(`curveEditingDensifyPrompt`)?this.reset():super.save()}back(e){return this._formViewModel.canGoBack?this._formViewModel.goBack():this.createFeatureState===`update-pending`&&this.data.selectedPendingFeature&&!N(this.data.creationInfo)&&!this.parent?this._clearSelectedFeature():super.back(e)}previous(e){return this._formViewModel.canGoBack?this._formViewModel.goBack():this.createFeatureState===`update-pending`&&this.data.selectedPendingFeature&&!N(this.data.creationInfo)?this._clearSelectedFeature():super.previous(e)}cancelFeature(e){this.data.isSharedTemplateWorkflow?s.getLogger(this).warn(`Cannot cancel individual features created by shared templates.`):(this.data.removePendingFeature(e),this.sketchViewModel.removeGraphic(e))}static create(e){let{applyEdits:t,applyEditsFeatureService:n,addAttachmentsCallback:r,isNested:i,creationInfo:a,parent:o,snappingManager:s,startAt:c,viewModel:l}=e,u=e.sketchOptions??new M,d=a?.layer,f=d?R(l.editorItems,d):void 0,p=new Y({data:new ie({creationInfo:a,editorItem:f,parent:o,sketchOptions:u,snappingManager:s,viewModel:l}),isNested:i,onCommit:async e=>{let{creationInfo:i}=e;if(!i)return;p._sketchViewModel.cancel();let a=e.pendingFeatures.toArray(),{layer:o}=i,s=o.capabilities?.editing.supportsGlobalId&&`globalIdField`in o,{fullTemplate:c}=e,u=z(p.data),d=x(c)&&u;if(s){if(Se(a),d){let t=me(u,e),r=await B(o,l.view)?.load();r&&(t=V({edits:t,serviceInfo:r,view:l.view,findOriginalFeature:t=>e.getEditsForPendingFeature(t)?.initialFeature??t})),await n(c.featureService,t,{globalIdUsed:!0,honorSequenceOfEdits:!0,gdbVersion:c.layer.gdbVersion??void 0})}else await t(o,he(a,e),{globalIdUsed:!0});return}let f=d?await n(c.featureService,u,{gdbVersion:c.layer.gdbVersion??void 0}):[await t(o,{addFeatures:a})];f?.length&&e.attachmentsModified&&!s&&await Promise.all(f.map(t=>{if(!t?.addFeatureResults)return;let n=ge(a,t.addFeatureResults,o,e);return r(o,n)}))}});return p._set(`steps`,this._createWorkflowSteps(p,c)),p}_fadeExistingFeatures(e){if(`effect`in e){let t=e.effect;return e.effect=`saturate(0.6) opacity(0.8)`,i(()=>e.effect=t)}let t=e.opacity;return e.opacity=.7,i(()=>e.opacity=t)}async _initializeFullTemplateAndExecutorInfo(e){let{creationInfo:t}=e,{view:n}=e.viewModel;if(!t||!n)return null;let r=await w(n,t.template);if(e.fullTemplate=r,r&&x(r)){let{createTemplateExecutor:i}=await import(`../../editing/sharedTemplates/executor/createTemplateExecutor.js`);e.templateExecutorInfo={completionResults:[],executor:await i(r),serviceLayersById:H(t.layer,n)}}return r}async _startCreating(){this.removeHandles(X);let{data:e}=this;if(!e.creationInfo)return;let t=this.data.creationInfo?.maxFeatures;t&&this.numPendingFeatures>=t?(this.sketchViewModel.cancel(),this.numPendingFeatures&&await this._startUpdating({feature:this.pendingFeatures.at(-1)})):(this.createFeatureState=`create-new`,await U(this._sketchViewModel,this._sketchLayer,e))}async _clearSelectedFeature(){let e=this._formViewModel.pendingSubtypeChoice;e&&(e.resolve(`undo`),await e.promise),this._stashValidationState(),this.sketchViewModel.cancel(),this.data.selectedPendingFeature=null,this._featureFormHandle=c(this._featureFormHandle),this._formViewModel.features=new n,this._formViewModel.activeFeatureIndex=-1}_stashValidationState(){let e=this._formViewModel.activeFeature,t=e&&this.data.getEditsForPendingFeature(e);t&&(t.submittable=this._formViewModel.valid)}async _selectFeatureForUpdate({feature:e,initialFeature:t=e}){this._stashValidationState();let{data:r,pendingFeatures:i}=this;i.includes(e)||r.addPendingFeature(e,t),r.selectedPendingFeature=e;let{_formViewModel:o,_sketchViewModel:s,sketchUpdateOptions:l}=this,{creationInfo:u,viewModel:d}=r,{layerInfos:m,view:h}=d;if(!h||!u)return;W(s,l),c(this._featureFormHandle);let g=e.sourceLayer,_=G(m,g),v=h.spatialReference;o.set({editType:`INSERT`,features:new n([e]),activeFeatureIndex:0,layerInfos:_?[_]:null,spatialReference:v,view:h}),await f(()=>o.updating===!1),await k(e,h.type===`2d`?h.scale:null);let y=r.getEditsForPendingFeature(e);y?.attachmentsModified&&o.applyStashedAttachmentEdits(y.attachmentEdits),this._featureFormHandle=a([o.on(`values-change`,K({filter:e=>e===y?.feature,forEachValueChange:(e,t)=>{if(ee(t)){let n=this._visualVariableAttributes;n.size&&!n.size.isUpdatingInteractively&&e===n.size.field&&n.size.setInitialValue(t),n.rotation&&!n.rotation.isUpdatingInteractively&&e===n.rotation.field&&n.rotation.setInitialValue(t)}},forEachFeature:e=>{y?.updateAttributes(o.getValues(e)),k(e,h.type===`2d`?h.scale:null)}})),o.on(`attachments-change`,e=>y?.setAttachmentEdits(e.attachmentEdits)),s.on([`update`,`undo`,`redo`],t=>{(t.type===`undo`||t.type===`redo`||t.type===`update`&&t.toolEventInfo!=null&&q(t.toolEventInfo.type))&&o.notifyGeometriesChanged([e])}),p(()=>o.activeFeature?.sourceLayer,t=>e.sourceLayer=t),p(()=>[o.activeFeature,o.valid],()=>this._stashValidationState())]),this.createFeatureState=`update-pending`}async _startUpdating({feature:e,initialFeature:t=e}){await this._selectFeatureForUpdate({feature:e,initialFeature:t});let{_sketchLayer:n,_sketchViewModel:r,data:i}=this,{creationInfo:a,viewModel:o}=i,{view:s}=o;if(!s||!a)return;let c=e.sourceLayer??a.layer;if(!D(c))return this._visualVariableAttributes=J(e),oe({graphic:e,sketchLayer:n,sketchViewModel:r,sourceLayer:c,updateOptions:this.sketchUpdateOptions,visualVariables:this._visualVariableAttributes})}static _createWorkflowSteps(e,t=`awaiting-feature-creation-info`){let{data:n}=e,r=n.creationInfo?.layer,i=se([`awaiting-feature-creation-info`,`creating-features`,`adding-attachment`,`editing-attachment`],t,{"awaiting-feature-creation-info":()=>({id:`awaiting-feature-creation-info`,async setUp(){let{creationInfo:t,viewModel:i}=n,{view:a}=i;a&&(N(t)?e.addHandles(await ae({view:a,data:n,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(r&&e.addHandles(i.restrictFeatureTemplatesViewModelToLayer(r),this.id),e.addHandles(i.featureTemplatesViewModel.on(`select`,({item:t})=>{t&&(n.creationInfo={...n.creationInfo,layer:t.layer,template:t.template},e.next())}),this.id)))},async tearDown(){e.removeHandles(this.id)}}),"creating-features":()=>({id:`creating-features`,async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){t.canceled&&e.removeHandles([Z,ve,X,Q])}}),"adding-attachment":()=>({id:`adding-attachment`,parent:`creating-features`,async setUp(){},async tearDown(){}}),"editing-attachment":()=>({id:`editing-attachment`,parent:`creating-features`,async setUp(){},async tearDown(){}})});return ce(n,i)}static _configureSketchViewModel(e){let{data:t,_sketchLayer:n,_sketchViewModel:r}=e,{creationInfo:o,viewModel:s}=t,{view:c}=s,l=[];if(!c)return i();if(c.type===`2d`){o&&l.push(e._fadeExistingFeatures(o.layer));let t=d((e,t)=>Promise.all(e.map(e=>k(e,t))));l.push(p(()=>c.scale,e=>t(n.graphics,e)))}let u=S(t.fullTemplate,o?.attributeOverrides,o?.layer),f=p(()=>r.createGraphic&&r.activeComponent,()=>{r.createGraphic&&r.activeComponent&&!e.hasHandles(X)&&e._updatingHandles.consumePromise(le({creationAttributes:u,data:t,sketchViewModel:r,view:c}).then(t=>e.addHandles(t,X)))}),m=async t=>{if((t.state===`cancel`||t.state===`complete`)&&e.removeHandles(X),t.state===`cancel`&&c.activeTool!==null&&c.activeTool!==e.sketchViewModel.activeComponent&&(await e._waitForActiveToolCleared(),await e._startCreating()),t.state===`complete`&&t.graphic){let n=await e._processEdits(t.graphic,{scale:c.type===`2d`?c.scale:null,useSourceLayer:!0});n&&(await e._waitForActiveToolCleared(),await e._startUpdating({feature:n}))}},h=async i=>{let{_formViewModel:a}=e;if(i.graphics.length>1){await e._clearSelectedFeature();return}let s=i.graphics[0];if(i.state===`complete`){if(e.numPendingFeatures!==o?.maxFeatures&&a.valid||a.activeForm.touchAll(),await e._clearSelectedFeature(),e.data.selectedPendingFeature==null&&(c.activeTool==null||c.activeTool===e.sketchViewModel.activeComponent)&&(await e.sketchViewModel.wait(),e.sketchViewModel.state===`ready`&&e.data.creationInfo?.layer.geometryType!==`mesh`))return e._startCreating()}else if(i.state===`start`)return s.sourceLayer??=t.creationInfo?.layer,await fe({graphic:s,sketchLayer:n,sketchViewModel:r,visualVariables:e._visualVariableAttributes,sourceLayer:s.sourceLayer}),e._selectFeatureForUpdate({feature:s});else if(i.state===`active`){await e.updatePendingFeature(s);let t=e._visualVariableAttributes;pe(c,s,i,t)&&await k(s,c.type===`2d`?c.scale:null);let n=s.attributes,{rotation:r,size:o}=t;if(r!=null){let{field:t}=r;e._updatingHandles.consumePromise(a.setFieldValue(t,n[t]))}if(o!=null){let{field:t}=o;e._updatingHandles.consumePromise(a.setFieldValue(t,n[t]))}}},g=async n=>{if(n.graphics.forEach(e=>{t.removePendingFeature(e)}),!N(t.creationInfo))return e._startCreating()},_=async()=>{if(N(t.creationInfo))try{await e.data.viewModel.back()}catch{}return e._startCreating()};l.push(f,r.on(`create`,t=>e._updatingHandles.addPromise(m(t))),r.on(`update`,t=>e._updatingHandles.addPromise(h(t))),r.on(`delete`,t=>e._updatingHandles.addPromise(g(t))),e._updatingHandles.addWhen(()=>!e.numPendingFeatures,()=>e._updatingHandles.addPromise(_())),i(()=>{r.cancel()}),be(r,n,t),...xe(t));let v=a(l);return r.addHandles(v),v}_initializeSketchViewModel(){let{data:e}=this,{view:t}=e.viewModel,n=new T({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:`hide`,title:`createFeaturesWorkflow-internal`}),r=new _e({layer:n,creationMode:`single`,sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,useLegacyCreateTools:e.viewModel.useLegacyCreateTools,updateOnGraphicClick:!1,defaultUpdateOptions:this.sketchUpdateOptions,view:t});this._sketchLayer=n,this._sketchViewModel=r,t?.map.add(n),this.addHandles([i(()=>{t?.destroyed||t?.map.remove(n),l(n)}),p(()=>this.numPendingFeatures>0,e=>this._sketchViewModel.updateOnGraphicClick=e,m),p(()=>this.sketchUpdateOptions,e=>{r.defaultUpdateOptions=e,W(r,e)},h)])}_hasValidationErrors(e){return e?!this.data.isSubmittable(e):!1}async _processEdits(e,t){let{data:r,_formViewModel:i,_sketchLayer:a}=this,{layerInfos:o,view:s}=r.viewModel;i.editType=`INSERT`,i.spatialReference=s?.spatialReference,i.view=s;let{templateExecutorInfo:c}=r;if(!c){let t=e.clone();return t.geometry=null,await this._addAndInitializeEdits(e,t),e}a.remove(e);let{executor:l}=c,d=l(e.geometry,`completion`),p=u(d)?await d:d;c.completionResults.push(p),ue(p.relationships),i.editType=`INSERT`,i.spatialReference=s?.spatialReference,i.view=s,p.primary&&r.creationInfo?.attributeOverrides&&(p.primary.graphic.attributes={...p.primary.graphic.attributes,...r.creationInfo.attributeOverrides});for(let e of p.edits){let n=null;if(e.addFeatures)for(let r of e.addFeatures){let e=r.clone();e.geometry=null,r.geometry!=null&&(r.symbol=await O(r,t),a.add(r)),r.sourceLayer!==n?.layer&&(n=G(o,r.sourceLayer));let i=!!p.associationGraphics?.has(r);await this._addAndInitializeEdits(r,e,n,i)}}return i.features=new n,i.activeFeatureIndex=-1,await f(()=>!i.updating),p.edits.reduce((e,t)=>e+(t.addFeatures?.length??0),0)>1?null:p.primary?.graphic}async _addAndInitializeEdits(e,t,r,i=!1){let{data:a,_formViewModel:o}=this,{layerInfos:s}=a.viewModel,c=a.addPendingFeature(e,t,{isAssociation:i});r??=G(s,e.sourceLayer),o.features=new n([e]),o.activeFeatureIndex=0,o.layerInfos=r?[r]:null,await f(()=>!o.updating),c.updateAttributes(o.getValues(e)),c.submittable=o.valid}async _setUpCreatingFeaturesStep(){if(this.hasHandles(Z))return;let{data:e,sketchViewModel:n}=this,{creationInfo:o,viewModel:s}=e,{view:l}=s;if(!l||!o?.layer)throw new r(`missing-parameters`,`CreateFeaturesWorkflow requires a view and creationInfo.`);let{initialFeature:u,layer:d}=o,f=[],h=[];this._featureFormHandle=c(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},e.editorItem=R(s.editorItems,o.layer),o.template&&(e.fullTemplate??await this._initializeFullTemplateAndExecutorInfo(e),h.push(i(()=>{e.templateExecutorInfo&&(e.templateExecutorInfo.completionResults=[])}))),n.allowDeleteKey=!e.isSharedTemplateWorkflow;let g=de(l);f.push(g);let _=D(o.layer),{template:v}=o,y=!v||C(v)||b(v)&&v.type===`feature`,x=_&&y;try{if(x){let n=u??new t({attributes:S(e.fullTemplate,o.attributeOverrides,d),sourceLayer:d}),r=await this._processEdits(n);r&&await this._startUpdating({feature:r})}else f.push(Y._configureSketchViewModel(this)),u?(N(o)&&o.geometryToPlace&&(u.attributes=S(e.fullTemplate,o.attributeOverrides,d)),n.addGraphic(u),await this._startUpdating({feature:u})):await this._startCreating()}finally{g.remove()}let w=i(()=>{for(let t of e.pendingFeatures)n.removeGraphic(t),e.removePendingFeature(t)}),T=p(()=>l?.timeZone,e=>this.data.timeZone=e,m),E=i(()=>{N(o)&&s.cancelWorkflow({warnIfNoWorkflow:!1})});this._featureFormHandle&&f.push(this._featureFormHandle),this.addHandles(f,this._handleKeys.beforeCommit),this.addHandles(h,this._handleKeys.afterCommit),this.addHandles([a(f),a(h),E,w,T],Z)}async _waitForActiveToolCleared(){let e=this.data.viewModel.view;if(e?.activeTool==null)return;let t=new AbortController;this.addHandles(o(t),Q),await f(()=>e?.activeTool==null,t.signal),t.abort()}};e([v()],$.prototype,`allowSave`,null),e([v()],$.prototype,`createFeatureState`,void 0),e([v()],$.prototype,`curveResizeDisabled`,null),e([v()],$.prototype,`curveUpdatesDisabled`,null),e([v()],$.prototype,`data`,void 0),e([v({constructOnly:!0})],$.prototype,`isNested`,void 0),e([v()],$.prototype,`formViewModel`,null),e([v()],$.prototype,`hasInvalidFormTemplate`,null),e([v()],$.prototype,`hasPendingEdits`,null),e([v()],$.prototype,`hasPreviousStep`,null),e([v()],$.prototype,`_getDrawMeshHelpMessage`,void 0),e([v()],$.prototype,`helpMessage`,null),e([v()],$.prototype,`noticeMessage`,null),e([v()],$.prototype,`layer`,null),e([v()],$.prototype,`parent`,null),e([v()],$.prototype,`keyboardCancellationEnabled`,null),e([v()],$.prototype,`reliesOnOwnerAdminPrivileges`,null),e([v()],$.prototype,`saveActionLabel`,null),e([v()],$.prototype,`shouldShowAttachments`,null),e([v()],$.prototype,`shouldAllowAttachmentEditing`,null),e([v()],$.prototype,`sketchUpdateOptions`,null),e([v()],$.prototype,`sketchViewModel`,null),e([v()],$.prototype,`availableCreateTools`,null),$=Y=e([y(`esri.widgets.Editor.CreateFeaturesWorkflow`)],$);function be(e,t,n){let r=null,o=()=>e.snappingOptions.featureSources,s=()=>(r=new te({layer:t}),o().add(r),r),c=()=>{r!=null&&(o().remove(r),r=l(r))};return a([p(()=>{let e=n.creationInfo?.layer,t=o().find(t=>t.layer===e);return{hasFeatureLayerSource:!!t,enabled:t?.enabled??!1}},({hasFeatureLayerSource:e,enabled:t})=>{if(e)r??=s(),r.enabled=t;else return c()},g),i(c)])}function xe(e){let t=e.viewModel.view;if(!t)return[];let n=[];if(t.type===`3d`){let r=new j({view:t});n.push(p(()=>e.selectedPendingFeature,(e,t)=>{r.remove(e),r.add(t)}),i(()=>r.destroy()))}let r=new j({view:t,highlightName:ne});return n.push(p(()=>e.temporaryHighlightFeature,e=>{r.removeAll(),r.add(e)}),i(()=>r.destroy())),n}function Se(e){for(let t of e){let{sourceLayer:e}=t;e&&`globalIdField`in e&&e.globalIdField!=null&&(t.attributes[e.globalIdField]??=_())}}const Ce=$;export{Ce as default};
@@ -508,4 +508,13 @@ export default class EditorViewModel extends EventedAccessor {
508
508
  startUpdateWorkflowAtMultipleFeatureSelection(candidates: Graphic[]): Promise<void>;
509
509
  /** Toggles the `UpdateWorkflow`. */
510
510
  toggleUpdateWorkflow(): Promise<void>;
511
- }
511
+ }
512
+
513
+ /** @deprecated since version 5.2. Import { EditorStartCreateFeaturesWorkflowAtFeatureEditParameters } from "@arcgis/core/widgets/Editor/types" instead. */
514
+ export type EditorViewModelStartCreateFeaturesWorkflowAtFeatureEditParameters = EditorStartCreateFeaturesWorkflowAtFeatureEditParameters;
515
+
516
+ /** @deprecated since version 5.2. Import { EditorStartMergeFeaturesWorkflowOptions } from "@arcgis/core/widgets/Editor/types" instead. */
517
+ export type EditorViewModelStartMergeFeaturesWorkflowOptions = EditorStartMergeFeaturesWorkflowOptions;
518
+
519
+ /** @deprecated since version 5.2. Import { EditorStartSplitFeatureWorkflowOptions } from "@arcgis/core/widgets/Editor/types" instead. */
520
+ export type EditorViewModelStartSplitFeatureWorkflowOptions = EditorStartSplitFeatureWorkflowOptions;
@@ -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"../../../Graphic.js";import n from"../../../core/Error.js";import{makeHandle as r,handlesGroup as i,abortHandle as a}from"../../../core/handleUtils.js";import"../../../core/has.js";import o from"../../../core/Logger.js";import{removeMaybe as s,destroyMaybe as c}from"../../../core/maybe.js";import{isPromiseLike as l,debounce as u}from"../../../core/promiseUtils.js";import{watch as d,initial as f,sync as p,whenOnce as m,syncAndInitial as h}from"../../../core/reactiveUtils.js";import{generateBracedUUID as g}from"../../../core/uuid.js";import{property as _,subclass as v}from"../../../core/accessorSupport/decorators.js";import{isSharedTemplateOrMetadata as y,isSharedTemplate as b,getCreationAttributes as x,isStandardFeatureTemplate as ee}from"../../../editing/templateUtils.js";import{getFullTemplate as S}from"../../../editing/sharedTemplates/templateLoader.js";import C from"../../../layers/GraphicsLayer.js";import{isSceneLayer as w,isTable as T}from"../../../layers/support/layerUtils.js";import{isNumber as E}from"../../../support/guards.js";import{getDisplayedSymbol as D}from"../../../symbols/support/symbolUtils.js";import{updateGraphicSymbolWhenRequired as O}from"../../../views/draw/support/editingSessionUtils.js";import{getDrawHelpMessage as k}from"../../../views/draw/support/helpMessageUtils.js";import A from"../../../views/draw/support/HighlightHelper.js";import j from"../../../views/interactive/sketch/SketchOptions.js";import te from"../../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as M}from"../../../views/support/HighlightDefaults.js";import{isModelUpload as N,handleModelUpload as ne}from"../modelUploadUtils.js";import{activeSketchToolDrawsUnsupportedCurve as re,createToolFromGeometryType as ie,containsUnsupportedCurve as ae,findEditorItemForLayer as P,getServiceEditsFromWorkflowData as F,getServiceInfoForLayer as I,orderEditsByRelationshipDependencies as L,getServiceLayersById as R,startCreatingNewFeature as z,syncUpdateOptions as B,findLayerInfo as V,isTerminalUpdateEventType as H,getVisualVariableAttributes as U,startUpdatingFeatureGeometry as W,createWorkflowSteps as G,avoidFeatureTemplateSelectionWithOnlyOneItem as K,setUpSketchCreateWatchers as q,setRelationshipFields as J,showProgressCursor as oe,setVisualVariablesAndElevationInfoForUpdate as se,visualVariableInteractiveUpdate as ce}from"../workflowUtils.js";import le from"./CreateFeaturesWorkflowData.js";import ue from"./Workflow.js";import{prepareAttachmentsForCreateFeaturesWorkflow as de}from"./workflowUtils.js";import fe from"../../FeatureForm/FeatureFormViewModel.js";import pe from"../../Sketch/SketchViewModel.js";var Y;const me=Symbol(),X=Symbol(),Z=Symbol(),Q=Symbol(),he={point:[`point`],multipoint:[`multipoint`],polygon:[`polygon`,`freehandPolygon`,`rectangle`,`circle`],polyline:[`polyline`,`freehandPolyline`],mesh:[],multipatch:[]};let $=Y=class extends ue{constructor(e){super(e),this.type=`create-features`,this.createFeatureState=`create-new`,this.data=void 0,this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._formViewModel=new fe,this._sketchLayer=null,this._sketchViewModel=null,this._attachmentFileInfos=new Map,this._isActive=!0}initialize(){this.isNested&&(this._isActive=!1),this._initializeSketchViewModel()}destroy(){this._sketchViewModel.destroy()}get allowSave(){return!this.updating}get curveResizeDisabled(){return this.data.curveResizeDisabled}get curveUpdatesDisabled(){return this.data.curveUpdatesDisabled}get formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return!!this.data.editorItem?.hasInvalidFormTemplate}get hasPendingEdits(){if(this.pendingFeatures.some(e=>!!this.data.getEditsForPendingFeature(e)?.modified))return!0;let{creationInfo:e,upload:t}=this.data,{activeComponent:n,createGraphic:r}=this._sketchViewModel,i=r?.geometry?.type;return!!((i===`polyline`||i===`polygon`||i===`multipoint`)&&(n?.type===`draw-2d`||n?.type===`draw-3d`)&&n.drawOperation.committedVertices.length>0||t&&(t.state===`pending`||t.state===`success`)||e?.geometryToPlace)}get hasPreviousStep(){return this._stepIndex>0||this.createFeatureState===`update-pending`&&!!this.data.selectedPendingFeature&&!this.parent&&!N(this.data.creationInfo)}get helpMessage(){let{creationInfo:e,viewModel:t}=this.data;if(this.stepId!==`creating-features`||!e)return;let{_sketchViewModel:n}=this,{drawTool:r,isUsingLegacyCreateTools:i}=n;if(!i)return r?.helpMessageKey??`noTool`;let a=e.layer.geometryType,o=n.createGraphic;if(a===`mesh`){this._getDrawMeshHelpMessage||import(`../../../views/draw/support/helpMessageUtils3d.js`).then(e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage});let{view:e}=t;return e?.type===`3d`?this._getDrawMeshHelpMessage?.(o,e):void 0}let{activeCreateToolDrawMode:s,activeTool:c}=n;return k(c===`rectangle`||c===`circle`?c:a,o?.geometry,s)}get noticeMessage(){if(re(this._sketchViewModel,this.data.editorItem))return`curveToolDensifyWarning`}get layer(){return this.data.creationInfo?.layer}get numPendingFeatures(){return this.pendingFeatures.length}get numPendingFeaturesExcludingHidden(){return this.pendingFeatures.filter(e=>this.data.isDisplayable(e)).length}get parent(){return this.data.parent}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return this.numPendingFeatures===0}get reliesOnOwnerAdminPrivileges(){return this.data.editorItem?.capabilities.create.reliesOnOwnerAdminPrivileges??!1}get saveActionLabel(){return`create`}get shouldShowAttachments(){return(this.data.selectedPendingFeature&&this.data.editorItem?.capabilities.create.attachments.enabled)??!1}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get sketchUpdateOptions(){let{editorItem:e}=this.data;return{enableScaling:!this.curveResizeDisabled,multipleSelectionEnabled:!1,reshapeOptions:{enableCreateCurveFromStraightEdge:!w(e?.layer)&&!!e?.capabilities.supportsTrueCurve}}}get sketchViewModel(){return this._sketchViewModel}get test(){}get availableCreateTools(){let e=this.data.creationInfo?.layer.geometryType,t=this.data.viewModel.view;if(!e||this.data.creationInfo?.maxFeatures&&this.data.creationInfo.maxFeatures<=this.numPendingFeatures)return[];if(y(this.data.fullTemplate)){let{tool:t}=ie(e,this.data.fullTemplate);return[t]}return t?.type!==`2d`&&e===`multipoint`?[]:[...he[e]]}get _attachmentsActive(){let e=this.data.viewModel.attachmentsViewModel.mode,t=this.stepId;return this.shouldShowAttachments&&(e===`add`||e===`edit`||t===`adding-attachment`||t===`editing-attachment`)}getUpdating(){return!!this._sketchViewModel?.updating}async enter(){this._isActive=!0,this.stepId!==`awaiting-feature-creation-info`&&await this._updatingHandles.addPromise(this._setUpCreatingFeaturesStep())}exit(){this._isActive=!1,this.removeHandles([Z])}async updatePendingFeature(e){if(e!==this.data.selectedPendingFeature)return this._sketchViewModel.cancel(),this._startUpdating({feature:e})}async start(){return await super.start(),T(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}async save(e){let{formViewModel:t}=this;if(t.pendingSubtypeChoice)return;t.submit(),this._stashValidationState();let n=this.data.selectedPendingFeature,r=this._hasValidationErrors(n)?n:this.data.pendingFeatures.find(e=>this._hasValidationErrors(e));if(r){await this._startUpdating({feature:r}),t?.submit();return}let{pendingFeatures:i,editorItem:a}=this.data;return a&&e&&ae(i.toArray(),a)&&!await e(`curveEditingDensifyPrompt`)?this.reset():super.save()}back(e){return this.createFeatureState===`update-pending`&&this.data.selectedPendingFeature&&!N(this.data.creationInfo)&&!this._attachmentsActive&&!this.parent?this._clearSelectedFeature():super.back(e)}previous(e){return this.createFeatureState===`update-pending`&&this.data.selectedPendingFeature&&!N(this.data.creationInfo)&&!this._attachmentsActive?this._clearSelectedFeature():super.previous(e)}cancelFeature(e){this.data.isSharedTemplateWorkflow?o.getLogger(this).warn(`Cannot cancel individual features created by shared templates.`):(this.data.removePendingFeature(e),this.sketchViewModel.removeGraphic(e))}static create(e){let{addAttachmentsCallback:t,applyEdits:n,applyEditsFeatureService:r,isNested:i,creationInfo:a,parent:o,snappingManager:s,startAt:c,viewModel:l}=e,u=e.sketchOptions??new j,d=a?.layer,f=d?P(l.editorItems,d):void 0,p=new Y({data:new le({creationInfo:a,editorItem:f,parent:o,sketchOptions:u,snappingManager:s,viewModel:l}),isNested:i,onCommit:async e=>{let{creationInfo:i}=e;if(!i)return;p._sketchViewModel.cancel();let a=e.pendingFeatures.toArray(),{layer:o}=i,s=o.capabilities?.editing.supportsGlobalId&&`globalIdField`in o,c=p._attachmentFileInfos,{fullTemplate:u}=e,d=F(p.data),f=b(u)&&d;if(s){if(ye(a),f){let t=xe(d,c),n=await I(o,l.view)?.load();n&&(t=L({edits:t,serviceInfo:n,view:l.view,findOriginalFeature:t=>e.getEditsForPendingFeature(t)?.initialFeature??t})),await r(u.featureService,t,{globalIdUsed:!0,honorSequenceOfEdits:!0,gdbVersion:u.layer.gdbVersion??void 0})}else{let e=be(a,c);await n(o,e,{globalIdUsed:!0})}return}let m=f?await r(u.featureService,d,{gdbVersion:u.layer.gdbVersion??void 0}):[await n(o,{addFeatures:a})];m&&c.size>0&&await Promise.all(m.map(e=>{if(e?.addFeatureResults)return t(o,ve(a,e.addFeatureResults,o,c))}))}});return p._set(`steps`,this._createWorkflowSteps(p,c)),p}_fadeExistingFeatures(e){if(`effect`in e){let t=e.effect;return e.effect=`saturate(0.6) opacity(0.8)`,r(()=>e.effect=t)}let t=e.opacity;return e.opacity=.7,r(()=>e.opacity=t)}async _initializeFullTemplateAndExecutorInfo(e){let{creationInfo:t}=e,{view:n}=e.viewModel;if(!t||!n)return null;let r=await S(n,t.template);if(e.fullTemplate=r,r&&b(r)){let{createTemplateExecutor:i}=await import(`../../../editing/sharedTemplates/executor/createTemplateExecutor.js`);e.templateExecutorInfo={completionResults:[],executor:await i(r),serviceLayersById:R(t.layer,n)}}return r}async _startCreating(){this.removeHandles(X);let{data:e}=this;if(!e.creationInfo)return;let t=this.data.creationInfo?.maxFeatures;t&&this.numPendingFeatures>=t?(this.sketchViewModel.cancel(),this.numPendingFeatures&&await this._startUpdating({feature:this.pendingFeatures.at(-1)})):(this.createFeatureState=`create-new`,await z(this._sketchViewModel,this._sketchLayer,e))}async _clearSelectedFeature(){let e=this._formViewModel.pendingSubtypeChoice;e&&(e.resolve(`undo`),await e.promise),this._stashValidationState(),this.sketchViewModel.cancel(),this.data.selectedPendingFeature=null,this._featureFormHandle=s(this._featureFormHandle),this._formViewModel.feature=null;let t=this.data.viewModel.attachmentsViewModel;(t.mode===`add`||t.mode===`edit`)&&await this.data.viewModel.activeWorkflow?.previous()}_stashValidationState(){let e=this._formViewModel.feature,t=e&&this.data.getEditsForPendingFeature(e);t&&(t.submittable=this._formViewModel.submittable)}async _selectFeatureForUpdate({feature:e,initialFeature:t=e}){this._stashValidationState();let{data:n,pendingFeatures:r}=this;r.includes(e)||n.addPendingFeature(e,t),n.selectedPendingFeature=e;let{_formViewModel:a,_sketchViewModel:o,sketchUpdateOptions:c}=this,{creationInfo:l,viewModel:u}=n,{attachmentsViewModel:f,layerInfos:p,view:m}=u;if(!m||!l)return;B(o,c),s(this._featureFormHandle);let h=e.sourceLayer,g=V(p,h)?.formTemplate,_=m.spatialReference;a.set({editType:`INSERT`,feature:e,formTemplate:g,spatialReference:_,view:m}),(f.mode===`add`||f.mode===`edit`)&&await u.activeWorkflow?.previous(),f.graphic=e,f.fileInfos.removeAll(),f.mode=`view`,(this._attachmentFileInfos.get(e)||[]).forEach(({file:e,form:t})=>f.addFile(e,t)),await O(e,m.type===`2d`?m.scale:null);let v=n.getEditsForPendingFeature(e);this._featureFormHandle=i([a.on(`value-change`,async({fieldName:t,value:n})=>{if(v?.updateAttributes(a.getValues()),E(n)){let e=this._visualVariableAttributes;e.size&&!e.size.isUpdatingInteractively&&t===e.size.field&&e.size.setInitialValue(n),e.rotation&&!e.rotation.isUpdatingInteractively&&t===e.rotation.field&&e.rotation.setInitialValue(n)}await O(e,m.type===`2d`?m.scale:null)}),o.on([`update`,`undo`,`redo`],e=>{(e.type===`undo`||e.type===`redo`||e.type===`update`&&e.toolEventInfo!=null&&H(e.toolEventInfo.type))&&a.notifyFeatureGeometryChanged()}),d(()=>a.feature?.sourceLayer,t=>e.sourceLayer=t),d(()=>[a.feature,a.submittable],()=>this._stashValidationState())]),this.createFeatureState=`update-pending`}async _startUpdating({feature:e,initialFeature:t=e}){await this._selectFeatureForUpdate({feature:e,initialFeature:t});let{_sketchLayer:n,_sketchViewModel:r,data:i}=this,{creationInfo:a,viewModel:o}=i,{view:s}=o;if(!s||!a)return;let c=e.sourceLayer??a.layer;if(!T(c))return this._visualVariableAttributes=U(e),W({graphic:e,sketchLayer:n,sketchViewModel:r,sourceLayer:c,updateOptions:this.sketchUpdateOptions,visualVariables:this._visualVariableAttributes})}static _createWorkflowSteps(e,t=`awaiting-feature-creation-info`){let{data:n}=e,r=n.creationInfo?.layer,i=G([`awaiting-feature-creation-info`,`creating-features`,`adding-attachment`,`editing-attachment`],t,{"awaiting-feature-creation-info":()=>({id:`awaiting-feature-creation-info`,async setUp(){let{creationInfo:t,viewModel:i}=n,{view:a}=i;a&&(N(t)?e.addHandles(await ne({view:a,data:n,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(r&&e.addHandles(i.restrictFeatureTemplatesViewModelToLayer(r),this.id),e.addHandles(i.featureTemplatesViewModel.on(`select`,({item:t})=>{t&&(n.creationInfo={...n.creationInfo,layer:t.layer,template:t.template},e.next())}),this.id)))},async tearDown(){e.removeHandles(this.id)}}),"creating-features":()=>({id:`creating-features`,async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){let{viewModel:r}=n;t.canceled&&(e.removeHandles([Z,me,X,Q]),r.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear())}}),"adding-attachment":()=>({id:`adding-attachment`,parent:`creating-features`,async setUp(){},async tearDown(){let{attachmentsViewModel:t}=n.viewModel,{graphic:r,fileInfos:i}=t;e._attachmentFileInfos.set(r,i.toArray()),t.mode=`view`}}),"editing-attachment":()=>({id:`editing-attachment`,parent:`creating-features`,async setUp(){},async tearDown(){let{attachmentsViewModel:t}=n.viewModel,{graphic:r,fileInfos:i}=t;e._attachmentFileInfos.set(r,i.toArray()),t.mode=`view`}})});return K(n,i)}static _configureSketchViewModel(e){let{data:t,_sketchLayer:n,_sketchViewModel:a}=e,{creationInfo:o,viewModel:s}=t,{view:c}=s,l=[];if(!c)return r();if(c.type===`2d`){o&&l.push(e._fadeExistingFeatures(o.layer));let t=u((e,t)=>Promise.all(e.map(e=>O(e,t))));l.push(d(()=>c.scale,e=>t(n.graphics,e)))}let f=x(t.fullTemplate,o?.attributeOverrides,o?.layer),p=d(()=>a.createGraphic&&a.activeComponent,()=>{a.createGraphic&&a.activeComponent&&!e.hasHandles(X)&&e._updatingHandles.consumePromise(q({creationAttributes:f,data:t,sketchViewModel:a,view:c}).then(t=>e.addHandles(t,X)))}),m=async t=>{if((t.state===`cancel`||t.state===`complete`)&&e.removeHandles(X),t.state===`cancel`&&c.activeTool!==null&&c.activeTool!==e.sketchViewModel.activeComponent&&(await e._waitForActiveToolCleared(),await e._startCreating()),t.state===`complete`&&t.graphic){let n=await e._processEdits(t.graphic,{scale:c.type===`2d`?c.scale:null,useSourceLayer:!0});n&&(await e._waitForActiveToolCleared(),await e._startUpdating({feature:n}))}},h=async r=>{let{attachmentsViewModel:i}=s,{_formViewModel:l}=e;if(r.graphics.length>1){await e._clearSelectedFeature();return}let u=r.graphics[0];if(r.state===`complete`){let{submittable:t}=l;if((e.numPendingFeatures===o?.maxFeatures||!t)&&l.submit(),await e._clearSelectedFeature(),(i.mode===`add`||i.mode===`edit`)&&await s.activeWorkflow?.previous(),e.data.selectedPendingFeature==null&&(c.activeTool==null||c.activeTool===e.sketchViewModel.activeComponent)&&(await e.sketchViewModel.wait(),e.sketchViewModel.state===`ready`&&e.data.creationInfo?.layer.geometryType!==`mesh`))return e._startCreating()}else if(r.state===`start`)return u.sourceLayer??=t.creationInfo?.layer,await se({graphic:u,sketchLayer:n,sketchViewModel:a,visualVariables:e._visualVariableAttributes,sourceLayer:u.sourceLayer}),e._selectFeatureForUpdate({feature:u});else if(r.state===`active`){await e.updatePendingFeature(u);let t=e._visualVariableAttributes;ce(c,u,r,t)&&await O(u,c.type===`2d`?c.scale:null);let n=u.attributes,{rotation:i,size:a}=t;if(i!=null){let{field:e}=i;l.setValue(e,n[e])}if(a!=null){let{field:e}=a;l.setValue(e,n[e])}}},g=async n=>{if(n.graphics.forEach(e=>{t.removePendingFeature(e)}),!N(t.creationInfo))return e._startCreating()},_=async()=>{if(N(t.creationInfo))try{await e.data.viewModel.back()}catch{}return e._startCreating()};l.push(p,a.on(`create`,t=>e._updatingHandles.addPromise(m(t))),a.on(`update`,t=>e._updatingHandles.addPromise(h(t))),a.on(`delete`,t=>e._updatingHandles.addPromise(g(t))),e._updatingHandles.addWhen(()=>!e.numPendingFeatures,()=>e._updatingHandles.addPromise(_())),r(()=>{a.cancel()}),ge(a,n,t),..._e(t));let v=i(l);return a.addHandles(v),v}_initializeSketchViewModel(){let{data:e}=this,{view:t}=e.viewModel,n=new C({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:`hide`,title:`createFeaturesWorkflow-internal`}),i=new pe({layer:n,creationMode:`single`,sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,useLegacyCreateTools:e.viewModel.useLegacyCreateTools,updateOnGraphicClick:!1,defaultUpdateOptions:this.sketchUpdateOptions,view:t});this._sketchLayer=n,this._sketchViewModel=i,t?.map.add(n),this.addHandles([r(()=>{t?.destroyed||t?.map.remove(n),c(n)}),d(()=>this.numPendingFeatures>0,e=>this._sketchViewModel.updateOnGraphicClick=e,f),d(()=>this.sketchUpdateOptions,e=>{i.defaultUpdateOptions=e,B(i,e)},p)])}_hasValidationErrors(e){return e?!this.data.isSubmittable(e)||!!this._formViewModel.validateContingencyConstraints(e.attributes,{includeIncompleteViolations:!0})?.length:!1}async _processEdits(e,t){let{data:n,_formViewModel:r,_sketchLayer:i}=this,{layerInfos:a,view:o}=n.viewModel;r.editType=`INSERT`,r.spatialReference=o?.spatialReference,r.view=o;let{templateExecutorInfo:s}=n;if(!s){let t=e.clone();return t.geometry=null,await this._addAndInitializeEdits(e,t),e}i.remove(e);let{executor:c}=s,u=c(e.geometry,`completion`),d=l(u)?await u:u;s.completionResults.push(d),J(d.relationships),r.editType=`INSERT`,r.spatialReference=o?.spatialReference,r.view=o,d.primary&&n.creationInfo?.attributeOverrides&&(d.primary.graphic.attributes={...d.primary.graphic.attributes,...n.creationInfo.attributeOverrides});for(let e of d.edits){let n=null;if(e.addFeatures)for(let r of e.addFeatures){let e=r.clone();e.geometry=null,r.geometry!=null&&(r.symbol=await D(r,t),i.add(r)),r.sourceLayer!==n?.layer&&(n=V(a,r.sourceLayer));let o=!!d.associationGraphics?.has(r);await this._addAndInitializeEdits(r,e,n,o)}}return r.feature=null,await m(()=>!r.updating),d.edits.reduce((e,t)=>e+(t.addFeatures?.length??0),0)>1?null:d.primary?.graphic}async _addAndInitializeEdits(e,t,n,r=!1){let{data:i,_formViewModel:a}=this,{layerInfos:o}=i.viewModel,s=i.addPendingFeature(e,t,{isAssociation:r});n??=V(o,e.sourceLayer),a.feature=e,a.formTemplate=n?.formTemplate,await m(()=>!a.updating),s.updateAttributes(a.getValues()),s.submittable=a.submittable}async _setUpCreatingFeaturesStep(){if(this.hasHandles(Z))return;let{data:e,sketchViewModel:a}=this,{creationInfo:o,viewModel:c}=e,{attachmentsViewModel:l,view:u}=c;if(!u||!o?.layer)throw new n(`missing-parameters`,`CreateFeaturesWorkflow requires a view and creationInfo.`);let{initialFeature:p,layer:m}=o,h=[],g=[];this._featureFormHandle=s(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},e.editorItem=P(c.editorItems,o.layer),o.template&&(e.fullTemplate??await this._initializeFullTemplateAndExecutorInfo(e),g.push(r(()=>{e.templateExecutorInfo&&(e.templateExecutorInfo.completionResults=[])}))),a.allowDeleteKey=!e.isSharedTemplateWorkflow,de(l),h.push(d(()=>l.mode,e=>{switch(e){case`add`:this.go(`adding-attachment`);break;case`edit`:this.go(`editing-attachment`)}}));let _=oe(u);h.push(_);let v=T(o.layer),{template:b}=o,S=!b||ee(b)||y(b)&&b.type===`feature`,C=v&&S;try{if(C){let n=p??new t({attributes:x(e.fullTemplate,o.attributeOverrides,m),sourceLayer:m}),r=await this._processEdits(n);r&&await this._startUpdating({feature:r})}else h.push(Y._configureSketchViewModel(this)),p?(N(o)&&o.geometryToPlace&&(p.attributes=x(e.fullTemplate,o.attributeOverrides,m)),a.addGraphic(p),await this._startUpdating({feature:p})):await this._startCreating()}finally{_.remove()}let w=r(()=>{for(let t of e.pendingFeatures)a.removeGraphic(t),e.removePendingFeature(t)}),E=d(()=>u?.timeZone,e=>this.data.timeZone=e,f),D=r(()=>{N(o)&&c.cancelWorkflow({warnIfNoWorkflow:!1})});this._featureFormHandle&&h.push(this._featureFormHandle),this.addHandles(h,this._handleKeys.beforeCommit),this.addHandles(g,this._handleKeys.afterCommit),this.addHandles([r(()=>l.fileInfos.removeAll()),i(h),i(g),D,w,E],Z)}async _waitForActiveToolCleared(){let e=this.data.viewModel.view;if(e?.activeTool==null)return;let t=new AbortController;this.addHandles(a(t),Q),await m(()=>e?.activeTool==null,t.signal),t.abort()}};e([_()],$.prototype,`allowSave`,null),e([_()],$.prototype,`createFeatureState`,void 0),e([_()],$.prototype,`curveResizeDisabled`,null),e([_()],$.prototype,`curveUpdatesDisabled`,null),e([_()],$.prototype,`data`,void 0),e([_({constructOnly:!0})],$.prototype,`isNested`,void 0),e([_()],$.prototype,`formViewModel`,null),e([_()],$.prototype,`hasInvalidFormTemplate`,null),e([_()],$.prototype,`hasPendingEdits`,null),e([_()],$.prototype,`hasPreviousStep`,null),e([_()],$.prototype,`_getDrawMeshHelpMessage`,void 0),e([_()],$.prototype,`helpMessage`,null),e([_()],$.prototype,`noticeMessage`,null),e([_()],$.prototype,`layer`,null),e([_()],$.prototype,`parent`,null),e([_()],$.prototype,`keyboardCancellationEnabled`,null),e([_()],$.prototype,`reliesOnOwnerAdminPrivileges`,null),e([_()],$.prototype,`saveActionLabel`,null),e([_()],$.prototype,`shouldShowAttachments`,null),e([_()],$.prototype,`shouldAllowAttachmentEditing`,null),e([_()],$.prototype,`sketchUpdateOptions`,null),e([_()],$.prototype,`sketchViewModel`,null),e([_()],$.prototype,`availableCreateTools`,null),e([_()],$.prototype,`_attachmentsActive`,null),$=Y=e([v(`esri.widgets.Editor.legacy.CreateFeaturesWorkflow`)],$);function ge(e,t,n){let a=null,o=()=>e.snappingOptions.featureSources,s=()=>(a=new te({layer:t}),o().add(a),a),l=()=>{a!=null&&(o().remove(a),a=c(a))};return i([d(()=>{let e=n.creationInfo?.layer,t=o().find(t=>t.layer===e);return{hasFeatureLayerSource:!!t,enabled:t?.enabled??!1}},({hasFeatureLayerSource:e,enabled:t})=>{if(e)a??=s(),a.enabled=t;else return l()},h),r(l)])}function _e(e){let t=e.viewModel.view;if(!t)return[];let n=[];if(t.type===`3d`){let i=new A({view:t});n.push(d(()=>e.selectedPendingFeature,(e,t)=>{i.remove(e),i.add(t)}),r(()=>i.destroy()))}let i=new A({view:t,highlightName:M});return n.push(d(()=>e.temporaryHighlightFeature,e=>{i.removeAll(),i.add(e)}),r(()=>i.destroy())),n}function ve(e,t,n,r){let i=[];return t.forEach((t,a)=>{if(!t.error){let o=e[a],s=r.get(o)||[];o.attributes[n.objectIdField]=t.objectId,s.forEach(({form:e})=>i.push({feature:o,attachment:e}))}}),i}function ye(e){for(let t of e){let{sourceLayer:e}=t;e&&`globalIdField`in e&&e.globalIdField!=null&&(t.attributes[e.globalIdField]??=g())}}function be(e,t){let n=[];if(!t||t.size===0)return{addFeatures:e};for(let[e,r]of t)for(let{file:t}of r)n.push({feature:e,attachment:{globalId:g(),data:t}});return n.length?{addFeatures:e,addAttachments:n}:{addFeatures:e}}function xe(e,t){return e.map(e=>{let{addFeatures:n}=e;if(!n||n.length===0)return e;let r=[];for(let e of n){let n=t.get(e);if(n)for(let{file:t}of n)r.push({feature:e,attachment:{globalId:g(),data:t}})}return r.length?{...e,addAttachments:r}:e})}const Se=$;export{Se as default};
2
+ import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import n from"../../../core/Error.js";import{makeHandle as r,handlesGroup as i,abortHandle as a}from"../../../core/handleUtils.js";import"../../../core/has.js";import o from"../../../core/Logger.js";import{removeMaybe as s,destroyMaybe as c}from"../../../core/maybe.js";import{isPromiseLike as l,debounce as u}from"../../../core/promiseUtils.js";import{watch as d,initial as f,sync as p,whenOnce as m,syncAndInitial as h}from"../../../core/reactiveUtils.js";import{generateBracedUUID as g}from"../../../core/uuid.js";import{property as _,subclass as v}from"../../../core/accessorSupport/decorators.js";import{isSharedTemplateOrMetadata as y,isSharedTemplate as b,getCreationAttributes as x,isStandardFeatureTemplate as ee}from"../../../editing/templateUtils.js";import{getFullTemplate as S}from"../../../editing/sharedTemplates/templateLoader.js";import C from"../../../layers/GraphicsLayer.js";import{isSceneLayer as w,isTable as T}from"../../../layers/support/layerUtils.js";import{isNumber as E}from"../../../support/guards.js";import{getDisplayedSymbol as D}from"../../../symbols/support/symbolUtils.js";import{updateGraphicSymbolWhenRequired as O}from"../../../views/draw/support/editingSessionUtils.js";import{getDrawHelpMessage as k}from"../../../views/draw/support/helpMessageUtils.js";import A from"../../../views/draw/support/HighlightHelper.js";import j from"../../../views/interactive/sketch/SketchOptions.js";import te from"../../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as M}from"../../../views/support/HighlightDefaults.js";import{isModelUpload as N,handleModelUpload as ne}from"../modelUploadUtils.js";import{activeSketchToolDrawsUnsupportedCurve as re,createToolFromGeometryType as ie,containsUnsupportedCurve as ae,findEditorItemForLayer as P,getServiceEditsFromWorkflowData as F,getServiceInfoForLayer as I,orderEditsByRelationshipDependencies as L,getServiceLayersById as R,startCreatingNewFeature as z,syncUpdateOptions as B,findLayerInfo as V,isTerminalUpdateEventType as H,getVisualVariableAttributes as U,startUpdatingFeatureGeometry as W,createWorkflowSteps as G,avoidFeatureTemplateSelectionWithOnlyOneItem as K,setUpSketchCreateWatchers as q,setRelationshipFields as J,showProgressCursor as oe,setVisualVariablesAndElevationInfoForUpdate as se,visualVariableInteractiveUpdate as ce}from"../workflowUtils.js";import le from"./CreateFeaturesWorkflowData.js";import ue from"./Workflow.js";import{prepareAttachmentsForCreateFeaturesWorkflow as de}from"./workflowUtils.js";import fe from"../../FeatureForm/FeatureFormViewModel.js";import pe from"../../Sketch/SketchViewModel.js";var Y;const me=Symbol(),X=Symbol(),Z=Symbol(),Q=Symbol(),he={point:[`point`],multipoint:[`multipoint`],polygon:[`polygon`,`freehandPolygon`,`rectangle`,`circle`],polyline:[`polyline`,`freehandPolyline`],mesh:[],multipatch:[]};let $=Y=class extends ue{constructor(e){super(e),this.type=`create-features`,this.createFeatureState=`create-new`,this.data=void 0,this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._formViewModel=new fe,this._sketchLayer=null,this._sketchViewModel=null,this._attachmentFileInfos=new Map,this._isActive=!0}initialize(){this.isNested&&(this._isActive=!1),this._initializeSketchViewModel()}destroy(){this._sketchViewModel.destroy()}get allowSave(){return!this.updating}get curveResizeDisabled(){return this.data.curveResizeDisabled}get curveUpdatesDisabled(){return this.data.curveUpdatesDisabled}get formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return!!this.data.editorItem?.hasInvalidFormTemplate}get hasPendingEdits(){if(this.pendingFeatures.some(e=>!!this.data.getEditsForPendingFeature(e)?.modified))return!0;let{creationInfo:e,upload:t}=this.data,{activeComponent:n,createGraphic:r}=this._sketchViewModel,i=r?.geometry?.type;return!!((i===`polyline`||i===`polygon`||i===`multipoint`)&&(n?.type===`draw-2d`||n?.type===`draw-3d`)&&n.drawOperation.committedVertices.length>0||t&&(t.state===`pending`||t.state===`success`)||e?.geometryToPlace)}get hasPreviousStep(){return this._stepIndex>0||this.createFeatureState===`update-pending`&&!!this.data.selectedPendingFeature&&!this.parent&&!N(this.data.creationInfo)}get helpMessage(){let{creationInfo:e,viewModel:t}=this.data;if(this.stepId!==`creating-features`||!e)return;let{_sketchViewModel:n}=this,{drawTool:r,isUsingLegacyCreateTools:i}=n;if(!i)return r?.helpMessageKey??`noTool`;let a=e.layer.geometryType,o=n.createGraphic;if(a===`mesh`){this._getDrawMeshHelpMessage||import(`../../../views/draw/support/helpMessageUtils3d.js`).then(e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage});let{view:e}=t;return e?.type===`3d`?this._getDrawMeshHelpMessage?.(o,e):void 0}let{activeCreateToolDrawMode:s,activeTool:c}=n;return k(c===`rectangle`||c===`circle`?c:a,o?.geometry,s)}get noticeMessage(){if(re(this._sketchViewModel,this.data.editorItem))return`curveToolDensifyWarning`}get layer(){return this.data.creationInfo?.layer}get numPendingFeatures(){return this.pendingFeatures.length}get numPendingFeaturesExcludingHidden(){return this.pendingFeatures.filter(e=>this.data.isDisplayable(e)).length}get parent(){return this.data.parent}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return this.numPendingFeatures===0}get reliesOnOwnerAdminPrivileges(){return this.data.editorItem?.capabilities.create.reliesOnOwnerAdminPrivileges??!1}get saveActionLabel(){return`create`}get shouldShowAttachments(){return(this.data.selectedPendingFeature&&this.data.editorItem?.capabilities.create.attachments.enabled)??!1}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get sketchUpdateOptions(){let{editorItem:e}=this.data;return{enableScaling:!this.curveResizeDisabled,multipleSelectionEnabled:!1,reshapeOptions:{enableCreateCurveFromStraightEdge:!w(e?.layer)&&!!e?.capabilities.supportsTrueCurve}}}get sketchViewModel(){return this._sketchViewModel}get test(){}get availableCreateTools(){let e=this.data.creationInfo?.layer.geometryType,t=this.data.viewModel.view;if(!e||this.data.creationInfo?.maxFeatures&&this.data.creationInfo.maxFeatures<=this.numPendingFeatures)return[];if(y(this.data.fullTemplate)){let{tool:t}=ie(e,this.data.fullTemplate);return[t]}return t?.type!==`2d`&&e===`multipoint`?[]:[...he[e]]}get _attachmentsActive(){let e=this.data.viewModel.attachmentsViewModel.mode,t=this.stepId;return this.shouldShowAttachments&&(e===`add`||e===`edit`||t===`adding-attachment`||t===`editing-attachment`)}getUpdating(){return!!this._sketchViewModel?.updating}async enter(){this._isActive=!0,this.stepId!==`awaiting-feature-creation-info`&&await this._updatingHandles.addPromise(this._setUpCreatingFeaturesStep())}exit(){this._isActive=!1,this.removeHandles([Z])}async updatePendingFeature(e){if(e!==this.data.selectedPendingFeature)return this._sketchViewModel.cancel(),this._startUpdating({feature:e})}async start(){return await super.start(),T(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}async save(e){let{formViewModel:t}=this;if(t.pendingSubtypeChoice)return;t.submit(),this._stashValidationState();let n=this.data.selectedPendingFeature,r=this._hasValidationErrors(n)?n:this.data.pendingFeatures.find(e=>this._hasValidationErrors(e));if(r){await this._startUpdating({feature:r}),t?.submit();return}let{pendingFeatures:i,editorItem:a}=this.data;return a&&e&&ae(i.toArray(),a)&&!await e(`curveEditingDensifyPrompt`)?this.reset():super.save()}back(e){return this.createFeatureState===`update-pending`&&this.data.selectedPendingFeature&&!N(this.data.creationInfo)&&!this._attachmentsActive&&!this.parent?this._clearSelectedFeature():super.back(e)}previous(e){return this.createFeatureState===`update-pending`&&this.data.selectedPendingFeature&&!N(this.data.creationInfo)&&!this._attachmentsActive?this._clearSelectedFeature():super.previous(e)}cancelFeature(e){this.data.isSharedTemplateWorkflow?o.getLogger(this).warn(`Cannot cancel individual features created by shared templates.`):(this.data.removePendingFeature(e),this.sketchViewModel.removeGraphic(e))}static create(e){let{addAttachmentsCallback:t,applyEdits:n,applyEditsFeatureService:r,isNested:i,creationInfo:a,parent:o,snappingManager:s,startAt:c,viewModel:l}=e,u=e.sketchOptions??new j,d=a?.layer,f=d?P(l.editorItems,d):void 0,p=new Y({data:new le({creationInfo:a,editorItem:f,parent:o,sketchOptions:u,snappingManager:s,viewModel:l}),isNested:i,onCommit:async e=>{let{creationInfo:i}=e;if(!i)return;p._sketchViewModel.cancel();let a=e.pendingFeatures.toArray(),{layer:o}=i,s=o.capabilities?.editing.supportsGlobalId&&`globalIdField`in o,c=p._attachmentFileInfos,{fullTemplate:u}=e,d=F(p.data),f=b(u)&&d;if(s){if(ye(a),f){let t=xe(d,c),n=await I(o,l.view)?.load();n&&(t=L({edits:t,serviceInfo:n,view:l.view,findOriginalFeature:t=>e.getEditsForPendingFeature(t)?.initialFeature??t})),await r(u.featureService,t,{globalIdUsed:!0,honorSequenceOfEdits:!0,gdbVersion:u.layer.gdbVersion??void 0})}else{let e=be(a,c);await n(o,e,{globalIdUsed:!0})}return}let m=f?await r(u.featureService,d,{gdbVersion:u.layer.gdbVersion??void 0}):[await n(o,{addFeatures:a})];m&&c.size>0&&await Promise.all(m.map(e=>{if(e?.addFeatureResults)return t(o,ve(a,e.addFeatureResults,o,c))}))}});return p._set(`steps`,this._createWorkflowSteps(p,c)),p}_fadeExistingFeatures(e){if(`effect`in e){let t=e.effect;return e.effect=`saturate(0.6) opacity(0.8)`,r(()=>e.effect=t)}let t=e.opacity;return e.opacity=.7,r(()=>e.opacity=t)}async _initializeFullTemplateAndExecutorInfo(e){let{creationInfo:t}=e,{view:n}=e.viewModel;if(!t||!n)return null;let r=await S(n,t.template);if(e.fullTemplate=r,r&&b(r)){let{createTemplateExecutor:i}=await import(`../../../editing/sharedTemplates/executor/createTemplateExecutor.js`);e.templateExecutorInfo={completionResults:[],executor:await i(r),serviceLayersById:R(t.layer,n)}}return r}async _startCreating(){this.removeHandles(X);let{data:e}=this;if(!e.creationInfo)return;let t=this.data.creationInfo?.maxFeatures;t&&this.numPendingFeatures>=t?(this.sketchViewModel.cancel(),this.numPendingFeatures&&await this._startUpdating({feature:this.pendingFeatures.at(-1)})):(this.createFeatureState=`create-new`,await z(this._sketchViewModel,this._sketchLayer,e))}async _clearSelectedFeature(){let e=this._formViewModel.pendingSubtypeChoice;e&&(e.resolve(`undo`),await e.promise),this._stashValidationState(),this.sketchViewModel.cancel(),this.data.selectedPendingFeature=null,this._featureFormHandle=s(this._featureFormHandle),this._formViewModel.feature=null;let t=this.data.viewModel.attachmentsViewModel;(t.mode===`add`||t.mode===`edit`)&&await this.data.viewModel.activeWorkflow?.previous()}_stashValidationState(){let e=this._formViewModel.feature,t=e&&this.data.getEditsForPendingFeature(e);t&&(t.submittable=this._formViewModel.submittable)}async _selectFeatureForUpdate({feature:e,initialFeature:t=e}){this._stashValidationState();let{data:n,pendingFeatures:r}=this;r.includes(e)||n.addPendingFeature(e,t),n.selectedPendingFeature=e;let{_formViewModel:a,_sketchViewModel:o,sketchUpdateOptions:c}=this,{creationInfo:l,viewModel:u}=n,{attachmentsViewModel:f,layerInfos:p,view:m}=u;if(!m||!l)return;B(o,c),s(this._featureFormHandle);let h=e.sourceLayer,g=V(p,h)?.formTemplate,_=m.spatialReference;a.set({editType:`INSERT`,feature:e,formTemplate:g,spatialReference:_,view:m}),(f.mode===`add`||f.mode===`edit`)&&await u.activeWorkflow?.previous(),f.graphic=e,f.fileInfos.removeAll(),f.mode=`view`,(this._attachmentFileInfos.get(e)||[]).forEach(({file:e,form:t})=>f.addFile(e,t)),await O(e,m.type===`2d`?m.scale:null);let v=n.getEditsForPendingFeature(e);this._featureFormHandle=i([a.on(`value-change`,async({fieldName:t,value:n})=>{if(v?.updateAttributes(a.getValues()),E(n)){let e=this._visualVariableAttributes;e.size&&!e.size.isUpdatingInteractively&&t===e.size.field&&e.size.setInitialValue(n),e.rotation&&!e.rotation.isUpdatingInteractively&&t===e.rotation.field&&e.rotation.setInitialValue(n)}await O(e,m.type===`2d`?m.scale:null)}),o.on([`update`,`undo`,`redo`],e=>{(e.type===`undo`||e.type===`redo`||e.type===`update`&&e.toolEventInfo!=null&&H(e.toolEventInfo.type))&&a.notifyFeatureGeometryChanged()}),d(()=>a.feature?.sourceLayer,t=>e.sourceLayer=t),d(()=>[a.feature,a.submittable],()=>this._stashValidationState())]),this.createFeatureState=`update-pending`}async _startUpdating({feature:e,initialFeature:t=e}){await this._selectFeatureForUpdate({feature:e,initialFeature:t});let{_sketchLayer:n,_sketchViewModel:r,data:i}=this,{creationInfo:a,viewModel:o}=i,{view:s}=o;if(!s||!a)return;let c=e.sourceLayer??a.layer;if(!T(c))return this._visualVariableAttributes=U(e),W({graphic:e,sketchLayer:n,sketchViewModel:r,sourceLayer:c,updateOptions:this.sketchUpdateOptions,visualVariables:this._visualVariableAttributes})}static _createWorkflowSteps(e,t=`awaiting-feature-creation-info`){let{data:n}=e,r=n.creationInfo?.layer,i=G([`awaiting-feature-creation-info`,`creating-features`,`adding-attachment`,`editing-attachment`],t,{"awaiting-feature-creation-info":()=>({id:`awaiting-feature-creation-info`,async setUp(){let{creationInfo:t,viewModel:i}=n,{view:a}=i;a&&(N(t)?e.addHandles(await ne({view:a,data:n,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(r&&e.addHandles(i.restrictFeatureTemplatesViewModelToLayer(r),this.id),e.addHandles(i.featureTemplatesViewModel.on(`select`,({item:t})=>{t&&(n.creationInfo={...n.creationInfo,layer:t.layer,template:t.template},e.next())}),this.id)))},async tearDown(){e.removeHandles(this.id)}}),"creating-features":()=>({id:`creating-features`,async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){let{viewModel:r}=n;t.canceled&&(e.removeHandles([Z,me,X,Q]),r.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear())}}),"adding-attachment":()=>({id:`adding-attachment`,parent:`creating-features`,async setUp(){},async tearDown(){let{attachmentsViewModel:t}=n.viewModel,{graphic:r,fileInfos:i}=t;e._attachmentFileInfos.set(r,i.toArray()),t.mode=`view`}}),"editing-attachment":()=>({id:`editing-attachment`,parent:`creating-features`,async setUp(){},async tearDown(){let{attachmentsViewModel:t}=n.viewModel,{graphic:r,fileInfos:i}=t;e._attachmentFileInfos.set(r,i.toArray()),t.mode=`view`}})});return K(n,i)}static _configureSketchViewModel(e){let{data:t,_sketchLayer:n,_sketchViewModel:a}=e,{creationInfo:o,viewModel:s}=t,{view:c}=s,l=[];if(!c)return r();if(c.type===`2d`){o&&l.push(e._fadeExistingFeatures(o.layer));let t=u((e,t)=>Promise.all(e.map(e=>O(e,t))));l.push(d(()=>c.scale,e=>t(n.graphics,e)))}let f=x(t.fullTemplate,o?.attributeOverrides,o?.layer),p=d(()=>a.createGraphic&&a.activeComponent,()=>{a.createGraphic&&a.activeComponent&&!e.hasHandles(X)&&e._updatingHandles.consumePromise(q({creationAttributes:f,data:t,sketchViewModel:a,view:c}).then(t=>e.addHandles(t,X)))}),m=async t=>{if((t.state===`cancel`||t.state===`complete`)&&e.removeHandles(X),t.state===`cancel`&&c.activeTool!==null&&c.activeTool!==e.sketchViewModel.activeComponent&&(await e._waitForActiveToolCleared(),await e._startCreating()),t.state===`complete`&&t.graphic){let n=await e._processEdits(t.graphic,{scale:c.type===`2d`?c.scale:null,useSourceLayer:!0});n&&(await e._waitForActiveToolCleared(),await e._startUpdating({feature:n}))}},h=async r=>{let{attachmentsViewModel:i}=s,{_formViewModel:l}=e;if(r.graphics.length>1){await e._clearSelectedFeature();return}let u=r.graphics[0];if(r.state===`complete`){let{submittable:t}=l;if(e.numPendingFeatures!==o?.maxFeatures&&t||l.submit(),await e._clearSelectedFeature(),(i.mode===`add`||i.mode===`edit`)&&await s.activeWorkflow?.previous(),e.data.selectedPendingFeature==null&&(c.activeTool==null||c.activeTool===e.sketchViewModel.activeComponent)&&(await e.sketchViewModel.wait(),e.sketchViewModel.state===`ready`&&e.data.creationInfo?.layer.geometryType!==`mesh`))return e._startCreating()}else if(r.state===`start`)return u.sourceLayer??=t.creationInfo?.layer,await se({graphic:u,sketchLayer:n,sketchViewModel:a,visualVariables:e._visualVariableAttributes,sourceLayer:u.sourceLayer}),e._selectFeatureForUpdate({feature:u});else if(r.state===`active`){await e.updatePendingFeature(u);let t=e._visualVariableAttributes;ce(c,u,r,t)&&await O(u,c.type===`2d`?c.scale:null);let n=u.attributes,{rotation:i,size:a}=t;if(i!=null){let{field:e}=i;l.setValue(e,n[e])}if(a!=null){let{field:e}=a;l.setValue(e,n[e])}}},g=async n=>{if(n.graphics.forEach(e=>{t.removePendingFeature(e)}),!N(t.creationInfo))return e._startCreating()},_=async()=>{if(N(t.creationInfo))try{await e.data.viewModel.back()}catch{}return e._startCreating()};l.push(p,a.on(`create`,t=>e._updatingHandles.addPromise(m(t))),a.on(`update`,t=>e._updatingHandles.addPromise(h(t))),a.on(`delete`,t=>e._updatingHandles.addPromise(g(t))),e._updatingHandles.addWhen(()=>!e.numPendingFeatures,()=>e._updatingHandles.addPromise(_())),r(()=>{a.cancel()}),ge(a,n,t),..._e(t));let v=i(l);return a.addHandles(v),v}_initializeSketchViewModel(){let{data:e}=this,{view:t}=e.viewModel,n=new C({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:`hide`,title:`createFeaturesWorkflow-internal`}),i=new pe({layer:n,creationMode:`single`,sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,useLegacyCreateTools:e.viewModel.useLegacyCreateTools,updateOnGraphicClick:!1,defaultUpdateOptions:this.sketchUpdateOptions,view:t});this._sketchLayer=n,this._sketchViewModel=i,t?.map.add(n),this.addHandles([r(()=>{t?.destroyed||t?.map.remove(n),c(n)}),d(()=>this.numPendingFeatures>0,e=>this._sketchViewModel.updateOnGraphicClick=e,f),d(()=>this.sketchUpdateOptions,e=>{i.defaultUpdateOptions=e,B(i,e)},p)])}_hasValidationErrors(e){return e?!this.data.isSubmittable(e)||!!this._formViewModel.validateContingencyConstraints(e.attributes,{includeIncompleteViolations:!0})?.length:!1}async _processEdits(e,t){let{data:n,_formViewModel:r,_sketchLayer:i}=this,{layerInfos:a,view:o}=n.viewModel;r.editType=`INSERT`,r.spatialReference=o?.spatialReference,r.view=o;let{templateExecutorInfo:s}=n;if(!s){let t=e.clone();return t.geometry=null,await this._addAndInitializeEdits(e,t),e}i.remove(e);let{executor:c}=s,u=c(e.geometry,`completion`),d=l(u)?await u:u;s.completionResults.push(d),J(d.relationships),r.editType=`INSERT`,r.spatialReference=o?.spatialReference,r.view=o,d.primary&&n.creationInfo?.attributeOverrides&&(d.primary.graphic.attributes={...d.primary.graphic.attributes,...n.creationInfo.attributeOverrides});for(let e of d.edits){let n=null;if(e.addFeatures)for(let r of e.addFeatures){let e=r.clone();e.geometry=null,r.geometry!=null&&(r.symbol=await D(r,t),i.add(r)),r.sourceLayer!==n?.layer&&(n=V(a,r.sourceLayer));let o=!!d.associationGraphics?.has(r);await this._addAndInitializeEdits(r,e,n,o)}}return r.feature=null,await m(()=>!r.updating),d.edits.reduce((e,t)=>e+(t.addFeatures?.length??0),0)>1?null:d.primary?.graphic}async _addAndInitializeEdits(e,t,n,r=!1){let{data:i,_formViewModel:a}=this,{layerInfos:o}=i.viewModel,s=i.addPendingFeature(e,t,{isAssociation:r});n??=V(o,e.sourceLayer),a.feature=e,a.formTemplate=n?.formTemplate,await m(()=>!a.updating),s.updateAttributes(a.getValues()),s.submittable=a.submittable}async _setUpCreatingFeaturesStep(){if(this.hasHandles(Z))return;let{data:e,sketchViewModel:a}=this,{creationInfo:o,viewModel:c}=e,{attachmentsViewModel:l,view:u}=c;if(!u||!o?.layer)throw new n(`missing-parameters`,`CreateFeaturesWorkflow requires a view and creationInfo.`);let{initialFeature:p,layer:m}=o,h=[],g=[];this._featureFormHandle=s(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},e.editorItem=P(c.editorItems,o.layer),o.template&&(e.fullTemplate??await this._initializeFullTemplateAndExecutorInfo(e),g.push(r(()=>{e.templateExecutorInfo&&(e.templateExecutorInfo.completionResults=[])}))),a.allowDeleteKey=!e.isSharedTemplateWorkflow,de(l),h.push(d(()=>l.mode,e=>{switch(e){case`add`:this.go(`adding-attachment`);break;case`edit`:this.go(`editing-attachment`)}}));let _=oe(u);h.push(_);let v=T(o.layer),{template:b}=o,S=!b||ee(b)||y(b)&&b.type===`feature`,C=v&&S;try{if(C){let n=p??new t({attributes:x(e.fullTemplate,o.attributeOverrides,m),sourceLayer:m}),r=await this._processEdits(n);r&&await this._startUpdating({feature:r})}else h.push(Y._configureSketchViewModel(this)),p?(N(o)&&o.geometryToPlace&&(p.attributes=x(e.fullTemplate,o.attributeOverrides,m)),a.addGraphic(p),await this._startUpdating({feature:p})):await this._startCreating()}finally{_.remove()}let w=r(()=>{for(let t of e.pendingFeatures)a.removeGraphic(t),e.removePendingFeature(t)}),E=d(()=>u?.timeZone,e=>this.data.timeZone=e,f),D=r(()=>{N(o)&&c.cancelWorkflow({warnIfNoWorkflow:!1})});this._featureFormHandle&&h.push(this._featureFormHandle),this.addHandles(h,this._handleKeys.beforeCommit),this.addHandles(g,this._handleKeys.afterCommit),this.addHandles([r(()=>l.fileInfos.removeAll()),i(h),i(g),D,w,E],Z)}async _waitForActiveToolCleared(){let e=this.data.viewModel.view;if(e?.activeTool==null)return;let t=new AbortController;this.addHandles(a(t),Q),await m(()=>e?.activeTool==null,t.signal),t.abort()}};e([_()],$.prototype,`allowSave`,null),e([_()],$.prototype,`createFeatureState`,void 0),e([_()],$.prototype,`curveResizeDisabled`,null),e([_()],$.prototype,`curveUpdatesDisabled`,null),e([_()],$.prototype,`data`,void 0),e([_({constructOnly:!0})],$.prototype,`isNested`,void 0),e([_()],$.prototype,`formViewModel`,null),e([_()],$.prototype,`hasInvalidFormTemplate`,null),e([_()],$.prototype,`hasPendingEdits`,null),e([_()],$.prototype,`hasPreviousStep`,null),e([_()],$.prototype,`_getDrawMeshHelpMessage`,void 0),e([_()],$.prototype,`helpMessage`,null),e([_()],$.prototype,`noticeMessage`,null),e([_()],$.prototype,`layer`,null),e([_()],$.prototype,`parent`,null),e([_()],$.prototype,`keyboardCancellationEnabled`,null),e([_()],$.prototype,`reliesOnOwnerAdminPrivileges`,null),e([_()],$.prototype,`saveActionLabel`,null),e([_()],$.prototype,`shouldShowAttachments`,null),e([_()],$.prototype,`shouldAllowAttachmentEditing`,null),e([_()],$.prototype,`sketchUpdateOptions`,null),e([_()],$.prototype,`sketchViewModel`,null),e([_()],$.prototype,`availableCreateTools`,null),e([_()],$.prototype,`_attachmentsActive`,null),$=Y=e([v(`esri.widgets.Editor.legacy.CreateFeaturesWorkflow`)],$);function ge(e,t,n){let a=null,o=()=>e.snappingOptions.featureSources,s=()=>(a=new te({layer:t}),o().add(a),a),l=()=>{a!=null&&(o().remove(a),a=c(a))};return i([d(()=>{let e=n.creationInfo?.layer,t=o().find(t=>t.layer===e);return{hasFeatureLayerSource:!!t,enabled:t?.enabled??!1}},({hasFeatureLayerSource:e,enabled:t})=>{if(e)a??=s(),a.enabled=t;else return l()},h),r(l)])}function _e(e){let t=e.viewModel.view;if(!t)return[];let n=[];if(t.type===`3d`){let i=new A({view:t});n.push(d(()=>e.selectedPendingFeature,(e,t)=>{i.remove(e),i.add(t)}),r(()=>i.destroy()))}let i=new A({view:t,highlightName:M});return n.push(d(()=>e.temporaryHighlightFeature,e=>{i.removeAll(),i.add(e)}),r(()=>i.destroy())),n}function ve(e,t,n,r){let i=[];return t.forEach((t,a)=>{if(!t.error){let o=e[a],s=r.get(o)||[];o.attributes[n.objectIdField]=t.objectId,s.forEach(({form:e})=>i.push({feature:o,attachment:e}))}}),i}function ye(e){for(let t of e){let{sourceLayer:e}=t;e&&`globalIdField`in e&&e.globalIdField!=null&&(t.attributes[e.globalIdField]??=g())}}function be(e,t){let n=[];if(!t||t.size===0)return{addFeatures:e};for(let[e,r]of t)for(let{file:t}of r)n.push({feature:e,attachment:{globalId:g(),data:t}});return n.length?{addFeatures:e,addAttachments:n}:{addFeatures:e}}function xe(e,t){return e.map(e=>{let{addFeatures:n}=e;if(!n||n.length===0)return e;let r=[];for(let e of n){let n=t.get(e);if(n)for(let{file:t}of n)r.push({feature:e,attachment:{globalId:g(),data:t}})}return r.length?{...e,addAttachments:r}:e})}const Se=$;export{Se as default};
@@ -15,7 +15,7 @@ import type { MapViewOrSceneView } from "../views/MapViewOrSceneView.js";
15
15
  import type { SelectionToolName } from "../views/selection/types.js";
16
16
  import type { WidgetProperties } from "./Widget.js";
17
17
  import type { EditorViewModelEvents, EditorViewModelProperties } from "./Editor/EditorViewModel.js";
18
- import type { CancelWorkflowOptions, CreationInfo, EditorStartCreateFeaturesWorkflowAtFeatureEditParameters, EditorStartCreateFeaturesWorkflowAtFeatureTypeSelectionParameters, EditorStartMergeFeaturesWorkflowOptions, EditorStartSplitFeatureWorkflowOptions, FeatureInfo, LayerInfo, SupportingWidgetDefaults } from "./Editor/types.js";
18
+ import type { CancelWorkflowOptions, CreationInfo, EditorStartCreateFeaturesWorkflowAtFeatureEditParameters as EditorStartCreateFeaturesWorkflowAtFeatureEditParametersExternal, EditorStartCreateFeaturesWorkflowAtFeatureTypeSelectionParameters, EditorStartMergeFeaturesWorkflowOptions as EditorStartMergeFeaturesWorkflowOptionExternal, EditorStartSplitFeatureWorkflowOptions as EditorStartSplitFeatureWorkflowOptionsExternal, FeatureInfo, LayerInfo, SupportingWidgetDefaults } from "./Editor/types.js";
19
19
  import type { HeadingLevel } from "./support/types.js";
20
20
  import type { SketchLabelOptionsProperties } from "../views/interactive/sketch/SketchLabelOptions.js";
21
21
  import type { SnappingOptionsProperties } from "../views/interactive/snapping/SnappingOptions.js";
@@ -102,6 +102,15 @@ export interface EditorProperties extends WidgetProperties, Partial<Pick<Editor,
102
102
  visibleElements?: VisibleElementsProperties;
103
103
  }
104
104
 
105
+ /** @deprecated since version 5.2. Import { EditorStartCreateFeaturesWorkflowAtFeatureEditParameters } from "@arcgis/core/widgets/Editor/types" instead. */
106
+ export type EditorStartCreateFeaturesWorkflowAtFeatureEditParameters = EditorStartCreateFeaturesWorkflowAtFeatureEditParametersExternal;
107
+
108
+ /** @deprecated since version 5.2. Import { EditorStartMergeFeaturesWorkflowOptions } from "@arcgis/core/widgets/Editor/types" instead. */
109
+ export type EditorStartMergeFeaturesWorkflowOptions = EditorStartMergeFeaturesWorkflowOptionExternal;
110
+
111
+ /** @deprecated since version 5.2. Import { EditorStartSplitFeatureWorkflowOptions } from "@arcgis/core/widgets/Editor/types" instead. */
112
+ export type EditorStartSplitFeatureWorkflowOptions = EditorStartSplitFeatureWorkflowOptionsExternal;
113
+
105
114
  /** @deprecated since version 5.0. Use the [Editor](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-editor/) component instead. For information on widget deprecation, read about [Esri's move to web components](https://developers.arcgis.com/javascript/latest/components-transition-plan/). */
106
115
  export interface EditorEvents extends EditorViewModelEvents {}
107
116
 
@@ -1,3 +1,3 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import*as e from"@amcharts/amcharts5/index.js";import{XYChart as t,ValueAxis as n,AxisRendererX as r,AxisRendererY as i,XYCursor as a,LineSeries as o}from"@amcharts/amcharts5/xy.js";import s from"@amcharts/amcharts5/themes/Dark.js";import c from"@amcharts/amcharts5/themes/Responsive.js";import{formatNumber as l,substitute as u}from"../../../intl.js";import{handlesGroup as d,makeHandle as f}from"../../../core/handleUtils.js";import"../../../core/has.js";import{throwIfAborted as p}from"../../../core/promiseUtils.js";import{signal as m}from"../../../core/signal.js";import{unitName as h,formatDecimal as g}from"../../../core/unitFormatUtils.js";import{convertUnit as _}from"../../../core/units.js";import{getEpsilon as v}from"../../../core/libs/gl-matrix-2/math/common.js";import{isDarkMode as ee}from"../../../support/modeUtils.js";import{getConfig as y,notAvailable as b}from"./constants.js";import{getTranslatedLineTitle as x}from"./intlUtils.js";import{niceScale as S}from"./niceScale.js";import{binaryFindClosest as te}from"./profileUtils.js";import{createRoot as ne}from"../../support/chartUtilsAm5.js";import{isRTL as C}from"../../support/widget.js";const w=`#f8f8f8`,T=`#a9a9a9`,E=`#323232`,D=.001,O={fontFamily:`Avenir Next`,paddingBottom:6,paddingLeft:0,paddingRight:0,paddingTop:0,axisGridStroke:`#f4f4f4`,axisLabelsFontSize:9,axisLabelsFontWeight:`400`,axisLabelsColor:T,axisTooltipFontSize:12,axisTooltipBackgroundColor:E,axisTooltipLabelColor:w,axisTooltipPaddingTop:3,axisTooltipPaddingBottom:3,axisTooltipPaddingHorizontal:4,xAxisMinGridDistance:50,xAxisLabelsSpacing:6,xAxisMinLabelPosition:.05,xAxisMaxLabelPosition:.9,yAxisMinGridDistance:30,yAxisLabelSpacing:4,yAxisMinLabelPosition:0,yAxisMaxLabelPosition:.8,seriesTooltipFontSize:12,seriesTooltipBackgroundColor:w,seriesTooltipLabelColor:E,seriesFillLighten:.9,seriesTooltipSpacing:6,seriesTooltipPaddingVertical:4,seriesTooltipPaddingHorizontal:4},k={...O,axisGridStroke:E,axisLabelsColor:T,axisTooltipBackgroundColor:E,axisTooltipLabelColor:w,seriesTooltipBackgroundColor:E,seriesTooltipLabelColor:w,seriesFillLighten:-.75},A={minX:void 0,maxX:void 0,minY:void 0,maxY:void 0};async function re(e){let a=await ne(e.container);p(e.abortOptions);let o=ee(e.container),l=o?k:O;a.setThemes(o?[c.new(a),s.new(a)]:[c.new(a)]);let u=C(e.container),f=a.container.children.push(t.new(a,{panX:!0,panY:!0,paddingTop:l.paddingTop,paddingBottom:l.paddingBottom,paddingLeft:u?l.paddingRight:l.paddingLeft,paddingRight:u?l.paddingLeft:l.paddingRight,maxTooltipDistance:-1}));f.zoomOutButton.set(`forceHidden`,!0);let h=f.xAxes.push(n.new(a,{renderer:r.new(a,{})})),g=f.yAxes.push(n.new(a,{renderer:i.new(a,{})})),_=m(null),v=m(`loading`),y={params:e,chart:f,xAxis:h,yAxis:g,seriesInfos:new Map,messages:null,theme:l,pointerIsOver:!1,rtl:u,onCursorPositionChange:e.onCursorPositionChange,onRangeChange:e.onRangeChange,get state(){return v.value},get data(){return _.value},set data(e){_.value=e}};N(y),ie(y),M(y);let b=d([U(y),G(y),$(a.events.once(`frameended`,()=>{v.value=`ready`})),$(a)]),x;return{destroy:()=>{b.remove(),v.value=`destroyed`},update:e=>{(e.data!==y.data||e.messages!==y.messages)&&(j(y)||ae(y,e))},zoomOut:()=>P(y),test:x}}function j(e){return e.state===`destroyed`}function M({chart:e,xAxis:t,yAxis:n}){let r=a.new(e.root,{behavior:`none`,xAxis:t,yAxis:n,snapToSeriesBy:`y`});r.lineY.set(`visible`,!1),e.set(`cursor`,r)}function N(t){let{chart:n,xAxis:r,theme:i}=t;r.setAll({extraMax:0,extraMin:0,maxDeviation:0,numberFormatter:J(t,`distance`),strictMinMax:!0,strictMinMaxSelection:!0}),r.axisHeader.set(`forceHidden`,!0);let a=r.get(`renderer`);a.setAll({inside:!1,minGridDistance:i.xAxisMinGridDistance}),a.labels.template.setAll({centerX:e.p0,centerY:e.p0,fill:e.color(i.axisLabelsColor),fontFamily:i.fontFamily,fontSize:i.axisLabelsFontSize,fontWeight:i.axisLabelsFontWeight,maxPosition:i.xAxisMaxLabelPosition,minPosition:i.xAxisMinLabelPosition,paddingLeft:0,paddingRight:0,paddingTop:i.xAxisLabelsSpacing});let o=r.set(`tooltip`,e.Tooltip.new(n.root,{paddingBottom:0,paddingLeft:0,paddingRight:0,paddingTop:0}));o.get(`background`)?.setAll({fill:e.color(i.axisTooltipBackgroundColor),stroke:void 0}),o.label.setAll({fill:e.color(i.axisTooltipLabelColor),fontFamily:i.fontFamily,fontSize:i.axisTooltipFontSize,paddingBottom:i.axisTooltipPaddingBottom,paddingLeft:i.axisTooltipPaddingHorizontal,paddingRight:i.axisTooltipPaddingHorizontal,paddingTop:i.axisTooltipPaddingTop,direction:t.rtl?`rtl`:`ltr`}),a.grid.template.setAll({strokeOpacity:1,stroke:e.color(i.axisGridStroke)})}function ie(t){let{yAxis:n,theme:r,rtl:i}=t;n.setAll({baseValue:y().noDataValue,extraMax:0,extraMin:0,maxDeviation:0,numberFormatter:J(t,`elevation`),strictMinMax:!0,strictMinMaxSelection:!0,tooltip:void 0}),n.axisHeader.set(`visible`,!1);let a=n.get(`renderer`);a.setAll({minGridDistance:r.yAxisMinGridDistance,opposite:i,inside:!0}),a.labels.template.setAll({centerX:e.p0,centerY:e.p100,fill:e.color(r.axisLabelsColor),fontFamily:r.fontFamily,fontSize:r.axisLabelsFontSize,fontWeight:r.axisLabelsFontWeight,maxPosition:r.yAxisMaxLabelPosition,minPosition:r.yAxisMinLabelPosition,paddingBottom:0,paddingLeft:i?0:r.yAxisLabelSpacing,paddingRight:i?r.yAxisLabelSpacing:0,paddingTop:0,textAlign:`start`}),a.grid.template.setAll({strokeOpacity:1,stroke:e.color(r.axisGridStroke)})}function ae(e,t){if(j(e))return;let n=e.data??void 0,r=t.data??void 0,i=n!==r,a=n?.effectiveUnits!==r?.effectiveUnits,o=n?.uniformScaling!==r?.uniformScaling;e.data=r,e.messages=t.messages,(i||a)&&(oe(e),R(e)),o&&P(e),K(e)}function P(e){j(e)||(e.xAxis.zoom(0,1),e.yAxis.zoom(0,1))}function oe(e){let{chart:t,data:n,xAxis:r,yAxis:i}=e,{minX:a,maxX:o,minY:s,maxY:c}=F({data:n,pixelWidth:r.width(),pixelHeight:i.height()}),l=!!n?.uniformScaling,u=!!n?.refined;t.setAll({panX:!0,panY:l,pinchZoomX:u,pinchZoomY:u&&l,wheelX:`panX`,wheelY:u?l?`zoomXY`:`zoomX`:`none`}),r.setAll({max:o,min:a,panX:!0,panY:!1,zoomX:!0,zoomY:l}),i.setAll({max:c,min:s,panX:!1,panY:l,zoomX:l,zoomY:l})}function F({data:e,pixelWidth:t,pixelHeight:n}){if(e==null)return A;let r=e.statistics,i=r?.maxDistance,a=r?.minElevation,o=r?.maxElevation;if(i==null||a==null||o==null)return A;let s=Math.max(i-0,D),c=Math.max(o-a,D),l=e.effectiveUnits;if(e.dynamicElevationRange){let e=_(s,l.distance,l.elevation);c=Math.max(c,e/y().maxChartRatio)}return a-=.02*c,o=a+c+.1*c,[a,o]=S(a,o,10),c=o-a,e.uniformScaling?I({data:e,bounds:{minX:0,maxX:i,minY:a,maxY:o},pixelWidth:t,pixelHeight:n,centered:!0}):{minX:0,maxX:0+s,minY:a,maxY:a+c}}function I({data:e,bounds:t,pixelWidth:n,pixelHeight:r,centered:i}){if(e==null)return t;let{minX:a,maxX:o,minY:s,maxY:c}=t;if(a==null||o==null||s==null||c==null)return A;let l=o-a,u=c-s,d=e.effectiveUnits,f=_(u,d.elevation,d.distance),p=l/n,m=f/r/p;return m>=1?[a,o]=L([a,o],m):[s,c]=L([s,c],1/m),{minX:a,maxX:o,minY:s,maxY:c}}function L([e,t],n,r){let i=(t-e)*n;{let n=(e+t)/2-i/2;return[n,n+i]}}function R(e){let{chart:t,data:n,seriesInfos:r,xAxis:i,yAxis:a}=e;if(n==null||n.lines.length===0){t.series.clear();return}let o=new Map,s=new Set(t.series.values),c=n.lines.length;for(let i=0;i<c;i++){let a=n.lines[i],l=r.get(a.id);l?(l.fill&&s.delete(l.fill),s.delete(l.line)):(l=B(e,a),l.fill&&t.series.push(l.fill),t.series.push(l.line)),o.set(l.id,l);let u=c-i-1;l.fill?.set(`layer`,u),l.line.set(`layer`,c+u),z(e,l,a)}e.seriesInfos=o;for(let e of s)t.series.removeValue(e);i.set(`layer`,c+1),a.set(`layer`,c+2)}function z({theme:t},n,r){let i=e.color(r.color.toCss()),a=r.samples??[],o=a.length>0,{line:s,fill:c}=n;s.set(`visible`,o),s.set(`stroke`,i),c?.set(`visible`,o),c?.set(`fill`,e.Color.lighten(i,t.seriesFillLighten)),s.data.setAll(a),c?.data.setAll(a)}function B(e,t){let{id:n}=t,r=V(e,`line-${n}`);r.setAll({dy:t.chartStrokeOffsetY,tooltip:void 0}),r.strokes.template.setAll({strokeWidth:t.chartStrokeWidth});let i=null;return t.chartFillEnabled&&(i=V(e,`fill-${n}`),i.fills.template.setAll({fillOpacity:1,visible:!0})),{id:n,line:r,fill:i}}function V(e,t){return o.new(e.chart.root,{connect:!1,excludeFromTotal:!0,fill:void 0,id:t,stroke:void 0,valueXField:`distance`,valueYField:`elevation`,xAxis:e.xAxis,yAxis:e.yAxis})}function H({theme:t,chart:n,rtl:r}){let i=e.Tooltip.new(n.root,{autoTextColor:!1,getFillFromSprite:!1,getLabelFillFromSprite:!1,pointerOrientation:`vertical`,visible:!1}),a=t.seriesTooltipPaddingHorizontal,o=t.seriesTooltipPaddingVertical;return i.label.setAll({fill:e.color(t.seriesTooltipLabelColor),fontFamily:t.fontFamily,fontSize:t.seriesTooltipFontSize,paddingBottom:o,paddingLeft:a,paddingRight:a,paddingTop:o,textAlign:r?`end`:`start`,direction:`ltr`}),i.get(`background`)?.setAll({stroke:void 0,fill:e.color(t.seriesTooltipBackgroundColor)}),i.adapters.add(`dy`,e=>{let n=t.seriesTooltipSpacing,r=i.get(`pointTo`)?.y??0;return(e??0)+(i.y()>r?n:-n)}),i}function U(e){let{xAxis:t,yAxis:n}=e,r=()=>{e.onRangeChange(W(t),W(n))},i=e=>[e.on(`start`,r),e.on(`end`,r)];return Q([...i(t),...i(n)])}function W(e){let t=Math.abs((e.get(`end`)??0)-(e.get(`start`)??0)),n=t===0?1:1/t;return Math.abs(1-n)<v()?1:n}function G(e){let{chart:t}=e,n=t.plotContainer.events,r=t=>{e.pointerIsOver=t,K(e)},i=()=>{r(!1),e.onCursorPositionChange(null,null)};return Q([n.on(`pointerover`,()=>r(!0)),n.on(`pointerout`,i),n.on(`blur`,i)])}function K(e){let{chart:t,data:n,xAxis:r,yAxis:i}=e,o=t.get(`cursor`);if(!n?.refined){o?.events.removeType(`cursormoved`),o?.dispose(),t.set(`cursor`,void 0);return}if(!o){let n=a.new(t.root,{behavior:`none`,xAxis:r,yAxis:i,snapToSeriesBy:`y`});n.lineY.set(`visible`,!1),n.events.on(`cursormoved`,se(e)),t.set(`cursor`,n)}let s=ce(e);s?e.seriesInfos.forEach(t=>{let n=t.line.get(`tooltip`)??H(e);n.label.set(`text`,s),t.line.set(`tooltip`,n)}):e.seriesInfos.forEach(e=>{e.line.get(`tooltip`)?.dispose(),e.line.set(`tooltip`,void 0)}),e.xAxis.getTooltip().setAll({tooltipText:de(e)})}function se(e){return()=>{if(!e.pointerIsOver)return;K(e);let{chart:t,xAxis:n,yAxis:r}=e,i=t.get(`cursor`),a=i?.getPrivate(`positionX`)??0,o=i?.getPrivate(`positionY`)??0,s=e.data;if(s?.statistics!=null){let{maxDistance:e,minElevation:t,maxElevation:i}=s.statistics,c,l;e!=null&&(W(n)===1?(c=0,l=e):(c=X(n),l=Z(n)),a=q(a,c,l,0,e)),t!=null&&i!=null&&(W(r)===1?(c=t,l=i):(c=X(r),l=Z(r)),o=q(o,c,l,t,i))}e.onCursorPositionChange(a,o)}}function q(e,t,n,r,i){return(t+e*(n-t)-r)/(i-r)}function ce(e){let{data:t}=e,n=t?.lines.map(t=>({line:t,y:Y(e,t)?.elevation})).sort(le);return!n||n.length===0||n[0].y==null?null:n.map(({y:t,line:n})=>ue(e,n,t)).join(`
2
+ import*as e from"@amcharts/amcharts5/index.js";import{XYChart as t,ValueAxis as n,AxisRendererX as r,AxisRendererY as i,XYCursor as a,LineSeries as o}from"@amcharts/amcharts5/xy.js";import s from"@amcharts/amcharts5/themes/Dark.js";import c from"@amcharts/amcharts5/themes/Responsive.js";import{formatNumber as l,substitute as u}from"../../../intl.js";import{handlesGroup as d,makeHandle as f}from"../../../core/handleUtils.js";import"../../../core/has.js";import{throwIfAborted as p}from"../../../core/promiseUtils.js";import{signal as m}from"../../../core/signal.js";import{unitName as h,formatDecimal as g}from"../../../core/unitFormatUtils.js";import{convertUnit as _}from"../../../core/units.js";import{getEpsilon as v}from"../../../core/libs/gl-matrix-2/math/common.js";import{isDarkMode as ee}from"../../../support/modeUtils.js";import{getConfig as y,notAvailable as b}from"./constants.js";import{getTranslatedLineTitle as x}from"./intlUtils.js";import{niceScale as S}from"./niceScale.js";import{binaryFindClosest as te}from"./profileUtils.js";import{createRoot as ne}from"../../support/chartUtilsAm5.js";import{isRTL as C}from"../../support/widget.js";const w=`#f8f8f8`,T=`#a9a9a9`,E=`#323232`,D=.001,O={fontFamily:`Avenir Next`,paddingBottom:6,paddingLeft:0,paddingRight:0,paddingTop:0,axisGridStroke:`#f4f4f4`,axisLabelsFontSize:9,axisLabelsFontWeight:`400`,axisLabelsColor:T,axisTooltipFontSize:12,axisTooltipBackgroundColor:E,axisTooltipLabelColor:w,axisTooltipPaddingTop:3,axisTooltipPaddingBottom:3,axisTooltipPaddingHorizontal:4,xAxisMinGridDistance:50,xAxisLabelsSpacing:6,xAxisMinLabelPosition:.05,xAxisMaxLabelPosition:.9,yAxisMinGridDistance:30,yAxisLabelSpacing:4,yAxisMinLabelPosition:0,yAxisMaxLabelPosition:.8,seriesTooltipFontSize:12,seriesTooltipBackgroundColor:w,seriesTooltipLabelColor:E,seriesFillLighten:.9,seriesTooltipSpacing:6,seriesTooltipPaddingVertical:4,seriesTooltipPaddingHorizontal:4},k={...O,axisGridStroke:E,axisLabelsColor:T,axisTooltipBackgroundColor:E,axisTooltipLabelColor:w,seriesTooltipBackgroundColor:E,seriesTooltipLabelColor:w,seriesFillLighten:-.75},A={minX:void 0,maxX:void 0,minY:void 0,maxY:void 0};async function re(e){let a=await ne(e.container);p(e.abortOptions);let o=ee(e.container),l=o?k:O;a.setThemes(o?[c.new(a),s.new(a)]:[c.new(a)]);let u=C(e.container),f=a.container.children.push(t.new(a,{panX:!0,panY:!0,paddingTop:l.paddingTop,paddingBottom:l.paddingBottom,paddingLeft:u?l.paddingRight:l.paddingLeft,paddingRight:u?l.paddingLeft:l.paddingRight,maxTooltipDistance:-1}));f.zoomOutButton.set(`forceHidden`,!0);let h=f.xAxes.push(n.new(a,{renderer:r.new(a,{})})),g=f.yAxes.push(n.new(a,{renderer:i.new(a,{})})),_=m(null),v=m(`loading`),y={params:e,chart:f,xAxis:h,yAxis:g,seriesInfos:new Map,messages:null,theme:l,pointerIsOver:!1,rtl:u,onCursorPositionChange:e.onCursorPositionChange,onRangeChange:e.onRangeChange,get state(){return v.value},get data(){return _.value},set data(e){_.value=e}};N(y),ie(y),M(y);let b=d([U(y),G(y),$(a.events.once(`frameended`,()=>{v.value=`ready`})),$(a)]),x;return{destroy:()=>{b.remove(),v.value=`destroyed`},update:e=>{e.data===y.data&&e.messages===y.messages||j(y)||ae(y,e)},zoomOut:()=>P(y),test:x}}function j(e){return e.state===`destroyed`}function M({chart:e,xAxis:t,yAxis:n}){let r=a.new(e.root,{behavior:`none`,xAxis:t,yAxis:n,snapToSeriesBy:`y`});r.lineY.set(`visible`,!1),e.set(`cursor`,r)}function N(t){let{chart:n,xAxis:r,theme:i}=t;r.setAll({extraMax:0,extraMin:0,maxDeviation:0,numberFormatter:J(t,`distance`),strictMinMax:!0,strictMinMaxSelection:!0}),r.axisHeader.set(`forceHidden`,!0);let a=r.get(`renderer`);a.setAll({inside:!1,minGridDistance:i.xAxisMinGridDistance}),a.labels.template.setAll({centerX:e.p0,centerY:e.p0,fill:e.color(i.axisLabelsColor),fontFamily:i.fontFamily,fontSize:i.axisLabelsFontSize,fontWeight:i.axisLabelsFontWeight,maxPosition:i.xAxisMaxLabelPosition,minPosition:i.xAxisMinLabelPosition,paddingLeft:0,paddingRight:0,paddingTop:i.xAxisLabelsSpacing});let o=r.set(`tooltip`,e.Tooltip.new(n.root,{paddingBottom:0,paddingLeft:0,paddingRight:0,paddingTop:0}));o.get(`background`)?.setAll({fill:e.color(i.axisTooltipBackgroundColor),stroke:void 0}),o.label.setAll({fill:e.color(i.axisTooltipLabelColor),fontFamily:i.fontFamily,fontSize:i.axisTooltipFontSize,paddingBottom:i.axisTooltipPaddingBottom,paddingLeft:i.axisTooltipPaddingHorizontal,paddingRight:i.axisTooltipPaddingHorizontal,paddingTop:i.axisTooltipPaddingTop,direction:t.rtl?`rtl`:`ltr`}),a.grid.template.setAll({strokeOpacity:1,stroke:e.color(i.axisGridStroke)})}function ie(t){let{yAxis:n,theme:r,rtl:i}=t;n.setAll({baseValue:y().noDataValue,extraMax:0,extraMin:0,maxDeviation:0,numberFormatter:J(t,`elevation`),strictMinMax:!0,strictMinMaxSelection:!0,tooltip:void 0}),n.axisHeader.set(`visible`,!1);let a=n.get(`renderer`);a.setAll({minGridDistance:r.yAxisMinGridDistance,opposite:i,inside:!0}),a.labels.template.setAll({centerX:e.p0,centerY:e.p100,fill:e.color(r.axisLabelsColor),fontFamily:r.fontFamily,fontSize:r.axisLabelsFontSize,fontWeight:r.axisLabelsFontWeight,maxPosition:r.yAxisMaxLabelPosition,minPosition:r.yAxisMinLabelPosition,paddingBottom:0,paddingLeft:i?0:r.yAxisLabelSpacing,paddingRight:i?r.yAxisLabelSpacing:0,paddingTop:0,textAlign:`start`}),a.grid.template.setAll({strokeOpacity:1,stroke:e.color(r.axisGridStroke)})}function ae(e,t){if(j(e))return;let n=e.data??void 0,r=t.data??void 0,i=n!==r,a=n?.effectiveUnits!==r?.effectiveUnits,o=n?.uniformScaling!==r?.uniformScaling;e.data=r,e.messages=t.messages,(i||a)&&(oe(e),R(e)),o&&P(e),K(e)}function P(e){j(e)||(e.xAxis.zoom(0,1),e.yAxis.zoom(0,1))}function oe(e){let{chart:t,data:n,xAxis:r,yAxis:i}=e,{minX:a,maxX:o,minY:s,maxY:c}=F({data:n,pixelWidth:r.width(),pixelHeight:i.height()}),l=!!n?.uniformScaling,u=!!n?.refined;t.setAll({panX:!0,panY:l,pinchZoomX:u,pinchZoomY:u&&l,wheelX:`panX`,wheelY:u?l?`zoomXY`:`zoomX`:`none`}),r.setAll({max:o,min:a,panX:!0,panY:!1,zoomX:!0,zoomY:l}),i.setAll({max:c,min:s,panX:!1,panY:l,zoomX:l,zoomY:l})}function F({data:e,pixelWidth:t,pixelHeight:n}){if(e==null)return A;let r=e.statistics,i=r?.maxDistance,a=r?.minElevation,o=r?.maxElevation;if(i==null||a==null||o==null)return A;let s=Math.max(i-0,D),c=Math.max(o-a,D),l=e.effectiveUnits;if(e.dynamicElevationRange){let e=_(s,l.distance,l.elevation);c=Math.max(c,e/y().maxChartRatio)}return a-=.02*c,o=a+c+.1*c,[a,o]=S(a,o,10),c=o-a,e.uniformScaling?I({data:e,bounds:{minX:0,maxX:i,minY:a,maxY:o},pixelWidth:t,pixelHeight:n,centered:!0}):{minX:0,maxX:0+s,minY:a,maxY:a+c}}function I({data:e,bounds:t,pixelWidth:n,pixelHeight:r,centered:i}){if(e==null)return t;let{minX:a,maxX:o,minY:s,maxY:c}=t;if(a==null||o==null||s==null||c==null)return A;let l=o-a,u=c-s,d=e.effectiveUnits,f=_(u,d.elevation,d.distance),p=l/n,m=f/r/p;return m>=1?[a,o]=L([a,o],m):[s,c]=L([s,c],1/m),{minX:a,maxX:o,minY:s,maxY:c}}function L([e,t],n,r){let i=(t-e)*n;{let n=(e+t)/2-i/2;return[n,n+i]}}function R(e){let{chart:t,data:n,seriesInfos:r,xAxis:i,yAxis:a}=e;if(n==null||n.lines.length===0){t.series.clear();return}let o=new Map,s=new Set(t.series.values),c=n.lines.length;for(let i=0;i<c;i++){let a=n.lines[i],l=r.get(a.id);l?(l.fill&&s.delete(l.fill),s.delete(l.line)):(l=B(e,a),l.fill&&t.series.push(l.fill),t.series.push(l.line)),o.set(l.id,l);let u=c-i-1;l.fill?.set(`layer`,u),l.line.set(`layer`,c+u),z(e,l,a)}e.seriesInfos=o;for(let e of s)t.series.removeValue(e);i.set(`layer`,c+1),a.set(`layer`,c+2)}function z({theme:t},n,r){let i=e.color(r.color.toCss()),a=r.samples??[],o=a.length>0,{line:s,fill:c}=n;s.set(`visible`,o),s.set(`stroke`,i),c?.set(`visible`,o),c?.set(`fill`,e.Color.lighten(i,t.seriesFillLighten)),s.data.setAll(a),c?.data.setAll(a)}function B(e,t){let{id:n}=t,r=V(e,`line-${n}`);r.setAll({dy:t.chartStrokeOffsetY,tooltip:void 0}),r.strokes.template.setAll({strokeWidth:t.chartStrokeWidth});let i=null;return t.chartFillEnabled&&(i=V(e,`fill-${n}`),i.fills.template.setAll({fillOpacity:1,visible:!0})),{id:n,line:r,fill:i}}function V(e,t){return o.new(e.chart.root,{connect:!1,excludeFromTotal:!0,fill:void 0,id:t,stroke:void 0,valueXField:`distance`,valueYField:`elevation`,xAxis:e.xAxis,yAxis:e.yAxis})}function H({theme:t,chart:n,rtl:r}){let i=e.Tooltip.new(n.root,{autoTextColor:!1,getFillFromSprite:!1,getLabelFillFromSprite:!1,pointerOrientation:`vertical`,visible:!1}),a=t.seriesTooltipPaddingHorizontal,o=t.seriesTooltipPaddingVertical;return i.label.setAll({fill:e.color(t.seriesTooltipLabelColor),fontFamily:t.fontFamily,fontSize:t.seriesTooltipFontSize,paddingBottom:o,paddingLeft:a,paddingRight:a,paddingTop:o,textAlign:r?`end`:`start`,direction:`ltr`}),i.get(`background`)?.setAll({stroke:void 0,fill:e.color(t.seriesTooltipBackgroundColor)}),i.adapters.add(`dy`,e=>{let n=t.seriesTooltipSpacing,r=i.get(`pointTo`)?.y??0;return(e??0)+(i.y()>r?n:-n)}),i}function U(e){let{xAxis:t,yAxis:n}=e,r=()=>{e.onRangeChange(W(t),W(n))},i=e=>[e.on(`start`,r),e.on(`end`,r)];return Q([...i(t),...i(n)])}function W(e){let t=Math.abs((e.get(`end`)??0)-(e.get(`start`)??0)),n=t===0?1:1/t;return Math.abs(1-n)<v()?1:n}function G(e){let{chart:t}=e,n=t.plotContainer.events,r=t=>{e.pointerIsOver=t,K(e)},i=()=>{r(!1),e.onCursorPositionChange(null,null)};return Q([n.on(`pointerover`,()=>r(!0)),n.on(`pointerout`,i),n.on(`blur`,i)])}function K(e){let{chart:t,data:n,xAxis:r,yAxis:i}=e,o=t.get(`cursor`);if(!n?.refined){o?.events.removeType(`cursormoved`),o?.dispose(),t.set(`cursor`,void 0);return}if(!o){let n=a.new(t.root,{behavior:`none`,xAxis:r,yAxis:i,snapToSeriesBy:`y`});n.lineY.set(`visible`,!1),n.events.on(`cursormoved`,se(e)),t.set(`cursor`,n)}let s=ce(e);s?e.seriesInfos.forEach(t=>{let n=t.line.get(`tooltip`)??H(e);n.label.set(`text`,s),t.line.set(`tooltip`,n)}):e.seriesInfos.forEach(e=>{e.line.get(`tooltip`)?.dispose(),e.line.set(`tooltip`,void 0)}),e.xAxis.getTooltip().setAll({tooltipText:de(e)})}function se(e){return()=>{if(!e.pointerIsOver)return;K(e);let{chart:t,xAxis:n,yAxis:r}=e,i=t.get(`cursor`),a=i?.getPrivate(`positionX`)??0,o=i?.getPrivate(`positionY`)??0,s=e.data;if(s?.statistics!=null){let{maxDistance:e,minElevation:t,maxElevation:i}=s.statistics,c,l;e!=null&&(W(n)===1?(c=0,l=e):(c=X(n),l=Z(n)),a=q(a,c,l,0,e)),t!=null&&i!=null&&(W(r)===1?(c=t,l=i):(c=X(r),l=Z(r)),o=q(o,c,l,t,i))}e.onCursorPositionChange(a,o)}}function q(e,t,n,r,i){return(t+e*(n-t)-r)/(i-r)}function ce(e){let{data:t}=e,n=t?.lines.map(t=>({line:t,y:Y(e,t)?.elevation})).sort(le);return!n||n.length===0||n[0].y==null?null:n.map(({y:t,line:n})=>ue(e,n,t)).join(`
3
3
  `)}function le({y:e},{y:t}){return e==null?1:t==null?-1:t-e}function ue(e,t,n){let{data:r,messages:i}=e;if(r==null||i==null)return``;let a=`[${t.color.toHex()}]●[/]`,o=y().formatPrecision,s=u(i.chartTooltip,{name:x(t,i),elevation:n==null?b:g(i,n,r.effectiveUnits.elevation,o)});return e.rtl?s+` `+a:a+` `+s}function de(e){let{data:t,messages:n}=e;if(t==null||n==null)return``;let r=t.lines[0],i=r?Y(e,r):null,a=y().formatPrecision;return i==null?`-`:g(n,i.distance,t.effectiveUnits.distance,a)}function J(t,n){let r=e.NumberFormatter.new(t.chart.root,{});return r.format=(e,r,i)=>{let{data:a,messages:o}=t;return o==null||a==null||typeof e==`string`?``:`${l(e,{maximumFractionDigits:i})} ${h(o,a.effectiveUnits[n],`abbr`)}`},r}function Y({chart:e,xAxis:t},n){let r=n.samples??[];if(r.length===0)return null;let i=e.get(`cursor`)?.getPrivate(`positionX`)??0,a=t.toAxisPosition(i),o=t.positionToValue(a);return te(r,o,e=>e.distance)}function X(e){return e.positionToValue(e.get(`start`)??0)}function Z(e){return e.positionToValue(e.get(`end`)??1)}function Q(e){return d(e.map($))}function $(e){return f(()=>{e?.dispose()})}export{re as createChart,F as getAdjustedBounds};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{onLocaleChange as t,substitute as n,fetchMessageBundle as r}from"../../intl.js";import{isSome as i}from"../../core/arrayUtils.js";import a from"../../core/Collection.js";import{referenceSetter as o}from"../../core/collectionUtils.js";import s from"../../core/Error.js";import c from"../../core/Logger.js";import{debounce as l,ignoreAbortErrors as u}from"../../core/promiseUtils.js";import{watch as d,initial as f,on as p,syncAndInitial as m}from"../../core/reactiveUtils.js";import{throttle as h}from"../../core/throttle.js";import{property as g,subclass as _}from"../../core/accessorSupport/decorators.js";import{getEffectiveFieldAlias as v}from"../../editing/fieldUtils.js";import{geometryTypes as y}from"../../geometry/support/typeUtils.js";import{getLowerCaseDefaultHiddenFields as b}from"../../layers/support/fieldUtils.js";import{getSubtypesFromLayer as x,isSubtypeGroupLayer as S}from"../../layers/support/layerUtils.js";import{createFieldInfos as C}from"../../support/popupUtils.js";import w from"../../tables/AttributeTableTemplate.js";import{syncAttributeTableTemplateWithColumns as T}from"../../tables/support/templateUtils.js";import E from"../../time/TimeExtent.js";import{isSelectableLayerWithObjectIds as D}from"../../views/support/selectionUtils.js";import O from"./ActionColumn.js";import k from"./AttachmentsColumn.js";import A from"./FieldColumn.js";import j from"./RelationshipColumn.js";import M from"./Grid/Column.js";import N from"./Grid/Grid.js";import P from"./Grid/GridViewModel.js";import F from"./Grid/GroupColumn.js";import I from"./support/AttachmentsColumnTemplate.js";import L from"./support/AttachmentsViewOptions.js";import{isAttachmentsColumn as R,isFieldColumn as z,isRelationshipColumn as B}from"./support/columnUtils.js";import{downloadAttachmentInfo as V,exportToCSV as H}from"./support/exportUtils.js";import U from"./support/FeatureStore.js";import W from"./support/FieldColumnTemplate.js";import G from"./support/RelationshipColumnTemplate.js";import K from"./support/TableTemplate.js";import{isIFeatureTableSupportedLayerWithFieldConfigurations as q,isIFeatureTableSupportedLayerWithRelationships as J,findRelatedLayerInSources as ee,findRelationship as te,uniqueColumnNames as Y,hasColumnForField as ne,findField as X,isIFeatureTableSupportedLayerWithAttachments as re,getRelationshipIdsToShow as ie}from"./support/tableUtils.js";import{goTo as ae}from"../support/goToUtils.js";import{messageBundle as Z}from"../support/widget.js";const Q=`80px`;let $=class extends P{constructor(e){super(e),this._refreshDebounced=l(()=>this._refresh()),this._syncTemplateThrottled=h(()=>this._syncAttributeTableTemplate()),this.attachmentsViewOptions=new L,this.attributeTableTemplate=null,this.autoRefreshEnabled=!0,this.columns=new a,this.dataProvider=async(e,t)=>{let{layer:n,store:r}=this;if(!t)return;if(!n||!r){t&&t([]);return}try{await n.load()}catch{return}let{objectIds:i}=this;if(this.filterBySelectionEnabled&&!this.highlightIds.length||i.length===1&&i.items[0]===-1){t([]);return}if(r.state!==`loaded`&&r.state!==`loading`)try{await r.load()}catch{return}let a=this.paginationEnabled?this.pageIndex:e.page;try{let n=await r.queryPage({...e,pageIndex:a});t?.(n)}catch{return}},this.grid=null,this.layers=null,this.menuConfig=null,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.messagesURIUtils=null,this.prompt=null,this.relatedTables=new a,this.relationshipColumnConfigs=null,this.showRelatedTableCallback=null,this.store=null,this.syncTemplateOnChangesEnabled=!0,this.tableController=null,this.tableParent=null,this.tableTemplate=null,this.tableTemplateOverride=null,this._onLayerRefresh=this._onLayerRefresh.bind(this),this._onShowPromptCallback=this._onShowPromptCallback.bind(this),this._set(`store`,new U),this._set(`grid`,new N({viewModel:this}))}initialize(){let e=async()=>{this.messages=await r(`esri/widgets/FeatureTable/t9n/FeatureTable`),this.messagesCommon=await r(`esri/t9n/common`),this.messagesUnits=await r(`esri/core/t9n/Units`),this.messagesURIUtils=await r(`esri/widgets/support/t9n/uriUtils`)};e(),this.addHandles([t(()=>{e(),this._generateColumns()}),d(()=>[this.messages,this.messagesCommon,this.messagesURIUtils],()=>{let e=this.messages;this.grid&&(this.grid.messages=e),this.allColumns.forEach(t=>{t.messages=e,t.messagesCommon=this.messagesCommon,t.messagesURIUtils=this.messagesURIUtils}),this.refreshCellContent()},f),d(()=>this.attachmentsEnabled,()=>this.layer?.loaded&&this._generateColumns()),d(()=>this.layer,async(e,t)=>{let n=this.grid;n&&(n.clearSort(),e&&t&&await this.reset()),this.goToPage(0),this._drainColumns(),this.store.layer=e,e&&(e.loaded?this._onLayerLoad().catch(()=>{}):e.load().catch(()=>{})),this.syncViewSelection&&this._syncSelection(),t&&this.attachmentsViewOptions.objectId!=null&&(this.attachmentsViewOptions.objectId=null)}),d(()=>this.layer?.loaded,e=>{e&&this._onLayerLoad().catch(()=>{})}),d(()=>this.store.state,e=>{e===`loaded`&&(this.scrollToTop(),this.refreshCellContent())}),d(()=>this._effectiveTableTemplate,()=>{this.scrollLeft(),this.layer?.loaded&&this._generateColumns()}),d(()=>this.editingEnabled,()=>this.refreshCellContent()),d(()=>this.timeZone??this.view?.timeZone,()=>this.refreshCellContent()),d(()=>this.effectiveWhere,()=>{this.store.state===`loaded`&&this.reset().catch(()=>{})}),d(()=>this.effectiveTimeExtent,()=>void this.refresh()),p(()=>this.layer,`refresh`,e=>this._onLayerRefresh(e)),p(()=>this.grid,[`cell-click`,`cell-dblclick`,`cell-pointerover`,`cell-pointerout`,`cell-keydown`,`column-reorder`],({index:e,item:t,native:n,path:r,type:i})=>{let a=t?.feature,o=a?.getObjectId(),s=i===`cell-keydown`&&n&&n instanceof KeyboardEvent&&n.key===`Enter`;this.emit(i,{feature:a,index:e,native:n,type:i,fieldName:r??void 0,objectId:o}),(s||i===`cell-click`)&&this._onCellInteraction(o)}),d(()=>this.actionColumnConfig,e=>{let{actionColumn:t,columns:n}=this;t?e?t.set(e):n.remove(t):e&&n.length&&n.add(this._generateActionColumn(),e.frozenToEnd===!1?this._getIndexOfFirstFrozenToEndColumn():void 0)}),d(()=>this.relatedRecordsEnabled,()=>this.layer?.loaded&&this._generateColumns()),p(()=>this.objectIds,`change`,()=>this._onObjectIdsChange(),{onListenerAdd:()=>this._onObjectIdsChange()}),d(()=>[this.paginationEnabled,this.pageIndex],()=>this.refreshPageCache()),d(()=>this.activeSortOrders,e=>{this.store.sortOrders=e,this._syncTemplateThrottled()}),d(()=>this.allVisibleColumns,()=>this._syncTemplateThrottled()),d(()=>this.pageCount,()=>{this.pageIndex>=this.pageCount&&this.goToPage(0)}),d(()=>this.state,e=>{e===`disabled`&&this.relatedTables.length&&this.drainRelatedTables()}),p(()=>this.tableParent?.highlightIds,`change`,({added:e})=>{let{relationshipConfig:t}=this,n=e[0];if(n==null||!t)return;let{relatedLayer:r,relationshipId:i}=t;this.relationshipConfig={objectId:n,relatedLayer:r,relationshipId:i}}),p(()=>this.tableParent,`cell-click`,async e=>{let{objectId:t}=e;this.tableController&&this.hasPendingEdits?await this.tableController.discardPendingEdits(void 0,!0).then(e=>e&&this._syncTableParentSelection(t)):this._syncTableParentSelection(t)}),d(()=>this.attachmentsViewOptions.objectId,(e,t)=>{e==null?this.hideAttachmentsView():t??this.showAttachmentsView({objectId:e})}),d(()=>[this.layerFieldConfigurations,this.pendingEditsCount],()=>this.refreshCellContent()),p(()=>this.highlightIds,`change`,e=>this._onHighlightIdsChange(e),{onListenerAdd:()=>this._syncSelection(),onListenerRemove:()=>this.defaultSelectionManager.clear()}),d(()=>this.effectiveSelectionManager,()=>this._syncSelection(),m),p(()=>this.effectiveSelectionManager,`selection-change`,()=>this._syncSelection(),m)])}destroy(){this._drainColumns(),this.grid?.destroy(),this.columns.destroyed||this.columns.destroy(),this.layer=null,this.view=null}get _defaultHiddenFields(){return b(this.layer)}get _effectiveTableTemplate(){return this.tableTemplateOverride||this.tableTemplate}get _effectiveAttributeTableTemplate(){return this.attributeTableTemplate||this.layer?.attributeTableTemplate}get _subtypes(){return x(this.layer)}get actionColumn(){return super.actionColumn}get activeFilters(){let{filterGeometry:e,objectIds:t,filterBySelectionEnabled:n,highlightIds:r}=this,i=new a;return e&&i.push({type:`geometry`,geometry:e}),n?i.push({type:`selection`,objectIds:r.toArray()}):t.length&&i.push({type:`objectId`,objectIds:t.toArray()}),i}get activeSortOrders(){return this.grid?.sortOrders?this.grid.sortOrders.map(({path:e,direction:t})=>({fieldName:e,direction:t})).filter(e=>e.fieldName&&e.direction):[]}get allColumns(){return super.allColumns}get allRelatedTablesVisible(){return!!(this.relatedRecordsEnabled&&this.relatedTables.length&&this.showAllRelatedTables)}get allVisibleColumns(){return super.allVisibleColumns}get attachmentsColumns(){return this.allColumns.filter(e=>R(e))}get attachmentsEnabled(){return this.store.attachmentsEnabled}set attachmentsEnabled(e){this.store.attachmentsEnabled=e}get autoSaveEnabled(){return this.store.autoSaveEnabled}set autoSaveEnabled(e){this.store.autoSaveEnabled=e}get cachedPageCount(){return this.store.cachedPageCount}get canAddRelatedFeature(){return this.store.canAddRelatedFeature}get clearPrompt(){return()=>this.prompt=null}set clearPrompt(e){this._overrideIfSome(`clearPrompt`,e)}get defaultSelectionManager(){return this.store.defaultSelectionManager}get definitionExpression(){return this.store.where}set definitionExpression(e){this.store.where=e}get editingEnabled(){return super.editingEnabled}set editingEnabled(e){super.editingEnabled=e}get effectiveSelectionManager(){return this.store.effectiveSelectionManager}get effectiveMultipleSelectionEnabled(){return super.effectiveMultipleSelectionEnabled}get effectiveSize(){return super.effectiveSize}get effectiveTimeExtent(){return this.store.effectiveTimeExtent}get effectiveWhere(){return this.store.effectiveWhere}get fieldColumns(){return this.allColumns.filter(e=>z(e))}get filterByViewExtent(){return this.store.filterByViewExtent}set filterByViewExtent(e){this.store.filterByViewExtent=e}get filterByLayerScaleRange(){return this.store.filterByLayerScaleRange}set filterByLayerScaleRange(e){this.store.filterByLayerScaleRange=e}get filterGeometry(){return this.store.filterGeometry}set filterGeometry(e){this.store.filterGeometry=e}get filterBySelectionEnabled(){return!!this._get(`filterBySelectionEnabled`)}set filterBySelectionEnabled(e){let{objectIds:t}=this,n=t.length;e?(n&&(t.removeAll(),this._logWarning(`Selection filter has been applied with an objectID filter. Object ID filter has been removed.`)),this.filterGeometry&&this._logWarning(`Selection filter has been applied with a geometry filter. Results may appear inconsistent`),this._syncObjectIdsWithStore(this.highlightIds.toArray())):n||this._syncObjectIdsWithStore(null),this._set(`filterBySelectionEnabled`,e)}get groupColumns(){return super.groupColumns}get hasContingentValues(){return this.relatedTableHasContingentValues||this.store.hasContingentValues}get hasInvalidPendingEdits(){return this.relatedTableHasInvalidPendingEdits||this.store.hasInvalidPendingEdits}get hasPendingEdits(){return this.relatedTableHasPendingEdits||this.store.hasPendingEdits}get hiddenFields(){return this._get(`hiddenFields`)??new a}set hiddenFields(e){this._set(`hiddenFields`,o(e,this._get(`hiddenFields`),a))}get highlightEnabled(){return this.store.highlightEnabled}set highlightEnabled(e){this.store.highlightEnabled=e}get highlightIds(){return super.highlightIds}set highlightIds(e){super.highlightIds=e}get initialSize(){return this.store.initialSize}set initialSize(e){this.store.initialSize=e}get isEditing(){return super.isEditing}get isQuerying(){return super.isQuerying}get isSyncing(){return super.isSyncing}get isQueryingOrSyncing(){return this.isQuerying||this.isSyncing||this.relatedTables.some(e=>!!e.isQueryingOrSyncing)}get isSyncingAttachments(){return this.store.isSyncingAttachmentEdits||this.relatedTables.some(e=>!!e.isSyncingAttachments)}get layer(){return this._get(`layer`)}set layer(e){this.drainRelatedTables(),this._set(`layer`,e)}get layerFieldConfigurations(){let e=this.layer;return q(e)?e.fieldConfigurations:void 0}get layerView(){return this.store.layerView}get maxSize(){return super.maxSize}set maxSize(e){super.maxSize=e}get objectIds(){return super.objectIds}set objectIds(e){super.objectIds=e}get outFields(){return this.store.outFields}set outFields(e){this.store.outFields=e}get pageCount(){return super.pageCount}get pageIndex(){return super.pageIndex}set pageIndex(e){super.pageIndex=e}get pageSize(){return super.pageSize}set pageSize(e){super.pageSize=e}get paginationEnabled(){return super.paginationEnabled}set paginationEnabled(e){super.paginationEnabled=e}get pendingEditsCount(){return this.store.pendingEditsCount}get relatedRecordsEnabled(){return this.store.relatedRecordsEnabled}set relatedRecordsEnabled(e){this.store.relatedRecordsEnabled=e}get relatedTable(){return this.relatedTables.at(-1)}get relatedTableHasContingentValues(){return!!this.relatedTable?.hasContingentValues}get relatedTableHasInvalidPendingEdits(){return!!this.relatedTable?.hasInvalidPendingEdits}get relatedTableHasPendingEdits(){return!!this.relatedTable?.hasPendingEdits}get relationship(){return this.store.relationship}get relationshipColumns(){return this.allColumns.filter(e=>B(e))}get relationshipConfig(){return this.store.relationshipConfig}set relationshipConfig(e){this.highlightIds.removeAll(),this.objectIds.removeAll(),this.filterBySelectionEnabled=!1,this.store.relationshipConfig=e}get relationshipInfos(){let{layer:e,layers:t,relationships:n,tableController:r}=this,i=this.store.relationshipInfos;if(i.length||!J(e)||!n?.length)return i;let a=[],o=r?.layers||t||[];return n.forEach(t=>{let n=ee(e,o,t);n&&(n.load().catch(()=>{}),a.push({layer:e,relatedLayer:n,relationshipId:t.id}))}),a}get relationships(){return this.store.relationships}get returnGeometryEnabled(){return this.store.returnGeometry}set returnGeometryEnabled(e){this.store.returnGeometry=e}get returnMEnabled(){return this.store.returnM}set returnMEnabled(e){this.store.returnM=e}get returnZEnabled(){return this.store.returnZ}set returnZEnabled(e){this.store.returnZ=e}get rowHighlightIds(){return super.rowHighlightIds}set rowHighlightIds(e){super.rowHighlightIds=e}get selectionManager(){return this.store.selectionManager}set selectionManager(e){this.store.selectionManager=e}get selectionSource(){return`table`}set selectionSource(e){this.syncViewSelection=e===`view`,this._overrideIfSome(`selectionSource`,e)}get showAllRelatedTables(){return this._get(`showAllRelatedTables`)}set showAllRelatedTables(e){let{relatedTable:t}=this;this._set(`showAllRelatedTables`,e),t&&(e?this._showAllRelatedTables(t):this._hideAllRelatedTables(t))}get showPrompt(){return e=>{this.prompt?.cancel?.(),this.prompt=e}}set showPrompt(e){this._overrideIfSome(`showPrompt`,e)}get size(){return super.size}get state(){return super.state}get supportsAttachments(){return this.store.supportsAttachments}get supportsAddAttachments(){let{store:{supportsAddAttachments:e,supportsEditing:t}}=this;return this.editingEnabled&&t&&e}get supportsDeleteAttachments(){return this.supportsUpdateAttachments}get supportsResizeAttachments(){return this.store.supportsResizeAttachments}get supportsUpdateAttachments(){let{store:{supportsUpdateAttachments:e,supportsEditing:t}}=this;return this.editingEnabled&&t&&e}get syncViewSelection(){return this.store.syncViewSelection}set syncViewSelection(e){this.store.syncViewSelection=e}get timeExtent(){return this.store.timeExtent}set timeExtent(e){this.store.timeExtent=e}get timeZone(){return this.store.timeZone}set timeZone(e){this.store.timeZone=e}get view(){return this.store.view}set view(e){this.store.view=e,this.fieldColumns.forEach(t=>t.view=e),this.refreshCellContent()}get viewTimeEnabled(){return this.store.viewTimeEnabled}set viewTimeEnabled(e){this.store.viewTimeEnabled=e}get visibleColumns(){return super.visibleColumns}async addAttachment(e,t){let{attachmentsViewOptions:n,store:r}=this,i=n.objectId===e;await r.addAttachment(e,t).catch(e=>{i&&e&&typeof e==`object`&&`error`in e&&e.error instanceof s&&(this._logWarning(`Unable to add attachment. ${e.error.name} ${e.error.message}`),n.error=e.error)}),i&&!n.error&&(n.onEditComplete(),n.attachmentInfos=await r.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}addPendingEdits(e){this.store.addPendingEdits(e)}collapseRelatedTable(e,t){let{relatedLayer:n,objectId:r,relationshipId:i}=t,{objectIdField:o}=n,s=te(n,i),c=n.displayField||s?.keyField||o;e.set({highlightIds:new a([r]),multipleSelectionEnabledOverride:!1,tableTemplateOverride:this._getTableTemplateForRelatedTableView(e,c,i)});let l=e.hiddenFields;l.includes(Y.action)||l.add(Y.action),l.includes(Y.attachments)||l.add(Y.attachments),e.scrollLeft()}async deleteAttachments(e,t){let{attachmentsViewOptions:n,store:r}=this,i=n.objectId===e;await r.deleteAttachments(e,t).catch(e=>{i&&e&&typeof e==`object`&&`error`in e&&e.error instanceof s&&(this._logWarning(`Unable to delete attachment(s). ${e.error.name} ${e.error.message}`),n.error=e.error)}),i&&!n.error&&(n.onEditComplete(),n.attachmentInfos=await r.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}async deleteSelection(){let e=this.highlightIds.toArray();if(!e?.length)return;let{deleteFeatureResults:t}=await this.store.deleteRowsByObjectId(e),n=t.filter(e=>!e.error).map(e=>e.objectId);n.length&&(this.highlightIds.removeMany(n),await this.refresh())}async discardPendingEdits(e){return this.relatedTable&&this.relatedTableHasPendingEdits?this.relatedTable.discardPendingEdits(e):(this.store.discardPendingEdits(e),!0)}async downloadAttachmentById(e,t){let n=(await this.store.getAttachmentsByObjectId(e,!0)).find(e=>e.id===t);await V(n)}drainRelatedTables(){this.relatedTables.drain(e=>e.destroy()),this.set({multipleSelectionEnabledOverride:null,relationshipColumnConfigs:null,showAllRelatedTables:!1,tableTemplateOverride:null}),this.hiddenFields.removeMany([Y.action,Y.attachments])}drainRelatedTablesAboveIndex(e){let{relatedTables:t}=this,n=t.slice(e+1);t.removeMany(n).forEach(e=>e.destroy());let r=t.at(-1);r&&(r.attachmentsViewOptions.objectId=null,this.allRelatedTablesVisible?this._showAllRelatedTables(r):this._hideAllRelatedTables(r))}async exportSelectionToCSV(e){let{highlightIds:t,layer:n,outFields:r}=this;!n||!t.length?this._logWarning(`Export failed.`):await H({layer:n,objectIds:t.toArray(),outFields:r,includeGeometry:e})}getCachedFeaturesByPageIndex(e){return this.store.getCachedFeaturesByPageIndex(e)}getFeatureStoreItemByObjectId(e){return this.store.getItemByObjectId(e)}async getFeatureTitle(e,t){return this.store.getFeatureTitle(e,t)}getFeatureTitleSync(e){let t=this.layer;if(!t)return`${e}`;let n=`${t.objectIdField}: ${e}`;return e==null?n:this.store.featureTitleMap.get(e)??n}getObjectIdIndex(e){return this.store.getItemIndexByObjectId(e)}getValue(e,t){return this.getFeatureStoreItemByObjectId(e)?.feature?.attributes[t]}getVirtualPageIndex(){return this.grid?.getVirtualPageIndex()??0}goToPage(e){if(e==null||!Number.isInteger(e)){this._logWarning(`Invalid 'page' parameter provided to 'goToPage()'. Current page will remain the same.`);return}let{pageCount:t}=this;(e>=t||e===-1)&&(e=t-1),e<-1&&(e=0),e!==this.pageIndex&&(this.pageIndex=e),this.paginationEnabled||this.scrollToIndex(e*this.pageSize)}hideAttachmentsView(){this.attachmentsViewOptions.objectId=null,this.set({relationshipColumnConfigs:null,multipleSelectionEnabledOverride:null,tableTemplateOverride:null}),this.hiddenFields.remove(Y.action)}nextPage(){let e=this.paginationEnabled?this.pageIndex:this.getVirtualPageIndex();this.goToPage(e+1)}previousPage(){let e=this.paginationEnabled?this.pageIndex:this.getVirtualPageIndex();this.goToPage(e-1)}async refresh(){await Promise.all([...this.relatedTables.map(e=>e.refresh()),u(this._refreshDebounced())])}refreshCellContent(){this.grid?.requestContentUpdate()}refreshPageCache(){this.grid?.refreshPageCache()}async reset(){this.goToPage(0),await this.grid?.reset()}async savePendingEdits(){this.relatedTableHasPendingEdits&&!this.relatedTableHasInvalidPendingEdits?await this.relatedTable?.savePendingEdits():this.hasPendingEdits&&!this.relatedTable&&(await this.store.savePendingEdits(),await this.refresh())}scrollLeft(){this.grid?.scrollLeft(0)}scrollToBottom(){this.grid?.scrollToBottom()}scrollToIndex(e){this.grid?.scrollToIndex(e)}scrollToRow(e){let t=this.store.getItemIndexByObjectId(e);t>-1?this.grid?.scrollToIndex(t):this._logWarning(`Row not found. Associated data may not be loaded yet.`)}scrollToTop(){this.grid?.scrollToTop()}async saveAttachmentsViewForm(){let{attachmentId:e,form:t,objectId:n}=this.attachmentsViewOptions;n!=null&&t&&(e==null?await this.addAttachment(n,t):await this.updateAttachment(n,e,t))}async showAttachmentsView({objectId:e}){let{attachmentsViewOptions:t,hiddenFields:n,layer:r}=this;if(!this.attachmentsEnabled||!r){this._logWarning(`The 'attachmentsEnabled' property is currently false.`);return}await r.load();let i=this._getDefaultLayerDisplayField(r),o=await this.store.getAttachmentsByObjectId(e,!0),s=this.store.getItemIndexByObjectId(e);t.set({attachmentInfos:o,mode:o.length?`list`:`file`,objectId:e}),this.set({highlightIds:new a([e]),multipleSelectionEnabledOverride:!1,relationshipColumnConfigs:[],tableTemplateOverride:this._getTableTemplateForAttachmentsView(i)}),n.includes(Y.action)||n.add(Y.action),s!=null&&this.scrollToIndex(s)}syncAttributeTableTemplate(){this._syncAttributeTableTemplate(!0)}syncSelectionSources(){this.store.syncSelectionSources()}async updateAttachment(e,t,n){let{attachmentsViewOptions:r,store:i}=this,a=r.objectId===e;await i.updateAttachment(e,t,n).catch(e=>{a&&e&&typeof e==`object`&&`error`in e&&e.error instanceof s&&(this._logWarning(`Unable to update attachment. ${e.error.name} ${e.error.message}`),r.error=e.error)}),a&&!r.error&&(r.onEditComplete(),r.attachmentInfos=await i.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}async zoomToSelection(){let{layer:e,view:t}=this,n=this.highlightIds.toArray();if(!e||!t||!n.length)return;let r=e.createQuery();r.objectIds=n,r.returnGeometry=!0;let i=await e.queryFeatures(r);try{await ae(t,i.features)}catch(e){e.name!==`AbortError`&&console.error(e)}}_syncAttributeTableTemplate(e=!1){let{_effectiveAttributeTableTemplate:t,layer:n,tableTemplateOverride:r,syncTemplateOnChangesEnabled:i}=this;if(!n||!t||!i&&!e||r||this.tableParent||this.relatedTable||this.attachmentsViewOptions.objectId!==null)return;let a=JSON.stringify(t.toJSON());T(t,this.columns.toArray(),this.activeSortOrders),t===n.attributeTableTemplate&&JSON.stringify(t.toJSON())!==a&&(n.attributeTableTemplate=t.clone())}async _refresh(){await super.refresh();let e=this.highlightIds.toArray();e.length&&(await this.store.verifyFeaturesByObjectId(e)).forEach((t,n)=>{t||this.highlightIds.remove(e[n])}),this.refreshPageCache();let t=this.attachmentsViewOptions;t?.objectId!=null&&(t.attachmentInfos=await this.store.getAttachmentsByObjectId(t.objectId,!0))}async _onLayerLoad(){let{layer:e,pageSize:t}=this;if(!e)return;e.parent&&S(e.parent)&&await e.parent.loadAll();let n=e.capabilities.query?.maxRecordCount,r=n&&n<t,i=r?n:t;r&&(this._logWarning(`The value for 'pageSize' has been adjusted due to the provided layer's max record count.`),this.pageSize=i),this.grid?.set(`pageSize`,i),this.store.load().catch(()=>{}),this._generateColumns()}_onLayerRefresh(e){this.autoRefreshEnabled&&e.dataChanged&&this.refresh()}_generateColumns(){this._drainColumns();let{_effectiveTableTemplate:e,_effectiveAttributeTableTemplate:t,layer:n}=this,r=e?.columnTemplates;if(!n)return;let i=this._generateColumnsFromColumnTemplates(n,r)??this._generateColumnsFromAttributeTableTemplate(n,t)??this._generateDefaultFieldColumns(n);i.length&&(this.attachmentsEnabled&&!i.some(e=>R(e))&&i.push(this._generateDefaultAttachmentsColumn(n)),this.relatedRecordsEnabled&&this.relationshipInfos.length&&!i.some(e=>B(e))&&i.push(...this._generateDefaultRelationshipColumns()),this.actionColumnConfig&&i.push(this._generateActionColumn()),i.sort((e,t)=>e.frozen&&t.frozen||e.frozenToEnd&&t.frozenToEnd?0:e.frozen||t.frozenToEnd?-1:0),this.columns.addMany(i))}_generateColumnsFromAttributeTableTemplate(e,t){if(!t)return null;let{elements:n,orderByFields:r}=t,a=C(e),o=[];o.push(...this._generateColumnsFromAttributeTableElements(e,n,r));let s=a.map(t=>{if(!t.fieldName||ne(t.fieldName,o))return null;let{fieldName:n}=t,i=X(e,n);return i?this._generateDefaultFieldColumn(e,i,{hidden:!0,orderByFields:r}):(this._logTemplateWarning(`A valid 'field' could not be found for the provided template.`),null)}).filter(i);return o.push(...s),this.attachmentsEnabled&&re(e)&&!o.some(e=>R(e))&&o.push(this._generateDefaultAttachmentsColumn(e,{hidden:!0})),this.relatedRecordsEnabled&&J(e)&&e.relationships?.forEach(({id:e},t)=>{let n=this.relationshipInfos.find(t=>t.relationshipId===e);n&&!o.some(t=>B(t)&&t.relationshipId===e)&&o.push(this._generateDefaultRelationshipColumn({hidden:!0,info:n,index:t}))}),o.length?o:null}_generateColumnsFromAttributeTableElements(e,t,n){return t?.map((t,r)=>{switch(t.type){case`field`:return this._createFieldColumnFromElement({layer:e,element:t,orderByFields:n});case`group`:return this._createGroupColumnFromElement({layer:e,element:t,orderByFields:n});case`attachment`:return this._createAttachmentColumnFromElement({layer:e,element:t,index:r});case`relationship`:return this._createRelationshipColumnFromElement({element:t,index:r})}}).filter(e=>!!e)??[]}_createFieldColumnFromElement(e){let{layer:t,element:n,orderByFields:r}=e,{fieldName:i}=n;if(i==null)return this._logTemplateWarning(`A valid 'fieldName' must be provided.`),null;let a=X(t,i);if(!a)return this._logTemplateWarning(`A valid 'field' could not be found for the provided template.`),null;let{description:o,label:s}=n,c=r?.findIndex(({field:e})=>e&&e===i)??-1,l=c>-1?r?.at(c)?.order:void 0,u=c>-1?c:void 0,{grid:d,messages:f,messagesCommon:p,messagesURIUtils:m,store:h,view:g}=this;return new A({description:o,direction:l,field:a,fieldName:i,grid:d,initialSortPriority:u,label:s,layer:t,messages:f,messagesCommon:p,messagesURIUtils:m,store:h,view:g,onShowPromptCallback:this._onShowPromptCallback})}_createGroupColumnFromElement(e){let{layer:t,element:n,orderByFields:r}=e,{description:i,label:a}=n;if(!a)return this._logTemplateWarning(`Group columns require a label.`),null;if(!n.elements.length)return this._logTemplateWarning(`Group columns require child columns.`),null;let{grid:o,messages:s,messagesCommon:c,messagesURIUtils:l,store:u}=this;return new F({columns:this._generateColumnsFromAttributeTableElements(t,n.elements,r),description:i,grid:o,label:a,messages:s,messagesCommon:c,messagesURIUtils:l,store:u})}_createAttachmentColumnFromElement(e){if(!this.attachmentsEnabled){this._logTemplateWarning(`The 'attachmentsEnabled' property is currently false.`);return}let{layer:t,element:n,index:r}=e,{description:i,label:a}=n,{grid:o,messages:s,messagesCommon:c,messagesURIUtils:l,store:u}=this;return new k({description:i,fieldName:`${Y.attachments}-${r}`,grid:o,label:a,layer:t,messages:s,messagesCommon:c,messagesURIUtils:l,store:u,onShowAttachments:e=>this._onShowAttachments(e)})}_createRelationshipColumnFromElement(e){if(!this.relatedRecordsEnabled){this._logTemplateWarning(`Relationship columns require related records to be enabled on the table.`);return}let{element:t,index:n}=e,{description:r,label:i,relationshipId:a}=t,o=this.relationshipInfos.find(e=>e.relationshipId===a);if(!o)return this._logTemplateWarning(`Unable to find valid related layer target based on the provided relationship id.`),null;let{grid:s,messages:c,messagesCommon:l,messagesURIUtils:u,store:d}=this;return new j({description:r,fieldName:`${Y.relationship}-${a}-${n}`,grid:s,label:i,messages:c,messagesCommon:l,messagesURIUtils:u,relationshipId:a,store:d,layer:o.relatedLayer,relatedLayer:o.layer,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateColumnsFromColumnTemplates(e,t){let{grid:n,messages:r,messagesCommon:i,messagesURIUtils:a,store:o,view:s}=this;if(!t?.length)return null;let c=[];return t.forEach((t,l)=>{let{autoWidth:u,description:d,direction:f,flexGrow:p,fieldName:m,formatFunction:h,frozen:g,frozenToEnd:_,icon:v,iconText:y,initialSortPriority:b,invalid:x,label:S,labelTooltipText:C,menuConfig:w,resizable:T,sortable:E,textAlign:D,textWrap:O,timeZone:k,type:j,width:N}=t;if(!j){this._logTemplateWarning(`Property 'type' is missing from the provided template.`);return}if(g&&_){this._logTemplateWarning(`Properties 'frozen' and 'frozenToEnd' cannot both be true for the same column.`);return}let P=t.visible===!1;if(j===`group`){if(!t.columnTemplates?.length){this._logTemplateWarning(`Group columns must contain column templates.`);return}if(!t.label){this._logTemplateWarning(`Group columns require a label.`);return}let o=this._generateColumnsFromColumnTemplates(e,t.columnTemplates),s=P||this._isFieldHidden(t.label);c.push(new F({autoWidth:u,columns:o,description:d,flexGrow:p,frozen:g,frozenToEnd:_,grid:n,hidden:s,icon:v,iconText:y,invalid:x,label:S,labelTooltipText:C,menuConfig:w,messages:r,messagesCommon:i,messagesURIUtils:a,resizable:T,textAlign:D,textWrap:O,timeZone:k,width:N}))}else if(j===`attachment`){if(!this.attachmentsEnabled){this._logTemplateWarning(`Attachment columns require attachments to be enabled on the table.`);return}c.push(this._generateAttachmentsColumnFromTemplate(e,t,l))}else if(j===`relationship`){if(!this.relatedRecordsEnabled){this._logTemplateWarning(`Relationship columns require related records to be enabled on the table.`);return}let{relationshipId:e}=t;if(e==null){this._logTemplateWarning(`Property 'relationshipId' is missing from the provided template.`);return}let n=this.relationshipInfos.find(t=>t.relationshipId===e);if(!n){this._logTemplateWarning(`Unable to find valid related layer target based on the provided relationship id.`);return}c.push(this._generateRelationshipColumnFromTemplate(n,t,l))}else if(!m){this._logTemplateWarning(`Value for 'fieldName' property was missing from the provided template.`);return}let I=P||this._isFieldHidden(m);if(j===`column`)c.push(new M({autoWidth:u,description:d,direction:f,fieldName:m,flexGrow:p,formatFunction:h,frozen:g,frozenToEnd:_,grid:n,hidden:I,icon:v,iconText:y,initialSortPriority:b,invalid:x,label:S,labelTooltipText:C,menuConfig:w,messages:r,messagesCommon:i,messagesURIUtils:a,resizable:T,sortable:E,store:o,textAlign:D,textWrap:O,timeZone:k,width:N}));else if(j===`field`){let l=X(e,t.fieldName);if(!l){this._logTemplateWarning(`A valid 'field' could not be found for the provided template.`);return}let{editable:m,required:j}=t;c.push(new A({autoWidth:u,description:d,direction:f,editable:m,field:l,fieldName:l.name,flexGrow:p,formatFunction:h,frozen:g,frozenToEnd:_,grid:n,hidden:I,icon:v,iconText:y,initialSortPriority:b,invalid:x,label:S,labelTooltipText:C,layer:e,messages:r,messagesCommon:i,messagesURIUtils:a,menuConfig:w,required:j,resizable:T,sortable:E,store:o,template:t,textAlign:D,textWrap:O,timeZone:k,width:N,view:s,onShowPromptCallback:this._onShowPromptCallback}))}}),c.length?c:null}_generateDefaultFieldColumns(e){return e.fields?.map(t=>this._generateDefaultFieldColumn(e,t)).filter(i)??[]}_generateDefaultFieldColumn(e,t,n){let{grid:r,messages:i,messagesCommon:a,messagesURIUtils:o,store:s,view:c}=this;if(!t.visible||t.type===`geometry`)return null;let l=n?.orderByFields,u=t.name,d=l?.findIndex(({field:e})=>e&&e===u)??-1,f=d>-1?l?.at(d)?.order:void 0,p=d>-1?d:void 0;return new A({direction:f,field:t,fieldName:u,grid:r,hidden:n?.hidden||this._isFieldHidden(u),initialSortPriority:p,layer:e,messages:i,messagesCommon:a,messagesURIUtils:o,store:s,view:c,onShowPromptCallback:this._onShowPromptCallback})}_generateAttachmentsColumnFromTemplate(e,t,n){let{grid:r,messages:i,messagesCommon:a,messagesURIUtils:o,store:s}=this,{attachmentsViewEnabled:c,autoWidth:l,description:u,flexGrow:d,fieldName:f,formatFunction:p,frozen:m,frozenToEnd:h,icon:g,iconText:_,invalid:v,label:y,labelTooltipText:b,menuConfig:x,resizable:S,textAlign:C,textWrap:w,thumbnailAppearance:T,thumbnailCount:E,thumbnailIconScale:D,thumbnailsEnabled:O,timeZone:A,width:j}=t;return new k({attachmentsViewEnabled:c,autoWidth:l,description:u,fieldName:`${Y.attachments}-${n}`,flexGrow:d,formatFunction:p,frozen:m,frozenToEnd:h,grid:r,hidden:t.visible===!1||this._isFieldHidden(y)||this._isFieldHidden(f),icon:g,iconText:_,invalid:v,label:y,labelTooltipText:b,layer:e,menuConfig:x,messages:i,messagesCommon:a,messagesURIUtils:o,resizable:S,store:s,textAlign:C,textWrap:w,thumbnailAppearance:T,thumbnailCount:E,thumbnailIconScale:D,thumbnailsEnabled:O,timeZone:A,width:j,onShowAttachments:e=>this._onShowAttachments(e)})}_generateDefaultAttachmentsColumn(e,t){let{grid:n,messages:r,messagesCommon:i,messagesURIUtils:a,store:o}=this,s=Y.attachments;return new k({fieldName:s,grid:n,hidden:t?.hidden||this._isFieldHidden(s),layer:e,messages:r,messagesCommon:i,messagesURIUtils:a,store:o,onShowAttachments:e=>this._onShowAttachments(e)})}_generateRelationshipColumnFromTemplate(e,t,n){let{grid:r,messages:i,messagesCommon:a,messagesURIUtils:o,store:s}=this,{autoWidth:c,collapsed:l,description:u,flexGrow:d,fieldName:f,formatFunction:p,frozen:m,frozenToEnd:h,icon:g,iconText:_,invalid:v,label:y,labelTooltipText:b,menuConfig:x,relationshipId:S,resizable:C,textAlign:w,textWrap:T,timeZone:E,width:D}=t;return new j({autoWidth:c,collapsed:l,description:u,fieldName:`${Y.relationship}-${S}-${n}`,flexGrow:d,formatFunction:p,frozen:m,frozenToEnd:h,grid:r,hidden:t.visible===!1||this._isFieldHidden(y)||this._isFieldHidden(f),icon:g,iconText:_,invalid:v,label:y,labelTooltipText:b,menuConfig:x,messages:i,messagesCommon:a,messagesURIUtils:o,relationshipId:S,resizable:C,store:s,textAlign:w,textWrap:T,timeZone:E,width:D,layer:e.relatedLayer,relatedLayer:e.layer,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateDefaultRelationshipColumns(){let{relationshipInfos:e,relationshipColumnConfigs:t}=this,n=[];return e?.length&&(t?t.forEach((t,r)=>{let{relationshipId:i}=t,a=e.find(e=>e.relationshipId===i);a&&n.push(this._generateDefaultRelationshipColumn({config:t,index:r,info:a}))}):e.forEach((e,t)=>n.push(this._generateDefaultRelationshipColumn({index:t,info:e})))),n}_generateDefaultRelationshipColumn(e){let{config:t,hidden:n,index:r,info:i}=e,{grid:a,messages:o,messagesCommon:s,messagesURIUtils:c,store:l}=this,{relationshipId:u}=i;return new j({...t,fieldName:`${Y.relationship}-${u}-${r}`,grid:a,hidden:!!n,messages:o,messagesCommon:s,messagesURIUtils:c,layer:i.relatedLayer,relatedLayer:i.layer,relationshipId:u,store:l,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateActionColumn(){let e=this.actionColumnConfig,t=e?.frozen===!0?!1:e?.frozenToEnd??!0;return new O({hidden:this._isFieldHidden(Y.action),store:this.store,...e,frozenToEnd:t})}_isFieldHidden(e){let t=e?.toLowerCase();return(this.hiddenFields??this._defaultHiddenFields).some(e=>e.toLowerCase()===t)}_syncSelection(){let{layer:e}=this;D(e)?this.highlightIds.items=this.effectiveSelectionManager.getSelection(e)??[]:this.highlightIds.removeAll()}_addToSelection(e){let t=this.layer;D(t)&&this.effectiveSelectionManager.add(t,e)}_removeFromSelection(e){let t=this.layer;D(t)&&this.effectiveSelectionManager.remove(t,e)}async _onHighlightIdsChange(e){let{added:t,removed:n}=e,{attachmentsViewOptions:r}=this;if(this._removeFromSelection(n),this._addToSelection(t),this.filterBySelectionEnabled&&this._syncObjectIdsWithStore(this.highlightIds.toArray()),r.objectId!=null){let e=this.highlightIds.at(0);if(e!=null){let t=await this.store.getAttachmentsByObjectId(e,!0);r.set({attachmentInfos:t,objectId:e,mode:t.length?`list`:`file`}),this.getFeatureTitle(e)}}}_syncTableParentSelection(e){let{tableParent:t}=this;t&&e!=null&&t.highlightIds.add(e)}_onShowRelatedTable(e){let{highlightIds:t}=this,{objectId:n}=e;t.removeAll(),t.add(n),this.showRelatedTableCallback?this.showRelatedTableCallback(e):this.emit(`show-related-table`,e)}_onObjectIdsChange(){let e=this.objectIds.toArray();e.length&&this.filterBySelectionEnabled&&(this.filterBySelectionEnabled=!1,this._logWarning(`Object ID filter was applied while a selection filter was applied. Selection filter has been removed.`)),this._syncObjectIdsWithStore(e)}_syncObjectIdsWithStore(e){this.store.objectIds=e,this.refreshPageCache()}_drainColumns(){this.columns.drain(e=>!e.destroyed&&e.destroy())}_showAllRelatedTables(e){let t=e.layer;if(!t)return;let n=this._getDefaultLayerDisplayField(t);e.set({relationshipColumnConfigs:[],tableTemplateOverride:this._getTableTemplateForShowAllTablesView(e,n)});let r=e.hiddenFields;r.includes(Y.action)||r.add(Y.action),r.includes(Y.attachments)||r.add(Y.attachments)}_hideAllRelatedTables(e){let{layer:t,relationship:n}=e;if(t&&n?.id!=null){if(e.attachmentsViewOptions.objectId!=null){let n=this._getDefaultLayerDisplayField(t);e.set({multipleSelectionEnabledOverride:!1,relationshipColumnConfigs:[],showAllRelatedTables:!1,tableTemplateOverride:this._getTableTemplateForAttachmentsView(n)})}else e.set({multipleSelectionEnabledOverride:null,relationshipColumnConfigs:ie(t,n.id),showAllRelatedTables:!1,tableTemplateOverride:null}),e.hiddenFields.removeMany([Y.action,Y.attachments])}}_getTableTemplateForRelatedTableView(e,t,n){return new K({columnTemplates:[new W({fieldName:t,editable:!1,menuConfig:{selectionMode:`single`,icon:`chevron-down`,items:this._extractFieldColumnInfosFromTableTemplate(e.viewModel).map(([r,i])=>({selected:r===t,label:i||r,clickFunction:()=>{e.tableTemplateOverride=this._getTableTemplateForRelatedTableView(e,r,n)}}))},resizable:!1}),new G({autoWidth:!1,collapsed:!0,flexGrow:0,label:``,resizable:!1,relationshipId:n,width:Q})]})}_getTableTemplateForShowAllTablesView(e,t){let n=[new W({fieldName:t,editable:!1,menuConfig:{selectionMode:`single`,icon:`chevron-down`,items:this._extractFieldColumnInfosFromTableTemplate(e.viewModel).map(([n,r])=>({selected:n===t,label:r||n,clickFunction:()=>{e.tableTemplateOverride=this._getTableTemplateForShowAllTablesView(e,n)}}))},resizable:!1})];return e.attachmentsViewOptions.objectId!=null&&n.push(new I({attachmentsViewEnabled:!1,autoWidth:!1,flexGrow:0,label:``,resizable:!1,thumbnailsEnabled:!1,width:Q})),new K({columnTemplates:n})}async _onShowPromptCallback(e){let{column:t,objectId:n,oldValue:r,value:i}=e,{_subtypes:a,layer:o}=this;if(!o||!a.length){t.cancel();return}let s=a.find(e=>e.code===i);if(!s){t.cancel();return}let c=Promise.withResolvers(),l=this._createSubtypeEditPrompt(r,s,c),u=!!o.parent&&this.autoSaveEnabled;try{this.showPrompt(l);let e=await c.promise,r=[{fieldName:t.fieldName,value:i}];switch(e){case`update-fields`:for(let[e,t]of Object.entries(s.defaultValues))t!=null&&r.push({fieldName:e,value:t});await t.updateItems({objectId:n,updates:r}),u&&this.refresh();break;case`keep-existing`:await t.updateItems({objectId:n,updates:r}),u&&this.refresh();break;case`undo`:t.cancel()}}finally{this.clearPrompt()}}_createSubtypeEditPrompt(e,t,r){let{_subtypes:i,messages:a,messagesCommon:o}=this,s=i.find(t=>t.code===e)?.name??`${e}`,c=`update-fields`,l=[{label:a.subtypes.useDefaultValuesOption,value:`update-fields`},{label:a.subtypes.keepCurrentValuesOption,value:`keep-existing`}];return{context:`info`,title:a.subtypes.changeWarningTitle,message:n(a.subtypes.changeWarning,{originalType:s,newType:t.name}),radios:l,defaultRadioSelection:`update-fields`,onRadioSelection:e=>{c=e},actions:{primary:{label:o.apply,action:()=>r.resolve(c),type:`positive`},secondary:{label:o.cancel,type:`neutral`,action:()=>r.resolve(`undo`)}},cancel:()=>r.reject()}}_onShowAttachments({objectId:e}){this.hasPendingEdits||(this.attachmentsViewOptions.objectId=e)}_getTableTemplateForAttachmentsView(e){return new K({columnTemplates:[new W({fieldName:e,editable:!1,menuConfig:{selectionMode:`single`,icon:`chevron-down`,items:this._extractFieldColumnInfosFromTableTemplate(this).map(([t,n])=>({selected:t===e,label:n||t,clickFunction:()=>{this.tableTemplateOverride=this._getTableTemplateForAttachmentsView(t)}}))},resizable:!1}),new I({attachmentsViewEnabled:!1,autoWidth:!1,flexGrow:0,label:``,resizable:!1,thumbnailsEnabled:!1,width:Q})]})}_extractFieldColumnInfosFromTableTemplate(e){let{layer:t,tableTemplate:n}=e??this;return n?n.columnTemplates.filter(({type:e})=>e===`field`||e===`column`).map(({fieldName:e,label:n})=>{if(n!=null&&n!==``)return[e,n];let r=t?.fieldsIndex.get(e);return[e,r&&v(r,t)]}):t?.fields.map(e=>[e.name,v(e,t)])??[]}_getDefaultLayerDisplayField(e){let{displayField:t,objectIdField:n}=e;return t&&t.trim()!==``?t:n||(e.fields.length?e.fields[0].name:``)}_getIndexOfFirstFrozenToEndColumn(){let e=this.columns.findIndex(e=>e.frozenToEnd);return e>-1?e:void 0}_logWarning(e,t){t?c.getLogger(this).warnOnce(e):c.getLogger(this).warn(e)}_logTemplateWarning(e){this._logWarning(`${e} Skipped generating a column using the provided template.`,!0)}_onCellInteraction(e){e!=null&&this.attachmentsViewOptions.objectId!=null&&this.highlightIds.add(e)}};e([g()],$.prototype,`_defaultHiddenFields`,null),e([g()],$.prototype,`_effectiveTableTemplate`,null),e([g()],$.prototype,`_effectiveAttributeTableTemplate`,null),e([g()],$.prototype,`_subtypes`,null),e([g()],$.prototype,`activeFilters`,null),e([g({readOnly:!0})],$.prototype,`activeSortOrders`,null),e([g()],$.prototype,`allRelatedTablesVisible`,null),e([g()],$.prototype,`attachmentsColumns`,null),e([g()],$.prototype,`attachmentsEnabled`,null),e([g()],$.prototype,`attachmentsViewOptions`,void 0),e([g({type:w})],$.prototype,`attributeTableTemplate`,void 0),e([g()],$.prototype,`autoRefreshEnabled`,void 0),e([g()],$.prototype,`autoSaveEnabled`,null),e([g()],$.prototype,`cachedPageCount`,null),e([g()],$.prototype,`canAddRelatedFeature`,null),e([g()],$.prototype,`clearPrompt`,null),e([g({readOnly:!0})],$.prototype,`columns`,void 0),e([g()],$.prototype,`dataProvider`,void 0),e([g()],$.prototype,`defaultSelectionManager`,null),e([g()],$.prototype,`definitionExpression`,null),e([g()],$.prototype,`effectiveSelectionManager`,null),e([g()],$.prototype,`effectiveTimeExtent`,null),e([g()],$.prototype,`effectiveWhere`,null),e([g()],$.prototype,`fieldColumns`,null),e([g()],$.prototype,`filterByViewExtent`,null),e([g()],$.prototype,`filterByLayerScaleRange`,null),e([g({types:y})],$.prototype,`filterGeometry`,null),e([g()],$.prototype,`filterBySelectionEnabled`,null),e([g({readOnly:!0})],$.prototype,`grid`,void 0),e([g()],$.prototype,`hasContingentValues`,null),e([g()],$.prototype,`hasInvalidPendingEdits`,null),e([g()],$.prototype,`hasPendingEdits`,null),e([g()],$.prototype,`hiddenFields`,null),e([g()],$.prototype,`highlightEnabled`,null),e([g()],$.prototype,`initialSize`,null),e([g()],$.prototype,`isQueryingOrSyncing`,null),e([g()],$.prototype,`isSyncingAttachments`,null),e([g()],$.prototype,`layer`,null),e([g()],$.prototype,`layers`,void 0),e([g()],$.prototype,`layerFieldConfigurations`,null),e([g()],$.prototype,`layerView`,null),e([g()],$.prototype,`menuConfig`,void 0),e([g()],$.prototype,`messages`,void 0),e([g(),Z(`esri/t9n/common`)],$.prototype,`messagesCommon`,void 0),e([g(),Z(`esri/core/t9n/Units`)],$.prototype,`messagesUnits`,void 0),e([g(),Z(`esri/widgets/support/t9n/uriUtils`)],$.prototype,`messagesURIUtils`,void 0),e([g()],$.prototype,`outFields`,null),e([g()],$.prototype,`pendingEditsCount`,null),e([g()],$.prototype,`prompt`,void 0),e([g()],$.prototype,`relatedRecordsEnabled`,null),e([g()],$.prototype,`relatedTable`,null),e([g()],$.prototype,`relatedTableHasContingentValues`,null),e([g()],$.prototype,`relatedTables`,void 0),e([g()],$.prototype,`relationship`,null),e([g()],$.prototype,`relationshipColumnConfigs`,void 0),e([g()],$.prototype,`relationshipColumns`,null),e([g()],$.prototype,`relationshipConfig`,null),e([g()],$.prototype,`relationshipInfos`,null),e([g()],$.prototype,`relationships`,null),e([g()],$.prototype,`returnGeometryEnabled`,null),e([g()],$.prototype,`returnMEnabled`,null),e([g()],$.prototype,`returnZEnabled`,null),e([g()],$.prototype,`selectionManager`,null),e([g()],$.prototype,`selectionSource`,null),e([g()],$.prototype,`showAllRelatedTables`,null),e([g()],$.prototype,`showPrompt`,null),e([g()],$.prototype,`showRelatedTableCallback`,void 0),e([g({readOnly:!0,type:U})],$.prototype,`store`,void 0),e([g()],$.prototype,`supportsAttachments`,null),e([g()],$.prototype,`supportsAddAttachments`,null),e([g()],$.prototype,`supportsDeleteAttachments`,null),e([g()],$.prototype,`supportsResizeAttachments`,null),e([g()],$.prototype,`supportsUpdateAttachments`,null),e([g()],$.prototype,`syncTemplateOnChangesEnabled`,void 0),e([g()],$.prototype,`syncViewSelection`,null),e([g()],$.prototype,`tableController`,void 0),e([g()],$.prototype,`tableParent`,void 0),e([g({type:K})],$.prototype,`tableTemplate`,void 0),e([g()],$.prototype,`tableTemplateOverride`,void 0),e([g({type:E})],$.prototype,`timeExtent`,null),e([g()],$.prototype,`timeZone`,null),e([g()],$.prototype,`view`,null),e([g()],$.prototype,`viewTimeEnabled`,null),$=e([_(`esri.widgets.FeatureTable.FeatureTableViewModel`)],$);const oe=$;export{oe as default};
2
+ import{__decorate as e}from"tslib";import{onLocaleChange as t,substitute as n,fetchMessageBundle as r}from"../../intl.js";import{isSome as i}from"../../core/arrayUtils.js";import a from"../../core/Collection.js";import{referenceSetter as o}from"../../core/collectionUtils.js";import s from"../../core/Error.js";import c from"../../core/Logger.js";import{debounce as l,ignoreAbortErrors as u}from"../../core/promiseUtils.js";import{watch as d,initial as f,on as p,syncAndInitial as m}from"../../core/reactiveUtils.js";import{throttle as h}from"../../core/throttle.js";import{property as g,subclass as _}from"../../core/accessorSupport/decorators.js";import{getEffectiveFieldAlias as v}from"../../editing/fieldUtils.js";import{geometryTypes as y}from"../../geometry/support/typeUtils.js";import{getLowerCaseDefaultHiddenFields as b}from"../../layers/support/fieldUtils.js";import{getSubtypesFromLayer as x,isSubtypeGroupLayer as S}from"../../layers/support/layerUtils.js";import{createFieldInfos as C}from"../../support/popupUtils.js";import w from"../../tables/AttributeTableTemplate.js";import{syncAttributeTableTemplateWithColumns as T}from"../../tables/support/templateUtils.js";import E from"../../time/TimeExtent.js";import{isSelectableLayerWithObjectIds as D}from"../../views/support/selectionUtils.js";import O from"./ActionColumn.js";import k from"./AttachmentsColumn.js";import A from"./FieldColumn.js";import j from"./RelationshipColumn.js";import M from"./Grid/Column.js";import N from"./Grid/Grid.js";import P from"./Grid/GridViewModel.js";import F from"./Grid/GroupColumn.js";import I from"./support/AttachmentsColumnTemplate.js";import L from"./support/AttachmentsViewOptions.js";import{isAttachmentsColumn as R,isFieldColumn as z,isRelationshipColumn as B}from"./support/columnUtils.js";import{downloadAttachmentInfo as V,exportToCSV as H}from"./support/exportUtils.js";import U from"./support/FeatureStore.js";import W from"./support/FieldColumnTemplate.js";import G from"./support/RelationshipColumnTemplate.js";import K from"./support/TableTemplate.js";import{isIFeatureTableSupportedLayerWithFieldConfigurations as q,isIFeatureTableSupportedLayerWithRelationships as J,findRelatedLayerInSources as ee,findRelationship as te,uniqueColumnNames as Y,hasColumnForField as ne,findField as X,isIFeatureTableSupportedLayerWithAttachments as re,getRelationshipIdsToShow as ie}from"./support/tableUtils.js";import{goTo as ae}from"../support/goToUtils.js";import{messageBundle as Z}from"../support/widget.js";const Q=`80px`;let $=class extends P{constructor(e){super(e),this._refreshDebounced=l(()=>this._refresh()),this._syncTemplateThrottled=h(()=>this._syncAttributeTableTemplate()),this.attachmentsViewOptions=new L,this.attributeTableTemplate=null,this.autoRefreshEnabled=!0,this.columns=new a,this.dataProvider=async(e,t)=>{let{layer:n,store:r}=this;if(!t)return;if(!n||!r){t&&t([]);return}try{await n.load()}catch{return}let{objectIds:i}=this;if(this.filterBySelectionEnabled&&!this.highlightIds.length||i.length===1&&i.items[0]===-1){t([]);return}if(r.state!==`loaded`&&r.state!==`loading`)try{await r.load()}catch{return}let a=this.paginationEnabled?this.pageIndex:e.page;try{let n=await r.queryPage({...e,pageIndex:a});t?.(n)}catch{return}},this.grid=null,this.layers=null,this.menuConfig=null,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.messagesURIUtils=null,this.prompt=null,this.relatedTables=new a,this.relationshipColumnConfigs=null,this.showRelatedTableCallback=null,this.store=null,this.syncTemplateOnChangesEnabled=!0,this.tableController=null,this.tableParent=null,this.tableTemplate=null,this.tableTemplateOverride=null,this._onLayerRefresh=this._onLayerRefresh.bind(this),this._onShowPromptCallback=this._onShowPromptCallback.bind(this),this._set(`store`,new U),this._set(`grid`,new N({viewModel:this}))}initialize(){let e=async()=>{this.messages=await r(`esri/widgets/FeatureTable/t9n/FeatureTable`),this.messagesCommon=await r(`esri/t9n/common`),this.messagesUnits=await r(`esri/core/t9n/Units`),this.messagesURIUtils=await r(`esri/widgets/support/t9n/uriUtils`)};e(),this.addHandles([t(()=>{e(),this._generateColumns()}),d(()=>[this.messages,this.messagesCommon,this.messagesURIUtils],()=>{let e=this.messages;this.grid&&(this.grid.messages=e),this.allColumns.forEach(t=>{t.messages=e,t.messagesCommon=this.messagesCommon,t.messagesURIUtils=this.messagesURIUtils}),this.refreshCellContent()},f),d(()=>this.attachmentsEnabled,()=>this.layer?.loaded&&this._generateColumns()),d(()=>this.layer,async(e,t)=>{let n=this.grid;n&&(n.clearSort(),e&&t&&await this.reset()),this.goToPage(0),this._drainColumns(),this.store.layer=e,e&&(e.loaded?this._onLayerLoad().catch(()=>{}):e.load().catch(()=>{})),this.syncViewSelection&&this._syncSelection(),t&&this.attachmentsViewOptions.objectId!=null&&(this.attachmentsViewOptions.objectId=null)}),d(()=>this.layer?.loaded,e=>{e&&this._onLayerLoad().catch(()=>{})}),d(()=>this.store.state,e=>{e===`loaded`&&(this.scrollToTop(),this.refreshCellContent())}),d(()=>this._effectiveTableTemplate,()=>{this.scrollLeft(),this.layer?.loaded&&this._generateColumns()}),d(()=>this.editingEnabled,()=>this.refreshCellContent()),d(()=>this.timeZone??this.view?.timeZone,()=>this.refreshCellContent()),d(()=>this.effectiveWhere,()=>{this.store.state===`loaded`&&this.reset().catch(()=>{})}),d(()=>this.effectiveTimeExtent,()=>void this.refresh()),p(()=>this.layer,`refresh`,e=>this._onLayerRefresh(e)),p(()=>this.grid,[`cell-click`,`cell-dblclick`,`cell-pointerover`,`cell-pointerout`,`cell-keydown`,`column-reorder`],({index:e,item:t,native:n,path:r,type:i})=>{let a=t?.feature,o=a?.getObjectId(),s=i===`cell-keydown`&&n&&n instanceof KeyboardEvent&&n.key===`Enter`;this.emit(i,{feature:a,index:e,native:n,type:i,fieldName:r??void 0,objectId:o}),(s||i===`cell-click`)&&this._onCellInteraction(o)}),d(()=>this.actionColumnConfig,e=>{let{actionColumn:t,columns:n}=this;t?e?t.set(e):n.remove(t):e&&n.length&&n.add(this._generateActionColumn(),e.frozenToEnd===!1?this._getIndexOfFirstFrozenToEndColumn():void 0)}),d(()=>this.relatedRecordsEnabled,()=>this.layer?.loaded&&this._generateColumns()),p(()=>this.objectIds,`change`,()=>this._onObjectIdsChange(),{onListenerAdd:()=>this._onObjectIdsChange()}),d(()=>[this.paginationEnabled,this.pageIndex],()=>this.refreshPageCache()),d(()=>this.activeSortOrders,e=>{this.store.sortOrders=e,this._syncTemplateThrottled()}),d(()=>this.allVisibleColumns,()=>this._syncTemplateThrottled()),d(()=>this.pageCount,()=>{this.pageIndex>=this.pageCount&&this.goToPage(0)}),d(()=>this.state,e=>{e===`disabled`&&this.relatedTables.length&&this.drainRelatedTables()}),p(()=>this.tableParent?.highlightIds,`change`,({added:e})=>{let{relationshipConfig:t}=this,n=e[0];if(n==null||!t)return;let{relatedLayer:r,relationshipId:i}=t;this.relationshipConfig={objectId:n,relatedLayer:r,relationshipId:i}}),p(()=>this.tableParent,`cell-click`,async e=>{let{objectId:t}=e;this.tableController&&this.hasPendingEdits?await this.tableController.discardPendingEdits(void 0,!0).then(e=>e&&this._syncTableParentSelection(t)):this._syncTableParentSelection(t)}),d(()=>this.attachmentsViewOptions.objectId,(e,t)=>{e==null?this.hideAttachmentsView():t??this.showAttachmentsView({objectId:e})}),d(()=>[this.layerFieldConfigurations,this.pendingEditsCount],()=>this.refreshCellContent()),p(()=>this.highlightIds,`change`,e=>this._onHighlightIdsChange(e),{onListenerAdd:()=>this._syncSelection(),onListenerRemove:()=>this.defaultSelectionManager.clear()}),d(()=>this.effectiveSelectionManager,()=>this._syncSelection(),m),p(()=>this.effectiveSelectionManager,`selection-change`,()=>this._syncSelection(),m)])}destroy(){this._drainColumns(),this.grid?.destroy(),this.columns.destroyed||this.columns.destroy(),this.layer=null,this.view=null}get _defaultHiddenFields(){return b(this.layer)}get _effectiveTableTemplate(){return this.tableTemplateOverride||this.tableTemplate}get _effectiveAttributeTableTemplate(){return this.attributeTableTemplate||this.layer?.attributeTableTemplate}get _subtypes(){return x(this.layer)}get actionColumn(){return super.actionColumn}get activeFilters(){let{filterGeometry:e,objectIds:t,filterBySelectionEnabled:n,highlightIds:r}=this,i=new a;return e&&i.push({type:`geometry`,geometry:e}),n?i.push({type:`selection`,objectIds:r.toArray()}):t.length&&i.push({type:`objectId`,objectIds:t.toArray()}),i}get activeSortOrders(){return this.grid?.sortOrders?this.grid.sortOrders.map(({path:e,direction:t})=>({fieldName:e,direction:t})).filter(e=>e.fieldName&&e.direction):[]}get allColumns(){return super.allColumns}get allRelatedTablesVisible(){return!!(this.relatedRecordsEnabled&&this.relatedTables.length&&this.showAllRelatedTables)}get allVisibleColumns(){return super.allVisibleColumns}get attachmentsColumns(){return this.allColumns.filter(e=>R(e))}get attachmentsEnabled(){return this.store.attachmentsEnabled}set attachmentsEnabled(e){this.store.attachmentsEnabled=e}get autoSaveEnabled(){return this.store.autoSaveEnabled}set autoSaveEnabled(e){this.store.autoSaveEnabled=e}get cachedPageCount(){return this.store.cachedPageCount}get canAddRelatedFeature(){return this.store.canAddRelatedFeature}get clearPrompt(){return()=>this.prompt=null}set clearPrompt(e){this._overrideIfSome(`clearPrompt`,e)}get defaultSelectionManager(){return this.store.defaultSelectionManager}get definitionExpression(){return this.store.where}set definitionExpression(e){this.store.where=e}get editingEnabled(){return super.editingEnabled}set editingEnabled(e){super.editingEnabled=e}get effectiveSelectionManager(){return this.store.effectiveSelectionManager}get effectiveMultipleSelectionEnabled(){return super.effectiveMultipleSelectionEnabled}get effectiveSize(){return super.effectiveSize}get effectiveTimeExtent(){return this.store.effectiveTimeExtent}get effectiveWhere(){return this.store.effectiveWhere}get fieldColumns(){return this.allColumns.filter(e=>z(e))}get filterByViewExtent(){return this.store.filterByViewExtent}set filterByViewExtent(e){this.store.filterByViewExtent=e}get filterByLayerScaleRange(){return this.store.filterByLayerScaleRange}set filterByLayerScaleRange(e){this.store.filterByLayerScaleRange=e}get filterGeometry(){return this.store.filterGeometry}set filterGeometry(e){this.store.filterGeometry=e}get filterBySelectionEnabled(){return!!this._get(`filterBySelectionEnabled`)}set filterBySelectionEnabled(e){let{objectIds:t}=this,n=t.length;e?(n&&(t.removeAll(),this._logWarning(`Selection filter has been applied with an objectID filter. Object ID filter has been removed.`)),this.filterGeometry&&this._logWarning(`Selection filter has been applied with a geometry filter. Results may appear inconsistent`),this._syncObjectIdsWithStore(this.highlightIds.toArray())):n||this._syncObjectIdsWithStore(null),this._set(`filterBySelectionEnabled`,e)}get groupColumns(){return super.groupColumns}get hasContingentValues(){return this.relatedTableHasContingentValues||this.store.hasContingentValues}get hasInvalidPendingEdits(){return this.relatedTableHasInvalidPendingEdits||this.store.hasInvalidPendingEdits}get hasPendingEdits(){return this.relatedTableHasPendingEdits||this.store.hasPendingEdits}get hiddenFields(){return this._get(`hiddenFields`)??new a}set hiddenFields(e){this._set(`hiddenFields`,o(e,this._get(`hiddenFields`),a))}get highlightEnabled(){return this.store.highlightEnabled}set highlightEnabled(e){this.store.highlightEnabled=e}get highlightIds(){return super.highlightIds}set highlightIds(e){super.highlightIds=e}get initialSize(){return this.store.initialSize}set initialSize(e){this.store.initialSize=e}get isEditing(){return super.isEditing}get isQuerying(){return super.isQuerying}get isSyncing(){return super.isSyncing}get isQueryingOrSyncing(){return this.isQuerying||this.isSyncing||this.relatedTables.some(e=>!!e.isQueryingOrSyncing)}get isSyncingAttachments(){return this.store.isSyncingAttachmentEdits||this.relatedTables.some(e=>!!e.isSyncingAttachments)}get layer(){return this._get(`layer`)}set layer(e){this.drainRelatedTables(),this._set(`layer`,e)}get layerFieldConfigurations(){let e=this.layer;return q(e)?e.fieldConfigurations:void 0}get layerView(){return this.store.layerView}get maxSize(){return super.maxSize}set maxSize(e){super.maxSize=e}get objectIds(){return super.objectIds}set objectIds(e){super.objectIds=e}get outFields(){return this.store.outFields}set outFields(e){this.store.outFields=e}get pageCount(){return super.pageCount}get pageIndex(){return super.pageIndex}set pageIndex(e){super.pageIndex=e}get pageSize(){return super.pageSize}set pageSize(e){super.pageSize=e}get paginationEnabled(){return super.paginationEnabled}set paginationEnabled(e){super.paginationEnabled=e}get pendingEditsCount(){return this.store.pendingEditsCount}get relatedRecordsEnabled(){return this.store.relatedRecordsEnabled}set relatedRecordsEnabled(e){this.store.relatedRecordsEnabled=e}get relatedTable(){return this.relatedTables.at(-1)}get relatedTableHasContingentValues(){return!!this.relatedTable?.hasContingentValues}get relatedTableHasInvalidPendingEdits(){return!!this.relatedTable?.hasInvalidPendingEdits}get relatedTableHasPendingEdits(){return!!this.relatedTable?.hasPendingEdits}get relationship(){return this.store.relationship}get relationshipColumns(){return this.allColumns.filter(e=>B(e))}get relationshipConfig(){return this.store.relationshipConfig}set relationshipConfig(e){this.highlightIds.removeAll(),this.objectIds.removeAll(),this.filterBySelectionEnabled=!1,this.store.relationshipConfig=e}get relationshipInfos(){let{layer:e,layers:t,relationships:n,tableController:r}=this,i=this.store.relationshipInfos;if(i.length||!J(e)||!n?.length)return i;let a=[],o=r?.layers||t||[];return n.forEach(t=>{let n=ee(e,o,t);n&&(n.load().catch(()=>{}),a.push({layer:e,relatedLayer:n,relationshipId:t.id}))}),a}get relationships(){return this.store.relationships}get returnGeometryEnabled(){return this.store.returnGeometry}set returnGeometryEnabled(e){this.store.returnGeometry=e}get returnMEnabled(){return this.store.returnM}set returnMEnabled(e){this.store.returnM=e}get returnZEnabled(){return this.store.returnZ}set returnZEnabled(e){this.store.returnZ=e}get rowHighlightIds(){return super.rowHighlightIds}set rowHighlightIds(e){super.rowHighlightIds=e}get selectionManager(){return this.store.selectionManager}set selectionManager(e){this.store.selectionManager=e}get selectionSource(){return`table`}set selectionSource(e){this.syncViewSelection=e===`view`,this._overrideIfSome(`selectionSource`,e)}get showAllRelatedTables(){return this._get(`showAllRelatedTables`)}set showAllRelatedTables(e){let{relatedTable:t}=this;this._set(`showAllRelatedTables`,e),t&&(e?this._showAllRelatedTables(t):this._hideAllRelatedTables(t))}get showPrompt(){return e=>{this.prompt?.cancel?.(),this.prompt=e}}set showPrompt(e){this._overrideIfSome(`showPrompt`,e)}get size(){return super.size}get state(){return super.state}get supportsAttachments(){return this.store.supportsAttachments}get supportsAddAttachments(){let{store:{supportsAddAttachments:e,supportsEditing:t}}=this;return this.editingEnabled&&t&&e}get supportsDeleteAttachments(){return this.supportsUpdateAttachments}get supportsResizeAttachments(){return this.store.supportsResizeAttachments}get supportsUpdateAttachments(){let{store:{supportsUpdateAttachments:e,supportsEditing:t}}=this;return this.editingEnabled&&t&&e}get syncViewSelection(){return this.store.syncViewSelection}set syncViewSelection(e){this.store.syncViewSelection=e}get timeExtent(){return this.store.timeExtent}set timeExtent(e){this.store.timeExtent=e}get timeZone(){return this.store.timeZone}set timeZone(e){this.store.timeZone=e}get view(){return this.store.view}set view(e){this.store.view=e,this.fieldColumns.forEach(t=>t.view=e),this.refreshCellContent()}get viewTimeEnabled(){return this.store.viewTimeEnabled}set viewTimeEnabled(e){this.store.viewTimeEnabled=e}get visibleColumns(){return super.visibleColumns}async addAttachment(e,t){let{attachmentsViewOptions:n,store:r}=this,i=n.objectId===e;await r.addAttachment(e,t).catch(e=>{i&&e&&typeof e==`object`&&`error`in e&&e.error instanceof s&&(this._logWarning(`Unable to add attachment. ${e.error.name} ${e.error.message}`),n.error=e.error)}),i&&!n.error&&(n.onEditComplete(),n.attachmentInfos=await r.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}addPendingEdits(e){this.store.addPendingEdits(e)}collapseRelatedTable(e,t){let{relatedLayer:n,objectId:r,relationshipId:i}=t,{objectIdField:o}=n,s=te(n,i),c=n.displayField||s?.keyField||o;e.set({highlightIds:new a([r]),multipleSelectionEnabledOverride:!1,tableTemplateOverride:this._getTableTemplateForRelatedTableView(e,c,i)});let l=e.hiddenFields;l.includes(Y.action)||l.add(Y.action),l.includes(Y.attachments)||l.add(Y.attachments),e.scrollLeft()}async deleteAttachments(e,t){let{attachmentsViewOptions:n,store:r}=this,i=n.objectId===e;await r.deleteAttachments(e,t).catch(e=>{i&&e&&typeof e==`object`&&`error`in e&&e.error instanceof s&&(this._logWarning(`Unable to delete attachment(s). ${e.error.name} ${e.error.message}`),n.error=e.error)}),i&&!n.error&&(n.onEditComplete(),n.attachmentInfos=await r.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}async deleteSelection(){let e=this.highlightIds.toArray();if(!e?.length)return;let{deleteFeatureResults:t}=await this.store.deleteRowsByObjectId(e),n=t.filter(e=>!e.error).map(e=>e.objectId);n.length&&(this.highlightIds.removeMany(n),await this.refresh())}async discardPendingEdits(e){return this.relatedTable&&this.relatedTableHasPendingEdits?this.relatedTable.discardPendingEdits(e):(this.store.discardPendingEdits(e),!0)}async downloadAttachmentById(e,t){let n=(await this.store.getAttachmentsByObjectId(e,!0)).find(e=>e.id===t);await V(n)}drainRelatedTables(){this.relatedTables.drain(e=>e.destroy()),this.set({multipleSelectionEnabledOverride:null,relationshipColumnConfigs:null,showAllRelatedTables:!1,tableTemplateOverride:null}),this.hiddenFields.removeMany([Y.action,Y.attachments])}drainRelatedTablesAboveIndex(e){let{relatedTables:t}=this,n=t.slice(e+1);t.removeMany(n).forEach(e=>e.destroy());let r=t.at(-1);r&&(r.attachmentsViewOptions.objectId=null,this.allRelatedTablesVisible?this._showAllRelatedTables(r):this._hideAllRelatedTables(r))}async exportSelectionToCSV(e){let{highlightIds:t,layer:n,outFields:r}=this;!n||!t.length?this._logWarning(`Export failed.`):await H({layer:n,objectIds:t.toArray(),outFields:r,includeGeometry:e})}getCachedFeaturesByPageIndex(e){return this.store.getCachedFeaturesByPageIndex(e)}getFeatureStoreItemByObjectId(e){return this.store.getItemByObjectId(e)}async getFeatureTitle(e,t){return this.store.getFeatureTitle(e,t)}getFeatureTitleSync(e){let t=this.layer;if(!t)return`${e}`;let n=`${t.objectIdField}: ${e}`;return e==null?n:this.store.featureTitleMap.get(e)??n}getObjectIdIndex(e){return this.store.getItemIndexByObjectId(e)}getValue(e,t){return this.getFeatureStoreItemByObjectId(e)?.feature?.attributes[t]}getVirtualPageIndex(){return this.grid?.getVirtualPageIndex()??0}goToPage(e){if(e==null||!Number.isInteger(e)){this._logWarning(`Invalid 'page' parameter provided to 'goToPage()'. Current page will remain the same.`);return}let{pageCount:t}=this;(e>=t||e===-1)&&(e=t-1),e<-1&&(e=0),e!==this.pageIndex&&(this.pageIndex=e),this.paginationEnabled||this.scrollToIndex(e*this.pageSize)}hideAttachmentsView(){this.attachmentsViewOptions.objectId=null,this.set({relationshipColumnConfigs:null,multipleSelectionEnabledOverride:null,tableTemplateOverride:null}),this.hiddenFields.remove(Y.action)}nextPage(){let e=this.paginationEnabled?this.pageIndex:this.getVirtualPageIndex();this.goToPage(e+1)}previousPage(){let e=this.paginationEnabled?this.pageIndex:this.getVirtualPageIndex();this.goToPage(e-1)}async refresh(){await Promise.all([...this.relatedTables.map(e=>e.refresh()),u(this._refreshDebounced())])}refreshCellContent(){this.grid?.requestContentUpdate()}refreshPageCache(){this.grid?.refreshPageCache()}async reset(){this.goToPage(0),await this.grid?.reset()}async savePendingEdits(){this.relatedTableHasPendingEdits&&!this.relatedTableHasInvalidPendingEdits?await this.relatedTable?.savePendingEdits():this.hasPendingEdits&&!this.relatedTable&&(await this.store.savePendingEdits(),await this.refresh())}scrollLeft(){this.grid?.scrollLeft(0)}scrollToBottom(){this.grid?.scrollToBottom()}scrollToIndex(e){this.grid?.scrollToIndex(e)}scrollToRow(e){let t=this.store.getItemIndexByObjectId(e);t>-1?this.grid?.scrollToIndex(t):this._logWarning(`Row not found. Associated data may not be loaded yet.`)}scrollToTop(){this.grid?.scrollToTop()}async saveAttachmentsViewForm(){let{attachmentId:e,form:t,objectId:n}=this.attachmentsViewOptions;n!=null&&t&&(e==null?await this.addAttachment(n,t):await this.updateAttachment(n,e,t))}async showAttachmentsView({objectId:e}){let{attachmentsViewOptions:t,hiddenFields:n,layer:r}=this;if(!this.attachmentsEnabled||!r){this._logWarning(`The 'attachmentsEnabled' property is currently false.`);return}await r.load();let i=this._getDefaultLayerDisplayField(r),o=await this.store.getAttachmentsByObjectId(e,!0),s=this.store.getItemIndexByObjectId(e);t.set({attachmentInfos:o,mode:o.length?`list`:`file`,objectId:e}),this.set({highlightIds:new a([e]),multipleSelectionEnabledOverride:!1,relationshipColumnConfigs:[],tableTemplateOverride:this._getTableTemplateForAttachmentsView(i)}),n.includes(Y.action)||n.add(Y.action),s!=null&&this.scrollToIndex(s)}syncAttributeTableTemplate(){this._syncAttributeTableTemplate(!0)}syncSelectionSources(){this.store.syncSelectionSources()}async updateAttachment(e,t,n){let{attachmentsViewOptions:r,store:i}=this,a=r.objectId===e;await i.updateAttachment(e,t,n).catch(e=>{a&&e&&typeof e==`object`&&`error`in e&&e.error instanceof s&&(this._logWarning(`Unable to update attachment. ${e.error.name} ${e.error.message}`),r.error=e.error)}),a&&!r.error&&(r.onEditComplete(),r.attachmentInfos=await i.getAttachmentsByObjectId(e,!0)),this.refreshCellContent()}async zoomToSelection(){let{layer:e,view:t}=this,n=this.highlightIds.toArray();if(!e||!t||!n.length)return;let r=e.createQuery();r.objectIds=n,r.returnGeometry=!0;let i=await e.queryFeatures(r);try{await ae(t,i.features)}catch(e){e.name!==`AbortError`&&console.error(e)}}_syncAttributeTableTemplate(e=!1){let{_effectiveAttributeTableTemplate:t,layer:n,tableTemplateOverride:r,syncTemplateOnChangesEnabled:i}=this;if(!n||!t||!i&&!e||r||this.tableParent||this.relatedTable||this.attachmentsViewOptions.objectId!==null)return;let a=JSON.stringify(t.toJSON());T(t,this.columns.toArray(),this.activeSortOrders),t===n.attributeTableTemplate&&JSON.stringify(t.toJSON())!==a&&(n.attributeTableTemplate=t.clone())}async _refresh(){await super.refresh();let e=this.highlightIds.toArray();e.length&&(await this.store.verifyFeaturesByObjectId(e)).forEach((t,n)=>{t||this.highlightIds.remove(e[n])}),this.refreshPageCache();let t=this.attachmentsViewOptions;t?.objectId!=null&&(t.attachmentInfos=await this.store.getAttachmentsByObjectId(t.objectId,!0))}async _onLayerLoad(){let{layer:e,pageSize:t}=this;if(!e)return;e.parent&&S(e.parent)&&await e.parent.loadAll();let n=e.capabilities.query?.maxRecordCount,r=n&&n<t,i=r?n:t;r&&(this._logWarning(`The value for 'pageSize' has been adjusted due to the provided layer's max record count.`),this.pageSize=i),this.grid?.set(`pageSize`,i);try{this._generateColumns(),await this.store.load(),this.refreshPageCache()}catch{c.getLogger(this).error(`Unable to load the provided layer.`)}}_onLayerRefresh(e){this.autoRefreshEnabled&&e.dataChanged&&this.refresh()}_generateColumns(){this._drainColumns();let{_effectiveTableTemplate:e,_effectiveAttributeTableTemplate:t,layer:n}=this,r=e?.columnTemplates;if(!n)return;let i=this._generateColumnsFromColumnTemplates(n,r)??this._generateColumnsFromAttributeTableTemplate(n,t)??this._generateDefaultFieldColumns(n);i.length&&(this.attachmentsEnabled&&!i.some(e=>R(e))&&i.push(this._generateDefaultAttachmentsColumn(n)),this.relatedRecordsEnabled&&this.relationshipInfos.length&&!i.some(e=>B(e))&&i.push(...this._generateDefaultRelationshipColumns()),this.actionColumnConfig&&i.push(this._generateActionColumn()),i.sort((e,t)=>e.frozen&&t.frozen||e.frozenToEnd&&t.frozenToEnd?0:e.frozen||t.frozenToEnd?-1:0),this.columns.addMany(i))}_generateColumnsFromAttributeTableTemplate(e,t){if(!t)return null;let{elements:n,orderByFields:r}=t,a=C(e),o=[];o.push(...this._generateColumnsFromAttributeTableElements(e,n,r));let s=a.map(t=>{if(!t.fieldName||ne(t.fieldName,o))return null;let{fieldName:n}=t,i=X(e,n);return i?this._generateDefaultFieldColumn(e,i,{hidden:!0,orderByFields:r}):(this._logTemplateWarning(`A valid 'field' could not be found for the provided template.`),null)}).filter(i);return o.push(...s),this.attachmentsEnabled&&re(e)&&!o.some(e=>R(e))&&o.push(this._generateDefaultAttachmentsColumn(e,{hidden:!0})),this.relatedRecordsEnabled&&J(e)&&e.relationships?.forEach(({id:e},t)=>{let n=this.relationshipInfos.find(t=>t.relationshipId===e);n&&!o.some(t=>B(t)&&t.relationshipId===e)&&o.push(this._generateDefaultRelationshipColumn({hidden:!0,info:n,index:t}))}),o.length?o:null}_generateColumnsFromAttributeTableElements(e,t,n){return t?.map((t,r)=>{switch(t.type){case`field`:return this._createFieldColumnFromElement({layer:e,element:t,orderByFields:n});case`group`:return this._createGroupColumnFromElement({layer:e,element:t,orderByFields:n});case`attachment`:return this._createAttachmentColumnFromElement({layer:e,element:t,index:r});case`relationship`:return this._createRelationshipColumnFromElement({element:t,index:r})}}).filter(e=>!!e)??[]}_createFieldColumnFromElement(e){let{layer:t,element:n,orderByFields:r}=e,{fieldName:i}=n;if(i==null)return this._logTemplateWarning(`A valid 'fieldName' must be provided.`),null;let a=X(t,i);if(!a)return this._logTemplateWarning(`A valid 'field' could not be found for the provided template.`),null;let{description:o,label:s}=n,c=r?.findIndex(({field:e})=>e&&e===i)??-1,l=c>-1?r?.at(c)?.order:void 0,u=c>-1?c:void 0,{grid:d,messages:f,messagesCommon:p,messagesURIUtils:m,store:h,view:g}=this;return new A({description:o,direction:l,field:a,fieldName:i,grid:d,initialSortPriority:u,label:s,layer:t,messages:f,messagesCommon:p,messagesURIUtils:m,store:h,view:g,onShowPromptCallback:this._onShowPromptCallback})}_createGroupColumnFromElement(e){let{layer:t,element:n,orderByFields:r}=e,{description:i,label:a}=n;if(!a)return this._logTemplateWarning(`Group columns require a label.`),null;if(!n.elements.length)return this._logTemplateWarning(`Group columns require child columns.`),null;let{grid:o,messages:s,messagesCommon:c,messagesURIUtils:l,store:u}=this;return new F({columns:this._generateColumnsFromAttributeTableElements(t,n.elements,r),description:i,grid:o,label:a,messages:s,messagesCommon:c,messagesURIUtils:l,store:u})}_createAttachmentColumnFromElement(e){if(!this.attachmentsEnabled){this._logTemplateWarning(`The 'attachmentsEnabled' property is currently false.`);return}let{layer:t,element:n,index:r}=e,{description:i,label:a}=n,{grid:o,messages:s,messagesCommon:c,messagesURIUtils:l,store:u}=this;return new k({description:i,fieldName:`${Y.attachments}-${r}`,grid:o,label:a,layer:t,messages:s,messagesCommon:c,messagesURIUtils:l,store:u,onShowAttachments:e=>this._onShowAttachments(e)})}_createRelationshipColumnFromElement(e){if(!this.relatedRecordsEnabled){this._logTemplateWarning(`Relationship columns require related records to be enabled on the table.`);return}let{element:t,index:n}=e,{description:r,label:i,relationshipId:a}=t,o=this.relationshipInfos.find(e=>e.relationshipId===a);if(!o)return this._logTemplateWarning(`Unable to find valid related layer target based on the provided relationship id.`),null;let{grid:s,messages:c,messagesCommon:l,messagesURIUtils:u,store:d}=this;return new j({description:r,fieldName:`${Y.relationship}-${a}-${n}`,grid:s,label:i,messages:c,messagesCommon:l,messagesURIUtils:u,relationshipId:a,store:d,layer:o.relatedLayer,relatedLayer:o.layer,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateColumnsFromColumnTemplates(e,t){let{grid:n,messages:r,messagesCommon:i,messagesURIUtils:a,store:o,view:s}=this;if(!t?.length)return null;let c=[];return t.forEach((t,l)=>{let{autoWidth:u,description:d,direction:f,flexGrow:p,fieldName:m,formatFunction:h,frozen:g,frozenToEnd:_,icon:v,iconText:y,initialSortPriority:b,invalid:x,label:S,labelTooltipText:C,menuConfig:w,resizable:T,sortable:E,textAlign:D,textWrap:O,timeZone:k,type:j,width:N}=t;if(!j){this._logTemplateWarning(`Property 'type' is missing from the provided template.`);return}if(g&&_){this._logTemplateWarning(`Properties 'frozen' and 'frozenToEnd' cannot both be true for the same column.`);return}let P=t.visible===!1;if(j===`group`){if(!t.columnTemplates?.length){this._logTemplateWarning(`Group columns must contain column templates.`);return}if(!t.label){this._logTemplateWarning(`Group columns require a label.`);return}let o=this._generateColumnsFromColumnTemplates(e,t.columnTemplates),s=P||this._isFieldHidden(t.label);c.push(new F({autoWidth:u,columns:o,description:d,flexGrow:p,frozen:g,frozenToEnd:_,grid:n,hidden:s,icon:v,iconText:y,invalid:x,label:S,labelTooltipText:C,menuConfig:w,messages:r,messagesCommon:i,messagesURIUtils:a,resizable:T,textAlign:D,textWrap:O,timeZone:k,width:N}))}else if(j===`attachment`){if(!this.attachmentsEnabled){this._logTemplateWarning(`Attachment columns require attachments to be enabled on the table.`);return}c.push(this._generateAttachmentsColumnFromTemplate(e,t,l))}else if(j===`relationship`){if(!this.relatedRecordsEnabled){this._logTemplateWarning(`Relationship columns require related records to be enabled on the table.`);return}let{relationshipId:e}=t;if(e==null){this._logTemplateWarning(`Property 'relationshipId' is missing from the provided template.`);return}let n=this.relationshipInfos.find(t=>t.relationshipId===e);if(!n){this._logTemplateWarning(`Unable to find valid related layer target based on the provided relationship id.`);return}c.push(this._generateRelationshipColumnFromTemplate(n,t,l))}else if(!m){this._logTemplateWarning(`Value for 'fieldName' property was missing from the provided template.`);return}let I=P||this._isFieldHidden(m);if(j===`column`)c.push(new M({autoWidth:u,description:d,direction:f,fieldName:m,flexGrow:p,formatFunction:h,frozen:g,frozenToEnd:_,grid:n,hidden:I,icon:v,iconText:y,initialSortPriority:b,invalid:x,label:S,labelTooltipText:C,menuConfig:w,messages:r,messagesCommon:i,messagesURIUtils:a,resizable:T,sortable:E,store:o,textAlign:D,textWrap:O,timeZone:k,width:N}));else if(j===`field`){let l=X(e,t.fieldName);if(!l){this._logTemplateWarning(`A valid 'field' could not be found for the provided template.`);return}let{editable:m,required:j}=t;c.push(new A({autoWidth:u,description:d,direction:f,editable:m,field:l,fieldName:l.name,flexGrow:p,formatFunction:h,frozen:g,frozenToEnd:_,grid:n,hidden:I,icon:v,iconText:y,initialSortPriority:b,invalid:x,label:S,labelTooltipText:C,layer:e,messages:r,messagesCommon:i,messagesURIUtils:a,menuConfig:w,required:j,resizable:T,sortable:E,store:o,template:t,textAlign:D,textWrap:O,timeZone:k,width:N,view:s,onShowPromptCallback:this._onShowPromptCallback}))}}),c.length?c:null}_generateDefaultFieldColumns(e){return e.fields?.map(t=>this._generateDefaultFieldColumn(e,t)).filter(i)??[]}_generateDefaultFieldColumn(e,t,n){let{grid:r,messages:i,messagesCommon:a,messagesURIUtils:o,store:s,view:c}=this;if(!t.visible||t.type===`geometry`)return null;let l=n?.orderByFields,u=t.name,d=l?.findIndex(({field:e})=>e&&e===u)??-1,f=d>-1?l?.at(d)?.order:void 0,p=d>-1?d:void 0;return new A({direction:f,field:t,fieldName:u,grid:r,hidden:n?.hidden||this._isFieldHidden(u),initialSortPriority:p,layer:e,messages:i,messagesCommon:a,messagesURIUtils:o,store:s,view:c,onShowPromptCallback:this._onShowPromptCallback})}_generateAttachmentsColumnFromTemplate(e,t,n){let{grid:r,messages:i,messagesCommon:a,messagesURIUtils:o,store:s}=this,{attachmentsViewEnabled:c,autoWidth:l,description:u,flexGrow:d,fieldName:f,formatFunction:p,frozen:m,frozenToEnd:h,icon:g,iconText:_,invalid:v,label:y,labelTooltipText:b,menuConfig:x,resizable:S,textAlign:C,textWrap:w,thumbnailAppearance:T,thumbnailCount:E,thumbnailIconScale:D,thumbnailsEnabled:O,timeZone:A,width:j}=t;return new k({attachmentsViewEnabled:c,autoWidth:l,description:u,fieldName:`${Y.attachments}-${n}`,flexGrow:d,formatFunction:p,frozen:m,frozenToEnd:h,grid:r,hidden:t.visible===!1||this._isFieldHidden(y)||this._isFieldHidden(f),icon:g,iconText:_,invalid:v,label:y,labelTooltipText:b,layer:e,menuConfig:x,messages:i,messagesCommon:a,messagesURIUtils:o,resizable:S,store:s,textAlign:C,textWrap:w,thumbnailAppearance:T,thumbnailCount:E,thumbnailIconScale:D,thumbnailsEnabled:O,timeZone:A,width:j,onShowAttachments:e=>this._onShowAttachments(e)})}_generateDefaultAttachmentsColumn(e,t){let{grid:n,messages:r,messagesCommon:i,messagesURIUtils:a,store:o}=this,s=Y.attachments;return new k({fieldName:s,grid:n,hidden:t?.hidden||this._isFieldHidden(s),layer:e,messages:r,messagesCommon:i,messagesURIUtils:a,store:o,onShowAttachments:e=>this._onShowAttachments(e)})}_generateRelationshipColumnFromTemplate(e,t,n){let{grid:r,messages:i,messagesCommon:a,messagesURIUtils:o,store:s}=this,{autoWidth:c,collapsed:l,description:u,flexGrow:d,fieldName:f,formatFunction:p,frozen:m,frozenToEnd:h,icon:g,iconText:_,invalid:v,label:y,labelTooltipText:b,menuConfig:x,relationshipId:S,resizable:C,textAlign:w,textWrap:T,timeZone:E,width:D}=t;return new j({autoWidth:c,collapsed:l,description:u,fieldName:`${Y.relationship}-${S}-${n}`,flexGrow:d,formatFunction:p,frozen:m,frozenToEnd:h,grid:r,hidden:t.visible===!1||this._isFieldHidden(y)||this._isFieldHidden(f),icon:g,iconText:_,invalid:v,label:y,labelTooltipText:b,menuConfig:x,messages:i,messagesCommon:a,messagesURIUtils:o,relationshipId:S,resizable:C,store:s,textAlign:w,textWrap:T,timeZone:E,width:D,layer:e.relatedLayer,relatedLayer:e.layer,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateDefaultRelationshipColumns(){let{relationshipInfos:e,relationshipColumnConfigs:t}=this,n=[];return e?.length&&(t?t.forEach((t,r)=>{let{relationshipId:i}=t,a=e.find(e=>e.relationshipId===i);a&&n.push(this._generateDefaultRelationshipColumn({config:t,index:r,info:a}))}):e.forEach((e,t)=>n.push(this._generateDefaultRelationshipColumn({index:t,info:e})))),n}_generateDefaultRelationshipColumn(e){let{config:t,hidden:n,index:r,info:i}=e,{grid:a,messages:o,messagesCommon:s,messagesURIUtils:c,store:l}=this,{relationshipId:u}=i;return new j({...t,fieldName:`${Y.relationship}-${u}-${r}`,grid:a,hidden:!!n,messages:o,messagesCommon:s,messagesURIUtils:c,layer:i.relatedLayer,relatedLayer:i.layer,relationshipId:u,store:l,showRelatedTableCallback:e=>this._onShowRelatedTable(e)})}_generateActionColumn(){let e=this.actionColumnConfig,t=e?.frozen===!0?!1:e?.frozenToEnd??!0;return new O({hidden:this._isFieldHidden(Y.action),store:this.store,...e,frozenToEnd:t})}_isFieldHidden(e){let t=e?.toLowerCase();return(this.hiddenFields??this._defaultHiddenFields).some(e=>e.toLowerCase()===t)}_syncSelection(){let{layer:e}=this;D(e)?this.highlightIds.items=this.effectiveSelectionManager.getSelection(e)??[]:this.highlightIds.removeAll()}_addToSelection(e){let t=this.layer;D(t)&&this.effectiveSelectionManager.add(t,e)}_removeFromSelection(e){let t=this.layer;D(t)&&this.effectiveSelectionManager.remove(t,e)}async _onHighlightIdsChange(e){let{added:t,removed:n}=e,{attachmentsViewOptions:r}=this;if(this._removeFromSelection(n),this._addToSelection(t),this.filterBySelectionEnabled&&this._syncObjectIdsWithStore(this.highlightIds.toArray()),r.objectId!=null){let e=this.highlightIds.at(0);if(e!=null){let t=await this.store.getAttachmentsByObjectId(e,!0);r.set({attachmentInfos:t,objectId:e,mode:t.length?`list`:`file`}),this.getFeatureTitle(e)}}}_syncTableParentSelection(e){let{tableParent:t}=this;t&&e!=null&&t.highlightIds.add(e)}_onShowRelatedTable(e){let{highlightIds:t}=this,{objectId:n}=e;t.removeAll(),t.add(n),this.showRelatedTableCallback?this.showRelatedTableCallback(e):this.emit(`show-related-table`,e)}_onObjectIdsChange(){let e=this.objectIds.toArray();e.length&&this.filterBySelectionEnabled&&(this.filterBySelectionEnabled=!1,this._logWarning(`Object ID filter was applied while a selection filter was applied. Selection filter has been removed.`)),this._syncObjectIdsWithStore(e)}_syncObjectIdsWithStore(e){this.store.objectIds=e,this.refreshPageCache()}_drainColumns(){this.columns.drain(e=>!e.destroyed&&e.destroy())}_showAllRelatedTables(e){let t=e.layer;if(!t)return;let n=this._getDefaultLayerDisplayField(t);e.set({relationshipColumnConfigs:[],tableTemplateOverride:this._getTableTemplateForShowAllTablesView(e,n)});let r=e.hiddenFields;r.includes(Y.action)||r.add(Y.action),r.includes(Y.attachments)||r.add(Y.attachments)}_hideAllRelatedTables(e){let{layer:t,relationship:n}=e;if(t&&n?.id!=null){if(e.attachmentsViewOptions.objectId!=null){let n=this._getDefaultLayerDisplayField(t);e.set({multipleSelectionEnabledOverride:!1,relationshipColumnConfigs:[],showAllRelatedTables:!1,tableTemplateOverride:this._getTableTemplateForAttachmentsView(n)})}else e.set({multipleSelectionEnabledOverride:null,relationshipColumnConfigs:ie(t,n.id),showAllRelatedTables:!1,tableTemplateOverride:null}),e.hiddenFields.removeMany([Y.action,Y.attachments])}}_getTableTemplateForRelatedTableView(e,t,n){return new K({columnTemplates:[new W({fieldName:t,editable:!1,menuConfig:{selectionMode:`single`,icon:`chevron-down`,items:this._extractFieldColumnInfosFromTableTemplate(e.viewModel).map(([r,i])=>({selected:r===t,label:i||r,clickFunction:()=>{e.tableTemplateOverride=this._getTableTemplateForRelatedTableView(e,r,n)}}))},resizable:!1}),new G({autoWidth:!1,collapsed:!0,flexGrow:0,label:``,resizable:!1,relationshipId:n,width:Q})]})}_getTableTemplateForShowAllTablesView(e,t){let n=[new W({fieldName:t,editable:!1,menuConfig:{selectionMode:`single`,icon:`chevron-down`,items:this._extractFieldColumnInfosFromTableTemplate(e.viewModel).map(([n,r])=>({selected:n===t,label:r||n,clickFunction:()=>{e.tableTemplateOverride=this._getTableTemplateForShowAllTablesView(e,n)}}))},resizable:!1})];return e.attachmentsViewOptions.objectId!=null&&n.push(new I({attachmentsViewEnabled:!1,autoWidth:!1,flexGrow:0,label:``,resizable:!1,thumbnailsEnabled:!1,width:Q})),new K({columnTemplates:n})}async _onShowPromptCallback(e){let{column:t,objectId:n,oldValue:r,value:i}=e,{_subtypes:a,layer:o}=this;if(!o||!a.length){t.cancel();return}let s=a.find(e=>e.code===i);if(!s){t.cancel();return}let c=Promise.withResolvers(),l=this._createSubtypeEditPrompt(r,s,c),u=!!o.parent&&this.autoSaveEnabled;try{this.showPrompt(l);let e=await c.promise,r=[{fieldName:t.fieldName,value:i}];switch(e){case`update-fields`:for(let[e,t]of Object.entries(s.defaultValues))t!=null&&r.push({fieldName:e,value:t});await t.updateItems({objectId:n,updates:r}),u&&this.refresh();break;case`keep-existing`:await t.updateItems({objectId:n,updates:r}),u&&this.refresh();break;case`undo`:t.cancel()}}finally{this.clearPrompt()}}_createSubtypeEditPrompt(e,t,r){let{_subtypes:i,messages:a,messagesCommon:o}=this,s=i.find(t=>t.code===e)?.name??`${e}`,c=`update-fields`,l=[{label:a.subtypes.useDefaultValuesOption,value:`update-fields`},{label:a.subtypes.keepCurrentValuesOption,value:`keep-existing`}];return{context:`info`,title:a.subtypes.changeWarningTitle,message:n(a.subtypes.changeWarning,{originalType:s,newType:t.name}),radios:l,defaultRadioSelection:`update-fields`,onRadioSelection:e=>{c=e},actions:{primary:{label:o.apply,action:()=>r.resolve(c),type:`positive`},secondary:{label:o.cancel,type:`neutral`,action:()=>r.resolve(`undo`)}},cancel:()=>r.reject()}}_onShowAttachments({objectId:e}){this.hasPendingEdits||(this.attachmentsViewOptions.objectId=e)}_getTableTemplateForAttachmentsView(e){return new K({columnTemplates:[new W({fieldName:e,editable:!1,menuConfig:{selectionMode:`single`,icon:`chevron-down`,items:this._extractFieldColumnInfosFromTableTemplate(this).map(([t,n])=>({selected:t===e,label:n||t,clickFunction:()=>{this.tableTemplateOverride=this._getTableTemplateForAttachmentsView(t)}}))},resizable:!1}),new I({attachmentsViewEnabled:!1,autoWidth:!1,flexGrow:0,label:``,resizable:!1,thumbnailsEnabled:!1,width:Q})]})}_extractFieldColumnInfosFromTableTemplate(e){let{layer:t,tableTemplate:n}=e??this;return n?n.columnTemplates.filter(({type:e})=>e===`field`||e===`column`).map(({fieldName:e,label:n})=>{if(n!=null&&n!==``)return[e,n];let r=t?.fieldsIndex.get(e);return[e,r&&v(r,t)]}):t?.fields.map(e=>[e.name,v(e,t)])??[]}_getDefaultLayerDisplayField(e){let{displayField:t,objectIdField:n}=e;return t&&t.trim()!==``?t:n||(e.fields.length?e.fields[0].name:``)}_getIndexOfFirstFrozenToEndColumn(){let e=this.columns.findIndex(e=>e.frozenToEnd);return e>-1?e:void 0}_logWarning(e,t){t?c.getLogger(this).warnOnce(e):c.getLogger(this).warn(e)}_logTemplateWarning(e){this._logWarning(`${e} Skipped generating a column using the provided template.`,!0)}_onCellInteraction(e){e!=null&&this.attachmentsViewOptions.objectId!=null&&this.highlightIds.add(e)}};e([g()],$.prototype,`_defaultHiddenFields`,null),e([g()],$.prototype,`_effectiveTableTemplate`,null),e([g()],$.prototype,`_effectiveAttributeTableTemplate`,null),e([g()],$.prototype,`_subtypes`,null),e([g()],$.prototype,`activeFilters`,null),e([g({readOnly:!0})],$.prototype,`activeSortOrders`,null),e([g()],$.prototype,`allRelatedTablesVisible`,null),e([g()],$.prototype,`attachmentsColumns`,null),e([g()],$.prototype,`attachmentsEnabled`,null),e([g()],$.prototype,`attachmentsViewOptions`,void 0),e([g({type:w})],$.prototype,`attributeTableTemplate`,void 0),e([g()],$.prototype,`autoRefreshEnabled`,void 0),e([g()],$.prototype,`autoSaveEnabled`,null),e([g()],$.prototype,`cachedPageCount`,null),e([g()],$.prototype,`canAddRelatedFeature`,null),e([g()],$.prototype,`clearPrompt`,null),e([g({readOnly:!0})],$.prototype,`columns`,void 0),e([g()],$.prototype,`dataProvider`,void 0),e([g()],$.prototype,`defaultSelectionManager`,null),e([g()],$.prototype,`definitionExpression`,null),e([g()],$.prototype,`effectiveSelectionManager`,null),e([g()],$.prototype,`effectiveTimeExtent`,null),e([g()],$.prototype,`effectiveWhere`,null),e([g()],$.prototype,`fieldColumns`,null),e([g()],$.prototype,`filterByViewExtent`,null),e([g()],$.prototype,`filterByLayerScaleRange`,null),e([g({types:y})],$.prototype,`filterGeometry`,null),e([g()],$.prototype,`filterBySelectionEnabled`,null),e([g({readOnly:!0})],$.prototype,`grid`,void 0),e([g()],$.prototype,`hasContingentValues`,null),e([g()],$.prototype,`hasInvalidPendingEdits`,null),e([g()],$.prototype,`hasPendingEdits`,null),e([g()],$.prototype,`hiddenFields`,null),e([g()],$.prototype,`highlightEnabled`,null),e([g()],$.prototype,`initialSize`,null),e([g()],$.prototype,`isQueryingOrSyncing`,null),e([g()],$.prototype,`isSyncingAttachments`,null),e([g()],$.prototype,`layer`,null),e([g()],$.prototype,`layers`,void 0),e([g()],$.prototype,`layerFieldConfigurations`,null),e([g()],$.prototype,`layerView`,null),e([g()],$.prototype,`menuConfig`,void 0),e([g()],$.prototype,`messages`,void 0),e([g(),Z(`esri/t9n/common`)],$.prototype,`messagesCommon`,void 0),e([g(),Z(`esri/core/t9n/Units`)],$.prototype,`messagesUnits`,void 0),e([g(),Z(`esri/widgets/support/t9n/uriUtils`)],$.prototype,`messagesURIUtils`,void 0),e([g()],$.prototype,`outFields`,null),e([g()],$.prototype,`pendingEditsCount`,null),e([g()],$.prototype,`prompt`,void 0),e([g()],$.prototype,`relatedRecordsEnabled`,null),e([g()],$.prototype,`relatedTable`,null),e([g()],$.prototype,`relatedTableHasContingentValues`,null),e([g()],$.prototype,`relatedTables`,void 0),e([g()],$.prototype,`relationship`,null),e([g()],$.prototype,`relationshipColumnConfigs`,void 0),e([g()],$.prototype,`relationshipColumns`,null),e([g()],$.prototype,`relationshipConfig`,null),e([g()],$.prototype,`relationshipInfos`,null),e([g()],$.prototype,`relationships`,null),e([g()],$.prototype,`returnGeometryEnabled`,null),e([g()],$.prototype,`returnMEnabled`,null),e([g()],$.prototype,`returnZEnabled`,null),e([g()],$.prototype,`selectionManager`,null),e([g()],$.prototype,`selectionSource`,null),e([g()],$.prototype,`showAllRelatedTables`,null),e([g()],$.prototype,`showPrompt`,null),e([g()],$.prototype,`showRelatedTableCallback`,void 0),e([g({readOnly:!0,type:U})],$.prototype,`store`,void 0),e([g()],$.prototype,`supportsAttachments`,null),e([g()],$.prototype,`supportsAddAttachments`,null),e([g()],$.prototype,`supportsDeleteAttachments`,null),e([g()],$.prototype,`supportsResizeAttachments`,null),e([g()],$.prototype,`supportsUpdateAttachments`,null),e([g()],$.prototype,`syncTemplateOnChangesEnabled`,void 0),e([g()],$.prototype,`syncViewSelection`,null),e([g()],$.prototype,`tableController`,void 0),e([g()],$.prototype,`tableParent`,void 0),e([g({type:K})],$.prototype,`tableTemplate`,void 0),e([g()],$.prototype,`tableTemplateOverride`,void 0),e([g({type:E})],$.prototype,`timeExtent`,null),e([g()],$.prototype,`timeZone`,null),e([g()],$.prototype,`view`,null),e([g()],$.prototype,`viewTimeEnabled`,null),$=e([_(`esri.widgets.FeatureTable.FeatureTableViewModel`)],$);const oe=$;export{oe as default};