@arcgis/core 4.28.0-next.20230621 → 4.28.0-next.20230623

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 (249) hide show
  1. package/Basemap.js +1 -1
  2. package/arcade/ArcadeModuleResolver.js +1 -1
  3. package/arcade/Feature.js +1 -1
  4. package/arcade/arcadeCompiler.js +1 -1
  5. package/arcade/arcadeTimeUtils.js +1 -1
  6. package/arcade/featureset/actions/GroupBy.js +1 -1
  7. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  8. package/arcade/featureset/support/sqlUtils.js +1 -1
  9. package/arcade/functions/date.js +1 -1
  10. package/arcade/functions/geomasync.js +1 -1
  11. package/arcade/functions/geometry.js +1 -1
  12. package/arcade/functions/geomsync.js +1 -1
  13. package/arcade/functions/string.js +1 -1
  14. package/arcade/languageUtils.js +1 -1
  15. package/assets/esri/core/workers/RemoteClient.js +1 -1
  16. package/assets/esri/core/workers/chunks/0380e9f61b6f3ca85139.js +1 -0
  17. package/assets/esri/core/workers/chunks/0bd95f46a0a9005a19f9.js +1 -0
  18. package/assets/esri/core/workers/chunks/0c621046b7211cdde980.js +1 -0
  19. package/assets/esri/core/workers/chunks/0e0267739728e5413f1d.js +1 -0
  20. package/assets/esri/core/workers/chunks/{39079bcfd35ed73c4e34.js → 156e801a3262f0ac79c0.js} +1 -1
  21. package/assets/esri/core/workers/chunks/19b4f02fb2392d964582.js +1 -0
  22. package/assets/esri/core/workers/chunks/1ae75f5282e983f6d768.js +1 -0
  23. package/assets/esri/core/workers/chunks/2179b3e9e532ca8ef982.js +1 -0
  24. package/assets/esri/core/workers/chunks/21aaa7fa0e5482670010.js +1 -0
  25. package/assets/esri/core/workers/chunks/26212a08ea383547335b.js +1 -0
  26. package/assets/esri/core/workers/chunks/{2420ec029236ab31d908.js → 2882a55a971af1f7858b.js} +1 -1
  27. package/assets/esri/core/workers/chunks/294285f2822c101326ec.js +1 -0
  28. package/assets/esri/core/workers/chunks/29f9a380610e4fd98a7c.js +1 -0
  29. package/assets/esri/core/workers/chunks/303238fc2fcdbb277981.js +1 -0
  30. package/assets/esri/core/workers/chunks/{3db8ae98799c752afe60.js → 34958516e604d487c625.js} +1 -1
  31. package/assets/esri/core/workers/chunks/3bee743f4c9370045a5d.js +1 -0
  32. package/assets/esri/core/workers/chunks/{8e08968505483dc58e00.js → 40ee4e0a5000a08c3abd.js} +1 -1
  33. package/assets/esri/core/workers/chunks/4128e45e17c9e5280e11.js +1 -0
  34. package/assets/esri/core/workers/chunks/4f88c4d1d2103843aca8.js +1 -0
  35. package/assets/esri/core/workers/chunks/505792ce8cbbddd2e815.js +1 -0
  36. package/assets/esri/core/workers/chunks/{3d42fa4ab5f8632d690a.js → 5237b3938be0d4bc6045.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{57077e608f20d3a931e8.js → 570e94f4fbefc856d303.js} +1 -1
  38. package/assets/esri/core/workers/chunks/{4b235d1b6a72773cd4f4.js → 57bb8516fa998a0fba78.js} +1 -1
  39. package/assets/esri/core/workers/chunks/57bf3ff01d738cedc292.js +1 -0
  40. package/assets/esri/core/workers/chunks/{1e9e68312cd865358260.js → 60486acc5dacf73f851a.js} +1 -1
  41. package/assets/esri/core/workers/chunks/6208f2dfa9dfd3bca000.js +1 -0
  42. package/assets/esri/core/workers/chunks/64008bde5d3ffd9f2499.js +1 -0
  43. package/assets/esri/core/workers/chunks/69f51a7768bf51c9e346.js +1 -0
  44. package/assets/esri/core/workers/chunks/719f741a0e45c3e694ba.js +1 -0
  45. package/assets/esri/core/workers/chunks/{cfe379a78a983373b3ac.js → 7304f45f5622a68253e4.js} +1 -1
  46. package/assets/esri/core/workers/chunks/733b70d6e5c466a67e9c.js +1 -0
  47. package/assets/esri/core/workers/chunks/7694521b44681d52b713.js +1 -0
  48. package/assets/esri/core/workers/chunks/840fd05ceaa038c476d6.js +1 -0
  49. package/assets/esri/core/workers/chunks/89f7fd2ab92aa14fe0c0.js +1 -0
  50. package/assets/esri/core/workers/chunks/8a6f29f2ebd59783bb1b.js +1 -0
  51. package/assets/esri/core/workers/chunks/9d487b7817ccf5bceff6.js +1 -0
  52. package/assets/esri/core/workers/chunks/{42b6315e21c4c1345ba5.js → 9f5337a80963e0b3c009.js} +1 -1
  53. package/assets/esri/core/workers/chunks/a0face18b3ea567999ef.js +1 -0
  54. package/assets/esri/core/workers/chunks/b773c8854e98384ac8ac.js +1 -0
  55. package/assets/esri/core/workers/chunks/{fb44d872b9dbadcf8ccf.js → b9ef05c22bc3e395bcb3.js} +1 -1
  56. package/assets/esri/core/workers/chunks/bc5e34200776cfc83d5b.js +1 -0
  57. package/assets/esri/core/workers/chunks/{cfc3dcca2b69d20d5375.js → c0b9cc091efd5db827de.js} +1 -1
  58. package/assets/esri/core/workers/chunks/c9f5e949830196ad9458.js +1 -0
  59. package/assets/esri/core/workers/chunks/{036301f545aba2b8e485.js → cc15e28a99694120556d.js} +1 -1
  60. package/assets/esri/core/workers/chunks/ce7f575a6c2053c7ca17.js +1 -0
  61. package/assets/esri/core/workers/chunks/ce9c99cee3d1a3963e7c.js +1 -0
  62. package/assets/esri/core/workers/chunks/cf9a87b53ea74bae6a37.js +1 -0
  63. package/assets/esri/core/workers/chunks/d16850b98a53ade0de10.js +1 -0
  64. package/assets/esri/core/workers/chunks/d24f7ef6eca8c91b90b4.js +1 -0
  65. package/assets/esri/core/workers/chunks/dbd86e4b7983873cbe7c.js +1 -0
  66. package/assets/esri/core/workers/chunks/{3c3f65913006b84b2289.js → de20572d334abd4a7d82.js} +1 -1
  67. package/assets/esri/core/workers/chunks/e009e7f074a572894f48.js +1 -0
  68. package/assets/esri/core/workers/chunks/{cb004c492e22c50f9bfa.js → f3eb89cff63e00f036c6.js} +1 -1
  69. package/assets/esri/core/workers/chunks/{b2a423d9ce8bb784267c.js → f53f20c7100092823487.js} +1 -1
  70. package/assets/esri/core/workers/chunks/f6040205c50e2795a1a0.js +1 -0
  71. package/assets/esri/core/workers/chunks/{915734255a79bff3ef0f.js → fcd54e9e64c2864f183c.js} +1 -1
  72. package/assets/esri/t9n/common.json +1 -1
  73. package/assets/esri/t9n/common_en.json +1 -1
  74. package/assets/esri/themes/base/_core.scss +6 -2
  75. package/assets/esri/themes/base/_mixins.scss +0 -147
  76. package/assets/esri/themes/base/widgets/_AreaMeasurement2D.scss +0 -8
  77. package/assets/esri/themes/base/widgets/_AreaMeasurement3D.scss +0 -8
  78. package/assets/esri/themes/base/widgets/_DirectLineMeasurement3D.scss +0 -1
  79. package/assets/esri/themes/base/widgets/_DistanceMeasurement2D.scss +0 -1
  80. package/assets/esri/themes/base/widgets/_MeasurementWidgetContent.scss +67 -0
  81. package/assets/esri/themes/base/widgets/_Slice.scss +17 -54
  82. package/assets/esri/themes/base/widgets/_UnitSelect.scss +14 -0
  83. package/assets/esri/themes/dark/main.css +1 -1
  84. package/assets/esri/themes/light/main.css +1 -1
  85. package/assets/esri/themes/light/view.css +1 -1
  86. package/assets/esri/widgets/AreaMeasurement2D/t9n/AreaMeasurement2D.json +1 -1
  87. package/assets/esri/widgets/AreaMeasurement2D/t9n/AreaMeasurement2D_en.json +1 -1
  88. package/assets/esri/widgets/AreaMeasurement3D/t9n/AreaMeasurement3D.json +1 -1
  89. package/assets/esri/widgets/AreaMeasurement3D/t9n/AreaMeasurement3D_en.json +1 -1
  90. package/assets/esri/widgets/DirectLineMeasurement3D/t9n/DirectLineMeasurement3D.json +1 -1
  91. package/assets/esri/widgets/DirectLineMeasurement3D/t9n/DirectLineMeasurement3D_en.json +1 -1
  92. package/assets/esri/widgets/DistanceMeasurement2D/t9n/DistanceMeasurement2D.json +1 -1
  93. package/assets/esri/widgets/DistanceMeasurement2D/t9n/DistanceMeasurement2D_en.json +1 -1
  94. package/chunks/HUDMaterial.glsl.js +39 -39
  95. package/chunks/HighlightBlur.glsl.js +2 -2
  96. package/chunks/ShadowHighlight.glsl.js +1 -1
  97. package/chunks/arcade.js +1 -1
  98. package/chunks/languageUtils.js +1 -1
  99. package/core/HandleOwner.js +1 -1
  100. package/core/promiseUtils.js +1 -1
  101. package/core/support/{WatchUpdatingTracking.js → UpdatingHandles.js} +1 -1
  102. package/core/workers/workerFactory.js +1 -1
  103. package/geometry/projection.js +1 -1
  104. package/interfaces.d.ts +270 -5
  105. package/kernel.js +1 -1
  106. package/layers/Layer.js +1 -1
  107. package/layers/LinkChartLayer.d.ts +4 -0
  108. package/layers/LinkChartLayer.js +1 -1
  109. package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
  110. package/layers/mixins/PortalLayer.js +1 -1
  111. package/layers/support/TileInfoTilemapCache.js +1 -1
  112. package/package.json +1 -1
  113. package/support/revision.js +1 -1
  114. package/symbols/cim/cimAnalyzer.js +1 -1
  115. package/views/2d/layers/features/controllers/FeatureController2D.js +1 -1
  116. package/views/2d/layers/features/sources/DataTileSource.js +1 -1
  117. package/views/2d/layers/features/support/AttributeStore.js +1 -1
  118. package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
  119. package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
  120. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  121. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  122. package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
  123. package/views/3d/analysis/LineOfSight/LineOfSightVisualization.js +1 -1
  124. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  125. package/views/3d/environment/CloudsGenerator.js +1 -1
  126. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  127. package/views/3d/environment/Precipitation.js +1 -1
  128. package/views/3d/environment/SceneViewEnvironmentManager.js +1 -1
  129. package/views/3d/environment/Stars.js +1 -1
  130. package/views/3d/interactive/editingTools/moveGraphic/GraphicMoveTool.js +1 -1
  131. package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
  132. package/views/3d/interactive/editingTools/transformGraphic/GraphicTransformTool.js +1 -1
  133. package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js +1 -1
  134. package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
  135. package/views/3d/interactive/visualElements/PointVisualElement.js +1 -1
  136. package/views/3d/layers/I3SMeshView3D.js +1 -1
  137. package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
  138. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  139. package/views/3d/layers/graphics/Graphics3DFeatureProcessor.js +1 -1
  140. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  141. package/views/3d/layers/graphics/Graphics3DLineCalloutSymbolLayer.js +1 -1
  142. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  143. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  144. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  145. package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
  146. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  147. package/views/3d/layers/graphics/Graphics3DScaleVisibility.js +1 -1
  148. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  149. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  150. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  151. package/views/3d/layers/graphics/GraphicsProcessor.js +1 -1
  152. package/views/3d/layers/graphics/Labeler.js +1 -1
  153. package/views/3d/layers/graphics/labelPlacement.js +1 -1
  154. package/views/3d/layers/support/FeatureTileTree3DDebugger.js +1 -1
  155. package/views/3d/layers/support/FeatureVisibilityFilter.js +1 -1
  156. package/views/3d/layers/support/HeatmapFeatureProcessor.js +1 -1
  157. package/views/3d/state/ViewState.js +1 -1
  158. package/views/3d/state/ViewStateManager.js +1 -1
  159. package/views/3d/support/DisplayQualityProfile.js +1 -1
  160. package/views/3d/support/MemoryController.js +1 -1
  161. package/views/3d/support/SceneViewPerformanceInfo.js +1 -1
  162. package/views/3d/support/cameraUtils.js +1 -1
  163. package/views/3d/support/viewpointUtils.js +1 -1
  164. package/views/3d/terrain/OverlayFramebufferObject.js +1 -1
  165. package/views/3d/terrain/OverlayManager.js +1 -1
  166. package/views/3d/terrain/OverlayRenderer.js +1 -1
  167. package/views/3d/terrain/TerrainSurface.js +1 -1
  168. package/views/3d/webgl-engine/Stage.js +1 -1
  169. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  170. package/views/3d/webgl-engine/core/shaderLibrary/hud/HUDOcclusionPass.glsl.js +6 -7
  171. package/views/3d/webgl-engine/core/shaderLibrary/output/OutputHighlight.glsl.js +1 -1
  172. package/views/3d/webgl-engine/lib/Highlight.js +1 -1
  173. package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
  174. package/views/3d/webgl-engine/lib/RenderPluginManager.js +1 -1
  175. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  176. package/views/3d/webgl-engine/lib/SSAOHelper.js +1 -1
  177. package/views/3d/webgl-engine/lib/SmaaRenderPass.js +1 -1
  178. package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
  179. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  180. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  181. package/views/LayerViewManager.js +1 -1
  182. package/views/ToolViewManager.js +1 -1
  183. package/views/draw/DrawOperation.js +1 -1
  184. package/views/draw/PointDrawAction.js +1 -1
  185. package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
  186. package/views/interactive/snapping/featureSources/FeatureServiceSnappingSource.js +1 -1
  187. package/views/interactive/snapping/featureSources/GraphicsSnappingSource.js +1 -1
  188. package/views/interactive/snapping/featureSources/I3SSnappingSource.js +1 -1
  189. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
  190. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js +1 -1
  191. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiledFetcher.js +1 -1
  192. package/views/layers/LayerView.js +1 -1
  193. package/views/overlay/ViewOverlay.js +1 -1
  194. package/views/webgl/Texture.js +1 -1
  195. package/widgets/AreaMeasurement2D.js +1 -1
  196. package/widgets/AreaMeasurement3D.js +1 -1
  197. package/widgets/DirectLineMeasurement3D.js +1 -1
  198. package/widgets/DistanceMeasurement2D.js +1 -1
  199. package/widgets/Editor/EditorViewModel.js +1 -1
  200. package/widgets/Editor/Workflow.js +1 -1
  201. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  202. package/widgets/FeatureForm/FieldInput.js +1 -1
  203. package/widgets/FeatureForm/FormExpressionArcadeExecutor.js +1 -1
  204. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  205. package/widgets/OrientedImageryViewer.js +1 -1
  206. package/widgets/Slice.js +1 -1
  207. package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.js +1 -1
  208. package/widgets/support/MeasurementWidgetContent.js +5 -0
  209. package/widgets/support/UnitSelect.js +5 -0
  210. package/assets/esri/core/workers/chunks/0254165377538522c830.js +0 -1
  211. package/assets/esri/core/workers/chunks/07f16ea775b39a1a4a7b.js +0 -1
  212. package/assets/esri/core/workers/chunks/170c72126d10b1fdb2b0.js +0 -1
  213. package/assets/esri/core/workers/chunks/1bbc868d2430103951eb.js +0 -1
  214. package/assets/esri/core/workers/chunks/1d2ef88a8d028adef102.js +0 -1
  215. package/assets/esri/core/workers/chunks/2ef70c9b2484a11b7435.js +0 -1
  216. package/assets/esri/core/workers/chunks/39ae4b9b766f674bc6f2.js +0 -1
  217. package/assets/esri/core/workers/chunks/3b3d676b609c47a77164.js +0 -1
  218. package/assets/esri/core/workers/chunks/3d9a8cb638cf9b8ca4b3.js +0 -1
  219. package/assets/esri/core/workers/chunks/42f3421740a5479559dc.js +0 -1
  220. package/assets/esri/core/workers/chunks/45629ff775e77234b227.js +0 -1
  221. package/assets/esri/core/workers/chunks/52315f93a6f0ad59bd90.js +0 -1
  222. package/assets/esri/core/workers/chunks/5bb96e602d7cecbecf54.js +0 -1
  223. package/assets/esri/core/workers/chunks/63322229183f1d4eaa70.js +0 -1
  224. package/assets/esri/core/workers/chunks/642510b0371311ff8e16.js +0 -1
  225. package/assets/esri/core/workers/chunks/6995ace1d25d67c98d0e.js +0 -1
  226. package/assets/esri/core/workers/chunks/7e4013f8c31c9a9438c6.js +0 -1
  227. package/assets/esri/core/workers/chunks/82939ead43848a13f765.js +0 -1
  228. package/assets/esri/core/workers/chunks/8b6b963230df56850580.js +0 -1
  229. package/assets/esri/core/workers/chunks/95ff92d7caa34664d58f.js +0 -1
  230. package/assets/esri/core/workers/chunks/9e570cd4a48c30c83ae6.js +0 -1
  231. package/assets/esri/core/workers/chunks/a9e9297267614c4c4f3b.js +0 -1
  232. package/assets/esri/core/workers/chunks/b052463ffb7cb32306dc.js +0 -1
  233. package/assets/esri/core/workers/chunks/b31974524932e638df8c.js +0 -1
  234. package/assets/esri/core/workers/chunks/b75b4b132dbd9cb9d372.js +0 -1
  235. package/assets/esri/core/workers/chunks/c1dfbda75abc748a6ca4.js +0 -1
  236. package/assets/esri/core/workers/chunks/c8702e53a8ad6cf6ab85.js +0 -1
  237. package/assets/esri/core/workers/chunks/c90416e7bf29eb1d4536.js +0 -1
  238. package/assets/esri/core/workers/chunks/cad7a2092ea7f51dbd8b.js +0 -1
  239. package/assets/esri/core/workers/chunks/d0e2b42dca51711f2c6f.js +0 -1
  240. package/assets/esri/core/workers/chunks/d2a127f7bb0e2ba14a13.js +0 -1
  241. package/assets/esri/core/workers/chunks/df96824a6f76bad1370c.js +0 -1
  242. package/assets/esri/core/workers/chunks/e097f41bbfac00250477.js +0 -1
  243. package/assets/esri/core/workers/chunks/e3243d120a23a9b48392.js +0 -1
  244. package/assets/esri/core/workers/chunks/e55f80b774e090a0aa04.js +0 -1
  245. package/assets/esri/core/workers/chunks/e668c7e2e61aae6ca6e0.js +0 -1
  246. package/assets/esri/core/workers/chunks/ef900614353505afb210.js +0 -1
  247. package/assets/esri/core/workers/chunks/f0299d93a95f40ea7cf7.js +0 -1
  248. package/assets/esri/core/workers/chunks/f23b95d7e51a144ad065.js +0 -1
  249. package/assets/esri/core/workers/chunks/f263e73a25fae4beffae.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import{ignoreAbortErrors as t}from"../core/promiseUtils.js";import{isMeasurementSystem as s}from"../core/unitUtils.js";import{property as i}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as r}from"../core/accessorSupport/decorators/subclass.js";import n from"./Widget.js";import a from"./AreaMeasurement2D/AreaMeasurement2DViewModel.js";import{accessibleHandler as o}from"./support/decorators/accessibleHandler.js";import{messageBundle as l}from"./support/decorators/messageBundle.js";import{tsx as u}from"./support/jsxFactory.js";import"./support/widgetUtils.js";const m="esri-area-measurement-2d",p=`${m}__units`,c=`${m}__measurement`,d={buttonDisabled:"esri-button--disabled",widgetIcon:"esri-icon-measure-area",base:`${m} esri-widget esri-widget--panel`,container:`${m}__container`,hint:`${m}__hint`,hintText:`${m}__hint-text`,panelError:`${m}__panel--error`,measurement:c,measurementItem:`${c}-item`,measurementItemDisabled:`${c}-item--disabled`,measurementItemTitle:`${c}-item-title`,measurementItemValue:`${c}-item-value`,settings:`${m}__settings`,units:p,unitsLabel:`${p}-label`,unitsSelect:`${p}-select esri-select`,unitsSelectWrapper:`${p}-select-wrapper`,actionSection:`${m}__actions`,newMeasurementButton:`${m}__clear-button esri-button esri-button--primary`};let v=class extends n{constructor(e,t){super(e,t),this.iconClass=d.widgetIcon,this.icon=null,this.messages=null,this.messagesUnits=null,this.viewModel=new a}get active(){return this.viewModel.active}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get unit(){return this.viewModel.unit}set unit(e){this.viewModel.unit=e}get unitOptions(){return this.viewModel.unitOptions}set unitOptions(e){this.viewModel.unitOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}render(){const{id:e,viewModel:t,visible:i}=this,{active:r,supported:n,measurementLabel:a,state:o,unit:l,unitOptions:m}=t,p="disabled"===o,c="ready"===o,v="measuring"===o||"measured"===o,{messages:b,messagesUnits:h}=this,w=r&&c?u("section",{key:"hint",class:d.hint},u("p",{class:d.hintText},b.hint)):null,g=n?null:u("section",{key:"unsupported",class:d.panelError},u("p",null,b.unsupported)),y=(e,t,s)=>t?u("div",{key:`${s}-enabled`,class:d.measurementItem},u("span",{class:d.measurementItemTitle},e),u("span",{"aria-live":"polite",class:d.measurementItemValue},t)):u("div",{key:`${s}-disabled`,class:this.classes(d.measurementItem,d.measurementItemDisabled),"aria-disabled":"true"},u("span",{class:d.measurementItemTitle},e)),M=v?u("section",{key:"measurement",class:d.measurement},y(b.area,a?.area,"area"),y(b.perimeter,a?.perimeter,"perimeter")):null,_=`${e}__units`,$=u("section",{key:"units",class:d.units},u("label",{class:d.unitsLabel,for:_},b.unit),u("div",{class:d.unitsSelectWrapper},u("select",{class:d.unitsSelect,id:_,onchange:this._changeUnit,bind:this,value:l},m.map((e=>u("option",{key:e,value:e},s(e)?h.systems[e]:h.units[e]?.pluralCapitalized)))))),j=v?u("div",{key:"settings",class:d.settings},$):null,I=!n||r&&!v?null:u("div",{class:d.actionSection},u("button",{"aria-label":b.newMeasurement,bind:this,class:this.classes(d.newMeasurementButton,p&&d.buttonDisabled),disabled:p,onclick:this._newMeasurement,title:b.newMeasurement,type:"button"},b.newMeasurement)),f=i?u("div",{class:d.container},g,w,j,M,I):null;return u("div",{"aria-label":b.widgetLabel,class:d.base,role:"region"},f)}_newMeasurement(){t(this.viewModel.start())}_changeUnit(e){const t=e.target,s=t.options[t.selectedIndex];s&&(this.viewModel.unit=s.value)}};e([i({readOnly:!0})],v.prototype,"active",null),e([i()],v.prototype,"iconClass",void 0),e([i()],v.prototype,"icon",void 0),e([i()],v.prototype,"label",null),e([i(),l("esri/widgets/AreaMeasurement2D/t9n/AreaMeasurement2D")],v.prototype,"messages",void 0),e([i(),l("esri/core/t9n/Units")],v.prototype,"messagesUnits",void 0),e([i()],v.prototype,"uiStrings",void 0),e([i()],v.prototype,"unit",null),e([i()],v.prototype,"unitOptions",null),e([i()],v.prototype,"view",null),e([i({type:a})],v.prototype,"viewModel",void 0),e([i({type:Boolean})],v.prototype,"visible",null),e([o()],v.prototype,"_newMeasurement",null),e([o()],v.prototype,"_changeUnit",null),v=e([r("esri.widgets.AreaMeasurement2D")],v);const b=v;export{b as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import{ignoreAbortErrors as t}from"../core/promiseUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as i}from"../core/accessorSupport/decorators/subclass.js";import o from"./Widget.js";import r from"./AreaMeasurement2D/AreaMeasurement2DViewModel.js";import{MeasurementWidgetContent as n}from"./support/MeasurementWidgetContent.js";import"./support/widgetUtils.js";import{messageBundle as a}from"./support/decorators/messageBundle.js";import{tsx as l}from"./support/jsxFactory.js";const p="esri-area-measurement-2d",u={base:`${p} esri-widget esri-widget--panel`,newMeasurementButton:`${p}__clear-button`,widgetIcon:"esri-icon-measure-area"};let m=class extends o{constructor(e,t){super(e,t),this.iconClass=u.widgetIcon,this.icon=null,this.messages=null,this.messagesUnits=null,this.messagesCommon=null,this.viewModel=new r}get active(){return this.viewModel.active}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get unit(){return this.viewModel.unit}set unit(e){this.viewModel.unit=e}get unitOptions(){return this.viewModel.unitOptions}set unitOptions(e){this.viewModel.unitOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}render(){const{messages:e,messagesCommon:s,messagesUnits:i,unit:o,unitOptions:r,viewModel:a,visible:p}=this,{active:m,measurementLabel:d,state:c,supported:v}=a;return l("div",{"aria-label":e.widgetLabel,key:this,class:u.base,role:"presentation"},p?l(n,{active:m,measurementItems:[{key:"area",title:i?.measures.area,value:d?.area},{key:"perimeter",title:e.perimeter,value:d?.perimeter}],messages:{...e,notApplicable:s.notApplicable},newMeasurementButtonClass:u.newMeasurementButton,onNewMeasurementClick:()=>{t(a.start())},onUnitChange:e=>{this.unit=e},state:c,supported:v,unit:o,unitOptions:r}):null)}};e([s({readOnly:!0})],m.prototype,"active",null),e([s()],m.prototype,"iconClass",void 0),e([s()],m.prototype,"icon",void 0),e([s()],m.prototype,"label",null),e([s(),a("esri/widgets/AreaMeasurement2D/t9n/AreaMeasurement2D")],m.prototype,"messages",void 0),e([s(),a("esri/core/t9n/Units")],m.prototype,"messagesUnits",void 0),e([s(),a("esri/t9n/common")],m.prototype,"messagesCommon",void 0),e([s()],m.prototype,"uiStrings",void 0),e([s()],m.prototype,"unit",null),e([s()],m.prototype,"unitOptions",null),e([s()],m.prototype,"view",null),e([s({type:r})],m.prototype,"viewModel",void 0),e([s({type:Boolean})],m.prototype,"visible",null),m=e([i("esri.widgets.AreaMeasurement2D")],m);const d=m;export{d as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import{ignoreAbortErrors as t}from"../core/promiseUtils.js";import{isMeasurementSystem as s}from"../core/unitUtils.js";import{property as i}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";import r from"./Widget.js";import a from"./AreaMeasurement3D/AreaMeasurement3DViewModel.js";import{accessibleHandler as l}from"./support/decorators/accessibleHandler.js";import{messageBundle as o}from"./support/decorators/messageBundle.js";import{tsx as u}from"./support/jsxFactory.js";import"./support/widgetUtils.js";const m="esri-area-measurement-3d",p=`${m}__measurement`,c=`${m}__units`,d={buttonDisabled:"esri-button--disabled",base:`${m} esri-widget esri-widget--panel`,container:`${m}__container`,hint:`${m}__hint`,hintText:`${m}__hint-text`,panelError:`${m}__panel--error`,measurement:p,measurementItem:`${p}-item`,measurementItemDisabled:`${p}-item--disabled`,measurementItemTitle:`${p}-item-title`,measurementItemValue:`${p}-item-value`,settings:`${m}__settings`,units:c,unitsLabel:`${c}-label`,unitsSelect:`${c}-select esri-select`,unitsSelectWrapper:`${c}-select-wrapper`,actionSection:`${m}__actions`,newMeasurementButton:`${m}__clear-button esri-button esri-button--primary`,widgetIcon:"esri-icon-measure-area"};let v=class extends r{constructor(e,t){super(e,t),this.iconClass=d.widgetIcon,this.icon=null,this.viewModel=new a}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}get active(){return this.viewModel.active}get analysis(){return this.viewModel.analysis}set analysis(e){this.viewModel.analysis=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get unitOptions(){return this.viewModel.unitOptions}set unitOptions(e){this.viewModel.unitOptions=e}get unit(){return this.viewModel.unit}set unit(e){this.viewModel.unit=e}render(){const{messages:e,messagesUnits:t}=this,{supported:i,active:n,measurement:r,state:a,unit:l}=this.viewModel,o="disabled"===a,m="measuring"===a||"measured"===a,p=n&&"ready"===a?u("section",{key:"esri-area-measurement-3d__hint",class:d.hint},u("p",{class:d.hintText},e.hint),u("p",{class:d.hintText},e.snappingDisablePromptAlternate)):null,c=i?null:u("section",{key:"esri-area-measurement-3d__unsupported",class:d.panelError},u("p",null,e.unsupported)),v=(t,s,i)=>{switch(s.state){case"available":return u("div",{key:`${i}-enabled`,class:d.measurementItem},u("span",{class:d.measurementItemTitle},t),u("span",{"aria-live":"polite",class:d.measurementItemValue},s.text));case"unavailable":return u("div",{key:`${i}-disabled`,class:this.classes(d.measurementItem,d.measurementItemDisabled)},u("span",{class:d.measurementItemTitle},t));case"invalid":return u("div",{key:`${i}-enabled`,class:d.measurementItem},u("span",{class:d.measurementItemTitle},t),u("span",{class:d.measurementItemValue},e.notApplicable))}},h=m&&r?u("section",{key:"esri-area-measurement-3d__measurement",class:d.measurement},v(e.area,r.area,"area"),v(e.perimeterLength,r.perimeterLength,"perimeter-length")):null,b=`${this.id}__units`,w=u("label",{class:d.unitsLabel,for:b},e.unit),y=u("div",{class:d.unitsSelectWrapper},u("select",{class:d.unitsSelect,id:b,onchange:this._changeUnit,bind:this,value:l},this.viewModel.unitOptions.map((e=>u("option",{key:e,value:e},s(e)?t.systems[e]:t.units[e]?.pluralCapitalized))))),g=m?u("section",{key:"esri-area-measurement-3d__units",class:d.units},w,y):null,_=m?u("div",{key:"settings",class:d.settings},g):null,M=!i||n&&!m?null:u("div",{class:d.actionSection},u("button",{bind:this,class:this.classes(d.newMeasurementButton,o&&d.buttonDisabled),disabled:o,onclick:this._newMeasurement,type:"button"},e.newMeasurement)),$=this.visible?u("div",{class:d.container},c,p,_,h,M):null;return u("div",{"aria-label":e.widgetLabel,key:this,class:d.base,role:"presentation"},$)}_newMeasurement(){t(this.viewModel.start())}_changeUnit(e){const t=e.target,s=t.options[t.selectedIndex];s&&(this.unit=s.value)}};e([i()],v.prototype,"view",null),e([i()],v.prototype,"visible",null),e([i()],v.prototype,"active",null),e([i({constructOnly:!0,nonNullable:!0})],v.prototype,"analysis",null),e([i()],v.prototype,"iconClass",void 0),e([i()],v.prototype,"icon",void 0),e([i()],v.prototype,"label",null),e([i(),o("esri/widgets/AreaMeasurement3D/t9n/AreaMeasurement3D")],v.prototype,"messages",void 0),e([i(),o("esri/core/t9n/Units")],v.prototype,"messagesUnits",void 0),e([i()],v.prototype,"uiStrings",void 0),e([i({type:a})],v.prototype,"viewModel",void 0),e([i()],v.prototype,"unitOptions",null),e([i()],v.prototype,"unit",null),e([l()],v.prototype,"_newMeasurement",null),e([l()],v.prototype,"_changeUnit",null),v=e([n("esri.widgets.AreaMeasurement3D")],v);const h=v;export{h as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import{ignoreAbortErrors as t}from"../core/promiseUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as i}from"../core/accessorSupport/decorators/subclass.js";import o from"./Widget.js";import r from"./AreaMeasurement3D/AreaMeasurement3DViewModel.js";import{MeasurementWidgetContent as n}from"./support/MeasurementWidgetContent.js";import"./support/widgetUtils.js";import{messageBundle as a}from"./support/decorators/messageBundle.js";import{tsx as l}from"./support/jsxFactory.js";const p="esri-area-measurement-3d",u={base:`${p} esri-widget esri-widget--panel`,newMeasurementButton:`${p}__clear-button`,widgetIcon:"esri-icon-measure-area"};let m=class extends o{constructor(e,t){super(e,t),this.iconClass=u.widgetIcon,this.icon=null,this.messages=null,this.messagesCommon=null,this.messagesUnits=null,this.viewModel=new r}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}get active(){return this.viewModel.active}get analysis(){return this.viewModel.analysis}set analysis(e){this.viewModel.analysis=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get unitOptions(){return this.viewModel.unitOptions}set unitOptions(e){this.viewModel.unitOptions=e}get unit(){return this.viewModel.unit}set unit(e){this.viewModel.unit=e}render(){const{messages:e,messagesCommon:s,messagesUnits:i,unit:o,unitOptions:r,viewModel:a}=this,{active:p,measurement:m,state:d,supported:v}=a;return l("div",{"aria-label":this.messages.widgetLabel,key:this,class:u.base,role:"presentation"},this.visible?l(n,{active:p,measurementItems:[{key:"direct",title:i.measures.area,value:c(m?.area)},{key:"perimeter",title:e.perimeterLength,value:c(m?.perimeterLength)}],messages:{...e,notApplicable:s.notApplicable},newMeasurementButtonClass:u.newMeasurementButton,onNewMeasurementClick:()=>{t(this.viewModel.start())},onUnitChange:e=>{this.unit=e},state:d,supported:v,unit:o,unitOptions:r}):null)}};function c(e){return"available"===e?.state?e.text:null}e([s()],m.prototype,"view",null),e([s()],m.prototype,"visible",null),e([s()],m.prototype,"active",null),e([s({constructOnly:!0,nonNullable:!0})],m.prototype,"analysis",null),e([s()],m.prototype,"iconClass",void 0),e([s()],m.prototype,"icon",void 0),e([s()],m.prototype,"label",null),e([s(),a("esri/widgets/AreaMeasurement3D/t9n/AreaMeasurement3D")],m.prototype,"messages",void 0),e([s(),a("esri/t9n/common")],m.prototype,"messagesCommon",void 0),e([s(),a("esri/core/t9n/Units")],m.prototype,"messagesUnits",void 0),e([s()],m.prototype,"uiStrings",void 0),e([s({type:r})],m.prototype,"viewModel",void 0),e([s()],m.prototype,"unitOptions",null),e([s()],m.prototype,"unit",null),m=e([i("esri.widgets.AreaMeasurement3D")],m);const d=m;export{d as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import{ignoreAbortErrors as t}from"../core/promiseUtils.js";import{isMeasurementSystem as s}from"../core/unitUtils.js";import{property as i}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";import r from"./Widget.js";import a from"./DirectLineMeasurement3D/DirectLineMeasurement3DViewModel.js";import{accessibleHandler as l}from"./support/decorators/accessibleHandler.js";import{messageBundle as o}from"./support/decorators/messageBundle.js";import{tsx as u}from"./support/jsxFactory.js";import"./support/widgetUtils.js";const c="esri-direct-line-measurement-3d",p=`${c}__units`,m=`${c}__measurement`,d={buttonDisabled:"esri-button--disabled",base:`${c} esri-widget esri-widget--panel`,container:`${c}__container`,hint:`${c}__hint`,hintText:`${c}__hint-text`,panelError:`${c}__panel--error`,measurement:m,measurementItem:`${m}-item`,measurementItemDisabled:`${m}-item--disabled`,measurementItemTitle:`${m}-item-title`,measurementItemValue:`${m}-item-value`,settings:`${c}__settings`,units:p,unitsLabel:`${p}-label`,unitsSelect:`${p}-select esri-select`,unitsSelectWrapper:`${p}-select-wrapper`,actionSection:`${c}__actions`,newMeasurementButton:`${c}__clear-button esri-button esri-button--primary`,widgetIcon:"esri-icon-measure-line"};let v=class extends r{constructor(e,t){super(e,t),this.iconClass=d.widgetIcon,this.icon=null,this.viewModel=new a}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}get active(){return this.viewModel.active}get analysis(){return this.viewModel.analysis}set analysis(e){this.viewModel.analysis=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get unitOptions(){return this.viewModel.unitOptions}set unitOptions(e){this.viewModel.unitOptions=e}get unit(){return this.viewModel.unit}set unit(e){this.viewModel.unit=e}render(){const{supported:e,active:t,state:i,measurement:n,unit:r}=this.viewModel,a="disabled"===i,l="ready"===i,o="measuring"===i||"measured"===i,{messages:c,messagesUnits:p}=this,m=t&&l?u("section",{key:"esri-direct-line-measurement-3d__hint",class:d.hint},u("p",{class:d.hintText},c.hint),u("p",{class:d.hintText},c.snappingDisablePromptAlternate)):null,v=e?null:u("section",{key:"esri-direct-line-measurement-3d__unsupported",class:d.panelError},u("p",null,c.unsupported)),h=(e,t,s)=>{switch(t.state){case"available":return u("div",{key:`${s}-enabled`,class:d.measurementItem},u("span",{class:d.measurementItemTitle},e),u("span",{"aria-live":"polite",class:d.measurementItemValue},t.text));case"unavailable":return u("div",{key:`${s}-disabled`,class:this.classes(d.measurementItem,d.measurementItemDisabled)},u("span",{class:d.measurementItemTitle},e))}},b=o&&n?u("section",{key:"esri-direct-line-measurement-3d__measurement",class:d.measurement},h(c.direct,n.directDistance,"direct"),h(c.horizontal,n.horizontalDistance,"horizontal"),h(c.vertical,n.verticalDistance,"vertical")):null,w=`${this.id}__units`,y=u("label",{class:d.unitsLabel,for:w},c.unit),_=u("div",{class:d.unitsSelectWrapper},u("select",{class:d.unitsSelect,id:w,onchange:this._changeUnit,bind:this,value:r},this.viewModel.unitOptions.map((e=>u("option",{key:e,value:e},s(e)?p.systems[e]:p.units[e]?.pluralCapitalized))))),g=u("section",{key:"esri-direct-line-measurement-3d__units",class:d.units},y,_),M=o?u("div",{key:"settings",class:d.settings},g):null,$=!e||t&&!o?null:u("div",{class:d.actionSection},u("button",{disabled:a,class:this.classes(d.newMeasurementButton,a&&d.buttonDisabled),bind:this,onclick:this._newMeasurement,type:"button"},c.newMeasurement)),D=this.visible?u("div",{class:d.container},v,m,M,b,$):null;return u("div",{"aria-label":c.widgetLabel,key:this,class:d.base,role:"presentation"},D)}_newMeasurement(){t(this.viewModel.start())}_changeUnit(e){const t=e.target,s=t.options[t.selectedIndex];s&&(this.unit=s.value)}};e([i()],v.prototype,"view",null),e([i()],v.prototype,"visible",null),e([i()],v.prototype,"active",null),e([i({constructOnly:!0,nonNullable:!0})],v.prototype,"analysis",null),e([i()],v.prototype,"iconClass",void 0),e([i()],v.prototype,"icon",void 0),e([i()],v.prototype,"label",null),e([i(),o("esri/widgets/DirectLineMeasurement3D/t9n/DirectLineMeasurement3D")],v.prototype,"messages",void 0),e([i(),o("esri/core/t9n/Units")],v.prototype,"messagesUnits",void 0),e([i()],v.prototype,"uiStrings",void 0),e([i({type:a})],v.prototype,"viewModel",void 0),e([i()],v.prototype,"unitOptions",null),e([i()],v.prototype,"unit",null),e([l()],v.prototype,"_newMeasurement",null),e([l()],v.prototype,"_changeUnit",null),v=e([n("esri.widgets.DirectLineMeasurement3D")],v);const h=v;export{h as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import{ignoreAbortErrors as t}from"../core/promiseUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as i}from"../core/accessorSupport/decorators/subclass.js";import o from"./Widget.js";import r from"./DirectLineMeasurement3D/DirectLineMeasurement3DViewModel.js";import{MeasurementWidgetContent as n}from"./support/MeasurementWidgetContent.js";import"./support/widgetUtils.js";import{messageBundle as l}from"./support/decorators/messageBundle.js";import{tsx as a}from"./support/jsxFactory.js";const p="esri-direct-line-measurement-3d",u={base:`${p} esri-widget esri-widget--panel`,newMeasurementButton:`${p}__clear-button`,widgetIcon:"esri-icon-measure-line"};let c=class extends o{constructor(e,t){super(e,t),this.iconClass=u.widgetIcon,this.icon=null,this.messages=null,this.messagesCommon=null,this.viewModel=new r}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}get active(){return this.viewModel.active}get analysis(){return this.viewModel.analysis}set analysis(e){this.viewModel.analysis=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get unitOptions(){return this.viewModel.unitOptions}set unitOptions(e){this.viewModel.unitOptions=e}get unit(){return this.viewModel.unit}set unit(e){this.viewModel.unit=e}render(){const{messages:e,messagesCommon:s,unit:i,unitOptions:o,viewModel:r}=this,{active:l,measurement:p,state:c,supported:d}=r;return a("div",{"aria-label":this.messages.widgetLabel,key:this,class:u.base,role:"presentation"},this.visible?a(n,{active:l,measurementItems:[{key:"direct",title:e.direct,value:m(p?.directDistance)},{key:"horizontal",title:e.horizontal,value:m(p?.horizontalDistance)},{key:"vertical",title:e.vertical,value:m(p?.verticalDistance)}],messages:{...e,notApplicable:s?.notApplicable},newMeasurementButtonClass:u.newMeasurementButton,onNewMeasurementClick:()=>{t(this.viewModel.start())},onUnitChange:e=>{this.unit=e},state:c,supported:d,unit:i,unitOptions:o}):null)}};function m(e){return"available"===e?.state?e.text:null}e([s()],c.prototype,"view",null),e([s()],c.prototype,"visible",null),e([s()],c.prototype,"active",null),e([s({constructOnly:!0,nonNullable:!0})],c.prototype,"analysis",null),e([s()],c.prototype,"iconClass",void 0),e([s()],c.prototype,"icon",void 0),e([s()],c.prototype,"label",null),e([s(),l("esri/widgets/DirectLineMeasurement3D/t9n/DirectLineMeasurement3D")],c.prototype,"messages",void 0),e([s(),l("esri/t9n/common")],c.prototype,"messagesCommon",void 0),e([s()],c.prototype,"uiStrings",void 0),e([s({type:r})],c.prototype,"viewModel",void 0),e([s()],c.prototype,"unitOptions",null),e([s()],c.prototype,"unit",null),c=e([i("esri.widgets.DirectLineMeasurement3D")],c);const d=c;export{d as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import{ignoreAbortErrors as t}from"../core/promiseUtils.js";import{isMeasurementSystem as s}from"../core/unitUtils.js";import{property as i}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as n}from"../core/accessorSupport/decorators/subclass.js";import r from"./Widget.js";import a from"./DistanceMeasurement2D/DistanceMeasurement2DViewModel.js";import{accessibleHandler as o}from"./support/decorators/accessibleHandler.js";import{messageBundle as l}from"./support/decorators/messageBundle.js";import{tsx as u}from"./support/jsxFactory.js";import"./support/widgetUtils.js";const m="esri-distance-measurement-2d",p=`${m}__measurement`,c=`${m}__units`,d={buttonDisabled:"esri-button--disabled",widgetIcon:"esri-icon-measure-line",base:`${m} esri-widget esri-widget--panel`,container:`${m}__container`,hint:`${m}__hint`,hintText:`${m}__hint-text`,panelError:`${m}__panel--error`,measurement:p,measurementItem:`${p}-item`,measurementItemDisabled:`${p}-item--disabled`,measurementItemTitle:`${p}-item-title`,measurementItemValue:`${p}-item-value`,settings:`${m}__settings`,units:c,unitsLabel:`${c}-label`,unitsSelect:`${c}-select esri-select`,unitsSelectWrapper:`${c}-select-wrapper`,actionSection:`${m}__actions`,newMeasurementButton:`${m}__clear-button esri-button esri-button--primary`};let v=class extends r{constructor(e,t){super(e,t),this.iconClass=d.widgetIcon,this.icon=null,this.messages=null,this.messagesUnits=null,this.viewModel=new a}get active(){return this.viewModel.active}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get unit(){return this.viewModel.unit}set unit(e){this.viewModel.unit=e}get unitOptions(){return this.viewModel.unitOptions}set unitOptions(e){this.viewModel.unitOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}render(){const{id:e,messages:t,messagesUnits:i,viewModel:n,visible:r}=this,{active:a,supported:o,measurementLabel:l,state:m,unit:p,unitOptions:c}=n,v="disabled"===m,b="measuring"===m||"measured"===m,h=a&&"ready"===m?u("section",{key:"hint",class:d.hint},u("p",{class:d.hintText},t.hint)):null,w=o?null:u("section",{key:"unsupported",class:d.panelError},u("p",null,t.unsupported)),g=(e,t,s)=>null!=t?u("div",{key:`${s}-enabled`,class:d.measurementItem},u("span",{class:d.measurementItemTitle},e),u("span",{"aria-live":"polite",class:d.measurementItemValue},t)):u("div",{key:`${s}-disabled`,class:this.classes(d.measurementItem,d.measurementItemDisabled),"aria-disabled":"true"},u("span",{class:d.measurementItemTitle},e)),y=b?u("section",{key:"measurement",class:d.measurement},g(t.distance,l,"distance")):null,M=`${e}-units`,_=b?u("section",{key:"units",class:d.units},u("label",{class:d.unitsLabel,for:M},t.unit),u("div",{class:d.unitsSelectWrapper},u("select",{class:d.unitsSelect,id:M,onchange:this._changeUnit,bind:this,value:p},c.map((e=>u("option",{key:e,value:e},s(e)?i.systems[e]:i.units[e]?.pluralCapitalized)))))):null,$=b?u("div",{key:"settings",class:d.settings},_):null,j=!o||a&&!b?null:u("div",{class:d.actionSection},u("button",{"aria-label":t.newMeasurement,bind:this,class:this.classes(d.newMeasurementButton,v&&d.buttonDisabled),disabled:v,onclick:this._newMeasurement,title:t.newMeasurement,type:"button"},t.newMeasurement)),D=r?u("div",{class:d.container},w,h,$,y,j):null;return u("div",{"aria-label":t.widgetLabel,class:d.base,role:"region"},D)}_newMeasurement(){t(this.viewModel.start())}_changeUnit(e){const t=e.target,s=t.options[t.selectedIndex];s&&(this.viewModel.unit=s.value)}};e([i({readOnly:!0})],v.prototype,"active",null),e([i()],v.prototype,"iconClass",void 0),e([i()],v.prototype,"icon",void 0),e([i()],v.prototype,"label",null),e([i()],v.prototype,"uiStrings",void 0),e([i(),l("esri/widgets/DistanceMeasurement2D/t9n/DistanceMeasurement2D")],v.prototype,"messages",void 0),e([i(),l("esri/core/t9n/Units")],v.prototype,"messagesUnits",void 0),e([i()],v.prototype,"unit",null),e([i()],v.prototype,"unitOptions",null),e([i()],v.prototype,"view",null),e([i({type:a})],v.prototype,"viewModel",void 0),e([i({type:Boolean})],v.prototype,"visible",null),e([o()],v.prototype,"_newMeasurement",null),e([o()],v.prototype,"_changeUnit",null),v=e([n("esri.widgets.DistanceMeasurement2D")],v);const b=v;export{b as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import{ignoreAbortErrors as t}from"../core/promiseUtils.js";import{property as s}from"../core/accessorSupport/decorators/property.js";import"../core/accessorSupport/ensureType.js";import"../core/arrayUtils.js";import"../core/has.js";import{subclass as i}from"../core/accessorSupport/decorators/subclass.js";import o from"./Widget.js";import r from"./DistanceMeasurement2D/DistanceMeasurement2DViewModel.js";import{MeasurementWidgetContent as n}from"./support/MeasurementWidgetContent.js";import"./support/widgetUtils.js";import{messageBundle as a}from"./support/decorators/messageBundle.js";import{tsx as l}from"./support/jsxFactory.js";const p="esri-distance-measurement-2d",u={base:`${p} esri-widget esri-widget--panel`,newMeasurementButton:`${p}__clear-button`,widgetIcon:"esri-icon-measure-line"};let m=class extends o{constructor(e,t){super(e,t),this.iconClass=u.widgetIcon,this.icon=null,this.messages=null,this.messagesCommon=null,this.viewModel=new r}get active(){return this.viewModel.active}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get unit(){return this.viewModel.unit}set unit(e){this.viewModel.unit=e}get unitOptions(){return this.viewModel.unitOptions}set unitOptions(e){this.viewModel.unitOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}get visible(){return this.viewModel.visible}set visible(e){this.viewModel.visible=e}render(){const{messages:e,messagesCommon:s,unit:i,unitOptions:o,viewModel:r}=this,{active:a,measurementLabel:p,state:m,supported:c}=r;return l("div",{"aria-label":this.messages.widgetLabel,key:this,class:u.base,role:"presentation"},this.visible?l(n,{active:a,measurementItems:[{key:"distance",title:e.distance,value:p}],messages:{...e,notApplicable:s.notApplicable},newMeasurementButtonClass:u.newMeasurementButton,onNewMeasurementClick:()=>{t(this.viewModel.start())},onUnitChange:e=>{this.unit=e},state:m,supported:c,unit:i,unitOptions:o}):null)}};e([s({readOnly:!0})],m.prototype,"active",null),e([s()],m.prototype,"iconClass",void 0),e([s()],m.prototype,"icon",void 0),e([s()],m.prototype,"label",null),e([s()],m.prototype,"uiStrings",void 0),e([s(),a("esri/widgets/DistanceMeasurement2D/t9n/DistanceMeasurement2D")],m.prototype,"messages",void 0),e([s(),a("esri/t9n/common")],m.prototype,"messagesCommon",void 0),e([s()],m.prototype,"unit",null),e([s()],m.prototype,"unitOptions",null),e([s()],m.prototype,"view",null),e([s({type:r})],m.prototype,"viewModel",void 0),e([s({type:Boolean})],m.prototype,"visible",null),m=e([i("esri.widgets.DistanceMeasurement2D")],m);const c=m;export{c as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import{createTask as e}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{deprecated as r}from"../../core/deprecate.js";import i from"../../core/Error.js";import s from"../../core/Evented.js";import o from"../../core/Logger.js";import{abortMaybe as n}from"../../core/maybe.js";import{throwIfAborted as l}from"../../core/promiseUtils.js";import{watch as d,on as p,when as c,whenOnce as u,initial as h}from"../../core/reactiveUtils.js";import{property as w}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import{WatchUpdatingTracking as m}from"../../core/support/WatchUpdatingTracking.js";import y from"../../layers/GraphicsLayer.js";import{isEditableLayer as k}from"../../layers/support/editableLayers.js";import{getOwningPortalUrl as g,getEffectiveLayerCapabilities as v,isFeatureLayer as W}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as b}from"../../portal/support/urlUtils.js";import _ from"../Attachments/AttachmentsViewModel.js";import F from"./CreateFeaturesWorkflow.js";import C from"./CreateWorkflow.js";import{workflowDeprecation as E}from"./deprecationUtils.js";import I from"./UpdateWorkflow.js";import{whenEditorLayerView as U}from"./workflowUtils.js";import{formTemplateHasInvalidFields as A,unsupportedDateFieldTypes as O}from"../FeatureForm/featureFormUtils.js";import V from"../FeatureForm/FeatureFormViewModel.js";import M from"../FeatureTemplates/FeatureTemplatesViewModel.js";import j from"../Sketch/SketchViewModel.js";import T from"../Spinner/SpinnerViewModel.js";const S="esri.widgets.Editor.EditorViewModel",L=o.getLogger(S),P=["create","create-features","update"];function D(t,e,a){L.error(new i(t,e,a))}function G(t,e){return t?t.find((t=>t.layer===e)):void 0}let x=class extends s.EventedAccessor{constructor(t){super(t),this._editableItems=new a,this._sketchGraphicsLayer=new y({listMode:"hide",internal:!0}),this._updateEditableItemsTask=null,this._updatingHandles=new m,this.activeWorkflow=null,this._activityQueue=[],this.failures=[],this.attachmentsViewModel=new _({capabilities:{editing:!0}}),this.featureFormViewModel=new V,this.featureTemplatesViewModel=new M,this.sketchViewModel=new j({layer:this._sketchGraphicsLayer}),this.spinnerViewModel=new T,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.useDeprecatedCreateWorkflow=!1,this.back=async()=>{this.canGoBack&&(this.activeWorkflow?.hasPreviousStep?await this.activeWorkflow.back(this.showDiscardEditsPrompt):await this._cancelWorkflow({force:!this.hasPendingEdits}))},this.saveWorkflow=async()=>{const{featureFormViewModel:t}=this;if(t.submit(),!t.submittable)return;const e=t.getValues();t.validateContingencyConstraints(e,{includeIncompleteViolations:!0}).length>0||await(this.activeWorkflow?.save())},this.selectFeature=(t,e=!1)=>{const a=this.activeWorkflow;this._candidateCommitted||"update"!==a?.type||(a.data.rootFeature=t,e&&(a.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([d((()=>{const t=this.view?.map?.editableLayers.filter((({parent:t,visible:e})=>t&&"visible"in t?e&&t.visible:e)),e=this.view?.allLayerViews,a=e?.filter((e=>!!t?.includes(e.layer)&&!e.suspended));return[t,a,this.layerInfos,this.allowedWorkflows]}),(()=>this._updateEditableItems()),h),p((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),p((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),p((()=>this.activeWorkflow),"complete",(()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)})),c((()=>this.view?.map),(t=>t.add(this._sketchGraphicsLayer)),h),d((()=>this._editableItems.toArray()),(()=>{const{activeWorkflow:t}=this;if(this.refreshCreationTemplates(),!t)return;const{stepId:e}=t;"create"!==t.type?"update"===t.type&&("awaiting-feature-to-update"===e&&!this.canUpdate||"awaiting-update-feature-candidate"===e&&!t.data.candidates.some((t=>{const e=this._editableItems.find((e=>e.layer===t.layer));return e&&e.supports.includes("update")})))&&this._cancelWorkflow():"awaiting-feature-creation-info"!==e||this.canCreate||this._cancelWorkflow()})),d((()=>this.page),((t,e)=>{const a=this.pageStack.slice(),r=a.indexOf(t);-1===r&&e?a.push(e):a.splice(r),this.pageStack=a})),c((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1)),p((()=>this.featureTemplatesViewModel),"select",(async({item:t,oldItem:e})=>{const{activeWorkflow:a}=this,r=!!t&&t.id===e?.id,i="create-features"===a?.type&&a.data.upload?.error;if(a)try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return this.featureTemplatesViewModel.select(e,{emit:!1})}if(!t||r&&!i)return;const s={layer:t.layer,template:t.template};if(t.supportsUpload)return this.startCreateFeaturesWorkflow(s);this.useDeprecatedCreateWorkflow?this.startCreateWorkflowAtFeatureCreation(s):this.startCreateFeaturesWorkflowAtFeatureCreation(s)})),p((()=>this.view),"key-down",(t=>{"Escape"===t.key&&this.activeWorkflow?.keyboardCancellationEnabled&&this.back()}))])}destroy(){this._cancelWorkflow().then((()=>{this.view?.map&&this.view.map.remove(this._sketchGraphicsLayer),this.view=null})),this._updateEditableItemsTask=n(this._updateEditableItemsTask),this._updatingHandles.destroy()}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(t){t&&0!==t.length||(t=[...P]),this._set("allowedWorkflows",t)}get canCreate(){return this._editableItems.some((t=>t.supports.includes("create")))}get canUpdate(){return this._editableItems.some((({attachmentsOnUpdateEnabled:t,layer:e,supports:a})=>{const r=a.includes("update")||a.includes("delete")||t,i=e.parent,s=!(i&&"visible"in i)||!!i.visible;return e.visible&&s&&r}))}get editableItems(){return this._editableItems}get labelOptions(){return this.sketchViewModel.labelOptions}set labelOptions(t){this.sketchViewModel.labelOptions=t}set layerInfos(t){t?.some((t=>("allowAttachments"in t&&r(L,"Property: layerInfo.allowAttachments",{replacement:"layerInfo.attachmentsOnCreateEnabled or layerInfo.attachmentsOnUpdateEnabled",version:"4.26"}),!0))),this._set("layerInfos",t)}get snappingOptions(){return this.sketchViewModel.snappingOptions}set snappingOptions(t){this.sketchViewModel.snappingOptions=t}get state(){if(!this.get("view.ready")||0===this._editableItems.length)return"disabled";const t=this.attachmentsViewModel.mode;if("add"===t)return"adding-attachment";if("edit"===t)return"editing-attachment";const{activeWorkflow:e}=this;return e?e.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get updating(){return this._updatingHandles.updating||!0===this.activeWorkflow?.updating}get tooltipOptions(){return this.sketchViewModel.tooltipOptions}set tooltipOptions(t){this.sketchViewModel.tooltipOptions=t}set view(t){this.sketchViewModel.view=t,this.spinnerViewModel.view=t,this._set("view",t)}get page(){const{activeWorkflow:t,state:e}=this;return"awaiting-feature-to-update"===e||"awaiting-feature-to-create"===e||"create-features"===t?.type&&0===t.numPendingFeatures?"ready":e??"disabled"}get selectedTemplateItem(){const{activeWorkflow:t}=this;if("create-features"===t?.type&&0===t.numPendingFeatures){const e=t.data.creationInfo?.template;if(!e)return;for(const t of this.featureTemplatesViewModel.items)if("findByTemplate"in t){const a=t.findByTemplate(e);if(a)return a}else if(t.template===e)return t}}get featureFormDisabled(){const{activeWorkflow:t}=this;return"update"===t?.type&&!1===t.activeEditableItem?.attributeUpdatesEnabled}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:t}=this;return!!t&&"update"===t.type&&!!t.activeEditableItem?.supports.includes("delete")}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}async startCreateWorkflowAtFeatureTypeSelection(){if(E(L,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),await u((()=>!this.updating)),!this.canCreate)return void D("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateWorkflowAtFeatureCreation(t){if(E(L,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),await u((()=>!this.updating)),!this.canCreate)return void D("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("awaiting-feature-to-create");e.data.creationInfo=t,await e.start(),this._set("activeWorkflow",e)}async startCreateFeaturesWorkflowAtFeatureCreation(t){return this.startCreateFeaturesWorkflow(t,"creating-features")}async startCreateFeaturesWorkflow(t,e="awaiting-feature-creation-info"){if(await u((()=>!this.updating)),!this.canCreate)throw new i("editing:unsupported-workflow","Creating features is unsupported or disabled.");await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow(t,e);await a.start(),this._set("activeWorkflow",a)}async startCreateWorkflowAtFeatureEdit(t){if(E(L,"startCreateWorkflowAtFeatureEdit"),await u((()=>!this.updating)),!this.canCreate)return void D("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("editing-new-feature");e.data.edits.feature=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureSelection(){if(await u((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtMultipleFeatureSelection(t){if(await u((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("awaiting-update-feature-candidate");e.data.candidates=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureEdit(t){if(await u((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("editing-existing-feature");e.data.rootFeature=t,await e.start(),this._set("activeWorkflow",e)}async deleteFeatureFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?await t.deleteActiveFeature():D("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(t){return this._cancelWorkflow({warn:!0,...t})}findEditableItemForLayer(t){const e="subtype-sublayer"===t.type?t.parent:t;return this._editableItems.find((t=>t.layer===e))}itemHasInvalidFormTemplate(t){return!!t&&(this.findEditableItemForLayer(t.layer)?.hasInvalidFormTemplate??!1)}itemHasUnsupportedFields(t){return!!t&&(this.findEditableItemForLayer(t.layer)?.hasUnsupportedFields??!1)}refreshCreationTemplates(){const t=[];for(const{layer:e,supports:a}of this._editableItems)e.loaded&&a.includes("create")&&t.push(e);this.featureTemplatesViewModel.layers=t}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!0}):await this.startUpdateWorkflowAtFeatureSelection()))}async _updateEditableItems(){n(this._updateEditableItemsTask);const t=e((async t=>{const e=this.view?.allLayerViews,r=this.view?.map,i=r?.editableLayers.toArray()??[],s=r?.allTables.toArray().filter(W)??[];await Promise.all(s.map((t=>t.load())));const o=s.filter((t=>k(t))),n=[...i.reverse(),...o.reverse()].filter((t=>"mesh"!==t.geometryType||"3d"===this.view?.type));if(!e||!i)return;const d=[],p=[];for(const a of n){const r=e.find((t=>t.layer===a)),i=r?d:p;if("subtype-group"===a.type){await a.loadAll(),l(t);for(let t=a.sublayers.length-1;t>=0;--t)i.push(this._makeEditableItemForLayer(a.sublayers.at(t),!!r?.suspended))}else i.push(this._makeEditableItemForLayer(a,!!r?.suspended))}if(t.aborted)return;const c=this._editableItems;this._editableItems=new a(d.concat(p)),c.destroy()}));this._updatingHandles.addPromise(t.promise),this._updateEditableItemsTask=t}async _cancelWorkflow(t){const e=this.activeWorkflow;if(!e)return void(t&&t.warn&&D("editing:no-active-workflow","There is no active workflow to cancel."));if(!t||!1!==t.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await e.cancel(t);await e.cancel(t),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(t,e){return F.create({viewModel:this,creationInfo:t,startAt:e,applyEditsCallback:(t,e,a)=>this._applyEdits(t,e,a),addAttachmentsCallback:(t,e)=>this._addAttachments(t,e)})}_createCreateWorkflow(t){return C.create(this,t,((t,e,a)=>this._applyEdits(t,e,a)))}_createUpdateWorkflow(t){return I.create(this,t,((t,e)=>this._applyEdits(t,e)))}_addAttachments(t,e){const a=e.map((e=>this._addAttachment(t,e.feature,e.attachment)))??[];return Promise.all(a)}async _addAttachment(t,e,a){let r=null;if("geojson"===t.type||"scene"===t.type||"oriented-imagery"===t.type)throw new i("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(r=await(t.addAttachment?.(e,a).catch((t=>{throw t?.error||t})))??null,r))),r}async _applyEdits(t,e,a){let r=null;const i=t.url?await g(t.url):null,s={returnServiceEditsOption:(!i||!b(i))&&!RegExp("/hosted/","i").test(t.url)?"original-and-current-features":void 0,...a};return await this._queueOperation((async()=>{const a=await U(this.view,t).catch((()=>null));return r=await t.applyEdits(e,s),a&&await u((()=>!a.updating)),r})),r}_queueOperation(t){this._activityQueue.push(t),this.notifyChange("syncing");const e=(t,e)=>{const a=e.indexOf(t);a>-1&&e.splice(a,1)};return t().then((t=>{if("error"in t&&t.error)throw t.error;if("addFeatureResults"in t){const{addFeatureResults:e,deleteFeatureResults:a,updateFeatureResults:r}=t,i=e.find((t=>!!t.error))||r.find((t=>!!t.error))||a.find((t=>!!t.error));if(i)throw i.error}return t})).catch((a=>{D("editing:operation-error","An error occurred.",{error:a});const r={error:a,retry:()=>(e(r,this.failures),this._queueOperation(t)),cancel:()=>{e(r,this.failures)}};this._set("failures",[...this.failures,r])})).then((()=>{e(t,this._activityQueue),this.notifyChange("syncing")}))}_makeEditableItemForLayer(t,e=!0){const a=v(t),r=a?.operations,i=G(this.layerInfos,t),s=A(t),o=t.fields.some((({type:t})=>O.has(t))),n=s||o,{allowedWorkflows:l}=this,d=l.includes("create")||l.includes("create-features"),p=l.includes("update"),c=t=>!i||!1!==i.enabled&&!1!==i[t],u=d&&!!r?.supportsAdd&&c("addEnabled"),h=p&&!!r?.supportsUpdate&&c("updateEnabled"),w=!n&&p&&!!r?.supportsDelete&&c("deleteEnabled"),f=[];e||(u&&f.push("create"),h&&f.push("update"),w&&f.push("delete"));const m=h&&!n&&(!i||!1!==i.attributeUpdatesEnabled),y=h&&!n&&!!a?.editing?.supportsGeometryUpdate&&(!i||!1!==i.geometryUpdatesEnabled),k=!(!a?.data?.supportsAttachment||i&&!1===i.allowAttachments);return{layer:t,supports:f,attributeUpdatesEnabled:m,geometryUpdatesEnabled:y,hasAttachments:k,attachmentsOnCreateEnabled:k&&d&&(!i||!1!==i.attachmentsOnCreateEnabled),attachmentsOnUpdateEnabled:!n&&k&&(!i||!1!==i.attachmentsOnUpdateEnabled),hasInvalidFormTemplate:s,hasUnsupportedFields:o}}};t([w()],x.prototype,"_editableItems",void 0),t([w({readOnly:!0})],x.prototype,"activeWorkflow",void 0),t([w({readOnly:!0})],x.prototype,"_activityQueue",void 0),t([w({value:[...P]})],x.prototype,"allowedWorkflows",null),t([w({readOnly:!0})],x.prototype,"canCreate",null),t([w({readOnly:!0})],x.prototype,"canUpdate",null),t([w()],x.prototype,"editableItems",null),t([w({readOnly:!0})],x.prototype,"failures",void 0),t([w()],x.prototype,"attachmentsViewModel",void 0),t([w()],x.prototype,"featureFormViewModel",void 0),t([w()],x.prototype,"featureTemplatesViewModel",void 0),t([w()],x.prototype,"labelOptions",null),t([w()],x.prototype,"layerInfos",null),t([w()],x.prototype,"sketchViewModel",void 0),t([w()],x.prototype,"snappingOptions",null),t([w()],x.prototype,"spinnerViewModel",void 0),t([w()],x.prototype,"state",null),t([w({readOnly:!0})],x.prototype,"syncing",null),t([w()],x.prototype,"updating",null),t([w()],x.prototype,"tooltipOptions",null),t([w()],x.prototype,"view",null),t([w()],x.prototype,"pageStack",void 0),t([w()],x.prototype,"showDiscardEditsPrompt",void 0),t([w()],x.prototype,"_candidateCommitted",void 0),t([w()],x.prototype,"page",null),t([w()],x.prototype,"selectedTemplateItem",null),t([w()],x.prototype,"featureFormDisabled",null),t([w()],x.prototype,"canGoBack",null),t([w()],x.prototype,"shouldShowDeleteButton",null),t([w()],x.prototype,"hasPendingEdits",null),t([w()],x.prototype,"useDeprecatedCreateWorkflow",void 0),x=t([f(S)],x);const B=x;export{B as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import{createTask as e}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{deprecated as r}from"../../core/deprecate.js";import i from"../../core/Error.js";import s from"../../core/Evented.js";import o from"../../core/Logger.js";import{abortMaybe as n}from"../../core/maybe.js";import{throwIfAborted as l}from"../../core/promiseUtils.js";import{watch as d,on as p,when as c,whenOnce as u,initial as h}from"../../core/reactiveUtils.js";import{property as w}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as m}from"../../core/support/UpdatingHandles.js";import y from"../../layers/GraphicsLayer.js";import{isEditableLayer as k}from"../../layers/support/editableLayers.js";import{getOwningPortalUrl as g,getEffectiveLayerCapabilities as v,isFeatureLayer as W}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as b}from"../../portal/support/urlUtils.js";import _ from"../Attachments/AttachmentsViewModel.js";import F from"./CreateFeaturesWorkflow.js";import C from"./CreateWorkflow.js";import{workflowDeprecation as E}from"./deprecationUtils.js";import I from"./UpdateWorkflow.js";import{whenEditorLayerView as U}from"./workflowUtils.js";import{formTemplateHasInvalidFields as A,unsupportedDateFieldTypes as O}from"../FeatureForm/featureFormUtils.js";import V from"../FeatureForm/FeatureFormViewModel.js";import M from"../FeatureTemplates/FeatureTemplatesViewModel.js";import j from"../Sketch/SketchViewModel.js";import T from"../Spinner/SpinnerViewModel.js";const S="esri.widgets.Editor.EditorViewModel",L=o.getLogger(S),P=["create","create-features","update"];function D(t,e,a){L.error(new i(t,e,a))}function G(t,e){return t?t.find((t=>t.layer===e)):void 0}let H=class extends s.EventedAccessor{constructor(t){super(t),this._editableItems=new a,this._sketchGraphicsLayer=new y({listMode:"hide",internal:!0}),this._updateEditableItemsTask=null,this._updatingHandles=new m,this.activeWorkflow=null,this._activityQueue=[],this.failures=[],this.attachmentsViewModel=new _({capabilities:{editing:!0}}),this.featureFormViewModel=new V,this.featureTemplatesViewModel=new M,this.sketchViewModel=new j({layer:this._sketchGraphicsLayer}),this.spinnerViewModel=new T,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.useDeprecatedCreateWorkflow=!1,this.back=async()=>{this.canGoBack&&(this.activeWorkflow?.hasPreviousStep?await this.activeWorkflow.back(this.showDiscardEditsPrompt):await this._cancelWorkflow({force:!this.hasPendingEdits}))},this.saveWorkflow=async()=>{const{featureFormViewModel:t}=this;if(t.submit(),!t.submittable)return;const e=t.getValues();t.validateContingencyConstraints(e,{includeIncompleteViolations:!0}).length>0||await(this.activeWorkflow?.save())},this.selectFeature=(t,e=!1)=>{const a=this.activeWorkflow;this._candidateCommitted||"update"!==a?.type||(a.data.rootFeature=t,e&&(a.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([d((()=>{const t=this.view?.map?.editableLayers.filter((({parent:t,visible:e})=>t&&"visible"in t?e&&t.visible:e)),e=this.view?.allLayerViews,a=e?.filter((e=>!!t?.includes(e.layer)&&!e.suspended));return[t,a,this.layerInfos,this.allowedWorkflows]}),(()=>this._updateEditableItems()),h),p((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),p((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),p((()=>this.activeWorkflow),"complete",(()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)})),c((()=>this.view?.map),(t=>t.add(this._sketchGraphicsLayer)),h),d((()=>this._editableItems.toArray()),(()=>{const{activeWorkflow:t}=this;if(this.refreshCreationTemplates(),!t)return;const{stepId:e}=t;"create"!==t.type?"update"===t.type&&("awaiting-feature-to-update"===e&&!this.canUpdate||"awaiting-update-feature-candidate"===e&&!t.data.candidates.some((t=>{const e=this._editableItems.find((e=>e.layer===t.layer));return e&&e.supports.includes("update")})))&&this._cancelWorkflow():"awaiting-feature-creation-info"!==e||this.canCreate||this._cancelWorkflow()})),d((()=>this.page),((t,e)=>{const a=this.pageStack.slice(),r=a.indexOf(t);-1===r&&e?a.push(e):a.splice(r),this.pageStack=a})),c((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1)),p((()=>this.featureTemplatesViewModel),"select",(async({item:t,oldItem:e})=>{const{activeWorkflow:a}=this,r=!!t&&t.id===e?.id,i="create-features"===a?.type&&a.data.upload?.error;if(a)try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return this.featureTemplatesViewModel.select(e,{emit:!1})}if(!t||r&&!i)return;const s={layer:t.layer,template:t.template};if(t.supportsUpload)return this.startCreateFeaturesWorkflow(s);this.useDeprecatedCreateWorkflow?this.startCreateWorkflowAtFeatureCreation(s):this.startCreateFeaturesWorkflowAtFeatureCreation(s)})),p((()=>this.view),"key-down",(t=>{"Escape"===t.key&&this.activeWorkflow?.keyboardCancellationEnabled&&this.back()}))])}destroy(){this._cancelWorkflow().then((()=>{this.view?.map&&this.view.map.remove(this._sketchGraphicsLayer),this.view=null})),this._updateEditableItemsTask=n(this._updateEditableItemsTask),this._updatingHandles.destroy()}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(t){t&&0!==t.length||(t=[...P]),this._set("allowedWorkflows",t)}get canCreate(){return this._editableItems.some((t=>t.supports.includes("create")))}get canUpdate(){return this._editableItems.some((({attachmentsOnUpdateEnabled:t,layer:e,supports:a})=>{const r=a.includes("update")||a.includes("delete")||t,i=e.parent,s=!(i&&"visible"in i)||!!i.visible;return e.visible&&s&&r}))}get editableItems(){return this._editableItems}get labelOptions(){return this.sketchViewModel.labelOptions}set labelOptions(t){this.sketchViewModel.labelOptions=t}set layerInfos(t){t?.some((t=>("allowAttachments"in t&&r(L,"Property: layerInfo.allowAttachments",{replacement:"layerInfo.attachmentsOnCreateEnabled or layerInfo.attachmentsOnUpdateEnabled",version:"4.26"}),!0))),this._set("layerInfos",t)}get snappingOptions(){return this.sketchViewModel.snappingOptions}set snappingOptions(t){this.sketchViewModel.snappingOptions=t}get state(){if(!this.get("view.ready")||0===this._editableItems.length)return"disabled";const t=this.attachmentsViewModel.mode;if("add"===t)return"adding-attachment";if("edit"===t)return"editing-attachment";const{activeWorkflow:e}=this;return e?e.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get updating(){return this._updatingHandles.updating||!0===this.activeWorkflow?.updating}get tooltipOptions(){return this.sketchViewModel.tooltipOptions}set tooltipOptions(t){this.sketchViewModel.tooltipOptions=t}set view(t){this.sketchViewModel.view=t,this.spinnerViewModel.view=t,this._set("view",t)}get page(){const{activeWorkflow:t,state:e}=this;return"awaiting-feature-to-update"===e||"awaiting-feature-to-create"===e||"create-features"===t?.type&&0===t.numPendingFeatures?"ready":e??"disabled"}get selectedTemplateItem(){const{activeWorkflow:t}=this;if("create-features"===t?.type&&0===t.numPendingFeatures){const e=t.data.creationInfo?.template;if(!e)return;for(const t of this.featureTemplatesViewModel.items)if("findByTemplate"in t){const a=t.findByTemplate(e);if(a)return a}else if(t.template===e)return t}}get featureFormDisabled(){const{activeWorkflow:t}=this;return"update"===t?.type&&!1===t.activeEditableItem?.attributeUpdatesEnabled}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:t}=this;return!!t&&"update"===t.type&&!!t.activeEditableItem?.supports.includes("delete")}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}async startCreateWorkflowAtFeatureTypeSelection(){if(E(L,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),await u((()=>!this.updating)),!this.canCreate)return void D("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateWorkflowAtFeatureCreation(t){if(E(L,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),await u((()=>!this.updating)),!this.canCreate)return void D("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("awaiting-feature-to-create");e.data.creationInfo=t,await e.start(),this._set("activeWorkflow",e)}async startCreateFeaturesWorkflowAtFeatureCreation(t){return this.startCreateFeaturesWorkflow(t,"creating-features")}async startCreateFeaturesWorkflow(t,e="awaiting-feature-creation-info"){if(await u((()=>!this.updating)),!this.canCreate)throw new i("editing:unsupported-workflow","Creating features is unsupported or disabled.");await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow(t,e);await a.start(),this._set("activeWorkflow",a)}async startCreateWorkflowAtFeatureEdit(t){if(E(L,"startCreateWorkflowAtFeatureEdit"),await u((()=>!this.updating)),!this.canCreate)return void D("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("editing-new-feature");e.data.edits.feature=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureSelection(){if(await u((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtMultipleFeatureSelection(t){if(await u((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("awaiting-update-feature-candidate");e.data.candidates=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureEdit(t){if(await u((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("editing-existing-feature");e.data.rootFeature=t,await e.start(),this._set("activeWorkflow",e)}async deleteFeatureFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?await t.deleteActiveFeature():D("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(t){return this._cancelWorkflow({warn:!0,...t})}findEditableItemForLayer(t){const e="subtype-sublayer"===t.type?t.parent:t;return this._editableItems.find((t=>t.layer===e))}itemHasInvalidFormTemplate(t){return!!t&&(this.findEditableItemForLayer(t.layer)?.hasInvalidFormTemplate??!1)}itemHasUnsupportedFields(t){return!!t&&(this.findEditableItemForLayer(t.layer)?.hasUnsupportedFields??!1)}refreshCreationTemplates(){const t=[];for(const{layer:e,supports:a}of this._editableItems)e.loaded&&a.includes("create")&&t.push(e);this.featureTemplatesViewModel.layers=t}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!0}):await this.startUpdateWorkflowAtFeatureSelection()))}async _updateEditableItems(){n(this._updateEditableItemsTask);const t=e((async t=>{const e=this.view?.allLayerViews,r=this.view?.map,i=r?.editableLayers.toArray()??[],s=r?.allTables.toArray().filter(W)??[];await Promise.all(s.map((t=>t.load())));const o=s.filter((t=>k(t))),n=[...i.reverse(),...o.reverse()].filter((t=>"mesh"!==t.geometryType||"3d"===this.view?.type));if(!e||!i)return;const d=[],p=[];for(const a of n){const r=e.find((t=>t.layer===a)),i=r?d:p;if("subtype-group"===a.type){await a.loadAll(),l(t);for(let t=a.sublayers.length-1;t>=0;--t)i.push(this._makeEditableItemForLayer(a.sublayers.at(t),!!r?.suspended))}else i.push(this._makeEditableItemForLayer(a,!!r?.suspended))}if(t.aborted)return;const c=this._editableItems;this._editableItems=new a(d.concat(p)),c.destroy()}));this._updatingHandles.addPromise(t.promise),this._updateEditableItemsTask=t}async _cancelWorkflow(t){const e=this.activeWorkflow;if(!e)return void(t&&t.warn&&D("editing:no-active-workflow","There is no active workflow to cancel."));if(!t||!1!==t.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await e.cancel(t);await e.cancel(t),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(t,e){return F.create({viewModel:this,creationInfo:t,startAt:e,applyEditsCallback:(t,e,a)=>this._applyEdits(t,e,a),addAttachmentsCallback:(t,e)=>this._addAttachments(t,e)})}_createCreateWorkflow(t){return C.create(this,t,((t,e,a)=>this._applyEdits(t,e,a)))}_createUpdateWorkflow(t){return I.create(this,t,((t,e)=>this._applyEdits(t,e)))}_addAttachments(t,e){const a=e.map((e=>this._addAttachment(t,e.feature,e.attachment)))??[];return Promise.all(a)}async _addAttachment(t,e,a){let r=null;if("geojson"===t.type||"scene"===t.type||"oriented-imagery"===t.type)throw new i("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(r=await(t.addAttachment?.(e,a).catch((t=>{throw t?.error||t})))??null,r))),r}async _applyEdits(t,e,a){let r=null;const i=t.url?await g(t.url):null,s={returnServiceEditsOption:(!i||!b(i))&&!RegExp("/hosted/","i").test(t.url)?"original-and-current-features":void 0,...a};return await this._queueOperation((async()=>{const a=await U(this.view,t).catch((()=>null));return r=await t.applyEdits(e,s),a&&await u((()=>!a.updating)),r})),r}_queueOperation(t){this._activityQueue.push(t),this.notifyChange("syncing");const e=(t,e)=>{const a=e.indexOf(t);a>-1&&e.splice(a,1)};return t().then((t=>{if("error"in t&&t.error)throw t.error;if("addFeatureResults"in t){const{addFeatureResults:e,deleteFeatureResults:a,updateFeatureResults:r}=t,i=e.find((t=>!!t.error))||r.find((t=>!!t.error))||a.find((t=>!!t.error));if(i)throw i.error}return t})).catch((a=>{D("editing:operation-error","An error occurred.",{error:a});const r={error:a,retry:()=>(e(r,this.failures),this._queueOperation(t)),cancel:()=>{e(r,this.failures)}};this._set("failures",[...this.failures,r])})).then((()=>{e(t,this._activityQueue),this.notifyChange("syncing")}))}_makeEditableItemForLayer(t,e=!0){const a=v(t),r=a?.operations,i=G(this.layerInfos,t),s=A(t),o=t.fields.some((({type:t})=>O.has(t))),n=s||o,{allowedWorkflows:l}=this,d=l.includes("create")||l.includes("create-features"),p=l.includes("update"),c=t=>!i||!1!==i.enabled&&!1!==i[t],u=d&&!!r?.supportsAdd&&c("addEnabled"),h=p&&!!r?.supportsUpdate&&c("updateEnabled"),w=!n&&p&&!!r?.supportsDelete&&c("deleteEnabled"),f=[];e||(u&&f.push("create"),h&&f.push("update"),w&&f.push("delete"));const m=h&&!n&&(!i||!1!==i.attributeUpdatesEnabled),y=h&&!n&&!!a?.editing?.supportsGeometryUpdate&&(!i||!1!==i.geometryUpdatesEnabled),k=!(!a?.data?.supportsAttachment||i&&!1===i.allowAttachments);return{layer:t,supports:f,attributeUpdatesEnabled:m,geometryUpdatesEnabled:y,hasAttachments:k,attachmentsOnCreateEnabled:k&&d&&(!i||!1!==i.attachmentsOnCreateEnabled),attachmentsOnUpdateEnabled:!n&&k&&(!i||!1!==i.attachmentsOnUpdateEnabled),hasInvalidFormTemplate:s,hasUnsupportedFields:o}}};t([w()],H.prototype,"_editableItems",void 0),t([w({readOnly:!0})],H.prototype,"activeWorkflow",void 0),t([w({readOnly:!0})],H.prototype,"_activityQueue",void 0),t([w({value:[...P]})],H.prototype,"allowedWorkflows",null),t([w({readOnly:!0})],H.prototype,"canCreate",null),t([w({readOnly:!0})],H.prototype,"canUpdate",null),t([w()],H.prototype,"editableItems",null),t([w({readOnly:!0})],H.prototype,"failures",void 0),t([w()],H.prototype,"attachmentsViewModel",void 0),t([w()],H.prototype,"featureFormViewModel",void 0),t([w()],H.prototype,"featureTemplatesViewModel",void 0),t([w()],H.prototype,"labelOptions",null),t([w()],H.prototype,"layerInfos",null),t([w()],H.prototype,"sketchViewModel",void 0),t([w()],H.prototype,"snappingOptions",null),t([w()],H.prototype,"spinnerViewModel",void 0),t([w()],H.prototype,"state",null),t([w({readOnly:!0})],H.prototype,"syncing",null),t([w()],H.prototype,"updating",null),t([w()],H.prototype,"tooltipOptions",null),t([w()],H.prototype,"view",null),t([w()],H.prototype,"pageStack",void 0),t([w()],H.prototype,"showDiscardEditsPrompt",void 0),t([w()],H.prototype,"_candidateCommitted",void 0),t([w()],H.prototype,"page",null),t([w()],H.prototype,"selectedTemplateItem",null),t([w()],H.prototype,"featureFormDisabled",null),t([w()],H.prototype,"canGoBack",null),t([w()],H.prototype,"shouldShowDeleteButton",null),t([w()],H.prototype,"hasPendingEdits",null),t([w()],H.prototype,"useDeprecatedCreateWorkflow",void 0),H=t([f(S)],H);const x=H;export{x as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Error.js";import s from"../../core/Evented.js";import{abortMaybe as i}from"../../core/maybe.js";import{throwIfNotAbortError as r,createResolver as o}from"../../core/promiseUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{WatchUpdatingTracking as p}from"../../core/support/WatchUpdatingTracking.js";let h=class extends s.EventedAccessor{constructor(t){super(t),this._indexHistory=[],this._lastStepIndex=-1,this._stepIndex=-1,this._setupAbortController=null,this._updatingHandles=new p,this._handleKeys={afterCommit:"after-commit",beforeCommit:"before-commit"},this.data=void 0,this.started=!1,this.steps=[],this.type=null,this._pendingOperation=Promise.resolve()}destroy(){this._updatingHandles.destroy()}get hasNextStep(){const{steps:t}=this;return!!(t&&this._stepIndex<t.filter((t=>!t.parent)).length-1)}get hasPreviousStep(){return this._stepIndex>0}get reliesOnOwnerAdminPrivileges(){return!1}get hasInvalidFormTemplate(){return!1}get hasUnsupportedFields(){return!1}get shouldShowAttachments(){return!1}get shouldAllowAttachmentEditing(){return!1}get stepId(){const{steps:t}=this,e=t&&t[this._stepIndex];return e&&e.id}get helpMessage(){}get hasPendingEdits(){return!1}get keyboardCancellationEnabled(){return!0}get updating(){return this._updatingHandles.updating}async back(t=(()=>Promise.resolve(!0))){if(this.hasPendingEdits){if(!await t())return}this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0})}async cancel(t={force:!0}){return!1!==t.force?this._cancel(t):new Promise(((s,i)=>{this.emit("cancel-request",{controller:{allow:()=>{this._cancel({...t,force:!0}).then(s)},deny:()=>i(new e("workflow:cancel-denied","Request to cancel workflow was denied."))}})}))}async commit(){this.removeHandles(this._handleKeys.beforeCommit),await(this.onCommit?.(this.data)),this.removeHandles(this._handleKeys.afterCommit),this.emit("commit")}async go(t){const{steps:e}=this,s=e.findIndex((e=>e.id===t));this._indexHistory.push(this._stepIndex),await this._go(s)}async next(){this._indexHistory.push(this._stepIndex),await this._go(this._stepIndex+1)}async previous(t={cancelCurrentStep:!1}){await this._go(this._indexHistory.pop(),t.cancelCurrentStep)}async reset(){await this._cancel({notify:!1}),await this.start()}async save(){await this.commit(),await this.reset()}async start(){this._set("started",!0);const t=-1===this._stepIndex?0:this._stepIndex;await this._go(t)}_cancel({notify:t=!0,error:e}={}){return this._transaction((async()=>{this.started&&(this._set("started",!1),await this.steps[this._stepIndex].tearDown({canceled:!0})),this.removeHandles([this._handleKeys.afterCommit,this._handleKeys.beforeCommit]),this._resetIndexing(t),t&&this.emit("cancel",{error:e})}))}_go(t=-1,e=!1){return this._transaction((async()=>{const{steps:s}=this;if(t<=-1||t>=s.length)return;if(!this.started)return this._stepIndex=t,void this._notifyStepProps();this._lastStepIndex>-1&&(this._setupAbortController=i(this._setupAbortController),await s[this._lastStepIndex].tearDown({canceled:e})),this._setupAbortController=new AbortController;const o=this._setupAbortController.signal;try{await s[t].setUp()}catch(n){r(n)}this._setupAbortController.signal===o&&(this._setupAbortController=null),o.aborted||(this._lastStepIndex=t,this._stepIndex=t,this._notifyStepProps())}))}async _transaction(t){const e=this._pendingOperation,s=o();this._pendingOperation=e.then((()=>s.promise)),this._updatingHandles.addPromise(this._pendingOperation);try{await e,await t()}finally{s.resolve()}}_resetIndexing(t=!0){this._stepIndex=-1,this._lastStepIndex=-1,this._indexHistory.length=0,t&&this._notifyStepProps()}_notifyStepProps(){this.notifyChange("stepId"),this.notifyChange("hasPreviousStep"),this.notifyChange("hasNextStep")}};t([n()],h.prototype,"data",void 0),t([n()],h.prototype,"hasNextStep",null),t([n()],h.prototype,"hasPreviousStep",null),t([n()],h.prototype,"onCommit",void 0),t([n()],h.prototype,"reliesOnOwnerAdminPrivileges",null),t([n()],h.prototype,"hasInvalidFormTemplate",null),t([n()],h.prototype,"hasUnsupportedFields",null),t([n()],h.prototype,"shouldShowAttachments",null),t([n()],h.prototype,"shouldAllowAttachmentEditing",null),t([n()],h.prototype,"started",void 0),t([n({readOnly:!0})],h.prototype,"stepId",null),t([n()],h.prototype,"steps",void 0),t([n({readOnly:!0})],h.prototype,"type",void 0),t([n()],h.prototype,"helpMessage",null),t([n()],h.prototype,"hasPendingEdits",null),t([n()],h.prototype,"keyboardCancellationEnabled",null),t([n()],h.prototype,"updating",null),h=t([a("esri.widgets.Editor.Workflow")],h);const l=h;export{l as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Error.js";import s from"../../core/Evented.js";import{abortMaybe as i}from"../../core/maybe.js";import{throwIfNotAbortError as r,createResolver as o}from"../../core/promiseUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as p}from"../../core/support/UpdatingHandles.js";let l=class extends s.EventedAccessor{constructor(t){super(t),this._indexHistory=[],this._lastStepIndex=-1,this._stepIndex=-1,this._setupAbortController=null,this._updatingHandles=new p,this._handleKeys={afterCommit:"after-commit",beforeCommit:"before-commit"},this.data=void 0,this.started=!1,this.steps=[],this.type=null,this._pendingOperation=Promise.resolve()}destroy(){this._updatingHandles.destroy()}get hasNextStep(){const{steps:t}=this;return!!(t&&this._stepIndex<t.filter((t=>!t.parent)).length-1)}get hasPreviousStep(){return this._stepIndex>0}get reliesOnOwnerAdminPrivileges(){return!1}get hasInvalidFormTemplate(){return!1}get hasUnsupportedFields(){return!1}get shouldShowAttachments(){return!1}get shouldAllowAttachmentEditing(){return!1}get stepId(){const{steps:t}=this,e=t&&t[this._stepIndex];return e&&e.id}get helpMessage(){}get hasPendingEdits(){return!1}get keyboardCancellationEnabled(){return!0}get updating(){return this._updatingHandles.updating}async back(t=(()=>Promise.resolve(!0))){if(this.hasPendingEdits){if(!await t())return}this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0})}async cancel(t={force:!0}){return!1!==t.force?this._cancel(t):new Promise(((s,i)=>{this.emit("cancel-request",{controller:{allow:()=>{this._cancel({...t,force:!0}).then(s)},deny:()=>i(new e("workflow:cancel-denied","Request to cancel workflow was denied."))}})}))}async commit(){this.removeHandles(this._handleKeys.beforeCommit),await(this.onCommit?.(this.data)),this.removeHandles(this._handleKeys.afterCommit),this.emit("commit")}async go(t){const{steps:e}=this,s=e.findIndex((e=>e.id===t));this._indexHistory.push(this._stepIndex),await this._go(s)}async next(){this._indexHistory.push(this._stepIndex),await this._go(this._stepIndex+1)}async previous(t={cancelCurrentStep:!1}){await this._go(this._indexHistory.pop(),t.cancelCurrentStep)}async reset(){await this._cancel({notify:!1}),await this.start()}async save(){await this.commit(),await this.reset()}async start(){this._set("started",!0);const t=-1===this._stepIndex?0:this._stepIndex;await this._go(t)}_cancel({notify:t=!0,error:e}={}){return this._transaction((async()=>{this.started&&(this._set("started",!1),await this.steps[this._stepIndex].tearDown({canceled:!0})),this.removeHandles([this._handleKeys.afterCommit,this._handleKeys.beforeCommit]),this._resetIndexing(t),t&&this.emit("cancel",{error:e})}))}_go(t=-1,e=!1){return this._transaction((async()=>{const{steps:s}=this;if(t<=-1||t>=s.length)return;if(!this.started)return this._stepIndex=t,void this._notifyStepProps();this._lastStepIndex>-1&&(this._setupAbortController=i(this._setupAbortController),await s[this._lastStepIndex].tearDown({canceled:e})),this._setupAbortController=new AbortController;const o=this._setupAbortController.signal;try{await s[t].setUp()}catch(n){r(n)}this._setupAbortController.signal===o&&(this._setupAbortController=null),o.aborted||(this._lastStepIndex=t,this._stepIndex=t,this._notifyStepProps())}))}async _transaction(t){const e=this._pendingOperation,s=o();this._pendingOperation=e.then((()=>s.promise)),this._updatingHandles.addPromise(this._pendingOperation);try{await e,await t()}finally{s.resolve()}}_resetIndexing(t=!0){this._stepIndex=-1,this._lastStepIndex=-1,this._indexHistory.length=0,t&&this._notifyStepProps()}_notifyStepProps(){this.notifyChange("stepId"),this.notifyChange("hasPreviousStep"),this.notifyChange("hasNextStep")}};t([n()],l.prototype,"data",void 0),t([n()],l.prototype,"hasNextStep",null),t([n()],l.prototype,"hasPreviousStep",null),t([n()],l.prototype,"onCommit",void 0),t([n()],l.prototype,"reliesOnOwnerAdminPrivileges",null),t([n()],l.prototype,"hasInvalidFormTemplate",null),t([n()],l.prototype,"hasUnsupportedFields",null),t([n()],l.prototype,"shouldShowAttachments",null),t([n()],l.prototype,"shouldAllowAttachmentEditing",null),t([n()],l.prototype,"started",void 0),t([n({readOnly:!0})],l.prototype,"stepId",null),t([n()],l.prototype,"steps",void 0),t([n({readOnly:!0})],l.prototype,"type",void 0),t([n()],l.prototype,"helpMessage",null),t([n()],l.prototype,"hasPendingEdits",null),t([n()],l.prototype,"keyboardCancellationEnabled",null),t([n()],l.prototype,"updating",null),l=t([a("esri.widgets.Editor.Workflow")],l);const h=l;export{h as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{deprecatedProperty as n}from"../../core/deprecate.js";import s from"../../core/Evented.js";import i from"../../core/Logger.js";import{destroyMaybe as o}from"../../core/maybe.js";import{EsriPromiseMixin as r}from"../../core/Promise.js";import{watch as a}from"../../core/reactiveUtils.js";import{templateHasKey as l}from"../../core/string.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import{WatchUpdatingTracking as c}from"../../core/support/WatchUpdatingTracking.js";import d from"../../form/FormTemplate.js";import h from"../../layers/support/ContingentValue.js";import{isEditableLayer as f}from"../../layers/support/editableLayers.js";import m from"../../layers/support/LayerContingentValuesCache.js";import{flattenFieldInputs as g,flattenRelationshipInputs as y,parseFormTemplateString as _,isGroupInput as v,isGroupElement as C,isFieldElement as I,isRelationshipElement as E,isRelationshipInput as F,isFieldInput as x,getNormalizedFeatureTypeInfo as b}from"./featureFormUtils.js";import V from"./FieldInput.js";import{createFormExpressionArcadeExecutor as w}from"./FormExpressionArcadeExecutor.js";import{FormExpressionsManager as j}from"./FormExpressionsManager.js";import A from"./GroupInput.js";import T from"./RelationshipInput.js";const M=new t({attributes:{}}),R=["editableExpression","requiredExpression","valueExpression","visibilityExpression"],L=["visibilityExpression"],N=["editableExpression","visibilityExpression"],S="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",k="#JSAPI_CONTINGENT_VALUE_ANY_HASH",H="#JSAPI_CONTINGENT_VALUE_NULL_HASH",P="esri.widgets.FeatureForm.FeatureFormViewModel",U=i.getLogger(P);let G=class extends(r(s.EventedAccessor)){constructor(e){super(e),this._expressionExecutorLookup=new Map,this._expressionsManager=null,this._contingentValuesCache=null,this._featureClone=M.clone(),this._initialFeature=M.clone(),this._updatingHandles=new c,this.arcadeEditType="NA",this.contingencyConstraintViolations=new Map,this.disabled=!1,this.inputs=[],this.map=null,this.relatedRecordCallbacks=null,this.strict=!1}initialize(){const e=a((()=>[this.layer,!!this.layer?.loaded,this.formTemplate,this.feature,this.arcadeEditType]),(([e,t])=>{null!=e&&(t?this._updateInputs():e.load().catch((()=>i.getLogger(this).error("Failed to load layer",e.loadError))))}),{equals:([e,t,n,s,i],[o,r,a,l,u])=>e===o&&t===r&&n===a&&s===l&&i===u,initial:!0}),t=a((()=>this._arcadeContextInfo),(e=>{null!=this._expressionsManager&&(this._expressionsManager.arcadeContextInfo=e)})),n=a((()=>this.layer),(e=>{const t="subtype-sublayer"===e?.type?e.parent:"feature"===e?.type?e:null;t&&this.addResolvingPromise(m.createLoadedLayerContingentValuesCache(t).then((e=>{this._contingentValuesCache=e,this.notifyChange("fieldsWithContingentValues")})))}),{initial:!0});this.addHandles([e,t,n])}destroy(){this.feature=null,this.layer=null,this._contingentValuesCache=o(this._contingentValuesCache),this._updatingHandles.destroy()}get _expressionInfosLookup(){return new Map(this.formTemplate?.expressionInfos?.map((e=>[e.name,e])))}get activeRelationshipInput(){return this.allRelationshipInputs.find((e=>e.relationshipId===this.relationshipId))}get _arcadeContextInfo(){const{_initialFeature:e,arcadeEditType:t,layer:n,map:s,spatialReference:i}=this;return{layer:f(n)?n:null,originalFeature:e,editType:t,map:s,spatialReference:i}}get allFieldInputs(){return g(this.inputs)}get allRelationshipInputs(){return y(this.inputs)}get _layerFieldsByName(){return new Map(this.layer?.fields.map((e=>[e.name,e])))}get feature(){return this._get("feature")}set feature(e){this._featureClone=e?e.clone():M.clone(),this._initialFeature=this._featureClone.clone(),e?(this._resetFieldInputValues(this._featureClone),this.allRelationshipInputs.forEach((t=>t.feature=e))):(this.inputs.forEach((e=>e.destroy())),this.inputs.length=0),this.contingencyConstraintViolations.clear(),null!=this._expressionsManager&&(this._expressionsManager.resetExecutors(),this._expressionsManager.feature=this._featureClone,this._updatingHandles.addPromise(this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated())))),this._set("feature",e)}get fieldsWithContingentValues(){if(null==this._contingentValuesCache)return new Set;const e=this._contingentValuesCache.fieldGroups.flatMap((e=>e.fields));return new Set(e)}get formTemplate(){return this.layer&&"formTemplate"in this.layer?this.layer.formTemplate:null}set formTemplate(e){void 0===e?this._clearOverride("formTemplate"):this._override("formTemplate",e)}get formDescription(){const{formTemplate:e,layer:t}=this;return null!=e&&e.description&&t?_(e.description,this.getValues(),t.fieldsIndex):null}get formTitle(){const{formTemplate:e,layer:t}=this;return null!=e&&e.title&&t?_(e.title,this.getValues(),t.fieldsIndex):null}formHeaderVisible(){const{activeRelationshipInput:e,formDescription:t,formTitle:n}=this;return!(e||!t&&!n)}set inputFields(e){n(U,"inputFields",{replacement:"FeatureFormViewModel.inputs",version:"4.27"}),this.inputs=e}get inputFields(){return n(U,"inputFields",{replacement:"FeatureFormViewModel.inputs",version:"4.27"}),this.inputs}get joinedContingentValues(){return this._joinContingentValues()}get layer(){return this.feature?.sourceLayer&&"applyEdits"in this.feature.sourceLayer?this.feature.sourceLayer:null}set layer(e){this._override("layer",e)}get relationshipId(){return this._get("relationshipId")}set relationshipId(e){const t=this.allRelationshipInputs;if(null!=e&&e===this.relationshipId||t.forEach((e=>e.showAllEnabled=!1)),null!=e){const n=t.find((t=>t.relationshipId===e));n&&(n.showAllEnabled=!0)}this._set("relationshipId",e)}get spatialReference(){return this.layer?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){return this.get("layer.loaded")?"ready":"disabled"}get submittable(){return!!this.valid||this.allFieldInputs.filter((e=>!e.valid)).every((({submittable:e})=>e))}get updating(){return this._updatingHandles.updating}get valid(){const e=this.allFieldInputs;return e.length>0&&e.every((({valid:e})=>e))}get view(){return n(U,"view",{replacement:"FeatureForm.map",version:"4.27"}),this._get("view")}set view(e){n(U,"view",{replacement:"FeatureForm.map",version:"4.27"}),this._set("view",e),e?.map&&(this.map=e.map)}findField(e){return this.allFieldInputs.find((t=>t.name===e))}getValue(e){const{_featureClone:t,layer:n}=this,s=!!n?.getField(e);return t.getAttribute(e)??(s?null:void 0)}setValue(e,t){const{_featureClone:n,strict:s}=this,i=this.findField(e);t=""===t?null:t,i&&n.getAttribute(e)!==t&&(i.value=t,s&&!i.valid||(this._afterValueChange(i),null!=this._expressionsManager&&this._updatingHandles.addPromise(this._expressionsManager.evaluateInvalidated([i.name]).finally((()=>this._afterExpressionsEvaluated())))))}getValues(){return{...this._featureClone.attributes}}submit(){const e=this.allFieldInputs,t=new Set(e.filter((e=>e.valid)).map((({name:e})=>e))),n=e.filter((e=>!e.valid)).map((({name:e})=>e)),s=this.getValues();if(this.validateContingencyConstraints(s,{includeIncompleteViolations:!0}).length>0)for(const[i,o]of this.contingencyConstraintViolations.entries())"error"===o.type&&(t.delete(i),n.push(i));this.emit("submit",{valid:[...t],invalid:n,values:s})}validateContingencyConstraints(e,t){const{_contingentValuesCache:n}=this,s=new Map;if(this.contingencyConstraintViolations=s,null==n)return[];const{invalid:i,incomplete:o}=n.validateContingencyConstraints(e),r=[...i,...t?.includeIncompleteViolations?o:[]];for(const a of r)for(const e of a.fieldGroup.fields)s.set(e,a);return r}notifyFeatureGeometryChanged(){const{_expressionsManager:e,feature:t,_featureClone:n}=this;n.geometry=t.geometry,null!=e&&this._updatingHandles.addPromise(e.evaluateInvalidatedByGeometry().finally((()=>this._afterExpressionsEvaluated())))}_emitChangeEvent({name:e,valid:t,value:n}){this.emit("value-change",{layer:this.layer,feature:this.feature,fieldName:e,value:n,valid:t})}_updateInputs(){const{_featureClone:e,_initialFeature:t,arcadeEditType:n,formTemplate:s,inputs:i,layer:o}=this;if(!o)return;const r={arcadeEditType:n,feature:e,initialFeature:t,layer:o},a=i.slice(),l=null!=s&&s.elements&&s.elements.length>0?this._updateInputsUsingFormElements(a,s.elements,r):this._updateInputsUsingLayerFields(a,o?.fields,r);this.inputs=l}_updateInputsUsingFormElements(e,t,n){const s=new Map;for(const r of e)if(v(r)){s.set(r.element,r);for(const e of r.inputs)e.element&&s.set(e.element,e)}else r.element&&s.set(r.element,r);const i=new Map,o=this._updateInputsUsingFormElementsRecursive({existingInputsByElement:s,updatedElements:t.filter(O),sharedInitializationProperties:n,group:null,newExpressionExecutorPromises:i});this._updatingHandles.addPromise(Promise.all(Array.from(i.values())).then((()=>{const e=Array.from(this._expressionExecutorLookup.values()),t=g(o);return this._createExpressionsManager(e,t),this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated()))})));for(const[r,a]of s.entries())s.delete(r),a.destroy();return o}_updateInputsUsingFormElementsRecursive(e){const{existingInputsByElement:t,updatedElements:n,sharedInitializationProperties:s,group:i,newExpressionExecutorPromises:o}=e,r=[];for(const a of n){const e=t.has(a),n=e?t.get(a):C(a)?this._makeGroupInputFromElement(a,s):I(a)?this._makeFieldInputFromElement(a,s,i):E(a)?this._makeRelationshipInputFromElement(a,s,i):null;if(n){if(r.push(n),e)if(t.delete(a),v(n)){const{feature:e}=s;n.set({feature:e})}else if(F(n)){const e=this.relationshipId===a.relationshipId;n.set(s),n.set({map:this.map,showAllEnabled:e})}else n.set(s);else this._assignExpressionExecutors(n,a,o);if(C(a)){const e=a.elements.filter((e=>O(e)));n.inputs=this._updateInputsUsingFormElementsRecursive({existingInputsByElement:t,updatedElements:e,sharedInitializationProperties:s,group:n,newExpressionExecutorPromises:o})}}}return r}_updateInputsUsingLayerFields(e,t,n){if(!Array.isArray(t))return i.getLogger(this).warn(this.declaredClass,"No attribute fields found."),[];const s=new Map;for(const i of e)if(v(i)){for(const e of i.inputs)e.destroy();i.inputs.length=0,i.destroy()}else F(i)?i.destroy():x(i)&&(null!==i.element?i.destroy():s.set(i.field,i));const o=[],{arcadeEditType:r,feature:a,initialFeature:l,layer:u}=n;for(const i of t){const e=s.get(i)??new V({arcadeEditType:r,field:i,feature:a,initialFeature:l,layer:u,value:a?.getAttribute(i.name)??null});o.push(e),s.delete(i)}for(const[i,p]of s.entries())s.delete(i),p.destroy();return o}_resetFieldInputValues(e){for(const t of this.allFieldInputs)t.value=e.getAttribute(t.name)}_makeFieldInputFromElement(e,t,n){const{arcadeEditType:s,feature:i,initialFeature:o,layer:r}=t,{fieldName:a}=e,l=a&&this._layerFieldsByName.get(a);return l?new V({arcadeEditType:s,element:e,field:l,value:i?.getAttribute(e.fieldName)??null,feature:i,initialFeature:o,layer:r,group:n}):null}_makeGroupInputFromElement(e,t){const{feature:n,layer:s}=t;return new A({element:e,inputs:[],feature:n,layer:s})}_makeRelationshipInputFromElement(e,t,n=null){const{map:s}=this,{feature:i,layer:o}=t;return new T({element:e,feature:i,group:n,layer:o,map:s})}_assignExpressionExecutors(e,t,n){const s=C(t)?L:E(t)?N:R,i=[];for(const o of s){const s=t[o],{_expressionExecutorLookup:i}=this;if(null!=s&&""!==s){const t=`${o}Executor`,r=this._expressionInfosLookup.get(s)?.expression??s;if(i.has(r))e[t]=i.get(r);else if(n.has(r)){const s=n.get(r).then((n=>(e[t]=n,n)));n.set(r,s)}else{const s=w(r,this.layer).then((n=>(e[t]=n,i.set(r,n),n)));n.set(r,s)}}}return i}_createExpressionsManager(e,t){const{_arcadeContextInfo:n,_featureClone:s}=this;this._expressionsManager=new j({executors:e,feature:s,arcadeContextInfo:n,fieldInputs:t})}_afterValueChange(e){const{name:t,value:n}=e,{_featureClone:s,formTemplate:i,layer:o}=this;if(!o)return;const r=s.getAttribute(t);s.setAttribute(t,n);const{typeFieldName:a,types:u}=b(o);if(t===a&&n!==r){if("subtype-sublayer"===o.type){const e=o.parent?.findSublayerForFeature(s);s.sourceLayer=this.feature.sourceLayer=e}const e=new Set;for(const t of u)if(t.domains&&"object"==typeof t.domains)for(const n of Object.keys(t.domains))e.add(n);for(const t of e){const e=this.findField(t);e&&e.notifyChange("domain")}}if(null!=i){const{description:e,title:n}=i;n&&l(n,t)&&this.notifyChange("formTitle"),e&&l(e,t)&&this.notifyChange("formDescription")}this._emitChangeEvent(e)}_afterExpressionsEvaluated(){const{_featureClone:e}=this;for(const t of this.allFieldInputs)t.value!==e.getAttribute(t.name)&&this._afterValueChange(t)}_joinContingentValues(){const e=this._contingentValuesCache;if(null==e)return[];const{typeFieldName:t}=b(this.layer),n=t?this.getValue(t):null,s=[];for(const r of e.fieldGroups){const{contingencies:e,fields:t,name:i}=r,o=[];for(const s of e)s.isRetired||null!=s.subtype&&s.subtype.code!==n||o.push({values:s.values});o.length>0&&s.push({name:i,fields:t,contingencies:o})}const[i,o]=this._generateJoinPlan(s);return[...i.flatMap((e=>this._joinFieldGroupContingencies(e))),...o.flatMap((e=>e.contingencies))]}_generateJoinPlan(e){const t=new Map,n=[],s=new Set;for(const l of e)for(const e of l.fields)if(t.has(e)){const i=t.get(e),o=l,r=[i.name,o.name].sort().join("|");if(s.has(r))continue;n.push([i,o]),s.add(r),t.set(e,o)}else t.set(e,l);const i=new Set(n.flat()),o=new Set(e);for(const l of i)o.delete(l);const r=new Map,a=new Map;for(const l of new Set(n.flat())){const e=Symbol(l.name);r.set(e,new Set([l])),a.set(l,e)}for(const[l,u]of n){const e=a.get(l),t=a.get(u);if(e===t)continue;const n=r.get(e),s=r.get(t);for(const i of s)n.add(i),a.set(i,e);r.delete(t)}return[[...r.values()].map((e=>[...e])),[...o]]}_joinFieldGroupContingencies(e){const t=e.slice(),n=t.shift();let s=t.shift(),i=this._generateJoinKey(n.fields,s.fields),o=new Set([...n.fields,...s.fields]),r=new Map;for(const l of n.contingencies){const[e]=this._hashContingency(l,i.codedValueFields,!0);r.has(e)?r.get(e)?.push(l):r.set(e,[l])}for(;t.length>0;){const e=new Map,n=t.shift(),a=this._generateJoinKey(o,n.fields);for(const t of s.contingencies){const[n,s]=this._hashContingency(t,i.codedValueFields),o=s?this._findMatchingContingenciesWithAnyHashMask(r,n):r.get(n);if(r.has(k)&&o?.push(...this._findMatchingContingenciesContainingAny(t,r.get(k),i.codedValueFields)),null!=o)for(const r of o){const n=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(r,t,i.rangeFields):this._joinContingencies(r,t);if(null==n)break;const[s]=this._hashContingency(n,a.codedValueFields,!0);e.has(s)?e.get(s)?.push(n):e.set(s,[n])}}r=e,s=n,i=a,o=new Set([...o,...s.fields])}const a=[];for(const l of s.contingencies){const[e,t]=this._hashContingency(l,i.codedValueFields),n=t?this._findMatchingContingenciesWithAnyHashMask(r,e):r.get(e);if(r.has(k)&&n.push(...this._findMatchingContingenciesContainingAny(l,r.get(k),i.codedValueFields)),null!=n)for(const s of n){const e=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(s,l,i.rangeFields):this._joinContingencies(s,l);null!=e&&a.push(e)}}return a}_joinContingencies(e,t){const n={values:{...e.values,...t.values}};for(const[s,i]of Object.entries(n.values))"any"===i.objectType&&null!=e.values[s]&&(n.values[s]=e.values[s]);return n}_joinContingenciesWithRangeDomains(e,t,n){const s=this._joinContingencies(e,t);for(const i of n){const n=e.values[i],o=t.values[i],{leftIsNull:r,rightIsNull:a,bothAreNull:l,leftIsAny:u,rightIsAny:p,bothAreAny:c,leftIsRange:d,rightIsRange:f}=this._compareObjectTypes(n.objectType,o.objectType);if(l||c)continue;if(r&&p||a&&u){s.values[i]=new h({objectType:"null"});continue}if(r&&f||a&&d)return null;u?(n.minValue=-1/0,n.maxValue=1/0):p&&(o.minValue=-1/0,o.maxValue=1/0);const m=Math.max(n.minValue,o.minValue),g=Math.min(n.maxValue,o.maxValue);if(m>g)return null;s.values[i]=new h({objectType:"range",minValue:m,maxValue:g})}return s}_findMatchingContingenciesContainingAny(e,t,n){return t.filter((t=>n.every((n=>{const s=t.values[n],i=e.values[n];return"any"===s.objectType||"any"===i.objectType||s.codedValue?.code===i.codedValue?.code}))))}_findMatchingContingenciesWithAnyHashMask(e,t){const n=RegExp(`${t}$`),s=[];for(const[i,o]of e){if(i===k)break;n.test(i)&&s.push(...o)}return s}_generateJoinKey(e,t){const n=Array.isArray(e)?new Set(e):e,s=Array.isArray(t)?new Set(t):t,i=n.size<s.size?n:s,o=i===n?s:n,r=new Set,a=new Set;for(const l of i)if(o.has(l)){const e=this.layer?.getFieldDomain(l,{feature:this.feature});if(null==e)continue;switch(e.type){case"coded-value":r.add(l);break;case"range":a.add(l)}}return{codedValueFields:[...r],rangeFields:[...a]}}_hashContingency(e,t,n=!1){if(t.length<1)return[S,!1];const s=[];let i=!1;for(const o of t){const t=e.values[o];if("any"===t.objectType){if(n)return[k,!0];i=!0,s.push(`${o}:.*`)}else"null"===t.objectType?s.push(`${o}:${H}`):s.push(`${o}:${t.codedValue?.code}`)}return[s.sort().join("&"),i]}_compareObjectTypes(e,t){return{leftIsNull:"null"===e,rightIsNull:"null"===t,bothAreNull:"null"===e&&"null"===t,leftIsAny:"any"===e,rightIsAny:"any"===t,bothAreAny:"any"===e&&"any"===t,leftIsRange:"range"===e,rightIsRange:"range"===t}}};function O(e){return"field"===e.type||"group"===e.type||"relationship"===e.type||(i.getLogger(P).warn("form-info::unsupported-element-type","Only element types 'field', 'group' and 'relationship' are supported",`Element ${e.label} has unsupported type '${e.type}'`),!1)}e([u()],G.prototype,"_expressionInfosLookup",null),e([u()],G.prototype,"_featureClone",void 0),e([u()],G.prototype,"activeRelationshipInput",null),e([u()],G.prototype,"_arcadeContextInfo",null),e([u({readOnly:!0})],G.prototype,"allFieldInputs",null),e([u()],G.prototype,"allRelationshipInputs",null),e([u()],G.prototype,"_layerFieldsByName",null),e([u()],G.prototype,"arcadeEditType",void 0),e([u()],G.prototype,"contingencyConstraintViolations",void 0),e([u()],G.prototype,"disabled",void 0),e([u()],G.prototype,"feature",null),e([u()],G.prototype,"fieldsWithContingentValues",null),e([u({type:d})],G.prototype,"formTemplate",null),e([u()],G.prototype,"formDescription",null),e([u()],G.prototype,"formTitle",null),e([u()],G.prototype,"formHeaderVisible",null),e([u()],G.prototype,"inputs",void 0),e([u()],G.prototype,"inputFields",null),e([u()],G.prototype,"joinedContingentValues",null),e([u()],G.prototype,"layer",null),e([u()],G.prototype,"map",void 0),e([u()],G.prototype,"relatedRecordCallbacks",void 0),e([u()],G.prototype,"relationshipId",null),e([u()],G.prototype,"spatialReference",null),e([u()],G.prototype,"state",null),e([u()],G.prototype,"strict",void 0),e([u()],G.prototype,"submittable",null),e([u()],G.prototype,"updating",null),e([u()],G.prototype,"valid",null),e([u()],G.prototype,"view",null),e([u()],G.prototype,"getValues",null),e([u()],G.prototype,"submit",null),G=e([p(P)],G);const W=G;export{W as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{deprecatedProperty as n}from"../../core/deprecate.js";import s from"../../core/Evented.js";import i from"../../core/Logger.js";import{destroyMaybe as o}from"../../core/maybe.js";import{EsriPromiseMixin as r}from"../../core/Promise.js";import{watch as a}from"../../core/reactiveUtils.js";import{templateHasKey as l}from"../../core/string.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as c}from"../../core/support/UpdatingHandles.js";import d from"../../form/FormTemplate.js";import h from"../../layers/support/ContingentValue.js";import{isEditableLayer as f}from"../../layers/support/editableLayers.js";import m from"../../layers/support/LayerContingentValuesCache.js";import{flattenFieldInputs as g,flattenRelationshipInputs as y,parseFormTemplateString as _,isGroupInput as v,isGroupElement as C,isFieldElement as I,isRelationshipElement as E,isRelationshipInput as F,isFieldInput as x,getNormalizedFeatureTypeInfo as b}from"./featureFormUtils.js";import V from"./FieldInput.js";import{createFormExpressionArcadeExecutor as w}from"./FormExpressionArcadeExecutor.js";import{FormExpressionsManager as j}from"./FormExpressionsManager.js";import A from"./GroupInput.js";import T from"./RelationshipInput.js";const M=new t({attributes:{}}),R=["editableExpression","requiredExpression","valueExpression","visibilityExpression"],L=["visibilityExpression"],N=["editableExpression","visibilityExpression"],S="#JSAPI_CONTINGENT_VALUE_EMPTY_HASH",k="#JSAPI_CONTINGENT_VALUE_ANY_HASH",H="#JSAPI_CONTINGENT_VALUE_NULL_HASH",P="esri.widgets.FeatureForm.FeatureFormViewModel",U=i.getLogger(P);let G=class extends(r(s.EventedAccessor)){constructor(e){super(e),this._expressionExecutorLookup=new Map,this._expressionsManager=null,this._contingentValuesCache=null,this._featureClone=M.clone(),this._initialFeature=M.clone(),this._updatingHandles=new c,this.arcadeEditType="NA",this.contingencyConstraintViolations=new Map,this.disabled=!1,this.inputs=[],this.map=null,this.relatedRecordCallbacks=null,this.strict=!1}initialize(){const e=a((()=>[this.layer,!!this.layer?.loaded,this.formTemplate,this.feature,this.arcadeEditType]),(([e,t])=>{null!=e&&(t?this._updateInputs():e.load().catch((()=>i.getLogger(this).error("Failed to load layer",e.loadError))))}),{equals:([e,t,n,s,i],[o,r,a,l,u])=>e===o&&t===r&&n===a&&s===l&&i===u,initial:!0}),t=a((()=>this._arcadeContextInfo),(e=>{null!=this._expressionsManager&&(this._expressionsManager.arcadeContextInfo=e)})),n=a((()=>this.layer),(e=>{const t="subtype-sublayer"===e?.type?e.parent:"feature"===e?.type?e:null;t&&this.addResolvingPromise(m.createLoadedLayerContingentValuesCache(t).then((e=>{this._contingentValuesCache=e,this.notifyChange("fieldsWithContingentValues")})))}),{initial:!0});this.addHandles([e,t,n])}destroy(){this.feature=null,this.layer=null,this._contingentValuesCache=o(this._contingentValuesCache),this._updatingHandles.destroy()}get _expressionInfosLookup(){return new Map(this.formTemplate?.expressionInfos?.map((e=>[e.name,e])))}get activeRelationshipInput(){return this.allRelationshipInputs.find((e=>e.relationshipId===this.relationshipId))}get _arcadeContextInfo(){const{_initialFeature:e,arcadeEditType:t,layer:n,map:s,spatialReference:i}=this;return{layer:f(n)?n:null,originalFeature:e,editType:t,map:s,spatialReference:i}}get allFieldInputs(){return g(this.inputs)}get allRelationshipInputs(){return y(this.inputs)}get _layerFieldsByName(){return new Map(this.layer?.fields.map((e=>[e.name,e])))}get feature(){return this._get("feature")}set feature(e){this._featureClone=e?e.clone():M.clone(),this._initialFeature=this._featureClone.clone(),e?(this._resetFieldInputValues(this._featureClone),this.allRelationshipInputs.forEach((t=>t.feature=e))):(this.inputs.forEach((e=>e.destroy())),this.inputs.length=0),this.contingencyConstraintViolations.clear(),null!=this._expressionsManager&&(this._expressionsManager.resetExecutors(),this._expressionsManager.feature=this._featureClone,this._updatingHandles.addPromise(this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated())))),this._set("feature",e)}get fieldsWithContingentValues(){if(null==this._contingentValuesCache)return new Set;const e=this._contingentValuesCache.fieldGroups.flatMap((e=>e.fields));return new Set(e)}get formTemplate(){return this.layer&&"formTemplate"in this.layer?this.layer.formTemplate:null}set formTemplate(e){void 0===e?this._clearOverride("formTemplate"):this._override("formTemplate",e)}get formDescription(){const{formTemplate:e,layer:t}=this;return null!=e&&e.description&&t?_(e.description,this.getValues(),t.fieldsIndex):null}get formTitle(){const{formTemplate:e,layer:t}=this;return null!=e&&e.title&&t?_(e.title,this.getValues(),t.fieldsIndex):null}formHeaderVisible(){const{activeRelationshipInput:e,formDescription:t,formTitle:n}=this;return!(e||!t&&!n)}set inputFields(e){n(U,"inputFields",{replacement:"FeatureFormViewModel.inputs",version:"4.27"}),this.inputs=e}get inputFields(){return n(U,"inputFields",{replacement:"FeatureFormViewModel.inputs",version:"4.27"}),this.inputs}get joinedContingentValues(){return this._joinContingentValues()}get layer(){return this.feature?.sourceLayer&&"applyEdits"in this.feature.sourceLayer?this.feature.sourceLayer:null}set layer(e){this._override("layer",e)}get relationshipId(){return this._get("relationshipId")}set relationshipId(e){const t=this.allRelationshipInputs;if(null!=e&&e===this.relationshipId||t.forEach((e=>e.showAllEnabled=!1)),null!=e){const n=t.find((t=>t.relationshipId===e));n&&(n.showAllEnabled=!0)}this._set("relationshipId",e)}get spatialReference(){return this.layer?.spatialReference??null}set spatialReference(e){this._override("spatialReference",e)}get state(){return this.get("layer.loaded")?"ready":"disabled"}get submittable(){return!!this.valid||this.allFieldInputs.filter((e=>!e.valid)).every((({submittable:e})=>e))}get updating(){return this._updatingHandles.updating}get valid(){const e=this.allFieldInputs;return e.length>0&&e.every((({valid:e})=>e))}get view(){return n(U,"view",{replacement:"FeatureForm.map",version:"4.27"}),this._get("view")}set view(e){n(U,"view",{replacement:"FeatureForm.map",version:"4.27"}),this._set("view",e),e?.map&&(this.map=e.map)}findField(e){return this.allFieldInputs.find((t=>t.name===e))}getValue(e){const{_featureClone:t,layer:n}=this,s=!!n?.getField(e);return t.getAttribute(e)??(s?null:void 0)}setValue(e,t){const{_featureClone:n,strict:s}=this,i=this.findField(e);t=""===t?null:t,i&&n.getAttribute(e)!==t&&(i.value=t,s&&!i.valid||(this._afterValueChange(i),null!=this._expressionsManager&&this._updatingHandles.addPromise(this._expressionsManager.evaluateInvalidated([i.name]).finally((()=>this._afterExpressionsEvaluated())))))}getValues(){return{...this._featureClone.attributes}}submit(){const e=this.allFieldInputs,t=new Set(e.filter((e=>e.valid)).map((({name:e})=>e))),n=e.filter((e=>!e.valid)).map((({name:e})=>e)),s=this.getValues();if(this.validateContingencyConstraints(s,{includeIncompleteViolations:!0}).length>0)for(const[i,o]of this.contingencyConstraintViolations.entries())"error"===o.type&&(t.delete(i),n.push(i));this.emit("submit",{valid:[...t],invalid:n,values:s})}validateContingencyConstraints(e,t){const{_contingentValuesCache:n}=this,s=new Map;if(this.contingencyConstraintViolations=s,null==n)return[];const{invalid:i,incomplete:o}=n.validateContingencyConstraints(e),r=[...i,...t?.includeIncompleteViolations?o:[]];for(const a of r)for(const e of a.fieldGroup.fields)s.set(e,a);return r}notifyFeatureGeometryChanged(){const{_expressionsManager:e,feature:t,_featureClone:n}=this;n.geometry=t.geometry,null!=e&&this._updatingHandles.addPromise(e.evaluateInvalidatedByGeometry().finally((()=>this._afterExpressionsEvaluated())))}_emitChangeEvent({name:e,valid:t,value:n}){this.emit("value-change",{layer:this.layer,feature:this.feature,fieldName:e,value:n,valid:t})}_updateInputs(){const{_featureClone:e,_initialFeature:t,arcadeEditType:n,formTemplate:s,inputs:i,layer:o}=this;if(!o)return;const r={arcadeEditType:n,feature:e,initialFeature:t,layer:o},a=i.slice(),l=null!=s&&s.elements&&s.elements.length>0?this._updateInputsUsingFormElements(a,s.elements,r):this._updateInputsUsingLayerFields(a,o?.fields,r);this.inputs=l}_updateInputsUsingFormElements(e,t,n){const s=new Map;for(const r of e)if(v(r)){s.set(r.element,r);for(const e of r.inputs)e.element&&s.set(e.element,e)}else r.element&&s.set(r.element,r);const i=new Map,o=this._updateInputsUsingFormElementsRecursive({existingInputsByElement:s,updatedElements:t.filter(O),sharedInitializationProperties:n,group:null,newExpressionExecutorPromises:i});this._updatingHandles.addPromise(Promise.all(Array.from(i.values())).then((()=>{const e=Array.from(this._expressionExecutorLookup.values()),t=g(o);return this._createExpressionsManager(e,t),this._expressionsManager.evaluateAll().finally((()=>this._afterExpressionsEvaluated()))})));for(const[r,a]of s.entries())s.delete(r),a.destroy();return o}_updateInputsUsingFormElementsRecursive(e){const{existingInputsByElement:t,updatedElements:n,sharedInitializationProperties:s,group:i,newExpressionExecutorPromises:o}=e,r=[];for(const a of n){const e=t.has(a),n=e?t.get(a):C(a)?this._makeGroupInputFromElement(a,s):I(a)?this._makeFieldInputFromElement(a,s,i):E(a)?this._makeRelationshipInputFromElement(a,s,i):null;if(n){if(r.push(n),e)if(t.delete(a),v(n)){const{feature:e}=s;n.set({feature:e})}else if(F(n)){const e=this.relationshipId===a.relationshipId;n.set(s),n.set({map:this.map,showAllEnabled:e})}else n.set(s);else this._assignExpressionExecutors(n,a,o);if(C(a)){const e=a.elements.filter((e=>O(e)));n.inputs=this._updateInputsUsingFormElementsRecursive({existingInputsByElement:t,updatedElements:e,sharedInitializationProperties:s,group:n,newExpressionExecutorPromises:o})}}}return r}_updateInputsUsingLayerFields(e,t,n){if(!Array.isArray(t))return i.getLogger(this).warn(this.declaredClass,"No attribute fields found."),[];const s=new Map;for(const i of e)if(v(i)){for(const e of i.inputs)e.destroy();i.inputs.length=0,i.destroy()}else F(i)?i.destroy():x(i)&&(null!==i.element?i.destroy():s.set(i.field,i));const o=[],{arcadeEditType:r,feature:a,initialFeature:l,layer:u}=n;for(const i of t){const e=s.get(i)??new V({arcadeEditType:r,field:i,feature:a,initialFeature:l,layer:u,value:a?.getAttribute(i.name)??null});o.push(e),s.delete(i)}for(const[i,p]of s.entries())s.delete(i),p.destroy();return o}_resetFieldInputValues(e){for(const t of this.allFieldInputs)t.value=e.getAttribute(t.name)}_makeFieldInputFromElement(e,t,n){const{arcadeEditType:s,feature:i,initialFeature:o,layer:r}=t,{fieldName:a}=e,l=a&&this._layerFieldsByName.get(a);return l?new V({arcadeEditType:s,element:e,field:l,value:i?.getAttribute(e.fieldName)??null,feature:i,initialFeature:o,layer:r,group:n}):null}_makeGroupInputFromElement(e,t){const{feature:n,layer:s}=t;return new A({element:e,inputs:[],feature:n,layer:s})}_makeRelationshipInputFromElement(e,t,n=null){const{map:s}=this,{feature:i,layer:o}=t;return new T({element:e,feature:i,group:n,layer:o,map:s})}_assignExpressionExecutors(e,t,n){const s=C(t)?L:E(t)?N:R,i=[];for(const o of s){const s=t[o],{_expressionExecutorLookup:i}=this;if(null!=s&&""!==s){const t=`${o}Executor`,r=this._expressionInfosLookup.get(s)?.expression??s;if(i.has(r))e[t]=i.get(r);else if(n.has(r)){const s=n.get(r).then((n=>(e[t]=n,n)));n.set(r,s)}else{const s=w(r,this.layer).then((n=>(e[t]=n,i.set(r,n),n)));n.set(r,s)}}}return i}_createExpressionsManager(e,t){const{_arcadeContextInfo:n,_featureClone:s}=this;this._expressionsManager=new j({executors:e,feature:s,arcadeContextInfo:n,fieldInputs:t})}_afterValueChange(e){const{name:t,value:n}=e,{_featureClone:s,formTemplate:i,layer:o}=this;if(!o)return;const r=s.getAttribute(t);s.setAttribute(t,n);const{typeFieldName:a,types:u}=b(o);if(t===a&&n!==r){if("subtype-sublayer"===o.type){const e=o.parent?.findSublayerForFeature(s);s.sourceLayer=this.feature.sourceLayer=e}const e=new Set;for(const t of u)if(t.domains&&"object"==typeof t.domains)for(const n of Object.keys(t.domains))e.add(n);for(const t of e){const e=this.findField(t);e&&e.notifyChange("domain")}}if(null!=i){const{description:e,title:n}=i;n&&l(n,t)&&this.notifyChange("formTitle"),e&&l(e,t)&&this.notifyChange("formDescription")}this._emitChangeEvent(e)}_afterExpressionsEvaluated(){const{_featureClone:e}=this;for(const t of this.allFieldInputs)t.value!==e.getAttribute(t.name)&&this._afterValueChange(t)}_joinContingentValues(){const e=this._contingentValuesCache;if(null==e)return[];const{typeFieldName:t}=b(this.layer),n=t?this.getValue(t):null,s=[];for(const r of e.fieldGroups){const{contingencies:e,fields:t,name:i}=r,o=[];for(const s of e)s.isRetired||null!=s.subtype&&s.subtype.code!==n||o.push({values:s.values});o.length>0&&s.push({name:i,fields:t,contingencies:o})}const[i,o]=this._generateJoinPlan(s);return[...i.flatMap((e=>this._joinFieldGroupContingencies(e))),...o.flatMap((e=>e.contingencies))]}_generateJoinPlan(e){const t=new Map,n=[],s=new Set;for(const l of e)for(const e of l.fields)if(t.has(e)){const i=t.get(e),o=l,r=[i.name,o.name].sort().join("|");if(s.has(r))continue;n.push([i,o]),s.add(r),t.set(e,o)}else t.set(e,l);const i=new Set(n.flat()),o=new Set(e);for(const l of i)o.delete(l);const r=new Map,a=new Map;for(const l of new Set(n.flat())){const e=Symbol(l.name);r.set(e,new Set([l])),a.set(l,e)}for(const[l,u]of n){const e=a.get(l),t=a.get(u);if(e===t)continue;const n=r.get(e),s=r.get(t);for(const i of s)n.add(i),a.set(i,e);r.delete(t)}return[[...r.values()].map((e=>[...e])),[...o]]}_joinFieldGroupContingencies(e){const t=e.slice(),n=t.shift();let s=t.shift(),i=this._generateJoinKey(n.fields,s.fields),o=new Set([...n.fields,...s.fields]),r=new Map;for(const l of n.contingencies){const[e]=this._hashContingency(l,i.codedValueFields,!0);r.has(e)?r.get(e)?.push(l):r.set(e,[l])}for(;t.length>0;){const e=new Map,n=t.shift(),a=this._generateJoinKey(o,n.fields);for(const t of s.contingencies){const[n,s]=this._hashContingency(t,i.codedValueFields),o=s?this._findMatchingContingenciesWithAnyHashMask(r,n):r.get(n);if(r.has(k)&&o?.push(...this._findMatchingContingenciesContainingAny(t,r.get(k),i.codedValueFields)),null!=o)for(const r of o){const n=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(r,t,i.rangeFields):this._joinContingencies(r,t);if(null==n)break;const[s]=this._hashContingency(n,a.codedValueFields,!0);e.has(s)?e.get(s)?.push(n):e.set(s,[n])}}r=e,s=n,i=a,o=new Set([...o,...s.fields])}const a=[];for(const l of s.contingencies){const[e,t]=this._hashContingency(l,i.codedValueFields),n=t?this._findMatchingContingenciesWithAnyHashMask(r,e):r.get(e);if(r.has(k)&&n.push(...this._findMatchingContingenciesContainingAny(l,r.get(k),i.codedValueFields)),null!=n)for(const s of n){const e=i.rangeFields.length>0?this._joinContingenciesWithRangeDomains(s,l,i.rangeFields):this._joinContingencies(s,l);null!=e&&a.push(e)}}return a}_joinContingencies(e,t){const n={values:{...e.values,...t.values}};for(const[s,i]of Object.entries(n.values))"any"===i.objectType&&null!=e.values[s]&&(n.values[s]=e.values[s]);return n}_joinContingenciesWithRangeDomains(e,t,n){const s=this._joinContingencies(e,t);for(const i of n){const n=e.values[i],o=t.values[i],{leftIsNull:r,rightIsNull:a,bothAreNull:l,leftIsAny:u,rightIsAny:p,bothAreAny:c,leftIsRange:d,rightIsRange:f}=this._compareObjectTypes(n.objectType,o.objectType);if(l||c)continue;if(r&&p||a&&u){s.values[i]=new h({objectType:"null"});continue}if(r&&f||a&&d)return null;u?(n.minValue=-1/0,n.maxValue=1/0):p&&(o.minValue=-1/0,o.maxValue=1/0);const m=Math.max(n.minValue,o.minValue),g=Math.min(n.maxValue,o.maxValue);if(m>g)return null;s.values[i]=new h({objectType:"range",minValue:m,maxValue:g})}return s}_findMatchingContingenciesContainingAny(e,t,n){return t.filter((t=>n.every((n=>{const s=t.values[n],i=e.values[n];return"any"===s.objectType||"any"===i.objectType||s.codedValue?.code===i.codedValue?.code}))))}_findMatchingContingenciesWithAnyHashMask(e,t){const n=RegExp(`${t}$`),s=[];for(const[i,o]of e){if(i===k)break;n.test(i)&&s.push(...o)}return s}_generateJoinKey(e,t){const n=Array.isArray(e)?new Set(e):e,s=Array.isArray(t)?new Set(t):t,i=n.size<s.size?n:s,o=i===n?s:n,r=new Set,a=new Set;for(const l of i)if(o.has(l)){const e=this.layer?.getFieldDomain(l,{feature:this.feature});if(null==e)continue;switch(e.type){case"coded-value":r.add(l);break;case"range":a.add(l)}}return{codedValueFields:[...r],rangeFields:[...a]}}_hashContingency(e,t,n=!1){if(t.length<1)return[S,!1];const s=[];let i=!1;for(const o of t){const t=e.values[o];if("any"===t.objectType){if(n)return[k,!0];i=!0,s.push(`${o}:.*`)}else"null"===t.objectType?s.push(`${o}:${H}`):s.push(`${o}:${t.codedValue?.code}`)}return[s.sort().join("&"),i]}_compareObjectTypes(e,t){return{leftIsNull:"null"===e,rightIsNull:"null"===t,bothAreNull:"null"===e&&"null"===t,leftIsAny:"any"===e,rightIsAny:"any"===t,bothAreAny:"any"===e&&"any"===t,leftIsRange:"range"===e,rightIsRange:"range"===t}}};function O(e){return"field"===e.type||"group"===e.type||"relationship"===e.type||(i.getLogger(P).warn("form-info::unsupported-element-type","Only element types 'field', 'group' and 'relationship' are supported",`Element ${e.label} has unsupported type '${e.type}'`),!1)}e([u()],G.prototype,"_expressionInfosLookup",null),e([u()],G.prototype,"_featureClone",void 0),e([u()],G.prototype,"activeRelationshipInput",null),e([u()],G.prototype,"_arcadeContextInfo",null),e([u({readOnly:!0})],G.prototype,"allFieldInputs",null),e([u()],G.prototype,"allRelationshipInputs",null),e([u()],G.prototype,"_layerFieldsByName",null),e([u()],G.prototype,"arcadeEditType",void 0),e([u()],G.prototype,"contingencyConstraintViolations",void 0),e([u()],G.prototype,"disabled",void 0),e([u()],G.prototype,"feature",null),e([u()],G.prototype,"fieldsWithContingentValues",null),e([u({type:d})],G.prototype,"formTemplate",null),e([u()],G.prototype,"formDescription",null),e([u()],G.prototype,"formTitle",null),e([u()],G.prototype,"formHeaderVisible",null),e([u()],G.prototype,"inputs",void 0),e([u()],G.prototype,"inputFields",null),e([u()],G.prototype,"joinedContingentValues",null),e([u()],G.prototype,"layer",null),e([u()],G.prototype,"map",void 0),e([u()],G.prototype,"relatedRecordCallbacks",void 0),e([u()],G.prototype,"relationshipId",null),e([u()],G.prototype,"spatialReference",null),e([u()],G.prototype,"state",null),e([u()],G.prototype,"strict",void 0),e([u()],G.prototype,"submittable",null),e([u()],G.prototype,"updating",null),e([u()],G.prototype,"valid",null),e([u()],G.prototype,"view",null),e([u()],G.prototype,"getValues",null),e([u()],G.prototype,"submit",null),G=e([p(P)],G);const $=G;export{$ as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{CodedValue as l}from"../../layers/support/CodedValue.js";import r from"../../layers/support/CodedValueDomain.js";import"../../layers/support/Domain.js";import"../../layers/support/InheritedDomain.js";import"../../layers/support/RangeDomain.js";import{getDomainRange as n,validateDomainValue as s}from"../../layers/support/domainUtils.js";import{isFieldVisibleByDefault as o,getLowerCaseEditTrackingFields as a,isNumericField as u,isStringField as p,isDateField as d,getFieldRange as m,TypeValidationError as y,validateFieldValue as h}from"../../layers/support/fieldUtils.js";import{isRelatableFeatureSupportedLayer as c}from"../Feature/support/featureUtils.js";import f from"./EditableInput.js";import{getNormalizedFeatureTypeInfo as g,isFieldElementWithTextInput as E,LengthValidationError as v}from"./featureFormUtils.js";var x;!function(e){e.Text="text",e.Number="number",e.Date="date",e.Unsupported="unsupported"}(x||(x={}));const b="__internal-type-based-coded-value-domain__";let _=class extends f{constructor(e){super(e),this._storedValue=null,this.error=null,this.field=null,this.group=null,this.requiredExpressionExecutor=null,this.type="field",this.valueExpressionExecutor=null}get _dateRange(){const{element:e}=this;if("datetime-picker"===e?.input?.type){const{max:t,min:i}=e.input;return{max:t,min:i}}return{min:null,max:null}}get _configAllowsEdits(){const{element:e,layer:t,name:i}=this;if(null!=e)return e.editableExpression?!!this.evaluatedEditableExpression:!1!==e.editable;if(t?.userHasUpdateItemPrivileges)return!0;const l=t&&"popupTemplate"in t?t?.popupTemplate?.fieldInfos?.find((({fieldName:e})=>e===i)):null;return l?.isEditable??!0}get _layerAndFieldAllowEdits(){return this.layerAllowsEdits&&this.field?.editable}get _isVisibleByDefault(){const{field:e,layer:t}=this;return!!e?.visible&&o(e,t)}get _isEditTrackingField(){return a(this.layer).includes(this.name?.toLowerCase())}get _shouldUseValueExpression(){return this._layerAndFieldAllowEdits&&!this._configAllowsEdits&&null!=this.valueExpressionExecutor}get dataType(){const{field:e}=this;return u(e)?x.Number:p(e)?x.Text:d(e)?x.Date:x.Unsupported}get dateDataType(){if(this.dataType===x.Date)return"date"!==this.field.type?"string":"number"}get domain(){const{layer:e}=this,{typeFieldName:t,types:i}=g(e);if(t===this.name&&null==this.field.domain)return new r({name:b,codedValues:i.map((({code:e,name:t})=>new l({code:e,name:t})))});const{feature:n}=this,s=e?.getFieldDomain(this.name,{feature:n}),o=this.element?.domain;return null!=o&&this._isDomainCompatible(o)?o:s}get editable(){return!!this._layerAndFieldAllowEdits&&(this.evaluatedEditableExpression??this._configAllowsEdits)}get evaluatedRequiredExpression(){const{requiredExpressionExecutor:e}=this;return null!=e?!!e.lastEvaluatedValue:null}get evaluatedValueExpression(){const{valueExpressionExecutor:e}=this;return null!=e?e.lastEvaluatedValue:null}get hint(){return this.element?.hint}get includeDate(){return!(this.dataType!==x.Date||"time-only"===this.field.type)}get includeTime(){const{element:e,field:t}=this;if(this.dataType!==x.Date)return!1;if("time-only"===t.type)return!0;if("date-only"===t.type)return!1;const i="datetime-picker"===e?.input?.type?e.input.includeTime:void 0;return void 0===i||i}get includeTimestamp(){return"timestamp-offset"===this.field.type}set initialFeature(e){this._set("initialFeature",e),this.notifyChange("valid")}get inputType(){return this.element?.input?.type}get isRelationshipKeyField(){const{field:e,layer:t}=this;return c(t)&&!!t.relationships?.some((t=>t.keyField===e.name))}get label(){return this.element?.label||this.field.alias||this.field.name}get maxLength(){const e=-1;if(this.dataType===x.Date)return e;const{field:t,element:i}=this,l=t?.length,r=E(i)?i.input.maxLength:NaN;return null!=r&&!isNaN(r)&&r>=e&&(l===e||r<=l)?r:l}get minLength(){const e=-1;if(this.dataType===x.Date)return e;const{field:t,element:i}=this,l=t?.length,r=E(i)?i.input.minLength:NaN;return null!=r&&!isNaN(r)&&r>=e&&(l===e||r<=l)?r:e}get name(){return this.field?.name}get range(){const{_dateRange:e,domain:t,field:i}=this,{max:l,min:r}=e,s=null!=l&&T(l)?l.getTime():null,o=null!=r&&T(r)?r.getTime():null,a=n(t)||m(i);if(!a)return{max:s,min:o};const u=a.max===Number.MAX_VALUE?null:a.max,p=a.min===Number.MIN_VALUE?null:a.min;return{max:null!=s&&(null===u||null!=u&&s<u)?s:u,min:null!=o&&(null===p||null!=p&&o>p)?o:p}}get required(){const{editable:e,evaluatedRequiredExpression:t,field:i,visible:l}=this;return!!e&&(!1===i?.nullable||!(!l||null==t)&&t)}set required(e){this._overrideIfSome("required",e)}get submittable(){const{field:e,required:t,valid:i,value:l}=this;return(!t||null!=l)&&(!!i||this.initialFeature.getAttribute(e.name)===l)}get updating(){const{editableExpressionExecutor:e,valueExpressionExecutor:t}=this;return null!=t&&t.updating||null!=e&&e.updating}get valid(){const e=this.editable?this._validate():null;return this._set("error",e),null===e}get value(){if(this._shouldUseValueExpression){const e=this.evaluatedValueExpression;if(this.dataType===x.Date){if(e instanceof Date)return e.getTime();if("number"!=typeof e)return parseInt(e,10)}return null!=e&&"object"==typeof e?e.toString():e}return this.get("_storedValue")}set value(e){this.notifyChange("evaluatedVisibilityExpression"),this.set("_storedValue",e)}get visible(){return!this._isEditTrackingField&&(null!=this.evaluatedVisibilityExpression?this.evaluatedVisibilityExpression:null!=this.element||this._isVisibleByDefault)}_isDomainCompatible(e){const{field:t}=this;if("coded-value"===e?.type){const i=typeof e.codedValues[0].code;if("string"===i&&p(t)||"number"===i&&u(t))return!0}return!!("range"===e?.type&&u(t)||d(t))}_validate(){const{dataType:e,domain:t,field:i,initialFeature:l,minLength:r,required:n,valid:o,value:a}=this,u=n&&null===a,p=void 0!==o;return!u&&l.getAttribute(i.name)===a&&p?null:u?y.INVALID_TYPE:"text"===e&&r>-1&&"string"==typeof a&&a.length<r?v.TOO_SHORT:t?null!==a||n?s(t,a):null:h(i,a)}};e([t()],_.prototype,"_storedValue",void 0),e([t()],_.prototype,"_configAllowsEdits",null),e([t()],_.prototype,"_layerAndFieldAllowEdits",null),e([t()],_.prototype,"_isVisibleByDefault",null),e([t()],_.prototype,"_isEditTrackingField",null),e([t()],_.prototype,"_shouldUseValueExpression",null),e([t()],_.prototype,"dataType",null),e([t()],_.prototype,"dateDataType",null),e([t()],_.prototype,"domain",null),e([t()],_.prototype,"editable",null),e([t({readOnly:!0})],_.prototype,"error",void 0),e([t()],_.prototype,"evaluatedRequiredExpression",null),e([t()],_.prototype,"evaluatedValueExpression",null),e([t()],_.prototype,"field",void 0),e([t()],_.prototype,"group",void 0),e([t({readOnly:!0})],_.prototype,"hint",null),e([t()],_.prototype,"includeDate",null),e([t()],_.prototype,"includeTime",null),e([t()],_.prototype,"includeTimestamp",null),e([t()],_.prototype,"initialFeature",null),e([t({readOnly:!0})],_.prototype,"inputType",null),e([t()],_.prototype,"label",null),e([t()],_.prototype,"maxLength",null),e([t()],_.prototype,"minLength",null),e([t({readOnly:!0})],_.prototype,"name",null),e([t()],_.prototype,"range",null),e([t()],_.prototype,"required",null),e([t()],_.prototype,"requiredExpressionExecutor",void 0),e([t()],_.prototype,"submittable",null),e([t({readOnly:!0})],_.prototype,"type",void 0),e([t()],_.prototype,"updating",null),e([t()],_.prototype,"valid",null),e([t({value:null})],_.prototype,"value",null),e([t()],_.prototype,"valueExpressionExecutor",void 0),e([t()],_.prototype,"visible",null),_=e([i("esri.widgets.FeatureForm.FieldInput")],_);const T=e=>e&&!Number.isNaN(e.valueOf()),V=_;export{V as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{CodedValue as l}from"../../layers/support/CodedValue.js";import r from"../../layers/support/CodedValueDomain.js";import"../../layers/support/Domain.js";import"../../layers/support/InheritedDomain.js";import"../../layers/support/RangeDomain.js";import{getDomainRange as n,validateDomainValue as s}from"../../layers/support/domainUtils.js";import{isFieldVisibleByDefault as o,getLowerCaseEditTrackingFields as a,isNumericField as u,isStringField as p,isDateField as d,getFieldRange as m,TypeValidationError as y,validateFieldValue as h}from"../../layers/support/fieldUtils.js";import{isRelatableFeatureSupportedLayer as c}from"../Feature/support/featureUtils.js";import f from"./EditableInput.js";import{getNormalizedFeatureTypeInfo as g,isFieldElementWithTextInput as E,LengthValidationError as v}from"./featureFormUtils.js";var x;!function(e){e.Text="text",e.Number="number",e.Date="date",e.Unsupported="unsupported"}(x||(x={}));const b="__internal-type-based-coded-value-domain__";let _=class extends f{constructor(e){super(e),this._storedValue=null,this.error=null,this.field=null,this.group=null,this.requiredExpressionExecutor=null,this.type="field",this.valueExpressionExecutor=null}get _dateRange(){const{element:e}=this;if("datetime-picker"===e?.input?.type){const{max:t,min:i}=e.input;return{max:t,min:i}}return{min:null,max:null}}get _configAllowsEdits(){const{element:e,layer:t,name:i}=this;if(null!=e)return e.editableExpression?!!this.evaluatedEditableExpression:!1!==e.editable;if(t?.userHasUpdateItemPrivileges)return!0;const l=t&&"popupTemplate"in t?t?.popupTemplate?.fieldInfos?.find((({fieldName:e})=>e===i)):null;return l?.isEditable??!0}get _layerAndFieldAllowEdits(){return this.layerAllowsEdits&&this.field?.editable}get _isVisibleByDefault(){const{field:e,layer:t}=this;return!!e?.visible&&o(e,t)}get _isEditTrackingField(){return a(this.layer).includes(this.name?.toLowerCase())}get _shouldUseValueExpression(){return this._layerAndFieldAllowEdits&&!this._configAllowsEdits&&null!=this.valueExpressionExecutor}get dataType(){const{field:e}=this;return u(e)?x.Number:p(e)?x.Text:d(e)?x.Date:x.Unsupported}get dateDataType(){if(this.dataType===x.Date)return"date"!==this.field.type?"string":"number"}get domain(){const{layer:e}=this,{typeFieldName:t,types:i}=g(e);if(t===this.name&&null==this.field.domain)return new r({name:b,codedValues:i.map((({code:e,name:t})=>new l({code:e,name:t})))});const{feature:n}=this,s=e?.getFieldDomain(this.name,{feature:n}),o=this.element?.domain;return null!=o&&this._isDomainCompatible(o)?o:s}get editable(){return!!this._layerAndFieldAllowEdits&&(this.evaluatedEditableExpression??this._configAllowsEdits)}get evaluatedRequiredExpression(){const{requiredExpressionExecutor:e}=this;return null!=e?!!e.lastEvaluatedValue:null}get evaluatedValueExpression(){const{valueExpressionExecutor:e}=this;return null!=e?e.lastEvaluatedValue:null}get hint(){return this.element?.hint}get includeDate(){return!(this.dataType!==x.Date||"time-only"===this.field.type)}get includeTime(){const{element:e,field:t}=this;if(this.dataType!==x.Date)return!1;if("time-only"===t.type)return!0;if("date-only"===t.type)return!1;const i="datetime-picker"===e?.input?.type?e.input.includeTime:void 0;return void 0===i||i}get includeTimestamp(){return"timestamp-offset"===this.field.type}set initialFeature(e){this._set("initialFeature",e),this.notifyChange("valid")}get inputType(){return this.element?.input?.type}get isRelationshipKeyField(){const{field:e,layer:t}=this;return c(t)&&!!t.relationships?.some((t=>t.keyField===e.name))}get label(){return this.element?.label||this.field.alias||this.field.name}get maxLength(){const e=-1;if(this.dataType===x.Date)return e;const{field:t,element:i}=this,l=t?.length,r=E(i)?i.input.maxLength:NaN;return null!=r&&!isNaN(r)&&r>=e&&(l===e||r<=l)?r:l}get minLength(){const e=-1;if(this.dataType===x.Date)return e;const{field:t,element:i}=this,l=t?.length,r=E(i)?i.input.minLength:NaN;return null!=r&&!isNaN(r)&&r>=e&&(l===e||r<=l)?r:e}get name(){return this.field?.name}get range(){const{_dateRange:e,domain:t,field:i}=this,{max:l,min:r}=e,s=null!=l&&T(l)?l.getTime():null,o=null!=r&&T(r)?r.getTime():null,a=n(t)||m(i);if(!a)return{max:s,min:o};const u=a.max===Number.MAX_VALUE?null:a.max,p=a.min===Number.MIN_VALUE?null:a.min;return{max:null!=s&&(null===u||null!=u&&s<u)?s:u,min:null!=o&&(null===p||null!=p&&o>p)?o:p}}get required(){const{editable:e,evaluatedRequiredExpression:t,field:i,visible:l}=this;return!!e&&(!1===i?.nullable||!(!l||null==t)&&t)}set required(e){this._overrideIfSome("required",e)}get submittable(){const{field:e,required:t,valid:i,value:l}=this;return(!t||null!=l)&&(!!i||this.initialFeature.getAttribute(e.name)===l)}get updating(){const{editableExpressionExecutor:e,valueExpressionExecutor:t}=this;return null!=t&&t.updating||null!=e&&e.updating}get valid(){const e=this.editable?this._validate():null;return this._set("error",e),null===e}get value(){if(this._shouldUseValueExpression){const e=this.evaluatedValueExpression;if(this.dataType===x.Date){if(e instanceof Date)return e.getTime();if("number"!=typeof e)return parseInt(e,10)}return null!=e&&"object"==typeof e?e.toString():e}return this.get("_storedValue")}set value(e){this.notifyChange("evaluatedVisibilityExpression"),this.set("_storedValue",e)}get visible(){return!this._isEditTrackingField&&(null!=this.evaluatedVisibilityExpression?this.evaluatedVisibilityExpression:null!=this.element||this._isVisibleByDefault)}_isDomainCompatible(e){const{field:t}=this;if("coded-value"===e?.type){const i=typeof e.codedValues[0].code;if("string"===i&&p(t)||"number"===i&&u(t))return!0}return!!("range"===e?.type&&u(t)||d(t))}_validate(){const{dataType:e,domain:t,field:i,initialFeature:l,minLength:r,required:n,valid:o,value:a}=this,u=n&&null==a,p=void 0!==o;return!u&&l.getAttribute(i.name)===a&&p?null:u?y.INVALID_TYPE:"text"===e&&r>-1&&"string"==typeof a&&a.length<r?v.TOO_SHORT:t?null!==a||n?s(t,a):null:h(i,a)}};e([t()],_.prototype,"_storedValue",void 0),e([t()],_.prototype,"_configAllowsEdits",null),e([t()],_.prototype,"_layerAndFieldAllowEdits",null),e([t()],_.prototype,"_isVisibleByDefault",null),e([t()],_.prototype,"_isEditTrackingField",null),e([t()],_.prototype,"_shouldUseValueExpression",null),e([t()],_.prototype,"dataType",null),e([t()],_.prototype,"dateDataType",null),e([t()],_.prototype,"domain",null),e([t()],_.prototype,"editable",null),e([t({readOnly:!0})],_.prototype,"error",void 0),e([t()],_.prototype,"evaluatedRequiredExpression",null),e([t()],_.prototype,"evaluatedValueExpression",null),e([t()],_.prototype,"field",void 0),e([t()],_.prototype,"group",void 0),e([t({readOnly:!0})],_.prototype,"hint",null),e([t()],_.prototype,"includeDate",null),e([t()],_.prototype,"includeTime",null),e([t()],_.prototype,"includeTimestamp",null),e([t()],_.prototype,"initialFeature",null),e([t({readOnly:!0})],_.prototype,"inputType",null),e([t()],_.prototype,"label",null),e([t()],_.prototype,"maxLength",null),e([t()],_.prototype,"minLength",null),e([t({readOnly:!0})],_.prototype,"name",null),e([t()],_.prototype,"range",null),e([t()],_.prototype,"required",null),e([t()],_.prototype,"requiredExpressionExecutor",void 0),e([t()],_.prototype,"submittable",null),e([t({readOnly:!0})],_.prototype,"type",void 0),e([t()],_.prototype,"updating",null),e([t()],_.prototype,"valid",null),e([t({value:null})],_.prototype,"value",null),e([t()],_.prototype,"valueExpressionExecutor",void 0),e([t()],_.prototype,"visible",null),_=e([i("esri.widgets.FeatureForm.FieldInput")],_);const T=e=>e&&!Number.isNaN(e.valueOf()),V=_;export{V as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import{createArcadeProfile as e,createArcadeExecutor as r}from"../../arcade.js";import s from"../../core/Accessor.js";import{debounce as o}from"../../core/promiseUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{WatchUpdatingTracking as i}from"../../core/support/WatchUpdatingTracking.js";import{fixFields as n}from"../../layers/support/fieldUtils.js";var u;const c=Symbol("FormExpressionArcadeExecutor");let p=class extends s{constructor(t){super(t),this[u]=!0,this._lastEvaluatedValue=null,this._abortController=new AbortController,this._stale=!1,this._updatingTracking=new i,this._executeAsyncDebounced=o((async(t,e,r)=>{const s=await this.executor.executeAsync(t,{...e,abortSignal:r});return r.aborted?this._lastEvaluatedValue:(this._lastEvaluatedValue=s,this._stale=!1,s)}))}get isAsync(){return this.executor.isAsync}get fieldsUsed(){return this.executor.fieldsUsed}get syntaxTree(){return this.executor.syntaxTree}get updating(){return this._updatingTracking.updating}get stale(){return this._stale}get geometryUsed(){return this.executor.geometryUsed}get variablesUsed(){return this.executor.variablesUsed}get lastEvaluatedValue(){return this._lastEvaluatedValue}abort(){this._abortController.abort()}execute(t,e){this._abortController=new AbortController;const r=this.executor.execute(t,{...e,abortSignal:this._abortController.signal});return this._lastEvaluatedValue=r,r}async executeAsync(t,e){return this._abortController=new AbortController,this._updatingTracking.addPromise(this._executeAsyncDebounced(t,e??{},this._abortController.signal))}markStale(){this._stale=!0}reset(){this.abort(),this._lastEvaluatedValue=null,this._stale=!1}};u=c,t([a()],p.prototype,"_lastEvaluatedValue",void 0),t([a()],p.prototype,"_stale",void 0),t([a()],p.prototype,"_updatingTracking",void 0),t([a({constructOnly:!0})],p.prototype,"executor",void 0),t([a()],p.prototype,"isAsync",null),t([a()],p.prototype,"fieldsUsed",null),t([a()],p.prototype,"syntaxTree",null),t([a()],p.prototype,"updating",null),t([a()],p.prototype,"stale",null),t([a()],p.prototype,"geometryUsed",null),t([a()],p.prototype,"variablesUsed",null),t([a()],p.prototype,"lastEvaluatedValue",null),p=t([l("esri.widgets.FeatureForm.FormExpressionArcadeExecutor")],p);const d=async(t,s)=>{const o=e("form-calculation"),a=await r(t,o,{});return s?.fieldsIndex&&(a.fieldsUsed=n(s.fieldsIndex,a.fieldsUsed)),new p({executor:a})};export{p as FormExpressionArcadeExecutor,d as createFormExpressionArcadeExecutor};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import{createArcadeProfile as e,createArcadeExecutor as r}from"../../arcade.js";import s from"../../core/Accessor.js";import{debounce as o}from"../../core/promiseUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as i}from"../../core/support/UpdatingHandles.js";import{fixFields as n}from"../../layers/support/fieldUtils.js";var u;const c=Symbol("FormExpressionArcadeExecutor");let p=class extends s{constructor(t){super(t),this[u]=!0,this._lastEvaluatedValue=null,this._abortController=new AbortController,this._stale=!1,this._updatingTracking=new i,this._executeAsyncDebounced=o((async(t,e,r)=>{const s=await this.executor.executeAsync(t,{...e,abortSignal:r});return r.aborted?this._lastEvaluatedValue:(this._lastEvaluatedValue=s,this._stale=!1,s)}))}get isAsync(){return this.executor.isAsync}get fieldsUsed(){return this.executor.fieldsUsed}get syntaxTree(){return this.executor.syntaxTree}get updating(){return this._updatingTracking.updating}get stale(){return this._stale}get geometryUsed(){return this.executor.geometryUsed}get variablesUsed(){return this.executor.variablesUsed}get lastEvaluatedValue(){return this._lastEvaluatedValue}abort(){this._abortController.abort()}execute(t,e){this._abortController=new AbortController;const r=this.executor.execute(t,{...e,abortSignal:this._abortController.signal});return this._lastEvaluatedValue=r,r}async executeAsync(t,e){return this._abortController=new AbortController,this._updatingTracking.addPromise(this._executeAsyncDebounced(t,e??{},this._abortController.signal))}markStale(){this._stale=!0}reset(){this.abort(),this._lastEvaluatedValue=null,this._stale=!1}};u=c,t([a()],p.prototype,"_lastEvaluatedValue",void 0),t([a()],p.prototype,"_stale",void 0),t([a()],p.prototype,"_updatingTracking",void 0),t([a({constructOnly:!0})],p.prototype,"executor",void 0),t([a()],p.prototype,"isAsync",null),t([a()],p.prototype,"fieldsUsed",null),t([a()],p.prototype,"syntaxTree",null),t([a()],p.prototype,"updating",null),t([a()],p.prototype,"stale",null),t([a()],p.prototype,"geometryUsed",null),t([a()],p.prototype,"variablesUsed",null),t([a()],p.prototype,"lastEvaluatedValue",null),p=t([l("esri.widgets.FeatureForm.FormExpressionArcadeExecutor")],p);const d=async(t,s)=>{const o=e("form-calculation"),a=await r(t,o,{});return s?.fieldsIndex&&(a.fieldsUsed=n(s.fieldsIndex,a.fieldsUsed)),new p({executor:a})};export{p as FormExpressionArcadeExecutor,d as createFormExpressionArcadeExecutor};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import{isSome as r}from"../../core/arrayUtils.js";import i from"../../core/Collection.js";import o from"../../core/Evented.js";import s from"../../core/Logger.js";import{clamp as a}from"../../core/mathUtils.js";import{destroyMaybe as n}from"../../core/maybe.js";import{once as l,on as g,watch as h,initial as c}from"../../core/reactiveUtils.js";import{createScreenPoint as u}from"../../core/screenUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import{ensureType as d}from"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import y from"../../geometry/Extent.js";import _ from"../../layers/GraphicsLayer.js";import v from"../../layers/ImageryTileLayer.js";import{searchImages as f}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as C}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as P,computePolygonForInspection as w,resizePolygon as I,checkIfPolygonContainsSelectedPoint as b}from"../../layers/orientedImagery/core/coverageUtils.js";import{updateElevation as F,transformPoints as S}from"../../layers/orientedImagery/transformations/groundToImageUtils.js";import{transformPoints as V}from"../../layers/orientedImagery/transformations/imageToGroundUtils.js";import x from"../../views/MapView.js";import{getResolutionToScaleFactor as O}from"../../views/2d/viewpointUtils.js";import{projectWithEngineOrService as M}from"../../views/support/projectionUtils.js";import{activePolygonSymbol as G,polygonSymbol as j,activeSourcePointSymbol as R,sourcePointSymbol as L,crossSymbol as A,diamondSymbol as E}from"./symbols.js";import D from"../../geometry/Polygon.js";import U from"../../geometry/SpatialReference.js";import T from"../../geometry/Point.js";const N={click:"view-click",view:"view",viewLayers:"view-layers",mapLayers:"map-layers",layerViews:"layer-views",layerListMode:"layer-list-mode",children:"children",registerLayerSelection:"register-layer-selection",plotPointOnGround:"plot-point-on-ground"};function J(e){return"3d"===e?.type}function k(e){return"esri.Graphic"===e?.declaredClass}function H(e){return/.*.(tif|mrf)$/i.test(e??"")}let z=class extends o.EventedAccessor{constructor(e){super(e),this.activeLayer=null,this.shouldShowSelectedImage=!1,this.coverageFrustums=null,this.coveragePolygons=null,this.displayMessage=null,this.pointSources=null,this.selectedFeature=null,this.selectedPoint=null,this.features=null,this.mapImageConversionToolState=!1,this._additionalCoveragePolygons=null,this._additionalFeatureGraphics=null,this._currentCoveragePolygon=null,this._currentImage=null,this._fetchFeaturesController=null,this._imageViewer=null,this._initialCurrentCoveragePolygon=null,this._initialCurrentCoverageUpdate=!0,this._overlays=null,this._referencePointOnGround=null,this._referencePointOnImage=null,this._crossSymbol=null,this._panConstraint=null,this._scaleConstraint=null,this._transformController=new AbortController,this._updateCoverageController=null,this.loadViewer=this.loadViewer.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this)}initialize(){l((()=>this.view?.ready)).then((()=>{this._overlays=new _({listMode:"hide"}),this.view.map.layers.add(this._overlays)})),this.addHandles(g((()=>this.view),"click",(e=>{this.view.ready&&this.active&&(e.stopPropagation(),e.preventDefault(),"mouse"===e.pointerType&&0!==e.button||(this.mapImageConversionToolState?(this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.selectedFeature,selectedLocation:e.mapPoint,options:{signal:this._transformController?.signal}})):(this.displayMessage=null,this.selectedPoint=e.mapPoint,this.features=null,this.selectedFeature=null,this._overlays?.removeAll(),this._overlays?.add(new t({geometry:e.mapPoint.clone(),symbol:A})),this._fetchFeaturesWithController(e))))})),N.view)}destroy(){this._cancelCurrentCoverageUpdate(),this._cancelFetchingFeatures(),this.coverageFrustums=null,this.coveragePolygons=null,this.pointSources=null,this._additionalCoveragePolygons=null,this._additionalFeatureGraphics=null,this._currentImage=n(this._currentImage),this._imageViewer=n(this._imageViewer),this._initialCurrentCoveragePolygon=n(this._initialCurrentCoveragePolygon),this._currentCoveragePolygon=n(this._currentCoveragePolygon),this._crossSymbol=n(this._crossSymbol),this._referencePointOnGround=n(this._referencePointOnGround),this._referencePointOnImage=n(this._referencePointOnImage),this._overlays&&this.view?.map.remove(this._overlays),this._overlays=n(this._overlays)}get active(){return!0===this.view?.map?.allLayers.some((e=>"oriented-imagery"===e.type&&e.loaded))}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",a(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",a(e,-10,10))}get currentImageView(){return this._imageViewer?.allLayerViews.find((e=>e.layer===this._currentImage))}get featureCount(){return this.features?.length??0}get imageLoaded(){return this._currentImage?.loaded??!1}get isAdditionalCoverageDisabled(){return!this._additionalCoveragePolygons?.length}get isAdditionalCoverageVisible(){return this._additionalCoveragePolygons?.getItemAt(0)?.visible??!1}get isAdditionalPointSourcesDisabled(){return!this._additionalFeatureGraphics?.length}get isAdditionalPointSourcesVisible(){return this._additionalFeatureGraphics?.getItemAt(0)?.visible??!1}get isCurrentCoverageDisabled(){return!this._currentCoveragePolygon}get isCurrentCoverageVisible(){return!!this._currentCoveragePolygon?.visible}get isImageGalleryEnabled(){return!(this.featureCount<2)&&H(this.selectedFeature?.attributes.image?.trim())}get updating(){return(this.currentImageView?.updating??!1)||"loading"===this._currentImage?.loadStatus||!!this._fetchFeaturesController}get state(){const{active:e,activeLayer:t}=this;return e||t?this._currentImage?.loadStatus?`image-${this._currentImage.loadStatus}`:"ready":"disabled"}get thumbnails(){const{features:e}=this;return e?new i(e.map((({attributes:{image:e,objectId:t}})=>{const r=e?.trim();return H(r)?{url:r,objectId:t}:null})).filter(r)):null}set view(e){this._set("view",e)}getCurrentCoveragePolygon(){return this._currentCoveragePolygon}getSelectedFeature(){return this.selectedFeature}getSelectedFeaturePolygon(){return this._initialCurrentCoveragePolygon}loadViewer(e){const t=new Map,r={wkid:0};this._imageViewer=new x({container:e,map:t,spatialReferance:r,constraints:{snapToZoom:!1,rotationEnabled:!1},ui:{components:["zoom"]}}),l((()=>!0===this._imageViewer?.stationary)).then((()=>{this.setMessage("onLoadMessage","info")})),this._imageViewer.addHandles([this._imageViewer.on("click",(async e=>{if(0===e.button&&this._currentImage&&this.mapImageConversionToolState&&this._currentImage&&this._currentImage.fullExtent){const{xmin:t,xmax:r,ymin:i,ymax:o}=this._currentImage.fullExtent,{x:s,y:a}=e.mapPoint;if(t>s||r<s||o<a||i>a)return;this.plotReferencePointOnImage(e.mapPoint);const n=this.getSelectedFeature();if(n){const t=(await V([e.mapPoint.toJSON()],{feature:n,currentCoveragePolygon:this.getSelectedFeaturePolygon(),imageProperties:this._currentImage.rasterInfo,options:{signal:this._transformController?.signal}}))[0];t&&this.plotReferencePointOnGround(t)}}})),h((()=>[this._imageViewer?.viewpoint,this._initialCurrentCoveragePolygon]),(()=>{this._imageViewer?.viewpoint&&this._initialCurrentCoveragePolygon&&(this._cancelCurrentCoverageUpdate(),this.updateCoverage())})),h((()=>this.selectedFeature),(async()=>{const{_fetchFeaturesController:e,selectedFeature:t,selectedPoint:r}=this;!t&&this._currentImage&&(this._imageViewer?.map.layers.remove(this._currentImage),this._currentImage=n(this._currentImage)),t&&r&&(await this.loadImage(t,{signal:e?.signal}),this.transformAndPlotSelectedLocation({signal:this._fetchFeaturesController?.signal}))}))])}async searchBestImage(e,t){try{const r=await f(e,t);r&&await this._processFeatureResponse(r,{signal:t?.signal})}catch(r){const e=s.getLogger(this);this.setMessage("imageLoadError","error"),e.error("error occured while finding best image",r)}}toggleAdditionalCameraLocations(){this._additionalFeatureGraphics?.forEach((e=>{e.visible=!e.visible}))}toggleAdditionalCoverage(){this._additionalCoveragePolygons?.forEach((e=>{e.visible=!e.visible}))}toggleCurrentCoverage(){this._currentCoveragePolygon&&(this._currentCoveragePolygon.visible=!this._currentCoveragePolygon.visible,this._selectedFeatureGraphic.visible=!this._selectedFeatureGraphic)}toggleMapImageConversionToolState(){this.mapImageConversionToolState=!this.mapImageConversionToolState}_cancelFetchingFeatures(){const e=this._fetchFeaturesController;e&&e.abort(),this._fetchFeaturesController=null}_cancelCurrentCoverageUpdate(){const e=this._updateCoverageController;e&&e.abort("Multiple Coverage Updates: Aborting Current Coverage Update to sync image and coverage"),this._updateCoverageController=null}async _fetchFeatures(e,t){const{screenPoint:r}=e,i=this.activeLayer;if(i){const e={include:i},o=await this.view.hitTest(r,e);this._processHitTestResults(i,o,t)}}async _fetchFeaturesWithController(e){this._cancelFetchingFeatures();const t=new AbortController,{signal:r}=t;this._fetchFeaturesController=t;try{this._fetchFeatures(e,{signal:r})}catch(i){const e=s.getLogger(this);this.setMessage("imageLoadError","error"),e.error("error occured while fetching features",i)}this._fetchFeaturesController=null}async _processFeatureResponse(e,r){const{selectedPoint:o}=this;if(!o)return;if(!e)return;const s=e;if(this._fetchFeaturesController=null,!s)return;const{features:a}=s;if(!a.length)return this.setMessage("noImageError","error"),void(this.selectedFeature=null);const n=new Array;this.coveragePolygons=new i,this.coverageFrustums=new i,this.pointSources=new i,a.forEach((e=>{let t;const{polygon:r,frustum:i}=P(e);if(t=r,e.attributes.isInspection&&(t=w(e.attributes)),e.layer.coveragePercent&&(t=I(t,e.layer.coveragePercent)),b(t,o)){n.push(e);const r=t.toJSON(),o=i?.toJSON(),{attributes:s}=e,{cameraHeight:a,cameraHeading:l,location:g,objectId:h}=s,c="toJSON"in g?g.toJSON():g;r.imageID=c.imageID=h,o&&(o.imageID=h),c.z=a,this.pointSources?.push(c),this.coveragePolygons?.push(l>0?r:void 0),this.coverageFrustums?.push(l>0?o:void 0)}}));const l=this.coveragePolygons?.getItemAt(0);if(!n.length)return void this.setMessage("noImageError","error");if(n[0].attributes.elevationSource&&!o.z&&l){const e=await F([o],{feature:n[0],currentCoveragePolygon:new D(l),options:r});if(e[0]){const t=e[0];o.elevation=t.z}}const g=C({features:n,selectedPoint:o,camera:J(this.view)?this.view.camera:null,currentImage:this.selectedFeature});g?.sort(((e,t)=>e.suitability-t.suitability));const h=g?.map((e=>e.feature)),c=h[0];await this._updateFeatures(h),this._additionalCoveragePolygons=new i,this._additionalFeatureGraphics=new i,this._currentCoveragePolygon&&(this._currentCoveragePolygon.destroy(),this._currentCoveragePolygon=null,this._initialCurrentCoveragePolygon=null);for(const i of this.coveragePolygons)i?.imageID===c?.attributes.objectId?this._initialCurrentCoveragePolygon=new t({attributes:{imageID:i?.imageID},geometry:{type:"polygon",...i},symbol:G,visible:!1}):this._additionalCoveragePolygons.push(new t({attributes:{imageID:i?.imageID},geometry:{type:"polygon",...i},symbol:j,visible:!1}));for(const i of this.pointSources)i.imageID===c?.attributes.objectId?this._selectedFeatureGraphic=new t({attributes:{imageID:i.imageID},geometry:{type:"point",...i},symbol:R,visible:!1}):this._additionalFeatureGraphics?.push(new t({attributes:{imageID:i.imageID},geometry:{type:"point",...i},symbol:L,visible:!1}));this.selectedFeature=c,this._initialCurrentCoverageUpdate=!0}async _processHitTestResults(e,t,r){const{screenPoint:i,results:o}=t,s=this.view.toMap(i),a=o[0],n={layerInstanceOrURL:e,point:s,queryParams:{maximumDistance:e.maximumDistance,objectIds:this.shouldShowSelectedImage?[a.graphic.attributes.id]:void 0,outSpatialReference:s.spatialReference},queryFeatures:null};await this.searchBestImage(n,r)}async _updateFeatures(e){e.length&&(this.features=new i(e),this.notifyChange("features"))}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}updateCurrentCoveragePolygon(e){if(this._initialCurrentCoverageUpdate)if(this._initialCurrentCoverageUpdate=!1,e&&(this._currentCoveragePolygon&&(this._overlays?.remove(this._currentCoveragePolygon),this._currentCoveragePolygon.destroy()),e.visible=this.isCurrentCoverageVisible,this._currentCoveragePolygon=e),this.view)this._overlays?.graphics.addMany([...this._additionalCoveragePolygons??[],...this._additionalFeatureGraphics??[],this._currentCoveragePolygon,this._selectedFeatureGraphic].filter(k));else{const e={points:this.pointSources?.filter((e=>e?.imageID!==this.selectedFeature?.attributes.objectId)),frustums:this.coverageFrustums?.filter((e=>e?.imageID!==this.selectedFeature?.attributes.objectId)),polygons:this._additionalCoveragePolygons?.map((e=>e.geometry?.toJSON())),currentPoint:this.selectedFeature?.geometry,currentPolygon:this._currentCoveragePolygon,currentFrustum:this.coverageFrustums?.find((e=>e?.imageID===this.selectedFeature?.attributes.objectId))};this.emit("plot-polygons",{data:e})}else if(this.view){const t=this._currentCoveragePolygon&&this._overlays?this._overlays.graphics.indexOf(this._currentCoveragePolygon):-1;e&&(this._currentCoveragePolygon&&(this._overlays?.remove(this._currentCoveragePolygon),this._currentCoveragePolygon.destroy()),e.visible=this.isCurrentCoverageVisible,this._currentCoveragePolygon=e,this._overlays?.graphics.add(this._currentCoveragePolygon,t>=0?t:void 0))}else e&&(this._currentCoveragePolygon=e,this.emit("update-current-coverage",{graphic:e.toJSON()}))}async loadImage(e,t){if(!this._imageViewer)return;if(this._imageViewer.graphics.removeAll(),this._currentImage&&this._imageViewer?.map.layers.includes(this._currentImage)&&(this._currentImage?.removeHandles("image-handles"),this._imageViewer?.map.layers.remove(this._currentImage),this._currentImage?.destroy(),this._currentImage=null),!e)return void this.setMessage("noImageError","error");const r=e.attributes.image;this._referencePointOnGround&&(this._imageViewer?.graphics.remove(this._referencePointOnGround),this._referencePointOnGround.destroy());const i={skipExtensions:["aux.xml","jgw"]};this._currentImage=new v({ioConfig:i,url:r,options:t}),this._imageViewer.map.layers.add(this._currentImage);try{const t=await this._currentImage.when();this._imageViewer.extent=t.fullExtent,t.raster.rasterInfo.isPseudoSpatialReference&&(this._imageViewer.constraints.rotationEnabled=!0,this._imageViewer.rotation=(e.attributes.cameraRoll??0)+(e.attributes.imageRotation??0),this._imageViewer.constraints.rotationEnabled=!1),this._panConstraint&&this._imageViewer?.constraints.customConstraints.remove(this._panConstraint),this._panConstraint={constrain:(e,t)=>{if(!this._currentImage||!this._imageViewer||!e.targetGeometry)return e;const{xmin:r,xmax:i,ymin:o,ymax:s}=this._currentImage.fullExtent,{width:a,height:n}=this._imageViewer.extent,l=this._imageViewer?.rotation*Math.PI/180,g=Math.abs(Math.cos(l)*a+Math.sin(l)*n),h=Math.abs(Math.cos(l)*n+Math.sin(l)*a),{width:c,height:u}=this._currentImage.rasterInfo;return e.targetGeometry.x=Math.min(Math.max(r+(c>g?g:c)/2,e.targetGeometry.x),i-(c>g?g:c)/2),e.targetGeometry.y=Math.min(Math.max(o+(u>h?h:u)/2,e.targetGeometry.y),s-(u>h?h:u)/2),e}},this._scaleConstraint&&this._imageViewer?.constraints.customConstraints.remove(this._scaleConstraint),this._scaleConstraint={constrain:(e,t)=>{if(this._imageViewer&&this._currentImage){const{width:t,height:r}=this._currentImage.rasterInfo,{width:i,height:o}=this._imageViewer;e.scale=Math.min(e.scale,O(this._imageViewer.spatialReference)*Math.max(t/i,r/o))}return e}},this._imageViewer?.constraints.customConstraints.add(this._panConstraint),this._imageViewer?.constraints.customConstraints.add(this._scaleConstraint),t.addHandles(h((()=>[this.brightness,this.contrast]),(([e,r])=>{t.loaded&&(t.effect=`contrast(${10*(r+10)}%) brightness(${10*(e+10)}%)`)}),c))}catch(o){s.getLogger(this).error("oriented-imagery-viewer:load-image",o),this.setMessage("imageLoadError","error",o.message)}}async transformAndPlotSelectedLocation(e){const{_currentImage:r,selectedFeature:i,selectedPoint:o}=this;if(!o||!i||!r?.loaded)return;const{pixelSize:s}=r.rasterInfo,a=await S([o],{feature:i,imageProperties:r.rasterInfo,currentCoveragePolygon:this.getSelectedFeaturePolygon(),options:e});if(!a.length)return;const n=a[0];if(!n)return;const l=d(y,await M(r.fullExtent,d(U,this._imageViewer?.spatialReference),null,e?.signal));n.x=n.x*s.x+l.xmin,n.y=l.ymax-n.y*s.y,n.spatialReference=l.spatialReference,this._crossSymbol&&(this._imageViewer?.graphics.remove(this._crossSymbol),this._crossSymbol.destroy()),this._crossSymbol=new t({geometry:T.fromJSON(n),symbol:A}),this._imageViewer?.graphics.add(this._crossSymbol)}async transformAndPlotReferencePointOnImage(e){if(!this._imageViewer)return;const t=this._currentImage;if(!t)return;const{feature:r,selectedLocation:i,options:o}=e,{pixelSize:s,isPseudoSpatialReference:a,transform:n}=t.rasterInfo,l=await S([i],{feature:r,imageProperties:t.rasterInfo,currentCoveragePolygon:this.getSelectedFeaturePolygon(),options:o});if(!l.length)return;let g=l[0];const h=await M(t.fullExtent,this._imageViewer.spatialReference,null,o?.signal);a?(g.x=g.x*s.x+h.xmin,g.y=h.ymax-g.y*s.y,g.spatialReference=h.spatialReference):g=n.forwardTransform(new T(g)),this.plotReferencePointOnImage(g)}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),this._referencePointOnGround=new t({geometry:{type:"point",...e.toJSON()},symbol:E}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}})}plotReferencePointOnImage(e){this._imageViewer&&(this._referencePointOnImage&&(this._imageViewer.graphics.remove(this._referencePointOnImage),this._referencePointOnImage.destroy()),this._referencePointOnImage=new t({geometry:{type:"point",..."toJSON"in e?e.toJSON():e},symbol:E}),this._imageViewer.graphics.add(this._referencePointOnImage))}setMessage(e,t,r){this.displayMessage={key:e,type:t,data:r}}async updateCoverage(){const e=new AbortController,{signal:r}=e;this._updateCoverageController=e;const{_imageViewer:i}=this;if(this._currentImage?.loaded&&i){const{width:e,height:o}=this._currentImage.rasterInfo,{xmin:s,xmax:a,ymin:n,ymax:l}=this._currentImage.fullExtent,g=[[0,0],[Math.min(i.width,e),0],[Math.min(i.width,e),Math.min(i.height,o)],[0,Math.min(i.height,o)]].map((e=>i.toMap(u(e[0],e[1]))));g.forEach((e=>{e.x=s<=e.x&&e.x<=a?e.x:Math.abs(s-e.x)>Math.abs(a-e.x)?a:s,e.y=n<=e.y&&e.y<=l?e.y:Math.abs(n-e.y)>Math.abs(l-e.y)?l:n}));const h=await V(g,{feature:this.getSelectedFeature(),currentCoveragePolygon:this.getSelectedFeaturePolygon(),imageProperties:this._currentImage.rasterInfo,options:{signal:r}});if(h&&!r.aborted){const e=[h.map((e=>[e.x,e.y,1]))];e[0].push(e[0][0]);const r=new D({hasZ:!0,rings:e,spatialReference:h[0].spatialReference});this.updateCurrentCoveragePolygon(new t({geometry:r,symbol:G,visible:this.isCurrentCoverageVisible}))}}}};e([m()],z.prototype,"active",null),e([m()],z.prototype,"activeLayer",void 0),e([m()],z.prototype,"shouldShowSelectedImage",void 0),e([m({type:Number})],z.prototype,"brightness",null),e([m({type:Number})],z.prototype,"contrast",null),e([m()],z.prototype,"coverageFrustums",void 0),e([m()],z.prototype,"coveragePolygons",void 0),e([m()],z.prototype,"currentImageView",null),e([m()],z.prototype,"displayMessage",void 0),e([m()],z.prototype,"pointSources",void 0),e([m()],z.prototype,"selectedFeature",void 0),e([m()],z.prototype,"selectedPoint",void 0),e([m({readOnly:!0})],z.prototype,"featureCount",null),e([m()],z.prototype,"features",void 0),e([m()],z.prototype,"imageLoaded",null),e([m()],z.prototype,"isAdditionalCoverageDisabled",null),e([m()],z.prototype,"isAdditionalCoverageVisible",null),e([m()],z.prototype,"isAdditionalPointSourcesDisabled",null),e([m()],z.prototype,"isAdditionalPointSourcesVisible",null),e([m()],z.prototype,"isCurrentCoverageDisabled",null),e([m()],z.prototype,"isCurrentCoverageVisible",null),e([m()],z.prototype,"isImageGalleryEnabled",null),e([m()],z.prototype,"mapImageConversionToolState",void 0),e([m()],z.prototype,"updating",null),e([m()],z.prototype,"state",null),e([m()],z.prototype,"thumbnails",null),e([m()],z.prototype,"view",null),e([m()],z.prototype,"_additionalCoveragePolygons",void 0),e([m()],z.prototype,"_additionalFeatureGraphics",void 0),e([m()],z.prototype,"_currentCoveragePolygon",void 0),e([m()],z.prototype,"_currentImage",void 0),e([m()],z.prototype,"_fetchFeaturesController",void 0),e([m()],z.prototype,"_imageViewer",void 0),e([m()],z.prototype,"_initialCurrentCoveragePolygon",void 0),e([m()],z.prototype,"_initialCurrentCoverageUpdate",void 0),e([m()],z.prototype,"_overlays",void 0),e([m()],z.prototype,"_referencePointOnGround",void 0),e([m()],z.prototype,"_referencePointOnImage",void 0),e([m()],z.prototype,"_selectedFeatureGraphic",void 0),z=e([p("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],z);const B=z;export{B as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import{isSome as r}from"../../core/arrayUtils.js";import i from"../../core/Collection.js";import o from"../../core/Evented.js";import s from"../../core/Logger.js";import{clamp as a}from"../../core/mathUtils.js";import{destroyMaybe as n}from"../../core/maybe.js";import{once as l,on as g,watch as h,initial as c}from"../../core/reactiveUtils.js";import{createScreenPoint as u}from"../../core/screenUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import{ensureType as d}from"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import y from"../../geometry/Extent.js";import _ from"../../layers/GraphicsLayer.js";import v from"../../layers/ImageryTileLayer.js";import{searchImages as f}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as C}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as w,computePolygonForInspection as P,resizePolygon as I,checkIfPolygonContainsSelectedPoint as b}from"../../layers/orientedImagery/core/coverageUtils.js";import{updateElevation as F,transformPoints as S}from"../../layers/orientedImagery/transformations/groundToImageUtils.js";import{transformPoints as V}from"../../layers/orientedImagery/transformations/imageToGroundUtils.js";import x from"../../layers/support/RasterFunction.js";import{convolutionKernel as O}from"../../layers/support/rasterFunctionConstants.js";import M from"../../views/MapView.js";import{getResolutionToScaleFactor as j}from"../../views/2d/viewpointUtils.js";import{projectWithEngineOrService as G}from"../../views/support/projectionUtils.js";import{activePolygonSymbol as R,polygonSymbol as L,activeSourcePointSymbol as A,sourcePointSymbol as D,crossSymbol as E,diamondSymbol as U}from"./symbols.js";import T from"../../geometry/Polygon.js";import N from"../../geometry/SpatialReference.js";import J from"../../geometry/Point.js";const k={click:"view-click",view:"view",viewLayers:"view-layers",mapLayers:"map-layers",layerViews:"layer-views",layerListMode:"layer-list-mode",children:"children",registerLayerSelection:"register-layer-selection",plotPointOnGround:"plot-point-on-ground"};function H(e){return"3d"===e?.type}function z(e){return"esri.Graphic"===e?.declaredClass}function B(e){return/.*.(tif|mrf)$/i.test(e??"")}let $=class extends o.EventedAccessor{constructor(e){super(e),this.activeLayer=null,this.shouldShowSelectedImage=!1,this.coverageFrustums=null,this.coveragePolygons=null,this.displayMessage=null,this.pointSources=null,this.selectedFeature=null,this.selectedPoint=null,this.features=null,this.mapImageConversionToolState=!1,this._additionalCoveragePolygons=null,this._additionalFeatureGraphics=null,this._currentCoveragePolygon=null,this._currentImage=null,this._fetchFeaturesController=null,this._imageViewer=null,this._initialCurrentCoveragePolygon=null,this._initialCurrentCoverageUpdate=!0,this._overlays=null,this._referencePointOnGround=null,this._referencePointOnImage=null,this._crossSymbol=null,this._panConstraint=null,this._scaleConstraint=null,this._transformController=new AbortController,this._updateCoverageController=null,this.loadViewer=this.loadViewer.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this)}initialize(){l((()=>this.view?.ready)).then((()=>{this._overlays=new _({listMode:"hide"}),this.view.map.layers.add(this._overlays)})),this.addHandles([g((()=>this.view),"click",(e=>{this.view.ready&&this.active&&(e.stopPropagation(),e.preventDefault(),"mouse"===e.pointerType&&0!==e.button||(this.mapImageConversionToolState?(this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.selectedFeature,selectedLocation:e.mapPoint,options:{signal:this._transformController?.signal}})):(this.displayMessage=null,this.selectedPoint=e.mapPoint,this.features=null,this.selectedFeature=null,this._overlays?.removeAll(),this._overlays?.add(new t({geometry:e.mapPoint.clone(),symbol:E})),this._fetchFeaturesWithController(e))))})),h((()=>this.view?.map?.allLayers?.length),(e=>{e&&this._overlays&&this.view.map.layers.reorder(this._overlays,e-1)}),{initial:!0})],k.view)}destroy(){this._cancelCurrentCoverageUpdate(),this._cancelFetchingFeatures(),this.coverageFrustums=null,this.coveragePolygons=null,this.pointSources=null,this._additionalCoveragePolygons=null,this._additionalFeatureGraphics=null,this._currentImage=n(this._currentImage),this._imageViewer=n(this._imageViewer),this._initialCurrentCoveragePolygon=n(this._initialCurrentCoveragePolygon),this._currentCoveragePolygon=n(this._currentCoveragePolygon),this._crossSymbol=n(this._crossSymbol),this._referencePointOnGround=n(this._referencePointOnGround),this._referencePointOnImage=n(this._referencePointOnImage),this._overlays&&this.view?.map.remove(this._overlays),this._overlays=n(this._overlays)}get active(){return!0===this.view?.map?.allLayers.some((e=>"oriented-imagery"===e.type&&e.loaded))}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",a(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",a(e,-10,10))}get currentImageView(){return this._imageViewer?.allLayerViews.find((e=>e.layer===this._currentImage))}get featureCount(){return this.features?.length??0}get imageLoaded(){return this._currentImage?.loaded??!1}get isAdditionalCoverageDisabled(){return!this._additionalCoveragePolygons?.length}get isAdditionalCoverageVisible(){return this._additionalCoveragePolygons?.getItemAt(0)?.visible??!1}get isAdditionalPointSourcesDisabled(){return!this._additionalFeatureGraphics?.length}get isAdditionalPointSourcesVisible(){return this._additionalFeatureGraphics?.getItemAt(0)?.visible??!1}get isCurrentCoverageDisabled(){return!this._currentCoveragePolygon}get isCurrentCoverageVisible(){return!!this._currentCoveragePolygon?.visible}get isImageGalleryEnabled(){return!(this.featureCount<2)&&B(this.selectedFeature?.attributes.image?.trim())}get updating(){return(this.currentImageView?.updating??!1)||"loading"===this._currentImage?.loadStatus||!!this._fetchFeaturesController}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",a(e,0,1))}get state(){const{active:e,activeLayer:t}=this;return e||t?this._currentImage?.loadStatus?`image-${this._currentImage.loadStatus}`:"ready":"disabled"}get thumbnails(){const{features:e}=this;return e?new i(e.map((({attributes:{image:e,objectId:t}})=>{const r=e?.trim();return B(r)?{url:r,objectId:t}:null})).filter(r)):null}set view(e){this._set("view",e)}getCurrentCoveragePolygon(){return this._currentCoveragePolygon}getSelectedFeature(){return this.selectedFeature}getSelectedFeaturePolygon(){return this._initialCurrentCoveragePolygon}loadViewer(e){const t=new Map,r={wkid:0};this._imageViewer=new M({container:e,map:t,spatialReferance:r,constraints:{snapToZoom:!1,rotationEnabled:!1},ui:{components:["zoom"]}}),l((()=>!0===this._imageViewer?.stationary)).then((()=>{this.setMessage("onLoadMessage","info")})),this._imageViewer.addHandles([this._imageViewer.on("click",(async e=>{if(0===e.button&&this._currentImage&&this.mapImageConversionToolState&&this._currentImage&&this._currentImage.fullExtent){const{xmin:t,xmax:r,ymin:i,ymax:o}=this._currentImage.fullExtent,{x:s,y:a}=e.mapPoint;if(t>s||r<s||o<a||i>a)return;this.plotReferencePointOnImage(e.mapPoint);const n=this.getSelectedFeature();if(n){const t=(await V([e.mapPoint.toJSON()],{feature:n,currentCoveragePolygon:this.getSelectedFeaturePolygon(),imageProperties:this._currentImage.rasterInfo,options:{signal:this._transformController?.signal}}))[0];t&&this.plotReferencePointOnGround(t)}}})),h((()=>[this._imageViewer?.viewpoint,this._initialCurrentCoveragePolygon]),(()=>{this._imageViewer?.viewpoint&&this._initialCurrentCoveragePolygon&&(this._cancelCurrentCoverageUpdate(),this.updateCoverage())})),h((()=>this.selectedFeature),(async()=>{const{_fetchFeaturesController:e,selectedFeature:t,selectedPoint:r}=this;!t&&this._currentImage&&(this._imageViewer?.map.layers.remove(this._currentImage),this._currentImage=n(this._currentImage)),t&&r&&(await this.loadImage(t,{signal:e?.signal}),this.transformAndPlotSelectedLocation({signal:this._fetchFeaturesController?.signal}))}))])}async searchBestImage(e,t){try{const r=await f(e,t);r&&await this._processFeatureResponse(r,{signal:t?.signal})}catch(r){const e=s.getLogger(this);this.setMessage("imageLoadError","error"),e.error("error occured while finding best image",r)}}toggleAdditionalCameraLocations(){this._additionalFeatureGraphics?.forEach((e=>{e.visible=!e.visible}))}toggleAdditionalCoverage(){this._additionalCoveragePolygons?.forEach((e=>{e.visible=!e.visible}))}toggleCurrentCoverage(){this._currentCoveragePolygon&&(this._currentCoveragePolygon.visible=!this._currentCoveragePolygon.visible,this._selectedFeatureGraphic.visible=!this._selectedFeatureGraphic)}toggleMapImageConversionToolState(){this.mapImageConversionToolState=!this.mapImageConversionToolState}_cancelFetchingFeatures(){const e=this._fetchFeaturesController;e&&e.abort(),this._fetchFeaturesController=null}_cancelCurrentCoverageUpdate(){const e=this._updateCoverageController;e&&e.abort("Multiple Coverage Updates: Aborting Current Coverage Update to sync image and coverage"),this._updateCoverageController=null}async _fetchFeatures(e,t){const{screenPoint:r}=e,i=this.activeLayer;if(i){const e={include:i},o=await this.view.hitTest(r,e);this._processHitTestResults(i,o,t)}}async _fetchFeaturesWithController(e){this._cancelFetchingFeatures();const t=new AbortController,{signal:r}=t;this._fetchFeaturesController=t;try{this._fetchFeatures(e,{signal:r})}catch(i){const e=s.getLogger(this);this.setMessage("imageLoadError","error"),e.error("error occured while fetching features",i)}this._fetchFeaturesController=null}async _processFeatureResponse(e,r){const{selectedPoint:o}=this;if(!o)return;if(!e)return;const s=e;if(this._fetchFeaturesController=null,!s)return;const{features:a}=s;if(!a.length)return this.setMessage("noImageError","error"),void(this.selectedFeature=null);const n=new Array;this.coveragePolygons=new i,this.coverageFrustums=new i,this.pointSources=new i,a.forEach((e=>{let t;const{polygon:r,frustum:i}=w(e);if(t=r,e.attributes.isInspection&&(t=P(e.attributes)),e.layer.coveragePercent&&(t=I(t,e.layer.coveragePercent)),b(t,o)){n.push(e);const r=t.toJSON(),o=i?.toJSON(),{attributes:s}=e,{cameraHeight:a,cameraHeading:l,location:g,objectId:h}=s,c="toJSON"in g?g.toJSON():g;r.imageID=c.imageID=h,o&&(o.imageID=h),c.z=a,this.pointSources?.push(c),this.coveragePolygons?.push(l>0?r:void 0),this.coverageFrustums?.push(l>0?o:void 0)}}));const l=this.coveragePolygons?.getItemAt(0);if(!n.length)return void this.setMessage("noImageError","error");if(n[0].attributes.elevationSource&&!o.z&&l){const e=await F([o],{feature:n[0],currentCoveragePolygon:new T(l),options:r});if(e[0]){const t=e[0];o.elevation=t.z}}const g=C({features:n,selectedPoint:o,camera:H(this.view)?this.view.camera:null,currentImage:this.selectedFeature});g?.sort(((e,t)=>e.suitability-t.suitability));const h=g?.map((e=>e.feature)),c=h[0];await this._updateFeatures(h),this._additionalCoveragePolygons=new i,this._additionalFeatureGraphics=new i,this._currentCoveragePolygon&&(this._currentCoveragePolygon.destroy(),this._currentCoveragePolygon=null,this._initialCurrentCoveragePolygon=null);for(const i of this.coveragePolygons)i?.imageID===c?.attributes.objectId?this._initialCurrentCoveragePolygon=new t({attributes:{imageID:i?.imageID},geometry:{type:"polygon",...i},symbol:R,visible:!1}):this._additionalCoveragePolygons.push(new t({attributes:{imageID:i?.imageID},geometry:{type:"polygon",...i},symbol:L,visible:!1}));for(const i of this.pointSources)i.imageID===c?.attributes.objectId?this._selectedFeatureGraphic=new t({attributes:{imageID:i.imageID},geometry:{type:"point",...i},symbol:A,visible:!1}):this._additionalFeatureGraphics?.push(new t({attributes:{imageID:i.imageID},geometry:{type:"point",...i},symbol:D,visible:!1}));this.selectedFeature=c,this._initialCurrentCoverageUpdate=!0}async _processHitTestResults(e,t,r){const{screenPoint:i,results:o}=t,s=this.view.toMap(i),a=o[0],n={layerInstanceOrURL:e,point:s,queryParams:{maximumDistance:e.maximumDistance,objectIds:this.shouldShowSelectedImage?[a.graphic.attributes.id]:void 0,outSpatialReference:s.spatialReference},queryFeatures:null};await this.searchBestImage(n,r)}async _updateFeatures(e){e.length&&(this.features=new i(e),this.notifyChange("features"))}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}updateCurrentCoveragePolygon(e){if(this._initialCurrentCoverageUpdate)if(this._initialCurrentCoverageUpdate=!1,e&&(this._currentCoveragePolygon&&(this._overlays?.remove(this._currentCoveragePolygon),this._currentCoveragePolygon.destroy()),e.visible=this.isCurrentCoverageVisible,this._currentCoveragePolygon=e),this.view)this._overlays?.graphics.addMany([...this._additionalCoveragePolygons??[],...this._additionalFeatureGraphics??[],this._currentCoveragePolygon,this._selectedFeatureGraphic].filter(z));else{const e={points:this.pointSources?.filter((e=>e?.imageID!==this.selectedFeature?.attributes.objectId)),frustums:this.coverageFrustums?.filter((e=>e?.imageID!==this.selectedFeature?.attributes.objectId)),polygons:this._additionalCoveragePolygons?.map((e=>e.geometry?.toJSON())),currentPoint:this.selectedFeature?.geometry,currentPolygon:this._currentCoveragePolygon,currentFrustum:this.coverageFrustums?.find((e=>e?.imageID===this.selectedFeature?.attributes.objectId))};this.emit("plot-polygons",{data:e})}else if(this.view){const t=this._currentCoveragePolygon&&this._overlays?this._overlays.graphics.indexOf(this._currentCoveragePolygon):-1;e&&(this._currentCoveragePolygon&&(this._overlays?.remove(this._currentCoveragePolygon),this._currentCoveragePolygon.destroy()),e.visible=this.isCurrentCoverageVisible,this._currentCoveragePolygon=e,this._overlays?.graphics.add(this._currentCoveragePolygon,t>=0?t:void 0))}else e&&(this._currentCoveragePolygon=e,this.emit("update-current-coverage",{graphic:e.toJSON()}))}async loadImage(e,t){if(!this._imageViewer)return;if(this._imageViewer.graphics.removeAll(),this._currentImage&&this._imageViewer?.map.layers.includes(this._currentImage)&&(this._currentImage?.removeHandles("image-handles"),this._imageViewer?.map.layers.remove(this._currentImage),this._currentImage?.destroy(),this._currentImage=null),!e)return void this.setMessage("noImageError","error");const r=e.attributes.image;this._referencePointOnGround&&(this._imageViewer?.graphics.remove(this._referencePointOnGround),this._referencePointOnGround.destroy());const i={skipExtensions:["aux.xml","jgw"]};this._currentImage=new v({ioConfig:i,url:r,options:t}),this._imageViewer.map.layers.add(this._currentImage);try{const t=await this._currentImage.when();this._imageViewer.extent=t.fullExtent,t.raster.rasterInfo.isPseudoSpatialReference&&(this._imageViewer.constraints.rotationEnabled=!0,this._imageViewer.rotation=(e.attributes.cameraRoll??0)+(e.attributes.imageRotation??0),this._imageViewer.constraints.rotationEnabled=!1),this._panConstraint&&this._imageViewer?.constraints.customConstraints.remove(this._panConstraint),this._panConstraint={constrain:(e,t)=>{if(!this._currentImage||!this._imageViewer||!e.targetGeometry)return e;const{xmin:r,xmax:i,ymin:o,ymax:s}=this._currentImage.fullExtent,{width:a,height:n}=this._imageViewer.extent,l=this._imageViewer?.rotation*Math.PI/180,g=Math.abs(Math.cos(l)*a+Math.sin(l)*n),h=Math.abs(Math.cos(l)*n+Math.sin(l)*a),{width:c,height:u}=this._currentImage.rasterInfo;return e.targetGeometry.x=Math.min(Math.max(r+(c>g?g:c)/2,e.targetGeometry.x),i-(c>g?g:c)/2),e.targetGeometry.y=Math.min(Math.max(o+(u>h?h:u)/2,e.targetGeometry.y),s-(u>h?h:u)/2),e}},this._scaleConstraint&&this._imageViewer?.constraints.customConstraints.remove(this._scaleConstraint),this._scaleConstraint={constrain:(e,t)=>{if(this._imageViewer&&this._currentImage){const{width:t,height:r}=this._currentImage.rasterInfo,{width:i,height:o}=this._imageViewer;e.scale=Math.min(e.scale,j(this._imageViewer.spatialReference)*Math.max(t/i,r/o))}return e}},this._imageViewer?.constraints.customConstraints.add(this._panConstraint),this._imageViewer?.constraints.customConstraints.add(this._scaleConstraint),t.addHandles(h((()=>[this.brightness,this.contrast,this.sharpness]),(([e,r,i])=>{t.loaded&&(t.effect=`contrast(${10*(r+10)}%) brightness(${10*(e+10)}%)`,this.sharpenImage(t,i))}),c))}catch(o){s.getLogger(this).error("oriented-imagery-viewer:load-image",o),this.setMessage("imageLoadError","error",o.message)}}sharpenImage(e,t){const r=[0,-1*t,0,-1*t,5,-1*t,0,-1*t,0],i=new x({functionName:"Convolution",functionArguments:{type:O.userDefined,cols:3,rows:3,kernel:r,convolutionType:O.userDefined}});e.renderer=null,e.rasterFunction=i}async transformAndPlotSelectedLocation(e){const{_currentImage:r,selectedFeature:i,selectedPoint:o}=this;if(!o||!i||!r?.loaded)return;const{pixelSize:s}=r.rasterInfo,a=await S([o],{feature:i,imageProperties:r.rasterInfo,currentCoveragePolygon:this.getSelectedFeaturePolygon(),options:e});if(!a.length)return;const n=a[0];if(!n)return;const l=d(y,await G(r.fullExtent,d(N,this._imageViewer?.spatialReference),null,e?.signal));n.x=n.x*s.x+l.xmin,n.y=l.ymax-n.y*s.y,n.spatialReference=l.spatialReference,this._crossSymbol&&(this._imageViewer?.graphics.remove(this._crossSymbol),this._crossSymbol.destroy()),this._crossSymbol=new t({geometry:J.fromJSON(n),symbol:E}),this._imageViewer?.graphics.add(this._crossSymbol)}async transformAndPlotReferencePointOnImage(e){if(!this._imageViewer)return;const t=this._currentImage;if(!t)return;const{feature:r,selectedLocation:i,options:o}=e,{pixelSize:s,isPseudoSpatialReference:a,transform:n}=t.rasterInfo,l=await S([i],{feature:r,imageProperties:t.rasterInfo,currentCoveragePolygon:this.getSelectedFeaturePolygon(),options:o});if(!l.length)return;let g=l[0];const h=await G(t.fullExtent,this._imageViewer.spatialReference,null,o?.signal);a?(g.x=g.x*s.x+h.xmin,g.y=h.ymax-g.y*s.y,g.spatialReference=h.spatialReference):g=n.forwardTransform(new J(g)),this.plotReferencePointOnImage(g)}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),this._referencePointOnGround=new t({geometry:{type:"point",...e.toJSON()},symbol:U}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}})}plotReferencePointOnImage(e){this._imageViewer&&(this._referencePointOnImage&&(this._imageViewer.graphics.remove(this._referencePointOnImage),this._referencePointOnImage.destroy()),this._referencePointOnImage=new t({geometry:{type:"point",..."toJSON"in e?e.toJSON():e},symbol:U}),this._imageViewer.graphics.add(this._referencePointOnImage))}setMessage(e,t,r){this.displayMessage={key:e,type:t,data:r}}async updateCoverage(){const e=new AbortController,{signal:r}=e;this._updateCoverageController=e;const{_imageViewer:i}=this;if(this._currentImage?.loaded&&i){const{width:e,height:o}=this._currentImage.rasterInfo,{xmin:s,xmax:a,ymin:n,ymax:l}=this._currentImage.fullExtent,g=[[0,0],[Math.min(i.width,e),0],[Math.min(i.width,e),Math.min(i.height,o)],[0,Math.min(i.height,o)]].map((e=>i.toMap(u(e[0],e[1]))));g.forEach((e=>{e.x=s<=e.x&&e.x<=a?e.x:Math.abs(s-e.x)>Math.abs(a-e.x)?a:s,e.y=n<=e.y&&e.y<=l?e.y:Math.abs(n-e.y)>Math.abs(l-e.y)?l:n}));const h=await V(g,{feature:this.getSelectedFeature(),currentCoveragePolygon:this.getSelectedFeaturePolygon(),imageProperties:this._currentImage.rasterInfo,options:{signal:r}});if(h&&!r.aborted){const e=[h.map((e=>[e.x,e.y,1]))];e[0].push(e[0][0]);const r=new T({hasZ:!0,rings:e,spatialReference:h[0].spatialReference});this.updateCurrentCoveragePolygon(new t({geometry:r,symbol:R,visible:this.isCurrentCoverageVisible}))}}}};e([m()],$.prototype,"active",null),e([m()],$.prototype,"activeLayer",void 0),e([m()],$.prototype,"shouldShowSelectedImage",void 0),e([m({type:Number})],$.prototype,"brightness",null),e([m({type:Number})],$.prototype,"contrast",null),e([m()],$.prototype,"coverageFrustums",void 0),e([m()],$.prototype,"coveragePolygons",void 0),e([m()],$.prototype,"currentImageView",null),e([m()],$.prototype,"displayMessage",void 0),e([m()],$.prototype,"pointSources",void 0),e([m()],$.prototype,"selectedFeature",void 0),e([m()],$.prototype,"selectedPoint",void 0),e([m({readOnly:!0})],$.prototype,"featureCount",null),e([m()],$.prototype,"features",void 0),e([m()],$.prototype,"imageLoaded",null),e([m()],$.prototype,"isAdditionalCoverageDisabled",null),e([m()],$.prototype,"isAdditionalCoverageVisible",null),e([m()],$.prototype,"isAdditionalPointSourcesDisabled",null),e([m()],$.prototype,"isAdditionalPointSourcesVisible",null),e([m()],$.prototype,"isCurrentCoverageDisabled",null),e([m()],$.prototype,"isCurrentCoverageVisible",null),e([m()],$.prototype,"isImageGalleryEnabled",null),e([m()],$.prototype,"mapImageConversionToolState",void 0),e([m()],$.prototype,"updating",null),e([m({type:Number})],$.prototype,"sharpness",null),e([m()],$.prototype,"state",null),e([m()],$.prototype,"thumbnails",null),e([m()],$.prototype,"view",null),e([m()],$.prototype,"_additionalCoveragePolygons",void 0),e([m()],$.prototype,"_additionalFeatureGraphics",void 0),e([m()],$.prototype,"_currentCoveragePolygon",void 0),e([m()],$.prototype,"_currentImage",void 0),e([m()],$.prototype,"_fetchFeaturesController",void 0),e([m()],$.prototype,"_imageViewer",void 0),e([m()],$.prototype,"_initialCurrentCoveragePolygon",void 0),e([m()],$.prototype,"_initialCurrentCoverageUpdate",void 0),e([m()],$.prototype,"_overlays",void 0),e([m()],$.prototype,"_referencePointOnGround",void 0),e([m()],$.prototype,"_referencePointOnImage",void 0),e([m()],$.prototype,"_selectedFeatureGraphic",void 0),$=e([p("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],$);const q=$;export{q as default};