@arcgis/core 5.1.0-next.73 → 5.1.0-next.75

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 (373) hide show
  1. package/Viewpoint.js +1 -1
  2. package/applications/Urban/editingSessionUtils.d.ts +95 -0
  3. package/applications/Urban/editingSessionUtils.js +2 -0
  4. package/arcade/ArcadePortal.js +1 -1
  5. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  6. package/arcade/functions/aiServices.js +1 -1
  7. package/arcade/functions/featuresetbase.js +1 -1
  8. package/arcade/functions/geomasync.js +1 -1
  9. package/arcade/functions/knowledgegraph.js +1 -1
  10. package/arcade/functions/string.js +1 -1
  11. package/arcade/languageUtils.js +1 -1
  12. package/arcade/portalUtils.js +1 -1
  13. package/assets/esri/core/workers/RemoteClient.js +1 -1
  14. package/assets/esri/core/workers/chunks/{d17fcfc502f0e0fa6523.js → 003476e950bd27a2f884.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{8a664451845a47048859.js → 0539b5d015157c1d34a0.js} +1 -1
  16. package/assets/esri/core/workers/chunks/07aca5ecad659d55e795.js +2 -0
  17. package/assets/esri/core/workers/chunks/{5a4d7ba6dc1d4b41d80d.js → 07eff82916681fcff069.js} +1 -1
  18. package/assets/esri/core/workers/chunks/09630888267cde87654f.js +1 -0
  19. package/assets/esri/core/workers/chunks/{8a14e3db28c403b046cf.js → 0d2bc1be5802681666a4.js} +1 -1
  20. package/assets/esri/core/workers/chunks/0eed2b1b06355ab89013.js +1 -0
  21. package/assets/esri/core/workers/chunks/0fa207c68dfd7ddee160.js +1 -0
  22. package/assets/esri/core/workers/chunks/146424b5717d0a645ee1.js +1 -0
  23. package/assets/esri/core/workers/chunks/{cfe246adb5e6cb6f0cfc.js → 14eb2cc8e2ad6d8d03fd.js} +1 -1
  24. package/assets/esri/core/workers/chunks/1765dfeac20e34ce25b7.js +1 -0
  25. package/assets/esri/core/workers/chunks/176dd195f77b98cb0b0f.js +1 -0
  26. package/assets/esri/core/workers/chunks/18f77ee3552d92962f15.js +1 -0
  27. package/assets/esri/core/workers/chunks/1906416c84bab369bbd6.js +1 -0
  28. package/assets/esri/core/workers/chunks/1a87e9bbd85ba29b1514.js +1 -0
  29. package/assets/esri/core/workers/chunks/{b98c24229463029504e8.js → 1f6b7626f333809837ef.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{b54b7cc6b23a70fed700.js → 1f8ccf96069ac3a40c3d.js} +1 -1
  31. package/assets/esri/core/workers/chunks/1ff3c15a51c4dc991806.js +1 -0
  32. package/assets/esri/core/workers/chunks/{cdf6ad970dc1893dac58.js → 24646a1176ce34039155.js} +1 -1
  33. package/assets/esri/core/workers/chunks/2a2e97918524e0f436d7.js +1 -0
  34. package/assets/esri/core/workers/chunks/2b0b398180ed98c2c84c.js +1 -0
  35. package/assets/esri/core/workers/chunks/{03894992558d063d0d5e.js → 312036c89a6a09bb06c2.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{80ace1c7203c5059525d.js → 330b47ac0759c3c35cc5.js} +1 -1
  37. package/assets/esri/core/workers/chunks/34b6b5dd415c68f0b0d1.js +1 -0
  38. package/assets/esri/core/workers/chunks/{422824e407b550170c8c.js → 34ea3ed78041437a8fc8.js} +1 -1
  39. package/assets/esri/core/workers/chunks/{93ceb74ac88ef460fe5f.js → 359d3acb3953e64e5a78.js} +1 -1
  40. package/assets/esri/core/workers/chunks/384c235d36f32769e32b.js +1 -0
  41. package/assets/esri/core/workers/chunks/3a183259805638c25363.js +1 -0
  42. package/assets/esri/core/workers/chunks/{0839da55707f7c4cf780.js → 3b9100c59a8050f4834e.js} +1 -1
  43. package/assets/esri/core/workers/chunks/{deaca3cd202851ecf9c2.js → 3cce9dad8ee0e4971d50.js} +1 -1
  44. package/assets/esri/core/workers/chunks/3efbb684c0409955186d.js +1 -0
  45. package/assets/esri/core/workers/chunks/40d251b6b42a41d68bd2.js +1 -0
  46. package/assets/esri/core/workers/chunks/42336e0d1ef88737b078.js +1 -0
  47. package/assets/esri/core/workers/chunks/452c01cecbbd1e370098.js +1 -0
  48. package/assets/esri/core/workers/chunks/47656ec12401e53f4bd3.js +1 -0
  49. package/assets/esri/core/workers/chunks/47b3a5213539548ff3a6.js +1 -0
  50. package/assets/esri/core/workers/chunks/{260d4571722cb1ff1366.js → 484d6c1b0fe1633515b7.js} +1 -1
  51. package/assets/esri/core/workers/chunks/4a23b27bfbcfa08fd9a7.js +1 -0
  52. package/assets/esri/core/workers/chunks/4c97cc922eece3a91b6b.js +1 -0
  53. package/assets/esri/core/workers/chunks/52b3a11c962810bc6dbe.js +1 -0
  54. package/assets/esri/core/workers/chunks/53750e85f3128993a43a.js +1 -0
  55. package/assets/esri/core/workers/chunks/{f207b3be0714cc50030a.js → 537fe2522dff1e6ce03b.js} +1 -1
  56. package/assets/esri/core/workers/chunks/{656d6963e8f837fbf28f.js → 54023458195549f66215.js} +1 -1
  57. package/assets/esri/core/workers/chunks/55fd201ca5e10c6e4761.js +1 -0
  58. package/assets/esri/core/workers/chunks/56941e8bbd2d49bf2656.js +1 -0
  59. package/assets/esri/core/workers/chunks/{faad127dc07e54e7f6d1.js → 5abe34bb0110694f7b42.js} +1 -1
  60. package/assets/esri/core/workers/chunks/5d8e944b192aad4cf986.js +1 -0
  61. package/assets/esri/core/workers/chunks/{a78bc340a794fd332667.js → 5e1b847b116d21908a54.js} +1 -1
  62. package/assets/esri/core/workers/chunks/5ed8d8b5336c81fbcda3.js +1 -0
  63. package/assets/esri/core/workers/chunks/60915a3708a34da1977e.js +1 -0
  64. package/assets/esri/core/workers/chunks/6124141ac642e4ce1454.js +1 -0
  65. package/assets/esri/core/workers/chunks/61c523dd9d8027922465.js +1 -0
  66. package/assets/esri/core/workers/chunks/65c61171e6c6be5c5c2f.js +1 -0
  67. package/assets/esri/core/workers/chunks/6a3d207308b29651f397.js +1 -0
  68. package/assets/esri/core/workers/chunks/{b6cadb8a579241adcb86.js → 6b66fc32451433129a88.js} +1 -1
  69. package/assets/esri/core/workers/chunks/6c35583707f5c339ee99.js +1 -0
  70. package/assets/esri/core/workers/chunks/6f7aaba26773fe416ac2.js +1 -0
  71. package/assets/esri/core/workers/chunks/702e8468836863abd81b.js +1 -0
  72. package/assets/esri/core/workers/chunks/7540f7df86620f067b5a.js +1 -0
  73. package/assets/esri/core/workers/chunks/{9f4b97204def91567e3c.js → 7595ceba529ed01c7590.js} +1 -1
  74. package/assets/esri/core/workers/chunks/75d5ea0da181f9e7425f.js +1312 -0
  75. package/assets/esri/core/workers/chunks/{af75e91b88e747aa76ac.js → 7601278ebced0c0c31cf.js} +1 -1
  76. package/assets/esri/core/workers/chunks/76e34f81bb4a7b0e694c.js +1 -0
  77. package/assets/esri/core/workers/chunks/{1661684357912726a72a.js → 77dd719516138afb1a2a.js} +1 -1
  78. package/assets/esri/core/workers/chunks/7b6c8be59ed87e386aa4.js +1 -0
  79. package/assets/esri/core/workers/chunks/7c820c5f6f05480d5050.js +1 -0
  80. package/assets/esri/core/workers/chunks/{ce2aa75e084ee56f5e29.js → 7f55eef696e9ed717bfc.js} +1 -1
  81. package/assets/esri/core/workers/chunks/80f4f686ce403cb2693f.js +1 -0
  82. package/assets/esri/core/workers/chunks/852f4cd514008fee5a55.js +1 -0
  83. package/assets/esri/core/workers/chunks/85aac8539996372f1ee8.js +1 -0
  84. package/assets/esri/core/workers/chunks/{50d5d6654ada9f28345d.js → 85e65ced3312bf9cf162.js} +1 -1
  85. package/assets/esri/core/workers/chunks/8a3bff0f58483c1665f9.js +1 -0
  86. package/assets/esri/core/workers/chunks/8b046e28f879079caada.js +1 -0
  87. package/assets/esri/core/workers/chunks/8d738e9acc2f222235ea.js +1 -0
  88. package/assets/esri/core/workers/chunks/{b9848bdbaf3d9ac93d54.js → 8f4cd30ce23e41c1a42c.js} +1 -1
  89. package/assets/esri/core/workers/chunks/9103eb0b9078019d3a26.js +1 -0
  90. package/assets/esri/core/workers/chunks/915e2711d3a2cfa402b2.js +1 -0
  91. package/assets/esri/core/workers/chunks/91f9e0e3662d4bf9f163.js +1 -0
  92. package/assets/esri/core/workers/chunks/983f6c8727fd9484718e.js +1 -0
  93. package/assets/esri/core/workers/chunks/99c161fecae710b53b40.js +1 -0
  94. package/assets/esri/core/workers/chunks/99d298d0039c536fcf3e.js +1 -0
  95. package/assets/esri/core/workers/chunks/9a5ef33d99a8f89956ff.js +1 -0
  96. package/assets/esri/core/workers/chunks/9d10db72e342fe63c981.js +1 -0
  97. package/assets/esri/core/workers/chunks/{bef27a25fbc4a6e19ec0.js → 9d6491f996eeb0c646ed.js} +1 -1
  98. package/assets/esri/core/workers/chunks/a015c2f54eb91e43a1f4.js +1 -0
  99. package/assets/esri/core/workers/chunks/a242ec19a7508de436da.js +1 -0
  100. package/assets/esri/core/workers/chunks/a320998f18922a35899f.js +1 -0
  101. package/assets/esri/core/workers/chunks/a7f9f478bd1493fc3c76.js +1 -0
  102. package/assets/esri/core/workers/chunks/aac6a57edd7494125204.js +1 -0
  103. package/assets/esri/core/workers/chunks/b73c146d3e550eaf07eb.js +1 -0
  104. package/assets/esri/core/workers/chunks/b7af0e6b9aadbcaf6a0b.js +1 -0
  105. package/assets/esri/core/workers/chunks/b803e7b0d489bb628d72.js +1 -0
  106. package/assets/esri/core/workers/chunks/b858adff7043683fe41c.js +1 -0
  107. package/assets/esri/core/workers/chunks/baeb96aef03d4c566af7.js +1 -0
  108. package/assets/esri/core/workers/chunks/bc75ab48f4c7609ef09d.js +1 -0
  109. package/assets/esri/core/workers/chunks/bc78937986854e500b8e.js +1 -0
  110. package/assets/esri/core/workers/chunks/{6ef3b8d67b498d655a99.js → bcb021a167580bb1619f.js} +1 -1
  111. package/assets/esri/core/workers/chunks/bd10d21545bca9a49de0.js +1 -0
  112. package/assets/esri/core/workers/chunks/bec3ee5ea945e1e07a35.js +1 -0
  113. package/assets/esri/core/workers/chunks/{5c663d5f98bdfa29151b.js → bf8f603848bad4a7deb4.js} +1 -1
  114. package/assets/esri/core/workers/chunks/bfe575da727ce7c8d331.js +2 -0
  115. package/assets/esri/core/workers/chunks/c31ee5617c61a933cb0e.js +1 -0
  116. package/assets/esri/core/workers/chunks/cb45e5d4a4ef82cda583.js +1 -0
  117. package/assets/esri/core/workers/chunks/ce7ef7c4ca14d66d96f6.js +1 -0
  118. package/assets/esri/core/workers/chunks/{f5c57ff48ca505ed701d.js → cf14b3a44705dacefac4.js} +1 -1
  119. package/assets/esri/core/workers/chunks/d1a7d13e1d48abcd7bf1.js +1 -0
  120. package/assets/esri/core/workers/chunks/{06df187a116709f69952.js → d35c475f004367e333eb.js} +1 -1
  121. package/assets/esri/core/workers/chunks/d3b086eb9aa8c7d09048.js +1 -0
  122. package/assets/esri/core/workers/chunks/d55cef8199b8246fea3f.js +1 -0
  123. package/assets/esri/core/workers/chunks/d82da31dc702b8fd6a07.js +1 -0
  124. package/assets/esri/core/workers/chunks/d8decaee2c780e1b5e35.js +1 -0
  125. package/assets/esri/core/workers/chunks/{41809c16544ec25120fa.js → d95ffd990b3a7df69e1e.js} +1 -1
  126. package/assets/esri/core/workers/chunks/dc54d4a9fe1691862356.js +1 -0
  127. package/assets/esri/core/workers/chunks/dd4f431511edd975a53b.js +1 -0
  128. package/assets/esri/core/workers/chunks/dda2cb5c073d1e65f14f.js +1 -0
  129. package/assets/esri/core/workers/chunks/e18badd11f360cc2912b.js +1 -0
  130. package/assets/esri/core/workers/chunks/{e25a684eb9f025bdcc01.js → e262c4864dc06c43b380.js} +1 -1
  131. package/assets/esri/core/workers/chunks/e610d24539a675fb054b.js +1 -0
  132. package/assets/esri/core/workers/chunks/{99101789035f1787c630.js → e785f76c1a75cb1d1e1f.js} +1 -1
  133. package/assets/esri/core/workers/chunks/e9c5c295b6bf10e942a4.js +1 -0
  134. package/assets/esri/core/workers/chunks/ea59b81299acaf0d85ee.js +1 -0
  135. package/assets/esri/core/workers/chunks/{873c1b705ac3d4e6c384.js → ea97619a4470f1540b99.js} +1 -1
  136. package/assets/esri/core/workers/chunks/eaab5ac049622986e3bc.js +1 -0
  137. package/assets/esri/core/workers/chunks/edee616b6f1b5be8fd39.js +1 -0
  138. package/assets/esri/core/workers/chunks/ef0085aa743b33cb549f.js +1 -0
  139. package/assets/esri/core/workers/chunks/f0250cecb243b32cdba7.js +1 -0
  140. package/assets/esri/core/workers/chunks/f518835b2dc89a48cfb1.js +1 -0
  141. package/assets/esri/core/workers/chunks/f590b60fca607d66001a.js +1 -0
  142. package/assets/esri/core/workers/chunks/{f6d047358d14328f3622.js → f60292d97bcdbf19165b.js} +1 -1
  143. package/assets/esri/core/workers/chunks/f6c8e93ca2987e83f925.js +1 -0
  144. package/assets/esri/core/workers/chunks/fb5a2205f05afc396119.js +1 -0
  145. package/assets/esri/themes/base/widgets/_Sketch.scss +32 -0
  146. package/assets/esri/themes/dark/main.css +1 -1
  147. package/assets/esri/themes/light/main.css +1 -1
  148. package/assets/esri/themes/light/view.css +1 -1
  149. package/assets/esri/widgets/Directions/t9n/Directions_ja.json +1 -1
  150. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_no.json +1 -1
  151. package/assets/esri/widgets/Sketch/t9n/Sketch.json +1 -1
  152. package/assets/esri/widgets/Sketch/t9n/Sketch_en.json +1 -1
  153. package/chunks/MultiPathImpl.js +1 -1
  154. package/chunks/Point2D.js +1 -1
  155. package/chunks/SpatialReference.js +1 -1
  156. package/chunks/aiServices.js +1 -1
  157. package/chunks/geometryEngineBase.js +1 -1
  158. package/chunks/languageUtils.js +1 -1
  159. package/config.js +1 -1
  160. package/core/has.js +1 -1
  161. package/core/workers/registry.js +1 -1
  162. package/form/elements/AttachmentElement.d.ts +15 -16
  163. package/form/elements/FieldElement.js +1 -1
  164. package/form/elements/GroupElement.d.ts +3 -2
  165. package/form/elements/inputs/attachments/AttachmentInput.d.ts +7 -9
  166. package/form/elements/inputs/attachments/AudioInput.d.ts +6 -8
  167. package/form/elements/inputs/attachments/DocumentInput.d.ts +5 -7
  168. package/form/elements/inputs/attachments/ImageInput.d.ts +6 -8
  169. package/form/elements/inputs/attachments/Input.d.ts +2 -6
  170. package/form/elements/inputs/attachments/SignatureInput.d.ts +5 -7
  171. package/form/elements/inputs/attachments/VideoInput.d.ts +6 -8
  172. package/form/elements/inputs/attachments/types.d.ts +3 -3
  173. package/geometry/FlatGeometry.js +1 -1
  174. package/geometry/geometryEngine.js +1 -1
  175. package/geometry/geometryEngineJSON.js +1 -1
  176. package/geometry/operators/projectOperator.d.ts +5 -4
  177. package/geometry/operators/projectOperator.js +1 -1
  178. package/geometry/support/curves/densifyCurvedGeometry.js +1 -1
  179. package/geometry/support/normalizeUtils.js +1 -1
  180. package/geometry/support/normalizeUtilsCommon.js +1 -1
  181. package/graphic/ImageryGraphicOrigin.js +1 -1
  182. package/graphic/ImageryTileGraphicOrigin.js +1 -1
  183. package/graphic/WCSGraphicOrigin.js +1 -1
  184. package/identity/IdentityManagerBase.js +1 -1
  185. package/kernel.js +1 -1
  186. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  187. package/layers/IntegratedMeshLayer.js +1 -1
  188. package/layers/mixins/ArcGISImageService.js +1 -1
  189. package/layers/orientedImagery/core/ExposurePoint.js +1 -1
  190. package/layers/support/SymbolLayerDrawing.d.ts +18 -4
  191. package/package.json +4 -4
  192. package/popup/Features.d.ts +9 -9
  193. package/popup/Features.js +1 -1
  194. package/popup/actionUtils.js +1 -1
  195. package/popup/actions.js +1 -1
  196. package/portal/Portal.js +1 -1
  197. package/portal/PortalQueryParams.js +1 -1
  198. package/rest/print.js +1 -1
  199. package/support/revision.js +1 -1
  200. package/symbols/cim/CIMSymbolHelper.js +1 -1
  201. package/symbols/cim/CIMSymbolRasterizer.js +1 -1
  202. package/symbols/support/previewCIMSymbol.js +1 -1
  203. package/views/2d/analysis/AreaMeasurement/AreaMeasurementController.js +1 -1
  204. package/views/2d/engine/webgl/TextureManager.js +1 -1
  205. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  206. package/views/2d/layers/MediaLayerView2D.js +1 -1
  207. package/views/2d/layers/TileLayerView2D.js +1 -1
  208. package/views/2d/layers/features/schema/processor/symbols/ComplexSymbolSchema.js +1 -1
  209. package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
  210. package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
  211. package/views/3d/analysis/Dimension/DimensionController.js +1 -1
  212. package/views/3d/analysis/DirectLineMeasurement/DirectLineMeasurementController.js +1 -1
  213. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
  214. package/views/3d/camera/intersectionUtils.js +1 -1
  215. package/views/3d/input/SceneInputManager.js +1 -1
  216. package/views/3d/input/handlers/PinchAndPanNavigation.js +1 -1
  217. package/views/3d/interactive/editingTools/move/MoveTool3D.js +1 -1
  218. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  219. package/views/3d/interactive/editingTools/transform/extentTransform/ExtentMove.js +1 -1
  220. package/views/3d/interactive/editingTools/transform/extentTransform/ExtentScale.js +1 -1
  221. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  222. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  223. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  224. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  225. package/views/3d/state/GoToOperation.js +1 -1
  226. package/views/3d/state/controllers/PinchAndPanControllerGlobal.js +1 -1
  227. package/views/3d/state/controllers/PinchAndPanControllerLocal.js +1 -1
  228. package/views/3d/support/cameraScaleUtils.js +2 -0
  229. package/views/3d/support/cameraUtils.js +1 -1
  230. package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
  231. package/views/3d/support/renderInfoUtils/line.js +1 -1
  232. package/views/3d/support/viewpointUtils.js +1 -1
  233. package/views/3d/webgl-engine/collections/Component/ComponentObject.js +1 -1
  234. package/views/3d/webgl-engine/collections/Component/Material/ComponentData.glsl.js +13 -12
  235. package/views/3d/webgl-engine/effects/globalIllumination/GlobalIllumination.js +1 -1
  236. package/views/3d/webgl.js +1 -1
  237. package/views/SceneView.d.ts +1 -0
  238. package/views/VideoView.js +1 -1
  239. package/views/draw/DrawGraphicTool.js +1 -1
  240. package/views/draw/DrawTool.js +1 -1
  241. package/views/draw/support/Box.js +1 -1
  242. package/views/draw/support/Reshape.js +1 -1
  243. package/views/draw/support/editingSessionUtils.js +2 -0
  244. package/views/draw/support/managers/MeasurementManager.js +1 -1
  245. package/views/interactive/SegmentLabels.js +1 -1
  246. package/views/interactive/sketch/SketchTooltipOptions.d.ts +9 -1
  247. package/views/interactive/snapping/SelfSnappingEngine.js +1 -1
  248. package/views/support/GeometryWorker.js +2 -0
  249. package/views/support/GeometryWorkerHandle.js +2 -0
  250. package/views/support/Scheduler.js +1 -1
  251. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
  252. package/widgets/BatchAttributeForm/inputs/support/createBatchFormInputs.js +1 -1
  253. package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
  254. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  255. package/widgets/Editor/EditorViewModel.js +1 -1
  256. package/widgets/Editor/MergeFeaturesWorkflow.js +1 -1
  257. package/widgets/Editor/SplitFeatureWorkflow.js +1 -1
  258. package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
  259. package/widgets/Editor/UpdateFeaturesWorkflowData.js +1 -1
  260. package/widgets/Editor/support/SketchController.js +1 -1
  261. package/widgets/Editor/workflowUtils.js +1 -1
  262. package/widgets/FeatureTable/FeatureTableViewModel.d.ts +1 -3
  263. package/widgets/FeatureTable/Grid/GridViewModel.d.ts +2 -11
  264. package/widgets/FeatureTable/support/types.d.ts +2 -1
  265. package/widgets/OrientedImageryViewer/OrientedImageryViewerVisibleElements.d.ts +28 -0
  266. package/widgets/OrientedImageryViewer/OrientedImageryViewerVisibleElements.js +1 -1
  267. package/widgets/OrientedImageryViewer.d.ts +27 -0
  268. package/widgets/Sketch/SketchViewModel.d.ts +10 -2
  269. package/widgets/Sketch/SketchViewModel.js +1 -1
  270. package/widgets/Sketch/support/ResponsiveToolbar/MeasuredContentGroup.js +1 -1
  271. package/widgets/Sketch/support/ResponsiveToolbar/ResponsiveToolbar.js +1 -1
  272. package/widgets/Sketch.js +1 -1
  273. package/assets/esri/core/workers/chunks/00bae4b7e179336e0362.js +0 -1
  274. package/assets/esri/core/workers/chunks/027c3ea756db68e51f0a.js +0 -1
  275. package/assets/esri/core/workers/chunks/041c372e98a6fba90b36.js +0 -1
  276. package/assets/esri/core/workers/chunks/0783890816bac45277b9.js +0 -1
  277. package/assets/esri/core/workers/chunks/07aac6245a0d1adbb2d4.js +0 -1
  278. package/assets/esri/core/workers/chunks/0c00e5e4bd18467bcecd.js +0 -1
  279. package/assets/esri/core/workers/chunks/0dad0bca8d58b2c63d22.js +0 -1
  280. package/assets/esri/core/workers/chunks/0ef93722524620023f69.js +0 -1
  281. package/assets/esri/core/workers/chunks/1286f41f245ef22b3a26.js +0 -1
  282. package/assets/esri/core/workers/chunks/12e575a6d2b008b8fc2b.js +0 -1
  283. package/assets/esri/core/workers/chunks/161d60fdac2013c15543.js +0 -1
  284. package/assets/esri/core/workers/chunks/168de44a789d1cecc1f8.js +0 -1
  285. package/assets/esri/core/workers/chunks/1d9d7915cf7449e5d468.js +0 -1
  286. package/assets/esri/core/workers/chunks/235cb82952a18ff8d206.js +0 -1
  287. package/assets/esri/core/workers/chunks/266ba61b72a278d93a26.js +0 -1
  288. package/assets/esri/core/workers/chunks/27b80c386cebadcaca3c.js +0 -1
  289. package/assets/esri/core/workers/chunks/29d3890a5a43d934067a.js +0 -1
  290. package/assets/esri/core/workers/chunks/29e76256e3e867e80520.js +0 -1
  291. package/assets/esri/core/workers/chunks/2abf124e2956e4f76688.js +0 -1
  292. package/assets/esri/core/workers/chunks/2f17438d215bea3ce70f.js +0 -1
  293. package/assets/esri/core/workers/chunks/30f04dc001eaf838d64c.js +0 -1
  294. package/assets/esri/core/workers/chunks/356cb86606b8c674f947.js +0 -1
  295. package/assets/esri/core/workers/chunks/398e0dd2bc7e1ab84831.js +0 -1
  296. package/assets/esri/core/workers/chunks/3b1052aa30af3f6186cc.js +0 -1
  297. package/assets/esri/core/workers/chunks/3e87e3ad857d72f6ecbb.js +0 -1
  298. package/assets/esri/core/workers/chunks/42e483fde18f12da32a6.js +0 -1
  299. package/assets/esri/core/workers/chunks/43678e08a3d9d51c2a6d.js +0 -1
  300. package/assets/esri/core/workers/chunks/43ab44d37bc0ea97ef98.js +0 -1
  301. package/assets/esri/core/workers/chunks/47f2113357b2aa4f4f37.js +0 -1
  302. package/assets/esri/core/workers/chunks/488ed9584b527ec47be3.js +0 -1
  303. package/assets/esri/core/workers/chunks/4ad32580e0c0699fde1f.js +0 -1
  304. package/assets/esri/core/workers/chunks/54ed37ec9682ea739deb.js +0 -1
  305. package/assets/esri/core/workers/chunks/55369c5bd65bcaf78da1.js +0 -1
  306. package/assets/esri/core/workers/chunks/56fd3da911c2c4511e5d.js +0 -1
  307. package/assets/esri/core/workers/chunks/59592bb25f226865e88a.js +0 -1
  308. package/assets/esri/core/workers/chunks/5a83ea967ecde01d5622.js +0 -1
  309. package/assets/esri/core/workers/chunks/5b278b9980752ef495a2.js +0 -1
  310. package/assets/esri/core/workers/chunks/5d55b4449bcb24cd72b6.js +0 -1
  311. package/assets/esri/core/workers/chunks/5d8fe41a3c06ddb4094b.js +0 -1
  312. package/assets/esri/core/workers/chunks/5e59ff96aecdf2adcb3b.js +0 -1
  313. package/assets/esri/core/workers/chunks/608d707fd9d9f9088473.js +0 -1
  314. package/assets/esri/core/workers/chunks/6a21c9a4aeebe806ea39.js +0 -1
  315. package/assets/esri/core/workers/chunks/6c7ff968bd4fc816442d.js +0 -1
  316. package/assets/esri/core/workers/chunks/6d11ec355e5474b2968b.js +0 -1
  317. package/assets/esri/core/workers/chunks/6ea8b0d68881d16a2432.js +0 -1
  318. package/assets/esri/core/workers/chunks/7027d93dc5a4595d70c6.js +0 -1
  319. package/assets/esri/core/workers/chunks/70b35b2446558d5280e3.js +0 -1
  320. package/assets/esri/core/workers/chunks/7349cb45a93e6916f115.js +0 -1
  321. package/assets/esri/core/workers/chunks/74be994d789c57031631.js +0 -1
  322. package/assets/esri/core/workers/chunks/76edaeaf8fe344bb77a8.js +0 -1
  323. package/assets/esri/core/workers/chunks/76fe5b821d6b54db5721.js +0 -1
  324. package/assets/esri/core/workers/chunks/770880ad43f252962017.js +0 -1
  325. package/assets/esri/core/workers/chunks/7951d93f5f15aa76f49c.js +0 -1
  326. package/assets/esri/core/workers/chunks/7a56c836c89a8b978800.js +0 -1
  327. package/assets/esri/core/workers/chunks/81750c5177d8d52a3e05.js +0 -1
  328. package/assets/esri/core/workers/chunks/81d30c9062ad0120a863.js +0 -1
  329. package/assets/esri/core/workers/chunks/84772b023d04e415f17f.js +0 -1
  330. package/assets/esri/core/workers/chunks/88c5f7c712c6b89b5109.js +0 -1
  331. package/assets/esri/core/workers/chunks/88e469b82d2594f23649.js +0 -1
  332. package/assets/esri/core/workers/chunks/8a8242e7cc7e6a9e7876.js +0 -1
  333. package/assets/esri/core/workers/chunks/9444ed8ea117861ae89b.js +0 -1
  334. package/assets/esri/core/workers/chunks/9a38fd68b02b617c45d3.js +0 -1
  335. package/assets/esri/core/workers/chunks/9eb4ae556950e1d0124d.js +0 -2
  336. package/assets/esri/core/workers/chunks/a11f05ddd8314b648f76.js +0 -1
  337. package/assets/esri/core/workers/chunks/a37c28e3c4a2be9fd1d5.js +0 -1
  338. package/assets/esri/core/workers/chunks/a8d7f59927bdad564141.js +0 -1
  339. package/assets/esri/core/workers/chunks/a94bd20551c1179c7ec5.js +0 -1
  340. package/assets/esri/core/workers/chunks/abe22ae8ee0dcc9efbb7.js +0 -1
  341. package/assets/esri/core/workers/chunks/af5db0372d526e592fcc.js +0 -1
  342. package/assets/esri/core/workers/chunks/b702279c48f3009f6dd8.js +0 -1
  343. package/assets/esri/core/workers/chunks/bc53ce9a643f82d516c2.js +0 -1
  344. package/assets/esri/core/workers/chunks/bc887bd62579dba81e2b.js +0 -1
  345. package/assets/esri/core/workers/chunks/be1d6a571f76933dfbb0.js +0 -1
  346. package/assets/esri/core/workers/chunks/bfcdc5c315131aae34d8.js +0 -1
  347. package/assets/esri/core/workers/chunks/c0f624a2ca0d07ef8f8c.js +0 -1
  348. package/assets/esri/core/workers/chunks/c327fe276238af60fda4.js +0 -1
  349. package/assets/esri/core/workers/chunks/c3381b9a36299210ee47.js +0 -1
  350. package/assets/esri/core/workers/chunks/cb5e4b9b4a59c2622eb5.js +0 -1
  351. package/assets/esri/core/workers/chunks/d201a5dff18a5bb467ab.js +0 -1
  352. package/assets/esri/core/workers/chunks/d21fdd67477800101f3b.js +0 -1
  353. package/assets/esri/core/workers/chunks/d65b1234867f7d773d50.js +0 -2
  354. package/assets/esri/core/workers/chunks/d8d7331600d93bbca2b4.js +0 -1
  355. package/assets/esri/core/workers/chunks/db588bf3256e95c977b7.js +0 -1
  356. package/assets/esri/core/workers/chunks/dfdd474fddcd1d6091ce.js +0 -1
  357. package/assets/esri/core/workers/chunks/e1bc9ad767e08dc18bbc.js +0 -1
  358. package/assets/esri/core/workers/chunks/e235ea4293d5d463acfb.js +0 -1
  359. package/assets/esri/core/workers/chunks/e272411e2c9378aa8496.js +0 -1312
  360. package/assets/esri/core/workers/chunks/e43486113aaf72ac4dc1.js +0 -1
  361. package/assets/esri/core/workers/chunks/ea4c3393c5757e309a71.js +0 -1
  362. package/assets/esri/core/workers/chunks/ed216ddeb7f59f510bd0.js +0 -1
  363. package/assets/esri/core/workers/chunks/ef8886dff54063928bcb.js +0 -1
  364. package/assets/esri/core/workers/chunks/f43a63094190d2074cd0.js +0 -1
  365. package/assets/esri/core/workers/chunks/f5223ffb3be548c9b0a1.js +0 -1
  366. package/assets/esri/core/workers/chunks/fa160a2a5dc9f5a7c34b.js +0 -1
  367. package/geometry/support/triangulationUtilsDeprecated.js +0 -2
  368. package/views/3d/layers/graphics/extrudeUtilsDeprecated.js +0 -2
  369. package/views/3d/support/renderInfoUtils/polygonDeprecated.js +0 -2
  370. package/views/support/MeasurementWorker.js +0 -2
  371. package/views/support/MeasurementWorkerHandle.js +0 -2
  372. /package/assets/esri/core/workers/chunks/{9eb4ae556950e1d0124d.js.LICENSE.txt → 07aca5ecad659d55e795.js.LICENSE.txt} +0 -0
  373. /package/assets/esri/core/workers/chunks/{d65b1234867f7d773d50.js.LICENSE.txt → bfe575da727ce7c8d331.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i,handlesGroup as r,abortHandle as s}from"../../core/handleUtils.js";import"../../core/has.js";import o from"../../core/Logger.js";import{removeMaybe as n,destroyMaybe as l}from"../../core/maybe.js";import{isPromiseLike as d,debounce as c}from"../../core/promiseUtils.js";import{watch as u,when as p,initial as h,sync as m,whenOnce as f,syncAndInitial as g}from"../../core/reactiveUtils.js";import{generateBracedUUID as w}from"../../core/uuid.js";import{property as y,subclass as v}from"../../core/accessorSupport/decorators.js";import{isSharedTemplateOrMetadata as _,isSharedTemplate as F,getCreationAttributes as b,isStandardFeatureTemplate as M}from"../../editing/templateUtils.js";import{getFullTemplate as I}from"../../editing/sharedTemplates/templateLoader.js";import V from"../../layers/GraphicsLayer.js";import{isSceneLayer as k,isTable as S}from"../../layers/support/layerUtils.js";import{isNumber as C}from"../../support/guards.js";import{getDisplayedSymbol as T}from"../../symbols/support/symbolUtils.js";import{getDrawHelpMessage as A}from"../../views/draw/support/helpMessageUtils.js";import P from"../../views/draw/support/HighlightHelper.js";import E from"../../views/interactive/sketch/SketchOptions.js";import U from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as H}from"../../views/support/HighlightDefaults.js";import L from"./CreateFeaturesWorkflowData.js";import{isModelUpload as O,handleModelUpload as j}from"./modelUploadUtils.js";import x from"./Workflow.js";import{activeSketchToolDrawsUnsupportedCurve as D,createToolFromGeometryType as z,containsUnsupportedCurve as R,findEditorItemForLayer as W,getServiceEditsFromWorkflowData as G,getServiceInfoForLayer as N,orderEditsByRelationshipDependencies as K,getServiceLayersById as Z,startCreatingNewFeature as q,syncUpdateOptions as B,findLayerInfo as J,updateGraphicSymbolWhenRequired as Q,isTerminalUpdateEventType as X,getVisualVariableAttributes as Y,startUpdatingFeatureGeometry as $,createWorkflowSteps as ee,avoidFeatureTemplateSelectionWithOnlyOneItem as te,setUpSketchCreateWatchers as ae,setRelationshipFields as ie,prepareAttachmentsForCreateFeaturesWorkflow as re,showProgressCursor as se,setVisualVariablesAndElevationInfoForUpdate as oe,visualVariableInteractiveUpdate as ne}from"./workflowUtils.js";import le from"../FeatureForm/FeatureFormViewModel.js";import de from"../Sketch/SketchViewModel.js";var ce;const ue=Symbol(),pe=Symbol(),he=Symbol(),me=Symbol(),fe={point:["point"],multipoint:["multipoint"],polygon:["polygon","freehandPolygon","rectangle","circle"],polyline:["polyline","freehandPolyline"],mesh:[],multipatch:[]};let ge=ce=class extends x{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.data=void 0,this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._webStyleCache=new Map,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._formViewModel=new le,this._sketchLayer=null,this._sketchViewModel=null,this._attachmentFileInfos=new Map,this._isActive=!0}initialize(){this.isNested&&(this._isActive=!1),this._initializeSketchViewModel()}destroy(){this._sketchViewModel.destroy()}get allowSave(){return!this.updating}get curveResizeDisabled(){return this.data.curveResizeDisabled}get curveUpdatesDisabled(){return this.data.curveUpdatesDisabled}get formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return!!this.data.editorItem?.hasInvalidFormTemplate}get hasPendingEdits(){if(this.pendingFeatures.some(e=>!!this.data.getEditsForPendingFeature(e)?.modified))return!0;const{creationInfo:e,upload:t}=this.data,{activeComponent:a,createGraphic:i}=this._sketchViewModel,r=i?.geometry?.type;return!("polyline"!==r&&"polygon"!==r&&"multipoint"!==r||"draw-2d"!==a?.type&&"draw-3d"!==a?.type)&&a.drawOperation.committedVertices.length>0||(!(!t||"pending"!==t.state&&"success"!==t.state)||!!e?.geometryToPlace)}get hasPreviousStep(){return this._stepIndex>0||"update-pending"===this.createFeatureState&&!!this.data.selectedPendingFeature&&!this.parent&&!O(this.data.creationInfo)}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const{_sketchViewModel:a}=this,{drawTool:i,isUsingLegacyCreateTools:r}=a;if(!r)return i?.helpMessageKey??"noTool";const s=e.layer.geometryType,o=a.createGraphic;if("mesh"===s){this._getDrawMeshHelpMessage||import("../../views/draw/support/helpMessageUtils3d.js").then(e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage});const{view:e}=t;return"3d"===e?.type?this._getDrawMeshHelpMessage?.(o,e):void 0}const{activeCreateToolDrawMode:n,activeTool:l}=a;return A("rectangle"===l||"circle"===l?l:s,o?.geometry,n)}get noticeMessage(){if(D(this._sketchViewModel,this.data.editorItem))return"curveToolDensifyWarning"}get layer(){return this.data.creationInfo?.layer}get numPendingFeatures(){return this.pendingFeatures.length}get numPendingFeaturesExcludingHidden(){return this.pendingFeatures.filter(e=>this.data.isDisplayable(e)).length}get parent(){return this.data.parent}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){return this.data.editorItem?.capabilities.create.reliesOnOwnerAdminPrivileges??!1}get saveActionLabel(){return"create"}get shouldShowAttachments(){return(this.data.selectedPendingFeature&&this.data.editorItem?.capabilities.create.attachments.enabled)??!1}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get sketchUpdateOptions(){const{editorItem:e}=this.data;return{enableScaling:!this.curveResizeDisabled,multipleSelectionEnabled:!1,reshapeOptions:{enableCreateCurveFromStraightEdge:!k(e?.layer)&&!!e?.capabilities.supportsTrueCurve}}}get sketchViewModel(){return this._sketchViewModel}get test(){}get availableCreateTools(){const e=this.data.creationInfo?.layer.geometryType,t=this.data.viewModel.view;if(!e)return[];if(this.data.creationInfo?.maxFeatures&&this.data.creationInfo.maxFeatures<=this.numPendingFeatures)return[];if(_(this.data.fullTemplate)){const{tool:t}=z(e,this.data.fullTemplate);return[t]}return"2d"!==t?.type&&"multipoint"===e?[]:[...fe[e]]}get _attachmentsActive(){const e=this.data.viewModel.attachmentsViewModel.mode,t=this.stepId;return this.shouldShowAttachments&&("add"===e||"edit"===e||"adding-attachment"===t||"editing-attachment"===t)}getUpdating(){return!!this._sketchViewModel?.updating}async enter(){this._isActive=!0,"awaiting-feature-creation-info"!==this.stepId&&await this._updatingHandles.addPromise(this._setUpCreatingFeaturesStep())}exit(){this._isActive=!1,this.removeHandles([he])}async updatePendingFeature(e){if(e!==this.data.selectedPendingFeature)return this._sketchViewModel.cancel(),this._startUpdating({feature:e})}async start(){return await super.start(),S(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}async save(e){const{formViewModel:t}=this;if(t.pendingSubtypeChoice)return;t.submit(),this._stashValidationState();const a=this.data.selectedPendingFeature,i=this._hasValidationErrors(a)?a:this.data.pendingFeatures.find(e=>this._hasValidationErrors(e));if(i)return await this._startUpdating({feature:i}),void t?.submit();const{pendingFeatures:r,editorItem:s}=this.data;if(s&&e&&R(r.toArray(),s)){if(!await e("curveEditingDensifyPrompt"))return this.reset()}return super.save()}back(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||O(this.data.creationInfo)||this._attachmentsActive||this.parent?super.back(e):this._clearSelectedFeature()}previous(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||O(this.data.creationInfo)||this._attachmentsActive?super.previous(e):this._clearSelectedFeature()}cancelFeature(e){this.data.isSharedTemplateWorkflow?o.getLogger(this).warn("Cannot cancel individual features created by shared templates."):(this.data.removePendingFeature(e),this.sketchViewModel.removeGraphic(e))}static create(e){const{addAttachmentsCallback:t,applyEdits:a,applyEditsFeatureService:i,isNested:r,creationInfo:s,parent:o,snappingManager:n,startAt:l,viewModel:d}=e,c=e.sketchOptions??new E,u=s?.layer,p=u?W(d.editorItems,u):void 0,h=new ce({data:new L({creationInfo:s,editorItem:p,parent:o,sketchOptions:c,snappingManager:n,viewModel:d}),isNested:r,onCommit:async e=>{const{creationInfo:r}=e;if(!r)return;h._sketchViewModel.cancel();const s=e.pendingFeatures.toArray(),{layer:o}=r,n=o.capabilities?.editing.supportsGlobalId&&"globalIdField"in o,l=h._attachmentFileInfos,{fullTemplate:c}=e,u=G(h.data),p=F(c)&&u;if(n){if(_e(s),p){let t=be(u,l);const a=await(N(o,d.view)?.load());a&&(t=K({edits:t,serviceInfo:a,view:d.view,findOriginalFeature:t=>e.getEditsForPendingFeature(t)?.initialFeature??t})),await i(c.featureService,t,{globalIdUsed:!0,honorSequenceOfEdits:!0,gdbVersion:c.layer.gdbVersion??void 0})}else{const e=Fe(s,l);await a(o,e,{globalIdUsed:!0})}return}const m=p?await i(c.featureService,u,{gdbVersion:c.layer.gdbVersion??void 0}):[await a(o,{addFeatures:s})];m&&l.size>0&&await Promise.all(m.map(e=>{if(e?.addFeatureResults)return t(o,ve(s,e.addFeatureResults,o,l))}))}});return h._set("steps",this._createWorkflowSteps(h,l)),h}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",i(()=>e.effect=t)}const t=e.opacity;return e.opacity=.7,i(()=>e.opacity=t)}async _initializeFullTemplateAndExecutorInfo(e){const{creationInfo:t}=e,{view:a}=e.viewModel;if(!t||!a)return null;const i=await I(a,t.template);if(e.fullTemplate=i,i&&F(i)){const{createTemplateExecutor:r}=await import("../../editing/sharedTemplates/executor/createTemplateExecutor.js"),s={completionResults:[],executor:await r(i),serviceLayersById:Z(t.layer,a)};e.templateExecutorInfo=s}return i}async _startCreating(){this.removeHandles(pe);const{data:e}=this;if(!e.creationInfo)return;const t=this.data.creationInfo?.maxFeatures;if(t&&this.numPendingFeatures>=t)return this.sketchViewModel.cancel(),void(this.numPendingFeatures&&await this._startUpdating({feature:this.pendingFeatures.at(-1)}));this.createFeatureState="create-new",await q(this._sketchViewModel,this._sketchLayer,e,this._webStyleCache)}async _clearSelectedFeature(){const e=this._formViewModel.pendingSubtypeChoice;e&&(e.resolve("undo"),await e.promise),this._stashValidationState(),this.sketchViewModel.cancel(),this.data.selectedPendingFeature=null,this._featureFormHandle=n(this._featureFormHandle),this._formViewModel.feature=null;const t=this.data.viewModel.attachmentsViewModel;"add"!==t.mode&&"edit"!==t.mode||await(this.data.viewModel.activeWorkflow?.previous())}_stashValidationState(){const e=this._formViewModel.feature,t=e&&this.data.getEditsForPendingFeature(e);t&&(t.submittable=this._formViewModel.submittable)}async _selectFeatureForUpdate({feature:e,initialFeature:t=e}){this._stashValidationState();const{data:a,pendingFeatures:i,_webStyleCache:s}=this;i.includes(e)||a.addPendingFeature(e,t),a.selectedPendingFeature=e;const{_formViewModel:o,_sketchViewModel:l,sketchUpdateOptions:d}=this,{creationInfo:c,viewModel:p}=a,{attachmentsViewModel:h,layerInfos:m,view:f}=p;if(!f||!c)return;B(l,d),n(this._featureFormHandle);const g=e.sourceLayer,w=J(m,g),y=w?.formTemplate,v=f.spatialReference;o.set({editType:"INSERT",feature:e,formTemplate:y,spatialReference:v,map:f.map}),"add"!==h.mode&&"edit"!==h.mode||await(p.activeWorkflow?.previous()),h.graphic=e,h.fileInfos.removeAll(),h.mode="view";(this._attachmentFileInfos.get(e)||[]).forEach(({file:e,form:t})=>h.addFile(e,t)),await Q(e,s,"2d"===f.type?f.scale:null);const _=a.getEditsForPendingFeature(e);this._featureFormHandle=r([o.on("value-change",async({fieldName:t,value:a})=>{if(_?.updateAttributes(o.getValues()),C(a)){const e=this._visualVariableAttributes;e.size&&!e.size.isUpdatingInteractively&&t===e.size.field&&e.size.setInitialValue(a),e.rotation&&!e.rotation.isUpdatingInteractively&&t===e.rotation.field&&e.rotation.setInitialValue(a)}await Q(e,s,"2d"===f.type?f.scale:null)}),l.on(["update","undo","redo"],e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&X(e.toolEventInfo.type))&&o.notifyFeatureGeometryChanged()}),u(()=>o.feature?.sourceLayer,t=>e.sourceLayer=t),u(()=>[o.feature,o.submittable],()=>this._stashValidationState())]),this.createFeatureState="update-pending"}async _startUpdating({feature:e,initialFeature:t=e}){await this._selectFeatureForUpdate({feature:e,initialFeature:t});const{_sketchLayer:a,_sketchViewModel:i,data:r}=this,{creationInfo:s,viewModel:o}=r,{view:n}=o;if(!n||!s)return;const l=e.sourceLayer??s.layer;return S(l)?void 0:(this._visualVariableAttributes=Y(e),$({graphic:e,sketchLayer:a,sketchViewModel:i,sourceLayer:l,updateOptions:this.sketchUpdateOptions,visualVariables:this._visualVariableAttributes,webStyleCache:this._webStyleCache}))}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=ee(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],t,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){const{creationInfo:t,viewModel:i}=a,{view:r}=i;r&&(O(t)?e.addHandles(await j({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&e.addHandles(i.restrictFeatureTemplatesViewModelToLayer(t.layer),this.id),e.addHandles(i.featureTemplatesViewModel.on("select",({item:t})=>{t&&(a.creationInfo={...a.creationInfo,layer:t.layer,template:t.template},e.next())}),this.id)))},async tearDown(){e.removeHandles(this.id)}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([he,ue,pe,me]),i.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear())}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}})});return te(a,i)}static _configureSketchViewModel(e){const{data:t,_sketchLayer:a,_sketchViewModel:s,_webStyleCache:o}=e,{creationInfo:n,viewModel:l}=t,{view:d}=l,h=[];if(!d)return i();if("2d"===d.type){n&&h.push(e._fadeExistingFeatures(n.layer));const t=c((e,t)=>Promise.all(e.map(e=>Q(e,o,t))));h.push(u(()=>d.scale,e=>t(a.graphics,e)))}const m=b(t.fullTemplate,n?.attributeOverrides,n?.layer),f=u(()=>s.createGraphic&&s.activeComponent,()=>{s.createGraphic&&s.activeComponent&&!e.hasHandles(pe)&&e._updatingHandles.consumePromise(ae({creationAttributes:m,data:t,sketchViewModel:s,view:d,webStyleCache:o}).then(t=>e.addHandles(t,pe)))}),g=async t=>{if("cancel"!==t.state&&"complete"!==t.state||e.removeHandles(pe),"cancel"===t.state&&null!==d.activeTool&&d.activeTool!==e.sketchViewModel.activeComponent&&(await e._waitForActiveToolCleared(),await e._startCreating()),"complete"===t.state&&t.graphic){const a=await e._processEdits(t.graphic,{scale:"2d"===d.type?d.scale:null,useSourceLayer:!0,webStyleCache:e._webStyleCache});a&&(await e._waitForActiveToolCleared(),await e._startUpdating({feature:a}))}},w=async i=>{const{attachmentsViewModel:r}=l,{_formViewModel:o}=e;if(i.graphics.length>1)return void await e._clearSelectedFeature();const c=i.graphics[0];if("complete"===i.state){const{submittable:t}=o;if(e.numPendingFeatures!==n?.maxFeatures&&t||o.submit(),await e._clearSelectedFeature(),"add"!==r.mode&&"edit"!==r.mode||await(l.activeWorkflow?.previous()),!i.aborted&&d.activeTool===e.sketchViewModel.activeComponent&&(await e.sketchViewModel.wait(),"ready"===e.sketchViewModel.state&&"mesh"!==e.data.creationInfo?.layer.geometryType))return e._startCreating()}else{if("start"===i.state)return c.sourceLayer??=t.creationInfo?.layer,await oe({graphic:c,sketchLayer:a,sketchViewModel:s,visualVariables:e._visualVariableAttributes,webStyleCache:e._webStyleCache,sourceLayer:c.sourceLayer}),e._selectFeatureForUpdate({feature:c});if("active"===i.state){await e.updatePendingFeature(c);const t=e._visualVariableAttributes;ne(d,c,i,t)&&await Q(c,e._webStyleCache,"2d"===d.type?d.scale:null);const a=c.attributes,{rotation:r,size:s}=t;if(null!=r){const{field:e}=r;o.setValue(e,a[e])}if(null!=s){const{field:e}=s;o.setValue(e,a[e])}}}},y=async a=>{if(a.graphics.forEach(e=>{t.removePendingFeature(e)}),!O(t.creationInfo))return e._startCreating()},v=async()=>{if(O(t.creationInfo))try{await e.data.viewModel.back()}catch{}return e._startCreating()};h.push(f,s.on("create",t=>e._updatingHandles.addPromise(g(t))),s.on("update",t=>e._updatingHandles.addPromise(w(t))),s.on("delete",t=>e._updatingHandles.addPromise(y(t))),p(()=>!e.numPendingFeatures,()=>e._updatingHandles.addPromise(v())),i(()=>{s.cancel()}),we(s,a,t),...ye(t));const _=r(h);return s.addHandles(_),_}_initializeSketchViewModel(){const{data:e}=this,{view:t}=e.viewModel,a=new V({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:"hide",title:"createFeaturesWorkflow-internal"}),r=new de({layer:a,creationMode:"single",sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,useLegacyCreateTools:e.viewModel.useLegacyCreateTools,updateOnGraphicClick:!1,defaultUpdateOptions:this.sketchUpdateOptions,view:t});this._sketchLayer=a,this._sketchViewModel=r,t?.map.add(a),this.addHandles([i(()=>{t?.destroyed||t?.map.remove(a),l(a)}),u(()=>this.numPendingFeatures>0,e=>this._sketchViewModel.updateOnGraphicClick=e,h),u(()=>this.sketchUpdateOptions,e=>{r.defaultUpdateOptions=e,B(r,e)},m)])}_hasValidationErrors(e){return!!e&&(!this.data.isSubmittable(e)||!!this._formViewModel.validateContingencyConstraints(e.attributes,{includeIncompleteViolations:!0})?.length)}async _processEdits(e,t){const{data:a,_formViewModel:i,_sketchLayer:r}=this,{layerInfos:s,view:o}=a.viewModel;i.editType="INSERT",i.map=o?.map,i.spatialReference=o?.spatialReference;const{templateExecutorInfo:n}=a;if(!n){const t=e.clone();return t.geometry=null,await this._addAndInitializeEdits(e,t),e}r.remove(e);const{executor:l}=n,c=l(e.geometry,"completion"),u=d(c)?await c:c;n.completionResults.push(u),ie(u.relationships),i.editType="INSERT",i.map=o?.map,i.spatialReference=o?.spatialReference,u.primary&&a.creationInfo?.attributeOverrides&&(u.primary.graphic.attributes={...u.primary.graphic.attributes,...a.creationInfo.attributeOverrides});for(const d of u.edits){let e=null;if(d.addFeatures)for(const a of d.addFeatures){const i=a.clone();i.geometry=null,null!=a.geometry&&(a.symbol=await T(a,t),r.add(a)),a.sourceLayer!==e?.layer&&(e=J(s,a.sourceLayer));const o=!!u.associationGraphics?.has(a);await this._addAndInitializeEdits(a,i,e,o)}}i.feature=null,await f(()=>!i.updating);return u.edits.reduce((e,t)=>e+(t.addFeatures?.length??0),0)>1?null:u.primary?.graphic}async _addAndInitializeEdits(e,t,a,i=!1){const{data:r,_formViewModel:s}=this,{layerInfos:o}=r.viewModel,n=r.addPendingFeature(e,t,{isAssociation:i});a??=J(o,e.sourceLayer),s.feature=e,s.formTemplate=a?.formTemplate,await f(()=>!s.updating),n.updateAttributes(s.getValues()),n.submittable=s.submittable}async _setUpCreatingFeaturesStep(){if(this.hasHandles(he))return;const{data:e,sketchViewModel:s}=this,{creationInfo:o,viewModel:l}=e,{attachmentsViewModel:d,view:c}=l;if(!c||!o?.layer)throw new a("missing-parameters","CreateFeaturesWorkflow requires a view and creationInfo.");const{initialFeature:p,layer:m}=o,f=[],g=[];this._featureFormHandle=n(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},e.editorItem=W(l.editorItems,o.layer),o.template&&(null==e.fullTemplate&&await this._initializeFullTemplateAndExecutorInfo(e),g.push(i(()=>{e.templateExecutorInfo&&(e.templateExecutorInfo.completionResults=[])}))),s.allowDeleteKey=!e.isSharedTemplateWorkflow,re(d),f.push(u(()=>d.mode,e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}}));const w=se(c);f.push(w);const y=S(o.layer),{template:v}=o,F=!v||M(v)||_(v)&&"feature"===v.type,I=y&&F;try{if(I){const a=p??new t({attributes:b(e.fullTemplate,o.attributeOverrides,m),sourceLayer:m}),i=await this._processEdits(a);i&&await this._startUpdating({feature:i})}else f.push(ce._configureSketchViewModel(this)),p?(O(o)&&o.geometryToPlace&&(p.attributes=b(e.fullTemplate,o.attributeOverrides,m)),s.addGraphic(p),await this._startUpdating({feature:p})):await this._startCreating()}finally{w.remove()}const V=i(()=>{for(const t of e.pendingFeatures)s.removeGraphic(t),e.removePendingFeature(t)}),k=u(()=>c?.timeZone,e=>{this._formViewModel.timeZone=e,this.data.timeZone=e},h),C=i(()=>{O(o)&&l.cancelWorkflow({warnIfNoWorkflow:!1})});this._featureFormHandle&&f.push(this._featureFormHandle),this.addHandles(f,this._handleKeys.beforeCommit),this.addHandles(g,this._handleKeys.afterCommit),this.addHandles([i(()=>d.fileInfos.removeAll()),r(f),r(g),C,V,k],he)}async _waitForActiveToolCleared(){const e=this.data.viewModel.view;if(null==e?.activeTool)return;const t=new AbortController;this.addHandles(s(t),me),await f(()=>null==e?.activeTool,t.signal),t.abort()}};function we(e,t,a){let s=null;const o=()=>e.snappingOptions.featureSources,n=()=>(s=new U({layer:t}),o().add(s),s),d=()=>{null!=s&&(o().remove(s),s=l(s))};return r([u(()=>{const e=a.creationInfo?.layer,t=o().find(t=>t.layer===e);return{hasFeatureLayerSource:!!t,enabled:t?.enabled??!1}},({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return d();s??=n(),s.enabled=t},g),i(d)])}function ye(e){const t=e.viewModel.view;if(!t)return[];const a=[];if("3d"===t.type){const r=new P({view:t});a.push(u(()=>e.selectedPendingFeature,(e,t)=>{r.remove(e),r.add(t)}),i(()=>r.destroy()))}const r=new P({view:t,highlightName:H});return a.push(u(()=>e.temporaryHighlightFeature,e=>{r.removeAll(),r.add(e)}),i(()=>r.destroy())),a}function ve(e,t,a,i){const r=[];return t.forEach((t,s)=>{if(!t.error){const o=e[s],n=i.get(o)||[];o.attributes[a.objectIdField]=t.objectId,n.forEach(({form:e})=>r.push({feature:o,attachment:e}))}}),r}function _e(e){for(const t of e){const{sourceLayer:e}=t;e&&"globalIdField"in e&&null!=e.globalIdField&&(t.attributes[e.globalIdField]??=w())}}function Fe(e,t){const a=[];if(!t||0===t.size)return{addFeatures:e};for(const[i,r]of t)for(const{file:e}of r)a.push({feature:i,attachment:{globalId:w(),data:e}});return a.length?{addFeatures:e,addAttachments:a}:{addFeatures:e}}function be(e,t){return e.map(e=>{const{addFeatures:a}=e;if(!a||0===a.length)return e;const i=[];for(const r of a){const e=t.get(r);if(e)for(const{file:t}of e)i.push({feature:r,attachment:{globalId:w(),data:t}})}return i.length?{...e,addAttachments:i}:e})}e([y()],ge.prototype,"allowSave",null),e([y()],ge.prototype,"createFeatureState",void 0),e([y()],ge.prototype,"curveResizeDisabled",null),e([y()],ge.prototype,"curveUpdatesDisabled",null),e([y()],ge.prototype,"data",void 0),e([y({constructOnly:!0})],ge.prototype,"isNested",void 0),e([y()],ge.prototype,"formViewModel",null),e([y()],ge.prototype,"hasInvalidFormTemplate",null),e([y()],ge.prototype,"hasPendingEdits",null),e([y()],ge.prototype,"hasPreviousStep",null),e([y()],ge.prototype,"_getDrawMeshHelpMessage",void 0),e([y()],ge.prototype,"helpMessage",null),e([y()],ge.prototype,"noticeMessage",null),e([y()],ge.prototype,"layer",null),e([y()],ge.prototype,"parent",null),e([y()],ge.prototype,"keyboardCancellationEnabled",null),e([y()],ge.prototype,"reliesOnOwnerAdminPrivileges",null),e([y()],ge.prototype,"saveActionLabel",null),e([y()],ge.prototype,"shouldShowAttachments",null),e([y()],ge.prototype,"shouldAllowAttachmentEditing",null),e([y()],ge.prototype,"sketchUpdateOptions",null),e([y()],ge.prototype,"sketchViewModel",null),e([y()],ge.prototype,"availableCreateTools",null),e([y()],ge.prototype,"_attachmentsActive",null),ge=ce=e([v("esri.widgets.Editor.CreateFeaturesWorkflow")],ge);const Me=ge;export{Me as default};
2
+ import{__decorate as e}from"tslib";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i,handlesGroup as r,abortHandle as s}from"../../core/handleUtils.js";import"../../core/has.js";import o from"../../core/Logger.js";import{removeMaybe as n,destroyMaybe as l}from"../../core/maybe.js";import{isPromiseLike as d,debounce as c}from"../../core/promiseUtils.js";import{watch as u,when as p,initial as h,sync as m,whenOnce as f,syncAndInitial as g}from"../../core/reactiveUtils.js";import{generateBracedUUID as w}from"../../core/uuid.js";import{property as y,subclass as v}from"../../core/accessorSupport/decorators.js";import{isSharedTemplateOrMetadata as _,isSharedTemplate as F,getCreationAttributes as b,isStandardFeatureTemplate as M}from"../../editing/templateUtils.js";import{getFullTemplate as I}from"../../editing/sharedTemplates/templateLoader.js";import V from"../../layers/GraphicsLayer.js";import{isSceneLayer as k,isTable as S}from"../../layers/support/layerUtils.js";import{isNumber as C}from"../../support/guards.js";import{getDisplayedSymbol as T}from"../../symbols/support/symbolUtils.js";import{updateGraphicSymbolWhenRequired as A}from"../../views/draw/support/editingSessionUtils.js";import{getDrawHelpMessage as P}from"../../views/draw/support/helpMessageUtils.js";import E from"../../views/draw/support/HighlightHelper.js";import U from"../../views/interactive/sketch/SketchOptions.js";import H from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as L}from"../../views/support/HighlightDefaults.js";import O from"./CreateFeaturesWorkflowData.js";import{isModelUpload as j,handleModelUpload as x}from"./modelUploadUtils.js";import D from"./Workflow.js";import{activeSketchToolDrawsUnsupportedCurve as z,createToolFromGeometryType as R,containsUnsupportedCurve as W,findEditorItemForLayer as G,getServiceEditsFromWorkflowData as N,getServiceInfoForLayer as K,orderEditsByRelationshipDependencies as Z,getServiceLayersById as q,startCreatingNewFeature as B,syncUpdateOptions as J,findLayerInfo as Q,isTerminalUpdateEventType as X,getVisualVariableAttributes as Y,startUpdatingFeatureGeometry as $,createWorkflowSteps as ee,avoidFeatureTemplateSelectionWithOnlyOneItem as te,setUpSketchCreateWatchers as ae,setRelationshipFields as ie,prepareAttachmentsForCreateFeaturesWorkflow as re,showProgressCursor as se,setVisualVariablesAndElevationInfoForUpdate as oe,visualVariableInteractiveUpdate as ne}from"./workflowUtils.js";import le from"../FeatureForm/FeatureFormViewModel.js";import de from"../Sketch/SketchViewModel.js";var ce;const ue=Symbol(),pe=Symbol(),he=Symbol(),me=Symbol(),fe={point:["point"],multipoint:["multipoint"],polygon:["polygon","freehandPolygon","rectangle","circle"],polyline:["polyline","freehandPolyline"],mesh:[],multipatch:[]};let ge=ce=class extends D{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.data=void 0,this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._webStyleCache=new Map,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._formViewModel=new le,this._sketchLayer=null,this._sketchViewModel=null,this._attachmentFileInfos=new Map,this._isActive=!0}initialize(){this.isNested&&(this._isActive=!1),this._initializeSketchViewModel()}destroy(){this._sketchViewModel.destroy()}get allowSave(){return!this.updating}get curveResizeDisabled(){return this.data.curveResizeDisabled}get curveUpdatesDisabled(){return this.data.curveUpdatesDisabled}get formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return!!this.data.editorItem?.hasInvalidFormTemplate}get hasPendingEdits(){if(this.pendingFeatures.some(e=>!!this.data.getEditsForPendingFeature(e)?.modified))return!0;const{creationInfo:e,upload:t}=this.data,{activeComponent:a,createGraphic:i}=this._sketchViewModel,r=i?.geometry?.type;return!("polyline"!==r&&"polygon"!==r&&"multipoint"!==r||"draw-2d"!==a?.type&&"draw-3d"!==a?.type)&&a.drawOperation.committedVertices.length>0||(!(!t||"pending"!==t.state&&"success"!==t.state)||!!e?.geometryToPlace)}get hasPreviousStep(){return this._stepIndex>0||"update-pending"===this.createFeatureState&&!!this.data.selectedPendingFeature&&!this.parent&&!j(this.data.creationInfo)}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const{_sketchViewModel:a}=this,{drawTool:i,isUsingLegacyCreateTools:r}=a;if(!r)return i?.helpMessageKey??"noTool";const s=e.layer.geometryType,o=a.createGraphic;if("mesh"===s){this._getDrawMeshHelpMessage||import("../../views/draw/support/helpMessageUtils3d.js").then(e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage});const{view:e}=t;return"3d"===e?.type?this._getDrawMeshHelpMessage?.(o,e):void 0}const{activeCreateToolDrawMode:n,activeTool:l}=a;return P("rectangle"===l||"circle"===l?l:s,o?.geometry,n)}get noticeMessage(){if(z(this._sketchViewModel,this.data.editorItem))return"curveToolDensifyWarning"}get layer(){return this.data.creationInfo?.layer}get numPendingFeatures(){return this.pendingFeatures.length}get numPendingFeaturesExcludingHidden(){return this.pendingFeatures.filter(e=>this.data.isDisplayable(e)).length}get parent(){return this.data.parent}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){return this.data.editorItem?.capabilities.create.reliesOnOwnerAdminPrivileges??!1}get saveActionLabel(){return"create"}get shouldShowAttachments(){return(this.data.selectedPendingFeature&&this.data.editorItem?.capabilities.create.attachments.enabled)??!1}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get sketchUpdateOptions(){const{editorItem:e}=this.data;return{enableScaling:!this.curveResizeDisabled,multipleSelectionEnabled:!1,reshapeOptions:{enableCreateCurveFromStraightEdge:!k(e?.layer)&&!!e?.capabilities.supportsTrueCurve}}}get sketchViewModel(){return this._sketchViewModel}get test(){}get availableCreateTools(){const e=this.data.creationInfo?.layer.geometryType,t=this.data.viewModel.view;if(!e)return[];if(this.data.creationInfo?.maxFeatures&&this.data.creationInfo.maxFeatures<=this.numPendingFeatures)return[];if(_(this.data.fullTemplate)){const{tool:t}=R(e,this.data.fullTemplate);return[t]}return"2d"!==t?.type&&"multipoint"===e?[]:[...fe[e]]}get _attachmentsActive(){const e=this.data.viewModel.attachmentsViewModel.mode,t=this.stepId;return this.shouldShowAttachments&&("add"===e||"edit"===e||"adding-attachment"===t||"editing-attachment"===t)}getUpdating(){return!!this._sketchViewModel?.updating}async enter(){this._isActive=!0,"awaiting-feature-creation-info"!==this.stepId&&await this._updatingHandles.addPromise(this._setUpCreatingFeaturesStep())}exit(){this._isActive=!1,this.removeHandles([he])}async updatePendingFeature(e){if(e!==this.data.selectedPendingFeature)return this._sketchViewModel.cancel(),this._startUpdating({feature:e})}async start(){return await super.start(),S(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}async save(e){const{formViewModel:t}=this;if(t.pendingSubtypeChoice)return;t.submit(),this._stashValidationState();const a=this.data.selectedPendingFeature,i=this._hasValidationErrors(a)?a:this.data.pendingFeatures.find(e=>this._hasValidationErrors(e));if(i)return await this._startUpdating({feature:i}),void t?.submit();const{pendingFeatures:r,editorItem:s}=this.data;if(s&&e&&W(r.toArray(),s)){if(!await e("curveEditingDensifyPrompt"))return this.reset()}return super.save()}back(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||j(this.data.creationInfo)||this._attachmentsActive||this.parent?super.back(e):this._clearSelectedFeature()}previous(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||j(this.data.creationInfo)||this._attachmentsActive?super.previous(e):this._clearSelectedFeature()}cancelFeature(e){this.data.isSharedTemplateWorkflow?o.getLogger(this).warn("Cannot cancel individual features created by shared templates."):(this.data.removePendingFeature(e),this.sketchViewModel.removeGraphic(e))}static create(e){const{addAttachmentsCallback:t,applyEdits:a,applyEditsFeatureService:i,isNested:r,creationInfo:s,parent:o,snappingManager:n,startAt:l,viewModel:d}=e,c=e.sketchOptions??new U,u=s?.layer,p=u?G(d.editorItems,u):void 0,h=new ce({data:new O({creationInfo:s,editorItem:p,parent:o,sketchOptions:c,snappingManager:n,viewModel:d}),isNested:r,onCommit:async e=>{const{creationInfo:r}=e;if(!r)return;h._sketchViewModel.cancel();const s=e.pendingFeatures.toArray(),{layer:o}=r,n=o.capabilities?.editing.supportsGlobalId&&"globalIdField"in o,l=h._attachmentFileInfos,{fullTemplate:c}=e,u=N(h.data),p=F(c)&&u;if(n){if(_e(s),p){let t=be(u,l);const a=await(K(o,d.view)?.load());a&&(t=Z({edits:t,serviceInfo:a,view:d.view,findOriginalFeature:t=>e.getEditsForPendingFeature(t)?.initialFeature??t})),await i(c.featureService,t,{globalIdUsed:!0,honorSequenceOfEdits:!0,gdbVersion:c.layer.gdbVersion??void 0})}else{const e=Fe(s,l);await a(o,e,{globalIdUsed:!0})}return}const m=p?await i(c.featureService,u,{gdbVersion:c.layer.gdbVersion??void 0}):[await a(o,{addFeatures:s})];m&&l.size>0&&await Promise.all(m.map(e=>{if(e?.addFeatureResults)return t(o,ve(s,e.addFeatureResults,o,l))}))}});return h._set("steps",this._createWorkflowSteps(h,l)),h}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",i(()=>e.effect=t)}const t=e.opacity;return e.opacity=.7,i(()=>e.opacity=t)}async _initializeFullTemplateAndExecutorInfo(e){const{creationInfo:t}=e,{view:a}=e.viewModel;if(!t||!a)return null;const i=await I(a,t.template);if(e.fullTemplate=i,i&&F(i)){const{createTemplateExecutor:r}=await import("../../editing/sharedTemplates/executor/createTemplateExecutor.js"),s={completionResults:[],executor:await r(i),serviceLayersById:q(t.layer,a)};e.templateExecutorInfo=s}return i}async _startCreating(){this.removeHandles(pe);const{data:e}=this;if(!e.creationInfo)return;const t=this.data.creationInfo?.maxFeatures;if(t&&this.numPendingFeatures>=t)return this.sketchViewModel.cancel(),void(this.numPendingFeatures&&await this._startUpdating({feature:this.pendingFeatures.at(-1)}));this.createFeatureState="create-new",await B(this._sketchViewModel,this._sketchLayer,e,this._webStyleCache)}async _clearSelectedFeature(){const e=this._formViewModel.pendingSubtypeChoice;e&&(e.resolve("undo"),await e.promise),this._stashValidationState(),this.sketchViewModel.cancel(),this.data.selectedPendingFeature=null,this._featureFormHandle=n(this._featureFormHandle),this._formViewModel.feature=null;const t=this.data.viewModel.attachmentsViewModel;"add"!==t.mode&&"edit"!==t.mode||await(this.data.viewModel.activeWorkflow?.previous())}_stashValidationState(){const e=this._formViewModel.feature,t=e&&this.data.getEditsForPendingFeature(e);t&&(t.submittable=this._formViewModel.submittable)}async _selectFeatureForUpdate({feature:e,initialFeature:t=e}){this._stashValidationState();const{data:a,pendingFeatures:i,_webStyleCache:s}=this;i.includes(e)||a.addPendingFeature(e,t),a.selectedPendingFeature=e;const{_formViewModel:o,_sketchViewModel:l,sketchUpdateOptions:d}=this,{creationInfo:c,viewModel:p}=a,{attachmentsViewModel:h,layerInfos:m,view:f}=p;if(!f||!c)return;J(l,d),n(this._featureFormHandle);const g=e.sourceLayer,w=Q(m,g),y=w?.formTemplate,v=f.spatialReference;o.set({editType:"INSERT",feature:e,formTemplate:y,spatialReference:v,map:f.map}),"add"!==h.mode&&"edit"!==h.mode||await(p.activeWorkflow?.previous()),h.graphic=e,h.fileInfos.removeAll(),h.mode="view";(this._attachmentFileInfos.get(e)||[]).forEach(({file:e,form:t})=>h.addFile(e,t)),await A(e,s,"2d"===f.type?f.scale:null);const _=a.getEditsForPendingFeature(e);this._featureFormHandle=r([o.on("value-change",async({fieldName:t,value:a})=>{if(_?.updateAttributes(o.getValues()),C(a)){const e=this._visualVariableAttributes;e.size&&!e.size.isUpdatingInteractively&&t===e.size.field&&e.size.setInitialValue(a),e.rotation&&!e.rotation.isUpdatingInteractively&&t===e.rotation.field&&e.rotation.setInitialValue(a)}await A(e,s,"2d"===f.type?f.scale:null)}),l.on(["update","undo","redo"],e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&X(e.toolEventInfo.type))&&o.notifyFeatureGeometryChanged()}),u(()=>o.feature?.sourceLayer,t=>e.sourceLayer=t),u(()=>[o.feature,o.submittable],()=>this._stashValidationState())]),this.createFeatureState="update-pending"}async _startUpdating({feature:e,initialFeature:t=e}){await this._selectFeatureForUpdate({feature:e,initialFeature:t});const{_sketchLayer:a,_sketchViewModel:i,data:r}=this,{creationInfo:s,viewModel:o}=r,{view:n}=o;if(!n||!s)return;const l=e.sourceLayer??s.layer;return S(l)?void 0:(this._visualVariableAttributes=Y(e),$({graphic:e,sketchLayer:a,sketchViewModel:i,sourceLayer:l,updateOptions:this.sketchUpdateOptions,visualVariables:this._visualVariableAttributes,webStyleCache:this._webStyleCache}))}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=ee(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],t,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){const{creationInfo:t,viewModel:i}=a,{view:r}=i;r&&(j(t)?e.addHandles(await x({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&e.addHandles(i.restrictFeatureTemplatesViewModelToLayer(t.layer),this.id),e.addHandles(i.featureTemplatesViewModel.on("select",({item:t})=>{t&&(a.creationInfo={...a.creationInfo,layer:t.layer,template:t.template},e.next())}),this.id)))},async tearDown(){e.removeHandles(this.id)}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([he,ue,pe,me]),i.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear())}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=a.viewModel,{graphic:i,fileInfos:r}=t;e._attachmentFileInfos.set(i,r.toArray()),t.mode="view"}})});return te(a,i)}static _configureSketchViewModel(e){const{data:t,_sketchLayer:a,_sketchViewModel:s,_webStyleCache:o}=e,{creationInfo:n,viewModel:l}=t,{view:d}=l,h=[];if(!d)return i();if("2d"===d.type){n&&h.push(e._fadeExistingFeatures(n.layer));const t=c((e,t)=>Promise.all(e.map(e=>A(e,o,t))));h.push(u(()=>d.scale,e=>t(a.graphics,e)))}const m=b(t.fullTemplate,n?.attributeOverrides,n?.layer),f=u(()=>s.createGraphic&&s.activeComponent,()=>{s.createGraphic&&s.activeComponent&&!e.hasHandles(pe)&&e._updatingHandles.consumePromise(ae({creationAttributes:m,data:t,sketchViewModel:s,view:d,webStyleCache:o}).then(t=>e.addHandles(t,pe)))}),g=async t=>{if("cancel"!==t.state&&"complete"!==t.state||e.removeHandles(pe),"cancel"===t.state&&null!==d.activeTool&&d.activeTool!==e.sketchViewModel.activeComponent&&(await e._waitForActiveToolCleared(),await e._startCreating()),"complete"===t.state&&t.graphic){const a=await e._processEdits(t.graphic,{scale:"2d"===d.type?d.scale:null,useSourceLayer:!0,webStyleCache:e._webStyleCache});a&&(await e._waitForActiveToolCleared(),await e._startUpdating({feature:a}))}},w=async i=>{const{attachmentsViewModel:r}=l,{_formViewModel:o}=e;if(i.graphics.length>1)return void await e._clearSelectedFeature();const c=i.graphics[0];if("complete"===i.state){const{submittable:t}=o;if(e.numPendingFeatures!==n?.maxFeatures&&t||o.submit(),await e._clearSelectedFeature(),"add"!==r.mode&&"edit"!==r.mode||await(l.activeWorkflow?.previous()),!i.aborted&&d.activeTool===e.sketchViewModel.activeComponent&&(await e.sketchViewModel.wait(),"ready"===e.sketchViewModel.state&&"mesh"!==e.data.creationInfo?.layer.geometryType))return e._startCreating()}else{if("start"===i.state)return c.sourceLayer??=t.creationInfo?.layer,await oe({graphic:c,sketchLayer:a,sketchViewModel:s,visualVariables:e._visualVariableAttributes,webStyleCache:e._webStyleCache,sourceLayer:c.sourceLayer}),e._selectFeatureForUpdate({feature:c});if("active"===i.state){await e.updatePendingFeature(c);const t=e._visualVariableAttributes;ne(d,c,i,t)&&await A(c,e._webStyleCache,"2d"===d.type?d.scale:null);const a=c.attributes,{rotation:r,size:s}=t;if(null!=r){const{field:e}=r;o.setValue(e,a[e])}if(null!=s){const{field:e}=s;o.setValue(e,a[e])}}}},y=async a=>{if(a.graphics.forEach(e=>{t.removePendingFeature(e)}),!j(t.creationInfo))return e._startCreating()},v=async()=>{if(j(t.creationInfo))try{await e.data.viewModel.back()}catch{}return e._startCreating()};h.push(f,s.on("create",t=>e._updatingHandles.addPromise(g(t))),s.on("update",t=>e._updatingHandles.addPromise(w(t))),s.on("delete",t=>e._updatingHandles.addPromise(y(t))),p(()=>!e.numPendingFeatures,()=>e._updatingHandles.addPromise(v())),i(()=>{s.cancel()}),we(s,a,t),...ye(t));const _=r(h);return s.addHandles(_),_}_initializeSketchViewModel(){const{data:e}=this,{view:t}=e.viewModel,a=new V({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:"hide",title:"createFeaturesWorkflow-internal"}),r=new de({layer:a,creationMode:"single",sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,useLegacyCreateTools:e.viewModel.useLegacyCreateTools,updateOnGraphicClick:!1,defaultUpdateOptions:this.sketchUpdateOptions,view:t});this._sketchLayer=a,this._sketchViewModel=r,t?.map.add(a),this.addHandles([i(()=>{t?.destroyed||t?.map.remove(a),l(a)}),u(()=>this.numPendingFeatures>0,e=>this._sketchViewModel.updateOnGraphicClick=e,h),u(()=>this.sketchUpdateOptions,e=>{r.defaultUpdateOptions=e,J(r,e)},m)])}_hasValidationErrors(e){return!!e&&(!this.data.isSubmittable(e)||!!this._formViewModel.validateContingencyConstraints(e.attributes,{includeIncompleteViolations:!0})?.length)}async _processEdits(e,t){const{data:a,_formViewModel:i,_sketchLayer:r}=this,{layerInfos:s,view:o}=a.viewModel;i.editType="INSERT",i.map=o?.map,i.spatialReference=o?.spatialReference;const{templateExecutorInfo:n}=a;if(!n){const t=e.clone();return t.geometry=null,await this._addAndInitializeEdits(e,t),e}r.remove(e);const{executor:l}=n,c=l(e.geometry,"completion"),u=d(c)?await c:c;n.completionResults.push(u),ie(u.relationships),i.editType="INSERT",i.map=o?.map,i.spatialReference=o?.spatialReference,u.primary&&a.creationInfo?.attributeOverrides&&(u.primary.graphic.attributes={...u.primary.graphic.attributes,...a.creationInfo.attributeOverrides});for(const d of u.edits){let e=null;if(d.addFeatures)for(const a of d.addFeatures){const i=a.clone();i.geometry=null,null!=a.geometry&&(a.symbol=await T(a,t),r.add(a)),a.sourceLayer!==e?.layer&&(e=Q(s,a.sourceLayer));const o=!!u.associationGraphics?.has(a);await this._addAndInitializeEdits(a,i,e,o)}}i.feature=null,await f(()=>!i.updating);return u.edits.reduce((e,t)=>e+(t.addFeatures?.length??0),0)>1?null:u.primary?.graphic}async _addAndInitializeEdits(e,t,a,i=!1){const{data:r,_formViewModel:s}=this,{layerInfos:o}=r.viewModel,n=r.addPendingFeature(e,t,{isAssociation:i});a??=Q(o,e.sourceLayer),s.feature=e,s.formTemplate=a?.formTemplate,await f(()=>!s.updating),n.updateAttributes(s.getValues()),n.submittable=s.submittable}async _setUpCreatingFeaturesStep(){if(this.hasHandles(he))return;const{data:e,sketchViewModel:s}=this,{creationInfo:o,viewModel:l}=e,{attachmentsViewModel:d,view:c}=l;if(!c||!o?.layer)throw new a("missing-parameters","CreateFeaturesWorkflow requires a view and creationInfo.");const{initialFeature:p,layer:m}=o,f=[],g=[];this._featureFormHandle=n(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},e.editorItem=G(l.editorItems,o.layer),o.template&&(null==e.fullTemplate&&await this._initializeFullTemplateAndExecutorInfo(e),g.push(i(()=>{e.templateExecutorInfo&&(e.templateExecutorInfo.completionResults=[])}))),s.allowDeleteKey=!e.isSharedTemplateWorkflow,re(d),f.push(u(()=>d.mode,e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}}));const w=se(c);f.push(w);const y=S(o.layer),{template:v}=o,F=!v||M(v)||_(v)&&"feature"===v.type,I=y&&F;try{if(I){const a=p??new t({attributes:b(e.fullTemplate,o.attributeOverrides,m),sourceLayer:m}),i=await this._processEdits(a);i&&await this._startUpdating({feature:i})}else f.push(ce._configureSketchViewModel(this)),p?(j(o)&&o.geometryToPlace&&(p.attributes=b(e.fullTemplate,o.attributeOverrides,m)),s.addGraphic(p),await this._startUpdating({feature:p})):await this._startCreating()}finally{w.remove()}const V=i(()=>{for(const t of e.pendingFeatures)s.removeGraphic(t),e.removePendingFeature(t)}),k=u(()=>c?.timeZone,e=>{this._formViewModel.timeZone=e,this.data.timeZone=e},h),C=i(()=>{j(o)&&l.cancelWorkflow({warnIfNoWorkflow:!1})});this._featureFormHandle&&f.push(this._featureFormHandle),this.addHandles(f,this._handleKeys.beforeCommit),this.addHandles(g,this._handleKeys.afterCommit),this.addHandles([i(()=>d.fileInfos.removeAll()),r(f),r(g),C,V,k],he)}async _waitForActiveToolCleared(){const e=this.data.viewModel.view;if(null==e?.activeTool)return;const t=new AbortController;this.addHandles(s(t),me),await f(()=>null==e?.activeTool,t.signal),t.abort()}};function we(e,t,a){let s=null;const o=()=>e.snappingOptions.featureSources,n=()=>(s=new H({layer:t}),o().add(s),s),d=()=>{null!=s&&(o().remove(s),s=l(s))};return r([u(()=>{const e=a.creationInfo?.layer,t=o().find(t=>t.layer===e);return{hasFeatureLayerSource:!!t,enabled:t?.enabled??!1}},({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return d();s??=n(),s.enabled=t},g),i(d)])}function ye(e){const t=e.viewModel.view;if(!t)return[];const a=[];if("3d"===t.type){const r=new E({view:t});a.push(u(()=>e.selectedPendingFeature,(e,t)=>{r.remove(e),r.add(t)}),i(()=>r.destroy()))}const r=new E({view:t,highlightName:L});return a.push(u(()=>e.temporaryHighlightFeature,e=>{r.removeAll(),r.add(e)}),i(()=>r.destroy())),a}function ve(e,t,a,i){const r=[];return t.forEach((t,s)=>{if(!t.error){const o=e[s],n=i.get(o)||[];o.attributes[a.objectIdField]=t.objectId,n.forEach(({form:e})=>r.push({feature:o,attachment:e}))}}),r}function _e(e){for(const t of e){const{sourceLayer:e}=t;e&&"globalIdField"in e&&null!=e.globalIdField&&(t.attributes[e.globalIdField]??=w())}}function Fe(e,t){const a=[];if(!t||0===t.size)return{addFeatures:e};for(const[i,r]of t)for(const{file:e}of r)a.push({feature:i,attachment:{globalId:w(),data:e}});return a.length?{addFeatures:e,addAttachments:a}:{addFeatures:e}}function be(e,t){return e.map(e=>{const{addFeatures:a}=e;if(!a||0===a.length)return e;const i=[];for(const r of a){const e=t.get(r);if(e)for(const{file:t}of e)i.push({feature:r,attachment:{globalId:w(),data:t}})}return i.length?{...e,addAttachments:i}:e})}e([y()],ge.prototype,"allowSave",null),e([y()],ge.prototype,"createFeatureState",void 0),e([y()],ge.prototype,"curveResizeDisabled",null),e([y()],ge.prototype,"curveUpdatesDisabled",null),e([y()],ge.prototype,"data",void 0),e([y({constructOnly:!0})],ge.prototype,"isNested",void 0),e([y()],ge.prototype,"formViewModel",null),e([y()],ge.prototype,"hasInvalidFormTemplate",null),e([y()],ge.prototype,"hasPendingEdits",null),e([y()],ge.prototype,"hasPreviousStep",null),e([y()],ge.prototype,"_getDrawMeshHelpMessage",void 0),e([y()],ge.prototype,"helpMessage",null),e([y()],ge.prototype,"noticeMessage",null),e([y()],ge.prototype,"layer",null),e([y()],ge.prototype,"parent",null),e([y()],ge.prototype,"keyboardCancellationEnabled",null),e([y()],ge.prototype,"reliesOnOwnerAdminPrivileges",null),e([y()],ge.prototype,"saveActionLabel",null),e([y()],ge.prototype,"shouldShowAttachments",null),e([y()],ge.prototype,"shouldAllowAttachmentEditing",null),e([y()],ge.prototype,"sketchUpdateOptions",null),e([y()],ge.prototype,"sketchViewModel",null),e([y()],ge.prototype,"availableCreateTools",null),e([y()],ge.prototype,"_attachmentsActive",null),ge=ce=e([v("esri.widgets.Editor.CreateFeaturesWorkflow")],ge);const Me=ge;export{Me as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{isSome as t}from"../../core/arrayUtils.js";import{createTask as i}from"../../core/asyncUtils.js";import o from"../../core/Collection.js";import{deprecatedFunction as r}from"../../core/deprecate.js";import s from"../../core/Error.js";import{EventedAccessor as a}from"../../core/Evented.js";import{abortHandle as n,makeHandle as l}from"../../core/handleUtils.js";import"../../core/has.js";import c from"../../core/Logger.js";import{destroyMaybe as d,abortMaybe as p,removeMaybe as h}from"../../core/maybe.js";import{throwIfAborted as u}from"../../core/promiseUtils.js";import w from"../../core/ReactiveMap.js";import{watch as f,syncAndInitial as m,initial as y,on as g,when as k,sync as v,whenOnce as _}from"../../core/reactiveUtils.js";import{property as W,subclass as M}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as T}from"../../core/support/UpdatingHandles.js";import{getTemplatesForLayers as F}from"../../editing/templateUtils.js";import{getGraphicLayer as b}from"../../graphic/graphicOriginUtils.js";import V from"../../layers/GraphicsLayer.js";import{isEditableLayer as S}from"../../layers/support/editableLayers.js";import{isFeatureLayer as I,isSubtypeGroupLayer as L,getOwningPortalUrl as E}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as C}from"../../portal/support/urlUtils.js";import A from"../../views/SelectionManager.js";import U from"../../views/interactive/sketch/SketchLabelOptions.js";import O from"../../views/interactive/sketch/SketchOptions.js";import j from"../../views/interactive/sketch/SketchTooltipOptions.js";import P from"../../views/interactive/sketch/SketchValueOptions.js";import{SnappingManager as R}from"../../views/interactive/snapping/SnappingManager.js";import H from"../../views/interactive/snapping/SnappingOptions.js";import{isSelectableLayer as q}from"../../views/support/selectionUtils.js";import x from"../Attachments/AttachmentsViewModel.js";import G from"./CreateFeaturesWorkflow.js";import D from"./UpdateWorkflow.js";import{getLayersFromWorkflow as B,isCreateFeaturesWorkflow as N,isUpdateRecordWorkflow as Q,isUpdateFeaturesWorkflow as z,isMergeFeaturesWorkflow as Z,isSplitFeatureWorkflow as $,isUpdateWorkflow as J,isFeatureFormViewModel as K,findEditorItemForLayerOrThrow as X,toFeatureInfos as Y,fetchFullFeaturesByObjectId as ee,fetchFullFeatures as te,findEditorItemForLayer as ie,whenEditorLayerView as oe,isBatchAttributeFormViewModel as re}from"./workflowUtils.js";import se from"./support/EditorItem.js";import{assertViewNot3D as ae,MultipleSourceLayersError as ne,InsufficientFeatureCountError as le,MissingOriginLayerError as ce,assertMergeWorkflowCapabilities as de,FetchFullFeatureError as pe,assertSplitWorkflowCapabilities as he}from"./support/errors.js";import{makeTemplateGroupInfoForLayer as ue}from"../FeatureTemplates/featureTemplatesUtils.js";import we from"../FeatureTemplates/FeatureTemplatesViewModel.js";import fe from"../Sketch/SketchViewModel.js";import me from"../Spinner/SpinnerViewModel.js";import{goTo as ye}from"../support/goToUtils.js";import{isFeatureItem as ge,isLayerItem as ke}from"../support/SelectionList/selectionListUtils.js";import ve from"../support/SelectionList/SelectionListViewModel.js";import _e from"../support/SelectionToolbar/SelectionToolbarViewModel.js";function We(e,t){return e?.find(e=>e.layer===t)}let Me=class extends a{constructor(e){super(e),this._defaultSelectionManager=new A,this._queuedSelectionTool=null,this._sketchEventListenerHandle=null,this._sketchGraphicsLayer=new V({listMode:"hide",internal:!0,title:"Editor sketch layer"}),this._snappingManager=null,this._templatesByLayer=new Map,this._updateItemsTask=null,this._updateTemplatesTask=null,this._updatingHandles=new T,this._featureTemplatesViewModelIsRestricted=!1,this.activeWorkflow=null,this._activityQueue=new o,this.editorItems=new o,this.editorItemsLayerMap=new w,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new x({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new we({disabledItemFunction:({layer:e})=>this._itemIsSuspended(e)}),this.layerInfos=null,this.ownSketchViewModel=new fe({layer:this._sketchGraphicsLayer,useLegacyCreateTools:this._get("useLegacyCreateTools")??!0}),this.selectionListViewModel=new ve,this.selectionManager=null,this.selectionToolbarViewModel=new _e({continuousSelectionEnabled:!0,defaultOperationType:"replace",persistSelection:!1,returnGeometry:!1}),this.sketchOptions=new O,this.snappingOptions=new H({attributeRulesEnabled:!0}),this.spinnerViewModel=new me,this.syncViewSelection=!1,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this.showConfirmationPrompt=()=>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.showConfirmationPrompt)),this.selectFeature=(e,t=!1)=>{const i=this.activeWorkflow;if(this._candidateCommitted||"update"!==i?.type)return;const{rootFeatures:o}=i.data;o.removeAll(),e&&o.add(e),t&&(i.next(),this._candidateCommitted=!0)}}initialize(){this.addHandles([f(()=>{const e=this.view,t=e?.map?.editableLayers.toArray(),i=e?.allLayerViews,o=i?.filter(e=>!!t?.includes(e.layer));return[t,o,this.layerInfos]},()=>this._updateEditorItems(),m),f(()=>this.hideTemplatesForInactiveLayers,()=>this.syncFeatureTemplates()),f(()=>this._selectionSources,()=>this._syncSelectionSources(),y),g(()=>this.activeWorkflow,"cancel",()=>this.emit("workflow-cancel")),g(()=>this.activeWorkflow,"commit",()=>this.emit("workflow-commit")),g(()=>this.activeWorkflow,"complete",()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)}),k(()=>!this.activeWorkflow&&this._queuedSelectionTool,()=>this._queuedSelectionTool&&this.selectionToolbarViewModel.activateTool(this._queuedSelectionTool)),f(()=>this.activeWorkflow,e=>this._defaultSelectionManager.highlightEnabled=!e),k(()=>this.view?.map,e=>e.add(this._sketchGraphicsLayer),y),g(()=>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},m),k(()=>"awaiting-update-feature-candidate"===this.state,()=>this._candidateCommitted=!1),g(()=>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 o={layer:e.layer,template:e.template};if(e.supportsUpload)return this.featureTemplatesViewModel.select(t,{emit:!1}),this.startCreateFeaturesWorkflow(o);await this.startCreateFeaturesWorkflowAtFeatureCreation(o)}),f(()=>[this.view,this.featureTemplatesViewModel],([e,t])=>{t.view=e},m),g(()=>this.view,"key-down",e=>{"Escape"===e.key&&this.activeWorkflow?.keyboardCancellationEnabled&&(e.stopPropagation(),this.back())}),g(()=>this.sketchViewModel,["create","delete","update"],e=>{const{activeWorkflow:t}=this,i=B(t),o=`sketch-${e.type}`;this.emit(o,{type:o,detail:e,layer:i[0],layers:i})},v),f(()=>this.view,e=>{if(this._snappingManager=d(this._snappingManager),!e)return;const t=this.snappingOptions;this._snappingManager=new R({view:e,options:t}),this.ownSketchViewModel.snappingManager=this._snappingManager},m),f(()=>this.snappingOptions,e=>{this._snappingManager&&(this._snappingManager.options=e)},m),g(()=>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:o})=>{t.view=e,i.view=e,o.view=e},m),f(()=>this.effectiveSelectionManager,e=>{this.selectionListViewModel.selectionManager=e,this.selectionToolbarViewModel.selectionManager=e},m)])}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=h(this._sketchEventListenerHandle),this.selectionListViewModel?.destroy(),this.selectionToolbarViewModel?.destroy(),this._defaultSelectionManager.destroy()}get _featureTemplatesLayersAndTables(){const e=new o;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 o;if(this.syncViewSelection||this.selectionManager)return e;for(const t of this.editorItems)q(t.layer)&&t.supportsUpdateWorkflow&&e.push(t.layer);return e}get activeFeatureCount(){const e=this.activeLeafWorkflow;return N(e)?e.pendingFeatures.length:Q(e)&&e.data.edits.feature?1:z(e)?e.data.fullFeatures.length:Z(e)?e.data.features.length:$(e)?2:0}get activeLeafWorkflow(){const e=this.activeWorkflow;return e&&J(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(){const e=this.view;return e&&this.syncViewSelection?e.selectionManager:this.selectionManager??this._defaultSelectionManager}get featureFormViewModel(){const e=this.activeWorkflow?.formViewModel;return K(e)?e:null}get formViewModel(){return this.activeWorkflow?.formViewModel}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 useLegacyCreateTools(){return this.ownSketchViewModel.useLegacyCreateTools}set useLegacyCreateTools(e){this.ownSketchViewModel.useLegacyCreateTools=e}get isUsingLegacyCreateTools(){return this.useLegacyCreateTools||"2d"!==this.view?.type}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(){return this._getWorkingFeatures().some(e=>e.geometry)}get page(){const{activeWorkflow:e,state:t}=this;if("update"===e?.type&&K(e.formViewModel)){const{associatedLayer:t,associationId:i}=e.formViewModel;if(t||null!=i)return"viewing-associated-features"}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{activeLeafWorkflow:e}=this;if(Q(e))return!1===e.data.editorItem?.capabilities.update.attributes||!0===e.formViewModel.disabled;if(z(e)){const{formViewModel:t}=e;return t.disabled||t.readOnly}return!1}get featureFormHasAssociation(){return!!this.featureFormViewModel?.activeAssociation}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeLeafWorkflow:e}=this;if(Q(e)){const{data:t}=e;return t.editorItem?.capabilities.delete.enabled&&!t.readOnly}return!!z(e)&&e.data.editorItems.every(e=>e.capabilities.delete.enabled)}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}get snappingManager(){return this._snappingManager}activateSelectionTool(e){return this.selectionToolbarViewModel.activateTool(e)}cancelSelectionTool(){this.selectionToolbarViewModel.cancel()}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(o){this._logErrorAndCancelWorkflow(o)}finally{i.resolve()}}async startCreateFeaturesWorkflowAtFeatureEdit(e){await _(()=>!this.updating);const t=this._createUpdatingResolver();try{const{initialFeature:t}=e,i=t.sourceLayer=t.layer,o=i?X(this.editorItems,i):void 0;if(!o?.supportsCreateFeaturesWorkflow)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled for this layer.");await this._cancelWorkflow();const r=this._createCreateFeaturesWorkflow({initialFeature:t,layer:o.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",r),await r.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startMergeFeaturesWorkflow(e,t={}){await _(()=>!this.updating),ae(this,"merge-features");const i=Array.isArray(e)?Y(e):[e];if(i.length>1)throw new ne;if(0===i.length||i[0].objectIds.length<2)throw new le(2);const r=i[0],s=r.layer;if(!s)throw new ce;const a=X(this.editorItems,s);de(a);const l=this._createUpdatingResolver(),c=new AbortController;this.addHandles(n(c));try{await this._cancelWorkflow(),this.cancelSelectionTool();const e=await ee(r.objectIds,s,this.view?.spatialReference,c.signal);if(e.length!==r.objectIds.length)throw new pe;let i;if(t.keyFeature){const o=t.keyFeature.getObjectId();i=e.find(e=>e.getObjectId()===o)??t.keyFeature}const a=this._createUpdateWorkflow("editing-existing-feature",{rootFeatures:new o(e),rootWorkflowOptions:{type:"merge",props:{...t,keyFeature:i}}});this._set("activeWorkflow",a),this.addHandles(this._destroyWorkflowOnCommit(a)),await a.start()}catch(d){this._logErrorAndCancelWorkflow(d)}finally{l.resolve()}}async startSplitFeatureWorkflow(e,t={}){await _(()=>!this.updating),ae(this,"split-feature");const i=b(e);if(!i)throw new ce;const r=X(this.editorItems,i);he(r);const s=this._createUpdatingResolver(),a=new AbortController;this.addHandles(n(a));try{await this._cancelWorkflow(),this.cancelSelectionTool();const r=await te([e],i,this.view?.spatialReference,a.signal);if(1!==r.length)throw new pe;const s=this._createUpdateWorkflow("editing-existing-feature",{rootFeatures:new o(r),rootWorkflowOptions:{type:"split",props:t}});this._set("activeWorkflow",s),this.addHandles(this._destroyWorkflowOnCommit(s)),await s.start()}catch(l){this._logErrorAndCancelWorkflow(l)}finally{s.resolve()}}async startUpdateFeaturesWorkflow(e){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update features workflow is unsupported or disabled.");const t=Array.isArray(e)?Y(e):[e];if(t.length>1)throw new ne;const i=this._createUpdatingResolver();try{await this._cancelWorkflow(),this.cancelSelectionTool();const e=this._createUpdateWorkflow("editing-existing-feature",{rootFeatureInfos:t,rootWorkflowOptions:{type:"update-multiple"}});e.addHandles(this._destroyWorkflowOnCommit(e)),this._set("activeWorkflow",e),await e.start()}catch(o){this._logErrorAndCancelWorkflow(o)}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(),this.cancelSelectionTool();const t=this._createUpdateWorkflow("editing-existing-feature",{rootFeatures:new o([e])});t.addHandles(this._destroyWorkflowOnCommit(t)),this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowWithActiveSelection(){const{selectionListViewModel:e}=this;if(!e.visibleFeatureCount||!e.visibleLayerCount)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.layerItems.find(e=>e.visible);t&&await this._startUpdateWorkflowWithLayerItem(t,"update")}async deleteFeatureFromWorkflow(){r(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;if(J(e))return e.deleteActiveFeatures();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})}itemHasInvalidFormTemplate(e){return null!=e&&!0===ie(this.editorItems,e.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){this._featureTemplatesViewModelIsRestricted||this._updateTemplates()}zoomTo(e){const{view:i,sketchViewModel:o}=this;if(!i)return;const r=void 0,s=e??o?.createGraphic;if(s)"mesh"===s.geometry?.type?ye(i,s.geometry,r):ye(i,s,r);else{const e=this._getWorkingFeatures();"3d"===i.type&&e?.some(e=>"mesh"===e.geometry?.type)?ye(i,e.map(e=>e.geometry).filter(t),r):e&&ye(i,e,r)}}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){ge(e)&&await this.startUpdateWorkflowAtFeatureEdit(e.graphic)}async onSelectionListMenuItemSelect(e,t){ge(e)?await this.startUpdateWorkflowAtFeatureEdit(e.graphic):ke(e)&&await this._startUpdateWorkflowWithLayerItem(e,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,o=i.editableLayers.toArray(),r=i.allTables.toArray().filter(e=>I(e)||L(e));return await Promise.allSettled([...o.flatMap(e=>this._getLayerLoadPromise(e)),...r.flatMap(e=>this._getLayerLoadPromise(e))]),u(e),[...o.reverse(),...r.reverse()].filter(e=>S(e)&&("mesh"!==e.geometryType||"3d"===t.type)).flatMap(e=>"subtype-group"===e.type?e.sublayers.toArray():e)}_getLayerLoadPromise(e){return L(e)?e.loadAll():e.load()}_drainEditorItems(){this.editorItems.drain(e=>e.destroy())}_updateEditorItems(){p(this._updateItemsTask);const{view:e}=this,t=i(async t=>{if(!e?.map||!e?.allLayerViews)return;const i=await this._getEditorItemCandidates(t);if(!i.length)return this._drainEditorItems(),void this.editorItemsLayerMap.clear();const o=[],r=[],s=[],{editorItemsLayerMap:a,layerInfos:n}=this;for(const c of i){const t=We(n,c),i=await oe(e,c).catch(()=>null),l=t?o:i?r:s,d=new se({layer:c,layerInfo:t,layerView:i});l.push(d),a.set(c,d)}n?.length&&o.sort((e,t)=>n.findIndex(({layer:t})=>t===e.layer)-n.findIndex(({layer:e})=>e===t.layer));const l=[...o,...r,...s];t.aborted||(this._drainEditorItems(),this.editorItems.addMany(l))});this._updatingHandles.consumePromise(t.promise),this._updateItemsTask=t}_updateTemplates(){p(this._updateTemplatesTask);const e=i(async e=>{const t=this._templatesByLayer,i=this._featureTemplatesLayersAndTables.filter(e=>!t.has(e));if(i.length>0){const o=await F({layers:i.toArray(),view:this.view,signal:e,queryOptions:{returnVisibleTemplatesOnly:!0}});for(const{layer:e,templates:i}of o)t.set(e,i)}this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)});this._updatingHandles.consumePromise(e.promise),this._updateTemplatesTask=e}_setFeatureTemplatesViewModelLayers(e){const t=this._templatesByLayer,i=[];for(const o of e){const e=t.get(o);e&&e.length>0&&i.push(ue(o,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 G.create({viewModel:this,creationInfo:e,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)})}_createUpdateWorkflow(e,t){const i=D.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:e,...t,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)});return i}_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 o=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()=>(o=await(e.addAttachment?.(t,i).catch(e=>{throw e?.error||e}))??null,o)),o}async _applyEdits(e,t,i){let o=null;const r=e.url?await E(e.url):null,s={returnServiceEditsOption:(!r||!C(r))&&!/\/hosted\//i.test(e.url)?"original-and-current-features":void 0,editsRespectTrueCurves:!0,...i};return await this._queueOperation(async()=>{const{view:i}=this;if(!i)return null;const r=await oe(i,e).catch(()=>null);return o=await e.applyEdits(t,s),r&&await _(()=>!r.updating),o}),o}async _applyEditsFeatureService(e,t,i){let o=null;return await this._queueOperation(async()=>o=await e.applyEdits(t,i)),o}_destroyWorkflowOnCommit(e){return g(()=>e,"commit",()=>{e.destroy(),this.activeWorkflow===e&&this._set("activeWorkflow",null)})}_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 o={error:i,retry:()=>(t(o,this.failures),this._queueOperation(e)),cancel:()=>{t(o,this.failures)}};this._set("failures",[...this.failures,o])}).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:o}=e,r=t.find(e=>!!e.error)||o.find(e=>!!e.error)||i.find(e=>!!e.error);if(r)throw r.error}}_createUpdatingResolver(){const e=Promise.withResolvers();return this._updatingHandles.consumePromise(e.promise),e}_logErrorAndCancelWorkflow(e){const{name:t,message:i,details:o}=e;this._logError(t??"editing:workflow-start-failed",i??void 0,o??e),this._cancelWorkflow({force:!0})}_itemIsSuspended(e){const t=X(this.editorItems,e);return null!=t&&(!t.visible||t.disabled)}_logError(e,t,i){c.getLogger(this).error(new s(e,t,i))}_syncSelectionSources(){this._defaultSelectionManager.sources.items=this._selectionSources.toArray()}async _onSelectionComplete(e){if(e.aborted)return;const{operationType:t,selection:i}=e,{effectiveSelectionManager:o}=this;this._queuedSelectionTool=void 0;const r=[],s=[];i.forEach(e=>{const t=b(e),i=this.editorItemsLayerMap.get(t);i?.editable&&s.push(e),!1!==i?.visible&&r.push(e)});const a=1===r.length&&s.includes(r[0]);if("ready"===this.state&&a&&"replace"===t)return this._queuedSelectionTool=e.toolName,this.startUpdateWorkflowAtFeatureEdit(r[0]);switch(t){case"remove":o.updateSelection({current:[],added:[],removed:r});break;case"replace":o.clear(),o.updateSelection({current:r,added:[],removed:[]});break;case"add":o.updateSelection({current:r,added:[],removed:[]})}}async _startUpdateWorkflowWithLayerItem(e,t){if(!e.objectIds?.length)return;const i=e.featureItems.filter(e=>e.visible).map(e=>e.graphic),o=this.selectionListViewModel.filterText;if(1===i.length)return await this.startUpdateWorkflowAtFeatureEdit(i[0]);let r;if(null!=o&&""!==o){const e=Y(i);if(e.length>1)throw new ne;if(r=e[0],!r)throw new le("merge"===t?2:1)}else r={layer:e.layer,objectIds:e.objectIds};"update"===t?await this.startUpdateFeaturesWorkflow(r):"merge"===t&&await this.startMergeFeaturesWorkflow(r)}_getWorkingFeatures(){const{sketchViewModel:e}=this;if(e?.createGraphic)return[e.createGraphic];if(e?.updateGraphics?.length)return e.updateGraphics.toArray();const{formViewModel:t}=this;if(K(t)&&t.feature)return[t.feature];if(re(t)){if(t.activeFeature)return[t.activeFeature];if(t.features.length)return t.features.toArray()}return[]}};e([W()],Me.prototype,"_defaultSelectionManager",void 0),e([W()],Me.prototype,"_featureTemplatesLayersAndTables",null),e([W()],Me.prototype,"_queuedSelectionTool",void 0),e([W()],Me.prototype,"_snappingManager",void 0),e([W()],Me.prototype,"_selectionSources",null),e([W()],Me.prototype,"activeFeatureCount",null),e([W({readOnly:!0})],Me.prototype,"activeWorkflow",void 0),e([W()],Me.prototype,"activeLeafWorkflow",null),e([W({readOnly:!0})],Me.prototype,"_activityQueue",void 0),e([W({readOnly:!0})],Me.prototype,"canCreate",null),e([W()],Me.prototype,"canCreateVisible",null),e([W({readOnly:!0})],Me.prototype,"canUpdate",null),e([W()],Me.prototype,"canUpdateVisible",null),e([W()],Me.prototype,"featureTemplatesLayers",null),e([W()],Me.prototype,"editorItems",void 0),e([W()],Me.prototype,"editorItemsLayerMap",void 0),e([W()],Me.prototype,"effectiveSelectionManager",null),e([W({readOnly:!0})],Me.prototype,"failures",void 0),e([W()],Me.prototype,"hideTemplatesForInactiveLayers",void 0),e([W({type:x})],Me.prototype,"attachmentsViewModel",void 0),e([W()],Me.prototype,"featureFormViewModel",null),e([W()],Me.prototype,"formViewModel",null),e([W()],Me.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),e([W({type:we})],Me.prototype,"featureTemplatesViewModel",void 0),e([W({type:U})],Me.prototype,"labelOptions",null),e([W()],Me.prototype,"layerInfos",void 0),e([W()],Me.prototype,"useLegacyCreateTools",null),e([W()],Me.prototype,"isUsingLegacyCreateTools",null),e([W()],Me.prototype,"ownSketchViewModel",void 0),e([W()],Me.prototype,"selectionListViewModel",void 0),e([W()],Me.prototype,"selectionManager",void 0),e([W()],Me.prototype,"selectionToolbarViewModel",void 0),e([W()],Me.prototype,"sketchOptions",void 0),e([W()],Me.prototype,"sketchViewModel",null),e([W({type:H,nonNullable:!0})],Me.prototype,"snappingOptions",void 0),e([W()],Me.prototype,"spinnerViewModel",void 0),e([W()],Me.prototype,"state",null),e([W({readOnly:!0})],Me.prototype,"syncing",null),e([W()],Me.prototype,"syncViewSelection",void 0),e([W()],Me.prototype,"updating",null),e([W({type:j})],Me.prototype,"tooltipOptions",null),e([W({type:P})],Me.prototype,"valueOptions",null),e([W()],Me.prototype,"view",null),e([W()],Me.prototype,"canZoomTo",null),e([W()],Me.prototype,"pageStack",void 0),e([W()],Me.prototype,"showDiscardEditsPrompt",void 0),e([W()],Me.prototype,"showConfirmationPrompt",void 0),e([W()],Me.prototype,"_candidateCommitted",void 0),e([W()],Me.prototype,"page",null),e([W()],Me.prototype,"featureFormDisabled",null),e([W()],Me.prototype,"featureFormHasAssociation",null),e([W()],Me.prototype,"canGoBack",null),e([W()],Me.prototype,"shouldShowDeleteButton",null),e([W()],Me.prototype,"hasPendingEdits",null),e([W()],Me.prototype,"snappingManager",null),Me=e([M("esri.widgets.Editor.EditorViewModel")],Me);const Te=Me;export{Te as default};
2
+ import{__decorate as e}from"tslib";import{isSome as t}from"../../core/arrayUtils.js";import{createTask as i}from"../../core/asyncUtils.js";import o from"../../core/Collection.js";import{deprecatedFunction as r}from"../../core/deprecate.js";import s from"../../core/Error.js";import{EventedAccessor as a}from"../../core/Evented.js";import{abortHandle as n,makeHandle as l}from"../../core/handleUtils.js";import"../../core/has.js";import c from"../../core/Logger.js";import{destroyMaybe as d,abortMaybe as p,removeMaybe as h}from"../../core/maybe.js";import{throwIfAborted as u}from"../../core/promiseUtils.js";import w from"../../core/ReactiveMap.js";import{watch as f,syncAndInitial as m,initial as y,on as g,when as k,sync as v,whenOnce as _}from"../../core/reactiveUtils.js";import{property as W,subclass as M}from"../../core/accessorSupport/decorators.js";import{UpdatingHandles as T}from"../../core/support/UpdatingHandles.js";import{getTemplatesForLayers as F}from"../../editing/templateUtils.js";import{getGraphicLayer as b}from"../../graphic/graphicOriginUtils.js";import S from"../../layers/GraphicsLayer.js";import{isEditableLayer as V}from"../../layers/support/editableLayers.js";import{isFeatureLayer as I,isSubtypeGroupLayer as L,getOwningPortalUrl as E}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as C}from"../../portal/support/urlUtils.js";import A from"../../views/SelectionManager.js";import{fetchFullFeaturesByObjectId as U}from"../../views/draw/support/editingSessionUtils.js";import O from"../../views/interactive/sketch/SketchLabelOptions.js";import j from"../../views/interactive/sketch/SketchOptions.js";import P from"../../views/interactive/sketch/SketchTooltipOptions.js";import R from"../../views/interactive/sketch/SketchValueOptions.js";import{SnappingManager as H}from"../../views/interactive/snapping/SnappingManager.js";import q from"../../views/interactive/snapping/SnappingOptions.js";import{isSelectableLayer as x}from"../../views/support/selectionUtils.js";import G from"../Attachments/AttachmentsViewModel.js";import D from"./CreateFeaturesWorkflow.js";import B from"./UpdateWorkflow.js";import{getLayersFromWorkflow as N,isCreateFeaturesWorkflow as Q,isUpdateRecordWorkflow as z,isUpdateFeaturesWorkflow as Z,isMergeFeaturesWorkflow as $,isSplitFeatureWorkflow as J,isUpdateWorkflow as K,isFeatureFormViewModel as X,findEditorItemForLayerOrThrow as Y,toFeatureInfos as ee,fetchFullFeatures as te,findEditorItemForLayer as ie,whenEditorLayerView as oe,isBatchAttributeFormViewModel as re}from"./workflowUtils.js";import se from"./support/EditorItem.js";import{assertViewNot3D as ae,MultipleSourceLayersError as ne,InsufficientFeatureCountError as le,MissingOriginLayerError as ce,assertMergeWorkflowCapabilities as de,FetchFullFeatureError as pe,assertSplitWorkflowCapabilities as he}from"./support/errors.js";import{makeTemplateGroupInfoForLayer as ue}from"../FeatureTemplates/featureTemplatesUtils.js";import we from"../FeatureTemplates/FeatureTemplatesViewModel.js";import fe from"../Sketch/SketchViewModel.js";import me from"../Spinner/SpinnerViewModel.js";import{goTo as ye}from"../support/goToUtils.js";import{isFeatureItem as ge,isLayerItem as ke}from"../support/SelectionList/selectionListUtils.js";import ve from"../support/SelectionList/SelectionListViewModel.js";import _e from"../support/SelectionToolbar/SelectionToolbarViewModel.js";function We(e,t){return e?.find(e=>e.layer===t)}let Me=class extends a{constructor(e){super(e),this._defaultSelectionManager=new A,this._queuedSelectionTool=null,this._sketchEventListenerHandle=null,this._sketchGraphicsLayer=new S({listMode:"hide",internal:!0,title:"Editor sketch layer"}),this._snappingManager=null,this._templatesByLayer=new Map,this._updateItemsTask=null,this._updateTemplatesTask=null,this._updatingHandles=new T,this._featureTemplatesViewModelIsRestricted=!1,this.activeWorkflow=null,this._activityQueue=new o,this.editorItems=new o,this.editorItemsLayerMap=new w,this.failures=[],this.hideTemplatesForInactiveLayers=!1,this.attachmentsViewModel=new G({capabilities:{editing:!0}}),this.featureTemplatesViewModel=new we({disabledItemFunction:({layer:e})=>this._itemIsSuspended(e)}),this.layerInfos=null,this.ownSketchViewModel=new fe({layer:this._sketchGraphicsLayer,useLegacyCreateTools:this._get("useLegacyCreateTools")??!0}),this.selectionListViewModel=new ve,this.selectionManager=null,this.selectionToolbarViewModel=new _e({continuousSelectionEnabled:!0,defaultOperationType:"replace",persistSelection:!1,returnGeometry:!1}),this.sketchOptions=new j,this.snappingOptions=new q({attributeRulesEnabled:!0}),this.spinnerViewModel=new me,this.syncViewSelection=!1,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this.showConfirmationPrompt=()=>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.showConfirmationPrompt)),this.selectFeature=(e,t=!1)=>{const i=this.activeWorkflow;if(this._candidateCommitted||"update"!==i?.type)return;const{rootFeatures:o}=i.data;o.removeAll(),e&&o.add(e),t&&(i.next(),this._candidateCommitted=!0)}}initialize(){this.addHandles([f(()=>{const e=this.view,t=e?.map?.editableLayers.toArray(),i=e?.allLayerViews,o=i?.filter(e=>!!t?.includes(e.layer));return[t,o,this.layerInfos]},()=>this._updateEditorItems(),m),f(()=>this.hideTemplatesForInactiveLayers,()=>this.syncFeatureTemplates()),f(()=>this._selectionSources,()=>this._syncSelectionSources(),y),g(()=>this.activeWorkflow,"cancel",()=>this.emit("workflow-cancel")),g(()=>this.activeWorkflow,"commit",()=>this.emit("workflow-commit")),g(()=>this.activeWorkflow,"complete",()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)}),k(()=>!this.activeWorkflow&&this._queuedSelectionTool,()=>this._queuedSelectionTool&&this.selectionToolbarViewModel.activateTool(this._queuedSelectionTool)),f(()=>this.activeWorkflow,e=>this._defaultSelectionManager.highlightEnabled=!e),k(()=>this.view?.map,e=>e.add(this._sketchGraphicsLayer),y),g(()=>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},m),k(()=>"awaiting-update-feature-candidate"===this.state,()=>this._candidateCommitted=!1),g(()=>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 o={layer:e.layer,template:e.template};if(e.supportsUpload)return this.featureTemplatesViewModel.select(t,{emit:!1}),this.startCreateFeaturesWorkflow(o);await this.startCreateFeaturesWorkflowAtFeatureCreation(o)}),f(()=>[this.view,this.featureTemplatesViewModel],([e,t])=>{t.view=e},m),g(()=>this.view,"key-down",e=>{"Escape"===e.key&&this.activeWorkflow?.keyboardCancellationEnabled&&(e.stopPropagation(),this.back())}),g(()=>this.sketchViewModel,["create","delete","update"],e=>{const{activeWorkflow:t}=this,i=N(t),o=`sketch-${e.type}`;this.emit(o,{type:o,detail:e,layer:i[0],layers:i})},v),f(()=>this.view,e=>{if(this._snappingManager=d(this._snappingManager),!e)return;const t=this.snappingOptions;this._snappingManager=new H({view:e,options:t}),this.ownSketchViewModel.snappingManager=this._snappingManager},m),f(()=>this.snappingOptions,e=>{this._snappingManager&&(this._snappingManager.options=e)},m),g(()=>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:o})=>{t.view=e,i.view=e,o.view=e},m),f(()=>this.effectiveSelectionManager,e=>{this.selectionListViewModel.selectionManager=e,this.selectionToolbarViewModel.selectionManager=e},m)])}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=h(this._sketchEventListenerHandle),this.selectionListViewModel?.destroy(),this.selectionToolbarViewModel?.destroy(),this._defaultSelectionManager.destroy()}get _featureTemplatesLayersAndTables(){const e=new o;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 o;if(this.syncViewSelection||this.selectionManager)return e;for(const t of this.editorItems)x(t.layer)&&t.supportsUpdateWorkflow&&e.push(t.layer);return e}get activeFeatureCount(){const e=this.activeLeafWorkflow;return Q(e)?e.pendingFeatures.length:z(e)&&e.data.edits.feature?1:Z(e)?e.data.fullFeatures.length:$(e)?e.data.features.length:J(e)?2:0}get activeLeafWorkflow(){const e=this.activeWorkflow;return e&&K(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(){const e=this.view;return e&&this.syncViewSelection?e.selectionManager:this.selectionManager??this._defaultSelectionManager}get featureFormViewModel(){const e=this.activeWorkflow?.formViewModel;return X(e)?e:null}get formViewModel(){return this.activeWorkflow?.formViewModel}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 useLegacyCreateTools(){return this.ownSketchViewModel.useLegacyCreateTools}set useLegacyCreateTools(e){this.ownSketchViewModel.useLegacyCreateTools=e}get isUsingLegacyCreateTools(){return this.useLegacyCreateTools||"2d"!==this.view?.type}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(){return this._getWorkingFeatures().some(e=>e.geometry)}get page(){const{activeWorkflow:e,state:t}=this;if("update"===e?.type&&X(e.formViewModel)){const{associatedLayer:t,associationId:i}=e.formViewModel;if(t||null!=i)return"viewing-associated-features"}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{activeLeafWorkflow:e}=this;if(z(e))return!1===e.data.editorItem?.capabilities.update.attributes||!0===e.formViewModel.disabled;if(Z(e)){const{formViewModel:t}=e;return t.disabled||t.readOnly}return!1}get featureFormHasAssociation(){return!!this.featureFormViewModel?.activeAssociation}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeLeafWorkflow:e}=this;if(z(e)){const{data:t}=e;return t.editorItem?.capabilities.delete.enabled&&!t.readOnly}return!!Z(e)&&e.data.editorItems.every(e=>e.capabilities.delete.enabled)}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}get snappingManager(){return this._snappingManager}activateSelectionTool(e){return this.selectionToolbarViewModel.activateTool(e)}cancelSelectionTool(){this.selectionToolbarViewModel.cancel()}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(o){this._logErrorAndCancelWorkflow(o)}finally{i.resolve()}}async startCreateFeaturesWorkflowAtFeatureEdit(e){await _(()=>!this.updating);const t=this._createUpdatingResolver();try{const{initialFeature:t}=e,i=t.sourceLayer=t.layer,o=i?Y(this.editorItems,i):void 0;if(!o?.supportsCreateFeaturesWorkflow)throw new s("editing:unsupported-workflow","Creating features is unsupported or disabled for this layer.");await this._cancelWorkflow();const r=this._createCreateFeaturesWorkflow({initialFeature:t,layer:o.layer,maxFeatures:1},"creating-features");this._set("activeWorkflow",r),await r.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startMergeFeaturesWorkflow(e,t={}){await _(()=>!this.updating),ae(this,"merge-features");const i=Array.isArray(e)?ee(e):[e];if(i.length>1)throw new ne;if(0===i.length||i[0].objectIds.length<2)throw new le(2);const r=i[0],s=r.layer;if(!s)throw new ce;const a=Y(this.editorItems,s);de(a);const l=this._createUpdatingResolver(),c=new AbortController;this.addHandles(n(c));try{await this._cancelWorkflow(),this.cancelSelectionTool();const e=await U(r.objectIds,s,this.view?.spatialReference,c.signal);if(e.length!==r.objectIds.length)throw new pe;let i;if(t.keyFeature){const o=t.keyFeature.getObjectId();i=e.find(e=>e.getObjectId()===o)??t.keyFeature}const a=this._createUpdateWorkflow("editing-existing-feature",{rootFeatures:new o(e),rootWorkflowOptions:{type:"merge",props:{...t,keyFeature:i}}});this._set("activeWorkflow",a),this.addHandles(this._destroyWorkflowOnCommit(a)),await a.start()}catch(d){this._logErrorAndCancelWorkflow(d)}finally{l.resolve()}}async startSplitFeatureWorkflow(e,t={}){await _(()=>!this.updating),ae(this,"split-feature");const i=b(e);if(!i)throw new ce;const r=Y(this.editorItems,i);he(r);const s=this._createUpdatingResolver(),a=new AbortController;this.addHandles(n(a));try{await this._cancelWorkflow(),this.cancelSelectionTool();const r=await te([e],i,this.view?.spatialReference,a.signal);if(1!==r.length)throw new pe;const s=this._createUpdateWorkflow("editing-existing-feature",{rootFeatures:new o(r),rootWorkflowOptions:{type:"split",props:t}});this._set("activeWorkflow",s),this.addHandles(this._destroyWorkflowOnCommit(s)),await s.start()}catch(l){this._logErrorAndCancelWorkflow(l)}finally{s.resolve()}}async startUpdateFeaturesWorkflow(e){if(await _(()=>!this.updating),!this.canUpdate)return void this._logError("editing:unsupported-workflow","Update features workflow is unsupported or disabled.");const t=Array.isArray(e)?ee(e):[e];if(t.length>1)throw new ne;const i=this._createUpdatingResolver();try{await this._cancelWorkflow(),this.cancelSelectionTool();const e=this._createUpdateWorkflow("editing-existing-feature",{rootFeatureInfos:t,rootWorkflowOptions:{type:"update-multiple"}});e.addHandles(this._destroyWorkflowOnCommit(e)),this._set("activeWorkflow",e),await e.start()}catch(o){this._logErrorAndCancelWorkflow(o)}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(),this.cancelSelectionTool();const t=this._createUpdateWorkflow("editing-existing-feature",{rootFeatures:new o([e])});t.addHandles(this._destroyWorkflowOnCommit(t)),this._set("activeWorkflow",t),await t.start()}catch(i){this._logErrorAndCancelWorkflow(i)}finally{t.resolve()}}async startUpdateWorkflowWithActiveSelection(){const{selectionListViewModel:e}=this;if(!e.visibleFeatureCount||!e.visibleLayerCount)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.layerItems.find(e=>e.visible);t&&await this._startUpdateWorkflowWithLayerItem(t,"update")}async deleteFeatureFromWorkflow(){r(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;if(K(e))return e.deleteActiveFeatures();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})}itemHasInvalidFormTemplate(e){return null!=e&&!0===ie(this.editorItems,e.layer)?.hasInvalidFormTemplate}syncFeatureTemplates(){this._featureTemplatesViewModelIsRestricted||this._updateTemplates()}zoomTo(e){const{view:i,sketchViewModel:o}=this;if(!i)return;const r=void 0,s=e??o?.createGraphic;if(s)"mesh"===s.geometry?.type?ye(i,s.geometry,r):ye(i,s,r);else{const e=this._getWorkingFeatures();"3d"===i.type&&e?.some(e=>"mesh"===e.geometry?.type)?ye(i,e.map(e=>e.geometry).filter(t),r):e&&ye(i,e,r)}}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){ge(e)&&await this.startUpdateWorkflowAtFeatureEdit(e.graphic)}async onSelectionListMenuItemSelect(e,t){ge(e)?await this.startUpdateWorkflowAtFeatureEdit(e.graphic):ke(e)&&await this._startUpdateWorkflowWithLayerItem(e,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,o=i.editableLayers.toArray(),r=i.allTables.toArray().filter(e=>I(e)||L(e));return await Promise.allSettled([...o.flatMap(e=>this._getLayerLoadPromise(e)),...r.flatMap(e=>this._getLayerLoadPromise(e))]),u(e),[...o.reverse(),...r.reverse()].filter(e=>V(e)&&("mesh"!==e.geometryType||"3d"===t.type)).flatMap(e=>"subtype-group"===e.type?e.sublayers.toArray():e)}_getLayerLoadPromise(e){return L(e)?e.loadAll():e.load()}_drainEditorItems(){this.editorItems.drain(e=>e.destroy())}_updateEditorItems(){p(this._updateItemsTask);const{view:e}=this,t=i(async t=>{if(!e?.map||!e?.allLayerViews)return;const i=await this._getEditorItemCandidates(t);if(!i.length)return this._drainEditorItems(),void this.editorItemsLayerMap.clear();const o=[],r=[],s=[],{editorItemsLayerMap:a,layerInfos:n}=this;for(const c of i){const t=We(n,c),i=await oe(e,c).catch(()=>null),l=t?o:i?r:s,d=new se({layer:c,layerInfo:t,layerView:i});l.push(d),a.set(c,d)}n?.length&&o.sort((e,t)=>n.findIndex(({layer:t})=>t===e.layer)-n.findIndex(({layer:e})=>e===t.layer));const l=[...o,...r,...s];t.aborted||(this._drainEditorItems(),this.editorItems.addMany(l))});this._updatingHandles.consumePromise(t.promise),this._updateItemsTask=t}_updateTemplates(){p(this._updateTemplatesTask);const e=i(async e=>{const t=this._templatesByLayer,i=this._featureTemplatesLayersAndTables.filter(e=>!t.has(e));if(i.length>0){const o=await F({layers:i.toArray(),view:this.view,signal:e,queryOptions:{returnVisibleTemplatesOnly:!0}});for(const{layer:e,templates:i}of o)t.set(e,i)}this._setFeatureTemplatesViewModelLayers(this.featureTemplatesLayers)});this._updatingHandles.consumePromise(e.promise),this._updateTemplatesTask=e}_setFeatureTemplatesViewModelLayers(e){const t=this._templatesByLayer,i=[];for(const o of e){const e=t.get(o);e&&e.length>0&&i.push(ue(o,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 D.create({viewModel:this,creationInfo:e,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:t,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)})}_createUpdateWorkflow(e,t){const i=B.create({viewModel:this,sketchOptions:this.sketchOptions,snappingManager:this._snappingManager,startAt:e,...t,applyEdits:(e,t,i)=>this._applyEdits(e,t,i),applyEditsFeatureService:(e,t,i)=>this._applyEditsFeatureService(e,t,i),addAttachmentsCallback:(e,t)=>this._addAttachments(e,t)});return i}_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 o=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()=>(o=await(e.addAttachment?.(t,i).catch(e=>{throw e?.error||e}))??null,o)),o}async _applyEdits(e,t,i){let o=null;const r=e.url?await E(e.url):null,s={returnServiceEditsOption:(!r||!C(r))&&!/\/hosted\//i.test(e.url)?"original-and-current-features":void 0,editsRespectTrueCurves:!0,...i};return await this._queueOperation(async()=>{const{view:i}=this;if(!i)return null;const r=await oe(i,e).catch(()=>null);return o=await e.applyEdits(t,s),r&&await _(()=>!r.updating),o}),o}async _applyEditsFeatureService(e,t,i){let o=null;return await this._queueOperation(async()=>o=await e.applyEdits(t,i)),o}_destroyWorkflowOnCommit(e){return g(()=>e,"commit",()=>{e.destroy(),this.activeWorkflow===e&&this._set("activeWorkflow",null)})}_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 o={error:i,retry:()=>(t(o,this.failures),this._queueOperation(e)),cancel:()=>{t(o,this.failures)}};this._set("failures",[...this.failures,o])}).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:o}=e,r=t.find(e=>!!e.error)||o.find(e=>!!e.error)||i.find(e=>!!e.error);if(r)throw r.error}}_createUpdatingResolver(){const e=Promise.withResolvers();return this._updatingHandles.consumePromise(e.promise),e}_logErrorAndCancelWorkflow(e){const{name:t,message:i,details:o}=e;this._logError(t??"editing:workflow-start-failed",i??void 0,o??e),this._cancelWorkflow({force:!0})}_itemIsSuspended(e){const t=Y(this.editorItems,e);return null!=t&&(!t.visible||t.disabled)}_logError(e,t,i){c.getLogger(this).error(new s(e,t,i))}_syncSelectionSources(){this._defaultSelectionManager.sources.items=this._selectionSources.toArray()}async _onSelectionComplete(e){if(e.aborted)return;const{operationType:t,selection:i}=e,{effectiveSelectionManager:o}=this;this._queuedSelectionTool=void 0;const r=[],s=[];i.forEach(e=>{const t=b(e),i=this.editorItemsLayerMap.get(t);i?.editable&&s.push(e),!1!==i?.visible&&r.push(e)});const a=1===r.length&&s.includes(r[0]);if("ready"===this.state&&a&&"replace"===t)return this._queuedSelectionTool=e.toolName,this.startUpdateWorkflowAtFeatureEdit(r[0]);switch(t){case"remove":o.updateSelection({current:[],added:[],removed:r});break;case"replace":o.clear(),o.updateSelection({current:r,added:[],removed:[]});break;case"add":o.updateSelection({current:r,added:[],removed:[]})}}async _startUpdateWorkflowWithLayerItem(e,t){if(!e.objectIds?.length)return;const i=e.featureItems.filter(e=>e.visible).map(e=>e.graphic),o=this.selectionListViewModel.filterText;if(1===i.length)return await this.startUpdateWorkflowAtFeatureEdit(i[0]);let r;if(null!=o&&""!==o){const e=ee(i);if(e.length>1)throw new ne;if(r=e[0],!r)throw new le("merge"===t?2:1)}else r={layer:e.layer,objectIds:e.objectIds};"update"===t?await this.startUpdateFeaturesWorkflow(r):"merge"===t&&await this.startMergeFeaturesWorkflow(r)}_getWorkingFeatures(){const{sketchViewModel:e}=this;if(e?.createGraphic)return[e.createGraphic];if(e?.updateGraphics?.length)return e.updateGraphics.toArray();const{formViewModel:t}=this;if(X(t)&&t.feature)return[t.feature];if(re(t)){if(t.activeFeature)return[t.activeFeature];if(t.features.length)return t.features.toArray()}return[]}};e([W()],Me.prototype,"_defaultSelectionManager",void 0),e([W()],Me.prototype,"_featureTemplatesLayersAndTables",null),e([W()],Me.prototype,"_queuedSelectionTool",void 0),e([W()],Me.prototype,"_snappingManager",void 0),e([W()],Me.prototype,"_selectionSources",null),e([W()],Me.prototype,"activeFeatureCount",null),e([W({readOnly:!0})],Me.prototype,"activeWorkflow",void 0),e([W()],Me.prototype,"activeLeafWorkflow",null),e([W({readOnly:!0})],Me.prototype,"_activityQueue",void 0),e([W({readOnly:!0})],Me.prototype,"canCreate",null),e([W()],Me.prototype,"canCreateVisible",null),e([W({readOnly:!0})],Me.prototype,"canUpdate",null),e([W()],Me.prototype,"canUpdateVisible",null),e([W()],Me.prototype,"featureTemplatesLayers",null),e([W()],Me.prototype,"editorItems",void 0),e([W()],Me.prototype,"editorItemsLayerMap",void 0),e([W()],Me.prototype,"effectiveSelectionManager",null),e([W({readOnly:!0})],Me.prototype,"failures",void 0),e([W()],Me.prototype,"hideTemplatesForInactiveLayers",void 0),e([W({type:G})],Me.prototype,"attachmentsViewModel",void 0),e([W()],Me.prototype,"featureFormViewModel",null),e([W()],Me.prototype,"formViewModel",null),e([W()],Me.prototype,"utilityNetworkAssociationAddAssociationViewModel",null),e([W({type:we})],Me.prototype,"featureTemplatesViewModel",void 0),e([W({type:O})],Me.prototype,"labelOptions",null),e([W()],Me.prototype,"layerInfos",void 0),e([W()],Me.prototype,"useLegacyCreateTools",null),e([W()],Me.prototype,"isUsingLegacyCreateTools",null),e([W()],Me.prototype,"ownSketchViewModel",void 0),e([W()],Me.prototype,"selectionListViewModel",void 0),e([W()],Me.prototype,"selectionManager",void 0),e([W()],Me.prototype,"selectionToolbarViewModel",void 0),e([W()],Me.prototype,"sketchOptions",void 0),e([W()],Me.prototype,"sketchViewModel",null),e([W({type:q,nonNullable:!0})],Me.prototype,"snappingOptions",void 0),e([W()],Me.prototype,"spinnerViewModel",void 0),e([W()],Me.prototype,"state",null),e([W({readOnly:!0})],Me.prototype,"syncing",null),e([W()],Me.prototype,"syncViewSelection",void 0),e([W()],Me.prototype,"updating",null),e([W({type:P})],Me.prototype,"tooltipOptions",null),e([W({type:R})],Me.prototype,"valueOptions",null),e([W()],Me.prototype,"view",null),e([W()],Me.prototype,"canZoomTo",null),e([W()],Me.prototype,"pageStack",void 0),e([W()],Me.prototype,"showDiscardEditsPrompt",void 0),e([W()],Me.prototype,"showConfirmationPrompt",void 0),e([W()],Me.prototype,"_candidateCommitted",void 0),e([W()],Me.prototype,"page",null),e([W()],Me.prototype,"featureFormDisabled",null),e([W()],Me.prototype,"featureFormHasAssociation",null),e([W()],Me.prototype,"canGoBack",null),e([W()],Me.prototype,"shouldShowDeleteButton",null),e([W()],Me.prototype,"hasPendingEdits",null),e([W()],Me.prototype,"snappingManager",null),Me=e([M("esri.widgets.Editor.EditorViewModel")],Me);const Te=Me;export{Te as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as i,handlesGroup as r,destroyHandle as a}from"../../core/handleUtils.js";import{destroyMaybe as o}from"../../core/maybe.js";import{on as s,whenOnce as n,watch as l,initial as d}from"../../core/reactiveUtils.js";import{property as h,subclass as m}from"../../core/accessorSupport/decorators.js";import u from"../../layers/GraphicsLayer.js";import c from"../../views/draw/support/HighlightHelper.js";import{temporaryHighlightName as p}from"../../views/support/HighlightDefaults.js";import w from"./Edits.js";import f from"./MergeFeaturesWorkflowData.js";import y from"./Workflow.js";import{updateGraphicSymbolWhenRequired as g,makeMinimalAttributes as F}from"./workflowUtils.js";import{assertViewNot3D as v,assertMergeWorkflowCapabilities as _,assertMinimumFeatureCount as M,assertFeaturesAreFromSameLayer as k,InvalidKeyFeatureError as V}from"./support/errors.js";import{mergeFeatures as b}from"./support/mergeFeaturesUtils.js";import j from"../FeatureForm/FeatureFormViewModel.js";var H;const I=Symbol();let A=H=class extends y{constructor(e){super(e),this.type="merge-features",this._formViewModel=null,this._graphicsLayer=null,this._highlightHelper=null,this._webStyleCache=new Map}initialize(){const e=this.data.viewModel.view;this._highlightHelper=e?new c({view:e}):null,this._initializeFeatureFormViewModel(),this._initializeGraphicsLayer(),this._createAndInitializeEdits(this.data.keyFeature)}destroy(){const e=this._graphicsLayer,{view:t}=this.data.viewModel;t?.destroyed||t?.map.remove(e),this._graphicsLayer=o(this._graphicsLayer),this._formViewModel?.destroy(),this._highlightHelper?.destroy()}get formViewModel(){return this._formViewModel}get hasPendingEdits(){return!1}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get shouldShowAttachments(){return this.data.editorItem.capabilities.attachments.enabled}static async create(e){const{applyEdits:t,applyEditsFeatureService:i,...r}=e,{editorItem:a,features:o}=r;if(v(r.viewModel,"merge-features"),_(a),M(o,2),k(o),r.keyFeature&&!o.includes(r.keyFeature))throw new V;const s=await b(o),n=new H({data:new f({...r,mergedGeometry:s}),onCommit:L(t)});return n._set("steps",S()),n}async enter(){this._configureAttachmentsViewModel()}exit(){}isKeyFeature(e){return this.data.keyFeature===e}isTemporaryHighlightFeature(e){return this.data.temporaryHighlightFeature===e}async setKeyFeature(e){const{data:t}=this;if(e!==t.keyFeature){if(!t.features.includes(e))throw new V;t.keyFeature=e,await this._createAndInitializeEdits(e)}}async start(){return await super.start(),this._makeSketchController()}getFeatureTitle(e){return this.data.getFeatureTitle(e)}async _createAndInitializeEdits(e){const{data:t}=this,i=e.clone();i.geometry=t.mergedGeometry;const r=new w({feature:i});t.edits=r;const a=t.getInitialFeature(e)||e;r.trackChanges(a),await this._setFeatureOnFormViewModel(i,a),this._setFeatureOnAttachmentsViewModel(e)}_initializeFeatureFormViewModel(){const{data:e,_webStyleCache:t}=this,i=e.viewModel.view,r=new j({disabled:!0,editType:"UPDATE",formTemplate:e.editorItem.formTemplate,highlightHelper:this._highlightHelper,map:i?.map,spatialReference:i?.spatialReference,timeZone:e.timeZone});this._formViewModel=r,this.addHandles(s(()=>r,"value-change",({feature:r,fieldName:a,value:o})=>{const s=e.edits;r&&s&&(s.setAttribute(a,o),g(r,t,i?.scale))}))}_initializeGraphicsLayer(){const{data:e}=this,{view:t}=e.viewModel,i=new u({elevationInfo:e.editorItem.layer.elevationInfo,internal:!0,listMode:"hide",title:"mergeFeaturesWorkflow-internal"});this._graphicsLayer=i,t?.map.add(i)}_makeSketchController(){return{enter:async()=>{this.addHandles(z(this.data),I)},exit:()=>{this.removeHandles(I)}}}async _setFeatureOnFormViewModel(e,t){const i=this._formViewModel;i.feature=e,i.overrideInitialFeature(t),await n(()=>!i.updating)}_configureAttachmentsViewModel(){const{data:e}=this,{keyFeature:t,viewModel:i}=e,{attachmentsViewModel:r}=i;r.set({capabilities:{editing:!1},graphic:t,filesEnabled:!1,mode:"view"})}_setFeatureOnAttachmentsViewModel(e){this.data.viewModel.attachmentsViewModel.graphic=e}};e([h()],A.prototype,"formViewModel",null),e([h()],A.prototype,"hasPendingEdits",null),e([h()],A.prototype,"layer",null),e([h()],A.prototype,"parent",null),e([h()],A.prototype,"shouldShowAttachments",null),e([h()],A.prototype,"type",void 0),e([h()],A.prototype,"_formViewModel",void 0),e([h()],A.prototype,"_graphicsLayer",void 0),e([h()],A.prototype,"_highlightHelper",void 0),A=H=e([m("esri.widgets.Editor.MergeFeaturesWorkflow")],A);const E=A;function S(){return[{id:"choosing-key-feature",async setUp(){},async tearDown(){}}]}function L(e){return async i=>{const{edits:r,keyFeature:a}=i,o=r?.feature?.cloneShallow(),s=i.editorItem.layer;if(!r||!o)throw new t("editing:missing-feature","Workflow data has no edits to submit.");r.attributesModified||(o.attributes=F(o,i.editorItem.layer));const n=[];for(const e of i.features){if(e===a)continue;const t=e.cloneShallow();t.attributes=F(t,s),t.geometry=null,n.push(t)}await e(s,{updateFeatures:[o],deleteFeatures:n})}}function z(e){const t=e.viewModel.view;if(!t)return i();const o=new c({view:t});for(const i of e.features)o.add(i);const s=new c({view:t,highlightName:p}),n=l(()=>e.keyFeature,e=>{s.removeAll(),s.add(e)},d),h=new c({view:t,highlightName:p}),m=l(()=>e.temporaryHighlightFeature,e=>{h.removeAll(),e&&h.add(e)});return r([a(o),n,a(s),m,a(h)])}export{E as default};
2
+ import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as i,handlesGroup as r,destroyHandle as a}from"../../core/handleUtils.js";import{destroyMaybe as o}from"../../core/maybe.js";import{on as s,whenOnce as n,watch as l,initial as d}from"../../core/reactiveUtils.js";import{property as h,subclass as m}from"../../core/accessorSupport/decorators.js";import u from"../../layers/GraphicsLayer.js";import{updateGraphicSymbolWhenRequired as p}from"../../views/draw/support/editingSessionUtils.js";import c from"../../views/draw/support/HighlightHelper.js";import{temporaryHighlightName as w}from"../../views/support/HighlightDefaults.js";import f from"./Edits.js";import y from"./MergeFeaturesWorkflowData.js";import g from"./Workflow.js";import{makeMinimalAttributes as F}from"./workflowUtils.js";import{assertViewNot3D as v,assertMergeWorkflowCapabilities as _,assertMinimumFeatureCount as M,assertFeaturesAreFromSameLayer as k,InvalidKeyFeatureError as V}from"./support/errors.js";import{mergeFeatures as j}from"./support/mergeFeaturesUtils.js";import b from"../FeatureForm/FeatureFormViewModel.js";var H;const I=Symbol();let A=H=class extends g{constructor(e){super(e),this.type="merge-features",this._formViewModel=null,this._graphicsLayer=null,this._highlightHelper=null,this._webStyleCache=new Map}initialize(){const e=this.data.viewModel.view;this._highlightHelper=e?new c({view:e}):null,this._initializeFeatureFormViewModel(),this._initializeGraphicsLayer(),this._createAndInitializeEdits(this.data.keyFeature)}destroy(){const e=this._graphicsLayer,{view:t}=this.data.viewModel;t?.destroyed||t?.map.remove(e),this._graphicsLayer=o(this._graphicsLayer),this._formViewModel?.destroy(),this._highlightHelper?.destroy()}get formViewModel(){return this._formViewModel}get hasPendingEdits(){return!1}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get shouldShowAttachments(){return this.data.editorItem.capabilities.attachments.enabled}static async create(e){const{applyEdits:t,applyEditsFeatureService:i,...r}=e,{editorItem:a,features:o}=r;if(v(r.viewModel,"merge-features"),_(a),M(o,2),k(o),r.keyFeature&&!o.includes(r.keyFeature))throw new V;const s=await j(o),n=new H({data:new y({...r,mergedGeometry:s}),onCommit:L(t)});return n._set("steps",S()),n}async enter(){this._configureAttachmentsViewModel()}exit(){}isKeyFeature(e){return this.data.keyFeature===e}isTemporaryHighlightFeature(e){return this.data.temporaryHighlightFeature===e}async setKeyFeature(e){const{data:t}=this;if(e!==t.keyFeature){if(!t.features.includes(e))throw new V;t.keyFeature=e,await this._createAndInitializeEdits(e)}}async start(){return await super.start(),this._makeSketchController()}getFeatureTitle(e){return this.data.getFeatureTitle(e)}async _createAndInitializeEdits(e){const{data:t}=this,i=e.clone();i.geometry=t.mergedGeometry;const r=new f({feature:i});t.edits=r;const a=t.getInitialFeature(e)||e;r.trackChanges(a),await this._setFeatureOnFormViewModel(i,a),this._setFeatureOnAttachmentsViewModel(e)}_initializeFeatureFormViewModel(){const{data:e,_webStyleCache:t}=this,i=e.viewModel.view,r=new b({disabled:!0,editType:"UPDATE",formTemplate:e.editorItem.formTemplate,highlightHelper:this._highlightHelper,map:i?.map,spatialReference:i?.spatialReference,timeZone:e.timeZone});this._formViewModel=r,this.addHandles(s(()=>r,"value-change",({feature:r,fieldName:a,value:o})=>{const s=e.edits;r&&s&&(s.setAttribute(a,o),p(r,t,i?.scale))}))}_initializeGraphicsLayer(){const{data:e}=this,{view:t}=e.viewModel,i=new u({elevationInfo:e.editorItem.layer.elevationInfo,internal:!0,listMode:"hide",title:"mergeFeaturesWorkflow-internal"});this._graphicsLayer=i,t?.map.add(i)}_makeSketchController(){return{enter:async()=>{this.addHandles(z(this.data),I)},exit:()=>{this.removeHandles(I)}}}async _setFeatureOnFormViewModel(e,t){const i=this._formViewModel;i.feature=e,i.overrideInitialFeature(t),await n(()=>!i.updating)}_configureAttachmentsViewModel(){const{data:e}=this,{keyFeature:t,viewModel:i}=e,{attachmentsViewModel:r}=i;r.set({capabilities:{editing:!1},graphic:t,filesEnabled:!1,mode:"view"})}_setFeatureOnAttachmentsViewModel(e){this.data.viewModel.attachmentsViewModel.graphic=e}};e([h()],A.prototype,"formViewModel",null),e([h()],A.prototype,"hasPendingEdits",null),e([h()],A.prototype,"layer",null),e([h()],A.prototype,"parent",null),e([h()],A.prototype,"shouldShowAttachments",null),e([h()],A.prototype,"type",void 0),e([h()],A.prototype,"_formViewModel",void 0),e([h()],A.prototype,"_graphicsLayer",void 0),e([h()],A.prototype,"_highlightHelper",void 0),A=H=e([m("esri.widgets.Editor.MergeFeaturesWorkflow")],A);const E=A;function S(){return[{id:"choosing-key-feature",async setUp(){},async tearDown(){}}]}function L(e){return async i=>{const{edits:r,keyFeature:a}=i,o=r?.feature?.cloneShallow(),s=i.editorItem.layer;if(!r||!o)throw new t("editing:missing-feature","Workflow data has no edits to submit.");r.attributesModified||(o.attributes=F(o,i.editorItem.layer));const n=[];for(const e of i.features){if(e===a)continue;const t=e.cloneShallow();t.attributes=F(t,s),t.geometry=null,n.push(t)}await e(s,{updateFeatures:[o],deleteFeatures:n})}}function z(e){const t=e.viewModel.view;if(!t)return i();const o=new c({view:t});for(const i of e.features)o.add(i);const s=new c({view:t,highlightName:w}),n=l(()=>e.keyFeature,e=>{s.removeAll(),s.add(e)},d),h=new c({view:t,highlightName:w}),m=l(()=>e.temporaryHighlightFeature,e=>{h.removeAll(),e&&h.add(e)});return r([a(o),n,a(s),m,a(h)])}export{E as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as i,handlesGroup as r,destroyHandle as a}from"../../core/handleUtils.js";import"../../core/has.js";import{destroyMaybe as o}from"../../core/maybe.js";import{debounce as s}from"../../core/promiseUtils.js";import{watch as n,on as l,whenOnce as p,initial as d}from"../../core/reactiveUtils.js";import{property as u,subclass as c}from"../../core/accessorSupport/decorators.js";import h from"../../layers/GraphicsLayer.js";import{getDrawHelpMessage as m}from"../../views/draw/support/helpMessageUtils.js";import y from"../../views/draw/support/HighlightHelper.js";import w from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as g}from"../../views/support/HighlightDefaults.js";import f from"./Edits.js";import v from"./SplitFeatureWorkflowData.js";import _ from"./Workflow.js";import{activeSketchToolDrawsUnsupportedCurve as F,containsUnsupportedCurve as M,createWorkflowSteps as b,swapForEditingSession as S,updateGraphicSymbolWhenRequired as k,makeMinimalAttributes as T}from"./workflowUtils.js";import{assertViewNot3D as I,assertSplitWorkflowCapabilities as V}from"./support/errors.js";import{getCompatibleSpitterGeometryType as E,ensureSplittableGeometry as G,makeNewFeatureAttributes as H,splitGeometry as C,canSplitByPoint as j,isSplitterGeometry as x}from"./support/splitFeatureUtils.js";import U from"../FeatureForm/FeatureFormViewModel.js";import L from"../Sketch/SketchViewModel.js";import{getDrawToolGeometryTypeFromCreateTool as W}from"../Sketch/support/sketchUtils.js";var O;const P=Symbol(),z=Symbol();let A=O=class extends _{constructor(e){super(e),this.defaultSplitterGeometryType=null,this.type="split-feature",this._activeFeature=null,this._formViewModel=null,this._graphicsLayer=null,this._highlightHelper=null,this._lastSplitterGeometryWasInvalid=!1,this._sketchViewModel=null,this._webStyleCache=new Map}initialize(){const e=this.data.viewModel.view;this._highlightHelper=e?new y({view:e,highlightName:g}):null,this._initializeFormViewModel();const t=this._initializeGraphicsLayer();this._initializeSketchViewModel(t)}destroy(){const e=this._graphicsLayer,{view:t}=this.data.viewModel;t?.destroyed||t?.map.remove(e),this._graphicsLayer=o(this._graphicsLayer),this._formViewModel.destroy(),this._sketchViewModel.destroy(),this._highlightHelper?.destroy()}get activeFeature(){return this._activeFeature}get allowSave(){const{data:e}=this;return null!=e.existingFeatureEdits&&null!=e.newFeatureEdits&&!this.updating}get availableCreateTools(){const e=["polyline","polygon","rectangle","circle","freehandPolyline","freehandPolygon"];switch(this.data.editorItem.layer.geometryType){case"polygon":case"multipoint":return e;case"polyline":return["point",...e];default:return[]}}get formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return!!this.data.editorItem?.hasInvalidFormTemplate}get hasPreviousStep(){return null!==this._activeFeature||this._stepIndex>0}get helpMessage(){const{activeCreateToolDrawMode:e,activeTool:t,createGraphic:i,drawTool:r,isUsingLegacyCreateTools:a}=this._sketchViewModel;if(!a)return r?.helpMessageKey??"noTool";const o=W(t);return"mesh"!==o?m(o,i?.geometry,e):void 0}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get sketchUpdateOptions(){return{enableScaling:!this.curveResizeDisabled,multipleSelectionEnabled:!1}}get updating(){return this._updatingHandles.updating||this._formViewModel.updating||this._sketchViewModel.updating}get noticeMessage(){return this._splittingMayIntroduceCurves&&F(this._sketchViewModel,this.data.editorItem)?"curveToolDensifyWarning":this._lastSplitterGeometryWasInvalid?"invalidSplitterGeometry":void 0}get _splittingMayIntroduceCurves(){return"polygon"===this.data.editorItem.layer.geometryType}async back(e){return this.activeFeature?await this.setActiveFeature(null):await super.back(e)}static create(e){const{applyEdits:i,applyEditsFeatureService:r,defaultSplitterGeometryType:a,startAt:o,...s}=e;if(I(e.viewModel,"split-feature"),V(s.editorItem),"reviewing-features"===o){if(!s.splitterGeometry)throw new t("editing:split-geometry-required","Must provide the split geometry to start at the 'reviewing-features' step.");const e=E(G(s.feature.geometry),s.splitterGeometry.type);if(s.splitterGeometry.type!==e)throw new t("editing:incompatible-split-geometries",`Geometry of type '${s.splitterGeometry.type}' cannot be used to split geometry of type '${s.feature.geometry?.type}'.`)}const n=new O({data:new v(s),defaultSplitterGeometryType:a,onCommit:R(e.applyEdits)});return n._set("steps",O._createWorkflowSteps(n,o)),n}async enter(){}exit(){if("reviewing-features"!==this.stepId)throw new t("editing:invalid-exit-state","The SplitFeatureWorkflow can only be exited when in the 'reviewing-features' step.")}async setActiveFeature(e){const i=this._activeFeature;if(e===i)return;const r=this.data,a=i?r.getEditsForFeature(i):null;if(a&&(a.submittable=this._formViewModel.submittable),this._activeFeature=e,null==e)return;const o=this.data.getRoleForFeature(e);if(!o)throw new t("editing:unknown-feature","The provided feature is not part of this workflow.");await this._setFeatureOnFormViewModel(e,o)}async commit(e){const{newFeatureEdits:t,existingFeatureEdits:i,editorItem:r}=this.data,a=[i?.feature,t?.feature].filter(e=>!!e);if(e&&M(a,r)){if(!await e("curveEditingDensifyPrompt"))return this.reset()}return super.commit()}async start(){return await super.start(),this._makeSketchController()}async _createAndInitializeEdits({newPart:e,remainingPart:t}){const{data:i}=this,r=i.feature,a=this._formViewModel,o=r.clone();o.geometry=t;const s=new f({feature:o});i.existingFeatureEdits=s,s.trackChanges(i.initialFeature),await this._setFeatureOnFormViewModel(o,"existing"),s.submittable=a.submittable;const n=r.clone();n.geometry=e,n.attributes=H(r.attributes,i.editorItem.layer);const l=new f({feature:n});return i.newFeatureEdits=l,l.trackChanges(),await this._setFeatureOnFormViewModel(n,"new"),l.submittable=a.submittable,{featureToCreate:n,featureToUpdate:o}}static _createWorkflowSteps(e,i="drawing-splitter-geometry"){const{data:r}=e;return b(["drawing-splitter-geometry","reviewing-features"],i,{"drawing-splitter-geometry":()=>({id:"drawing-splitter-geometry",async setUp(){const i=G(r.feature.geometry),a=E(i,e.defaultSplitterGeometryType),{snappingManager:o}=r;j(i)&&o&&e.addHandles(N(o,e.layer));const s=e._sketchViewModel;e.addHandles([l(()=>s,"create",async i=>{if("start"===i.state&&e._lastSplitterGeometryWasInvalid&&(e._lastSplitterGeometryWasInvalid=!1),"complete"===i.state){e._graphicsLayer.removeAll();const o=i.graphic?.geometry;try{if(!x(o))throw new t("editing:invalid-split-geometry","The geometry produced by the Sketch operation cannot be used for splitting.");r.splitterGeometry=o,r.splitResult=await e._updatingHandles.addPromise(e._executeSplit(o)),await e.next()}catch(a){e._lastSplitterGeometryWasInvalid=!0,await s.create(i.tool)}}}),n(()=>s.activeTool,(t,i)=>{"point"===t&&!e.hasHandles(P)&&o?e.addHandles(Z(o,e.layer),P):"point"===i&&e.removeHandles(P)})],this.id),await s.create(a)},async tearDown(){e.removeHandles(this.id)}}),"reviewing-features":()=>({id:"reviewing-features",async setUp(){const i=r.splitterGeometry;if(!i)throw new t("editing:missing-splitter-geometry","The `splitterGeometry` property of the workflow's data must be set in order to start the 'reviewing-features' step.");const a=r.splitResult??await e._executeSplit(i),{featureToCreate:o,featureToUpdate:s}=await e._createAndInitializeEdits(a),n=await e._displayFeatureGraphics(s,o);e.addHandles(n,this.id)},async tearDown(){e.removeHandles(this.id)}})})}async _displayFeatureGraphics(e,t){const{data:a,_graphicsLayer:o}=this,l=a.viewModel.view,p=[];if(!e||!t||!l)return i();const d=s(i=>Promise.all([k(e,this._webStyleCache,i),k(t,this._webStyleCache,i)]));return await d("2d"===l.type?l.scale:null),"2d"===l.type&&p.push(n(()=>l.scale,e=>d(e))),o.add(t),p.push(i(()=>o.remove(t))),p.push(await S(o,l,a.feature,e)),r(p)}async _executeSplit(e){const{data:i}=this,{feature:r}=i,a=r.geometry;if(!a)throw new t("editing:feature-has-no-geometry","Cannot split the provided feature as it has no geometry.");const o=await C(a,e);if(!o||!o.newPart)throw new t("editing:split-failed","The split operation did not produce a valid result.");return o}_initializeFormViewModel(){const{data:e,_webStyleCache:t}=this,i=e.viewModel.view,r=new U({formTemplate:e.editorItem.formTemplate,highlightHelper:this._highlightHelper,map:i?.map,spatialReference:i?.spatialReference,timeZone:e.timeZone});this._formViewModel=r,this.addHandles(l(()=>r,"value-change",({feature:r,fieldName:a,value:o})=>{r&&(e.getEditsForFeature(r)?.setAttribute(a,o),k(r,t,i?.scale))}))}_initializeGraphicsLayer(){const{data:e}=this,{view:t}=e.viewModel,i=new h({elevationInfo:e.editorItem.layer.elevationInfo,internal:!0,listMode:"hide",title:"splitFeatureWorkflow-internal"});return this._graphicsLayer=i,t?.map.add(i),i}_initializeSketchViewModel(e){const{data:t}=this,{view:i}=t.viewModel;this._sketchViewModel=new L({layer:e,creationMode:"single",sketchOptions:t.sketchOptions,snappingManager:t.snappingManager,useLegacyCreateTools:t.viewModel.useLegacyCreateTools,updateOnGraphicClick:!1,defaultUpdateOptions:this.sketchUpdateOptions,view:i})}_makeSketchController(){return{enter:async()=>this.addHandles($(this)),exit:()=>this.removeHandles(z),viewModel:this._sketchViewModel}}async _setFeatureOnFormViewModel(e,t){const{data:i}=this,r=this._formViewModel;r.feature=e,"existing"===t?(r.editType="UPDATE",r.overrideInitialFeature(i.initialFeature)):r.editType="INSERT",await p(()=>!r.updating)}get test(){}};e([u()],A.prototype,"activeFeature",null),e([u()],A.prototype,"allowSave",null),e([u()],A.prototype,"availableCreateTools",null),e([u()],A.prototype,"defaultSplitterGeometryType",void 0),e([u()],A.prototype,"formViewModel",null),e([u()],A.prototype,"hasInvalidFormTemplate",null),e([u()],A.prototype,"hasPreviousStep",null),e([u()],A.prototype,"helpMessage",null),e([u()],A.prototype,"layer",null),e([u()],A.prototype,"parent",null),e([u()],A.prototype,"sketchUpdateOptions",null),e([u()],A.prototype,"type",void 0),e([u()],A.prototype,"updating",null),e([u()],A.prototype,"noticeMessage",null),e([u()],A.prototype,"_activeFeature",void 0),e([u()],A.prototype,"_formViewModel",void 0),e([u()],A.prototype,"_graphicsLayer",void 0),e([u()],A.prototype,"_highlightHelper",void 0),e([u()],A.prototype,"_lastSplitterGeometryWasInvalid",void 0),e([u()],A.prototype,"_sketchViewModel",void 0),e([u()],A.prototype,"_splittingMayIntroduceCurves",null),A=O=e([c("esri.widgets.Editor.SplitFeatureWorkflow")],A);const D=A;function R(e){return async i=>{const{existingFeatureEdits:r,newFeatureEdits:a}=i,o=r?.feature?.cloneShallow(),s=a?.feature?.cloneShallow(),n=i.editorItem.layer;if(null==o||null==s)throw new t("editing:missing-features","Expected both a feature to update and a feature to add for the split operation.");r?.attributesModified||(o.attributes=T(o,i.editorItem.layer)),await e(n,{addFeatures:[s],updateFeatures:[o]})}}function N(e,t){if(e.options.featureSources.some(e=>e.layer===t))return i();const r=new w({enabled:!1,layer:t});return e.options.featureSources.add(r),i(()=>{e.options.featureSources.remove(r),r.destroy()})}function Z(e,t){const{options:r}=e,a=r.enabled;r.enabled=!0;const o=r.featureEnabled;r.featureEnabled=!0;const s=r.distance;r.distance=15;const n=new Map;for(const i of r.featureSources)n.set(i,i.enabled),i.layer===t?i.enabled=!0:i.enabled=!1;return i(()=>{r.enabled=a,r.featureEnabled=o,r.distance=s;for(const[e,t]of n)e.enabled=t})}function $(e){const t=e.data,{feature:o,viewModel:s}=t,{view:l}=s;if(!l)return i();const p=new y({view:l}),u=n(()=>e.stepId,e=>{switch(p.removeAll(),e){case"drawing-splitter-geometry":p.add(o);break;case"reviewing-features":p.add(t.existingFeatureEdits?.feature),p.add(t.newFeatureEdits?.feature)}},d),c=new y({view:l,highlightName:g}),h=n(()=>t.temporaryHighlightFeature,(t,i)=>{i&&i!==e.activeFeature&&c.remove(i),t&&c.add(t)}),m=n(()=>e.activeFeature,(e,i)=>{i&&i!==t.temporaryHighlightFeature&&c.remove(i),e&&c.add(e)});return r([u,h,m,a(p),a(c)])}export{D as default};
2
+ import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as i,handlesGroup as r,destroyHandle as a}from"../../core/handleUtils.js";import"../../core/has.js";import{destroyMaybe as o}from"../../core/maybe.js";import{debounce as s}from"../../core/promiseUtils.js";import{watch as n,on as l,whenOnce as p,initial as d}from"../../core/reactiveUtils.js";import{property as u,subclass as c}from"../../core/accessorSupport/decorators.js";import h from"../../layers/GraphicsLayer.js";import{swapForEditingSession as m,updateGraphicSymbolWhenRequired as y}from"../../views/draw/support/editingSessionUtils.js";import{getDrawHelpMessage as w}from"../../views/draw/support/helpMessageUtils.js";import g from"../../views/draw/support/HighlightHelper.js";import f from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as v}from"../../views/support/HighlightDefaults.js";import _ from"./Edits.js";import F from"./SplitFeatureWorkflowData.js";import M from"./Workflow.js";import{activeSketchToolDrawsUnsupportedCurve as S,containsUnsupportedCurve as b,createWorkflowSteps as k,makeMinimalAttributes as T}from"./workflowUtils.js";import{assertViewNot3D as I,assertSplitWorkflowCapabilities as V}from"./support/errors.js";import{getCompatibleSpitterGeometryType as E,ensureSplittableGeometry as G,makeNewFeatureAttributes as H,splitGeometry as j,canSplitByPoint as C,isSplitterGeometry as x}from"./support/splitFeatureUtils.js";import U from"../FeatureForm/FeatureFormViewModel.js";import L from"../Sketch/SketchViewModel.js";import{getDrawToolGeometryTypeFromCreateTool as W}from"../Sketch/support/sketchUtils.js";var O;const P=Symbol(),z=Symbol();let A=O=class extends M{constructor(e){super(e),this.defaultSplitterGeometryType=null,this.type="split-feature",this._activeFeature=null,this._formViewModel=null,this._graphicsLayer=null,this._highlightHelper=null,this._lastSplitterGeometryWasInvalid=!1,this._sketchViewModel=null,this._webStyleCache=new Map}initialize(){const e=this.data.viewModel.view;this._highlightHelper=e?new g({view:e,highlightName:v}):null,this._initializeFormViewModel();const t=this._initializeGraphicsLayer();this._initializeSketchViewModel(t)}destroy(){const e=this._graphicsLayer,{view:t}=this.data.viewModel;t?.destroyed||t?.map.remove(e),this._graphicsLayer=o(this._graphicsLayer),this._formViewModel.destroy(),this._sketchViewModel.destroy(),this._highlightHelper?.destroy()}get activeFeature(){return this._activeFeature}get allowSave(){const{data:e}=this;return null!=e.existingFeatureEdits&&null!=e.newFeatureEdits&&!this.updating}get availableCreateTools(){const e=["polyline","polygon","rectangle","circle","freehandPolyline","freehandPolygon"];switch(this.data.editorItem.layer.geometryType){case"polygon":case"multipoint":return e;case"polyline":return["point",...e];default:return[]}}get formViewModel(){return this._formViewModel}get hasInvalidFormTemplate(){return!!this.data.editorItem?.hasInvalidFormTemplate}get hasPreviousStep(){return null!==this._activeFeature||this._stepIndex>0}get helpMessage(){const{activeCreateToolDrawMode:e,activeTool:t,createGraphic:i,drawTool:r,isUsingLegacyCreateTools:a}=this._sketchViewModel;if(!a)return r?.helpMessageKey??"noTool";const o=W(t);return"mesh"!==o?w(o,i?.geometry,e):void 0}get layer(){return this.data.editorItem.layer}get parent(){return this.data.parent}get sketchUpdateOptions(){return{enableScaling:!this.curveResizeDisabled,multipleSelectionEnabled:!1}}get updating(){return this._updatingHandles.updating||this._formViewModel.updating||this._sketchViewModel.updating}get noticeMessage(){return this._splittingMayIntroduceCurves&&S(this._sketchViewModel,this.data.editorItem)?"curveToolDensifyWarning":this._lastSplitterGeometryWasInvalid?"invalidSplitterGeometry":void 0}get _splittingMayIntroduceCurves(){return"polygon"===this.data.editorItem.layer.geometryType}async back(e){return this.activeFeature?await this.setActiveFeature(null):await super.back(e)}static create(e){const{applyEdits:i,applyEditsFeatureService:r,defaultSplitterGeometryType:a,startAt:o,...s}=e;if(I(e.viewModel,"split-feature"),V(s.editorItem),"reviewing-features"===o){if(!s.splitterGeometry)throw new t("editing:split-geometry-required","Must provide the split geometry to start at the 'reviewing-features' step.");const e=E(G(s.feature.geometry),s.splitterGeometry.type);if(s.splitterGeometry.type!==e)throw new t("editing:incompatible-split-geometries",`Geometry of type '${s.splitterGeometry.type}' cannot be used to split geometry of type '${s.feature.geometry?.type}'.`)}const n=new O({data:new F(s),defaultSplitterGeometryType:a,onCommit:R(e.applyEdits)});return n._set("steps",O._createWorkflowSteps(n,o)),n}async enter(){}exit(){if("reviewing-features"!==this.stepId)throw new t("editing:invalid-exit-state","The SplitFeatureWorkflow can only be exited when in the 'reviewing-features' step.")}async setActiveFeature(e){const i=this._activeFeature;if(e===i)return;const r=this.data,a=i?r.getEditsForFeature(i):null;if(a&&(a.submittable=this._formViewModel.submittable),this._activeFeature=e,null==e)return;const o=this.data.getRoleForFeature(e);if(!o)throw new t("editing:unknown-feature","The provided feature is not part of this workflow.");await this._setFeatureOnFormViewModel(e,o)}async commit(e){const{newFeatureEdits:t,existingFeatureEdits:i,editorItem:r}=this.data,a=[i?.feature,t?.feature].filter(e=>!!e);if(e&&b(a,r)){if(!await e("curveEditingDensifyPrompt"))return this.reset()}return super.commit()}async start(){return await super.start(),this._makeSketchController()}async _createAndInitializeEdits({newPart:e,remainingPart:t}){const{data:i}=this,r=i.feature,a=this._formViewModel,o=r.clone();o.geometry=t;const s=new _({feature:o});i.existingFeatureEdits=s,s.trackChanges(i.initialFeature),await this._setFeatureOnFormViewModel(o,"existing"),s.submittable=a.submittable;const n=r.clone();n.geometry=e,n.attributes=H(r.attributes,i.editorItem.layer);const l=new _({feature:n});return i.newFeatureEdits=l,l.trackChanges(),await this._setFeatureOnFormViewModel(n,"new"),l.submittable=a.submittable,{featureToCreate:n,featureToUpdate:o}}static _createWorkflowSteps(e,i="drawing-splitter-geometry"){const{data:r}=e;return k(["drawing-splitter-geometry","reviewing-features"],i,{"drawing-splitter-geometry":()=>({id:"drawing-splitter-geometry",async setUp(){const i=G(r.feature.geometry),a=E(i,e.defaultSplitterGeometryType),{snappingManager:o}=r;C(i)&&o&&e.addHandles(N(o,e.layer));const s=e._sketchViewModel;e.addHandles([l(()=>s,"create",async i=>{if("start"===i.state&&e._lastSplitterGeometryWasInvalid&&(e._lastSplitterGeometryWasInvalid=!1),"complete"===i.state){e._graphicsLayer.removeAll();const o=i.graphic?.geometry;try{if(!x(o))throw new t("editing:invalid-split-geometry","The geometry produced by the Sketch operation cannot be used for splitting.");r.splitterGeometry=o,r.splitResult=await e._updatingHandles.addPromise(e._executeSplit(o)),await e.next()}catch(a){e._lastSplitterGeometryWasInvalid=!0,await s.create(i.tool)}}}),n(()=>s.activeTool,(t,i)=>{"point"===t&&!e.hasHandles(P)&&o?e.addHandles(Z(o,e.layer),P):"point"===i&&e.removeHandles(P)})],this.id),await s.create(a)},async tearDown(){e.removeHandles(this.id)}}),"reviewing-features":()=>({id:"reviewing-features",async setUp(){const i=r.splitterGeometry;if(!i)throw new t("editing:missing-splitter-geometry","The `splitterGeometry` property of the workflow's data must be set in order to start the 'reviewing-features' step.");const a=r.splitResult??await e._executeSplit(i),{featureToCreate:o,featureToUpdate:s}=await e._createAndInitializeEdits(a),n=await e._displayFeatureGraphics(s,o);e.addHandles(n,this.id)},async tearDown(){e.removeHandles(this.id)}})})}async _displayFeatureGraphics(e,t){const{data:a,_graphicsLayer:o}=this,l=a.viewModel.view,p=[];if(!e||!t||!l)return i();const d=s(i=>Promise.all([y(e,this._webStyleCache,i),y(t,this._webStyleCache,i)]));return await d("2d"===l.type?l.scale:null),"2d"===l.type&&p.push(n(()=>l.scale,e=>d(e))),o.add(t),p.push(i(()=>o.remove(t))),p.push(await m(o,l,a.feature,e)),r(p)}async _executeSplit(e){const{data:i}=this,{feature:r}=i,a=r.geometry;if(!a)throw new t("editing:feature-has-no-geometry","Cannot split the provided feature as it has no geometry.");const o=await j(a,e);if(!o||!o.newPart)throw new t("editing:split-failed","The split operation did not produce a valid result.");return o}_initializeFormViewModel(){const{data:e,_webStyleCache:t}=this,i=e.viewModel.view,r=new U({formTemplate:e.editorItem.formTemplate,highlightHelper:this._highlightHelper,map:i?.map,spatialReference:i?.spatialReference,timeZone:e.timeZone});this._formViewModel=r,this.addHandles(l(()=>r,"value-change",({feature:r,fieldName:a,value:o})=>{r&&(e.getEditsForFeature(r)?.setAttribute(a,o),y(r,t,i?.scale))}))}_initializeGraphicsLayer(){const{data:e}=this,{view:t}=e.viewModel,i=new h({elevationInfo:e.editorItem.layer.elevationInfo,internal:!0,listMode:"hide",title:"splitFeatureWorkflow-internal"});return this._graphicsLayer=i,t?.map.add(i),i}_initializeSketchViewModel(e){const{data:t}=this,{view:i}=t.viewModel;this._sketchViewModel=new L({layer:e,creationMode:"single",sketchOptions:t.sketchOptions,snappingManager:t.snappingManager,useLegacyCreateTools:t.viewModel.useLegacyCreateTools,updateOnGraphicClick:!1,defaultUpdateOptions:this.sketchUpdateOptions,view:i})}_makeSketchController(){return{enter:async()=>this.addHandles($(this)),exit:()=>this.removeHandles(z),viewModel:this._sketchViewModel}}async _setFeatureOnFormViewModel(e,t){const{data:i}=this,r=this._formViewModel;r.feature=e,"existing"===t?(r.editType="UPDATE",r.overrideInitialFeature(i.initialFeature)):r.editType="INSERT",await p(()=>!r.updating)}get test(){}};e([u()],A.prototype,"activeFeature",null),e([u()],A.prototype,"allowSave",null),e([u()],A.prototype,"availableCreateTools",null),e([u()],A.prototype,"defaultSplitterGeometryType",void 0),e([u()],A.prototype,"formViewModel",null),e([u()],A.prototype,"hasInvalidFormTemplate",null),e([u()],A.prototype,"hasPreviousStep",null),e([u()],A.prototype,"helpMessage",null),e([u()],A.prototype,"layer",null),e([u()],A.prototype,"parent",null),e([u()],A.prototype,"sketchUpdateOptions",null),e([u()],A.prototype,"type",void 0),e([u()],A.prototype,"updating",null),e([u()],A.prototype,"noticeMessage",null),e([u()],A.prototype,"_activeFeature",void 0),e([u()],A.prototype,"_formViewModel",void 0),e([u()],A.prototype,"_graphicsLayer",void 0),e([u()],A.prototype,"_highlightHelper",void 0),e([u()],A.prototype,"_lastSplitterGeometryWasInvalid",void 0),e([u()],A.prototype,"_sketchViewModel",void 0),e([u()],A.prototype,"_splittingMayIntroduceCurves",null),A=O=e([c("esri.widgets.Editor.SplitFeatureWorkflow")],A);const D=A;function R(e){return async i=>{const{existingFeatureEdits:r,newFeatureEdits:a}=i,o=r?.feature?.cloneShallow(),s=a?.feature?.cloneShallow(),n=i.editorItem.layer;if(null==o||null==s)throw new t("editing:missing-features","Expected both a feature to update and a feature to add for the split operation.");r?.attributesModified||(o.attributes=T(o,i.editorItem.layer)),await e(n,{addFeatures:[s],updateFeatures:[o]})}}function N(e,t){if(e.options.featureSources.some(e=>e.layer===t))return i();const r=new f({enabled:!1,layer:t});return e.options.featureSources.add(r),i(()=>{e.options.featureSources.remove(r),r.destroy()})}function Z(e,t){const{options:r}=e,a=r.enabled;r.enabled=!0;const o=r.featureEnabled;r.featureEnabled=!0;const s=r.distance;r.distance=15;const n=new Map;for(const i of r.featureSources)n.set(i,i.enabled),i.layer===t?i.enabled=!0:i.enabled=!1;return i(()=>{r.enabled=a,r.featureEnabled=o,r.distance=s;for(const[e,t]of n)e.enabled=t})}function $(e){const t=e.data,{feature:o,viewModel:s}=t,{view:l}=s;if(!l)return i();const p=new g({view:l}),u=n(()=>e.stepId,e=>{switch(p.removeAll(),e){case"drawing-splitter-geometry":p.add(o);break;case"reviewing-features":p.add(t.existingFeatureEdits?.feature),p.add(t.newFeatureEdits?.feature)}},d),c=new g({view:l,highlightName:v}),h=n(()=>t.temporaryHighlightFeature,(t,i)=>{i&&i!==e.activeFeature&&c.remove(i),t&&c.add(t)}),m=n(()=>e.activeFeature,(e,i)=>{i&&i!==t.temporaryHighlightFeature&&c.remove(i),e&&c.add(e)});return r([u,h,m,a(p),a(c)])}export{D as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import"../../core/has.js";import{destroyMaybe as s}from"../../core/maybe.js";import{watch as a,sync as o}from"../../core/reactiveUtils.js";import{property as r,subclass as l}from"../../core/accessorSupport/decorators.js";import d from"../../layers/GraphicsLayer.js";import{isSceneLayer as h}from"../../layers/support/layerUtils.js";import{highlightsSupported as n}from"../../views/support/layerViewUtils.js";import c from"./UpdateFeatureWorkflowData.js";import{UpdateRecordWorkflow as p,handleKeys as u}from"./UpdateRecordWorkflow.js";import{getVisualVariableAttributes as w,setUpGeometryUpdate as y,syncUpdateOptions as m,updateGraphicSymbolWhenRequired as f,swapForEditingSession as k,cloneGraphicExceptMesh as g,canCreateInteractiveEditSession as _,isTerminalUpdateEventType as v}from"./workflowUtils.js";import V from"../Sketch/SketchViewModel.js";var b;const M={...u,highlights:Symbol(),sketchGraphics:Symbol(),sketchViewModel:Symbol(),waitingForTool:Symbol()};let S=b=class extends p{constructor(e){super(e),this.type="update-feature",this._layerViewEditSession=null,this._sketchGraphicClone=null,this._sketchLayer=null,this._sketchViewModel=null,this._webStyleCache=new Map}destroy(){this._layerViewEditSession?.rollback()}get curveResizeDisabled(){return this.data.curveResizeDisabled}get curveUpdatesDisabled(){return this.data.curveUpdatesDisabled}get sketchUpdateOptions(){const{capabilities:e,layer:t}=this.data.editorItem;return{enableScaling:!this.curveResizeDisabled,multipleSelectionEnabled:!1,reshapeOptions:{enableCreateCurveFromStraightEdge:!h(t)&&e.supportsTrueCurve}}}get supportsSplitFeatureWorkflow(){return this.data.supportsSplitFeatureWorkflow}get viewGraphic(){return this._sketchViewModel?this._sketchGraphicClone:this.data.edits.feature??this.fullFeature}getUpdating(){return!!this._sketchViewModel?.updating}async commit(){this.removeHandles(M.sketchGraphics);try{const e=this.data.edits.stagedForDelete;await super.commit();const t=this._layerViewEditSession;e?t?.rollback():t?.commit()}catch(e){throw await this._configureSketchViewModel(),new t("editor-workflow:failed-to-commit","An error occurred when sending the updates to the service",{error:e})}}async start(){return await super.start(),await this._initializeSketchViewModel()}_initializeFormViewModel(){super._initializeFormViewModel(),this.addHandles([this._formViewModel.on("value-change",e=>{this._layerViewEditSession?.setAttribute(e.fieldName,e.value)}),a(()=>this._formViewModel.feature?.sourceLayer,e=>this._sketchGraphicClone.sourceLayer=e)])}_configureHighlight(){const{edits:e,layerView:t}=this.data;n(t)&&this.addHandles(t.highlight(e.feature),M.highlights)}async _configureSketchViewModel(){const{_sketchLayer:e,_sketchViewModel:t}=this;if(!t||!e)return;const{data:i,_formViewModel:s,_sketchGraphicClone:a}=this,{edits:o,viewModel:r}=i,l=o.feature,{view:d}=r,h=w(l),n=await y({feature:l,featureClone:a,visualVariableAttributes:h,sketchLayer:e,sketchViewModel:t,getUpdateOptions:()=>this.sketchUpdateOptions,view:d,webStyleCache:this._webStyleCache,onUpdate:({geometry:e,attributes:t},i)=>{if(o.updateAttributes(t),o.updateGeometry(e),s.feature&&(s.feature.geometry=e),null!=h.rotation){const{field:e}=h.rotation;s.setValue(e,t[e])}if(null!=h.size){const{field:e}=h.size;s.setValue(e,t[e])}("undo"===i.type||"redo"===i.type||"update"===i.type&&null!=i.toolEventInfo&&v(i.toolEventInfo.type))&&s.notifyFeatureGeometryChanged()},addUpdatingPromise:e=>{this._updatingHandles.consumePromise(e)},addHandle:e=>{this.addHandles(e,M.waitingForTool)}});this.addHandles(n,M.sketchGraphics),t.addHandles(n)}async _initializeSketchViewModel(){const{data:e,_sketchGraphicClone:t}=this,{readOnly:r}=e,l=e.edits.feature,{capabilities:h,layer:n}=e.editorItem,c=e.viewModel.view;if(this.removeHandles([M.highlights,M.sketchGraphics,M.sketchViewModel,M.waitingForTool]),!h.update.geometry||r||this.curveUpdatesDisabled)return{enter:async()=>{this.hasHandles(M.highlights)||this._configureHighlight()},exit:()=>this.removeHandles([M.highlights])};const p=new d({elevationInfo:n.elevationInfo,internal:!0,listMode:"hide",title:"updateFeaturesWorkflow-internal"}),u=new V({allowDeleteKey:!1,layer:p,sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,useLegacyCreateTools:e.viewModel.useLegacyCreateTools,updateOnGraphicClick:!1,defaultUpdateOptions:this.sketchUpdateOptions,view:c});return this._sketchLayer=p,this._sketchViewModel=u,c?.map.add(p),await(c?.whenLayerView(p)),this.addHandles([i(()=>{c?.destroyed||c?.map.remove(p),p.destroyed||p.destroy(),this._sketchViewModel=s(u)}),a(()=>this.sketchUpdateOptions,e=>{u.defaultUpdateOptions=e,m(u,e)},o)],M.sketchViewModel),await f(t,this._webStyleCache,"2d"===c?.type?c.scale:null),this.addHandles([await k(p,c,l,t)]),{enter:async()=>{this.hasHandles(M.sketchGraphics)||await this._configureSketchViewModel()},exit:()=>this.removeHandles([M.sketchGraphics]),viewModel:u}}_onFullFeatureLoaded(e){super._onFullFeatureLoaded(e);const t=this._sketchGraphicClone=g(e),{edits:i,layerView:s}=this.data;i.updateGeometry(e.geometry),i.trackChanges(),_(s)&&(this._layerViewEditSession=s.createInteractiveEditSession(t))}static async create(e){const t=new b({data:await c.create(e),onCommit:this._onCommitFactory(e.applyEdits)});return t._set("steps",this._createWorkflowSteps(t)),t}get test(){}};e([r()],S.prototype,"curveResizeDisabled",null),e([r()],S.prototype,"curveUpdatesDisabled",null),e([r()],S.prototype,"sketchUpdateOptions",null),e([r()],S.prototype,"supportsSplitFeatureWorkflow",null),e([r()],S.prototype,"_layerViewEditSession",void 0),e([r()],S.prototype,"_sketchGraphicClone",void 0),e([r()],S.prototype,"_sketchLayer",void 0),e([r()],S.prototype,"_sketchViewModel",void 0),S=b=e([l("esri.widgets.Editor.UpdateFeatureWorkflow")],S);export{S as UpdateFeatureWorkflow,M as handleKeys};
2
+ import{__decorate as e}from"tslib";import t from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import"../../core/has.js";import{destroyMaybe as s}from"../../core/maybe.js";import{watch as a,sync as o}from"../../core/reactiveUtils.js";import{property as r,subclass as l}from"../../core/accessorSupport/decorators.js";import d from"../../layers/GraphicsLayer.js";import{isSceneLayer as h}from"../../layers/support/layerUtils.js";import{updateGraphicSymbolWhenRequired as n,swapForEditingSession as c}from"../../views/draw/support/editingSessionUtils.js";import{highlightsSupported as p}from"../../views/support/layerViewUtils.js";import u from"./UpdateFeatureWorkflowData.js";import{UpdateRecordWorkflow as w,handleKeys as y}from"./UpdateRecordWorkflow.js";import{getVisualVariableAttributes as m,setUpGeometryUpdate as f,syncUpdateOptions as k,cloneGraphicExceptMesh as g,canCreateInteractiveEditSession as _,isTerminalUpdateEventType as v}from"./workflowUtils.js";import V from"../Sketch/SketchViewModel.js";var S;const b={...y,highlights:Symbol(),sketchGraphics:Symbol(),sketchViewModel:Symbol(),waitingForTool:Symbol()};let M=S=class extends w{constructor(e){super(e),this.type="update-feature",this._layerViewEditSession=null,this._sketchGraphicClone=null,this._sketchLayer=null,this._sketchViewModel=null,this._webStyleCache=new Map}destroy(){this._layerViewEditSession?.rollback()}get curveResizeDisabled(){return this.data.curveResizeDisabled}get curveUpdatesDisabled(){return this.data.curveUpdatesDisabled}get sketchUpdateOptions(){const{capabilities:e,layer:t}=this.data.editorItem;return{enableScaling:!this.curveResizeDisabled,multipleSelectionEnabled:!1,reshapeOptions:{enableCreateCurveFromStraightEdge:!h(t)&&e.supportsTrueCurve}}}get supportsSplitFeatureWorkflow(){return this.data.supportsSplitFeatureWorkflow}get viewGraphic(){return this._sketchViewModel?this._sketchGraphicClone:this.data.edits.feature??this.fullFeature}getUpdating(){return!!this._sketchViewModel?.updating}async commit(){this.removeHandles(b.sketchGraphics);try{const e=this.data.edits.stagedForDelete;await super.commit();const t=this._layerViewEditSession;e?t?.rollback():t?.commit()}catch(e){throw await this._configureSketchViewModel(),new t("editor-workflow:failed-to-commit","An error occurred when sending the updates to the service",{error:e})}}async start(){return await super.start(),await this._initializeSketchViewModel()}_initializeFormViewModel(){super._initializeFormViewModel(),this.addHandles([this._formViewModel.on("value-change",e=>{this._layerViewEditSession?.setAttribute(e.fieldName,e.value)}),a(()=>this._formViewModel.feature?.sourceLayer,e=>this._sketchGraphicClone.sourceLayer=e)])}_configureHighlight(){const{edits:e,layerView:t}=this.data;p(t)&&this.addHandles(t.highlight(e.feature),b.highlights)}async _configureSketchViewModel(){const{_sketchLayer:e,_sketchViewModel:t}=this;if(!t||!e)return;const{data:i,_formViewModel:s,_sketchGraphicClone:a}=this,{edits:o,viewModel:r}=i,l=o.feature,{view:d}=r,h=m(l),n=await f({feature:l,featureClone:a,visualVariableAttributes:h,sketchLayer:e,sketchViewModel:t,getUpdateOptions:()=>this.sketchUpdateOptions,view:d,webStyleCache:this._webStyleCache,onUpdate:({geometry:e,attributes:t},i)=>{if(o.updateAttributes(t),o.updateGeometry(e),s.feature&&(s.feature.geometry=e),null!=h.rotation){const{field:e}=h.rotation;s.setValue(e,t[e])}if(null!=h.size){const{field:e}=h.size;s.setValue(e,t[e])}("undo"===i.type||"redo"===i.type||"update"===i.type&&null!=i.toolEventInfo&&v(i.toolEventInfo.type))&&s.notifyFeatureGeometryChanged()},addUpdatingPromise:e=>{this._updatingHandles.consumePromise(e)},addHandle:e=>{this.addHandles(e,b.waitingForTool)}});this.addHandles(n,b.sketchGraphics),t.addHandles(n)}async _initializeSketchViewModel(){const{data:e,_sketchGraphicClone:t}=this,{readOnly:r}=e,l=e.edits.feature,{capabilities:h,layer:p}=e.editorItem,u=e.viewModel.view;if(this.removeHandles([b.highlights,b.sketchGraphics,b.sketchViewModel,b.waitingForTool]),!h.update.geometry||r||this.curveUpdatesDisabled)return{enter:async()=>{this.hasHandles(b.highlights)||this._configureHighlight()},exit:()=>this.removeHandles([b.highlights])};const w=new d({elevationInfo:p.elevationInfo,internal:!0,listMode:"hide",title:"updateFeaturesWorkflow-internal"}),y=new V({allowDeleteKey:!1,layer:w,sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,useLegacyCreateTools:e.viewModel.useLegacyCreateTools,updateOnGraphicClick:!1,defaultUpdateOptions:this.sketchUpdateOptions,view:u});return this._sketchLayer=w,this._sketchViewModel=y,u?.map.add(w),await(u?.whenLayerView(w)),this.addHandles([i(()=>{u?.destroyed||u?.map.remove(w),w.destroyed||w.destroy(),this._sketchViewModel=s(y)}),a(()=>this.sketchUpdateOptions,e=>{y.defaultUpdateOptions=e,k(y,e)},o)],b.sketchViewModel),await n(t,this._webStyleCache,"2d"===u?.type?u.scale:null),this.addHandles([await c(w,u,l,t)]),{enter:async()=>{this.hasHandles(b.sketchGraphics)||await this._configureSketchViewModel()},exit:()=>this.removeHandles([b.sketchGraphics]),viewModel:y}}_onFullFeatureLoaded(e){super._onFullFeatureLoaded(e);const t=this._sketchGraphicClone=g(e),{edits:i,layerView:s}=this.data;i.updateGeometry(e.geometry),i.trackChanges(),_(s)&&(this._layerViewEditSession=s.createInteractiveEditSession(t))}static async create(e){const t=new S({data:await u.create(e),onCommit:this._onCommitFactory(e.applyEdits)});return t._set("steps",this._createWorkflowSteps(t)),t}get test(){}};e([r()],M.prototype,"curveResizeDisabled",null),e([r()],M.prototype,"curveUpdatesDisabled",null),e([r()],M.prototype,"sketchUpdateOptions",null),e([r()],M.prototype,"supportsSplitFeatureWorkflow",null),e([r()],M.prototype,"_layerViewEditSession",void 0),e([r()],M.prototype,"_sketchGraphicClone",void 0),e([r()],M.prototype,"_sketchLayer",void 0),e([r()],M.prototype,"_sketchViewModel",void 0),M=S=e([l("esri.widgets.Editor.UpdateFeatureWorkflow")],M);export{M as UpdateFeatureWorkflow,b as handleKeys};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import{isSome as t,unique as r}from"../../core/arrayUtils.js";import s from"../../core/Error.js";import{abortHandle as i}from"../../core/handleUtils.js";import{getOrCreateMapValue as o}from"../../core/MapUtils.js";import{EsriPromise as a}from"../../core/Promise.js";import{throwIfAborted as l,isAbortError as n}from"../../core/promiseUtils.js";import u from"../../core/ReactiveMap.js";import{property as p,subclass as f}from"../../core/accessorSupport/decorators.js";import{isCurvedGeometry as d}from"../../geometry/support/curves/curveUtils.js";import{isSubtypeSublayer as c}from"../../layers/support/layerUtils.js";import m from"./Edits.js";import{fetchFullFeaturesByObjectId as h}from"./workflowUtils.js";let y=class extends a{constructor(e){super(e),this.editorItems=[],this.featureInfos=null,this.parent=null,this.selectedFeature=null,this.sketchOptions=null,this.snappingManager=null,this.viewModel=null,this._editorItemsByLayer=new u,this._fullFeatures=new u,this._pendingEdits=new u}initialize(){const e=new AbortController;this.addResolvingPromise(this._initializeFullFeatures(e.signal).then(t=>{l(e.signal),this._initializeEdits(t)}).catch(e=>{if(n(e))throw new s("update-features-workflow:full-features-aborted","Fetching of full features was aborted.");throw e})),this.addHandles(i(e)),this._initializeEditorItemsByLayer()}get curveUpdatesDisabled(){return this.hasCurves&&this.editorItems.some(e=>!e.capabilities.supportsTrueCurveUpdate)}get features(){return this.fullFeatures}get fullFeatures(){return Array.from(this._fullFeatures.values())}get hasCurves(){return this.fullFeatures.some(e=>e.geometry&&d(e.geometry))}get initialFeatures(){return Array.from(this._pendingEdits.values()).map(e=>e.initialFeature).filter(t)}get layers(){const{featureInfos:e,features:s}=this;return e?.length?e.map(e=>e.layer):s.length?r(s.map(e=>e.sourceLayer).filter(t)):[]}set timeZone(e){this._set("timeZone",e),this._pendingEdits.forEach(t=>{t.timeZone=e})}getEditorItemForLayer(e){return this._editorItemsByLayer.get(e)}getFeatureTitle(e){return this._pendingEdits.get(e)?.displayTitle}getPendingEditsForFeature(e){const t=e.getObjectId();if(null!=t)return this._pendingEdits.get(this._fullFeatures.get(t)??e)}isSubmittable(e){const t=this._pendingEdits.get(e);return!!t&&(t.submittable||t.isAssociation)}stageDelete(){for(const e of this._pendingEdits.values())e.stageDelete()}_initializeEditorItemsByLayer(){for(const e of this.editorItems)this._editorItemsByLayer.set(e.layer,e)}_initializeEdits(e){const{timeZone:t}=this;for(const r of e){const e=new m({feature:r,timeZone:t});e.trackChanges(),this._pendingEdits.set(r,e)}}async _initializeFullFeatures(e){const{_fullFeatures:t,featureInfos:r,features:i,viewModel:a}=this,{spatialReference:l}=a.view,n=new Map;if(r?.length)for(const{layer:s,objectIds:o}of r)n.set(c(s)?s.parent:s,o);else if(i.length)for(const s of i){const e=s.getObjectId();if(null!=e){const t=s.sourceLayer??s.layer,r=c(t)?t.parent:t;o(n,r,()=>[]).push(e)}}const u=Array.from(n.entries()).map(async([r,i])=>{const o=await h(i,r,l,e);if(o.length!==i.length)throw new s("editor:update-features-workflow:fetch-full-features-incomplete","Failed to fetch full features for one or more of the provided features.");const a=r.objectIdField,n=(e,t)=>e.attributes[a]>t.attributes[a]?1:-1,u=i.sort((e,t)=>e-t),p=o.sort(n);for(let e=0;e<u.length;e++)t.set(u[e],p[e]);return o});return(await Promise.all(u)).flat()}};e([p()],y.prototype,"curveUpdatesDisabled",null),e([p({constructOnly:!0})],y.prototype,"editorItems",void 0),e([p({constructOnly:!0})],y.prototype,"featureInfos",void 0),e([p()],y.prototype,"features",null),e([p()],y.prototype,"fullFeatures",null),e([p()],y.prototype,"hasCurves",null),e([p()],y.prototype,"initialFeatures",null),e([p()],y.prototype,"layers",null),e([p()],y.prototype,"parent",void 0),e([p()],y.prototype,"selectedFeature",void 0),e([p({constructOnly:!0})],y.prototype,"sketchOptions",void 0),e([p()],y.prototype,"snappingManager",void 0),e([p()],y.prototype,"timeZone",null),e([p()],y.prototype,"viewModel",void 0),e([p()],y.prototype,"_fullFeatures",void 0),y=e([f("esri.widgets.Editor.UpdateFeaturesWorkflowData")],y);const g=y;export{g as default};
2
+ import{__decorate as e}from"tslib";import{isSome as t,unique as r}from"../../core/arrayUtils.js";import s from"../../core/Error.js";import{abortHandle as i}from"../../core/handleUtils.js";import{getOrCreateMapValue as o}from"../../core/MapUtils.js";import{EsriPromise as a}from"../../core/Promise.js";import{throwIfAborted as l,isAbortError as n}from"../../core/promiseUtils.js";import u from"../../core/ReactiveMap.js";import{property as p,subclass as f}from"../../core/accessorSupport/decorators.js";import{isCurvedGeometry as d}from"../../geometry/support/curves/curveUtils.js";import{isSubtypeSublayer as c}from"../../layers/support/layerUtils.js";import{fetchFullFeaturesByObjectId as m}from"../../views/draw/support/editingSessionUtils.js";import h from"./Edits.js";let y=class extends a{constructor(e){super(e),this.editorItems=[],this.featureInfos=null,this.parent=null,this.selectedFeature=null,this.sketchOptions=null,this.snappingManager=null,this.viewModel=null,this._editorItemsByLayer=new u,this._fullFeatures=new u,this._pendingEdits=new u}initialize(){const e=new AbortController;this.addResolvingPromise(this._initializeFullFeatures(e.signal).then(t=>{l(e.signal),this._initializeEdits(t)}).catch(e=>{if(n(e))throw new s("update-features-workflow:full-features-aborted","Fetching of full features was aborted.");throw e})),this.addHandles(i(e)),this._initializeEditorItemsByLayer()}get curveUpdatesDisabled(){return this.hasCurves&&this.editorItems.some(e=>!e.capabilities.supportsTrueCurveUpdate)}get features(){return this.fullFeatures}get fullFeatures(){return Array.from(this._fullFeatures.values())}get hasCurves(){return this.fullFeatures.some(e=>e.geometry&&d(e.geometry))}get initialFeatures(){return Array.from(this._pendingEdits.values()).map(e=>e.initialFeature).filter(t)}get layers(){const{featureInfos:e,features:s}=this;return e?.length?e.map(e=>e.layer):s.length?r(s.map(e=>e.sourceLayer).filter(t)):[]}set timeZone(e){this._set("timeZone",e),this._pendingEdits.forEach(t=>{t.timeZone=e})}getEditorItemForLayer(e){return this._editorItemsByLayer.get(e)}getFeatureTitle(e){return this._pendingEdits.get(e)?.displayTitle}getPendingEditsForFeature(e){const t=e.getObjectId();if(null!=t)return this._pendingEdits.get(this._fullFeatures.get(t)??e)}isSubmittable(e){const t=this._pendingEdits.get(e);return!!t&&(t.submittable||t.isAssociation)}stageDelete(){for(const e of this._pendingEdits.values())e.stageDelete()}_initializeEditorItemsByLayer(){for(const e of this.editorItems)this._editorItemsByLayer.set(e.layer,e)}_initializeEdits(e){const{timeZone:t}=this;for(const r of e){const e=new h({feature:r,timeZone:t});e.trackChanges(),this._pendingEdits.set(r,e)}}async _initializeFullFeatures(e){const{_fullFeatures:t,featureInfos:r,features:i,viewModel:a}=this,{spatialReference:l}=a.view,n=new Map;if(r?.length)for(const{layer:s,objectIds:o}of r)n.set(c(s)?s.parent:s,o);else if(i.length)for(const s of i){const e=s.getObjectId();if(null!=e){const t=s.sourceLayer??s.layer,r=c(t)?t.parent:t;o(n,r,()=>[]).push(e)}}const u=Array.from(n.entries()).map(async([r,i])=>{const o=await m(i,r,l,e);if(o.length!==i.length)throw new s("editor:update-features-workflow:fetch-full-features-incomplete","Failed to fetch full features for one or more of the provided features.");const a=r.objectIdField,n=(e,t)=>e.attributes[a]>t.attributes[a]?1:-1,u=i.sort((e,t)=>e-t),p=o.sort(n);for(let e=0;e<u.length;e++)t.set(u[e],p[e]);return o});return(await Promise.all(u)).flat()}};e([p()],y.prototype,"curveUpdatesDisabled",null),e([p({constructOnly:!0})],y.prototype,"editorItems",void 0),e([p({constructOnly:!0})],y.prototype,"featureInfos",void 0),e([p()],y.prototype,"features",null),e([p()],y.prototype,"fullFeatures",null),e([p()],y.prototype,"hasCurves",null),e([p()],y.prototype,"initialFeatures",null),e([p()],y.prototype,"layers",null),e([p()],y.prototype,"parent",void 0),e([p()],y.prototype,"selectedFeature",void 0),e([p({constructOnly:!0})],y.prototype,"sketchOptions",void 0),e([p()],y.prototype,"snappingManager",void 0),e([p()],y.prototype,"timeZone",null),e([p()],y.prototype,"viewModel",void 0),e([p()],y.prototype,"_fullFeatures",void 0),y=e([f("esri.widgets.Editor.UpdateFeaturesWorkflowData")],y);const g=y;export{g as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.1/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{isSome as i}from"../../../core/arrayUtils.js";import{abortHandle as s}from"../../../core/handleUtils.js";import{debounce as a}from"../../../core/promiseUtils.js";import o from"../../../core/ReactiveMap.js";import{whenOnce as r,watch as n}from"../../../core/reactiveUtils.js";import{property as l,subclass as p}from"../../../core/accessorSupport/decorators.js";import{UpdatingHandles as c}from"../../../core/support/UpdatingHandles.js";import d from"../../../layers/GraphicsLayer.js";import{isSceneLayer as u}from"../../../layers/support/layerUtils.js";import h from"../../../views/interactive/sketch/SketchOptions.js";import{getVisualVariablesForLayer as y,updateGraphicSymbolWhenRequired as m,setVisualVariablesAndElevationInfoForUpdate as v,swapForEditingSession as g,visualVariableInteractiveUpdate as f,getSizeVariableAttribute as _,getRotationVariableAttribute as b}from"../workflowUtils.js";import w from"../../Sketch/SketchViewModel.js";const k=Symbol();let U=class extends t{constructor(e){super(e),this.features=[],this.onGeometriesUpdated=()=>{},this.onVisualVariableAttributesUpdated=()=>{},this.sketchOptions=new h,this.snappingManager=null,this.sourceLayer=null,this.view=null,this.viewModel=null,this.useLegacyCreateTools=!1,this._nextUpdateSubset=[],this._sketchGraphicsMap=new o,this._sketchLayer=null,this._updatingHandles=new c,this._visualVariableAttributes=new Map,this._visualVariablesForLayer=null,this._webStyleCache=new Map}async initialize(){this._visualVariablesForLayer=y(this.sourceLayer),this._nextUpdateSubset=this.features,this._initializeSketchGraphics(),this._initializeSketchLayer(),await this._updatingHandles.addPromise(this._initializeSketchViewModel())}destroy(){const{_sketchLayer:e,view:t}=this;t?.destroyed||t?.map.remove(e),this._updatingHandles.destroy(),e.destroy(),this.viewModel.destroy()}get defaultUpdateOptions(){const e=this.sourceLayer;return{multipleSelectionEnabled:!1,reshapeOptions:{enableCreateCurveFromStraightEdge:!u(e)&&e.capabilities?.data.supportsTrueCurve}}}set defaultUpdateOptions(e){this._set("defaultUpdateOptions",e)}get sketchGraphics(){return Array.from(this._sketchGraphicsMap.values())}get updating(){return this._updatingHandles.updating}async enter(){await this.startUpdatingFeatures(this._nextUpdateSubset)}async exit(){this._completeCurrentOperation()}notifyAttributesChanged({features:e,fieldName:t}){const i=this._webStyleCache,s=this.view.scale,a=this._updatingHandles;for(const o of e){const e=this._sketchGraphicsMap.get(o),r=o.getAttribute(t);if(!e||e.getAttribute(t)===r)continue;e.setAttribute(t,r);const n=this._visualVariableAttributes.get(o);null==n?.size||n.size.isUpdatingInteractively||n.size.field!==t||n.size.setInitialValue(r),null==n?.rotation||n.rotation.isUpdatingInteractively||n.rotation.field!==t||n.rotation.setInitialValue(r),a.consumePromise(m(e,i,s))}}async startUpdatingFeatures(e){const{onGeometriesUpdated:t,onVisualVariableAttributesUpdated:a,_sketchGraphicsMap:o,_sketchLayer:n,sourceLayer:l,view:p,viewModel:c,_webStyleCache:d}=this,u=e.map(e=>o.get(e)).filter(i),h={...this.defaultUpdateOptions};this._completeCurrentOperation();let y=null;if(1===e.length){const t=e[0],i=this._visualVariableAttributes.get(t);!(!i?.rotation&&!i?.size)&&(await v({graphic:u[0],sketchLayer:n,sketchViewModel:c,sourceLayer:l,visualVariables:i,webStyleCache:d}),"point"===l.geometryType&&(h.enableRotation=null!=i.rotation,h.enableScaling=null!=i.size,y=async e=>{const s=e.graphics[0];f(p,s,e,i)&&(a?.([{feature:t,attributes:s.attributes}],e),this._updatingHandles.consumePromise(m(s,d,"2d"===p.type?p.scale:null)))}))}else h.tool="move";const g=()=>c.update(u,h),_=c.on("update",a=>{if("complete"===a.state){if(null===p.activeTool)return void g();const e=new AbortController,t=s(e);return this.addHandles(t,k),void this._updatingHandles.consumePromise(r(()=>null===p.activeTool,e.signal).then(async()=>{e.signal.aborted||(e.abort(),await g())}))}const n=e.map(e=>{const t=o.get(e);return t?{feature:e,geometry:t.geometry}:null}).filter(i);t(n,a),y?.(a)});await g(),this._nextUpdateSubset=this.features,this.addHandles(_,k),c.addHandles(_)}_completeCurrentOperation(){this.removeHandles(k),this.viewModel.complete()}_initializeSketchGraphics(){const{features:e,_sketchGraphicsMap:t,sourceLayer:i,_visualVariableAttributes:s}=this,a=this._visualVariablesForLayer,o=a.rotation?.field,r=a.size?.field,n={rotation:o?i.getField(o):null,size:r?i.getField(r):null},l=!(!n.rotation&&!n.size);for(const p of e)t.set(p,p.clone()),l&&s.set(p,L(a,n))}_initializeSketchLayer(){const{view:e}=this,t=new d({elevationInfo:this.sourceLayer.elevationInfo,internal:!0,listMode:"hide",title:"SketchController layer"});this._sketchLayer=t,e.map.add(t),this._updatingHandles.consumePromise(e.whenLayerView(t))}async _initializeSketchViewModel(){const{defaultUpdateOptions:e,sketchOptions:t,snappingManager:i,useLegacyCreateTools:s,view:o,_sketchGraphicsMap:r,_sketchLayer:l,_webStyleCache:p}=this,c=Array.from(r.entries()),d=new w({allowDeleteKey:!1,defaultUpdateOptions:e,layer:l,sketchOptions:t,snappingManager:i,useLegacyCreateTools:s,updateOnGraphicClick:!1,view:o});this.viewModel=d;const u=a(e=>Promise.all(c.map(([,t])=>m(t,p,e))));await u("2d"===o.type?o.scale:null),"2d"===o.type&&this.addHandles(n(()=>o.scale,e=>u(e))),this.addHandles(await Promise.all(c.map(([e,t])=>g(l,o,e,t))))}};function L({rotation:e,size:t},i){return{rotation:e?b(e,i.rotation):null,size:t?_(t,i.size):null}}e([l()],U.prototype,"defaultUpdateOptions",null),e([l()],U.prototype,"features",void 0),e([l()],U.prototype,"onGeometriesUpdated",void 0),e([l()],U.prototype,"onVisualVariableAttributesUpdated",void 0),e([l()],U.prototype,"sketchGraphics",null),e([l()],U.prototype,"sketchOptions",void 0),e([l()],U.prototype,"snappingManager",void 0),e([l()],U.prototype,"sourceLayer",void 0),e([l()],U.prototype,"updating",null),e([l()],U.prototype,"view",void 0),e([l()],U.prototype,"viewModel",void 0),e([l()],U.prototype,"useLegacyCreateTools",void 0),e([l()],U.prototype,"_nextUpdateSubset",void 0),e([l()],U.prototype,"_sketchGraphicsMap",void 0),e([l()],U.prototype,"_sketchLayer",void 0),e([l()],U.prototype,"_visualVariablesForLayer",void 0),U=e([p("esri.widgets.Editor.support.SketchController")],U);export{U as SketchController};
2
+ import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import{isSome as i}from"../../../core/arrayUtils.js";import{abortHandle as s}from"../../../core/handleUtils.js";import{debounce as a}from"../../../core/promiseUtils.js";import o from"../../../core/ReactiveMap.js";import{whenOnce as r,watch as n}from"../../../core/reactiveUtils.js";import{property as l,subclass as p}from"../../../core/accessorSupport/decorators.js";import{UpdatingHandles as c}from"../../../core/support/UpdatingHandles.js";import d from"../../../layers/GraphicsLayer.js";import{isSceneLayer as u}from"../../../layers/support/layerUtils.js";import{updateGraphicSymbolWhenRequired as h,swapForEditingSession as y}from"../../../views/draw/support/editingSessionUtils.js";import m from"../../../views/interactive/sketch/SketchOptions.js";import{getVisualVariablesForLayer as v,setVisualVariablesAndElevationInfoForUpdate as g,visualVariableInteractiveUpdate as f,getSizeVariableAttribute as _,getRotationVariableAttribute as w}from"../workflowUtils.js";import b from"../../Sketch/SketchViewModel.js";const k=Symbol();let U=class extends t{constructor(e){super(e),this.features=[],this.onGeometriesUpdated=()=>{},this.onVisualVariableAttributesUpdated=()=>{},this.sketchOptions=new m,this.snappingManager=null,this.sourceLayer=null,this.view=null,this.viewModel=null,this.useLegacyCreateTools=!1,this._nextUpdateSubset=[],this._sketchGraphicsMap=new o,this._sketchLayer=null,this._updatingHandles=new c,this._visualVariableAttributes=new Map,this._visualVariablesForLayer=null,this._webStyleCache=new Map}async initialize(){this._visualVariablesForLayer=v(this.sourceLayer),this._nextUpdateSubset=this.features,this._initializeSketchGraphics(),this._initializeSketchLayer(),await this._updatingHandles.addPromise(this._initializeSketchViewModel())}destroy(){const{_sketchLayer:e,view:t}=this;t?.destroyed||t?.map.remove(e),this._updatingHandles.destroy(),e.destroy(),this.viewModel.destroy()}get defaultUpdateOptions(){const e=this.sourceLayer;return{multipleSelectionEnabled:!1,reshapeOptions:{enableCreateCurveFromStraightEdge:!u(e)&&e.capabilities?.data.supportsTrueCurve}}}set defaultUpdateOptions(e){this._set("defaultUpdateOptions",e)}get sketchGraphics(){return Array.from(this._sketchGraphicsMap.values())}get updating(){return this._updatingHandles.updating}async enter(){await this.startUpdatingFeatures(this._nextUpdateSubset)}async exit(){this._completeCurrentOperation()}notifyAttributesChanged({features:e,fieldName:t}){const i=this._webStyleCache,s=this.view.scale,a=this._updatingHandles;for(const o of e){const e=this._sketchGraphicsMap.get(o),r=o.getAttribute(t);if(!e||e.getAttribute(t)===r)continue;e.setAttribute(t,r);const n=this._visualVariableAttributes.get(o);null==n?.size||n.size.isUpdatingInteractively||n.size.field!==t||n.size.setInitialValue(r),null==n?.rotation||n.rotation.isUpdatingInteractively||n.rotation.field!==t||n.rotation.setInitialValue(r),a.consumePromise(h(e,i,s))}}async startUpdatingFeatures(e){const{onGeometriesUpdated:t,onVisualVariableAttributesUpdated:a,_sketchGraphicsMap:o,_sketchLayer:n,sourceLayer:l,view:p,viewModel:c,_webStyleCache:d}=this,u=e.map(e=>o.get(e)).filter(i),y={...this.defaultUpdateOptions};this._completeCurrentOperation();let m=null;if(1===e.length){const t=e[0],i=this._visualVariableAttributes.get(t);!(!i?.rotation&&!i?.size)&&(await g({graphic:u[0],sketchLayer:n,sketchViewModel:c,sourceLayer:l,visualVariables:i,webStyleCache:d}),"point"===l.geometryType&&(y.enableRotation=null!=i.rotation,y.enableScaling=null!=i.size,m=async e=>{const s=e.graphics[0];f(p,s,e,i)&&(a?.([{feature:t,attributes:s.attributes}],e),this._updatingHandles.consumePromise(h(s,d,"2d"===p.type?p.scale:null)))}))}else y.tool="move";const v=()=>c.update(u,y),_=c.on("update",a=>{if("complete"===a.state){if(null===p.activeTool)return void v();const e=new AbortController,t=s(e);return this.addHandles(t,k),void this._updatingHandles.consumePromise(r(()=>null===p.activeTool,e.signal).then(async()=>{e.signal.aborted||(e.abort(),await v())}))}const n=e.map(e=>{const t=o.get(e);return t?{feature:e,geometry:t.geometry}:null}).filter(i);t(n,a),m?.(a)});await v(),this._nextUpdateSubset=this.features,this.addHandles(_,k),c.addHandles(_)}_completeCurrentOperation(){this.removeHandles(k),this.viewModel.complete()}_initializeSketchGraphics(){const{features:e,_sketchGraphicsMap:t,sourceLayer:i,_visualVariableAttributes:s}=this,a=this._visualVariablesForLayer,o=a.rotation?.field,r=a.size?.field,n={rotation:o?i.getField(o):null,size:r?i.getField(r):null},l=!(!n.rotation&&!n.size);for(const p of e)t.set(p,p.clone()),l&&s.set(p,L(a,n))}_initializeSketchLayer(){const{view:e}=this,t=new d({elevationInfo:this.sourceLayer.elevationInfo,internal:!0,listMode:"hide",title:"SketchController layer"});this._sketchLayer=t,e.map.add(t),this._updatingHandles.consumePromise(e.whenLayerView(t))}async _initializeSketchViewModel(){const{defaultUpdateOptions:e,sketchOptions:t,snappingManager:i,useLegacyCreateTools:s,view:o,_sketchGraphicsMap:r,_sketchLayer:l,_webStyleCache:p}=this,c=Array.from(r.entries()),d=new b({allowDeleteKey:!1,defaultUpdateOptions:e,layer:l,sketchOptions:t,snappingManager:i,useLegacyCreateTools:s,updateOnGraphicClick:!1,view:o});this.viewModel=d;const u=a(e=>Promise.all(c.map(([,t])=>h(t,p,e))));await u("2d"===o.type?o.scale:null),"2d"===o.type&&this.addHandles(n(()=>o.scale,e=>u(e))),this.addHandles(await Promise.all(c.map(([e,t])=>y(l,o,e,t))))}};function L({rotation:e,size:t},i){return{rotation:e?w(e,i.rotation):null,size:t?_(t,i.size):null}}e([l()],U.prototype,"defaultUpdateOptions",null),e([l()],U.prototype,"features",void 0),e([l()],U.prototype,"onGeometriesUpdated",void 0),e([l()],U.prototype,"onVisualVariableAttributesUpdated",void 0),e([l()],U.prototype,"sketchGraphics",null),e([l()],U.prototype,"sketchOptions",void 0),e([l()],U.prototype,"snappingManager",void 0),e([l()],U.prototype,"sourceLayer",void 0),e([l()],U.prototype,"updating",null),e([l()],U.prototype,"view",void 0),e([l()],U.prototype,"viewModel",void 0),e([l()],U.prototype,"useLegacyCreateTools",void 0),e([l()],U.prototype,"_nextUpdateSubset",void 0),e([l()],U.prototype,"_sketchGraphicsMap",void 0),e([l()],U.prototype,"_sketchLayer",void 0),e([l()],U.prototype,"_visualVariablesForLayer",void 0),U=e([p("esri.widgets.Editor.support.SketchController")],U);export{U as SketchController};