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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (308) hide show
  1. package/applications/Components/sanitizerUtils.d.ts +3 -0
  2. package/applications/Components/sanitizerUtils.js +5 -0
  3. package/applications/MapViewer/layerUtils.d.ts +3 -0
  4. package/applications/MapViewer/layerUtils.js +5 -0
  5. package/applications/SceneViewer/layerUtils.d.ts +2 -2
  6. package/arcade.js +1 -1
  7. package/assets/esri/core/workers/RemoteClient.js +1 -1
  8. package/assets/esri/core/workers/chunks/{a08ce98672ab94d19613.js → 04e558a970c6a77f243e.js} +1 -1
  9. package/assets/esri/core/workers/chunks/0512ee54f2259a437fdb.js +1 -0
  10. package/assets/esri/core/workers/chunks/0d99579d8cdeddc0fc9c.js +1 -0
  11. package/assets/esri/core/workers/chunks/0f81a2deb656e8b28eae.js +1 -0
  12. package/assets/esri/core/workers/chunks/{ad4f65d764654c70a117.js → 0f8f217aaf42eb1b9699.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{74276044cb75b51967f2.js → 10eb89a93c8e31f03c95.js} +1 -1
  14. package/assets/esri/core/workers/chunks/1443520c9fb23381f8d5.js +1 -0
  15. package/assets/esri/core/workers/chunks/15d3193576f93586674c.js +1 -0
  16. package/assets/esri/core/workers/chunks/1a7570bd2b79194ff94b.js +42 -0
  17. package/assets/esri/core/workers/chunks/243eb8a317333ec2715b.js +1 -0
  18. package/assets/esri/core/workers/chunks/{0ed4ec00ef16aa58a33d.js → 254c4f7e277ae9915dce.js} +1 -1
  19. package/assets/esri/core/workers/chunks/273beed633cc37416ad7.js +1 -0
  20. package/assets/esri/core/workers/chunks/2990145d7ac3af0d68be.js +1 -0
  21. package/assets/esri/core/workers/chunks/{63852887b3f07d50f7c9.js → 2ad538440cfb3ab94787.js} +1 -1
  22. package/assets/esri/core/workers/chunks/2d51d0a24cdc89bafa1c.js +1 -0
  23. package/assets/esri/core/workers/chunks/2d89e354eeadadca4f7f.js +1 -0
  24. package/assets/esri/core/workers/chunks/3f8cc157b65a9d570921.js +1 -0
  25. package/assets/esri/core/workers/chunks/{2254989ca3ff3960f2fe.js → 400a4c9fa62964f8fa1d.js} +1 -1
  26. package/assets/esri/core/workers/chunks/445ddf57d2f503a0b98b.js +1 -0
  27. package/assets/esri/core/workers/chunks/{aaa564c84ee8ea36fbb4.js → 49a57dc1e6d1048fa949.js} +1 -1
  28. package/assets/esri/core/workers/chunks/513dc2467e9b8b8c6df4.js +1 -0
  29. package/assets/esri/core/workers/chunks/52239e958a82ebcd2e7a.js +1 -0
  30. package/assets/esri/core/workers/chunks/53e43798d08ad2075c1f.js +1 -0
  31. package/assets/esri/core/workers/chunks/{8b93cd4132934b0d7d39.js → 54814a269d44855f0673.js} +1 -1
  32. package/assets/esri/core/workers/chunks/55ce214a10fb6fc2e901.js +1 -0
  33. package/assets/esri/core/workers/chunks/{e7589c39b13295af8f1d.js → 604f8094992bb642378b.js} +1 -1
  34. package/assets/esri/core/workers/chunks/66c8816e91e3f9e214d4.js +346 -0
  35. package/assets/esri/core/workers/chunks/6975929fa91c81c8afc0.js +1 -0
  36. package/assets/esri/core/workers/chunks/7716a9fb380d66ba7292.js +1 -0
  37. package/assets/esri/core/workers/chunks/77ad62ed93f713a909f0.js +1 -0
  38. package/assets/esri/core/workers/chunks/7b9eec0090f48e9cdaf1.js +1 -0
  39. package/assets/esri/core/workers/chunks/7c56740cac444419e5b4.js +1 -0
  40. package/assets/esri/core/workers/chunks/{3b63edcd34f832ac7bd8.js → 7c6b9e2c1dada4668c01.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{af0d7a7cbbaad47a49c6.js → 802c6b1a6cb9264b8e4f.js} +1 -1
  42. package/assets/esri/core/workers/chunks/{0b21651eb93efe9ce089.js → 827919fe23e06e40a330.js} +189 -165
  43. package/assets/esri/core/workers/chunks/87986f31061c426e761b.js +1 -0
  44. package/assets/esri/core/workers/chunks/{7ae88c141a5d85e5bb88.js → 87a743df7d8556d5e253.js} +1 -1
  45. package/assets/esri/core/workers/chunks/8855f1a6224ffbd0bb66.js +1 -0
  46. package/assets/esri/core/workers/chunks/885e8e90dfe5dbd5053d.js +1 -0
  47. package/assets/esri/core/workers/chunks/8865bd8f196556441ce3.js +1 -0
  48. package/assets/esri/core/workers/chunks/8b1842f0f94c18652d4e.js +1 -0
  49. package/assets/esri/core/workers/chunks/932808e485f305b6a26a.js +1 -0
  50. package/assets/esri/core/workers/chunks/93c145a738b3f6cf4ee4.js +1 -0
  51. package/assets/esri/core/workers/chunks/93e66d9c49eaeb503bff.js +1 -0
  52. package/assets/esri/core/workers/chunks/9959a91c8de6fef499c2.js +1 -0
  53. package/assets/esri/core/workers/chunks/9d779891d51d196aa8c8.js +1 -0
  54. package/assets/esri/core/workers/chunks/{6cbe8205a4e0f62da519.js → a5a27e2e9b91fbe12da9.js} +1 -1
  55. package/assets/esri/core/workers/chunks/aeac889d95f34b6d3b72.js +1 -0
  56. package/assets/esri/core/workers/chunks/c1a72e1dbd1ba7b41965.js +1 -0
  57. package/assets/esri/core/workers/chunks/c4065934637b820cad5b.js +1 -0
  58. package/assets/esri/core/workers/chunks/cc1328cacc4ac07eb548.js +1 -0
  59. package/assets/esri/core/workers/chunks/d0876a713079c669995a.js +1 -0
  60. package/assets/esri/core/workers/chunks/{3145218abe59b5e99ff8.js → d2139307f62ea8bf999a.js} +1 -1
  61. package/assets/esri/core/workers/chunks/{d5f770302dc686e55ba7.js → daffceecdc71e74d2629.js} +1 -1
  62. package/assets/esri/core/workers/chunks/{3f58da371633967a61ca.js → ddb66fe6fcd0764daa7a.js} +1 -1
  63. package/assets/esri/core/workers/chunks/{0eeb0dce918e4827309a.js → eac7af86166c09c6a9be.js} +1 -1
  64. package/assets/esri/core/workers/chunks/{998819aade3898f52414.js → ec49e2849766402ad5c7.js} +1 -1
  65. package/assets/esri/core/workers/chunks/{7317346ed8d7c5bb859d.js → f537a02dc2fc9e6435a2.js} +1 -1
  66. package/assets/esri/core/workers/chunks/fa3edfbdaa3b716a3a10.js +1 -0
  67. package/assets/esri/core/workers/chunks/fa5715ca3ce95d005b0a.js +1 -0
  68. package/assets/esri/core/workers/chunks/{7e1906d35a764f7f10b0.js → fe1129f03476825a7344.js} +1 -1
  69. package/assets/esri/themes/base/widgets/_SelectionList.scss +31 -28
  70. package/assets/esri/themes/dark/main.css +1 -1
  71. package/assets/esri/themes/light/main.css +1 -1
  72. package/assets/esri/themes/light/view.css +1 -1
  73. package/chunks/DefaultMaterial.glsl.js +30 -28
  74. package/chunks/RealisticTree.glsl.js +25 -22
  75. package/chunks/aiServices.js +1 -1
  76. package/chunks/chartUtilsAm5.js +1 -1
  77. package/config.js +1 -1
  78. package/core/LRUCache.js +1 -1
  79. package/core/MemCache.js +1 -1
  80. package/core/accessorSupport/utils.js +1 -1
  81. package/core/object.js +1 -1
  82. package/core/urlUtils.js +1 -1
  83. package/core/workers/RemoteClient.js +1 -1
  84. package/core/workers/WorkerHandle.js +1 -1
  85. package/editing/sharedTemplates/executor/builders/bufferPolygonToPolygon.js +1 -1
  86. package/interfaces.d.ts +76 -24
  87. package/intl/date.js +1 -1
  88. package/intl/duration.js +1 -1
  89. package/intl/locale.js +1 -1
  90. package/intl/messages.js +1 -1
  91. package/intl/number.js +1 -1
  92. package/intl.d.ts +1 -0
  93. package/intl.js +1 -1
  94. package/kernel.js +1 -1
  95. package/layers/CatalogLayer.js +1 -1
  96. package/layers/FeatureLayer.js +1 -1
  97. package/layers/GeoJSONLayer.js +1 -1
  98. package/layers/WFSLayer.js +1 -1
  99. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  100. package/layers/graphics/data/QueryEngineResult.js +1 -1
  101. package/layers/graphics/data/queryValidationUtils.js +1 -1
  102. package/layers/mixins/FeatureLayerBase.js +1 -1
  103. package/layers/orientedImagery/core/ExposurePoint.js +1 -1
  104. package/layers/support/arcgisLayers.js +1 -1
  105. package/layers/support/featureLayerUtils.js +1 -1
  106. package/layers/support/fetchService.js +1 -1
  107. package/layers/support/layerUtils.js +1 -1
  108. package/layers/support/rasterDatasets/covJSONParser.js +1 -1
  109. package/layers/support/rasterFormats/TiffDecoder.js +1 -1
  110. package/package.json +1 -1
  111. package/portal/support/layersLoader.js +1 -1
  112. package/portal/support/loadUtils.js +1 -1
  113. package/portal/support/portalLayers.js +1 -1
  114. package/renderers/support/DictionaryScriptEvaluator.js +1 -1
  115. package/renderers/visualVariables/support/visualVariableUtils.js +1 -1
  116. package/rest/networks/circuits/support/CircuitVerifyResult.js +1 -1
  117. package/rest/support/DateBinTimeInterval.js +1 -1
  118. package/rest/support/DateBinUtils.js +5 -0
  119. package/rest/support/TranslateParameters.js +1 -1
  120. package/smartMapping/renderers/size.js +1 -1
  121. package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
  122. package/smartMapping/support/adapters/support/utils.js +1 -1
  123. package/support/ArcadeExpression.js +1 -1
  124. package/support/revision.js +1 -1
  125. package/symbols/WaterSymbol3DLayer.js +1 -1
  126. package/symbols/cim/effects/EffectTaperedPolygon.js +1 -1
  127. package/symbols/support/symbolUtils.js +1 -1
  128. package/symbols/support/utils.js +1 -1
  129. package/views/2d/engine/vectorTiles/style/StyleProperty.js +1 -1
  130. package/views/2d/layers/features/support/FeatureSetReaderIndirect.js +1 -1
  131. package/views/3d/analysis/AreaMeasurementAnalysisView3D.js +1 -1
  132. package/views/3d/analysis/DimensionAnalysisView3D.js +1 -1
  133. package/views/3d/analysis/DirectLineMeasurementAnalysisView3D.js +1 -1
  134. package/views/3d/analysis/LineOfSightAnalysisView3D.js +1 -1
  135. package/views/3d/analysis/SliceAnalysisView3D.js +1 -1
  136. package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
  137. package/views/3d/camera/intersectionUtils.js +1 -1
  138. package/views/3d/layers/I3SMeshView3D.js +1 -1
  139. package/views/3d/layers/I3SMeshViewLabeler.js +1 -1
  140. package/views/3d/layers/I3SMeshWorkerHandle.js +1 -1
  141. package/views/3d/layers/RouteLayerView3D.js +1 -1
  142. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  143. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  144. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  145. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  146. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  147. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  148. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  149. package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
  150. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  151. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  152. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  153. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  154. package/views/3d/layers/graphics/graphicUtils.js +1 -1
  155. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  156. package/views/3d/layers/i3s/I3SLodHandling.js +1 -1
  157. package/views/3d/layers/support/StageLayerElevationProvider.js +1 -1
  158. package/views/3d/layers/support/makeScheduleFunction.js +1 -1
  159. package/views/3d/layers/support/symbolColorUtils.js +1 -1
  160. package/views/3d/state/controllers/FovController.js +1 -1
  161. package/views/3d/state/controllers/PinchAndPanControllerGlobal.js +1 -1
  162. package/views/3d/state/controllers/PinchAndPanControllerLocal.js +1 -1
  163. package/views/3d/state/controllers/RotateController.js +1 -1
  164. package/views/3d/state/controllers/ZoomControllerGlobal.js +1 -1
  165. package/views/3d/state/controllers/ZoomControllerLocal.js +1 -1
  166. package/views/3d/state/controllers/ZoomStepControllerGlobal.js +1 -1
  167. package/views/3d/state/controllers/ZoomStepControllerLocal.js +1 -1
  168. package/views/3d/state/utils/navigationUtils.js +1 -1
  169. package/views/3d/support/StreamDataLoader.js +1 -1
  170. package/views/3d/terrain/OverlayRenderer.js +1 -1
  171. package/views/3d/terrain/TerrainRenderer.js +1 -1
  172. package/views/3d/terrain/TerrainSurface.js +1 -1
  173. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  174. package/views/3d/webgl-engine/collections/Component/RenderSubmitSystem.js +1 -1
  175. package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
  176. package/views/3d/webgl-engine/core/shaderLibrary/attributes/InstanceColor.glsl.js +11 -0
  177. package/views/3d/webgl-engine/core/shaderLibrary/attributes/MaskedColor.glsl.js +18 -0
  178. package/views/3d/webgl-engine/core/shaderLibrary/attributes/PathVertexPosition.glsl.js +40 -26
  179. package/views/3d/webgl-engine/core/shaderLibrary/attributes/RibbonVertexPosition.glsl.js +35 -24
  180. package/views/3d/webgl-engine/core/shaderLibrary/attributes/SymbolColor.glsl.js +12 -8
  181. package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexColor.glsl.js +3 -1
  182. package/views/3d/webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js +2 -2
  183. package/views/3d/webgl-engine/core/shaderLibrary/shading/VisualVariables.glsl.js +26 -8
  184. package/views/3d/webgl-engine/core/shaderModules/Float2BindUniform.js +1 -1
  185. package/views/3d/webgl-engine/core/shaderModules/Float2DrawUniform.js +1 -1
  186. package/views/3d/webgl-engine/core/shaderModules/Float2PassUniform.js +1 -1
  187. package/views/3d/webgl-engine/core/shaderModules/Float3BindUniform.js +1 -1
  188. package/views/3d/webgl-engine/core/shaderModules/Float3DrawUniform.js +1 -1
  189. package/views/3d/webgl-engine/core/shaderModules/Float3PassUniform.js +1 -1
  190. package/views/3d/webgl-engine/core/shaderModules/Float4BindUniform.js +1 -1
  191. package/views/3d/webgl-engine/core/shaderModules/Float4DrawUniform.js +1 -1
  192. package/views/3d/webgl-engine/core/shaderModules/Float4PassUniform.js +1 -1
  193. package/views/3d/webgl-engine/core/shaderModules/Float4sPassUniform.js +1 -1
  194. package/views/3d/webgl-engine/core/shaderModules/FloatBindUniform.js +1 -1
  195. package/views/3d/webgl-engine/core/shaderModules/FloatDrawUniform.js +1 -1
  196. package/views/3d/webgl-engine/core/shaderModules/FloatPassUniform.js +1 -1
  197. package/views/3d/webgl-engine/core/shaderModules/FloatsPassUniform.js +1 -1
  198. package/views/3d/webgl-engine/core/shaderModules/Matrix3DrawUniform.js +1 -1
  199. package/views/3d/webgl-engine/core/shaderModules/Matrix3PassUniform.js +1 -1
  200. package/views/3d/webgl-engine/core/shaderModules/Matrix4BindUniform.js +1 -1
  201. package/views/3d/webgl-engine/core/shaderModules/Matrix4DrawUniform.js +1 -1
  202. package/views/3d/webgl-engine/core/shaderModules/Matrix4PassUniform.js +1 -1
  203. package/views/3d/webgl-engine/core/shaderModules/Matrix4sDrawUniform.js +1 -1
  204. package/views/3d/webgl-engine/core/shaderModules/Matrix4sPassUniform.js +1 -1
  205. package/views/3d/webgl-engine/effects/bloom/BloomRenderNode.js +1 -1
  206. package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
  207. package/views/3d/webgl-engine/lib/GeometryUtil.js +1 -1
  208. package/views/3d/webgl-engine/lib/PathGeometryData.js +1 -1
  209. package/views/3d/webgl-engine/lib/Program.js +1 -1
  210. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  211. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  212. package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
  213. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  214. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  215. package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
  216. package/views/3d/webgl-engine/materials/internal/MaterialUtil.js +1 -1
  217. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  218. package/views/3d/webgl-engine/shaders/DefaultMaterial.glsl.js +1 -1
  219. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  220. package/views/3d/webgl-engine/shaders/RealisticTree.glsl.js +1 -1
  221. package/views/analysis/analysisViewUtils.js +1 -1
  222. package/views/ui/UI.js +1 -1
  223. package/views/webgl/Program.js +1 -1
  224. package/views/webgl/ShaderBuilder.js +1 -1
  225. package/webscene/Slide.js +1 -1
  226. package/widgets/BatchAttributeForm/inputs/FieldInput.js +1 -1
  227. package/widgets/BatchAttributeForm.js +1 -1
  228. package/widgets/Directions/DirectionsVisibleElements.js +1 -1
  229. package/widgets/Directions.js +1 -1
  230. package/widgets/Editor/EditorViewModel.js +1 -1
  231. package/widgets/Editor/UpdateFeatureWorkflowData.js +1 -1
  232. package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
  233. package/widgets/Editor/UpdateWorkflow.js +1 -1
  234. package/widgets/Editor/components/PendingFeatureList.js +1 -1
  235. package/widgets/Editor.js +1 -1
  236. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  237. package/widgets/FeatureTable/Grid/Grid.js +1 -1
  238. package/widgets/FeatureTable.js +1 -1
  239. package/widgets/FeatureTemplates.js +1 -1
  240. package/widgets/Features/FeaturesViewModel.js +1 -1
  241. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  242. package/widgets/OrientedImageryViewer/components/ImageViewer.js +1 -1
  243. package/widgets/OrientedImageryViewer/components/NavigationNode.js +1 -1
  244. package/widgets/OrientedImageryViewer/components/NavigationSettings.js +1 -1
  245. package/widgets/OrientedImageryViewer/components/NavigationUI.js +1 -1
  246. package/widgets/OrientedImageryViewer/components/NavigationUI360.js +5 -0
  247. package/widgets/OrientedImageryViewer/components/NavigationUIPanoramicViewModel.js +1 -1
  248. package/widgets/OrientedImageryViewer/components/NavigationUIViewModel.js +1 -1
  249. package/widgets/OrientedImageryViewer/components/imageNavigationUtils.js +1 -1
  250. package/widgets/OrientedImageryViewer/navigation/NavigationManager.js +1 -1
  251. package/widgets/OrientedImageryViewer.js +1 -1
  252. package/widgets/PanoramicViewer.js +1 -1
  253. package/widgets/Print/PrintViewModel.js +1 -1
  254. package/widgets/Print.js +1 -1
  255. package/widgets/ScaleRangeSlider/scalePreviewUtils.js +1 -1
  256. package/widgets/Search/SearchViewModel.js +1 -1
  257. package/widgets/Search/support/layerSearchUtils.js +1 -1
  258. package/widgets/Search.js +1 -1
  259. package/widgets/support/ItemList.js +1 -1
  260. package/widgets/support/SelectionList/FeatureItem.js +1 -1
  261. package/widgets/support/SelectionList/GroupLayerItem.js +1 -1
  262. package/widgets/support/SelectionList/LayerItem.js +1 -1
  263. package/widgets/support/SelectionList/SelectionListViewModel.js +1 -1
  264. package/widgets/support/SelectionList.js +1 -1
  265. package/widgets/support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js +1 -1
  266. package/widgets/support/dateUtils.js +1 -1
  267. package/widgets/support/symbolPreviewUtils.js +1 -1
  268. package/widgets/support/timeWidgetUtils.js +1 -1
  269. package/assets/esri/core/workers/chunks/0dbb350ce651bc236ec8.js +0 -1
  270. package/assets/esri/core/workers/chunks/0ff6f15d46d7ddf6fe4d.js +0 -1
  271. package/assets/esri/core/workers/chunks/18011c691e0aca4144dd.js +0 -1
  272. package/assets/esri/core/workers/chunks/183a7dec68c8ba6eb3d6.js +0 -1
  273. package/assets/esri/core/workers/chunks/2ddb776434a93b8d9e63.js +0 -1
  274. package/assets/esri/core/workers/chunks/369978472cc9ee6a00b5.js +0 -346
  275. package/assets/esri/core/workers/chunks/3916879b9ca8c6979011.js +0 -1
  276. package/assets/esri/core/workers/chunks/3cbc498388fb1931a9f8.js +0 -1
  277. package/assets/esri/core/workers/chunks/4079e307a0fce4516aa4.js +0 -1
  278. package/assets/esri/core/workers/chunks/4088f4c25a09932a3eb1.js +0 -1
  279. package/assets/esri/core/workers/chunks/462cc6966d060be59c7c.js +0 -1
  280. package/assets/esri/core/workers/chunks/467cacb501b0417bb4df.js +0 -1
  281. package/assets/esri/core/workers/chunks/49089731ecfe7e8bb2f6.js +0 -1
  282. package/assets/esri/core/workers/chunks/4a805e7a57d25c4b595f.js +0 -66
  283. package/assets/esri/core/workers/chunks/4e0bae3671fe1c7efa76.js +0 -1
  284. package/assets/esri/core/workers/chunks/58f92100b1b2343111c6.js +0 -1
  285. package/assets/esri/core/workers/chunks/5dcc8fa321f0a7c49f36.js +0 -1
  286. package/assets/esri/core/workers/chunks/5df4f2315fae82030e87.js +0 -1
  287. package/assets/esri/core/workers/chunks/5e539ce4751bcfa57145.js +0 -1
  288. package/assets/esri/core/workers/chunks/6194636638b0439fccd8.js +0 -1
  289. package/assets/esri/core/workers/chunks/622c0552ca3cd674d46c.js +0 -1
  290. package/assets/esri/core/workers/chunks/64f5f27e7c5649d79cbc.js +0 -1
  291. package/assets/esri/core/workers/chunks/658e82c9b722852e02d0.js +0 -1
  292. package/assets/esri/core/workers/chunks/679d7baea233faf3fdbc.js +0 -1
  293. package/assets/esri/core/workers/chunks/72ea996b03932c0f004f.js +0 -1
  294. package/assets/esri/core/workers/chunks/7aef81778155be373d3e.js +0 -1
  295. package/assets/esri/core/workers/chunks/97b69fec3e87f11210ba.js +0 -1
  296. package/assets/esri/core/workers/chunks/a1a42b0d7cd47b647f8a.js +0 -1
  297. package/assets/esri/core/workers/chunks/a250a5c6e055e33bd25c.js +0 -1
  298. package/assets/esri/core/workers/chunks/a622ed3f182648ab3ff6.js +0 -1
  299. package/assets/esri/core/workers/chunks/a693cd3af2e995972252.js +0 -1
  300. package/assets/esri/core/workers/chunks/b4273381dc069f4e1fa2.js +0 -1
  301. package/assets/esri/core/workers/chunks/b72137c63b7f2a525d9e.js +0 -1
  302. package/assets/esri/core/workers/chunks/c2264451d12f1fbaad22.js +0 -1
  303. package/assets/esri/core/workers/chunks/c6c86cbe65a58c3093ae.js +0 -1
  304. package/assets/esri/core/workers/chunks/c8856370bae65d9eeb2b.js +0 -1
  305. package/assets/esri/core/workers/chunks/cd4fb107489594c57438.js +0 -1
  306. package/assets/esri/core/workers/chunks/d28d874c1337b69fedc0.js +0 -1
  307. package/assets/esri/core/workers/chunks/ec922f876e1465d36045.js +0 -1
  308. package/assets/esri/core/workers/chunks/fe3703ec198cbfebec30.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.34/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import{isSome as t}from"../../../core/arrayUtils.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";import{CodedValue as n}from"../../../layers/support/CodedValue.js";import a from"../../../layers/support/CodedValueDomain.js";import"../../../layers/support/Domain.js";import"../../../layers/support/InheritedDomain.js";import s from"../../../layers/support/RangeDomain.js";import{getDomainRange as l,dateTimeFieldValuesToNumericRange as o,isDomainValidForField as u}from"../../../layers/support/domainUtils.js";import{isNumericField as m,isStringField as p,isTimeOnlyField as d,getFieldRange as f,isDateOnlyField as h,isTimestampOffsetField as c}from"../../../layers/support/fieldUtils.js";import{isAnyDateField as y}from"../../../smartMapping/support/utils.js";import{isNumber as g}from"../../../support/guards.js";import{unknown as _,utc as x}from"../../../time/constants.js";import{EditableInput as V}from"./EditableInput.js";import{MultiFeatureError as b,visibilityCodeToBoolean as v,InputVisibilityCode as E,isFieldInputWithShowNoValueOptionInput as D,differentValuesString as F}from"./support/inputUtils.js";import{FieldInputDataTypes as I,getMaxLength as M,getMinLength as N,isEmptyValue as T,dateIsValid as w,validateFormValue as R}from"../../support/forms/formUtils.js";let S=class extends V{constructor(e){super(e),this.group=null,this.type="field",this.userHasChangedValue=!1,this._hasIntersectionWithElementFieldDomain=!1}get compositeError(){if(this.valid)return null;const{errors:e}=this;if(e.length<this.features.length)return b.DIFFERENT_ERRORS;const t=e[0];for(const i of e)if(i.error!==t.error)return b.DIFFERENT_ERRORS;return t.error}get dataType(){const{field:e}=this;return m(e)?I.Number:p(e)?I.Text:y(e)||d(e)?I.Date:I.Unsupported}get domain(){const e=this._allDomains.toArray();return this.calculateDomain(e)}get distinctValues(){if(this.featuresHaveSameValue)return[this.value];const e=new Set;for(const t of this.features)e.add(t.getAttribute(this.fieldName));return Array.from(e)}get editable(){return!!this.field.editable&&(this._evaluatedEditableExpression??!0)}get effectiveVisible(){return v(this.effectiveVisibilityCode)}get effectiveVisibilityCode(){const{visibilityCode:e}=this;if(e!==E.VISIBLE)return e;const{group:t}=this;if(null==t)return e;const i=t.visibilityCode;return i===E.HIDDEN_VISIBILITY_EXPRESSION_ALL?E.HIDDEN_GROUP_VISIBILITY_EXPRESSION_ALL:i===E.HIDDEN_VISIBILITY_EXPRESSION_SOME?E.HIDDEN_GROUP_VISIBILITY_EXPRESSION_SOME:e}get errors(){return this._validate()}get featuresHaveSameValue(){const{fieldName:e}=this,t=this.features.at(0)?.getAttribute(e);return this.features.every((i=>i.getAttribute(e)===t))}get field(){return this.template.field}get fieldName(){return this.field.name}get invalidFeatures(){return this.errors.map((e=>e.feature))}get isSubtypeField(){return this.layers.some((e=>{if(e&&"subtypeField"in e){const{subtypeField:t,fieldsIndex:i}=e;return(i.get(t)?.name??t)===this.fieldName}return!1}))}get showNoValueOptionEnabled(){const{input:e}=this.template;return!this.required&&(!D(e)||!0===e?.showNoValueOption)}get showNoValueLabel(){const{input:e}=this.template;return D(e)?e?.noValueOptionLabel:null}get includeTime(){const{template:e,field:t}=this;return this.dataType===I.Date&&("time-only"===t.type||"date-only"!==t.type&&("datetime-picker"!==e.input?.type||e.input.includeTime))}get includeTimeOffset(){if("timestamp-offset"!==this.field.type)return!1;const e=this.template.input;return!e||"datetimeoffset-picker"===e.type&&e.includeTimeOffset}get maxLength(){return M({dataType:this.dataType,field:this.field,input:this.template.input})}get minLength(){return N({dataType:this.dataType,field:this.field,input:this.template.input})}get range(){if("date"===this.dataType)return this._dateRange;const{domain:e,field:t}=this;if(e){const i=l(t,e);return{max:i?.max,min:i?.min}}const i=this._allDomains.toArray().every((e=>!e))?f(t):null;return{max:i?.max===Number.MAX_VALUE?null:i?.max??null,min:i?.min===-Number.MAX_VALUE?null:i?.min??null}}get required(){if(!this.editable)return!1;if(!this.field.nullable||this.isSubtypeField)return!0;const e=this.visible&&!1!==this.group?.visible,t=this._evaluatedRequiredExpression;return!(!e||null==t)&&t}get submittable(){return(!this.required||!this.distinctValues.some((e=>T(e))))&&!!this.valid}get valid(){return 0===this.errors.length}get value(){return this.featuresHaveSameValue?this.features.at(0)?.getAttribute(this.fieldName)??null:F}get visibilityCode(){return this.field.visible?this._fieldShouldHaveDomain&&null==this.domain?E.HIDDEN_NO_DOMAIN_IN_COMMON:this._baseVisibilityCode:E.HIDDEN_FIELD_DEFINITION}get effectiveTimeZone(){const e=this.template;let t=e.formTimeZone??"system";return e.layerTimeZone?e.layerTimeZone===_?t=x:e.formTimeZone===_&&(t=e.layerTimeZone):e.formTimeZone===_&&(t=x),t}get codedValueDomainOptions(){return"coded-value"===this.domain?.type?this.domain.codedValues.map((({name:e,code:t})=>({name:e,value:t}))):[]}get codedValueOptions(){const e=this.codedValueDomainOptions,{value:t}=this,i=null==t||t===F||e.some((e=>e.value===t))?[]:[{name:`${t}`,value:t}];return[e,i]}get _evaluatedRequiredExpression(){let e=!1,t=!0;const i=this.template;for(const r of this.features){if(null==i.getExpressionExecutorsForLayer(r.layer)?.requiredExpression)continue;t=!1;const n=this._lookupEvaluatedExpression(r,"required");"success"===n?.status?e=e||!0===n.result:e=!0}return t?null:e}get _allDomains(){const e=this.template.domain;return this.features.map((t=>{const i=t.layer.getFieldDomain(this.fieldName,{feature:t.plainGraphic});return"range"===i?.type||"range"===e?.type?i??this.template.domain:i}))}get _fieldShouldHaveDomain(){return!!this._hasIntersectionWithElementFieldDomain||this._allDomains.some(t)}get _dateFormRange(){if("date"!==this.dataType)return{};const e=this.template.input;if(!e)return{};const{type:t}=e;let i={};if("date-picker"!==t&&"time-picker"!==t&&"datetimeoffset-picker"!==t||(i=o(this.field,e.max,e.min)),"datetime-picker"===t){const{max:t,min:r}=e;i={max:null!=t&&w(t)?t.getTime():null,min:null!=r&&w(r)?r.getTime():null}}return{min:i.min,max:i.max,rawMax:i?.rawMax??null,rawMin:i?.rawMin??null}}get _dateRange(){const{_dateFormRange:e,template:t,field:i,domain:r}=this;if("date"!==this.dataType)return{};if(!r)return this._fieldShouldHaveDomain?{}:e;const n=l(i,r);if(!n)return e;const{max:a,min:s,rawMax:o,rawMin:u}=e,{type:m}=t.field;if("date"===m){const{max:e,min:t}=n;return{max:g(a)&&(null===e||null!=e&&a<=e)?a:e??null,min:g(s)&&(null===t||null!=t&&s>=t)?s:t??null}}if("date-only"===m||"time-only"===m||"timestamp-offset"===m){const{max:e,min:t,rawMax:i,rawMin:r}=n,l=g(a)&&o&&(null==e||a<e),m=g(s)&&u&&(null==t||s>t);return{max:l?a:e,min:m?s:t,rawMax:l?o:i,rawMin:m?u:r}}return{}}async setValueFromUser(e){this.userHasChangedValue=!0;const t=[],i=this.fieldName;for(const r of this.features)r.getAttribute(i)!==e&&t.push(r);this._setValue(e),await this.expressionsManager.valueChanged(i,t)}_setValue(e){const{fieldName:t}=this;for(const i of this.features)i.setAttribute(t,e)}_validate(){const{dataType:e,fieldName:t,maxLength:i,minLength:r,range:n}=this,a=[];for(const s of this.features){const{layer:l}=s,o=l.getField(t)??this.field,u=l.getFieldDomain(t,{feature:s.plainGraphic}),m=this.calculateDomain([u]),p=this._requiredForFeature(s),d=s.getAttribute(t),f=R(d,{dataType:e,domain:m,field:o,maxLength:i,minLength:r,range:n,required:p});f&&a.push({error:f,feature:s.source})}return a}_editableForFeature(e){if(!this.field.editable)return!1;if(null==this.template.getExpressionExecutorsForLayer(e.layer)?.editableExpression)return!0;const t=this._lookupEvaluatedExpression(e,"editable");return"success"===t?.status&&!0===t.result}_effectiveVisibleFeature(e){if(this.group&&!this.group.visibleForFeature(e))return!1;if(null==this.template.getExpressionExecutorsForLayer(e.layer)?.visibilityExpression)return!0;const t=this._lookupEvaluatedExpression(e,"visibility");return"success"===t?.status&&!0===t.result}_requiredForFeature(e){if(!this._editableForFeature(e))return!1;if(!this.field.nullable||this.isSubtypeField)return!0;const t=this._effectiveVisibleFeature(e);if(null==this.template.getExpressionExecutorsForLayer(e.layer)?.requiredExpression)return!1;const i=this._lookupEvaluatedExpression(e,"required");return"success"!==i?.status?t:t&&!0===i.result}calculateDomain(e){const t=e.find((e=>null!=e)),i=this.template.domain;if(!t)return i&&u(this.field,i)?i:null;switch(t.type){case"coded-value":if(e.some((e=>!e))){if(!i)return null;e=e.filter((e=>null!==e))}break;case"range":e=e.filter((e=>null!==e))}if(!e.every((e=>e?.type===t?.type)))return null;let r=null;switch(t?.type){case"range":r=this._intersectRangeDomains(e);break;case"coded-value":r=this._intersectCodedValueDomains(e)}return r}_intersectCodedValueDomains(e){if(!e.length)return null;const t=new Map(e[0].codedValues.map((({code:e,name:t})=>[e,t]))),i=this.template.domain?new Map(this.template.domain.codedValues.map((({code:e,name:t})=>[e,t]))):null;for(const n of e)for(const[e,i]of t){n.codedValues.some((t=>t.code===e&&t.name===i))||t.delete(e)}let r=t;if(i){r=new Map;for(const[e,n]of i)t.has(e)&&r.set(e,n)}const s=Array.from(r.entries()).map((([e,t])=>new n({code:e,name:t})));return s.length?new a({codedValues:s}):null}_intersectRangeDomains(e){if(!e.length)return null;let t=e[0];if(e.length>1&&(t=e.reduce(((e,t)=>{const i=this._findMinMaxValuesBetweenTwoDomains(e,t);return i||null}),t)),t&&!u(this.field,t))return null;const{domain:i}=this.template;if(t&&i&&i instanceof s){const e=this._findMinMaxValuesBetweenTwoDomains(t,i);return this._hasIntersectionWithElementFieldDomain=!!e,e}return t}_getMinMaxFromRangeDomain(e){const t=e.minValue,i=e.maxValue,{field:r}=this;return h(r)||d(r)||c(r)?o(r,i,t):{min:null!=t&&"number"==typeof t?t:null,max:null!=i&&"number"==typeof i?i:null}}_findMinMaxValuesBetweenTwoDomains(e,t){const i=new s,r=this._getMinMaxFromRangeDomain(e),n=this._getMinMaxFromRangeDomain(t),{field:a}=this,l=this._getValidRangeValue(r.min,-1/0),o=this._getValidRangeValue(r.max,1/0),u=this._getValidRangeValue(n.min,-1/0),m=this._getValidRangeValue(n.max,1/0);return i.minValue=Math.max(l,u),i.maxValue=Math.min(o,m),i.minValue===-1/0||i.maxValue===1/0||i.minValue>i.maxValue?null:((h(a)||d(a)||c(a))&&(i.minValue=Number(r.min)>Number(n.min)?r.rawMin:n.rawMin,i.maxValue=Number(r.max)<Number(n.max)?r.rawMax:n.rawMax),i.name="intersection",i)}_getValidRangeValue(e,t){return g(e)?e:t}};e([i()],S.prototype,"dataType",null),e([i()],S.prototype,"domain",null),e([i()],S.prototype,"distinctValues",null),e([i()],S.prototype,"editable",null),e([i()],S.prototype,"effectiveVisible",null),e([i()],S.prototype,"effectiveVisibilityCode",null),e([i()],S.prototype,"errors",null),e([i()],S.prototype,"featuresHaveSameValue",null),e([i()],S.prototype,"field",null),e([i()],S.prototype,"fieldName",null),e([i()],S.prototype,"group",void 0),e([i()],S.prototype,"invalidFeatures",null),e([i()],S.prototype,"isSubtypeField",null),e([i()],S.prototype,"showNoValueOptionEnabled",null),e([i()],S.prototype,"includeTime",null),e([i()],S.prototype,"includeTimeOffset",null),e([i()],S.prototype,"maxLength",null),e([i()],S.prototype,"minLength",null),e([i()],S.prototype,"range",null),e([i()],S.prototype,"required",null),e([i()],S.prototype,"submittable",null),e([i({readOnly:!0})],S.prototype,"type",void 0),e([i()],S.prototype,"userHasChangedValue",void 0),e([i()],S.prototype,"valid",null),e([i()],S.prototype,"value",null),e([i()],S.prototype,"visibilityCode",null),e([i()],S.prototype,"effectiveTimeZone",null),e([i()],S.prototype,"_evaluatedRequiredExpression",null),e([i()],S.prototype,"_hasIntersectionWithElementFieldDomain",void 0),e([i()],S.prototype,"_allDomains",null),e([i()],S.prototype,"_fieldShouldHaveDomain",null),e([i()],S.prototype,"_dateFormRange",null),e([i()],S.prototype,"_dateRange",null),S=e([r("esri.widgets.BatchAttributeForm.inputs.FieldInput")],S);export{S as FieldInput};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import{isSome as t}from"../../../core/arrayUtils.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";import{CodedValue as n}from"../../../layers/support/CodedValue.js";import a from"../../../layers/support/CodedValueDomain.js";import"../../../layers/support/Domain.js";import"../../../layers/support/InheritedDomain.js";import s from"../../../layers/support/RangeDomain.js";import{getDomainRange as l,dateTimeFieldValuesToNumericRange as o,isDomainValidForField as u}from"../../../layers/support/domainUtils.js";import{isNumericField as m,isStringField as p,isTimeOnlyField as d,getFieldRange as f,isDateOnlyField as h,isTimestampOffsetField as c}from"../../../layers/support/fieldUtils.js";import{isAnyDateField as y}from"../../../smartMapping/support/utils.js";import{isNumber as g}from"../../../support/guards.js";import{unknown as _,utc as x}from"../../../time/constants.js";import{EditableInput as V}from"./EditableInput.js";import{MultiFeatureError as b,visibilityCodeToBoolean as v,InputVisibilityCode as E,isFieldInputWithShowNoValueOptionInput as D,differentValuesString as F}from"./support/inputUtils.js";import{FieldInputDataTypes as I,getMaxLength as M,getMinLength as N,isEmptyValue as T,dateIsValid as w,validateFormValue as R}from"../../support/forms/formUtils.js";let S=class extends V{constructor(e){super(e),this.group=null,this.type="field",this.userHasChangedValue=!1,this._hasIntersectionWithElementFieldDomain=!1}get compositeError(){if(this.valid)return null;const{errors:e}=this;if(e.length<this.features.length)return b.DIFFERENT_ERRORS;const t=e[0];for(const i of e)if(i.error!==t.error)return b.DIFFERENT_ERRORS;return t.error}get dataType(){const{field:e}=this;return m(e)?I.Number:p(e)?I.Text:y(e)||d(e)?I.Date:I.Unsupported}get domain(){const e=this._allDomains.toArray();return this.calculateDomain(e)}get distinctValues(){if(this.featuresHaveSameValue)return[this.value];const e=new Set;for(const t of this.features)e.add(t.getAttribute(this.fieldName));return Array.from(e)}get editable(){return!!this.field.editable&&(this._evaluatedEditableExpression??!0)}get effectiveVisible(){return v(this.effectiveVisibilityCode)}get effectiveVisibilityCode(){const{visibilityCode:e}=this;if(e!==E.VISIBLE)return e;const{group:t}=this;if(null==t)return e;const i=t.visibilityCode;return i===E.HIDDEN_VISIBILITY_EXPRESSION_ALL?E.HIDDEN_GROUP_VISIBILITY_EXPRESSION_ALL:i===E.HIDDEN_VISIBILITY_EXPRESSION_SOME?E.HIDDEN_GROUP_VISIBILITY_EXPRESSION_SOME:e}get errors(){return this._validate()}get featuresHaveSameValue(){const{fieldName:e}=this,t=this.features.at(0)?.getAttribute(e);return this.features.every((i=>i.getAttribute(e)===t))}get field(){return this.template.field}get fieldName(){return this.field.name}get invalidFeatures(){return this.errors.map((e=>e.feature))}get isSubtypeField(){return this.layers.some((e=>{if(e&&"subtypeField"in e){const{subtypeField:t,fieldsIndex:i}=e;return(i.get(t)?.name??t)===this.fieldName}return!1}))}get showNoValueOptionEnabled(){const{input:e}=this.template;return!this.required&&(!D(e)||!0===e?.showNoValueOption)}get showNoValueLabel(){const{input:e}=this.template;return D(e)?e?.noValueOptionLabel:null}get includeTime(){const{template:e,field:t}=this;return this.dataType===I.Date&&("time-only"===t.type||"date-only"!==t.type&&("datetime-picker"!==e.input?.type||e.input.includeTime))}get includeTimeOffset(){if("timestamp-offset"!==this.field.type)return!1;const e=this.template.input;return!e||"datetimeoffset-picker"===e.type&&e.includeTimeOffset}get maxLength(){return M({dataType:this.dataType,field:this.field,input:this.template.input})}get minLength(){return N({dataType:this.dataType,field:this.field,input:this.template.input})}get range(){if("date"===this.dataType)return this._dateRange;const{domain:e,field:t}=this;if(e){const i=l(t,e);return{max:i?.max,min:i?.min}}const i=this._allDomains.toArray().every((e=>!e))?f(t):null;return{max:i?.max===Number.MAX_VALUE?null:i?.max??null,min:i?.min===-Number.MAX_VALUE?null:i?.min??null}}get required(){if(!this.editable)return!1;if(!this.field.nullable||this.isSubtypeField)return!0;const e=this.visible&&!1!==this.group?.visible,t=this._evaluatedRequiredExpression;return!(!e||null==t)&&t}get submittable(){return(!this.required||!this.distinctValues.some((e=>T(e))))&&!!this.valid}get valid(){return 0===this.errors.length}get value(){return this.featuresHaveSameValue?this.features.at(0)?.getAttribute(this.fieldName)??null:F}get visibilityCode(){return this.field.visible?this._fieldShouldHaveDomain&&null==this.domain?E.HIDDEN_NO_DOMAIN_IN_COMMON:this._baseVisibilityCode:E.HIDDEN_FIELD_DEFINITION}get effectiveTimeZone(){const e=this.template;let t=e.formTimeZone??"system";return e.layerTimeZone?e.layerTimeZone===_?t=x:e.formTimeZone===_&&(t=e.layerTimeZone):e.formTimeZone===_&&(t=x),t}get codedValueDomainOptions(){return"coded-value"===this.domain?.type?this.domain.codedValues.map((({name:e,code:t})=>({name:e,value:t}))):[]}get codedValueOptions(){const e=this.codedValueDomainOptions,{value:t}=this,i=null==t||t===F||e.some((e=>e.value===t))?[]:[{name:`${t}`,value:t}];return[e,i]}get _evaluatedRequiredExpression(){let e=!1,t=!0;const i=this.template;for(const r of this.features){if(null==i.getExpressionExecutorsForLayer(r.layer)?.requiredExpression)continue;t=!1;const n=this._lookupEvaluatedExpression(r,"required");"success"===n?.status?e=e||!0===n.result:e=!0}return t?null:e}get _allDomains(){const e=this.template.domain;return this.features.map((t=>{const i=t.layer.getFieldDomain(this.fieldName,{feature:t.plainGraphic});return"range"===i?.type||"range"===e?.type?i??this.template.domain:i}))}get _fieldShouldHaveDomain(){return!!this._hasIntersectionWithElementFieldDomain||this._allDomains.some(t)}get _dateFormRange(){if("date"!==this.dataType)return{};const e=this.template.input;if(!e)return{};const{type:t}=e;let i={};if("date-picker"!==t&&"time-picker"!==t&&"datetimeoffset-picker"!==t||(i=o(this.field,e.max,e.min)),"datetime-picker"===t){const{max:t,min:r}=e;i={max:null!=t&&w(t)?t.getTime():null,min:null!=r&&w(r)?r.getTime():null}}return{min:i.min,max:i.max,rawMax:i?.rawMax??null,rawMin:i?.rawMin??null}}get _dateRange(){const{_dateFormRange:e,template:t,field:i,domain:r}=this;if("date"!==this.dataType)return{};if(!r)return this._fieldShouldHaveDomain?{}:e;const n=l(i,r);if(!n)return e;const{max:a,min:s,rawMax:o,rawMin:u}=e,{type:m}=t.field;if("date"===m){const{max:e,min:t}=n;return{max:g(a)&&(null===e||null!=e&&a<=e)?a:e??null,min:g(s)&&(null===t||null!=t&&s>=t)?s:t??null}}if("date-only"===m||"time-only"===m||"timestamp-offset"===m){const{max:e,min:t,rawMax:i,rawMin:r}=n,l=g(a)&&o&&(null==e||a<e),m=g(s)&&u&&(null==t||s>t);return{max:l?a:e,min:m?s:t,rawMax:l?o:i,rawMin:m?u:r}}return{}}async setValueFromUser(e){this.userHasChangedValue=!0;const t=[],i=this.fieldName;for(const r of this.features)r.getAttribute(i)!==e&&t.push(r);this._setValue(e),await this.expressionsManager.valueChanged(i,t)}_setValue(e){const{fieldName:t}=this;for(const i of this.features)i.setAttribute(t,e)}_validate(){const{dataType:e,fieldName:t,maxLength:i,minLength:r,range:n}=this,a=[];for(const s of this.features){const{layer:l}=s,o=l.getField(t)??this.field,u=l.getFieldDomain(t,{feature:s.plainGraphic}),m=this.calculateDomain([u]),p=this._requiredForFeature(s),d=s.getAttribute(t),f=R(d,{dataType:e,domain:m,field:o,maxLength:i,minLength:r,range:n,required:p});f&&a.push({error:f,feature:s.source})}return a}_editableForFeature(e){if(!this.field.editable)return!1;if(null==this.template.getExpressionExecutorsForLayer(e.layer)?.editableExpression)return!0;const t=this._lookupEvaluatedExpression(e,"editable");return"success"===t?.status&&!0===t.result}_effectiveVisibleFeature(e){if(this.group&&!this.group.visibleForFeature(e))return!1;if(null==this.template.getExpressionExecutorsForLayer(e.layer)?.visibilityExpression)return!0;const t=this._lookupEvaluatedExpression(e,"visibility");return"success"===t?.status&&!0===t.result}_requiredForFeature(e){if(!this._editableForFeature(e))return!1;if(!this.field.nullable||this.isSubtypeField)return!0;const t=this._effectiveVisibleFeature(e);if(null==this.template.getExpressionExecutorsForLayer(e.layer)?.requiredExpression)return!1;const i=this._lookupEvaluatedExpression(e,"required");return"success"!==i?.status?t:t&&!0===i.result}calculateDomain(e){const t=e.find((e=>null!=e)),i=this.template.domain;if(!t)return i&&u(this.field,i)?i:null;switch(t.type){case"coded-value":if(e.some((e=>!e))){if(!i)return null;e=e.filter((e=>null!==e))}break;case"range":e=e.filter((e=>null!==e))}if(!e.every((e=>e?.type===t?.type)))return null;let r=null;switch(t?.type){case"range":r=this._intersectRangeDomains(e);break;case"coded-value":r=this._intersectCodedValueDomains(e)}return r}_intersectCodedValueDomains(e){if(!e.length)return null;const t=new Map(e[0].codedValues.map((({code:e,name:t})=>[e,t]))),i=this.template.domain?new Map(this.template.domain.codedValues.map((({code:e,name:t})=>[e,t]))):null;for(const n of e)for(const[e,i]of t){n.codedValues.some((t=>t.code===e&&t.name===i))||t.delete(e)}let r=t;if(i){r=new Map;for(const[e,n]of i)t.has(e)&&r.set(e,n)}const s=Array.from(r.entries()).map((([e,t])=>new n({code:e,name:t})));return s.length?new a({codedValues:s}):null}_intersectRangeDomains(e){if(!e.length)return null;let t=e[0];for(let r=1;r<e.length;r++){if(!t)return null;t=this._findMinMaxValuesBetweenTwoDomains(t,e[r])}if(t&&!u(this.field,t))return null;const{domain:i}=this.template;if(t&&i&&i instanceof s){const e=this._findMinMaxValuesBetweenTwoDomains(t,i);return this._hasIntersectionWithElementFieldDomain=!!e,e}return t}_getMinMaxFromRangeDomain(e){const t=e.minValue,i=e.maxValue,{field:r}=this;return h(r)||d(r)||c(r)?o(r,i,t):{min:null!=t&&"number"==typeof t?t:null,max:null!=i&&"number"==typeof i?i:null}}_findMinMaxValuesBetweenTwoDomains(e,t){const i=new s,r=this._getMinMaxFromRangeDomain(e),n=this._getMinMaxFromRangeDomain(t),{field:a}=this,l=this._getValidRangeValue(r.min,-1/0),o=this._getValidRangeValue(r.max,1/0),u=this._getValidRangeValue(n.min,-1/0),m=this._getValidRangeValue(n.max,1/0);return i.minValue=Math.max(l,u),i.maxValue=Math.min(o,m),i.minValue===-1/0||i.maxValue===1/0||i.minValue>i.maxValue?null:((h(a)||d(a)||c(a))&&(i.minValue=Number(r.min)>Number(n.min)?r.rawMin:n.rawMin,i.maxValue=Number(r.max)<Number(n.max)?r.rawMax:n.rawMax),i.name="intersection",i)}_getValidRangeValue(e,t){return g(e)?e:t}};e([i()],S.prototype,"dataType",null),e([i()],S.prototype,"domain",null),e([i()],S.prototype,"distinctValues",null),e([i()],S.prototype,"editable",null),e([i()],S.prototype,"effectiveVisible",null),e([i()],S.prototype,"effectiveVisibilityCode",null),e([i()],S.prototype,"errors",null),e([i()],S.prototype,"featuresHaveSameValue",null),e([i()],S.prototype,"field",null),e([i()],S.prototype,"fieldName",null),e([i()],S.prototype,"group",void 0),e([i()],S.prototype,"invalidFeatures",null),e([i()],S.prototype,"isSubtypeField",null),e([i()],S.prototype,"showNoValueOptionEnabled",null),e([i()],S.prototype,"includeTime",null),e([i()],S.prototype,"includeTimeOffset",null),e([i()],S.prototype,"maxLength",null),e([i()],S.prototype,"minLength",null),e([i()],S.prototype,"range",null),e([i()],S.prototype,"required",null),e([i()],S.prototype,"submittable",null),e([i({readOnly:!0})],S.prototype,"type",void 0),e([i()],S.prototype,"userHasChangedValue",void 0),e([i()],S.prototype,"valid",null),e([i()],S.prototype,"value",null),e([i()],S.prototype,"visibilityCode",null),e([i()],S.prototype,"effectiveTimeZone",null),e([i()],S.prototype,"_evaluatedRequiredExpression",null),e([i()],S.prototype,"_hasIntersectionWithElementFieldDomain",void 0),e([i()],S.prototype,"_allDomains",null),e([i()],S.prototype,"_fieldShouldHaveDomain",null),e([i()],S.prototype,"_dateFormRange",null),e([i()],S.prototype,"_dateRange",null),S=e([r("esri.widgets.BatchAttributeForm.inputs.FieldInput")],S);export{S as FieldInput};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import"../core/has.js";import{getOrCreateMapValue as t}from"../core/MapUtils.js";import{watch as i,on as o}from"../core/reactiveUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as a}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as s}from"../layers/support/fieldUtils.js";import{isString as r}from"../support/guards.js";import l from"./Widget.js";import{getHiddenFieldsValidationErrorMessage as d,getVisibleFieldInputValidationErrorMessage as p,isElementTemplateWithInputType as u}from"./BatchAttributeForm/batchAttributeFormUtils.js";import c from"./BatchAttributeForm/BatchAttributeFormViewModel.js";import{css as m}from"./BatchAttributeForm/css.js";import{VisibleElements as h}from"./BatchAttributeForm/VisibleElements.js";import{InputVisibilityCode as v,isGroupInput as f,isFieldInput as b,differentValuesString as _}from"./BatchAttributeForm/inputs/support/inputUtils.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as g,getIntlOptionsForField as y,prepareISOFieldValueForDateComponents as I,prepareUnixFieldValueForDateComponents as F,normalizeTimeOnlyString as w,getISOFieldValueFromDateComponents as M,getUnixFieldValueFromDateComponents as x}from"./support/dateUtils.js";import{globalCss as O}from"./support/globalCss.js";import{setFocus as T}from"./support/widgetUtils.js";import{messageBundle as k}from"./support/decorators/messageBundle.js";import{vmEvent as D}from"./support/decorators/vmEvent.js";import{tsx as V}from"./support/jsxFactory.js";import{isEmptyValue as E}from"./support/forms/formUtils.js";import{substitute as S}from"../intl/substitute.js";const U="data-element-id";let R=class extends l{constructor(e,t){super(e,t),this.headingLevel=2,this.messagesCommon=null,this.messages=null,this.featureFormMessages=null,this.viewModel=new c,this.visibleElements=new h,this.groupDisplay="all",this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._touchedInputs=new Set,this._focusedFieldInput=null,this._batchSwitchInputInitialValues=new Map,this._saveInput=this._saveInput.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterDateComponentUpdate=this._afterDateComponentUpdate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this)}initialize(){this.addHandles([i((()=>this.features),(()=>{this._dateComponentMap.clear()})),i((()=>this.viewModel.activeForm),(()=>{this._batchSwitchInputInitialValues.clear()})),o((()=>this.viewModel),"submit",(()=>{this.valid||this.goToClosestError()}))])}loadDependencies(){return C({input:()=>import("@esri/calcite-components/dist/components/calcite-input"),block:()=>import("@esri/calcite-components/dist/components/calcite-block"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch"),"text-area":()=>import("@esri/calcite-components/dist/components/calcite-text-area"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group")})}get activeFeatureIndex(){return this.viewModel.activeFeatureIndex}set activeFeatureIndex(e){this.viewModel.activeFeatureIndex=e}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get _effectiveDisabled(){return this.disabled||this.viewModel.updating}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get icon(){return"edit-attributes"}set icon(e){this._overrideIfSome("icon",e)}get readOnly(){return this.viewModel.readOnly}set readOnly(e){this.viewModel.readOnly=e}get valid(){return this.viewModel.valid}goToClosestError(){const e=this.viewModel.getFirstVisibleInvalidFieldInput();if(!e)return;const{groupInput:t}=e;t&&(t.open||(t.open=!0)),this._focusedFieldInput=e.input,this._attemptFocusOnNextRender=!0,this.scheduleRender()}render(){const{status:e}=this.viewModel;return"failed"===e?this.viewModel.hasTooManyComplexFeatures?this._renderErrorNotice(S(this.messages.formFailedToLoadTooManyComplexFeatures,{num:this.viewModel.maximumFeatureCountWithComplexForms})):this.viewModel.hasTooManyFeatures?this._renderErrorNotice(S(this.messages.formFailedToLoadTooManyFeatures,{num:this.viewModel.maximumFeatureCount})):this._renderErrorNotice(this.messages.formFailedToLoad):this.viewModel.expressionEvaluationFailed?this._renderErrorNotice(this.messages.expressionEvaluationFailed):this.viewModel.hasLayersWithContingentValues?this._renderErrorNotice(this.messages.unsupportedContingentValues):V("div",{class:this.classes(m.base,O.widget,O.panel)},"loaded"===e?this._renderForm():"loading"===e&&this.visibleElements.loadingIndicator?V("calcite-loader",{key:"loader",label:this.messagesCommon?.loading}):null)}submit(){this.viewModel.submit()}_setDateTimeTimeZoneMap(e){const{datePart:i,elementId:o}=e.dataset,n=this._getCalciteElementFromDateTimeTimeZonePicker(e,i);if(!n)return;const a=t(this._dateComponentMap,`${o}`,(()=>({placeholder:{date:"",time:"",timeZone:""}})));switch(a.placeholder[i]=n.placeholder??"",i){case"date":a.date=e;break;case"time":a.time=e;break;case"timeZone":a.timeZone=e,a.defaultComboboxItemElements=n.selectedItems}"timeZone"===i&&(a.defaultComboboxItemElements=n.selectedItems)}_getCalciteElementFromDateTimeTimeZonePicker(e,t){const i=e.shadowRoot;return i?"timeZone"===t?i.querySelector("calcite-combobox"):i.querySelector("calcite-input-text"):null}_updateDateTimeOrTimeZoneShadowDom(e,t){const{datePart:i,elementId:o}=e.dataset,n=this._dateComponentMap.get(`${o}`);if(!n)return;const a=this._getCalciteElementFromDateTimeTimeZonePicker(e,i);if(a)switch(i){case"date":case"time":a.placeholder=t?this.messages.differentValuesPlaceholder:n.placeholder[i];break;case"timeZone":t?(a.value="",a.placeholder=this.messages.differentValuesPlaceholder):(!a.selectedItems.length&&n.defaultComboboxItemElements?.length&&(a.selectedItems[0]=n.defaultComboboxItemElements[0]),a.placeholder=n.placeholder[i])}}_renderErrorNotice(e){return V("div",{class:this.classes(m.base,O.widget,O.panel)},V("calcite-notice",{class:m.noticeError,icon:!0,kind:"warning",open:!0},V("div",{slot:"message"},e)))}_renderForm(){return V("form",{onsubmit:this._onFormSubmit},this._renderInvisibleFieldsError(),this._renderContent())}_renderInvisibleFieldsError(){const{viewModel:e}=this,{hasNonActiveInvalidFeatures:t,activeForm:i}=e;let o;if(!e.submitHasBeenAttempted)return null;if(i.invalidHiddenInputs.length>0)if(o=d(i,e.mode,this.messages),"batch"===this.viewModel.mode){const e=i.invalidHiddenInputs.filter((e=>e.effectiveVisibilityCode===v.HIDDEN_GROUP_VISIBILITY_EXPRESSION_ALL||e.visibilityCode===v.HIDDEN_VISIBILITY_EXPRESSION_ALL));e.length>0?o+=` (${e.map((e=>e.label)).join(", ")})`:o=null}else o+=` (${i.invalidHiddenInputs.map((e=>e.label)).join(", ")})`;else if(t)return null;return o?V("calcite-notice",{class:m.noticeError,icon:!0,kind:"danger",open:!0},V("div",{slot:"message"},o)):null}_renderContent(){if(!this.viewModel.hasVisibleInputs)return[V("calcite-notice",{class:m.noticeError,icon:!0,kind:"warning",open:!0},V("div",{slot:"message"},this.messages.noVisibleFields[this.viewModel.noVisibleElementsReason]))];const{inputs:e}=this.viewModel.activeForm;return e.filter((e=>e.visible)).map((e=>this._renderInput(e)))}_renderInput(e){return f(e)?this._renderGroupInput(e):b(e)?this._renderLabeledField(e):void 0}_renderGroupInput(e){const{inputs:t,template:i,open:o}=e,n=t.filter((e=>e.visible)),a=i.label??"";return V("calcite-block",{class:this.classes(m.group,"sequential"===this.groupDisplay?m.groupSequential:null,this.disabled?m.inputDisabled:null),collapsible:!0,description:i.description??void 0,disabled:this._effectiveDisabled,expanded:o,heading:a,headingLevel:this.headingLevel,key:`{${i.elementId}-key}`,label:a,onCalciteBlockClose:()=>{e.open=!1},onCalciteBlockOpen:()=>{e.open=!0}},n.map((e=>this._renderInput(e))))}_renderLabeledField(e){const{label:t,elementId:i}=e.template,{required:o,dataType:n}=e,a=o?S(this.messages.requiredFieldLabel,{name:t}):t;return V("calcite-label",{"aria-label":a,class:m.label,key:`field--${i}`},V("div",{class:m.labelTextContent,key:"labelTextContainer"},t,o?V("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==n?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e))}_renderFieldInput(e){const t=this.getCommonInputProps(e),{dataType:i}=e;return"date"===i?this._renderDateComponents(e,t):"coded-value"===e.domain?.type?this._renderCodedInputs({input:e,props:t}):"number"===i?this._renderNumberComponent(e,t):this._renderStringComponent(e,t)}_renderAuxiliaryText(e){const{compositeError:t,description:i,submittable:o}=e,n=!o&&t&&(this.viewModel.submitHasBeenAttempted||this._touchedInputs.has(e.template.elementId))?p(e,t,this.messages):null;return n?V("calcite-input-message",{icon:!0,status:"invalid"},n):i?V("calcite-input-message",{class:m.description,icon:!1,status:"idle"},i):null}_renderCodedInputs({input:e,props:t}){const i=e.template.input?.type??null,o=e.codedValueOptions;switch(i){case"switch":return this._renderSwitchField({input:e,props:t});case"radio-buttons":return this._renderRadioButtonGroupComponent({input:e,options:o.flat(),props:t});default:return this._renderComboBoxComponent({options:o,props:t,input:e})}}_renderSwitchField({input:e,props:t}){if((this._batchSwitchInputInitialValues.get(e)===_||e.value===_)&&"batch"===this.viewModel.mode){const i={dropdown:{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,disabled:t.readOnly,open:!1,[U]:t[U]},trigger:{appearance:"transparent",iconEnd:"chevron-down",kind:"neutral",slot:"trigger",label:t.label},group:{mode:"single"}};return this._renderDropdownComponent({buttonValue:e.value,dropdownProps:i,options:[{name:this.messages.differentValuesPlaceholder,value:_,disabled:!0},...e.codedValueDomainOptions]})}return this._renderSwitchComponent({input:e,props:t})}_renderSwitchComponent({input:e,props:t}){return V("calcite-switch",{...t,checked:!!u(e.template,"switch")&&e.value===e.template.input.onValue,class:m.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldInput=null},onCalciteSwitchChange:({currentTarget:e})=>this._saveInput(e)})}_renderDropdownComponent({buttonValue:e,options:t,dropdownProps:i}){const{trigger:o,dropdown:n,group:a}=i;return V("calcite-dropdown",{...n,onblur:()=>{this._focusedFieldInput=null},onfocus:this._onComponentFocus,onCalciteDropdownSelect:({currentTarget:e})=>this._saveInput(e)},V("calcite-button",{...o},e===_?this.messages.differentValuesPlaceholder:e),V("calcite-dropdown-group",{selectionMode:a.mode},t.map((t=>V("calcite-dropdown-item",{disabled:t.disabled,label:String(t.name),selected:e===t.value},t.name)))))}_renderComboBoxComponent({input:e,options:t,props:i}){const o="INSERT"===this.viewModel.editType,n=this._touchedInputs.has(e?.template?.elementId),a=o&&e.showNoValueOptionEnabled&&!n?()=>{}:i.onblur,s={...i,onblur:a};return V("calcite-combobox",{...s,selectionMode:"single",value:i.placeholder===this.messages.differentValuesPlaceholder?_:String(i.value),onCalciteComboboxChange:({currentTarget:e})=>{e.value!==_&&this._saveInput(e)}},this.renderComboboxOptionsList({input:e,options:t,props:i}))}renderComboboxOptionsList({input:e,options:t,props:i}){const[o,n]=t.map((e=>e.map((({name:e,value:t})=>V("calcite-combobox-item",{key:`#${t}`,selected:i.value===t,textLabel:e,value:`${t}`}))))),a=[...o];n.length>0&&a.push(V("calcite-combobox-item-group",{key:"unsupported",label:this.featureFormMessages.subtypes.unsupportedDomainGroupTitle},n));const s=i.placeholder===this.messages.differentValuesPlaceholder,r=!s&&E(i.value);return e.showNoValueOptionEnabled&&a.unshift(V("calcite-combobox-item",{key:"empty-option",selected:r,textLabel:e.showNoValueLabel||this.messages.empty,value:""})),s&&a.unshift(V("calcite-combobox-item",{key:_,selected:!0,textLabel:this.messages.differentValuesPlaceholder,value:_})),a}_renderRadioButtonGroupComponent({input:e,options:t,props:i}){const o=t.map((({name:t,value:o})=>this._renderRadioButtons({label:t,value:o,selected:o===e.value,props:i})));if(e.showNoValueOptionEnabled){const t="",n=e.showNoValueLabel||this.messages.empty,a=E(e.value);o.unshift(this._renderRadioButtons({label:n,value:t,selected:a,props:i}))}return V("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:m.inputRadioGroup,disabled:i.readOnly,key:`${i.key}-radio-group`,layout:"vertical",name:i.name,required:i.required},o,i.placeholder===this.messages.differentValuesPlaceholder?V("calcite-label",{class:m.placeholderRadio,key:i.label,layout:"inline"},V("calcite-radio-button",{checked:!0,class:m.inputRadio,disabled:!0,name:i.placeholder,value:i.placeholder}),i.placeholder):null)}_renderRadioButtons({value:e,selected:t,label:i,props:o}){return V("calcite-label",{class:m.inputRadioLabel,key:o.label,layout:"inline"},V("calcite-radio-button",{...o,afterCreate:void 0,afterUpdate:void 0,checked:t,class:m.inputRadio,disabled:o.readOnly,name:o.label,onblur:()=>{this._focusedFieldInput=null},value:e,onCalciteRadioButtonChange:({currentTarget:e})=>{e.checked&&this._saveInput(e)}}),i)}_renderStringComponent(e,t){const{template:i}=e;return!i.field.editable||this.readOnly?this._renderReadOnlyComponent(e):i.input&&"text-area"===i.input.type?V("calcite-text-area",{...t,class:this.classes(m.individualElement),resize:"vertical",value:t.value?String(t.value):"",onCalciteTextAreaInput:({currentTarget:e})=>this._saveInput(e)}):V("calcite-input",{...t,class:this.classes(m.individualElement),type:"text",value:t.value?String(t.value):"",onCalciteInputInput:({currentTarget:e})=>this._saveInput(e)})}_renderNumberComponent(e,t){const i=s(e.field);return V("calcite-input-number",{...t,integer:i,type:"number",value:i&&""!==t.value?Math.round(parseFloat(String(t.value))).toString():String(t.value),onCalciteInputNumberInput:({currentTarget:e})=>this._saveInput(e)})}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return V("calcite-input",{...i,class:this.classes(m.fieldInput,m.inputDisabled,m.individualElement),readOnly:!0,type:"text",value:String(t??i.value??"")})}_renderDateComponents(e,t){const{type:i}=e.field;switch(i){case"date":return this._renderDateFieldComponents(e,t);case"date-only":return this._renderDateOnlyFieldComponent(e,t);case"time-only":return this._renderTimeOnlyFieldComponent(e,t);case"timestamp-offset":return this._renderTimestampOffsetFieldComponents(e,t);default:return this._renderReadOnlyComponent(e,g(e.field,t.value,{timeZone:e.effectiveTimeZone,...y(e.template.field)}))}}_renderDateOnlyFieldComponent(e,t){const{class:i,key:o,readOnly:n}=t,{rawMax:a,rawMin:s}=e.range;return V("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentUpdate,class:i,"data-date-part":"date","data-element-id":t[U],key:`${o}-date-input`,max:r(a)?a:void 0,min:r(s)?s:void 0,onblur:()=>{this._focusedFieldInput=null},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:n,value:e.value===_?"":e.value?String(e.value):"",onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget)})}_renderTimeOnlyFieldComponent(e,t){const{class:i,key:o,readOnly:n}=t;return V("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentUpdate,class:i,"data-date-part":"time","data-element-id":t[U],key:`${o}-time-input`,onblur:()=>{this._focusedFieldInput=null},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:n,value:e.value===_?"":e.value?String(e.value):"",onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget)})}_renderTimestampOffsetFieldComponents(e,t){const{class:i,key:o,readOnly:n}=t,{rawMax:a,rawMin:s}=e.range,r=I(a),l=I(s),d=I(e.value===_?"":e.value),p=e.includeTimeOffset,u={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentUpdate,overlayPositioning:"fixed",readOnly:n,[U]:t[U],onfocus:this._onComponentFocus};return V("div",{class:m.dateInputContainer,key:`${o}-date-time-container`},V("calcite-input-date-picker",{...u,class:i,"data-date-part":"date",key:`${o}-date-input`,max:r?.date??void 0,min:l?.date??void 0,onblur:()=>{this._focusedFieldInput=null},value:d.date??"",onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),V("calcite-input-time-picker",{...u,class:i,"data-date-part":"time",key:`${o}-time-input`,onblur:()=>{this._focusedFieldInput=null},value:d.time??"",onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),p?V("calcite-input-time-zone",{...u,class:i,"data-date-part":"timeZone",key:`${o}-timezone-input`,onblur:()=>{this._focusedFieldInput=null},value:d.timeZoneOffset??"0",onCalciteInputTimeZoneChange:t=>this._saveValueFromDateComponent(e,t.target)}):null)}_renderDateFieldComponents(e,t){const{class:i,key:o,readOnly:n,min:a,max:s}=t,r=e.effectiveTimeZone,l=F(e.value===_?"":e.value,r),d=F(s,r),p=F(a,r),u=e.includeTime,c={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterDateComponentUpdate,overlayPositioning:"fixed",readOnly:n,[U]:t[U],onfocus:this._onComponentFocus};return V("div",{class:m.dateInputContainer,key:`${o}-date-time-container`},V("calcite-input-date-picker",{...c,class:i,"data-date-part":"date",key:`${o}-date-input`,max:d?.date??void 0,min:p?.date??void 0,onblur:()=>{this._focusedFieldInput=null},value:l.date??"",onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),u?V("calcite-input-time-picker",{...c,"data-date-part":"time",key:`${o}-time-input`,onblur:()=>{this._focusedFieldInput=null},step:1,value:l.time??"",onCalciteInputTimePickerChange:t=>{this._saveValueFromDateComponent(e,t.target)}}):null)}getCommonInputProps(e){const{_effectiveDisabled:t}=this,{template:i,valid:o,value:n,minLength:a,maxLength:s,required:r,fieldName:l,editable:d,userHasChangedValue:p,range:{max:u,min:c}}=e,h=!d||t||this.readOnly;let v=i.hint??void 0,f=!1;return n===_&&(v=this.messages.differentValuesPlaceholder,f=!0),{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":o?"false":"true",class:this.classes(m.fieldInput,h?m.inputDisabled:null),status:!p&&!this.viewModel.submitHasBeenAttempted||o?"idle":"invalid",maxLength:s&&s>-1?s:void 0,minLength:a&&a>-1?a:void 0,key:i.elementId,label:l,name:l,max:null!=u?u:void 0,min:null!=c?c:void 0,readOnly:h,onblur:this._onComponentBlur,required:r,placeholder:v,value:f?"":n??"",[U]:i.elementId,onfocus:this._onComponentFocus}}_onFormSubmit(e){e.preventDefault()}_getFieldInputFromHTMLElement(e){return this.viewModel.findFieldInput(e.getAttribute(U))}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),o=t||i;o&&this._afterComponentCreateOrUpdate(o)}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._touchedInputs.add(i.template.elementId),this._focusedFieldInput=i}_afterComponentCreateOrUpdate(e){const t=this._getFieldInputFromHTMLElement(e),i=this._focusedFieldInput;this._attemptFocusOnNextRender&&i===t&&(this._attemptFocusOnNextRender=!1,T(e))}_onComponentBlur(){this._focusedFieldInput=null}_parseValue(e,t){if(u(t.template,"switch")){if("calcite-dropdown"===e.localName&&t.domain)for(const i of t.domain.codedValues)if(i.name===e.selectedItems[0].textContent)return i.code;return e.checked?t.template.input.onValue:t.template.input.offValue}const i=e.value;return null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):"date"===t.field.type?parseFloat(i):i}_saveInput(e){const i=this._getFieldInputFromHTMLElement(e),{elementId:o}=i.template;if(!i)return;const n=i?.value;if(u(i.template,"switch")&&"single"!==this.viewModel.mode){const e=t(this._batchSwitchInputInitialValues,i,(()=>i.value));this._batchSwitchInputInitialValues.set(i,null===e?n:e)}const a=this._parseValue(e,i);a!==n&&this.viewModel.setValue(o,a)}async _afterDateComponentCreate(e){const t=this._getFieldInputFromHTMLElement(e);await e.componentOnReady(),this._setDateTimeTimeZoneMap(e),this._updateDateTimeOrTimeZoneShadowDom(e,t.value===_),this._afterComponentCreateOrUpdate(e)}async _afterDateComponentUpdate(e){const{value:t}=this._getFieldInputFromHTMLElement(e);await e.componentOnReady(),this._updateDateTimeOrTimeZoneShadowDom(e,t===_),this._afterComponentCreateOrUpdate(e)}_saveValueFromDateComponent(e,t){const{elementId:i}=e.template,o=e.field.type,n=this._dateComponentMap.get(`${i}`);if(!n)return;const a=e.effectiveTimeZone;let s=e.value===_?void 0:e.value,r=null;"date-only"===o?r=Array.isArray(t.value)?t.value[0]:t.value:"time-only"===o?(s=w(s),r=w(t.value)):r="timestamp-offset"===o?null!=t.value?M({dateComponent:n.date,timeComponent:n.time,oldValue:s,timeZoneComponent:n.timeZone,defaultTimeZone:a}):null:null!=t.value?x({oldValue:s,dateComponent:n.date,timeZone:a,timeComponent:n.time?.value===_?void 0:n.time}):null,s!==r&&(null!==r&&t.value?this.viewModel.setValue(`${i}`,r):this.viewModel.setValue(`${i}`,null))}};e([n()],R.prototype,"activeFeatureIndex",null),e([n()],R.prototype,"disabled",null),e([n()],R.prototype,"_effectiveDisabled",null),e([n()],R.prototype,"features",null),e([n()],R.prototype,"map",null),e([n()],R.prototype,"spatialReference",null),e([n()],R.prototype,"timeZone",null),e([n()],R.prototype,"headingLevel",void 0),e([n()],R.prototype,"icon",null),e([n(),k("esri/t9n/common")],R.prototype,"messagesCommon",void 0),e([n(),k("esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm")],R.prototype,"messages",void 0),e([n(),k("esri/widgets/FeatureForm/t9n/FeatureForm")],R.prototype,"featureFormMessages",void 0),e([n()],R.prototype,"readOnly",null),e([n()],R.prototype,"valid",null),e([n(),D(["value-change","submit"])],R.prototype,"viewModel",void 0),e([n({type:h,nonNullable:!0})],R.prototype,"visibleElements",void 0),e([n()],R.prototype,"groupDisplay",void 0),R=e([a("esri.widgets.BatchAttributeForm")],R);const L=R;export{L as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import"../core/has.js";import{getOrCreateMapValue as t}from"../core/MapUtils.js";import{watch as i,on as o}from"../core/reactiveUtils.js";import{property as n}from"../core/accessorSupport/decorators/property.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as a}from"../core/accessorSupport/decorators/subclass.js";import{isIntegerField as s}from"../layers/support/fieldUtils.js";import{isString as r}from"../support/guards.js";import l from"./Widget.js";import{getHiddenFieldsValidationErrorMessage as d,getVisibleFieldInputValidationErrorMessage as p,isElementTemplateWithInputType as u}from"./BatchAttributeForm/batchAttributeFormUtils.js";import c from"./BatchAttributeForm/BatchAttributeFormViewModel.js";import{css as m}from"./BatchAttributeForm/css.js";import{VisibleElements as h}from"./BatchAttributeForm/VisibleElements.js";import{InputVisibilityCode as v,isGroupInput as b,isFieldInput as f,differentValuesString as C}from"./BatchAttributeForm/inputs/support/inputUtils.js";import{loadCalciteComponents as _}from"./support/componentsUtils.js";import{getLabelForDateFieldValue as g,getIntlOptionsForField as y,prepareISOFieldValueForDateComponents as I,prepareUnixFieldValueForDateComponents as F,normalizeTimeOnlyString as w,getISOFieldValueFromDateComponents as M,getUnixFieldValueFromDateComponents as x}from"./support/dateUtils.js";import{globalCss as O}from"./support/globalCss.js";import{setFocus as k}from"./support/widgetUtils.js";import{messageBundle as T}from"./support/decorators/messageBundle.js";import{vmEvent as V}from"./support/decorators/vmEvent.js";import{tsx as D}from"./support/jsxFactory.js";import{isEmptyValue as S}from"./support/forms/formUtils.js";import{substitute as E}from"../intl/substitute.js";const R="data-element-id";let U=class extends l{constructor(e,t){super(e,t),this.headingLevel=2,this.messagesCommon=null,this.messages=null,this.featureFormMessages=null,this.viewModel=new c,this.visibleElements=new h,this.groupDisplay="all",this._attemptFocusOnNextRender=!1,this._dateComponentMap=new Map,this._touchedInputs=new Set,this._focusedFieldInput=null,this._batchSwitchInputInitialValues=new Map,this._saveInput=this._saveInput.bind(this),this._onFormSubmit=this._onFormSubmit.bind(this),this._onComponentFocus=this._onComponentFocus.bind(this),this._onComponentBlur=this._onComponentBlur.bind(this),this._afterComponentCreateOrUpdate=this._afterComponentCreateOrUpdate.bind(this),this._afterDateComponentCreate=this._afterDateComponentCreate.bind(this),this._afterRadioGroupCreateOrUpdate=this._afterRadioGroupCreateOrUpdate.bind(this)}initialize(){this.addHandles([i((()=>this.features),(()=>{this._dateComponentMap.clear()})),i((()=>this.viewModel.activeForm),(()=>{this._batchSwitchInputInitialValues.clear()})),o((()=>this.viewModel),"submit",(()=>{this.valid||this.goToClosestError()}))])}loadDependencies(){return _({input:()=>import("@esri/calcite-components/dist/components/calcite-input"),block:()=>import("@esri/calcite-components/dist/components/calcite-block"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),"combobox-item-group":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item-group"),dropdown:()=>import("@esri/calcite-components/dist/components/calcite-dropdown"),"dropdown-group":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-group"),"dropdown-item":()=>import("@esri/calcite-components/dist/components/calcite-dropdown-item"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),"input-number":()=>import("@esri/calcite-components/dist/components/calcite-input-number"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker"),"input-time-zone":()=>import("@esri/calcite-components/dist/components/calcite-input-time-zone"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),"input-message":()=>import("@esri/calcite-components/dist/components/calcite-input-message"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch"),"text-area":()=>import("@esri/calcite-components/dist/components/calcite-text-area"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group")})}get activeFeatureIndex(){return this.viewModel.activeFeatureIndex}set activeFeatureIndex(e){this.viewModel.activeFeatureIndex=e}get disabled(){return this.viewModel.disabled}set disabled(e){this.viewModel.disabled=e}get _effectiveDisabled(){return this.disabled||this.viewModel.updating}get features(){return this.viewModel.features}set features(e){this.viewModel.features=e}get map(){return this.viewModel.map}set map(e){this.viewModel.map=e}get spatialReference(){return this.viewModel.spatialReference}set spatialReference(e){this.viewModel.spatialReference=e}get timeZone(){return this.viewModel.timeZone}set timeZone(e){this.viewModel.timeZone=e}get icon(){return"edit-attributes"}set icon(e){this._overrideIfSome("icon",e)}get readOnly(){return this.viewModel.readOnly}set readOnly(e){this.viewModel.readOnly=e}get valid(){return this.viewModel.valid}goToClosestError(){const e=this.viewModel.getFirstVisibleInvalidFieldInput();if(!e)return;const{groupInput:t}=e;t&&(t.open||(t.open=!0)),this._focusedFieldInput=e.input,this._attemptFocusOnNextRender=!0,this.scheduleRender()}render(){const{status:e}=this.viewModel;return"failed"===e?this.viewModel.hasTooManyComplexFeatures?this._renderErrorNotice(E(this.messages.formFailedToLoadTooManyComplexFeatures,{num:this.viewModel.maximumFeatureCountWithComplexForms})):this.viewModel.hasTooManyFeatures?this._renderErrorNotice(E(this.messages.formFailedToLoadTooManyFeatures,{num:this.viewModel.maximumFeatureCount})):this._renderErrorNotice(this.messages.formFailedToLoad):this.viewModel.expressionEvaluationFailed?this._renderErrorNotice(this.messages.expressionEvaluationFailed):this.viewModel.hasLayersWithContingentValues?this._renderErrorNotice(this.messages.unsupportedContingentValues):D("div",{class:this.classes(m.base,O.widget,O.panel)},"loaded"===e?this._renderForm():"loading"===e&&this.visibleElements.loadingIndicator?D("calcite-loader",{key:"loader",label:this.messagesCommon?.loading}):null)}submit(){this.viewModel.submit()}_setDateTimeTimeZoneMap(e){const{datePart:i,elementId:o}=e.dataset,n=t(this._dateComponentMap,`${o}`,(()=>({})));switch(i){case"date":n.date=e;break;case"time":n.time=e;break;case"timeZone":n.timeZone=e}}_renderErrorNotice(e){return D("div",{class:this.classes(m.base,O.widget,O.panel)},D("calcite-notice",{class:m.noticeError,icon:!0,kind:"warning",open:!0},D("div",{slot:"message"},e)))}_renderForm(){return D("form",{onsubmit:this._onFormSubmit},this._renderInvisibleFieldsError(),this._renderContent())}_renderInvisibleFieldsError(){const{viewModel:e}=this,{hasNonActiveInvalidFeatures:t,activeForm:i}=e;let o;if(!e.submitHasBeenAttempted)return null;if(i.invalidHiddenInputs.length>0)if(o=d(i,e.mode,this.messages),"batch"===this.viewModel.mode){const e=i.invalidHiddenInputs.filter((e=>e.effectiveVisibilityCode===v.HIDDEN_GROUP_VISIBILITY_EXPRESSION_ALL||e.visibilityCode===v.HIDDEN_VISIBILITY_EXPRESSION_ALL));e.length>0?o+=` (${e.map((e=>e.label)).join(", ")})`:o=null}else o+=` (${i.invalidHiddenInputs.map((e=>e.label)).join(", ")})`;else if(t)return null;return o?D("calcite-notice",{class:m.noticeError,icon:!0,kind:"danger",open:!0},D("div",{slot:"message"},o)):null}_renderContent(){if(!this.viewModel.hasVisibleInputs)return[D("calcite-notice",{class:m.noticeError,icon:!0,kind:"warning",open:!0},D("div",{slot:"message"},this.messages.noVisibleFields[this.viewModel.noVisibleElementsReason]))];const{inputs:e}=this.viewModel.activeForm;return e.filter((e=>e.visible)).map((e=>this._renderInput(e)))}_renderInput(e){return b(e)?this._renderGroupInput(e):f(e)?this._renderLabeledField(e):void 0}_renderGroupInput(e){const{inputs:t,template:i,open:o}=e,n=t.filter((e=>e.visible)),a=i.label??"";return D("calcite-block",{class:this.classes(m.group,"sequential"===this.groupDisplay?m.groupSequential:null,this.disabled?m.inputDisabled:null),collapsible:!0,description:i.description??void 0,disabled:this._effectiveDisabled,expanded:o,heading:a,headingLevel:this.headingLevel,key:`{${i.elementId}-key}`,label:a,onCalciteBlockClose:()=>{e.open=!1},onCalciteBlockOpen:()=>{e.open=!0}},n.map((e=>this._renderInput(e))))}_renderLabeledField(e){const{label:t,elementId:i}=e.template,{required:o,dataType:n}=e,a=o?E(this.messages.requiredFieldLabel,{name:t}):t;return D("calcite-label",{"aria-label":a,class:m.label,key:`field--${i}`},D("div",{class:m.labelTextContent,key:"labelTextContainer"},t,o?D("span",{"aria-hidden":"true",title:this.messagesCommon.required},"*"):void 0),"unsupported"!==n?this._renderFieldInput(e):this._renderReadOnlyComponent(e),this._renderAuxiliaryText(e))}_renderFieldInput(e){const t=this.getCommonInputProps(e),{dataType:i}=e;return"date"===i?this._renderDateComponents(e,t):"coded-value"===e.domain?.type?this._renderCodedInputs({input:e,props:t}):"number"===i?this._renderNumberComponent(e,t):this._renderStringComponent(e,t)}_renderAuxiliaryText(e){const{compositeError:t,description:i,submittable:o}=e,n=!o&&t&&(this.viewModel.submitHasBeenAttempted||this._touchedInputs.has(e.template.elementId))?p(e,t,this.messages):null;return n?D("calcite-input-message",{icon:!0,status:"invalid"},n):i?D("calcite-input-message",{class:m.description,icon:!1,status:"idle"},i):null}_renderCodedInputs({input:e,props:t}){const i=e.template.input?.type??null,o=e.codedValueOptions;switch(i){case"switch":return this._renderSwitchField({input:e,props:t});case"radio-buttons":return this._renderRadioButtonGroupComponent({input:e,options:o.flat(),props:t});default:return this._renderComboBoxComponent({options:o,props:t,input:e})}}_renderSwitchField({input:e,props:t}){if((this._batchSwitchInputInitialValues.get(e)===C||e.value===C)&&"batch"===this.viewModel.mode){const i={dropdown:{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,disabled:t.readOnly,open:!1,[R]:t[R]},trigger:{appearance:"transparent",iconEnd:"chevron-down",kind:"neutral",slot:"trigger",label:t.label},group:{mode:"single"}};return this._renderDropdownComponent({buttonValue:e.value,dropdownProps:i,options:[{name:this.messages.differentValuesPlaceholder,value:C,disabled:!0},...e.codedValueDomainOptions]})}return this._renderSwitchComponent({input:e,props:t})}_renderSwitchComponent({input:e,props:t}){return D("calcite-switch",{...t,checked:!!u(e.template,"switch")&&e.value===e.template.input.onValue,class:m.inputSwitch,disabled:t.readOnly,onblur:()=>{this._focusedFieldInput=null},onCalciteSwitchChange:({currentTarget:e})=>this._saveInput(e)})}_renderDropdownComponent({buttonValue:e,options:t,dropdownProps:i}){const{trigger:o,dropdown:n,group:a}=i;return D("calcite-dropdown",{...n,onblur:()=>{this._focusedFieldInput=null},onfocus:this._onComponentFocus,onCalciteDropdownSelect:({currentTarget:e})=>this._saveInput(e)},D("calcite-button",{...o},e===C?this.messages.differentValuesPlaceholder:e),D("calcite-dropdown-group",{selectionMode:a.mode},t.map((t=>D("calcite-dropdown-item",{disabled:t.disabled,label:String(t.name),selected:e===t.value},t.name)))))}_renderComboBoxComponent({input:e,options:t,props:i}){const o="INSERT"===this.viewModel.editType,n=this._touchedInputs.has(e?.template?.elementId),a=o&&e.showNoValueOptionEnabled&&!n?()=>{}:i.onblur,s={...i,onblur:a};return D("calcite-combobox",{...s,selectionMode:"single",value:i.placeholder===this.messages.differentValuesPlaceholder?C:String(i.value),onCalciteComboboxChange:({currentTarget:e})=>{e.value!==C&&this._saveInput(e)}},this.renderComboboxOptionsList({input:e,options:t,props:i}))}renderComboboxOptionsList({input:e,options:t,props:i}){const[o,n]=t.map((e=>e.map((({name:e,value:t})=>D("calcite-combobox-item",{key:`#${t}`,selected:i.value===t,textLabel:e,value:`${t}`}))))),a=[...o];n.length>0&&a.push(D("calcite-combobox-item-group",{key:"unsupported",label:this.featureFormMessages.subtypes.unsupportedDomainGroupTitle},n));const s=i.placeholder===this.messages.differentValuesPlaceholder,r=!s&&S(i.value);return e.showNoValueOptionEnabled&&a.unshift(D("calcite-combobox-item",{key:"empty-option",selected:r,textLabel:e.showNoValueLabel||this.messages.empty,value:""})),s&&a.unshift(D("calcite-combobox-item",{key:C,selected:!0,textLabel:this.messages.differentValuesPlaceholder,value:C})),a}_renderRadioButtonGroupComponent({input:e,options:t,props:i}){const o=t.map((({name:t,value:o})=>this._renderRadioButtons({label:t,value:o,selected:o===e.value,props:i})));if(e.showNoValueOptionEnabled){const t="",n=e.showNoValueLabel||this.messages.empty,a=S(e.value);o.unshift(this._renderRadioButtons({label:n,value:t,selected:a,props:i}))}return D("calcite-radio-button-group",{afterCreate:this._afterRadioGroupCreateOrUpdate,afterUpdate:this._afterRadioGroupCreateOrUpdate,class:m.inputRadioGroup,disabled:i.readOnly,key:`${i.key}-radio-group`,layout:"vertical",name:i.name,required:i.required},o,i.placeholder===this.messages.differentValuesPlaceholder?D("calcite-label",{class:m.placeholderRadio,key:i.label,layout:"inline"},D("calcite-radio-button",{checked:!0,class:m.inputRadio,disabled:!0,name:i.placeholder,value:i.placeholder}),i.placeholder):null)}_renderRadioButtons({value:e,selected:t,label:i,props:o}){return D("calcite-label",{class:m.inputRadioLabel,key:o.label,layout:"inline"},D("calcite-radio-button",{...o,afterCreate:void 0,afterUpdate:void 0,checked:t,class:m.inputRadio,disabled:o.readOnly,name:o.label,onblur:()=>{this._focusedFieldInput=null},value:e,onCalciteRadioButtonChange:({currentTarget:e})=>{e.checked&&this._saveInput(e)}}),i)}_renderStringComponent(e,t){const{template:i}=e;return!i.field.editable||this.readOnly?this._renderReadOnlyComponent(e):i.input&&"text-area"===i.input.type?D("calcite-text-area",{...t,class:this.classes(m.individualElement),resize:"vertical",value:t.value?String(t.value):"",onCalciteTextAreaInput:({currentTarget:e})=>this._saveInput(e)}):D("calcite-input",{...t,class:this.classes(m.individualElement),type:"text",value:t.value?String(t.value):"",onCalciteInputInput:({currentTarget:e})=>this._saveInput(e)})}_renderNumberComponent(e,t){const i=s(e.field);return D("calcite-input-number",{...t,integer:i,type:"number",value:i&&""!==t.value?Math.round(parseFloat(String(t.value))).toString():String(t.value),onCalciteInputNumberInput:({currentTarget:e})=>this._saveInput(e)})}_renderReadOnlyComponent(e,t){const i=this.getCommonInputProps(e);return D("calcite-input",{...i,class:this.classes(m.fieldInput,m.inputDisabled,m.individualElement),readOnly:!0,type:"text",value:String(t??i.value??"")})}_renderDateComponents(e,t){const{field:i}=e;let o;switch(i.type){case"date":o=this._renderDateFieldComponents(e,t);break;case"date-only":o=this._renderDateOnlyFieldComponent(e,t);break;case"time-only":o=this._renderTimeOnlyFieldComponent(e,t);break;case"timestamp-offset":o=this._renderTimestampOffsetFieldComponents(e,t);break;default:o=this._renderReadOnlyComponent(e,g(i,t.value,{timeZone:e.effectiveTimeZone,...y(e.template.field)}))}return e.value===C?[o,D("calcite-input-message",{icon:"information",key:"diff-values-message",status:"idle"},this.messages.differentValues)]:o}_renderDateOnlyFieldComponent(e,t){const{class:i,key:o,readOnly:n}=t,{rawMax:a,rawMin:s}=e.range;return D("calcite-input-date-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,class:i,"data-date-part":"date","data-element-id":t[R],key:`${o}-date-input`,max:r(a)?a:void 0,min:r(s)?s:void 0,onblur:()=>{this._focusedFieldInput=null},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:n,value:e.value===C?"":e.value?String(e.value):"",onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget)})}_renderTimeOnlyFieldComponent(e,t){const{class:i,key:o,readOnly:n}=t;return D("calcite-input-time-picker",{afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,class:i,"data-date-part":"time","data-element-id":t[R],key:`${o}-time-input`,onblur:()=>{this._focusedFieldInput=null},onfocus:this._onComponentFocus,overlayPositioning:"fixed",readOnly:n,value:e.value===C?"":e.value?String(e.value):"",onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.currentTarget)})}_renderTimestampOffsetFieldComponents(e,t){const{class:i,key:o,readOnly:n}=t,{rawMax:a,rawMin:s}=e.range,r=I(a),l=I(s),d=I(e.value===C?"":e.value),p=e.includeTimeOffset,u={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,overlayPositioning:"fixed",readOnly:n,[R]:t[R],onfocus:this._onComponentFocus};return D("div",{class:m.dateInputContainer,key:`${o}-date-time-container`},D("calcite-input-date-picker",{...u,class:i,"data-date-part":"date",key:`${o}-date-input`,max:r?.date??void 0,min:l?.date??void 0,onblur:()=>{this._focusedFieldInput=null},value:d.date??"",onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),D("calcite-input-time-picker",{...u,class:i,"data-date-part":"time",key:`${o}-time-input`,onblur:()=>{this._focusedFieldInput=null},value:d.time??"",onCalciteInputTimePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),p?D("calcite-input-time-zone",{...u,class:i,clearable:e.value===C||null==e.value,"data-date-part":"timeZone",key:`${o}-timezone-input`,onblur:()=>{this._focusedFieldInput=null},value:d.timeZoneOffset||"",onCalciteInputTimeZoneChange:t=>this._saveValueFromDateComponent(e,t.target)}):null)}_renderDateFieldComponents(e,t){const{class:i,key:o,readOnly:n,min:a,max:s}=t,r=e.effectiveTimeZone,l=F(e.value===C?"":e.value,r),d=F(s,r),p=F(a,r),u=e.includeTime,c={afterCreate:this._afterDateComponentCreate,afterUpdate:this._afterComponentCreateOrUpdate,overlayPositioning:"fixed",readOnly:n,[R]:t[R],onfocus:this._onComponentFocus};return D("div",{class:m.dateInputContainer,key:`${o}-date-time-container`},D("calcite-input-date-picker",{...c,class:i,"data-date-part":"date",key:`${o}-date-input`,max:d?.date??void 0,min:p?.date??void 0,onblur:()=>{this._focusedFieldInput=null},value:l.date??"",onCalciteInputDatePickerChange:t=>this._saveValueFromDateComponent(e,t.target)}),u?D("calcite-input-time-picker",{...c,"data-date-part":"time",key:`${o}-time-input`,onblur:()=>{this._focusedFieldInput=null},step:1,value:l.time??"",onCalciteInputTimePickerChange:t=>{this._saveValueFromDateComponent(e,t.target)}}):null)}getCommonInputProps(e){const{_effectiveDisabled:t}=this,{template:i,valid:o,value:n,minLength:a,maxLength:s,required:r,fieldName:l,editable:d,userHasChangedValue:p,range:{max:u,min:c}}=e,h=!d||t||this.readOnly;let v=i.hint??void 0,b=!1;return n===C&&(v=this.messages.differentValuesPlaceholder,b=!0),{afterCreate:this._afterComponentCreateOrUpdate,afterUpdate:this._afterComponentCreateOrUpdate,"aria-invalid":o?"false":"true",class:this.classes(m.fieldInput,h?m.inputDisabled:null),status:!p&&!this.viewModel.submitHasBeenAttempted||o?"idle":"invalid",maxLength:s&&s>-1?s:void 0,minLength:a&&a>-1?a:void 0,key:i.elementId,label:l,name:l,max:null!=u?u:void 0,min:null!=c?c:void 0,readOnly:h,onblur:this._onComponentBlur,required:r,placeholder:v,value:b?"":n??"",[R]:i.elementId,onfocus:this._onComponentFocus}}_onFormSubmit(e){e.preventDefault()}_getFieldInputFromHTMLElement(e){return this.viewModel.findFieldInput(e.getAttribute(R))}_afterRadioGroupCreateOrUpdate(e){const t=e.selectedItem,i=e.querySelector("calcite-radio-button"),o=t||i;o&&this._afterComponentCreateOrUpdate(o)}_onComponentFocus(e){const t=e.target,i=this._getFieldInputFromHTMLElement(t);this._touchedInputs.add(i.template.elementId),this._focusedFieldInput=i}_afterComponentCreateOrUpdate(e){const t=this._getFieldInputFromHTMLElement(e),i=this._focusedFieldInput;this._attemptFocusOnNextRender&&i===t&&(this._attemptFocusOnNextRender=!1,k(e))}_onComponentBlur(){this._focusedFieldInput=null}_parseValue(e,t){if(u(t.template,"switch")){if("calcite-dropdown"===e.localName&&t.domain)for(const i of t.domain.codedValues)if(i.name===e.selectedItems[0].textContent)return i.code;return e.checked?t.template.input.onValue:t.template.input.offValue}const i=e.value;return null==i||""===i?null:"number"===t.dataType?"-0"===i||"-0."===i||"-0,"===i?i:parseFloat(i):"date"===t.field.type?parseFloat(i):i}_saveInput(e){const i=this._getFieldInputFromHTMLElement(e),{elementId:o}=i.template;if(!i)return;const n=i?.value;if(u(i.template,"switch")&&"single"!==this.viewModel.mode){const e=t(this._batchSwitchInputInitialValues,i,(()=>i.value));this._batchSwitchInputInitialValues.set(i,null===e?n:e)}const a=this._parseValue(e,i);a!==n&&this.viewModel.setValue(o,a)}async _afterDateComponentCreate(e){this._setDateTimeTimeZoneMap(e),this._afterComponentCreateOrUpdate(e)}_saveValueFromDateComponent(e,t){const{elementId:i}=e.template,o=e.field.type,n=this._dateComponentMap.get(`${i}`);if(!n)return;const a=e.effectiveTimeZone;let s=e.value===C?void 0:e.value,r=null;"date-only"===o?r=Array.isArray(t.value)?t.value[0]:t.value:"time-only"===o?(s=w(s),r=w(t.value)):r="timestamp-offset"===o?null!=t.value?M({dateComponent:n.date,timeComponent:n.time,oldValue:s,timeZoneComponent:n.timeZone,defaultTimeZone:a}):null:null!=t.value?x({oldValue:s,dateComponent:n.date,timeZone:a,timeComponent:n.time?.value===C?void 0:n.time}):null,s!==r&&(null!==r&&t.value?this.viewModel.setValue(`${i}`,r):this.viewModel.setValue(`${i}`,null))}};e([n()],U.prototype,"activeFeatureIndex",null),e([n()],U.prototype,"disabled",null),e([n()],U.prototype,"_effectiveDisabled",null),e([n()],U.prototype,"features",null),e([n()],U.prototype,"map",null),e([n()],U.prototype,"spatialReference",null),e([n()],U.prototype,"timeZone",null),e([n()],U.prototype,"headingLevel",void 0),e([n()],U.prototype,"icon",null),e([n(),T("esri/t9n/common")],U.prototype,"messagesCommon",void 0),e([n(),T("esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm")],U.prototype,"messages",void 0),e([n(),T("esri/widgets/FeatureForm/t9n/FeatureForm")],U.prototype,"featureFormMessages",void 0),e([n()],U.prototype,"readOnly",null),e([n()],U.prototype,"valid",null),e([n(),V(["value-change","submit"])],U.prototype,"viewModel",void 0),e([n({type:h,nonNullable:!0})],U.prototype,"visibleElements",void 0),e([n()],U.prototype,"groupDisplay",void 0),U=e([a("esri.widgets.BatchAttributeForm")],U);const L=U;export{L 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.34/esri/copyright.txt for details.
4
4
  */
5
- import{_ as o}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import{property as e}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";let r=class extends t{constructor(){super(...arguments),this.editRouteButton=!0,this.layerDetails=!0,this.saveAsButton=!0,this.saveButton=!0}};o([e({type:Boolean,nonNullable:!0})],r.prototype,"editRouteButton",void 0),o([e({type:Boolean,nonNullable:!0})],r.prototype,"layerDetails",void 0),o([e({type:Boolean,nonNullable:!0})],r.prototype,"saveAsButton",void 0),o([e({type:Boolean,nonNullable:!0})],r.prototype,"saveButton",void 0),r=o([s("esri.widgets.Directions.DirectionsVisibleElements")],r);const i=r;export{i as default};
5
+ import{_ as o}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import{property as e}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";let r=class extends t{constructor(){super(...arguments),this.editRouteButton=!0,this.layerDetails=!0,this.printButton=!0,this.saveAsButton=!0,this.saveButton=!0}};o([e({type:Boolean,nonNullable:!0})],r.prototype,"editRouteButton",void 0),o([e({type:Boolean,nonNullable:!0})],r.prototype,"layerDetails",void 0),o([e({type:Boolean,nonNullable:!0})],r.prototype,"printButton",void 0),o([e({type:Boolean,nonNullable:!0})],r.prototype,"saveAsButton",void 0),o([e({type:Boolean,nonNullable:!0})],r.prototype,"saveButton",void 0),r=o([s("esri.widgets.Directions.DirectionsVisibleElements")],r);const n=r;export{n 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.34/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import{isSome as t}from"../core/arrayUtils.js";import i from"../core/Collection.js";import{addEventListener as s}from"../core/events.js";import{makeHandle as o}from"../core/handleUtils.js";import{destroyMaybe as r}from"../core/maybe.js";import{debounce as n,isAbortError as a}from"../core/promiseUtils.js";import{watch as l,initial as c,on as d}from"../core/reactiveUtils.js";import{escapeRegExpString as h}from"../core/string.js";import{property as p}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import{onLocaleChange as u,getLocaleParts as v}from"../intl/locale.js";import _ from"../portal/Portal.js";import{defaultUnitPropertyMetadata as g}from"../properties/defaultUnit.js";import w from"../rest/support/Stop.js";import y from"../symbols/SimpleMarkerSymbol.js";import b from"./Search.js";import S from"./Widget.js";import{css as f}from"./Directions/css.js";import{DirectionsSearchTool as k}from"./Directions/DirectionsSearchTool.js";import C from"./Directions/DirectionsViewModel.js";import D from"./Directions/DirectionsVisibleElements.js";import{formatDistance as M,formatDuration as I,DepartureTimeOption as T,getIconName as F}from"./Directions/support/directionsUtils.js";import{isArcGISWorldGeocoder as P,meteredArcGISLocatorUrl as x}from"./Search/support/locatorUtils.js";import{loadCalciteComponents as E}from"./support/componentsUtils.js";import{globalCss as R}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as L}from"./support/decorators/messageBundle.js";import{tsx as A}from"./support/jsxFactory.js";function O(e){const{branchName:i,displayText:s,exitName:o,intersectingName:r,name:n,towardName:a}=e;if(null==s)return null;const l=[i,o,r,n,a].filter(t).sort(((e,t)=>t.length-e.length)).map((e=>h(e)));if(!l.length)return s;const c=new RegExp(l.join("|"),"g"),d=s.matchAll(c);let p=0;const m=[];for(const{0:t,index:h}of d)m.push(s.slice(p,h),A("span",{class:f.labelEmphasize,key:`maneuver-${h}`},t)),p=h+t.length;return m.push(s.slice(p)),A("span",null,m)}let N=class extends S{constructor(e,t){super(e,t),this._activeManeuver=null,this._placeholderStops=new i([new w,new w]),this._portalFolderCombobox=null,this._portalFolders=null,this._portalItemNameInput=null,this._portalUserName=null,this._printDocument=null,this._printDocumentParent=null,this._sections=null,this._stopsToSearches=new Map,this._printDocumentOpen=!1,this._currentFlowItem="primary",this._parentFlowItem="primary",this._saveState="initialized",this._searchTool=null,this.headingLevel=2,this.messages=null,this.messagesUnits=null,this.searchProperties=null,this.viewModel=new C,this.visibleElements=new D,this._solveRouteDebounced=n((()=>this._solveRoute()))}initialize(){this.addHandles([l((()=>this.viewModel.layer),(()=>{try{this.viewModel.load()}catch{}}),c),l((()=>this.viewModel.layer?.routeInfo),(()=>{this._sections=this._getStopSections()}),c),l((()=>this.viewModel.layer?.stops.toArray()),(e=>{e&&this.view?.activeTool&&this._searchTool&&this.view.activeTool===this._searchTool&&!e.includes(this._searchTool.stop)&&(this.view.tools.remove(this._searchTool),this._searchTool=null)})),s(window,"beforeprint",this._beforePrint.bind(this)),s(window,"afterprint",this._afterPrint.bind(this))])}loadDependencies(){return E({accordion:()=>import("@esri/calcite-components/dist/components/calcite-accordion"),"accordion-item":()=>import("@esri/calcite-components/dist/components/calcite-accordion-item"),action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu"),"block-section":()=>import("@esri/calcite-components/dist/components/calcite-block-section"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch")})}destroy(){this._stopsToSearches.forEach(r)}get apiKey(){return this.viewModel.apiKey}set apiKey(e){this.viewModel.apiKey=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get icon(){return"right"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get lastRoute(){return this.viewModel.lastRoute}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get maxStops(){return this.viewModel.maxStops}set maxStops(e){this.viewModel.maxStops=e}get unit(){return this.defaultUnit}set unit(e){this._overrideIfSome("unit",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}acquireSearch(e){const{view:t}=this.viewModel;if(this._stopsToSearches.has(e)){const i=this._stopsToSearches.get(e);return i.view=t,this._overrideDefaultSources(i),i}const i=new b({icon:!1,popupEnabled:!1,resultGraphicEnabled:!1,view:t,...this.searchProperties});return this._normalizeSearchSources(i),this.addHandles([d((()=>i.allSources),"change",(()=>this._normalizeSearchSources(i))),i.on("search-clear",(()=>{e.geometry=null,e.name=null,this.viewModel.layer?.removeResult()})),i.on("select-result",(()=>{const t=i.selectedResult;e.geometry=t?.feature.geometry,e.name=t?.name,this._solveRouteDebounced()})),l((()=>i.searchTerm),(t=>{e.name=t})),u((()=>this._normalizeSearchSources(i)))],i),this._stopsToSearches.set(e,i),i}getDirections(){return this.viewModel.getDirections()}render(){return A("div",{class:this.classes(f.base,R.widget,R.panel)},A("calcite-flow",null,this._renderPrimaryFlowItem(),this._renderDirectionsFlowItem(),this._renderEditFlowItem(),this._renderSaveFlowItem()),this._renderPrintDocument())}save(){return this.viewModel.save()}saveAs(e,t={}){return this.viewModel.saveAs(e,t)}zoomToRoute(){return this.viewModel.zoomToRoute()}_afterPrint(){this._printDocumentOpen&&this._printDocument&&this._printDocumentParent?.appendChild(this._printDocument)}_applyLocatorSourceOverrides({allSources:e}){for(const t of e)"url"in t&&t.url&&(t.language=v()?.language,t.locationType??="street",P(t.url)&&this.apiKey&&null==t.apiKey&&(t.apiKey=this.apiKey,t.url=x))}_beforePrint(){this._printDocumentOpen&&this._printDocument&&document.body.appendChild(this._printDocument)}_disposeSearch(e){if(!e||!this._stopsToSearches.has(e))return;const t=this._stopsToSearches.get(e);this.removeHandles(t),t.destroy(),this._stopsToSearches.delete(e)}_getEffectiveStops(){return this.viewModel.layer?.stops??this._placeholderStops}_getErrorDescription(){switch(this.viewModel.lastError?.name){case"directions-view-model:unable-to-route":return this.messages.errors.unableToRoute;case"directions-view-model:service-metadata-unavailable":return this.messages.errors.unableToLoadServiceMetadata;default:return this.messages.errors.unknownError}}_getNetworkFeatureName(e){switch(e.type){case"stop":switch(e.locationType){case"stop":default:return this.messages.networkFeatures.stops.stop;case"waypoint":return this.messages.networkFeatures.stops.waypoint;case"break":return this.messages.networkFeatures.stops.break}case"point-barrier":return this.messages.networkFeatures.pointBarrier;case"polyline-barrier":return this.messages.networkFeatures.polylineBarrier;case"polygon-barrier":return this.messages.networkFeatures.polygonBarrier}}_getRouteCostSummary(){const e=this.viewModel.layer?.routeInfo;if(!e)return null;const t=e.totalDistance??0,i=e.totalDuration??0,{messagesUnits:s,unit:o}=this;return{distance:M(s,t,o),duration:I(i)}}_getStopCostDescription(e){if(!e.directions.length)return;const{totalDistance:t,totalDuration:i}=e.directions.reduce(((e,{lines:t})=>{for(const{distance:i,duration:s}of t)e.totalDistance+=i??0,e.totalDuration+=s??0;return e}),{totalDistance:0,totalDuration:0}),{messagesUnits:s,unit:o}=this,r=M(s,t,o);return`${I(i)} (${r})`}_getStopSections(){if(!this.viewModel.layer)return null;const{directionPoints:e,directionLines:t,stops:i}=this.viewModel.layer;if(!e||!t)return null;const s=[];let o=null;for(const r of e){const{objectId:e,stopId:n}=r;if(null!=n){const e=i.find((({objectId:e})=>e===n));o&&o.stop===e||(o={stop:e,directions:[]},s.push(o));continue}if(null==o)continue;const a=t.toArray().filter((({directionPointId:t})=>t===e));0!==a.length&&o.directions.push({directionPoint:r,lines:a})}return s}_handleAddStopClick(){const e=new y;this.viewModel.layer?.stops.add(new w({symbol:e}))}_handleAutoSolveChange({target:e}){this.viewModel.autoSolve=e.checked}_handleCreatePolylineBarrierClick(){this.viewModel.create("polyline-barrier")}_handleClearRouteClick(){this._currentFlowItem="primary",this.viewModel.reset()}_handleCreateStopClick(){this.viewModel.create("stop")}_handleDeleteNetworkFeatureClick(e){this.viewModel.remove(e),this.viewModel.autoSolve&&this._solveRouteDebounced()}_handleDeleteStopClick(e){this._getEffectiveStops().remove(e),this._disposeSearch(e),this._solveRouteDebounced()}_handleDepartureDateChange({currentTarget:{value:e}}){Array.isArray(e)||(this.viewModel.departureIsoDate=e,this._solveRouteDebounced())}_handleDepartureTimeChange({currentTarget:{value:e}}){this.viewModel.departureIsoTime=e,this._solveRouteDebounced()}_handleDepartureTimeOptionChange({currentTarget:e}){const{selectedItems:t}=e;t.length&&(this.viewModel.departureOption=t[0].value,this._solveRouteDebounced())}_handleDirectionsFlowItemBackClick(e){e.stopPropagation(),this._currentFlowItem="primary"}_handleDirectionTurnItemSelect(e){this._activeManeuver===e?this.zoomToRoute():(this._activeManeuver=e,this.viewModel.centerAt(e.geometry))}_handleDirectionTurnPointerEnter(e){this.viewModel.highlight(e)}_handleDirectionTurnPointerLeave(){this.viewModel.clearHighlights()}_handleEditFlowItemBackClick(e){e.stopPropagation(),this.viewModel.stopEditing(),this._currentFlowItem="primary"}_handleEditingDoneClick(){this.viewModel.stopEditing(),this._currentFlowItem="primary"}_handleEditRouteClick(){this._currentFlowItem="edit",this.viewModel.startEditing()}_handleItemDetailsClick(){const e=this.viewModel.layer?.portalItem;e&&window.open(`${e.portal.url}/home/item.html?id=${e.id}`,"_blank")}_handleLocateStopClick(e){const{view:t}=this;if(!t)return;const i="directions-search-tool";this.removeHandles(i),this._searchTool=new k({stop:e,view:t}),this.addHandles([this._searchTool.on("click",(async t=>{if(t.mapPoint&&this._stopsToSearches.has(e)){const i=this._stopsToSearches.get(e),s=await i.search(t.mapPoint),o=s?.results?.[0].results?.[0];if(o){const{feature:t,name:s}=o;i.searchTerm=s,e.geometry=t.geometry}}this.removeHandles(i)})),o((()=>{this._searchTool&&(this.view?.tools.remove(this._searchTool),this._searchTool=null)}))],i),t.addAndActivateTool(this._searchTool)}_handleOptimizeStopOrderToggle({target:{expanded:e}}){this.viewModel.routeParameters.findBestSequence=e,this._solveRouteDebounced()}_handlePanToStopClick(e){this.viewModel.centerAt(e)}_handlePreserveFirstStopChange({target:{checked:e}}){this.viewModel.routeParameters.preserveFirstStop=e,this._solveRouteDebounced()}_handlePreserveLastStopChange({target:{checked:e}}){this.viewModel.routeParameters.preserveLastStop=e,this._solveRouteDebounced()}_handlePrintDocumentAfterCreate(e){e.focus(),this._printDocument=e,this._printDocumentParent=e.parentElement}_handlePrintDocumentClick(){this._printDocumentOpen=!0}_handlePrintDocumentCloseClick(){this._printDocumentOpen=!1}_handlePrintDocumentKeyDown(e){"Escape"===e.key&&(this._printDocumentOpen=!1)}_handlePrintDocumentPrintClick(){document.body.classList.add(f.printMedia),window.print(),document.body.classList.remove(f.printMedia)}_handleResolveRouteClick(){this._solveRouteDebounced()}_handleReverseStopOrderClick(){this._getEffectiveStops().reverse(),this._solveRouteDebounced()}_handleSaveErrorCloseClick(){this._currentFlowItem=this._parentFlowItem}_handleSaveFlowItemBackClick(e){e.stopPropagation(),this._currentFlowItem=this._parentFlowItem}async _handleSaveLayerAs(){const e=_.getDefault();try{await e.signIn()}catch(t){if(a(t)||"identity-manager:user-aborted"===t.name)return;return this._parentFlowItem=this._currentFlowItem,this._currentFlowItem="save",void(this._saveState="connect-to-portal-error")}this._saveState="fetch-portal-information",this._parentFlowItem=this._currentFlowItem,this._currentFlowItem="save",this._portalUserName=e.user?.username;try{this._portalFolders=await(e.user?.fetchFolders())}catch{return void(this._saveState="fetch-portal-information-error")}this._saveState="save-layer"}_handleSaveLayerClick(){this.viewModel.layer?.save()}_handleSaveLayerButtonClick(){this._saveState="saving";const{layer:e}=this;if(!e||!this._portalFolders)return;const t=this._portalItemNameInput?.value,i=this._portalFolderCombobox?.value,s=this._portalFolders.find((({id:e})=>e===i));e.saveAs({title:t},{folder:s}).then((()=>{e.title=t,this._currentFlowItem=this._parentFlowItem})).catch((()=>{this._saveState="saving-error"}))}_handleSaveLayerCancelClick(){this._currentFlowItem=this._parentFlowItem}_handleSaveLayerFolderCreate(e){this._portalFolderCombobox=e}_handleSaveLayerNameCreate(e){this._portalItemNameInput=e}_handleSignInClick(){this.viewModel.load().catch((()=>{}))}_handleStopListReorder({detail:{dragEl:e,newIndex:t}}){this._getEffectiveStops().reorder(e.value,t),this._solveRouteDebounced()}_handleTravelModeChange({currentTarget:{selectedItems:e}}){e.length&&(this.viewModel.selectedTravelMode=e[0].value,this._solveRouteDebounced())}_handleViewDrivingDirectionsClick(){this._currentFlowItem="directions"}_normalizeSearchSources(e){this._overrideDefaultSources(e),this._applyLocatorSourceOverrides(e)}_overrideDefaultSources(e){for(const t of e.viewModel.defaultSources)t.autoNavigate=!1}_renderClearRouteAction(e){return A("calcite-action",{bind:this,icon:"trash",key:"clear-route",onclick:this._handleClearRouteClick,...e,text:this.messages.common.clear,textEnabled:!0})}_renderDeleteStopAction(e){return A("calcite-action",{icon:"trash",onclick:this._handleDeleteStopClick.bind(this,e),scale:"s",slot:"actions-end",text:this.messages.deleteStop,title:this.messages.deleteStop})}_renderDepartureTime(){const{DEPART_AT:e,NOW:t,UNSPECIFIED:i}=T;return A("calcite-label",{class:f.departureTime,key:"departure-time"},this.messages.departureTime,A("calcite-combobox",{bind:this,clearDisabled:!0,label:this.messages.departureTime,overlayPositioning:"fixed",selectionMode:"single-persist",onCalciteComboboxChange:this._handleDepartureTimeOptionChange},A("calcite-combobox-item",{heading:this.messages.leaveNow,key:t,label:this.messages.leaveNow,selected:this.viewModel.departureOption===t,value:t}),A("calcite-combobox-item",{heading:this.messages.departAt,key:e,label:this.messages.departAt,selected:this.viewModel.departureOption===e,value:e}),A("calcite-combobox-item",{heading:this.messages.timeUnspecified,key:i,label:this.messages.timeUnspecified,selected:this.viewModel.departureOption===i,value:i})))}_renderDepartureTimeOptions(){return this.viewModel.departureOption!==T.DEPART_AT?null:A("div",{class:f.departureTimeOptions},A("calcite-input-date-picker",{bind:this,scale:"s",value:this.viewModel.departureIsoDate,onCalciteInputDatePickerChange:this._handleDepartureDateChange}),A("calcite-input-time-picker",{bind:this,scale:"s",value:this.viewModel.departureIsoTime,onCalciteInputTimePickerClose:this._handleDepartureTimeChange}))}_renderDirectionsFlowItem(){if("directions"!==this._currentFlowItem)return null;const e=this._getRouteCostSummary();if(!this._sections||!e)return null;const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel,o=this._sections.at(0)?.stop.name??"",r=this._sections.at(-1)?.stop.name??"";return A("calcite-flow-item",{bind:this,key:"directions-flow-item",overlayPositioning:"fixed",selected:"directions"===this._currentFlowItem,onCalciteFlowItemBack:this._handleDirectionsFlowItemBackClick},A("div",{class:f.directionsHeader,slot:"header-content"},A("div",{class:f.headerStops},A("span",null,this.messages.from)," ",A("span",{class:f.directionsHeaderStopName},o),A("span",null,this.messages.to)," ",A("span",{class:f.directionsHeaderStopName},r)),A("div",{class:f.flexColumn},A("span",null,`${i} (${t})`),s?A("span",null,s):null)),this._renderRouteLayerActions({slot:"header-menu-actions"}),A("calcite-accordion",{class:f.accordion,iconPosition:"start",selectionMode:"single"},this._sections.map(((e,t)=>this._renderDirectionSection(e,t)))))}_renderDirectionSection(e,t){const{stop:i,directions:s}=e,{name:o}=i,r=0===t,n=this._getStopCostDescription(e);return A("calcite-accordion-item",{description:n,expanded:r,heading:o??"",key:`stop-${t}`},A("calcite-action",{icon:"zoom-to-object",onclick:this._handlePanToStopClick.bind(this,i),slot:"actions-end",text:this.messages.panToStop,title:this.messages.panToStop}),this._renderDirectionTurns(s))}_renderDirectionTurns(e){return A("calcite-list",{label:this.messages.drivingDirections,selectionMode:"none"},e.map(((e,t)=>{const{directionPoint:i,lines:s}=e,o=s[0],{distance:r,duration:n}=o,a=M(this.messagesUnits,r??0,this.unit),l=I(n??0),c=a&&l?`${a} | ${l}`:`${a||l}`,d=O(i),h=F(i.directionPointType);return A("calcite-list-item",{class:f.labelNoBottomMargin,key:`driving-direction-${t}`,onpointerenter:this._handleDirectionTurnPointerEnter.bind(this,o),onpointerleave:this._handleDirectionTurnPointerLeave.bind(this),onCalciteListItemSelect:this._handleDirectionTurnItemSelect.bind(this,o)},A("calcite-icon",{icon:h,slot:"content-start"}),A("div",{slot:"content"},A("calcite-label",{layout:"inline",scale:"s"},d),A("calcite-label",{layout:"inline",scale:"s"},c)))})))}_renderEditFlowItem(){return"edit"!==this._currentFlowItem?null:A("calcite-flow-item",{bind:this,heading:this.messages.editRoute,headingLevel:this.headingLevel,key:"edit-flow-item",loading:"routing"===this.viewModel.state,selected:"edit"===this._currentFlowItem,onCalciteFlowItemBack:this._handleEditFlowItemBackClick},A("div",{class:f.flexColumn,key:"edit-container"},A("div",{class:f.editToolbarContainer},A("calcite-label",{layout:"inline",scale:"s"},this.messages.automaticallySolve,A("calcite-switch",{bind:this,checked:this.viewModel.autoSolve,scale:"s",onCalciteSwitchChange:this._handleAutoSolveChange})),A("div",{class:f.editToolbar},A("calcite-action",{bind:this,disabled:!this.viewModel.layer||this.viewModel.layer.stops.length>=this.maxStops,icon:"flag",onclick:this._handleCreateStopClick,scale:"s",text:this.messages.networkFeatures.stops.stop,textEnabled:!0}),A("calcite-action",{bind:this,icon:"line",onclick:this._handleCreatePolylineBarrierClick,scale:"s",text:this.messages.barrier,textEnabled:!0}),A("calcite-action",{bind:this,class:f.solveRoute,disabled:this.viewModel.autoSolve,icon:"refresh",onclick:this._handleResolveRouteClick,scale:"s",text:this.messages.solve,textEnabled:!0}))),A("div",{class:f.selectedFeatureContainer},A("calcite-list",{label:this.messages.selectedNetworkFeatures,scale:"s",selectionMode:"none"},this.viewModel.selectedNetworkFeatures?.toArray().map(((e,t)=>A("calcite-list-item",{description:this._getNetworkFeatureName(e),key:`network-feature-${t}`,label:e.name??e.objectId?.toString()??this.messages.unnamed},A("calcite-action",{icon:"trash",onclick:this._handleDeleteNetworkFeatureClick.bind(this,e),scale:"s",slot:"actions-end",text:this.messages.common.delete})))))),A("div",{class:f.editFooter},this._renderEditFooterContent())))}_renderEditFooterContent(){return this.viewModel.lastError?this._renderErrorNotice():A("calcite-button",{appearance:"outline-fill",bind:this,onclick:this._handleEditingDoneClick,width:"full"},this.messages.common.done)}_renderErrorNotice(){return A("calcite-notice",{icon:"exclamation-mark-circle",kind:"danger",open:!0},A("calcite-label",{class:f.labelNoBottomMargin,slot:"message"},this._getErrorDescription()))}_renderFooter(){if(!this.viewModel.layer)return A("div",{class:f.primaryFooter,key:"footer-missing-layer"},A("calcite-notice",{icon:"information",open:!0},A("calcite-label",{class:f.labelNoBottomMargin,slot:"message"},this.messages.missingLayer)));if("unauthenticated"===this.viewModel.state)return A("div",{class:f.primaryFooterCentered,key:"footer-sign-in"},A("calcite-label",null,this.messages.signInRequired),A("calcite-button",{bind:this,onclick:this._handleSignInClick},this.messages.common.auth.signIn));if("routing"===this.viewModel.state)return A("div",{class:this.classes(f.primaryFooter,f.primaryFooterLoader),key:"footer-routing"},A("calcite-loader",{label:this.messages.solve,scale:"s"}));if("error"===this.viewModel.state)return A("div",{class:f.primaryFooter,key:"footer-service-error"},this._renderErrorNotice());if(!this.viewModel.layer?.routeInfo)return A("div",{class:f.primaryFooter,key:"footer-unsolved-route"},A("calcite-notice",{icon:"information",open:!0},A("calcite-label",{class:f.labelNoBottomMargin,slot:"message"},this.messages.directionsPlaceholder)));const e=this._getRouteCostSummary();if(!e||!this.viewModel.layer?.directionPoints)return A("div",{class:f.primaryFooter,key:"footer-invalid-route"},A("calcite-notice",{icon:"exclamation-mark-triangle",kind:"danger",open:!0},A("calcite-label",{class:f.labelNoBottomMargin,slot:"message"},this.messages.invalidRoute)));const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel;return A("div",{class:f.routeItem,key:"footer-directions-summary"},A("button",{"aria-busy":"false","aria-label":this.messages.viewDrivingDirections,"aria-live":"polite",bind:this,class:f.routeItemButton,onclick:this._handleViewDrivingDirectionsClick,title:this.messages.viewDrivingDirections,type:"button"},A("div",{class:f.routeItemButtonContent},A("span",{class:f.routeItemLabel},`${i} (${t})`),A("span",{class:f.routeItemDescription},s)),A("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s"})),A("calcite-action-menu",{label:"test"},A("calcite-action",{icon:"ellipsis",key:"route-actions",slot:"trigger",text:"Route actions"}),this._renderRouteLayerActions()))}_renderInteractiveRouteActions(){return A("div",{class:f.actionContainer,key:f.actionContainer},A("calcite-button",{appearance:"outline",bind:this,class:f.addStopButton,disabled:this._getEffectiveStops().length>=this.maxStops,iconStart:"plus",kind:"neutral",label:this.messages.addStop,onclick:this._handleAddStopClick,title:this.messages.addStop,width:"half"},this.messages.addStop),this.visibleElements.editRouteButton?A("calcite-button",{appearance:"outline",bind:this,class:f.editRouteButton,disabled:"2d"!==this.viewModel.view?.type,iconStart:"pencil",kind:"neutral",label:this.messages.editRoute,onclick:this._handleEditRouteClick,title:this.messages.editRoute,width:"half"},this.messages.editRoute):null)}_renderLocateStopAction(e){if(null!=e.name||null!=e.geometry)return null;const t=this._getEffectiveStops().indexOf(e),i=!!this.view?.activeTool&&this.view.activeTool===this._searchTool&&this._searchTool.stop===e;return A("calcite-action",{active:i,icon:"crosshair",key:`stop-location-action-${t}`,onclick:this._handleLocateStopClick.bind(this,e),scale:"s",slot:"actions-end",text:this.messages.pickALocationOnTheMap,title:this.messages.pickALocationOnTheMap})}_renderOptimizeStopOrder(){const{routeParameters:e}=this.viewModel,{findBestSequence:t,preserveFirstStop:i,preserveLastStop:s}=e;return A("calcite-block-section",{bind:this,class:f.optimizeSection,text:this.messages.optimizeOrder,toggleDisplay:"switch",onCalciteBlockSectionToggle:this._handleOptimizeStopOrderToggle},t?[A("calcite-label",{class:f.optimizeSwitches,key:"preserve-first-stop",layout:"inline-space-between"},this.messages.preserveFirstStop,A("calcite-switch",{bind:this,checked:i,scale:"s",onCalciteSwitchChange:this._handlePreserveFirstStopChange})),A("calcite-label",{class:f.optimizeSwitches,key:"preserve-last-stop",layout:"inline-space-between"},this.messages.preserveLastStop,A("calcite-switch",{bind:this,checked:s,scale:"s",onCalciteSwitchChange:this._handlePreserveLastStopChange}))]:null)}_renderPrimaryFlowItem(){return A("calcite-flow-item",{key:"primary-flow-item",loading:"initializing"===this.viewModel.state,selected:"primary"===this._currentFlowItem},A("calcite-panel",{class:f.primaryFlowItem,disabled:!this.viewModel.layer||"unauthenticated"===this.viewModel.state||"error"===this.viewModel.state&&!this.viewModel.serviceDescription},this._renderStops(),this._renderInteractiveRouteActions(),this._renderSeparator(),this._renderRouteSolveOptions()),this._renderFooter())}_renderPrintDocument(){if(!this._printDocumentOpen)return null;const e=this._getRouteCostSummary();if(!this._sections||!e)return null;const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel,o=this._sections.at(0)?.stop.name??"",r=this._sections.at(-1)?.stop.name??"";return A("div",{afterCreate:this._handlePrintDocumentAfterCreate,bind:this,class:f.printDocument,onkeydown:this._handlePrintDocumentKeyDown,tabindex:0},A("div",{class:f.printBody},A("div",{class:f.printHeader},A("div",{class:f.printHeaderLabel},A("div",{class:f.headerStops},A("span",null,this.messages.from)," ",A("span",{class:f.directionsHeaderStopName},o),A("span",null,this.messages.to)," ",A("span",{class:f.directionsHeaderStopName},r))),A("div",{class:this.classes(f.printHeaderButtons,f.printHideOnPrint)},A("calcite-button",{class:f.printDocumentPrint,iconStart:"print",onclick:this._handlePrintDocumentPrintClick},this.messages.common.print),A("calcite-button",{appearance:"outline",bind:this,class:f.printDocumentClose,iconStart:"x-circle",onclick:this._handlePrintDocumentCloseClick},this.messages.common.close))),A("div",{class:f.directionsHeader},A("span",null,`${i} (${t})`),s?A("span",null,s):null),this._sections.map(((e,t)=>this._renderPrintSection(e,t)))))}_renderPrintManuever(e,t){const{directionPoint:i,lines:s}=e,{distance:o,duration:r}=s.at(0)??{},n=M(this.messagesUnits,o??0,this.unit),a=I(r??0),l=n&&a?`${n} | ${a}`:`${n||a}`,c=O(i),d=F(i.directionPointType);return A("div",{class:this.classes(f.flexRow,f.printAvoidPageBreak),key:`direction-${t}`},A("calcite-icon",{icon:d}),A("div",{class:f.flexColumn},A("span",null,c),A("span",null,l)))}_renderPrintRouteAction(e){const t=!this.viewModel.layer?.routeInfo;return A("calcite-action",{bind:this,disabled:t,icon:"print",key:"print-route",onclick:this._handlePrintDocumentClick,...e,text:this.messages.common.print,textEnabled:!0})}_renderPrintSection({stop:e,directions:t},i){return A("div",{class:f.printSection,key:`section-${i}`},A("span",{class:f.directionsHeaderStopName},e.name??""),t.map(((e,t)=>this._renderPrintManuever(e,t))))}_renderRouteLayerActions(e){return[this._renderClearRouteAction(e),this._renderSaveLayerAction(e),this._renderSaveLayerAsAction(e),this._renderPrintRouteAction(e),this._renderViewItemDetailsAction(e)]}_renderRouteSolveOptions(){return A("div",{class:f.marginInlineMedium,key:"route-solve-options"},this._renderTravelModes(),this._renderDepartureTime(),this._renderDepartureTimeOptions(),this._renderOptimizeStopOrder())}_renderSaveContent(){switch(this._saveState){case"initialized":return this._renderSaveInitialized();case"connect-to-portal":return this._renderSaveProcessing(this.messages.identity.lblSigning);case"connect-to-portal-error":return this._renderSaveError(this.messages.errors.authenticating);case"fetch-portal-information":return this._renderSaveProcessing(this.messages.processing.fetching);case"fetch-portal-information-error":return this._renderSaveError(this.messages.errors.fetching);case"save-layer":return this._renderSaveLayerSettings();case"saving":return this._renderSaveProcessing(this.messages.processing.saving);case"saving-error":return this._renderSaveError(this.messages.errors.saving)}}_renderSaveError(e){return A("calcite-panel",{class:f.paddingMedium,key:"save-layer-error"},A("div",{class:f.saveError},A("calcite-icon",{class:f.saveErrorIcon,icon:"exclamation-mark-triangle",scale:"l",textLabel:this.messages.common.errorMessage}),A("calcite-label",{class:f.saveErrorLabel},e)),A("calcite-button",{appearance:"outline",bind:this,onclick:this._handleSaveErrorCloseClick,slot:"footer-actions",width:"full"},this.messages.common.close))}_renderSaveInitialized(){return A("calcite-panel",{class:f.paddingMedium,key:"save-layer-initialized"})}_renderSaveFlowItem(){return"save"!==this._currentFlowItem?null:A("calcite-flow-item",{bind:this,heading:this.messages.saveLayer,headingLevel:this.headingLevel,key:"save-layer-flow-item",selected:"save"===this._currentFlowItem,onCalciteFlowItemBack:this._handleSaveFlowItemBackClick},this._renderSaveContent())}_renderSaveLayerAction(e){if(!this.visibleElements.saveButton)return null;const t=this.viewModel.layer,i=t?.routeInfo,s=t?.portalItem?.itemControl;return A("calcite-action",{bind:this,disabled:!(!!i&&("admin"===s||"update"===s)),icon:"save",key:"save-route",onclick:this._handleSaveLayerClick,...e,text:this.messages.common.save,textEnabled:!0})}_renderSaveLayerAsAction(e){if(!this.visibleElements.saveAsButton)return null;const t=!this.viewModel.layer?.routeInfo;return A("calcite-action",{disabled:t,icon:"save-as",key:"save-as-route",onclick:()=>{this._handleSaveLayerAs()},...e,text:this.messages.common.saveAs,textEnabled:!0})}_renderSaveLayerSettings(){if(null==this.layer||null==this._portalFolders||null==this._portalUserName)return this._renderSaveInitialized();const{stops:e}=this.layer,t=`${e.at(0).name} - ${e.at(-1).name}`,i=[A("calcite-combobox-item",{heading:`${this._portalUserName} (${this.messages.common.home})`,key:f.folderHome,selected:!0,value:f.folderHome}),...this._portalFolders.map((e=>A("calcite-combobox-item",{heading:e.title??"",key:`${f.folder}-${e.id}`,value:e.id})))];return A("calcite-panel",{key:"save-layer-panel"},A("div",{class:f.paddingMedium},A("calcite-label",null,this.messages.layerName,A("calcite-input",{afterCreate:this._handleSaveLayerNameCreate,bind:this,label:this.messages.layerName,value:t})),A("calcite-label",null,this.messages.saveInFolder,A("calcite-combobox",{afterCreate:this._handleSaveLayerFolderCreate,bind:this,clearDisabled:!0,label:this.messages.saveInFolder,overlayPositioning:"fixed",selectionMode:"single-persist"},i))),A("calcite-button",{bind:this,onclick:this._handleSaveLayerButtonClick,slot:"footer-actions",width:"full"},this.messages.common.save),A("calcite-button",{appearance:"outline",bind:this,onclick:this._handleSaveLayerCancelClick,slot:"footer-actions",width:"full"},this.messages.common.cancel))}_renderSaveProcessing(e){return A("calcite-panel",{class:f.marginInlineMedium,key:"save-layer-processing"},A("calcite-loader",{class:f.saveProcessLoader,label:e,text:e}))}_renderSeparator(){return A("div",{class:f.separator})}_renderStop(e){const t=this.acquireSearch(e);null!=e.name&&(t.searchTerm=e.name);const i=this._getEffectiveStops(),s=this._renderLocateStopAction(e),o=i.length>2&&this._renderDeleteStopAction(e);return A("calcite-list-item",{key:e,value:e},s,o,A("div",{class:f.stopItem,slot:"content"},t.render()))}_renderStops(){const e=this._getEffectiveStops();for(const t of this._stopsToSearches.keys())e.includes(t)||this._disposeSearch(t);return A("div",{class:f.stopContainer,key:f.stopContainer},A("calcite-list",{bind:this,class:f.stopList,dragEnabled:!0,label:this.messages.widgetLabel,scale:"s",onCalciteListOrderChange:this._handleStopListReorder},e.toArray().map((e=>this._renderStop(e)))),2===e.length&&A("calcite-action",{bind:this,icon:"arrow-up-down",onclick:this._handleReverseStopOrderClick,scale:"s",text:this.messages.reverseStops,title:this.messages.reverseStops}))}_renderTravelMode(e){const{id:t,name:i}=e;return A("calcite-combobox-item",{heading:i,key:t,label:i,selected:this.viewModel.selectedTravelMode?.id===t,value:e})}_renderTravelModes(){return this.viewModel.travelModes.length?A("calcite-label",{key:"travel-modes"},this.messages.mode,A("calcite-combobox",{bind:this,clearDisabled:!0,label:this.messages.mode,overlayPositioning:"fixed",selectionMode:"single-persist",onCalciteComboboxChange:this._handleTravelModeChange},this.viewModel.travelModes.map((e=>this._renderTravelMode(e))))):null}_renderViewItemDetailsAction(e){return this.visibleElements.layerDetails?A("calcite-action",{bind:this,disabled:!this.viewModel.layer?.portalItem,icon:"launch",key:"open-route-details-link",onclick:this._handleItemDetailsClick,...e,text:this.messages.viewLayerDetails,textEnabled:!0}):null}async _solveRoute(){this.viewModel.updateDepartureTime();if(!((this.viewModel.layer?.stops.filter((({geometry:e})=>!!e)).length??0)<2))try{await this.viewModel.getDirections()}catch{}}};e([p()],N.prototype,"_printDocumentOpen",void 0),e([p()],N.prototype,"_currentFlowItem",void 0),e([p()],N.prototype,"_saveState",void 0),e([p()],N.prototype,"_searchTool",void 0),e([p()],N.prototype,"apiKey",null),e([p(g)],N.prototype,"defaultUnit",void 0),e([p()],N.prototype,"goToOverride",null),e([p()],N.prototype,"headingLevel",void 0),e([p()],N.prototype,"icon",null),e([p()],N.prototype,"label",null),e([p({readOnly:!0})],N.prototype,"lastRoute",null),e([p()],N.prototype,"layer",null),e([p()],N.prototype,"maxStops",null),e([p(),L("esri/widgets/Directions/t9n/Directions")],N.prototype,"messages",void 0),e([p(),L("esri/core/t9n/Units")],N.prototype,"messagesUnits",void 0),e([p()],N.prototype,"searchProperties",void 0),e([p()],N.prototype,"unit",null),e([p()],N.prototype,"view",null),e([p({type:C})],N.prototype,"viewModel",void 0),e([p({type:D,nonNullable:!0})],N.prototype,"visibleElements",void 0),N=e([m("esri.widgets.Directions")],N);const j=N;export{j as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import{isSome as t}from"../core/arrayUtils.js";import i from"../core/Collection.js";import{addEventListener as s}from"../core/events.js";import{makeHandle as o}from"../core/handleUtils.js";import{destroyMaybe as r}from"../core/maybe.js";import{debounce as n,isAbortError as a}from"../core/promiseUtils.js";import{watch as l,initial as c,on as d}from"../core/reactiveUtils.js";import{escapeRegExpString as h}from"../core/string.js";import{property as p}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import{subclass as m}from"../core/accessorSupport/decorators/subclass.js";import{onLocaleChange as u,getLocaleLanguage as v}from"../intl/locale.js";import _ from"../portal/Portal.js";import{defaultUnitPropertyMetadata as g}from"../properties/defaultUnit.js";import w from"../rest/support/Stop.js";import y from"../symbols/SimpleMarkerSymbol.js";import b from"./Search.js";import S from"./Widget.js";import{css as f}from"./Directions/css.js";import{DirectionsSearchTool as k}from"./Directions/DirectionsSearchTool.js";import C from"./Directions/DirectionsViewModel.js";import D from"./Directions/DirectionsVisibleElements.js";import{formatDistance as M,formatDuration as I,DepartureTimeOption as T,getIconName as F}from"./Directions/support/directionsUtils.js";import{isArcGISWorldGeocoder as P,meteredArcGISLocatorUrl as x}from"./Search/support/locatorUtils.js";import{loadCalciteComponents as E}from"./support/componentsUtils.js";import{globalCss as R}from"./support/globalCss.js";import"./support/widgetUtils.js";import{messageBundle as L}from"./support/decorators/messageBundle.js";import{tsx as A}from"./support/jsxFactory.js";function O(e){const{branchName:i,displayText:s,exitName:o,intersectingName:r,name:n,towardName:a}=e;if(null==s)return null;const l=[i,o,r,n,a].filter(t).sort(((e,t)=>t.length-e.length)).map((e=>h(e)));if(!l.length)return s;const c=new RegExp(l.join("|"),"g"),d=s.matchAll(c);let p=0;const m=[];for(const{0:t,index:h}of d)m.push(s.slice(p,h),A("span",{class:f.labelEmphasize,key:`maneuver-${h}`},t)),p=h+t.length;return m.push(s.slice(p)),A("span",null,m)}let N=class extends S{constructor(e,t){super(e,t),this._activeManeuver=null,this._placeholderStops=new i([new w,new w]),this._portalFolderCombobox=null,this._portalFolders=null,this._portalItemNameInput=null,this._portalUserName=null,this._printDocument=null,this._printDocumentParent=null,this._sections=null,this._stopsToSearches=new Map,this._printDocumentOpen=!1,this._currentFlowItem="primary",this._parentFlowItem="primary",this._saveState="initialized",this._searchTool=null,this.headingLevel=2,this.messages=null,this.messagesUnits=null,this.searchProperties=null,this.viewModel=new C,this.visibleElements=new D,this._solveRouteDebounced=n((()=>this._solveRoute()))}initialize(){this.addHandles([l((()=>this.viewModel.layer),(()=>{try{this.viewModel.load()}catch{}}),c),l((()=>this.viewModel.layer?.routeInfo),(()=>{this._sections=this._getStopSections()}),c),l((()=>this.viewModel.layer?.stops.toArray()),(e=>{e&&this.view?.activeTool&&this._searchTool&&this.view.activeTool===this._searchTool&&!e.includes(this._searchTool.stop)&&(this.view.tools.remove(this._searchTool),this._searchTool=null)})),s(window,"beforeprint",this._beforePrint.bind(this)),s(window,"afterprint",this._afterPrint.bind(this))])}loadDependencies(){return E({accordion:()=>import("@esri/calcite-components/dist/components/calcite-accordion"),"accordion-item":()=>import("@esri/calcite-components/dist/components/calcite-accordion-item"),action:()=>import("@esri/calcite-components/dist/components/calcite-action"),"action-menu":()=>import("@esri/calcite-components/dist/components/calcite-action-menu"),"block-section":()=>import("@esri/calcite-components/dist/components/calcite-block-section"),button:()=>import("@esri/calcite-components/dist/components/calcite-button"),combobox:()=>import("@esri/calcite-components/dist/components/calcite-combobox"),"combobox-item":()=>import("@esri/calcite-components/dist/components/calcite-combobox-item"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),input:()=>import("@esri/calcite-components/dist/components/calcite-input"),"input-date-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-date-picker"),"input-time-picker":()=>import("@esri/calcite-components/dist/components/calcite-input-time-picker"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),list:()=>import("@esri/calcite-components/dist/components/calcite-list"),"list-item":()=>import("@esri/calcite-components/dist/components/calcite-list-item"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice"),panel:()=>import("@esri/calcite-components/dist/components/calcite-panel"),switch:()=>import("@esri/calcite-components/dist/components/calcite-switch")})}destroy(){this._stopsToSearches.forEach(r)}get apiKey(){return this.viewModel.apiKey}set apiKey(e){this.viewModel.apiKey=e}get goToOverride(){return this.viewModel.goToOverride}set goToOverride(e){this.viewModel.goToOverride=e}get icon(){return"right"}set icon(e){this._overrideIfSome("icon",e)}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get lastRoute(){return this.viewModel.lastRoute}get layer(){return this.viewModel.layer}set layer(e){this.viewModel.layer=e}get maxStops(){return this.viewModel.maxStops}set maxStops(e){this.viewModel.maxStops=e}get unit(){return this.defaultUnit}set unit(e){this._overrideIfSome("unit",e)}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}acquireSearch(e){const{view:t}=this.viewModel;if(this._stopsToSearches.has(e)){const i=this._stopsToSearches.get(e);return i.view=t,this._overrideDefaultSources(i),i}const i=new b({icon:"",popupEnabled:!1,resultGraphicEnabled:!1,view:t,...this.searchProperties});return this._normalizeSearchSources(i),this.addHandles([d((()=>i.allSources),"change",(()=>this._normalizeSearchSources(i))),i.on("search-clear",(()=>{e.geometry=null,e.name=null,this.viewModel.layer?.removeResult()})),i.on("select-result",(()=>{const t=i.selectedResult;e.geometry=t?.feature.geometry,e.name=t?.name,this._solveRouteDebounced()})),l((()=>i.searchTerm),(t=>{e.name=t})),u((()=>this._normalizeSearchSources(i)))],i),this._stopsToSearches.set(e,i),i}getDirections(){return this.viewModel.getDirections()}render(){return A("div",{class:this.classes(f.base,R.widget,R.panel)},A("calcite-flow",null,this._renderPrimaryFlowItem(),this._renderDirectionsFlowItem(),this._renderEditFlowItem(),this._renderSaveFlowItem()),this._renderPrintDocument())}save(){return this.viewModel.save()}saveAs(e,t={}){return this.viewModel.saveAs(e,t)}zoomToRoute(){return this.viewModel.zoomToRoute()}_afterPrint(){this._printDocumentOpen&&this._printDocument&&this._printDocumentParent?.appendChild(this._printDocument)}_applyLocatorSourceOverrides({allSources:e}){for(const t of e)"url"in t&&t.url&&(t.language=v(),t.locationType??="street",P(t.url)&&this.apiKey&&null==t.apiKey&&(t.apiKey=this.apiKey,t.url=x))}_beforePrint(){this._printDocumentOpen&&this._printDocument&&document.body.appendChild(this._printDocument)}_disposeSearch(e){if(!e||!this._stopsToSearches.has(e))return;const t=this._stopsToSearches.get(e);this.removeHandles(t),t.destroy(),this._stopsToSearches.delete(e)}_getEffectiveStops(){return this.viewModel.layer?.stops??this._placeholderStops}_getErrorDescription(){switch(this.viewModel.lastError?.name){case"directions-view-model:unable-to-route":return this.messages.errors.unableToRoute;case"directions-view-model:service-metadata-unavailable":return this.messages.errors.unableToLoadServiceMetadata;default:return this.messages.errors.unknownError}}_getNetworkFeatureName(e){switch(e.type){case"stop":switch(e.locationType){case"stop":default:return this.messages.networkFeatures.stops.stop;case"waypoint":return this.messages.networkFeatures.stops.waypoint;case"break":return this.messages.networkFeatures.stops.break}case"point-barrier":return this.messages.networkFeatures.pointBarrier;case"polyline-barrier":return this.messages.networkFeatures.polylineBarrier;case"polygon-barrier":return this.messages.networkFeatures.polygonBarrier}}_getRouteCostSummary(){const e=this.viewModel.layer?.routeInfo;if(!e)return null;const t=e.totalDistance??0,i=e.totalDuration??0,{messagesUnits:s,unit:o}=this;return{distance:M(s,t,o),duration:I(i)}}_getStopCostDescription(e){if(!e.directions.length)return;const{totalDistance:t,totalDuration:i}=e.directions.reduce(((e,{lines:t})=>{for(const{distance:i,duration:s}of t)e.totalDistance+=i??0,e.totalDuration+=s??0;return e}),{totalDistance:0,totalDuration:0}),{messagesUnits:s,unit:o}=this,r=M(s,t,o);return`${I(i)} (${r})`}_getStopSections(){if(!this.viewModel.layer)return null;const{directionPoints:e,directionLines:t,stops:i}=this.viewModel.layer;if(!e||!t)return null;const s=[];let o=null;for(const r of e){const{objectId:e,stopId:n}=r;if(null!=n){const e=i.find((({objectId:e})=>e===n));o&&o.stop===e||(o={stop:e,directions:[]},s.push(o));continue}if(null==o)continue;const a=t.toArray().filter((({directionPointId:t})=>t===e));0!==a.length&&o.directions.push({directionPoint:r,lines:a})}return s}_handleAddStopClick(){const e=new y;this.viewModel.layer?.stops.add(new w({symbol:e}))}_handleAutoSolveChange({target:e}){this.viewModel.autoSolve=e.checked}_handleCreatePolylineBarrierClick(){this.viewModel.create("polyline-barrier")}_handleClearRouteClick(){this._currentFlowItem="primary",this.viewModel.reset()}_handleCreateStopClick(){this.viewModel.create("stop")}_handleDeleteNetworkFeatureClick(e){this.viewModel.remove(e),this.viewModel.autoSolve&&this._solveRouteDebounced()}_handleDeleteStopClick(e){this._getEffectiveStops().remove(e),this._disposeSearch(e),this._solveRouteDebounced()}_handleDepartureDateChange({currentTarget:{value:e}}){Array.isArray(e)||(this.viewModel.departureIsoDate=e,this._solveRouteDebounced())}_handleDepartureTimeChange({currentTarget:{value:e}}){this.viewModel.departureIsoTime=e,this._solveRouteDebounced()}_handleDepartureTimeOptionChange({currentTarget:e}){const{selectedItems:t}=e;t.length&&(this.viewModel.departureOption=t[0].value,this._solveRouteDebounced())}_handleDirectionsFlowItemBackClick(e){e.stopPropagation(),this._currentFlowItem="primary"}_handleDirectionTurnItemSelect(e){this._activeManeuver===e?this.zoomToRoute():(this._activeManeuver=e,this.viewModel.centerAt(e.geometry))}_handleDirectionTurnPointerEnter(e){this.viewModel.highlight(e)}_handleDirectionTurnPointerLeave(){this.viewModel.clearHighlights()}_handleEditFlowItemBackClick(e){e.stopPropagation(),this.viewModel.stopEditing(),this._currentFlowItem="primary"}_handleEditingDoneClick(){this.viewModel.stopEditing(),this._currentFlowItem="primary"}_handleEditRouteClick(){this._currentFlowItem="edit",this.viewModel.startEditing()}_handleItemDetailsClick(){const e=this.viewModel.layer?.portalItem;e&&window.open(`${e.portal.url}/home/item.html?id=${e.id}`,"_blank")}_handleLocateStopClick(e){const{view:t}=this;if(!t)return;const i="directions-search-tool";this.removeHandles(i),this._searchTool=new k({stop:e,view:t}),this.addHandles([this._searchTool.on("click",(async t=>{if(t.mapPoint&&this._stopsToSearches.has(e)){const i=this._stopsToSearches.get(e),s=await i.search(t.mapPoint),o=s?.results?.[0].results?.[0];if(o){const{feature:t,name:s}=o;i.searchTerm=s,e.geometry=t.geometry}}this.removeHandles(i)})),o((()=>{this._searchTool&&(this.view?.tools.remove(this._searchTool),this._searchTool=null)}))],i),t.addAndActivateTool(this._searchTool)}_handleOptimizeStopOrderToggle({target:{expanded:e}}){this.viewModel.routeParameters.findBestSequence=e,this._solveRouteDebounced()}_handlePanToStopClick(e){this.viewModel.centerAt(e)}_handlePreserveFirstStopChange({target:{checked:e}}){this.viewModel.routeParameters.preserveFirstStop=e,this._solveRouteDebounced()}_handlePreserveLastStopChange({target:{checked:e}}){this.viewModel.routeParameters.preserveLastStop=e,this._solveRouteDebounced()}_handlePrintDocumentAfterCreate(e){e.focus(),this._printDocument=e,this._printDocumentParent=e.parentElement}_handlePrintDocumentClick(){this._printDocumentOpen=!0}_handlePrintDocumentCloseClick(){this._printDocumentOpen=!1}_handlePrintDocumentKeyDown(e){"Escape"===e.key&&(this._printDocumentOpen=!1)}_handlePrintDocumentPrintClick(){document.body.classList.add(f.printMedia),window.print(),document.body.classList.remove(f.printMedia)}_handleResolveRouteClick(){this._solveRouteDebounced()}_handleReverseStopOrderClick(){this._getEffectiveStops().reverse(),this._solveRouteDebounced()}_handleSaveErrorCloseClick(){this._currentFlowItem=this._parentFlowItem}_handleSaveFlowItemBackClick(e){e.stopPropagation(),this._currentFlowItem=this._parentFlowItem}async _handleSaveLayerAs(){const e=_.getDefault();try{await e.signIn()}catch(t){if(a(t)||"identity-manager:user-aborted"===t.name)return;return this._parentFlowItem=this._currentFlowItem,this._currentFlowItem="save",void(this._saveState="connect-to-portal-error")}this._saveState="fetch-portal-information",this._parentFlowItem=this._currentFlowItem,this._currentFlowItem="save",this._portalUserName=e.user?.username;try{this._portalFolders=await(e.user?.fetchFolders())}catch{return void(this._saveState="fetch-portal-information-error")}this._saveState="save-layer"}_handleSaveLayerClick(){this.viewModel.layer?.save()}_handleSaveLayerButtonClick(){this._saveState="saving";const{layer:e}=this;if(!e||!this._portalFolders)return;const t=this._portalItemNameInput?.value,i=this._portalFolderCombobox?.value,s=this._portalFolders.find((({id:e})=>e===i));e.saveAs({title:t},{folder:s}).then((()=>{e.title=t,this._currentFlowItem=this._parentFlowItem})).catch((()=>{this._saveState="saving-error"}))}_handleSaveLayerCancelClick(){this._currentFlowItem=this._parentFlowItem}_handleSaveLayerFolderCreate(e){this._portalFolderCombobox=e}_handleSaveLayerNameCreate(e){this._portalItemNameInput=e}_handleSignInClick(){this.viewModel.load().catch((()=>{}))}_handleStopListReorder({detail:{dragEl:e,newIndex:t}}){this._getEffectiveStops().reorder(e.value,t),this._solveRouteDebounced()}_handleTravelModeChange({currentTarget:{selectedItems:e}}){e.length&&(this.viewModel.selectedTravelMode=e[0].value,this._solveRouteDebounced())}_handleViewDrivingDirectionsClick(){this._currentFlowItem="directions"}_normalizeSearchSources(e){this._overrideDefaultSources(e),this._applyLocatorSourceOverrides(e)}_overrideDefaultSources(e){for(const t of e.viewModel.defaultSources)t.autoNavigate=!1}_renderClearRouteAction(e){return A("calcite-action",{bind:this,icon:"trash",key:"clear-route",onclick:this._handleClearRouteClick,...e,text:this.messages.common.clear,textEnabled:!0})}_renderDeleteStopAction(e){return A("calcite-action",{icon:"trash",onclick:this._handleDeleteStopClick.bind(this,e),scale:"s",slot:"actions-end",text:this.messages.deleteStop,title:this.messages.deleteStop})}_renderDepartureTime(){const{DEPART_AT:e,NOW:t,UNSPECIFIED:i}=T;return A("calcite-label",{class:f.departureTime,key:"departure-time"},this.messages.departureTime,A("calcite-combobox",{bind:this,clearDisabled:!0,label:this.messages.departureTime,overlayPositioning:"fixed",selectionMode:"single-persist",onCalciteComboboxChange:this._handleDepartureTimeOptionChange},A("calcite-combobox-item",{heading:this.messages.leaveNow,key:t,label:this.messages.leaveNow,selected:this.viewModel.departureOption===t,value:t}),A("calcite-combobox-item",{heading:this.messages.departAt,key:e,label:this.messages.departAt,selected:this.viewModel.departureOption===e,value:e}),A("calcite-combobox-item",{heading:this.messages.timeUnspecified,key:i,label:this.messages.timeUnspecified,selected:this.viewModel.departureOption===i,value:i})))}_renderDepartureTimeOptions(){return this.viewModel.departureOption!==T.DEPART_AT?null:A("div",{class:f.departureTimeOptions},A("calcite-input-date-picker",{bind:this,scale:"s",value:this.viewModel.departureIsoDate,onCalciteInputDatePickerChange:this._handleDepartureDateChange}),A("calcite-input-time-picker",{bind:this,scale:"s",value:this.viewModel.departureIsoTime,onCalciteInputTimePickerClose:this._handleDepartureTimeChange}))}_renderDirectionsFlowItem(){if("directions"!==this._currentFlowItem)return null;const e=this._getRouteCostSummary();if(!this._sections||!e)return null;const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel,o=this._sections.at(0)?.stop.name??"",r=this._sections.at(-1)?.stop.name??"";return A("calcite-flow-item",{bind:this,key:"directions-flow-item",overlayPositioning:"fixed",selected:"directions"===this._currentFlowItem,onCalciteFlowItemBack:this._handleDirectionsFlowItemBackClick},A("div",{class:f.directionsHeader,slot:"header-content"},A("div",{class:f.headerStops},A("span",null,this.messages.from)," ",A("span",{class:f.directionsHeaderStopName},o),A("span",null,this.messages.to)," ",A("span",{class:f.directionsHeaderStopName},r)),A("div",{class:f.flexColumn},A("span",null,`${i} (${t})`),s?A("span",null,s):null)),this._renderRouteLayerActions({slot:"header-menu-actions"}),A("calcite-accordion",{class:f.accordion,iconPosition:"start",selectionMode:"single"},this._sections.map(((e,t)=>this._renderDirectionSection(e,t)))))}_renderDirectionSection(e,t){const{stop:i,directions:s}=e,{name:o}=i,r=0===t,n=this._getStopCostDescription(e);return A("calcite-accordion-item",{description:n,expanded:r,heading:o??"",key:`stop-${t}`},A("calcite-action",{icon:"zoom-to-object",onclick:this._handlePanToStopClick.bind(this,i),slot:"actions-end",text:this.messages.panToStop,title:this.messages.panToStop}),this._renderDirectionTurns(s))}_renderDirectionTurns(e){return A("calcite-list",{label:this.messages.drivingDirections,selectionMode:"none"},e.map(((e,t)=>{const{directionPoint:i,lines:s}=e,o=s[0],{distance:r,duration:n}=o,a=M(this.messagesUnits,r??0,this.unit),l=I(n??0),c=a&&l?`${a} | ${l}`:`${a||l}`,d=O(i),h=F(i.directionPointType);return A("calcite-list-item",{class:f.labelNoBottomMargin,key:`driving-direction-${t}`,onpointerenter:this._handleDirectionTurnPointerEnter.bind(this,o),onpointerleave:this._handleDirectionTurnPointerLeave.bind(this),onCalciteListItemSelect:this._handleDirectionTurnItemSelect.bind(this,o)},A("calcite-icon",{icon:h,slot:"content-start"}),A("div",{slot:"content"},A("calcite-label",{layout:"inline",scale:"s"},d),A("calcite-label",{layout:"inline",scale:"s"},c)))})))}_renderEditFlowItem(){return"edit"!==this._currentFlowItem?null:A("calcite-flow-item",{bind:this,heading:this.messages.editRoute,headingLevel:this.headingLevel,key:"edit-flow-item",loading:"routing"===this.viewModel.state,selected:"edit"===this._currentFlowItem,onCalciteFlowItemBack:this._handleEditFlowItemBackClick},A("div",{class:f.flexColumn,key:"edit-container"},A("div",{class:f.editToolbarContainer},A("calcite-label",{layout:"inline",scale:"s"},this.messages.automaticallySolve,A("calcite-switch",{bind:this,checked:this.viewModel.autoSolve,scale:"s",onCalciteSwitchChange:this._handleAutoSolveChange})),A("div",{class:f.editToolbar},A("calcite-action",{bind:this,disabled:!this.viewModel.layer||this.viewModel.layer.stops.length>=this.maxStops,icon:"flag",onclick:this._handleCreateStopClick,scale:"s",text:this.messages.networkFeatures.stops.stop,textEnabled:!0}),A("calcite-action",{bind:this,icon:"line",onclick:this._handleCreatePolylineBarrierClick,scale:"s",text:this.messages.barrier,textEnabled:!0}),A("calcite-action",{bind:this,class:f.solveRoute,disabled:this.viewModel.autoSolve,icon:"refresh",onclick:this._handleResolveRouteClick,scale:"s",text:this.messages.solve,textEnabled:!0}))),A("div",{class:f.selectedFeatureContainer},A("calcite-list",{label:this.messages.selectedNetworkFeatures,scale:"s",selectionMode:"none"},this.viewModel.selectedNetworkFeatures?.toArray().map(((e,t)=>A("calcite-list-item",{description:this._getNetworkFeatureName(e),key:`network-feature-${t}`,label:e.name??e.objectId?.toString()??this.messages.unnamed},A("calcite-action",{icon:"trash",onclick:this._handleDeleteNetworkFeatureClick.bind(this,e),scale:"s",slot:"actions-end",text:this.messages.common.delete})))))),A("div",{class:f.editFooter},this._renderEditFooterContent())))}_renderEditFooterContent(){return this.viewModel.lastError?this._renderErrorNotice():A("calcite-button",{appearance:"outline-fill",bind:this,onclick:this._handleEditingDoneClick,width:"full"},this.messages.common.done)}_renderErrorNotice(){return A("calcite-notice",{icon:"exclamation-mark-circle",kind:"danger",open:!0},A("calcite-label",{class:f.labelNoBottomMargin,slot:"message"},this._getErrorDescription()))}_renderFooter(){if(!this.viewModel.layer)return A("div",{class:f.primaryFooter,key:"footer-missing-layer"},A("calcite-notice",{icon:"information",open:!0},A("calcite-label",{class:f.labelNoBottomMargin,slot:"message"},this.messages.missingLayer)));if("unauthenticated"===this.viewModel.state)return A("div",{class:f.primaryFooterCentered,key:"footer-sign-in"},A("calcite-label",null,this.messages.signInRequired),A("calcite-button",{bind:this,onclick:this._handleSignInClick},this.messages.common.auth.signIn));if("routing"===this.viewModel.state)return A("div",{class:this.classes(f.primaryFooter,f.primaryFooterLoader),key:"footer-routing"},A("calcite-loader",{label:this.messages.solve,scale:"s"}));if("error"===this.viewModel.state)return A("div",{class:f.primaryFooter,key:"footer-service-error"},this._renderErrorNotice());if(!this.viewModel.layer?.routeInfo)return A("div",{class:f.primaryFooter,key:"footer-unsolved-route"},A("calcite-notice",{icon:"information",open:!0},A("calcite-label",{class:f.labelNoBottomMargin,slot:"message"},this.messages.directionsPlaceholder)));const e=this._getRouteCostSummary();if(!e||!this.viewModel.layer?.directionPoints)return A("div",{class:f.primaryFooter,key:"footer-invalid-route"},A("calcite-notice",{icon:"exclamation-mark-triangle",kind:"danger",open:!0},A("calcite-label",{class:f.labelNoBottomMargin,slot:"message"},this.messages.invalidRoute)));const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel;return A("div",{class:f.routeItem,key:"footer-directions-summary"},A("button",{"aria-busy":"false","aria-label":this.messages.viewDrivingDirections,"aria-live":"polite",bind:this,class:f.routeItemButton,onclick:this._handleViewDrivingDirectionsClick,title:this.messages.viewDrivingDirections,type:"button"},A("div",{class:f.routeItemButtonContent},A("span",{class:f.routeItemLabel},`${i} (${t})`),A("span",{class:f.routeItemDescription},s)),A("calcite-icon",{flipRtl:!0,icon:"chevron-right",scale:"s"})),A("calcite-action-menu",{label:"test"},A("calcite-action",{icon:"ellipsis",key:"route-actions",slot:"trigger",text:"Route actions"}),this._renderRouteLayerActions()))}_renderInteractiveRouteActions(){return A("div",{class:f.actionContainer,key:f.actionContainer},A("calcite-button",{appearance:"outline",bind:this,class:f.addStopButton,disabled:this._getEffectiveStops().length>=this.maxStops,iconStart:"plus",kind:"neutral",label:this.messages.addStop,onclick:this._handleAddStopClick,title:this.messages.addStop,width:"half"},this.messages.addStop),this.visibleElements.editRouteButton?A("calcite-button",{appearance:"outline",bind:this,class:f.editRouteButton,disabled:"2d"!==this.viewModel.view?.type,iconStart:"pencil",kind:"neutral",label:this.messages.editRoute,onclick:this._handleEditRouteClick,title:this.messages.editRoute,width:"half"},this.messages.editRoute):null)}_renderLocateStopAction(e){if(null!=e.name||null!=e.geometry)return null;const t=this._getEffectiveStops().indexOf(e),i=!!this.view?.activeTool&&this.view.activeTool===this._searchTool&&this._searchTool.stop===e;return A("calcite-action",{active:i,icon:"crosshair",key:`stop-location-action-${t}`,onclick:this._handleLocateStopClick.bind(this,e),scale:"s",slot:"actions-end",text:this.messages.pickALocationOnTheMap,title:this.messages.pickALocationOnTheMap})}_renderOptimizeStopOrder(){const{routeParameters:e}=this.viewModel,{findBestSequence:t,preserveFirstStop:i,preserveLastStop:s}=e;return A("calcite-block-section",{bind:this,class:f.optimizeSection,text:this.messages.optimizeOrder,toggleDisplay:"switch",onCalciteBlockSectionToggle:this._handleOptimizeStopOrderToggle},t?[A("calcite-label",{class:f.optimizeSwitches,key:"preserve-first-stop",layout:"inline-space-between"},this.messages.preserveFirstStop,A("calcite-switch",{bind:this,checked:i,scale:"s",onCalciteSwitchChange:this._handlePreserveFirstStopChange})),A("calcite-label",{class:f.optimizeSwitches,key:"preserve-last-stop",layout:"inline-space-between"},this.messages.preserveLastStop,A("calcite-switch",{bind:this,checked:s,scale:"s",onCalciteSwitchChange:this._handlePreserveLastStopChange}))]:null)}_renderPrimaryFlowItem(){return A("calcite-flow-item",{key:"primary-flow-item",loading:"initializing"===this.viewModel.state,selected:"primary"===this._currentFlowItem},A("calcite-panel",{class:f.primaryFlowItem,disabled:!this.viewModel.layer||"unauthenticated"===this.viewModel.state||"error"===this.viewModel.state&&!this.viewModel.serviceDescription},this._renderStops(),this._renderInteractiveRouteActions(),this._renderSeparator(),this._renderRouteSolveOptions()),this._renderFooter())}_renderPrintDocument(){if(!this._printDocumentOpen)return null;const e=this._getRouteCostSummary();if(!this._sections||!e)return null;const{distance:t,duration:i}=e,{formattedEta:s}=this.viewModel,o=this._sections.at(0)?.stop.name??"",r=this._sections.at(-1)?.stop.name??"";return A("div",{afterCreate:this._handlePrintDocumentAfterCreate,bind:this,class:f.printDocument,onkeydown:this._handlePrintDocumentKeyDown,tabindex:0},A("div",{class:f.printBody},A("div",{class:f.printHeader},A("div",{class:f.printHeaderLabel},A("div",{class:f.headerStops},A("span",null,this.messages.from)," ",A("span",{class:f.directionsHeaderStopName},o),A("span",null,this.messages.to)," ",A("span",{class:f.directionsHeaderStopName},r))),A("div",{class:this.classes(f.printHeaderButtons,f.printHideOnPrint)},A("calcite-button",{class:f.printDocumentPrint,iconStart:"print",onclick:this._handlePrintDocumentPrintClick},this.messages.common.print),A("calcite-button",{appearance:"outline",bind:this,class:f.printDocumentClose,iconStart:"x-circle",onclick:this._handlePrintDocumentCloseClick},this.messages.common.close))),A("div",{class:f.directionsHeader},A("span",null,`${i} (${t})`),s?A("span",null,s):null),this._sections.map(((e,t)=>this._renderPrintSection(e,t)))))}_renderPrintManuever(e,t){const{directionPoint:i,lines:s}=e,{distance:o,duration:r}=s.at(0)??{},n=M(this.messagesUnits,o??0,this.unit),a=I(r??0),l=n&&a?`${n} | ${a}`:`${n||a}`,c=O(i),d=F(i.directionPointType);return A("div",{class:this.classes(f.flexRow,f.printAvoidPageBreak),key:`direction-${t}`},A("calcite-icon",{icon:d}),A("div",{class:f.flexColumn},A("span",null,c),A("span",null,l)))}_renderPrintRouteAction(e){if(!this.visibleElements.printButton)return null;const t=!this.viewModel.layer?.routeInfo;return A("calcite-action",{bind:this,disabled:t,icon:"print",key:"print-route",onclick:this._handlePrintDocumentClick,...e,text:this.messages.common.print,textEnabled:!0})}_renderPrintSection({stop:e,directions:t},i){return A("div",{class:f.printSection,key:`section-${i}`},A("span",{class:f.directionsHeaderStopName},e.name??""),t.map(((e,t)=>this._renderPrintManuever(e,t))))}_renderRouteLayerActions(e){return[this._renderClearRouteAction(e),this._renderSaveLayerAction(e),this._renderSaveLayerAsAction(e),this._renderPrintRouteAction(e),this._renderViewItemDetailsAction(e)]}_renderRouteSolveOptions(){return A("div",{class:f.marginInlineMedium,key:"route-solve-options"},this._renderTravelModes(),this._renderDepartureTime(),this._renderDepartureTimeOptions(),this._renderOptimizeStopOrder())}_renderSaveContent(){switch(this._saveState){case"initialized":return this._renderSaveInitialized();case"connect-to-portal":return this._renderSaveProcessing(this.messages.identity.lblSigning);case"connect-to-portal-error":return this._renderSaveError(this.messages.errors.authenticating);case"fetch-portal-information":return this._renderSaveProcessing(this.messages.processing.fetching);case"fetch-portal-information-error":return this._renderSaveError(this.messages.errors.fetching);case"save-layer":return this._renderSaveLayerSettings();case"saving":return this._renderSaveProcessing(this.messages.processing.saving);case"saving-error":return this._renderSaveError(this.messages.errors.saving)}}_renderSaveError(e){return A("calcite-panel",{class:f.paddingMedium,key:"save-layer-error"},A("div",{class:f.saveError},A("calcite-icon",{class:f.saveErrorIcon,icon:"exclamation-mark-triangle",scale:"l",textLabel:this.messages.common.errorMessage}),A("calcite-label",{class:f.saveErrorLabel},e)),A("calcite-button",{appearance:"outline",bind:this,onclick:this._handleSaveErrorCloseClick,slot:"footer-actions",width:"full"},this.messages.common.close))}_renderSaveInitialized(){return A("calcite-panel",{class:f.paddingMedium,key:"save-layer-initialized"})}_renderSaveFlowItem(){return"save"!==this._currentFlowItem?null:A("calcite-flow-item",{bind:this,heading:this.messages.saveLayer,headingLevel:this.headingLevel,key:"save-layer-flow-item",selected:"save"===this._currentFlowItem,onCalciteFlowItemBack:this._handleSaveFlowItemBackClick},this._renderSaveContent())}_renderSaveLayerAction(e){if(!this.visibleElements.saveButton)return null;const t=this.viewModel.layer,i=t?.routeInfo,s=t?.portalItem?.itemControl;return A("calcite-action",{bind:this,disabled:!(!!i&&("admin"===s||"update"===s)),icon:"save",key:"save-route",onclick:this._handleSaveLayerClick,...e,text:this.messages.common.save,textEnabled:!0})}_renderSaveLayerAsAction(e){if(!this.visibleElements.saveAsButton)return null;const t=!this.viewModel.layer?.routeInfo;return A("calcite-action",{disabled:t,icon:"save-as",key:"save-as-route",onclick:()=>{this._handleSaveLayerAs()},...e,text:this.messages.common.saveAs,textEnabled:!0})}_renderSaveLayerSettings(){if(null==this.layer||null==this._portalFolders||null==this._portalUserName)return this._renderSaveInitialized();const{stops:e}=this.layer,t=`${e.at(0).name} - ${e.at(-1).name}`,i=[A("calcite-combobox-item",{heading:`${this._portalUserName} (${this.messages.common.home})`,key:f.folderHome,selected:!0,value:f.folderHome}),...this._portalFolders.map((e=>A("calcite-combobox-item",{heading:e.title??"",key:`${f.folder}-${e.id}`,value:e.id})))];return A("calcite-panel",{key:"save-layer-panel"},A("div",{class:f.paddingMedium},A("calcite-label",null,this.messages.layerName,A("calcite-input",{afterCreate:this._handleSaveLayerNameCreate,bind:this,label:this.messages.layerName,value:t})),A("calcite-label",null,this.messages.saveInFolder,A("calcite-combobox",{afterCreate:this._handleSaveLayerFolderCreate,bind:this,clearDisabled:!0,label:this.messages.saveInFolder,overlayPositioning:"fixed",selectionMode:"single-persist"},i))),A("calcite-button",{bind:this,onclick:this._handleSaveLayerButtonClick,slot:"footer-actions",width:"full"},this.messages.common.save),A("calcite-button",{appearance:"outline",bind:this,onclick:this._handleSaveLayerCancelClick,slot:"footer-actions",width:"full"},this.messages.common.cancel))}_renderSaveProcessing(e){return A("calcite-panel",{class:f.marginInlineMedium,key:"save-layer-processing"},A("calcite-loader",{class:f.saveProcessLoader,label:e,text:e}))}_renderSeparator(){return A("div",{class:f.separator})}_renderStop(e){const t=this.acquireSearch(e);null!=e.name&&(t.searchTerm=e.name);const i=this._getEffectiveStops(),s=this._renderLocateStopAction(e),o=i.length>2&&this._renderDeleteStopAction(e);return A("calcite-list-item",{key:e,value:e},s,o,A("div",{class:f.stopItem,slot:"content"},t.render()))}_renderStops(){const e=this._getEffectiveStops();for(const t of this._stopsToSearches.keys())e.includes(t)||this._disposeSearch(t);return A("div",{class:f.stopContainer,key:f.stopContainer},A("calcite-list",{bind:this,class:f.stopList,dragEnabled:!0,label:this.messages.widgetLabel,scale:"s",onCalciteListOrderChange:this._handleStopListReorder},e.toArray().map((e=>this._renderStop(e)))),2===e.length&&A("calcite-action",{bind:this,icon:"arrow-up-down",onclick:this._handleReverseStopOrderClick,scale:"s",text:this.messages.reverseStops,title:this.messages.reverseStops}))}_renderTravelMode(e){const{id:t,name:i}=e;return A("calcite-combobox-item",{heading:i,key:t,label:i,selected:this.viewModel.selectedTravelMode?.id===t,value:e})}_renderTravelModes(){return this.viewModel.travelModes.length?A("calcite-label",{key:"travel-modes"},this.messages.mode,A("calcite-combobox",{bind:this,clearDisabled:!0,label:this.messages.mode,overlayPositioning:"fixed",selectionMode:"single-persist",onCalciteComboboxChange:this._handleTravelModeChange},this.viewModel.travelModes.map((e=>this._renderTravelMode(e))))):null}_renderViewItemDetailsAction(e){return this.visibleElements.layerDetails?A("calcite-action",{bind:this,disabled:!this.viewModel.layer?.portalItem,icon:"launch",key:"open-route-details-link",onclick:this._handleItemDetailsClick,...e,text:this.messages.viewLayerDetails,textEnabled:!0}):null}async _solveRoute(){this.viewModel.updateDepartureTime();if(!((this.viewModel.layer?.stops.filter((({geometry:e})=>!!e)).length??0)<2))try{await this.viewModel.getDirections()}catch{}}};e([p()],N.prototype,"_printDocumentOpen",void 0),e([p()],N.prototype,"_currentFlowItem",void 0),e([p()],N.prototype,"_saveState",void 0),e([p()],N.prototype,"_searchTool",void 0),e([p()],N.prototype,"apiKey",null),e([p(g)],N.prototype,"defaultUnit",void 0),e([p()],N.prototype,"goToOverride",null),e([p()],N.prototype,"headingLevel",void 0),e([p()],N.prototype,"icon",null),e([p()],N.prototype,"label",null),e([p({readOnly:!0})],N.prototype,"lastRoute",null),e([p()],N.prototype,"layer",null),e([p()],N.prototype,"maxStops",null),e([p(),L("esri/widgets/Directions/t9n/Directions")],N.prototype,"messages",void 0),e([p(),L("esri/core/t9n/Units")],N.prototype,"messagesUnits",void 0),e([p()],N.prototype,"searchProperties",void 0),e([p()],N.prototype,"unit",null),e([p()],N.prototype,"view",null),e([p({type:C})],N.prototype,"viewModel",void 0),e([p({type:D,nonNullable:!0})],N.prototype,"visibleElements",void 0),N=e([m("esri.widgets.Directions")],N);const j=N;export{j 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.34/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{unique as t,isSome as i}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{deprecatedFunction as o}from"../../core/deprecate.js";import s from"../../core/Error.js";import n from"../../core/Evented.js";import{makeHandle as l}from"../../core/handleUtils.js";import d from"../../core/Logger.js";import{destroyMaybe as c,abortMaybe as p,removeMaybe as u}from"../../core/maybe.js";import{throwIfAborted as h,createResolver as f}from"../../core/promiseUtils.js";import{watch as w,on as m,when as y,syncAndInitial as g,initial as k,sync as v,whenOnce as _}from"../../core/reactiveUtils.js";import{property as W}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as M}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as F}from"../../core/support/UpdatingHandles.js";import{getTemplatesForLayers as E}from"../../editing/templateUtils.js";import T from"../../layers/GraphicsLayer.js";import{isEditableLayer as b}from"../../layers/support/editableLayers.js";import{isFeatureLayer as V,isSubtypeGroupLayer as S,getOwningPortalUrl as L}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as I}from"../../portal/support/urlUtils.js";import A from"../../views/SelectionManager.js";import U from"../../views/interactive/sketch/SketchOptions.js";import{SnappingManager as C}from"../../views/interactive/snapping/SnappingManager.js";import O from"../../views/interactive/snapping/SnappingOptions.js";import{isSelectableLayer as j}from"../../views/support/selectionUtils.js";import P from"../Attachments/AttachmentsViewModel.js";import R from"./CreateFeaturesWorkflow.js";import H from"./UpdateFeaturesWorkflow.js";import q from"./UpdateWorkflow.js";import{getLayersFromWorkflow as G,isCreateFeaturesWorkflow as x,isUpdateRecordWorkflow as D,isUpdateFeaturesWorkflow as B,isUpdateWorkflow as N,makeMultipleSourceLayersError as Q,whenEditorLayerView as z}from"./workflowUtils.js";import Z from"./support/EditorItem.js";import{makeTemplateGroupInfoForLayer as $}from"../FeatureTemplates/featureTemplatesUtils.js";import J from"../FeatureTemplates/FeatureTemplatesViewModel.js";import K from"../Sketch/SketchViewModel.js";import X from"../Spinner/SpinnerViewModel.js";import{goTo as Y}from"../support/goToUtils.js";import{isFeatureItem as ee,isLayerItem as te}from"../support/SelectionList/selectionListUtils.js";import ie from"../support/SelectionList/SelectionListViewModel.js";import re from"../support/SelectionToolbar/SelectionToolbarViewModel.js";function ae(e,t){return e?.find((e=>e.layer===t))}let oe=class extends n.EventedAccessor{constructor(e){super(e),this._queuedSelectionTool=null,this._sketchEventListenerHandle=null,this._sketchGraphicsLayer=new T({listMode:"hide",internal:!0}),this._snappingManager=null,this._templatesByLayer=new Map,this._updateItemsTask=null,this._updateTemplatesTask=null,this._updatingHandles=new F,this._featureTemplatesViewModelIsRestricted=!1,this.activeWorkflow=null,this._activityQueue=new a,this.editorItems=new a,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new P({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new J({disabledItemFunction:({layer:e})=>this._itemIsSuspended(e)}),this.layerInfos=null,this.ownSketchViewModel=new K({layer:this._sketchGraphicsLayer}),this.selectionListViewModel=new ie,this.selectionManager=new A,this.selectionToolbarViewModel=new re({continuousSelectionEnabled:!0,defaultOperationType:"replace",persistSelection:!1,returnGeometry:!1}),this.sketchOptions=new U,this.snappingOptions=new O({attributeRulesEnabled:!0}),this.spinnerViewModel=new X,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.back=async()=>{if("viewing-selection-list"===this.state)return this.selectionListViewModel.filterText=void 0,void this.effectiveSelectionManager.clear();this.canGoBack&&(this.activeWorkflow?.hasPreviousStep?await this.activeWorkflow.back(this.showDiscardEditsPrompt):await this._cancelWorkflow({force:!this.hasPendingEdits}))},this.saveWorkflow=async()=>await(this.activeWorkflow?.save()),this.selectFeature=(e,t=!1)=>{const i=this.activeWorkflow;this._candidateCommitted||"update"!==i?.type||(i.data.rootFeature=e,t&&(i.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([w((()=>{const e=this.view,t=e?.map?.editableLayers.toArray(),i=e?.allLayerViews,r=i?.filter((e=>!!t?.includes(e.layer)));return[t,r,this.layerInfos]}),(()=>this._updateEditorItems()),g),w((()=>this.hideTemplatesForInactiveLayers),(()=>this.syncFeatureTemplates())),w((()=>this._selectionSources),(()=>this._syncSelectionSources()),k),m((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),m((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),m((()=>this.activeWorkflow),"complete",(()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)})),y((()=>!this.activeWorkflow&&this._queuedSelectionTool),(()=>this._queuedSelectionTool&&this.selectionToolbarViewModel.activateTool(this._queuedSelectionTool))),w((()=>this.activeWorkflow),(e=>this.selectionManager.showHighlight=!e)),y((()=>this.view?.map),(e=>e.add(this._sketchGraphicsLayer)),k),m((()=>this.editorItems),"change",(()=>this._afterEditorItemsChange())),w((()=>[this.canCreate,this.canUpdateVisible]),(()=>this._afterEditorItemsChange())),w((()=>this.page),((e,t)=>{const i=[...this.pageStack];if(-1===i.indexOf(e))i.push(e);else for(;i.length&&i.at(-1)!==e;)i.pop();this.pageStack=i}),g),y((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1)),m((()=>this.featureTemplatesViewModel),"select",(async({item:e,oldItem:t})=>{const{activeWorkflow:i}=this;if(i){if("update"===i.type&&"awaiting-feature-creation-info"===i.activeWorkflow?.stepId)return;try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return void this.featureTemplatesViewModel.select(t,{emit:!1})}}if(!e)return;const r={layer:e.layer,template:e.template};if(e.supportsUpload)return this.featureTemplatesViewModel.select(t,{emit:!1}),this.startCreateFeaturesWorkflow(r);this.startCreateFeaturesWorkflowAtFeatureCreation(r)})),w((()=>[this.view,this.featureTemplatesViewModel]),(([e,t])=>{t.view=e}),g),m((()=>this.view),"key-down",(e=>{"Escape"===e.key&&this.activeWorkflow?.keyboardCancellationEnabled&&(e.stopPropagation(),this.back())})),m((()=>this.sketchViewModel),["create","delete","update"],(e=>{const{activeWorkflow:t}=this,i="update"===t?.type,r=G(t),a=i?t?.activeWorkflow?.parentLayer:void 0,o=`sketch-${e.type}`;this.emit(o,{type:o,detail:e,layer:r[0],layers:r,parentLayer:a})}),v),w((()=>this.view),(e=>{if(this._snappingManager=c(this._snappingManager),!e)return;const t=this.snappingOptions;this._snappingManager=new C({view:e,options:t}),this.ownSketchViewModel.snappingManager=this._snappingManager}),g),w((()=>this.snappingOptions),(e=>{this._snappingManager&&(this._snappingManager.options=e)}),g),m((()=>this.selectionToolbarViewModel),"complete",(e=>this._onSelectionComplete(e))),w((()=>({view:this.view,selectionManager:this.effectiveSelectionManager,selectionListViewModel:this.selectionListViewModel,selectionToolbarViewModel:this.selectionToolbarViewModel})),(({view:e,selectionManager:t,selectionListViewModel:i,selectionToolbarViewModel:r})=>{t.view=e,i.view=e,r.view=e}),g),w((()=>this.effectiveSelectionManager),(e=>{this.selectionListViewModel.selectionManager=e,this.selectionToolbarViewModel.selectionManager=e}),g)])}destroy(){this._cancelWorkflow({warnIfNoWorkflow:!1}).then((()=>{this.view?.map?.remove(this._sketchGraphicsLayer),this.view=null})),this._updateItemsTask=p(this._updateItemsTask),this._updatingHandles.destroy(),this._sketchEventListenerHandle=u(this._sketchEventListenerHandle),this.selectionListViewModel?.destroy(),this.selectionToolbarViewModel?.destroy(),this.selectionManager.destroy()}get _featureTemplatesLayersAndTables(){const e=new a;for(const t of this.editorItems){const i=this.hideTemplatesForInactiveLayers&&!t.visible;t.supportsCreateFeaturesWorkflow&&!i&&e.push(t.layer)}return e}get _selectionSources(){const e=new a;for(const t of this.editorItems)j(t.layer)&&t.supportsUpdateWorkflow&&t.visible&&e.push(t.layer);return e}get activeFeatureCount(){const e=this.activeLeafWorkflow;return x(e)?e.pendingFeatures.length:D(e)&&e.data.edits.feature?1:B(e)?e.data.features.length:0}get activeLeafWorkflow(){const e=this.activeWorkflow;return e&&N(e)?e.activeWorkflow??e:e}get canCreate(){return this.editorItems.some((e=>e.supportsCreateFeaturesWorkflow))}get canCreateVisible(){return!!this.featureTemplatesLayers.length}get canUpdate(){return this.editorItems.some((e=>e.supportsUpdateWorkflow))}get canUpdateVisible(){return this.editorItems.some((e=>e.supportsUpdateWorkflow&&e.visible))}get featureTemplatesLayers(){return this._featureTemplatesLayersAndTables.filter((e=>"scene"===e.type||!e.isTable))}get effectiveSelectionManager(){return this.selectionManager}get featureFormViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeFeatureFormViewModel:"create-features"===e?.type?e.featureFormViewModel:null}get formViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeFeatureFormViewModel:"create-features"===e?.type?e.featureFormViewModel:"update-features"===e?.type?e.formViewModel:null}get utilityNetworkAssociationAddAssociationViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeUtilityNetworkAssociationAddAssociationViewModel:null}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=e}get sketchViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeSketchViewModel:"create-features"===e?.type?e.sketchViewModel:this.ownSketchViewModel}get state(){if(!this.view?.ready)return"disabled";const e=this.attachmentsViewModel.mode;if("add"===e)return"adding-attachment";if("edit"===e)return"editing-attachment";const{activeWorkflow:t}=this,i=!t?.stepId;return this.effectiveSelectionManager.count&&i?"viewing-selection-list":i?"ready":"update"===t.type&&t.activeWorkflow?.stepId?t.activeWorkflow.stepId:t.stepId}get syncing(){return this._activityQueue.length>0}get updating(){return this._updatingHandles.updating||!0===this.activeWorkflow?.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}set view(e){this.ownSketchViewModel.view=e,this.spinnerViewModel.view=e,this._set("view",e)}get canZoomTo(){const e=this.sketchViewModel,t=e?.createGraphic?.geometry?.type;return!(!e?.updateGraphics?.length&&"multipoint"!==t)}get page(){const{activeWorkflow:e,state:t}=this;if("update"===e?.type&&null!=e?.activeWorkflow?.featureFormViewModel?.associatedLayer)return"viewing-associated-features";if("update"===e?.type&&null!=e?.activeWorkflow?.featureFormViewModel?.associationId)return"viewing-associated-layers";if("update"===e?.type&&"awaiting-feature-to-update"===e.stepId)return"ready";if("create-features"===e?.type&&0===e.numPendingFeatures){const t=e.data.upload;if(t)return"default"===t.state?"ready":"creating-features-upload-details"}return t??"disabled"}get featureFormDisabled(){const{activeWorkflow:e}=this;return"update"===e?.type&&(!1===e.activeEditorItem?.capabilities.update.attributes||!0===e.activeFeatureFormViewModel?.disabled)}get featureFormHasAssociation(){return!!this.featureFormViewModel?.activeAssociation}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:e}=this;return!this.featureFormDisabled&&(N(e)&&e.activeEditorItem?.capabilities.delete.enabled||B(e)&&e.data.editorItems.every((e=>e.capabilities.delete.enabled)))}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}get snappingManager(){return this._snappingManager}getTemplatesForLayer(e){return this._templatesByLayer.get(e)??[]}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateFeaturesWorkflowAtFeatureCreation(e){return this.startCreateFeaturesWorkflow(e,"creating-features")}async startCreateFeaturesWorkflow(e,t="awaiting-feature-creation-info"){if(await _((()=>!this.updating)),!this.canCreate)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled.");const i=this._createUpdatingResolver();try{await this._cancelWorkflow();const i=this._createCreateFeaturesWorkflow(e,t);this._set("activeWorkflow",i),await i.start()}catch(r){this._logErrorAndCancelWorkflow(r)}finally{i.resolve()}}async startCreateFeaturesWorkflowAtFeatureEdit(e){await _((()=>!this.updating));const t=this._createUpdatingResolver();try{const{initialFeature:t}=e,i=t.sourceLayer=t.layer,r=i?this.findEditorItemForLayer(i):void 0;if(!r?.supportsCreateFeaturesWorkflow)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled for this layer.");await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow({initialFeature:t,layer:r.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",a),await a.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateFeaturesWorkflow(e){if(await _((()=>!this.updating)),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update features workflow is unsupported or disabled.");if(t(e.map((e=>e.sourceLayer??e.layer))).length>1)throw Q();const i=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateFeaturesWorkflow(e);this._set("activeWorkflow",t),await t.start()}catch(r){this._logErrorAndCancelWorkflow(r)}finally{i.resolve()}}async startUpdateWorkflowAtFeatureSelection(){if(await _((()=>!this.updating)),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();try{await this._cancelWorkflow();const e=this._createUpdateWorkflow();this._set("activeWorkflow",e),await e.start()}catch(t){this._logErrorAndCancelWorkflow(t)}finally{e.resolve()}}async startUpdateWorkflowAtMultipleFeatureSelection(e){if(await _((()=>!this.updating)),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateWorkflow("awaiting-update-feature-candidate");t.data.candidates=e,this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowAtFeatureEdit(e){if(await _((()=>!this.updating)),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateWorkflow("editing-existing-feature");t.data.rootFeature=e,t.addHandles(m((()=>t),"commit",(()=>{t.destroy(),this.activeWorkflow===t&&this._set("activeWorkflow",null)}))),this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowWithActiveSelection(e){const{selectionListViewModel:t}=this;if(e?.length){const t=e;if(new Set(t.map((e=>e.sourceLayer))).size>1)throw new s("editing:features-different-layers","Cannot start workflow with features from different layers.");return 1===e.length?this.startUpdateWorkflowAtFeatureEdit(t[0]):this.startUpdateFeaturesWorkflow(t)}if(!t.visibleFeatureCount)throw new s("editing:missing-selection","Unable to determine visible selection.");if(t.visibleLayerCount>1)throw new s("editing:features-different-layers","Cannot start workflow with features from different layers.");const i=t.activeLayerItem??t.layerItems.find((e=>e.total>0));if(!i)throw new s("editing:no-layer-item","Unable to determine source layer of active selection.");const r=i.featureItems.map((e=>e.graphic));1===r.length?this.startUpdateWorkflowAtFeatureEdit(r[0]):this.startUpdateFeaturesWorkflow(r)}async deleteFeatureFromWorkflow(){o(d.getLogger(this),"EditorViewModel.deleteFeatureFromWorkflow is deprecated. Use EditorViewModel.deleteFeatures instead.",{version:"4.33",replacement:"EditorViewModel.deleteFeatures",warnOnce:!0}),await this.deleteFeatures()}async deleteFeatures(){const e=this.activeWorkflow;return N(e)?e.deleteActiveFeature():B(e)?e.deleteAndCommit():void this._logError("editing:unsupported-workflow","Deleting features requires an active update workflow.")}async deleteAssociationFromWorkflow(){const{activeWorkflow:e}=this;e&&"update"===e.type?await e.deleteActiveAssociation():this._logError("editing:unsupported-workflow","Deleting an association requires an active update workflow.")}async cancelWorkflow(e){return this._cancelWorkflow({warnIfNoWorkflow:!0,...e})}findEditorItemForLayer(e){return this.editorItems.find((t=>t.layer===e))}itemHasInvalidFormTemplate(e){return null!=e&&!0===this.findEditorItemForLayer(e.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){this._featureTemplatesViewModelIsRestricted||this._updateTemplates()}zoomTo(e){const{view:t,sketchViewModel:r}=this;if(!t)return;const a=e??r?.createGraphic;if(a)"mesh"===a.geometry?.type?Y(t,a.geometry):Y(t,a);else{const e=r?.updateGraphics?.toArray();"3d"===t.type&&e?.some((e=>"mesh"===e.geometry?.type))?Y(t,e.map((e=>e.geometry)).filter(i)):e&&Y(t,e)}}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 onSelectionListItemSelect(e){ee(e)&&this.startUpdateWorkflowAtFeatureEdit(e.graphic)}async onSelectionListMenuItemSelect(e){if(ee(e))this.startUpdateWorkflowAtFeatureEdit(e.graphic);else if(te(e)){const t=e.featureItems.map((e=>e.graphic));1===t.length?this.startUpdateWorkflowAtFeatureEdit(t[0]):this.startUpdateFeaturesWorkflow(t)}}restrictFeatureTemplatesViewModelToLayer(e){return this._featureTemplatesViewModelIsRestricted=!0,this._setFeatureTemplatesViewModelLayers([e]),l((()=>{this._featureTemplatesViewModelIsRestricted=!1,this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)}))}async _getEditorItemCandidates(e){const{view:t}=this;if(!t?.map)return[];const{map:i}=t,r=i.editableLayers.toArray(),a=i.allTables.toArray().filter((e=>V(e)||S(e)));return await Promise.allSettled([...r.flatMap((e=>this._getLayerLoadPromise(e))),...a.flatMap((e=>this._getLayerLoadPromise(e)))]),h(e),[...r.reverse(),...a.reverse()].filter((e=>b(e)&&("mesh"!==e.geometryType||"3d"===t.type))).flatMap((e=>"subtype-group"===e.type?e.sublayers.toArray():e))}_getLayerLoadPromise(e){return S(e)?e.loadAll():e.load()}_drainEditorItems(){this.editorItems.drain((e=>e.destroy()))}_updateEditorItems(){p(this._updateItemsTask);const{view:e}=this,t=r((async t=>{if(!e?.map||!e?.allLayerViews)return;const i=await this._getEditorItemCandidates(t);if(!i.length)return void this._drainEditorItems();const r=[],a=[],o=[],{layerInfos:s}=this;for(const l of i){const t=ae(s,l),i=await z(e,l).catch((()=>null));(t?r:i?a:o).push(new Z({layer:l,layerInfo:t,layerView:i}))}s?.length&&r.sort(((e,t)=>s.findIndex((({layer:t})=>t===e.layer))-s.findIndex((({layer:e})=>e===t.layer))));const n=[...r,...a,...o];t.aborted||(this._drainEditorItems(),this.editorItems.addMany(n))}));this._updatingHandles.addPromise(t.promise),this._updateItemsTask=t}_updateTemplates(){p(this._updateTemplatesTask);const e=r((async e=>{const t=this._templatesByLayer,i=this._featureTemplatesLayersAndTables.filter((e=>!t.has(e)));if(i.length>0){const r=await E(i.toArray(),this.view,e);for(const{layer:e,templates:i}of r)t.set(e,i)}this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)}));this._updatingHandles.addPromise(e.promise),this._updateTemplatesTask=e}_setFeatureTemplatesViewModelLayers(e){const t=this._templatesByLayer,i=[];for(const r of e){const e=t.get(r);e&&e.length>0&&i.push($(r,e))}this.featureTemplatesViewModel.templateInfos=i}_afterEditorItemsChange(){const{activeWorkflow:e}=this;if(this.syncFeatureTemplates(),!e)return;const{stepId:t}=e;"create-features"!==e.type?"update"===e.type&&("awaiting-feature-to-update"===t&&!this.canUpdateVisible||"awaiting-update-feature-candidate"===t&&!e.hasUpdatableCandidates)&&this._cancelWorkflow():"awaiting-feature-creation-info"!==t||this.canCreate||this._cancelWorkflow()}async _cancelWorkflow(e){const t=this.activeWorkflow;if(!t)return void(e?.warnIfNoWorkflow&&this._logError("editing:no-active-workflow","There is no active workflow to cancel."));if(!e||!1!==e.force){this.emit("workflow-cancel"),this._set("activeWorkflow",null);try{await t.cancel(e)}finally{t.destroy()}}else try{await t.cancel(e),this._set("activeWorkflow",null),t.destroy()}catch(i){}}_createCreateFeaturesWorkflow(e,t){return R.create({viewModel:this,creationInfo:e,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEditsCallback:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureServiceCallback:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)})}_createUpdateFeaturesWorkflow(e){const t=H.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,features:e,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i)});return t.addHandles(m((()=>t),"commit",(()=>{t.destroy(),this.activeWorkflow===t&&this._set("activeWorkflow",null)}))),t}_createUpdateWorkflow(e){return q.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:e,applyEditsCallback:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureServiceCallback:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)})}_addAttachments(e,t){const i=t.map((t=>this._addAttachment(e,t.feature,t.attachment)))??[];return Promise.all(i)}async _addAttachment(e,t,i){let r=null;if(!("addAttachment"in e)||null==e.capabilities?.attachment)throw new s("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(r=await(e.addAttachment?.(t,i).catch((e=>{throw e?.error||e})))??null,r))),r}async _applyEdits(e,t,i){let r=null;const a=e.url?await L(e.url):null,o={returnServiceEditsOption:(!a||!I(a))&&!RegExp("/hosted/","i").test(e.url)?"original-and-current-features":void 0,...i};return await this._queueOperation((async()=>{const{view:i}=this;if(!i)return null;const a=await z(i,e).catch((()=>null));return r=await e.applyEdits(t,o),a&&await _((()=>!a.updating)),r})),r}async _applyEditsFeatureService(e,t,i){let r=null;return await this._queueOperation((async()=>r=await e.applyEdits(t,i))),r}_queueOperation(e){this._activityQueue.push(e);const t=(e,t)=>{const i=t.indexOf(e);i>-1&&t.splice(i,1)};return e().then((e=>(Array.isArray(e)?e.forEach((e=>this._handleEditsResultError(e))):this._handleEditsResultError(e),e))).catch((i=>{this._logError("editing:operation-error","An error occurred.",{error:i});const r={error:i,retry:()=>(t(r,this.failures),this._queueOperation(e)),cancel:()=>{t(r,this.failures)}};this._set("failures",[...this.failures,r])})).then((()=>{t(e,this._activityQueue)}))}_handleEditsResultError(e){if(null!=e&&"error"in e&&null!=e.error)throw e.error;if(null!=e&&"addFeatureResults"in e){const{addFeatureResults:t,deleteFeatureResults:i,updateFeatureResults:r}=e,a=t.find((e=>!!e.error))||r.find((e=>!!e.error))||i.find((e=>!!e.error));if(a)throw a.error}}_createUpdatingResolver(){const e=f();return this._updatingHandles.addPromise(e.promise),e}_logErrorAndCancelWorkflow(e){const{name:t,message:i,details:r}=e;this._logError(t??"editing:workflow-start-failed",i??void 0,r??e),this._cancelWorkflow({force:!0})}_itemIsSuspended(e){const t=this.findEditorItemForLayer(e);return null!=t&&(!t.visible||t.disabled)}_logError(e,t,i){d.getLogger(this).error(new s(e,t,i))}_syncSelectionSources(){this.selectionManager.sources.items=this._selectionSources.toArray()}async _onSelectionComplete(e){if(e.aborted)return;const{operationType:t,selection:i}=e,{effectiveSelectionManager:r}=this,a="ready"===this.state,o=1===i.length;if(this._queuedSelectionTool=void 0,a&&o&&(0===r.count&&"add"===t||"replace"===t))return this._queuedSelectionTool=e.toolName,this.startUpdateWorkflowAtFeatureEdit(i[0]);switch(t){case"remove":r.updateSelection({current:[],added:[],removed:i});break;case"replace":r.clear(),r.updateSelection({current:i,added:[],removed:[]});break;case"add":r.updateSelection({current:i,added:[],removed:[]})}}};e([W()],oe.prototype,"_featureTemplatesLayersAndTables",null),e([W()],oe.prototype,"_queuedSelectionTool",void 0),e([W()],oe.prototype,"_snappingManager",void 0),e([W()],oe.prototype,"_selectionSources",null),e([W()],oe.prototype,"activeFeatureCount",null),e([W({readOnly:!0})],oe.prototype,"activeWorkflow",void 0),e([W()],oe.prototype,"activeLeafWorkflow",null),e([W({readOnly:!0})],oe.prototype,"_activityQueue",void 0),e([W({readOnly:!0})],oe.prototype,"canCreate",null),e([W()],oe.prototype,"canCreateVisible",null),e([W({readOnly:!0})],oe.prototype,"canUpdate",null),e([W()],oe.prototype,"canUpdateVisible",null),e([W()],oe.prototype,"featureTemplatesLayers",null),e([W()],oe.prototype,"editorItems",void 0),e([W()],oe.prototype,"effectiveSelectionManager",null),e([W({readOnly:!0})],oe.prototype,"failures",void 0),e([W()],oe.prototype,"hideTemplatesForInactiveLayers",void 0),e([W({type:P})],oe.prototype,"attachmentsViewModel",void 0),e([W()],oe.prototype,"featureFormViewModel",null),e([W()],oe.prototype,"formViewModel",null),e([W()],oe.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),e([W({type:J})],oe.prototype,"featureTemplatesViewModel",void 0),e([W()],oe.prototype,"labelOptions",null),e([W()],oe.prototype,"layerInfos",void 0),e([W()],oe.prototype,"ownSketchViewModel",void 0),e([W()],oe.prototype,"selectionListViewModel",void 0),e([W()],oe.prototype,"selectionManager",void 0),e([W()],oe.prototype,"selectionToolbarViewModel",void 0),e([W()],oe.prototype,"sketchOptions",void 0),e([W()],oe.prototype,"sketchViewModel",null),e([W({type:O,nonNullable:!0})],oe.prototype,"snappingOptions",void 0),e([W()],oe.prototype,"spinnerViewModel",void 0),e([W()],oe.prototype,"state",null),e([W({readOnly:!0})],oe.prototype,"syncing",null),e([W()],oe.prototype,"updating",null),e([W()],oe.prototype,"tooltipOptions",null),e([W()],oe.prototype,"valueOptions",null),e([W()],oe.prototype,"view",null),e([W()],oe.prototype,"canZoomTo",null),e([W()],oe.prototype,"pageStack",void 0),e([W()],oe.prototype,"showDiscardEditsPrompt",void 0),e([W()],oe.prototype,"_candidateCommitted",void 0),e([W()],oe.prototype,"page",null),e([W()],oe.prototype,"featureFormDisabled",null),e([W()],oe.prototype,"featureFormHasAssociation",null),e([W()],oe.prototype,"canGoBack",null),e([W()],oe.prototype,"shouldShowDeleteButton",null),e([W()],oe.prototype,"hasPendingEdits",null),e([W()],oe.prototype,"snappingManager",null),oe=e([M("esri.widgets.Editor.EditorViewModel")],oe);const se=oe;export{se as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{unique as t,isSome as i}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{deprecatedFunction as o}from"../../core/deprecate.js";import s from"../../core/Error.js";import n from"../../core/Evented.js";import{makeHandle as l}from"../../core/handleUtils.js";import c from"../../core/Logger.js";import{destroyMaybe as d,abortMaybe as p,removeMaybe as u}from"../../core/maybe.js";import{throwIfAborted as h,createResolver as w}from"../../core/promiseUtils.js";import{watch as f,on as m,when as y,syncAndInitial as g,initial as v,sync as k,whenOnce as _}from"../../core/reactiveUtils.js";import{property as M}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as W}from"../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as F}from"../../core/support/UpdatingHandles.js";import{getTemplatesForLayers as E}from"../../editing/templateUtils.js";import b from"../../layers/GraphicsLayer.js";import{isEditableLayer as T}from"../../layers/support/editableLayers.js";import{isFeatureLayer as V,isSubtypeGroupLayer as S,getOwningPortalUrl as L}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as I}from"../../portal/support/urlUtils.js";import A from"../../views/SelectionManager.js";import U from"../../views/interactive/sketch/SketchOptions.js";import{SnappingManager as C}from"../../views/interactive/snapping/SnappingManager.js";import O from"../../views/interactive/snapping/SnappingOptions.js";import{isSelectableLayer as j}from"../../views/support/selectionUtils.js";import P from"../Attachments/AttachmentsViewModel.js";import R from"./CreateFeaturesWorkflow.js";import H from"./UpdateFeaturesWorkflow.js";import q from"./UpdateWorkflow.js";import{getLayersFromWorkflow as G,isCreateFeaturesWorkflow as x,isUpdateRecordWorkflow as D,isUpdateFeaturesWorkflow as B,isUpdateWorkflow as N,makeMultipleSourceLayersError as Q,whenEditorLayerView as z}from"./workflowUtils.js";import Z from"./support/EditorItem.js";import{makeTemplateGroupInfoForLayer as $}from"../FeatureTemplates/featureTemplatesUtils.js";import J from"../FeatureTemplates/FeatureTemplatesViewModel.js";import K from"../Sketch/SketchViewModel.js";import X from"../Spinner/SpinnerViewModel.js";import{goTo as Y}from"../support/goToUtils.js";import{isFeatureItem as ee,isLayerItem as te}from"../support/SelectionList/selectionListUtils.js";import ie from"../support/SelectionList/SelectionListViewModel.js";import re from"../support/SelectionToolbar/SelectionToolbarViewModel.js";function ae(e,t){return e?.find((e=>e.layer===t))}let oe=class extends n.EventedAccessor{constructor(e){super(e),this._queuedSelectionTool=null,this._sketchEventListenerHandle=null,this._sketchGraphicsLayer=new b({listMode:"hide",internal:!0}),this._snappingManager=null,this._templatesByLayer=new Map,this._updateItemsTask=null,this._updateTemplatesTask=null,this._updatingHandles=new F,this._featureTemplatesViewModelIsRestricted=!1,this.activeWorkflow=null,this._activityQueue=new a,this.editorItems=new a,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new P({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new J({disabledItemFunction:({layer:e})=>this._itemIsSuspended(e)}),this.layerInfos=null,this.ownSketchViewModel=new K({layer:this._sketchGraphicsLayer}),this.selectionListViewModel=new ie,this.selectionManager=new A,this.selectionToolbarViewModel=new re({continuousSelectionEnabled:!0,defaultOperationType:"replace",persistSelection:!1,returnGeometry:!1}),this.sketchOptions=new U,this.snappingOptions=new O({attributeRulesEnabled:!0}),this.spinnerViewModel=new X,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.back=async()=>{if("viewing-selection-list"===this.state)return this.selectionListViewModel.filterText=void 0,void this.effectiveSelectionManager.clear();this.canGoBack&&(this.activeWorkflow?.hasPreviousStep?await this.activeWorkflow.back(this.showDiscardEditsPrompt):await this._cancelWorkflow({force:!this.hasPendingEdits}))},this.saveWorkflow=async()=>await(this.activeWorkflow?.save()),this.selectFeature=(e,t=!1)=>{const i=this.activeWorkflow;this._candidateCommitted||"update"!==i?.type||(i.data.rootFeature=e,t&&(i.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([f((()=>{const e=this.view,t=e?.map?.editableLayers.toArray(),i=e?.allLayerViews,r=i?.filter((e=>!!t?.includes(e.layer)));return[t,r,this.layerInfos]}),(()=>this._updateEditorItems()),g),f((()=>this.hideTemplatesForInactiveLayers),(()=>this.syncFeatureTemplates())),f((()=>this._selectionSources),(()=>this._syncSelectionSources()),v),m((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),m((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),m((()=>this.activeWorkflow),"complete",(()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)})),y((()=>!this.activeWorkflow&&this._queuedSelectionTool),(()=>this._queuedSelectionTool&&this.selectionToolbarViewModel.activateTool(this._queuedSelectionTool))),f((()=>this.activeWorkflow),(e=>this.selectionManager.showHighlight=!e)),y((()=>this.view?.map),(e=>e.add(this._sketchGraphicsLayer)),v),m((()=>this.editorItems),"change",(()=>this._afterEditorItemsChange())),f((()=>[this.canCreate,this.canUpdateVisible]),(()=>this._afterEditorItemsChange())),f((()=>this.page),((e,t)=>{const i=[...this.pageStack];if(-1===i.indexOf(e))i.push(e);else for(;i.length&&i.at(-1)!==e;)i.pop();this.pageStack=i}),g),y((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1)),m((()=>this.featureTemplatesViewModel),"select",(async({item:e,oldItem:t})=>{const{activeWorkflow:i}=this;if(i){if("update"===i.type&&"awaiting-feature-creation-info"===i.activeWorkflow?.stepId)return;try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return void this.featureTemplatesViewModel.select(t,{emit:!1})}}if(!e)return;const r={layer:e.layer,template:e.template};if(e.supportsUpload)return this.featureTemplatesViewModel.select(t,{emit:!1}),this.startCreateFeaturesWorkflow(r);this.startCreateFeaturesWorkflowAtFeatureCreation(r)})),f((()=>[this.view,this.featureTemplatesViewModel]),(([e,t])=>{t.view=e}),g),m((()=>this.view),"key-down",(e=>{"Escape"===e.key&&this.activeWorkflow?.keyboardCancellationEnabled&&(e.stopPropagation(),this.back())})),m((()=>this.sketchViewModel),["create","delete","update"],(e=>{const{activeWorkflow:t}=this,i="update"===t?.type,r=G(t),a=i?t?.activeWorkflow?.parentLayer:void 0,o=`sketch-${e.type}`;this.emit(o,{type:o,detail:e,layer:r[0],layers:r,parentLayer:a})}),k),f((()=>this.view),(e=>{if(this._snappingManager=d(this._snappingManager),!e)return;const t=this.snappingOptions;this._snappingManager=new C({view:e,options:t}),this.ownSketchViewModel.snappingManager=this._snappingManager}),g),f((()=>this.snappingOptions),(e=>{this._snappingManager&&(this._snappingManager.options=e)}),g),m((()=>this.selectionToolbarViewModel),"complete",(e=>this._onSelectionComplete(e))),f((()=>({view:this.view,selectionManager:this.effectiveSelectionManager,selectionListViewModel:this.selectionListViewModel,selectionToolbarViewModel:this.selectionToolbarViewModel})),(({view:e,selectionManager:t,selectionListViewModel:i,selectionToolbarViewModel:r})=>{t.view=e,i.view=e,r.view=e}),g),f((()=>this.effectiveSelectionManager),(e=>{this.selectionListViewModel.selectionManager=e,this.selectionToolbarViewModel.selectionManager=e}),g)])}destroy(){this._cancelWorkflow({warnIfNoWorkflow:!1}).then((()=>{this.view?.map?.remove(this._sketchGraphicsLayer),this.view=null})),this._updateItemsTask=p(this._updateItemsTask),this._updatingHandles.destroy(),this._sketchEventListenerHandle=u(this._sketchEventListenerHandle),this.selectionListViewModel?.destroy(),this.selectionToolbarViewModel?.destroy(),this.selectionManager.destroy()}get _featureTemplatesLayersAndTables(){const e=new a;for(const t of this.editorItems){const i=this.hideTemplatesForInactiveLayers&&!t.visible;t.supportsCreateFeaturesWorkflow&&!i&&e.push(t.layer)}return e}get _selectionSources(){const e=new a;for(const t of this.editorItems)j(t.layer)&&t.supportsUpdateWorkflow&&t.visible&&e.push(t.layer);return e}get activeFeatureCount(){const e=this.activeLeafWorkflow;return x(e)?e.pendingFeatures.length:D(e)&&e.data.edits.feature?1:B(e)?e.data.features.length:0}get activeLeafWorkflow(){const e=this.activeWorkflow;return e&&N(e)?e.activeWorkflow??e:e}get canCreate(){return this.editorItems.some((e=>e.supportsCreateFeaturesWorkflow))}get canCreateVisible(){return!!this.featureTemplatesLayers.length}get canUpdate(){return this.editorItems.some((e=>e.supportsUpdateWorkflow))}get canUpdateVisible(){return this.editorItems.some((e=>e.supportsUpdateWorkflow&&e.visible))}get featureTemplatesLayers(){return this._featureTemplatesLayersAndTables.filter((e=>"scene"===e.type||!e.isTable))}get effectiveSelectionManager(){return this.selectionManager}get featureFormViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeFeatureFormViewModel:"create-features"===e?.type?e.featureFormViewModel:null}get formViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeFeatureFormViewModel:"create-features"===e?.type?e.featureFormViewModel:"update-features"===e?.type?e.formViewModel:null}get utilityNetworkAssociationAddAssociationViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeUtilityNetworkAssociationAddAssociationViewModel:null}get labelOptions(){return this.sketchOptions.labels}set labelOptions(e){this.sketchOptions.labels=e}get sketchViewModel(){const{activeWorkflow:e}=this;return"update"===e?.type?e.activeSketchViewModel:"create-features"===e?.type?e.sketchViewModel:this.ownSketchViewModel}get state(){if(!this.view?.ready)return"disabled";const e=this.attachmentsViewModel.mode;if("add"===e)return"adding-attachment";if("edit"===e)return"editing-attachment";const{activeWorkflow:t}=this,i=!t?.stepId;return this.effectiveSelectionManager.count&&i?"viewing-selection-list":i?"ready":"update"===t.type&&t.activeWorkflow?.stepId?t.activeWorkflow.stepId:t.stepId}get syncing(){return this._activityQueue.length>0}get updating(){return this._updatingHandles.updating||!0===this.activeWorkflow?.updating}get tooltipOptions(){return this.sketchOptions.tooltips}set tooltipOptions(e){this.sketchOptions.tooltips=e}get valueOptions(){return this.sketchOptions.values}set valueOptions(e){this.sketchOptions.values=e}set view(e){this.ownSketchViewModel.view=e,this.spinnerViewModel.view=e,this._set("view",e)}get canZoomTo(){const e=this.sketchViewModel,t=e?.createGraphic?.geometry?.type;return!(!e?.updateGraphics?.length&&"multipoint"!==t)}get page(){const{activeWorkflow:e,state:t}=this;if("update"===e?.type&&null!=e?.activeWorkflow?.featureFormViewModel?.associatedLayer)return"viewing-associated-features";if("update"===e?.type&&null!=e?.activeWorkflow?.featureFormViewModel?.associationId)return"viewing-associated-layers";if("update"===e?.type&&"awaiting-feature-to-update"===e.stepId)return"ready";if("create-features"===e?.type&&0===e.numPendingFeatures){const t=e.data.upload;if(t)return"default"===t.state?"ready":"creating-features-upload-details"}return t??"disabled"}get featureFormDisabled(){const{activeWorkflow:e}=this;return"update"===e?.type&&(!1===e.activeEditorItem?.capabilities.update.attributes||!0===e.activeFeatureFormViewModel?.disabled)}get featureFormHasAssociation(){return!!this.featureFormViewModel?.activeAssociation}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:e}=this;return!this.featureFormDisabled&&(N(e)&&e.activeEditorItem?.capabilities.delete.enabled||B(e)&&e.data.editorItems.every((e=>e.capabilities.delete.enabled)))}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}get snappingManager(){return this._snappingManager}getTemplatesForLayer(e){return this._templatesByLayer.get(e)??[]}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateFeaturesWorkflowAtFeatureCreation(e){return this.startCreateFeaturesWorkflow(e,"creating-features")}async startCreateFeaturesWorkflow(e,t="awaiting-feature-creation-info"){if(await _((()=>!this.updating)),!this.canCreate)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled.");const i=this._createUpdatingResolver();try{await this._cancelWorkflow();const i=this._createCreateFeaturesWorkflow(e,t);this._set("activeWorkflow",i),await i.start()}catch(r){this._logErrorAndCancelWorkflow(r)}finally{i.resolve()}}async startCreateFeaturesWorkflowAtFeatureEdit(e){await _((()=>!this.updating));const t=this._createUpdatingResolver();try{const{initialFeature:t}=e,i=t.sourceLayer=t.layer,r=i?this.findEditorItemForLayer(i):void 0;if(!r?.supportsCreateFeaturesWorkflow)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled for this layer.");await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow({initialFeature:t,layer:r.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",a),await a.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateFeaturesWorkflow(e){if(await _((()=>!this.updating)),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update features workflow is unsupported or disabled.");if(t(e.map((e=>e.sourceLayer??e.layer))).length>1)throw Q();const i=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateFeaturesWorkflow(e);this._set("activeWorkflow",t),await t.start()}catch(r){this._logErrorAndCancelWorkflow(r)}finally{i.resolve()}}async startUpdateWorkflowAtFeatureSelection(){if(await _((()=>!this.updating)),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const e=this._createUpdatingResolver();try{await this._cancelWorkflow();const e=this._createUpdateWorkflow();this._set("activeWorkflow",e),await e.start()}catch(t){this._logErrorAndCancelWorkflow(t)}finally{e.resolve()}}async startUpdateWorkflowAtMultipleFeatureSelection(e){if(await _((()=>!this.updating)),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateWorkflow("awaiting-update-feature-candidate");t.data.candidates=e,this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowAtFeatureEdit(e){if(await _((()=>!this.updating)),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update workflow is unsupported or disabled.");const t=this._createUpdatingResolver();try{await this._cancelWorkflow();const t=this._createUpdateWorkflow("editing-existing-feature");t.data.rootFeature=e,t.addHandles(m((()=>t),"commit",(()=>{t.destroy(),this.activeWorkflow===t&&this._set("activeWorkflow",null)}))),this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowWithActiveSelection(){const{selectionListViewModel:e}=this;if(!e.visibleFeatureCount)throw new s("editing:missing-selection","Unable to determine visible selection.");if(e.visibleLayerCount>1)throw new s("editing:features-different-layers","Cannot start workflow with features from different layers.");const t=e.visibleFeatureItems.map((e=>e.graphic));1===t.length?this.startUpdateWorkflowAtFeatureEdit(t[0]):this.startUpdateFeaturesWorkflow(t)}async deleteFeatureFromWorkflow(){o(c.getLogger(this),"EditorViewModel.deleteFeatureFromWorkflow is deprecated. Use EditorViewModel.deleteFeatures instead.",{version:"4.33",replacement:"EditorViewModel.deleteFeatures",warnOnce:!0}),await this.deleteFeatures()}async deleteFeatures(){const e=this.activeWorkflow;return N(e)?e.deleteActiveFeature():B(e)?e.deleteAndCommit():void this._logError("editing:unsupported-workflow","Deleting features requires an active update workflow.")}async deleteAssociationFromWorkflow(){const{activeWorkflow:e}=this;e&&"update"===e.type?await e.deleteActiveAssociation():this._logError("editing:unsupported-workflow","Deleting an association requires an active update workflow.")}async cancelWorkflow(e){return this._cancelWorkflow({warnIfNoWorkflow:!0,...e})}findEditorItemForLayer(e){return this.editorItems.find((t=>t.layer===e))}itemHasInvalidFormTemplate(e){return null!=e&&!0===this.findEditorItemForLayer(e.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){this._featureTemplatesViewModelIsRestricted||this._updateTemplates()}zoomTo(e){const{view:t,sketchViewModel:r}=this;if(!t)return;const a=e??r?.createGraphic;if(a)"mesh"===a.geometry?.type?Y(t,a.geometry):Y(t,a);else{const e=r?.updateGraphics?.toArray();"3d"===t.type&&e?.some((e=>"mesh"===e.geometry?.type))?Y(t,e.map((e=>e.geometry)).filter(i)):e&&Y(t,e)}}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 onSelectionListItemSelect(e){ee(e)&&this.startUpdateWorkflowAtFeatureEdit(e.graphic)}async onSelectionListMenuItemSelect(e){if(ee(e))this.startUpdateWorkflowAtFeatureEdit(e.graphic);else if(te(e)){const t=e.featureItems.filter((e=>e.visible)).map((e=>e.graphic));1===t.length?this.startUpdateWorkflowAtFeatureEdit(t[0]):this.startUpdateFeaturesWorkflow(t)}}restrictFeatureTemplatesViewModelToLayer(e){return this._featureTemplatesViewModelIsRestricted=!0,this._setFeatureTemplatesViewModelLayers([e]),l((()=>{this._featureTemplatesViewModelIsRestricted=!1,this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)}))}async _getEditorItemCandidates(e){const{view:t}=this;if(!t?.map)return[];const{map:i}=t,r=i.editableLayers.toArray(),a=i.allTables.toArray().filter((e=>V(e)||S(e)));return await Promise.allSettled([...r.flatMap((e=>this._getLayerLoadPromise(e))),...a.flatMap((e=>this._getLayerLoadPromise(e)))]),h(e),[...r.reverse(),...a.reverse()].filter((e=>T(e)&&("mesh"!==e.geometryType||"3d"===t.type))).flatMap((e=>"subtype-group"===e.type?e.sublayers.toArray():e))}_getLayerLoadPromise(e){return S(e)?e.loadAll():e.load()}_drainEditorItems(){this.editorItems.drain((e=>e.destroy()))}_updateEditorItems(){p(this._updateItemsTask);const{view:e}=this,t=r((async t=>{if(!e?.map||!e?.allLayerViews)return;const i=await this._getEditorItemCandidates(t);if(!i.length)return void this._drainEditorItems();const r=[],a=[],o=[],{layerInfos:s}=this;for(const l of i){const t=ae(s,l),i=await z(e,l).catch((()=>null));(t?r:i?a:o).push(new Z({layer:l,layerInfo:t,layerView:i}))}s?.length&&r.sort(((e,t)=>s.findIndex((({layer:t})=>t===e.layer))-s.findIndex((({layer:e})=>e===t.layer))));const n=[...r,...a,...o];t.aborted||(this._drainEditorItems(),this.editorItems.addMany(n))}));this._updatingHandles.addPromise(t.promise),this._updateItemsTask=t}_updateTemplates(){p(this._updateTemplatesTask);const e=r((async e=>{const t=this._templatesByLayer,i=this._featureTemplatesLayersAndTables.filter((e=>!t.has(e)));if(i.length>0){const r=await E(i.toArray(),this.view,e);for(const{layer:e,templates:i}of r)t.set(e,i)}this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)}));this._updatingHandles.addPromise(e.promise),this._updateTemplatesTask=e}_setFeatureTemplatesViewModelLayers(e){const t=this._templatesByLayer,i=[];for(const r of e){const e=t.get(r);e&&e.length>0&&i.push($(r,e))}this.featureTemplatesViewModel.templateInfos=i}_afterEditorItemsChange(){const{activeWorkflow:e}=this;if(this.syncFeatureTemplates(),!e)return;const{stepId:t}=e;"create-features"!==e.type?"update"===e.type&&("awaiting-feature-to-update"===t&&!this.canUpdateVisible||"awaiting-update-feature-candidate"===t&&!e.hasUpdatableCandidates)&&this._cancelWorkflow():"awaiting-feature-creation-info"!==t||this.canCreate||this._cancelWorkflow()}async _cancelWorkflow(e){const t=this.activeWorkflow;if(!t)return void(e?.warnIfNoWorkflow&&this._logError("editing:no-active-workflow","There is no active workflow to cancel."));if(!e||!1!==e.force){this.emit("workflow-cancel"),this._set("activeWorkflow",null);try{await t.cancel(e)}finally{t.destroy()}}else try{await t.cancel(e),this._set("activeWorkflow",null),t.destroy()}catch(i){}}_createCreateFeaturesWorkflow(e,t){return R.create({viewModel:this,creationInfo:e,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEditsCallback:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureServiceCallback:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)})}_createUpdateFeaturesWorkflow(e){const t=H.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,features:e,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i)});return t.addHandles(m((()=>t),"commit",(()=>{t.destroy(),this.activeWorkflow===t&&this._set("activeWorkflow",null)}))),t}_createUpdateWorkflow(e){return q.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:e,applyEditsCallback:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureServiceCallback:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)})}_addAttachments(e,t){const i=t.map((t=>this._addAttachment(e,t.feature,t.attachment)))??[];return Promise.all(i)}async _addAttachment(e,t,i){let r=null;if(!("addAttachment"in e)||null==e.capabilities?.attachment)throw new s("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(r=await(e.addAttachment?.(t,i).catch((e=>{throw e?.error||e})))??null,r))),r}async _applyEdits(e,t,i){let r=null;const a=e.url?await L(e.url):null,o={returnServiceEditsOption:(!a||!I(a))&&!RegExp("/hosted/","i").test(e.url)?"original-and-current-features":void 0,...i};return await this._queueOperation((async()=>{const{view:i}=this;if(!i)return null;const a=await z(i,e).catch((()=>null));return r=await e.applyEdits(t,o),a&&await _((()=>!a.updating)),r})),r}async _applyEditsFeatureService(e,t,i){let r=null;return await this._queueOperation((async()=>r=await e.applyEdits(t,i))),r}_queueOperation(e){this._activityQueue.push(e);const t=(e,t)=>{const i=t.indexOf(e);i>-1&&t.splice(i,1)};return e().then((e=>(Array.isArray(e)?e.forEach((e=>this._handleEditsResultError(e))):this._handleEditsResultError(e),e))).catch((i=>{this._logError("editing:operation-error","An error occurred.",{error:i});const r={error:i,retry:()=>(t(r,this.failures),this._queueOperation(e)),cancel:()=>{t(r,this.failures)}};this._set("failures",[...this.failures,r])})).then((()=>{t(e,this._activityQueue)}))}_handleEditsResultError(e){if(null!=e&&"error"in e&&null!=e.error)throw e.error;if(null!=e&&"addFeatureResults"in e){const{addFeatureResults:t,deleteFeatureResults:i,updateFeatureResults:r}=e,a=t.find((e=>!!e.error))||r.find((e=>!!e.error))||i.find((e=>!!e.error));if(a)throw a.error}}_createUpdatingResolver(){const e=w();return this._updatingHandles.addPromise(e.promise),e}_logErrorAndCancelWorkflow(e){const{name:t,message:i,details:r}=e;this._logError(t??"editing:workflow-start-failed",i??void 0,r??e),this._cancelWorkflow({force:!0})}_itemIsSuspended(e){const t=this.findEditorItemForLayer(e);return null!=t&&(!t.visible||t.disabled)}_logError(e,t,i){c.getLogger(this).error(new s(e,t,i))}_syncSelectionSources(){this.selectionManager.sources.items=this._selectionSources.toArray()}async _onSelectionComplete(e){if(e.aborted)return;const{operationType:t,selection:i}=e,{effectiveSelectionManager:r}=this,a="ready"===this.state,o=1===i.length;if(this._queuedSelectionTool=void 0,a&&o&&(0===r.count&&"add"===t||"replace"===t))return this._queuedSelectionTool=e.toolName,this.startUpdateWorkflowAtFeatureEdit(i[0]);switch(t){case"remove":r.updateSelection({current:[],added:[],removed:i});break;case"replace":r.clear(),r.updateSelection({current:i,added:[],removed:[]});break;case"add":r.updateSelection({current:i,added:[],removed:[]})}}};e([M()],oe.prototype,"_featureTemplatesLayersAndTables",null),e([M()],oe.prototype,"_queuedSelectionTool",void 0),e([M()],oe.prototype,"_snappingManager",void 0),e([M()],oe.prototype,"_selectionSources",null),e([M()],oe.prototype,"activeFeatureCount",null),e([M({readOnly:!0})],oe.prototype,"activeWorkflow",void 0),e([M()],oe.prototype,"activeLeafWorkflow",null),e([M({readOnly:!0})],oe.prototype,"_activityQueue",void 0),e([M({readOnly:!0})],oe.prototype,"canCreate",null),e([M()],oe.prototype,"canCreateVisible",null),e([M({readOnly:!0})],oe.prototype,"canUpdate",null),e([M()],oe.prototype,"canUpdateVisible",null),e([M()],oe.prototype,"featureTemplatesLayers",null),e([M()],oe.prototype,"editorItems",void 0),e([M()],oe.prototype,"effectiveSelectionManager",null),e([M({readOnly:!0})],oe.prototype,"failures",void 0),e([M()],oe.prototype,"hideTemplatesForInactiveLayers",void 0),e([M({type:P})],oe.prototype,"attachmentsViewModel",void 0),e([M()],oe.prototype,"featureFormViewModel",null),e([M()],oe.prototype,"formViewModel",null),e([M()],oe.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),e([M({type:J})],oe.prototype,"featureTemplatesViewModel",void 0),e([M()],oe.prototype,"labelOptions",null),e([M()],oe.prototype,"layerInfos",void 0),e([M()],oe.prototype,"ownSketchViewModel",void 0),e([M()],oe.prototype,"selectionListViewModel",void 0),e([M()],oe.prototype,"selectionManager",void 0),e([M()],oe.prototype,"selectionToolbarViewModel",void 0),e([M()],oe.prototype,"sketchOptions",void 0),e([M()],oe.prototype,"sketchViewModel",null),e([M({type:O,nonNullable:!0})],oe.prototype,"snappingOptions",void 0),e([M()],oe.prototype,"spinnerViewModel",void 0),e([M()],oe.prototype,"state",null),e([M({readOnly:!0})],oe.prototype,"syncing",null),e([M()],oe.prototype,"updating",null),e([M()],oe.prototype,"tooltipOptions",null),e([M()],oe.prototype,"valueOptions",null),e([M()],oe.prototype,"view",null),e([M()],oe.prototype,"canZoomTo",null),e([M()],oe.prototype,"pageStack",void 0),e([M()],oe.prototype,"showDiscardEditsPrompt",void 0),e([M()],oe.prototype,"_candidateCommitted",void 0),e([M()],oe.prototype,"page",null),e([M()],oe.prototype,"featureFormDisabled",null),e([M()],oe.prototype,"featureFormHasAssociation",null),e([M()],oe.prototype,"canGoBack",null),e([M()],oe.prototype,"shouldShowDeleteButton",null),e([M()],oe.prototype,"hasPendingEdits",null),e([M()],oe.prototype,"snappingManager",null),oe=e([W("esri.widgets.Editor.EditorViewModel")],oe);const se=oe;export{se 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.34/esri/copyright.txt for details.
4
4
  */
5
- import{_ as o}from"../../chunks/tslib.es6.js";import r from"../../core/Error.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as e}from"../../core/accessorSupport/decorators/subclass.js";import s from"../../views/interactive/sketch/SketchOptions.js";import a from"./UpdateRecordWorkflowData.js";import{whenEditorLayerView as i}from"./workflowUtils.js";var p;let n=p=class extends a{constructor(o){super(o),this.sketchOptions=null,this.snappingManager=null}static async create(o){const{feature:t,snappingManager:e,viewModel:a}=o,n=o.sketchOptions??new s,{view:c}=a;if(!c)throw new r("editor:cannot-create-workflow-data","The provided EditorViewModel does not have an associated view");const d=await i(c,t.layer);return new p({...p._makeConstructorProps(o),layerView:d,sketchOptions:n,snappingManager:e})}};o([t()],n.prototype,"layerView",void 0),o([t({constructOnly:!0})],n.prototype,"sketchOptions",void 0),o([t()],n.prototype,"snappingManager",void 0),n=p=o([e("esri.widgets.Editor.UpdateFeatureWorkflowData")],n);const c=n;export{c as default};
5
+ import{_ as o}from"../../chunks/tslib.es6.js";import r from"../../core/Error.js";import{property as e}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as t}from"../../core/accessorSupport/decorators/subclass.js";import s from"../../views/interactive/sketch/SketchOptions.js";import a from"./UpdateRecordWorkflowData.js";import{whenEditorLayerView as i}from"./workflowUtils.js";var p;let n=p=class extends a{constructor(o){super(o),this.sketchOptions=null,this.snappingManager=null}static async create(o){const{feature:e,snappingManager:t,viewModel:a}=o,n=o.sketchOptions??new s,{view:c}=a;if(!c)throw new r("editor:cannot-create-workflow-data","The provided EditorViewModel does not have an associated view");const d=await i(c,e.layer??e.sourceLayer);return new p({...p._makeConstructorProps(o),layerView:d,sketchOptions:n,snappingManager:t})}};o([e()],n.prototype,"layerView",void 0),o([e({constructOnly:!0})],n.prototype,"sketchOptions",void 0),o([e()],n.prototype,"snappingManager",void 0),n=p=o([t("esri.widgets.Editor.UpdateFeatureWorkflowData")],n);const c=n;export{c as default};