@arcgis/core 4.27.0-rc.1 → 4.27.0-rc.3

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 (179) hide show
  1. package/README.md +2 -2
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{a8565d1c676f3bfbcebb.js → 002fe1ec63ea33e6972d.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{0610691a0c0d9fbbd6d2.js → 013de5c2955801b329b3.js} +1 -1
  5. package/assets/esri/core/workers/chunks/07163dcbb871f927a580.js +1 -0
  6. package/assets/esri/core/workers/chunks/0e46687004392c493c06.js +1 -0
  7. package/assets/esri/core/workers/chunks/0e65e00173b66c7fec2e.js +1 -0
  8. package/assets/esri/core/workers/chunks/1aa8dd317ecd3c41e0ea.js +1 -0
  9. package/assets/esri/core/workers/chunks/21328f3dd26abe84a10d.js +1 -0
  10. package/assets/esri/core/workers/chunks/28c67c98039503b62e6e.js +1 -0
  11. package/assets/esri/core/workers/chunks/2faa8f08f2fdaac3f4af.js +1 -0
  12. package/assets/esri/core/workers/chunks/{0407bf97ad621c89a734.js → 3160af63b860b52db389.js} +1 -1
  13. package/assets/esri/core/workers/chunks/3767b9e7660873b018c2.js +1 -0
  14. package/assets/esri/core/workers/chunks/39ae4b9b766f674bc6f2.js +1 -0
  15. package/assets/esri/core/workers/chunks/45629ff775e77234b227.js +1 -0
  16. package/assets/esri/core/workers/chunks/471f6eba213412b82840.js +1 -0
  17. package/assets/esri/core/workers/chunks/4a4f14a3d8da270059c4.js +1 -0
  18. package/assets/esri/core/workers/chunks/{3e239bfad611985e50fb.js → 50f910797c17c3028521.js} +1 -1
  19. package/assets/esri/core/workers/chunks/{f339db2b599fa9585283.js → 5e6471dd2a08e66b47d0.js} +79 -81
  20. package/assets/esri/core/workers/chunks/642c5a93c0a454bdd115.js +1 -0
  21. package/assets/esri/core/workers/chunks/{14145959a3dab1437818.js → 6627f1bc9ee6b620e3aa.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{170bdbdb4e21bf91a17f.js → 6eaa7a51efde2dd4a5a4.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{d8bd3f498b3fa8153404.js → 6f510f28526c73ab453c.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{2bdc63395c7466ce1641.js → 7053c2f5a958d4c8629b.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{4c35c663528f710e8c78.js → 79cb672c85ea29e8484a.js} +1 -1
  26. package/assets/esri/core/workers/chunks/82939ead43848a13f765.js +1 -0
  27. package/assets/esri/core/workers/chunks/83e3d104886b48f00397.js +1 -0
  28. package/assets/esri/core/workers/chunks/89001ee8d3f69fa03cc1.js +1 -0
  29. package/assets/esri/core/workers/chunks/8b6b963230df56850580.js +1 -0
  30. package/assets/esri/core/workers/chunks/9472184ef1432fc55d6b.js +1 -0
  31. package/assets/esri/core/workers/chunks/{3c5a64a545272f148e93.js → 9621b7d8d951aa881686.js} +1 -1
  32. package/assets/esri/core/workers/chunks/a6ddf80eb324c35076e1.js +1 -0
  33. package/assets/esri/core/workers/chunks/a80a6267d88246ede5d3.js +1 -0
  34. package/assets/esri/core/workers/chunks/{b6e173eddaad4244cb5f.js → b31974524932e638df8c.js} +1 -1
  35. package/assets/esri/core/workers/chunks/{f505ebd4bd3bfb6c790d.js → b6a55fdfe16795ebf02c.js} +1 -1
  36. package/assets/esri/core/workers/chunks/bf9e1fde9f6b2b4f10c0.js +1 -0
  37. package/assets/esri/core/workers/chunks/cfa3b2b1e184681e9af4.js +1 -0
  38. package/assets/esri/core/workers/chunks/{92e7f224a80195e606d6.js → d4ba894a2583f3930a4f.js} +1 -1
  39. package/assets/esri/core/workers/chunks/d5dfd3d693d5e393a542.js +1 -0
  40. package/assets/esri/core/workers/chunks/dabd889e064c4e7807fa.js +1 -0
  41. package/assets/esri/core/workers/chunks/{74fd2059ddda9083cbcc.js → dc6c97a43d642eeaf477.js} +1 -1
  42. package/assets/esri/core/workers/chunks/{2154d395f405be3cd3ba.js → eca0c3d57b3a1e3a14ee.js} +1 -1
  43. package/assets/esri/core/workers/chunks/f35895e03c036d67b3ed.js +1 -0
  44. package/assets/esri/core/workers/chunks/f36697f6aac782007d1a.js +1 -0
  45. package/assets/esri/core/workers/chunks/f52054f27619a98b7bb7.js +1 -0
  46. package/assets/esri/core/workers/chunks/{c6efe2e04ea6a55bb6e3.js → f6e68befe2812b90b40d.js} +1 -1
  47. package/assets/esri/core/workers/chunks/fb7fe307a583b6a22218.js +1 -0
  48. package/assets/esri/core/workers/chunks/fbd3c78ee8e2219a6c7a.js +1 -0
  49. package/assets/esri/core/workers/chunks/ff42585e1b1d0c5497af.js +1 -0
  50. package/assets/esri/images/portal/livestreamvideolayer16.png +0 -0
  51. package/assets/esri/images/portal/{mediaservice16.png → videolayer16.png} +0 -0
  52. package/assets/esri/themes/base/widgets/_Feature.scss +4 -0
  53. package/assets/esri/themes/base/widgets/_FeatureContent.scss +9 -2
  54. package/assets/esri/themes/base/widgets/_FeatureForm.scss +19 -2
  55. package/assets/esri/themes/base/widgets/_ScaleRangeSlider.scss +1 -0
  56. package/assets/esri/themes/dark/main.css +1 -1
  57. package/assets/esri/themes/light/main.css +1 -1
  58. package/assets/esri/themes/light/view.css +1 -1
  59. package/chunks/DefaultMaterial.glsl.js +3 -2
  60. package/chunks/ShadowCastAccumulate.glsl.js +1 -1
  61. package/core/timeUtils.js +1 -1
  62. package/geometry/Mesh.js +1 -1
  63. package/geometry/support/DoubleArray.js +1 -1
  64. package/geometry/support/meshVertexSpaceUtils.js +5 -0
  65. package/interfaces.d.ts +263 -31
  66. package/kernel.js +1 -1
  67. package/layers/VideoLayer.js +1 -1
  68. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  69. package/layers/graphics/controllers/StreamController.js +1 -1
  70. package/layers/graphics/data/QueryEngine.js +1 -1
  71. package/layers/graphics/data/attributeSupport.js +1 -1
  72. package/layers/graphics/editingSupport.js +1 -1
  73. package/layers/graphics/sources/FeatureLayerSource.js +1 -1
  74. package/layers/support/editableLayers.js +1 -1
  75. package/layers/support/layerUtils.js +1 -1
  76. package/layers/video/VideoController.js +1 -1
  77. package/layers/video/videoUtils.js +5 -0
  78. package/package.json +1 -1
  79. package/portal/PortalItem.js +1 -1
  80. package/request.js +1 -1
  81. package/rest/support/meshFeatureSet.js +1 -1
  82. package/smartMapping/symbology/flow.js +1 -1
  83. package/statistics/utils.js +1 -1
  84. package/support/requestUtils.js +1 -1
  85. package/support/revision.js +1 -1
  86. package/symbols/cim/CIMSymbolHelper.js +1 -1
  87. package/views/2d/layers/StreamLayerView2D.js +1 -1
  88. package/views/2d/layers/features/sources/StreamSource.js +1 -1
  89. package/views/3d/environment/ChapmanAtmosphereTechnique.js +1 -1
  90. package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
  91. package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
  92. package/views/3d/layers/I3SMeshView3D.js +1 -1
  93. package/views/3d/layers/I3SMeshWorkerHandle.js +1 -1
  94. package/views/3d/layers/II3SMeshView3D.js +1 -1
  95. package/views/3d/layers/SceneLayerView3D.js +1 -1
  96. package/views/3d/layers/SceneLayerWorker.js +1 -1
  97. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  98. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  99. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  100. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  101. package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
  102. package/views/3d/layers/i3s/I3SOverrides.js +1 -1
  103. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  104. package/views/3d/webgl-engine/core/renderPasses/AllRenderPasses.js +1 -1
  105. package/views/3d/webgl-engine/core/shaderLibrary/Transform.glsl.js +3 -9
  106. package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +12 -9
  107. package/views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js +10 -10
  108. package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js +2 -2
  109. package/views/3d/webgl-engine/core/shaderLibrary/shading/WaterDistortion.glsl.js +2 -2
  110. package/views/3d/webgl-engine/core/shaderLibrary/terrain/TerrainTexture.glsl.js +8 -8
  111. package/views/3d/webgl-engine/core/shaderModules/Matrix4sDrawUniform.js +1 -1
  112. package/views/3d/webgl-engine/lib/ShadowHighlight.js +1 -1
  113. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  114. package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
  115. package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
  116. package/views/3d/webgl-engine/materials/pbrUtils.js +1 -1
  117. package/views/3d/webgl-engine/shaders/AtmosphereCompositingTechnique.js +1 -1
  118. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  119. package/views/3d/webgl-engine/shaders/ShadowHighlightTechnique.js +1 -1
  120. package/views/draw/DrawGraphicTool.js +1 -1
  121. package/views/layers/GroupLayerView.js +1 -1
  122. package/webmap/initialViewPropertiesUtils.js +1 -1
  123. package/widgets/Daylight/DaylightViewModel.js +1 -1
  124. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  125. package/widgets/Editor/CreateWorkflow.js +1 -1
  126. package/widgets/Editor/EditorViewModel.js +1 -1
  127. package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
  128. package/widgets/Editor/UpdateWorkflow.js +1 -1
  129. package/widgets/Editor/UpdateWorkflowData.js +1 -1
  130. package/widgets/Editor/Workflow.js +1 -1
  131. package/widgets/Editor/workflowUtils.js +1 -1
  132. package/widgets/Editor.js +1 -1
  133. package/widgets/Feature/FeatureRelationship/FeatureRelationshipViewModel.js +1 -1
  134. package/widgets/Feature/FeatureRelationship.js +1 -1
  135. package/widgets/Feature/support/featureUtils.js +1 -1
  136. package/widgets/FeatureForm/EditableInput.d.ts +2 -2
  137. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  138. package/widgets/FeatureForm/RelationshipInput.js +1 -1
  139. package/widgets/FeatureForm/css.js +1 -1
  140. package/widgets/FeatureForm.js +1 -1
  141. package/widgets/FeatureTable/FieldColumn.js +1 -1
  142. package/widgets/FeatureTemplates/FeatureTemplatesViewModel.js +1 -1
  143. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
  144. package/widgets/UtilityNetworkTrace/support/GeometryHandler.js +1 -1
  145. package/widgets/UtilityNetworkTrace/support/ResultAreaHandler.js +1 -1
  146. package/widgets/UtilityNetworkTrace.js +1 -1
  147. package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.d.ts +4 -0
  148. package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.js +1 -1
  149. package/widgets/UtilityNetworkValidateTopology.d.ts +4 -0
  150. package/widgets/UtilityNetworkValidateTopology.js +1 -1
  151. package/widgets/ValuePicker/ValuePickerBaseComponent.js +1 -1
  152. package/widgets/ValuePicker.js +1 -1
  153. package/widgets/support/geolocationUtils.js +1 -1
  154. package/assets/esri/core/workers/chunks/07651ef8348f702d59ac.js +0 -1
  155. package/assets/esri/core/workers/chunks/0a02ac5628d1739372c6.js +0 -1
  156. package/assets/esri/core/workers/chunks/0fcb8d408696075338e2.js +0 -1
  157. package/assets/esri/core/workers/chunks/16e459b16bdd6e1a821b.js +0 -1
  158. package/assets/esri/core/workers/chunks/1b8074269800b384ecf6.js +0 -1
  159. package/assets/esri/core/workers/chunks/39714837f9d3708e3806.js +0 -1
  160. package/assets/esri/core/workers/chunks/3ba2fcb9110230f8790c.js +0 -1
  161. package/assets/esri/core/workers/chunks/474d9b334812533bab36.js +0 -1
  162. package/assets/esri/core/workers/chunks/5576858f56314afcb4d5.js +0 -1
  163. package/assets/esri/core/workers/chunks/5706edf45402dff279a6.js +0 -1
  164. package/assets/esri/core/workers/chunks/659b7bad7281c0e2aed3.js +0 -1
  165. package/assets/esri/core/workers/chunks/785a6c925f29bc962992.js +0 -1
  166. package/assets/esri/core/workers/chunks/90da1ed112b82712d0ef.js +0 -1
  167. package/assets/esri/core/workers/chunks/9326120c750799eb2d28.js +0 -1
  168. package/assets/esri/core/workers/chunks/99e0cec47e3ef72c1de4.js +0 -1
  169. package/assets/esri/core/workers/chunks/9c0e1e87790424f42d7e.js +0 -1
  170. package/assets/esri/core/workers/chunks/9e66af3b1c70cf25fb32.js +0 -1
  171. package/assets/esri/core/workers/chunks/a1c31bb8c12831539328.js +0 -1
  172. package/assets/esri/core/workers/chunks/b0cda39b53ecd6c44cd0.js +0 -1
  173. package/assets/esri/core/workers/chunks/b5fc6f2044ed047c5afd.js +0 -1
  174. package/assets/esri/core/workers/chunks/c08e03165043df67c11b.js +0 -1
  175. package/assets/esri/core/workers/chunks/c26148d4bfab3b3dfab2.js +0 -1
  176. package/assets/esri/core/workers/chunks/d6b6bb8aecc85d2a3f6b.js +0 -1
  177. package/assets/esri/core/workers/chunks/eeaf8010e38b65a101ac.js +0 -1
  178. package/assets/esri/core/workers/chunks/f235392c56063fbf89c6.js +0 -1
  179. package/assets/esri/core/workers/chunks/fdd0d3616c97e408b104.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import{HandleOwner as i}from"../../core/HandleOwner.js";import{makeHandle as e}from"../../core/handleUtils.js";import{applySome as s,removeMaybe as n}from"../../core/maybe.js";import{when as l,initial as a,watch as o,on as r,syncAndInitial as h}from"../../core/reactiveUtils.js";import{schedule as g}from"../../core/scheduling.js";import{truncateLocalTime as d,resetUTCDate as p,offsetDate as u}from"../../core/timeUtils.js";import{property as c}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import m from"../../views/SceneView.js";import _ from"../../views/3d/environment/SunLighting.js";import f from"../../views/3d/environment/VirtualLighting.js";import{positionToTimezoneInfo as w}from"../../views/3d/support/earthUtils.js";import{dateTimeToSliderPos as S,sliderPosToDateTime as D,getSeasonFromDate as T,getNorthernHemisphereSeason as U,getSeasonDate as v,Hemisphere as P,calculatePlaySpeed as L}from"./support/daylightUtils.js";import{SliderWithDropdownViewModel as b}from"./support/SliderWithDropdownViewModel.js";import O from"../support/DatePickerViewModel.js";import{formatSliderLabel as E,getSunriseAndSunsetTimes as C}from"../support/timeWidgetUtils.js";let M=class extends i{constructor(t){super(t),this.view=null,this.datePickerViewModel=new O,this.timeSliderViewModel=new b({min:0,max:1439,values:[0],labelFormatFunction:E,inputFormatFunction:E}),this.lightingUpdateInterval=200,this._oldLighting=null,this.playSpeedMultiplier=1,this._lastTime=null,this._sunrise=null,this._sunset=null,this._cachedLightingDateUTC=new Date(0),this._cachedDisplayUTCOffset=0,this._firstInteraction=!0,this._lastLightingUpdate=0,this._lightingUpdateHandle=null}initialize(){this.handles.add([l((()=>this.view),(t=>t.when((()=>this._updateLighting()))),a),o((()=>s(this._lighting,(t=>"virtual"!==t.type?t.date:null))),(t=>this._scheduleLightingUpdate(t))),r((()=>this._lighting),"timezone-will-change",(t=>this._timezoneWillChange(t)),{onListenerAdd:()=>this._timezoneWillChange(null)}),o((()=>!0===s(this.view,(t=>t.stationary))),(()=>{(this.dayPlaying||this.yearPlaying)&&this._updateSunriseAndSunset()}),a),o((()=>{const t=this.timeSliderViewModel;return{vm:t,state:t.state,sliderPosition:this.timeSliderPosition}}),(({vm:t,state:i,sliderPosition:e})=>{"ready"===i&&t.setValue(0,e)})),o((()=>this.timeSliderViewModel?.utcOffset),(t=>{null!=t&&(this.utcOffset=t)})),o((()=>({utcOffset:this.utcOffset,sliderViewModel:this.timeSliderViewModel})),(({utcOffset:t,sliderViewModel:i})=>{i&&(i.utcOffset=t)}),h),o((()=>this.timeSliderViewModel.timezonePickerOpen),(()=>this.stopPlaying())),o((()=>this.timeSliderViewModel.values),(t=>this._setTimeSliderPosition(t?.[0]??0,{forceLightingUpdate:!1}))),o((()=>this.datePickerViewModel.value),(t=>{this.dayPlaying=!1,this.localDate=t})),o((()=>this.localDate),(t=>{this.datePickerViewModel.value.valueOf()!==t.getTime()&&this.datePickerViewModel.set("value",t)}))])}destroy(){this._cancelLightingUpdate(),this.view=null}get isSupported(){return null==this.view||"3d"===this.view.type}get utcOffset(){return this._cachedDisplayUTCOffset}set utcOffset(t){t!==this.utcOffset&&null!=this._lighting&&"virtual"!==this._lighting.type&&(this._lighting.displayUTCOffset=t,this._updateLighting())}get localDate(){return d(this._lightingDateDisplay)}set localDate(t){t.getTime()!==this.localDate.getTime()&&(this._lightingDateDisplay=p(this._lightingDateDisplay,t))}get timeSliderPosition(){return S(this._lightingDateDisplay)}set timeSliderPosition(t){this._setTimeSliderPosition(t,{forceLightingUpdate:!0})}_setTimeSliderPosition(t,i){Math.abs(t-this.timeSliderPosition)<=1/60||(this.stopPlaying(),this._enableDirectShadowsIfFirstInteraction(),i.forceLightingUpdate&&(this._cancelLightingUpdate(),this._updateLighting()),this._lightingDateDisplay=D(this._lightingDateDisplay,t))}_timezoneFromCamera(t,i){if(null==i||!t.cameraTrackingEnabled)return 0;const e=w([i.longitude,i.latitude]);return null==e?0:Math.round(e.hours+e.minutes/60+e.seconds/3600)}get directShadowsEnabled(){return s(this._lighting,(t=>t.directShadowsEnabled))??!1}set directShadowsEnabled(t){s(this._lighting,(i=>{i.directShadowsEnabled=t}))}get sunLightingEnabled(){return"sun"===this._lightingType}set sunLightingEnabled(t){const i=this._environment;if(t===this._get("sunLightingEnabled")||null==i)return;const e=i.lighting,s=this._oldLighting;this._oldLighting=e;const n={directShadowsEnabled:e.directShadowsEnabled,cameraTrackingEnabled:e.cameraTrackingEnabled},l=t?"sun":"virtual";let a;a=null!=s&&s.type===l?s:t?new _:new f,a.set(n),i.lighting=a,t||(this.timeSliderViewModel.timezonePickerOpen=!1)}set playingState(t){this.playingState!==t&&this.sunLightingEnabled&&(this._set("playingState",t),"none"!==t&&(this._updateSunriseAndSunset(),this._lastTime=Date.now(),this._play(),this._enableDirectShadowsIfFirstInteraction()))}get dayPlaying(){return"day"===this.playingState}set dayPlaying(t){t?this.playingState="day":this.dayPlaying&&(this.playingState="none")}get yearPlaying(){return"year"===this.playingState}set yearPlaying(t){t?this.playingState="year":this.yearPlaying&&(this.playingState="none")}get currentSeason(){return T(this.localDate,this._currentHemisphere)}set currentSeason(t){this.stopPlaying();const i=U(t,this._currentHemisphere);this.localDate=v(this.localDate,i,P.NORTHERN)}get _currentHemisphere(){const t=s(this.view,(t=>t.camera?.position?.latitude));return null==t||t>=0?P.NORTHERN:P.SOUTHERN}get _environment(){return s(this.view,(t=>t.environment))}get _lighting(){return s(this._environment,(t=>t.lighting))}get _lightingType(){return s(this._lighting,(t=>t.type))}get _lightingDateDisplay(){return u(this._cachedLightingDateUTC,this._cachedDisplayUTCOffset,"hours")}set _lightingDateDisplay(t){const i=this._lighting;if(null==i||!this.sunLightingEnabled||"virtual"===i.type)return;const e=u(t,-this._cachedDisplayUTCOffset,"hours");e.getTime()!==i.date.getTime()&&(i.date=e,this._updateLighting())}stopPlaying(){this.playingState="none"}toggleDayPlaying(){this.dayPlaying=!this.dayPlaying}toggleYearPlaying(){this.yearPlaying=!this.yearPlaying}toggleSunLightingEnabled(){this.stopPlaying(),this.sunLightingEnabled=!this.sunLightingEnabled}toggleDirectShadowsEnabled(){this.stopPlaying(),this.directShadowsEnabled=!this.directShadowsEnabled}_enableDirectShadowsIfFirstInteraction(){this._firstInteraction&&(this._firstInteraction=!1,this.directShadowsEnabled=!0)}_updateLighting(t){const i=Date.now();this._lastLightingUpdate=i;const{view:e}=this,s=this._lighting;if(null==e||null==s||"virtual"===s.type)return;const n=t||s.date,l=s.displayUTCOffset,a=null!==l?l:this._timezoneFromCamera(s,e.camera?.position);this._cachedLightingDateUTC.getTime()!==n.getTime()&&(this._cachedLightingDateUTC=new Date(n.getTime())),this._cachedDisplayUTCOffset!==a&&(this._cachedDisplayUTCOffset=a)}_timezoneWillChange(t){const i=this._lighting;if(null==i||"virtual"===i.type||!i.cameraTrackingEnabled)return;let e;if(t)e=t.timezoneOffset;else{if(null!=i.displayUTCOffset)return;e=_.calculateTimezoneOffset(i.positionTimezoneInfo)}i.displayUTCOffset=e,this._scheduleLightingUpdate()}_scheduleLightingUpdate(t){if(t&&(this._lightingUpdateHandle=n(this._lightingUpdateHandle)),this._lightingUpdateHandle)return;const i=Date.now()-this._lastLightingUpdate,s=this.lightingUpdateInterval-i;let l=null;const a=()=>{this._updateLighting(t),this._lightingUpdateHandle===l&&(this._lightingUpdateHandle=null)};if(s<=0)this._lightingUpdateHandle=l=g(a);else{const t=setTimeout(a,s);this._lightingUpdateHandle=l=e((()=>clearTimeout(t)))}}_cancelLightingUpdate(){this._lightingUpdateHandle=n(this._lightingUpdateHandle)}_play(){const t=this._lighting;if(null!=t&&this.sunLightingEnabled&&"virtual"!==t.type&&(this.dayPlaying||this.yearPlaying)){const i=Date.now()-(this._lastTime??0);if(this.dayPlaying){this._lastTime=Date.now();const e=L(this._sunrise,this._sunset,t.date)*this.playSpeedMultiplier/100*i;if(e>0){let i=new Date(t.date.getTime()+e);const s=t.displayUTCOffset??0;if(((i.getUTCHours()+s)%24+24)%24<((t.date.getUTCHours()+s)%24+24)%24){const s=864e5;i=new Date(t.date.getTime()+e-s)}t.date=i}}else{if(i>1e3){this._lastTime=Date.now();const i=(t.date.getUTCMonth()+1)%12,e=new Date(t.date.getTime());e.setUTCMonth(i),t.date=e}}requestAnimationFrame((()=>this._play()))}}_updateSunriseAndSunset(){const t=this._lighting;if(null==t||"virtual"===t.type||!this.sunLightingEnabled)return;const i=s(this.view,(t=>t.camera?.position));if(null==i)return;const{latitude:e,longitude:n}=i,{date:l,displayUTCOffset:a}=t,o=C(l,e,n,a);o&&(this._sunrise=new Date(o.sunrise),this._sunset=new Date(o.sunset))}};t([c({type:m})],M.prototype,"view",void 0),t([c({type:O,nonNullable:!0})],M.prototype,"datePickerViewModel",void 0),t([c({type:b,nonNullable:!0})],M.prototype,"timeSliderViewModel",void 0),t([c()],M.prototype,"isSupported",null),t([c()],M.prototype,"lightingUpdateInterval",void 0),t([c()],M.prototype,"utcOffset",null),t([c()],M.prototype,"localDate",null),t([c()],M.prototype,"timeSliderPosition",null),t([c()],M.prototype,"directShadowsEnabled",null),t([c()],M.prototype,"sunLightingEnabled",null),t([c({type:["none","day","year"],value:"none"})],M.prototype,"playingState",null),t([c()],M.prototype,"dayPlaying",null),t([c()],M.prototype,"yearPlaying",null),t([c()],M.prototype,"playSpeedMultiplier",void 0),t([c()],M.prototype,"currentSeason",null),t([c()],M.prototype,"_lastTime",void 0),t([c()],M.prototype,"_sunrise",void 0),t([c()],M.prototype,"_sunset",void 0),t([c()],M.prototype,"_cachedLightingDateUTC",void 0),t([c()],M.prototype,"_cachedDisplayUTCOffset",void 0),t([c()],M.prototype,"_firstInteraction",void 0),t([c()],M.prototype,"_currentHemisphere",null),t([c()],M.prototype,"_environment",null),t([c()],M.prototype,"_lighting",null),t([c()],M.prototype,"_lightingType",null),t([c()],M.prototype,"_lightingDateDisplay",null),M=t([y("esri.widgets.Daylight.DaylightViewModel")],M);const V=M;export{V as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import{HandleOwner as i}from"../../core/HandleOwner.js";import{makeHandle as e}from"../../core/handleUtils.js";import n from"../../core/Logger.js";import{applySome as s,removeMaybe as l}from"../../core/maybe.js";import{when as a,initial as o,watch as r,on as h,syncAndInitial as g}from"../../core/reactiveUtils.js";import{schedule as d}from"../../core/scheduling.js";import{truncateLocalTime as p,isValidDate as u,resetUTCDate as c,offsetDate as y}from"../../core/timeUtils.js";import{property as m}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as _}from"../../core/accessorSupport/decorators/subclass.js";import f from"../../views/SceneView.js";import w from"../../views/3d/environment/SunLighting.js";import S from"../../views/3d/environment/VirtualLighting.js";import{positionToTimezoneInfo as D}from"../../views/3d/support/earthUtils.js";import{dateTimeToSliderPos as T,sliderPosToDateTime as v,getSeasonFromDate as U,getNorthernHemisphereSeason as P,getSeasonDate as L,Hemisphere as b,calculatePlaySpeed as O}from"./support/daylightUtils.js";import{SliderWithDropdownViewModel as E}from"./support/SliderWithDropdownViewModel.js";import C from"../support/DatePickerViewModel.js";import{formatSliderLabel as M,getSunriseAndSunsetTimes as j}from"../support/timeWidgetUtils.js";const V="esri.widgets.Daylight.DaylightViewModel";let H=class extends i{constructor(t){super(t),this.view=null,this.datePickerViewModel=new C,this.timeSliderViewModel=new E({min:0,max:1439,values:[0],labelFormatFunction:M,inputFormatFunction:M}),this.lightingUpdateInterval=200,this._oldLighting=null,this.playSpeedMultiplier=1,this._lastTime=null,this._sunrise=null,this._sunset=null,this._cachedLightingDateUTC=new Date(0),this._cachedDisplayUTCOffset=0,this._firstInteraction=!0,this._lastLightingUpdate=0,this._lightingUpdateHandle=null}initialize(){this.handles.add([a((()=>this.view),(t=>t.when((()=>this._updateLighting()))),o),r((()=>{const t=this._lighting;return"sun"===t?.type?I(t):null}),(t=>this._scheduleLightingUpdate(t))),h((()=>this._lighting),"timezone-will-change",(t=>this._timezoneWillChange(t)),{onListenerAdd:()=>this._timezoneWillChange(null)}),r((()=>!0===s(this.view,(t=>t.stationary))),(()=>{(this.dayPlaying||this.yearPlaying)&&this._updateSunriseAndSunset()}),o),r((()=>{const t=this.timeSliderViewModel;return{vm:t,state:t.state,sliderPosition:this.timeSliderPosition}}),(({vm:t,state:i,sliderPosition:e})=>{"ready"===i&&t.setValue(0,e)})),r((()=>this.timeSliderViewModel?.utcOffset),(t=>{null!=t&&(this.utcOffset=t)})),r((()=>({utcOffset:this.utcOffset,sliderViewModel:this.timeSliderViewModel})),(({utcOffset:t,sliderViewModel:i})=>{i&&(i.utcOffset=t)}),g),r((()=>this.timeSliderViewModel.timezonePickerOpen),(()=>this.stopPlaying())),r((()=>this.timeSliderViewModel.values),(t=>this._setTimeSliderPosition(t?.[0]??0,{forceLightingUpdate:!1}))),r((()=>this.datePickerViewModel.value),(t=>{this.dayPlaying=!1,this.localDate=t})),r((()=>this.localDate),(t=>{this.datePickerViewModel.value.valueOf()!==t.getTime()&&this.datePickerViewModel.set("value",t)}))])}destroy(){this._cancelLightingUpdate(),this.view=null}get isSupported(){return null==this.view||"3d"===this.view.type}get utcOffset(){return this._cachedDisplayUTCOffset}set utcOffset(t){t!==this.utcOffset&&null!=this._lighting&&"virtual"!==this._lighting.type&&(this._lighting.displayUTCOffset=t,this._updateLighting())}get localDate(){return p(this._lightingDateDisplay)}set localDate(t){u(t)&&t.getTime()!==this.localDate.getTime()&&(this._lightingDateDisplay=c(this._lightingDateDisplay,t))}get timeSliderPosition(){return T(this._lightingDateDisplay)}set timeSliderPosition(t){this._setTimeSliderPosition(t,{forceLightingUpdate:!0})}_setTimeSliderPosition(t,i){Math.abs(t-this.timeSliderPosition)<=1/60||(this.stopPlaying(),this._enableDirectShadowsIfFirstInteraction(),i.forceLightingUpdate&&(this._cancelLightingUpdate(),this._updateLighting()),this._lightingDateDisplay=v(this._lightingDateDisplay,t))}_timezoneFromCamera(t,i){if(null==i||!t.cameraTrackingEnabled)return 0;const e=D([i.longitude,i.latitude]);return null==e?0:Math.round(e.hours+e.minutes/60+e.seconds/3600)}get directShadowsEnabled(){return s(this._lighting,(t=>t.directShadowsEnabled))??!1}set directShadowsEnabled(t){s(this._lighting,(i=>{i.directShadowsEnabled=t}))}get sunLightingEnabled(){return"sun"===this._lightingType}set sunLightingEnabled(t){const i=this._environment;if(t===this._get("sunLightingEnabled")||null==i)return;const e=i.lighting,n=this._oldLighting;this._oldLighting=e;const s={directShadowsEnabled:e.directShadowsEnabled,cameraTrackingEnabled:e.cameraTrackingEnabled},l=t?"sun":"virtual";let a;a=null!=n&&n.type===l?n:t?new w:new S,a.set(s),i.lighting=a,t||(this.timeSliderViewModel.timezonePickerOpen=!1)}set playingState(t){this.playingState!==t&&this.sunLightingEnabled&&(this._set("playingState",t),"none"!==t&&(this._updateSunriseAndSunset(),this._lastTime=Date.now(),this._play(),this._enableDirectShadowsIfFirstInteraction()))}get dayPlaying(){return"day"===this.playingState}set dayPlaying(t){t?this.playingState="day":this.dayPlaying&&(this.playingState="none")}get yearPlaying(){return"year"===this.playingState}set yearPlaying(t){t?this.playingState="year":this.yearPlaying&&(this.playingState="none")}get currentSeason(){return U(this.localDate,this._currentHemisphere)}set currentSeason(t){this.stopPlaying();const i=P(t,this._currentHemisphere);this.localDate=L(this.localDate,i,b.NORTHERN)}get _currentHemisphere(){const t=s(this.view,(t=>t.camera?.position?.latitude));return null==t||t>=0?b.NORTHERN:b.SOUTHERN}get _environment(){return s(this.view,(t=>t.environment))}get _lighting(){return s(this._environment,(t=>t.lighting))}get _lightingType(){return s(this._lighting,(t=>t.type))}get _lightingDateDisplay(){return y(this._cachedLightingDateUTC,this._cachedDisplayUTCOffset,"hours")}set _lightingDateDisplay(t){const i=this._lighting;if(null==i||!this.sunLightingEnabled||"virtual"===i.type||!u(t))return;const e=I(i),n=y(t,-this._cachedDisplayUTCOffset,"hours");n.getTime()!==e.getTime()&&(i.date=n,this._updateLighting())}stopPlaying(){this.playingState="none"}toggleDayPlaying(){this.dayPlaying=!this.dayPlaying}toggleYearPlaying(){this.yearPlaying=!this.yearPlaying}toggleSunLightingEnabled(){this.stopPlaying(),this.sunLightingEnabled=!this.sunLightingEnabled}toggleDirectShadowsEnabled(){this.stopPlaying(),this.directShadowsEnabled=!this.directShadowsEnabled}_enableDirectShadowsIfFirstInteraction(){this._firstInteraction&&(this._firstInteraction=!1,this.directShadowsEnabled=!0)}_updateLighting(t){const i=Date.now();this._lastLightingUpdate=i;const{view:e}=this,n=this._lighting;if(null==e||null==n||"virtual"===n.type)return;t??=I(n);const s=n.displayUTCOffset,l=null!==s?s:this._timezoneFromCamera(n,e.camera?.position);this._cachedLightingDateUTC.getTime()!==t.getTime()&&(this._cachedLightingDateUTC=new Date(t.getTime())),this._cachedDisplayUTCOffset!==l&&(this._cachedDisplayUTCOffset=l)}_timezoneWillChange(t){const i=this._lighting;if(null==i||"virtual"===i.type||!i.cameraTrackingEnabled)return;let e;if(t)e=t.timezoneOffset;else{if(null!=i.displayUTCOffset)return;e=w.calculateTimezoneOffset(i.positionTimezoneInfo)}i.displayUTCOffset=e,this._scheduleLightingUpdate()}_scheduleLightingUpdate(t){if(t&&(this._lightingUpdateHandle=l(this._lightingUpdateHandle),!u(t)))return;if(this._lightingUpdateHandle)return;const i=Date.now()-this._lastLightingUpdate,n=this.lightingUpdateInterval-i;let s=null;const a=()=>{this._updateLighting(t),this._lightingUpdateHandle===s&&(this._lightingUpdateHandle=null)};if(n<=0)this._lightingUpdateHandle=s=d(a);else{const t=setTimeout(a,n);this._lightingUpdateHandle=s=e((()=>clearTimeout(t)))}}_cancelLightingUpdate(){this._lightingUpdateHandle=l(this._lightingUpdateHandle)}_play(){const t=this._lighting;if(null==t||!this.sunLightingEnabled||"virtual"===t.type)return;const i=I(t);if(this.dayPlaying||this.yearPlaying){const e=Date.now()-(this._lastTime??0);if(this.dayPlaying){this._lastTime=Date.now();const n=O(this._sunrise,this._sunset,i)*this.playSpeedMultiplier/100*e;if(n>0){let e=new Date(i.getTime()+n);const s=t.displayUTCOffset??0;if(((e.getUTCHours()+s)%24+24)%24<((i.getUTCHours()+s)%24+24)%24){const t=864e5;e=new Date(i.getTime()+n-t)}t.date=e}}else{if(e>1e3){this._lastTime=Date.now();const e=(i.getUTCMonth()+1)%12,n=new Date(i.getTime());n.setUTCMonth(e),t.date=n}}requestAnimationFrame((()=>this._play()))}}_updateSunriseAndSunset(){const t=this._lighting;if(null==t||"virtual"===t.type||!this.sunLightingEnabled)return;const i=s(this.view,(t=>t.camera?.position));if(null==i)return;const{latitude:e,longitude:n}=i,{date:l,displayUTCOffset:a}=t,o=j(l,e,n,a);o&&(this._sunrise=new Date(o.sunrise),this._sunset=new Date(o.sunset))}};function I(t){return u(t.date)||(n.getLogger(V).warn("Invalid date. Reverting to the current date/time."),t.date=new Date),t.date}t([m({type:f})],H.prototype,"view",void 0),t([m({type:C,nonNullable:!0})],H.prototype,"datePickerViewModel",void 0),t([m({type:E,nonNullable:!0})],H.prototype,"timeSliderViewModel",void 0),t([m()],H.prototype,"isSupported",null),t([m()],H.prototype,"lightingUpdateInterval",void 0),t([m()],H.prototype,"utcOffset",null),t([m()],H.prototype,"localDate",null),t([m()],H.prototype,"timeSliderPosition",null),t([m()],H.prototype,"directShadowsEnabled",null),t([m()],H.prototype,"sunLightingEnabled",null),t([m({type:["none","day","year"],value:"none"})],H.prototype,"playingState",null),t([m()],H.prototype,"dayPlaying",null),t([m()],H.prototype,"yearPlaying",null),t([m()],H.prototype,"playSpeedMultiplier",void 0),t([m()],H.prototype,"currentSeason",null),t([m()],H.prototype,"_lastTime",void 0),t([m()],H.prototype,"_sunrise",void 0),t([m()],H.prototype,"_sunset",void 0),t([m()],H.prototype,"_cachedLightingDateUTC",void 0),t([m()],H.prototype,"_cachedDisplayUTCOffset",void 0),t([m()],H.prototype,"_firstInteraction",void 0),t([m()],H.prototype,"_currentHemisphere",null),t([m()],H.prototype,"_environment",null),t([m()],H.prototype,"_lighting",null),t([m()],H.prototype,"_lightingType",null),t([m()],H.prototype,"_lightingDateDisplay",null),H=t([_(V)],H);const k=H;export{k as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{remove as t}from"../../core/arrayUtils.js";import{makeHandle as a,handlesGroup as i}from"../../core/handleUtils.js";import{removeMaybe as r,destroyMaybe as n}from"../../core/maybe.js";import{throwIfAborted as o}from"../../core/promiseUtils.js";import{whenOnce as s,watch as l,syncAndInitial as c}from"../../core/reactiveUtils.js";import{generateBracedUUID as d}from"../../core/uuid.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveLayerCapabilities as p,getEffectiveEditingEnabled as f}from"../../layers/support/layerUtils.js";import{getDrawHelpMessage as m}from"../../views/draw/support/helpMessageUtils.js";import g from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{CreateFeaturesWorkflowData as w}from"./CreateFeaturesWorkflowData.js";import{isModelUpload as y,waitForModelUpload as v}from"./modelUploadUtils.js";import _ from"./Workflow.js";import{shouldShowAttachmentsForCreateWorkflow as F,startCreatingNewFeature as I,findLayerInfo as b,updateGraphicSymbolWhenRequired as M,isTerminalUpdateEventType as A,getVisualVariableAttributes as k,startUpdatingFeature as V,createWorkflowSteps as j,avoidFeatureTemplateSelectionWithOnlyOneItem as C,prepareAttachmentsForCreateWorkflow as E,showProgressCursor as U,visualVariableInteractiveUpdate as S}from"./workflowUtils.js";var G;const H=Symbol();let O=G=class extends _{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._attachmentFileInfos=new Map,this._highlightHandles=new Map,this._preventDefaultActionOnCancel=!1,this._lastActiveGraphics=[]}get hasPendingEdits(){if(this.numPendingFeatures)return!0;const{data:e}=this,{upload:t}=e;return!(!t||t.error)||!!e.creationInfo?.geometryToPlace}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const a=e.layer.geometryType,i=t.sketchViewModel.createGraphic?.geometry;return m(a,i,t.view)}get numPendingFeatures(){return this.pendingFeatures.length}get pendingFeatures(){return this.data.viewModel.sketchViewModel.layer.graphics}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){const{creationInfo:e}=this.data;if(!e)return!1;const{layer:t}=e,a=t.capabilities?.operations.supportsAdd,i=p(t)?.operations.supportsAdd;return f(t)&&!t.editingEnabled||!!i&&!a}get shouldShowAttachments(){return!!(this.data&&this.data.creationInfo&&this.data.viewModel)&&F(this.data)}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get updating(){return this.updatingHandles.updating}get test(){return{addAttachment:(e,t)=>{this._attachmentFileInfos.set(e,t)}}}async enter(){}exit(){}async updatePendingFeature(e,a){return this._preventDefaultActionOnCancel=!0,this.data.viewModel.sketchViewModel.cancel(),t(this._lastActiveGraphics,e),this._startUpdating(e,a)}static create(e,t,a,i,r){const n=new G({data:new w({creationInfo:t,viewModel:e}),onCommit:async e=>{const{creationInfo:t,viewModel:a}=e;if(!t)return;t.geometryToPlace&&(e.creationInfo=null);const o=a.sketchViewModel.layer.graphics.toArray(),{layer:s}=t,l=s.capabilities?.editing.supportsGlobalId&&"globalIdField"in s,c=n._attachmentFileInfos;if(l){const e=T(o,s,c);return void await i(s,e,{globalIdUsed:!0})}const d=await i(s,{addFeatures:o});if(c.size>0){const e=d?.addFeatureResults??[];await r(s,P(o,e,s,c))}}});return n._set("steps",this._createWorkflowSteps(n,a)),n}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",a((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,a((()=>e.opacity=t))}_highlight(e){const t=this.data.viewModel.view;"3d"===t?.type&&this._highlightHandles.set(e,t.highlight(e))}_removeHighlight(e){r(this._highlightHandles.get(e)),this._highlightHandles.delete(e)}async _startCreating(e){const{data:t}=this,{creationInfo:a}=t;if(a)return this.createFeatureState="create-new",I(t.viewModel.sketchViewModel,a,e)}async _startUpdating(e,t){const{creationInfo:a,viewModel:n}=this.data,{featureFormViewModel:o,layerInfos:s,sketchViewModel:l,view:c}=n;if(!c||!a)return;const d=a.layer,u=b(s,d),h=u?.formTemplate,p=c.spatialReference;return o.set({arcadeEditType:"INSERT",feature:e,formTemplate:h,spatialReference:p,view:c}),await M(e,t),r(this._featureFormHandle),this._featureFormHandle=i([o.on("value-change",(async()=>{e.attributes=o.getValues(),await M(e,t)})),l.on(["update","undo","redo"],(e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&A(e.toolEventInfo.type))&&o.notifyFeatureGeometryChanged()}))]),this._removeHighlight(e),this.createFeatureState="update-pending",this._visualVariableAttributes=k(e),V(l,e,d,this._visualVariableAttributes,t)}static _createWorkflowSteps(e,n="awaiting-feature-creation-info"){const{data:c,handles:d}=e;let u=null,h=!0;const p=new Map,f=j(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],n,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(t){const{creationInfo:a,viewModel:i}=c,{view:r}=i;if(r)if(y(a)){const a=await v({view:r,data:c,signal:t,next:()=>e.next(),cancel:()=>i.cancelWorkflow()});o(t),d.add(a,this.id)}else c.creationInfo=null,d.add(i.featureTemplatesViewModel.on("select",(({item:e})=>{e&&(c.creationInfo=e,i.activeWorkflow?.next())})),this.id)},async tearDown(){d.remove(this.id)}}),"creating-features":()=>({id:"creating-features",async setUp(){if(d.has(this.id))return;const{viewModel:n}=c,{view:o}=n;if(!o)return;const f=n.sketchViewModel;h=f.updateOnGraphicClick,f.updateOnGraphicClick=!1,e._lastActiveGraphics=[],e._featureFormHandle=r(e._featureFormHandle),e._visualVariableAttributes={rotation:null,size:null},E(n.attachmentsViewModel);const m="2d"===o.type&&c.creationInfo?e._fadeExistingFeatures(c.creationInfo.layer):null,g=f.on("create",(async t=>{if("cancel"===t.state){if(e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);if(e._lastActiveGraphics.length<1)return e._startCreating(p);const t=e._lastActiveGraphics.pop();return e._startUpdating(t,p)}if("complete"===t.state&&t.graphic)return e._startUpdating(t.graphic,p)})),w=f.on("update",(async t=>{const{viewModel:a}=c,{attachmentsViewModel:i,featureFormViewModel:r}=a,n=t.graphics[0];if("complete"===t.state){if(n!==u&&(e._lastActiveGraphics.push(n),e._highlight(n)),u=null,e.numPendingFeatures===c.creationInfo?.maxFeatures){const t=e._lastActiveGraphics.pop();return e._startUpdating(t,p)}return"add"!==i.mode&&"edit"!==i.mode||a.activeWorkflow?.previous(),t.aborted&&e._preventDefaultActionOnCancel?void(e._preventDefaultActionOnCancel=!1):(d.add([U(o),o.on("click",(e=>e.preventDefault()))],H),s((()=>!r.updating)).then((()=>{d.remove(H),e._startCreating(p)})))}if("start"===t.state){e._removeHighlight(n),"add"!==i.mode&&"edit"!==i.mode||a.activeWorkflow?.previous(),i.fileInfos.removeAll(),i.graphic=n,i.mode="view";(e._attachmentFileInfos.get(n)||[]).forEach((({file:e,form:t})=>i.addFile(e,t)))}const l=e._visualVariableAttributes;await S(o,n,t,l,p);const h=n.attributes,{rotation:f,size:m}=l;if(null!=f){const{field:e}=f;r.setValue(e,h[e])}if(null!=m){const{field:e}=m;r.setValue(e,h[e])}})),v=f.on("delete",(async a=>{const i=a.graphics[0];t(e._lastActiveGraphics,i),u=i})),_=D(f,c),F=o.on("immediate-click",(async t=>{if(y(c.creationInfo))return;const{results:a}=await o.hitTest(t,{include:f.layer}),i=a.find((e=>"graphic"===e.type));if(!i)return;const r=i.graphic;if("transform"===f.activeTool||"reshape"===f.activeTool){if(f.updateGraphics.at(0)===r)return;await e.updatePendingFeature(r,p)}})),I=l((()=>n.attachmentsViewModel.mode),(t=>{switch(t){case"add":e.go("adding-attachment");break;case"edit":e.go("editing-attachment")}})),b=U(o);try{await e._startCreating(p)}finally{b.remove()}const M=i([b,e._featureFormHandle,g,w,v,_,a((()=>f.cancel())),F,I,m]);d.add(M,e._handleKeys.beforeCommit),d.add(M,this.id)},async tearDown(t){const{viewModel:a}=c;t.canceled&&(a.sketchViewModel.layer.removeAll(),d.remove([this.id,H]),a.attachmentsViewModel.fileInfos.removeAll(),e._attachmentFileInfos.clear(),a.sketchViewModel.updateOnGraphicClick=h)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=c.viewModel,{graphic:a,fileInfos:i}=t;e._attachmentFileInfos.set(a,i.toArray()),t.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"creating-features",async setUp(){},async tearDown(){const{attachmentsViewModel:t}=c.viewModel,{graphic:a,fileInfos:i}=t;e._attachmentFileInfos.set(a,i.toArray()),t.mode="view"}})});return C(c,f)}};function D(e,t){let r=null;const o=()=>e.snappingOptions.featureSources,s=()=>(r=new g({layer:e.layer}),o().add(r),r),d=()=>{null!=r&&(o().remove(r),r=n(r))};return i([l((()=>{const e=t.creationInfo?.layer,a=o().find((t=>t.layer===e));return{hasFeatureLayerSource:!!a,enabled:a?.enabled??!1}}),(({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return d();r??=s(),r.enabled=t}),c),a(d)])}function P(e,t,a,i){const r=[];return t.forEach(((t,n)=>{if(!t.error){const o=e[n],s=i.get(o)||[];o.attributes[a.objectIdField]=t.objectId,s.forEach((({form:e})=>r.push({feature:o,attachment:e})))}})),r}function T(e,t,a){const i=[],r=t.globalIdField;return e.forEach(((t,n)=>{e[n].attributes[r]??=d(),(a?.get(t)||[]).forEach((({file:e})=>i.push({feature:t,attachment:{globalId:d(),data:e}})))})),i.length?{addFeatures:e,addAttachments:i}:{addFeatures:e}}e([u()],O.prototype,"hasPendingEdits",null),e([u()],O.prototype,"helpMessage",null),e([u()],O.prototype,"keyboardCancellationEnabled",null),e([u()],O.prototype,"reliesOnOwnerAdminPrivileges",null),e([u()],O.prototype,"shouldShowAttachments",null),e([u()],O.prototype,"shouldAllowAttachmentEditing",null),e([u()],O.prototype,"updating",null),O=G=e([h("esri.widgets.Editor.CreateFeaturesWorkflow")],O);const x=O;export{x as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{remove as t}from"../../core/arrayUtils.js";import{makeHandle as a,handlesGroup as i}from"../../core/handleUtils.js";import{removeMaybe as r,destroyMaybe as n}from"../../core/maybe.js";import{throwIfAborted as o}from"../../core/promiseUtils.js";import{whenOnce as s,watch as l,syncAndInitial as c}from"../../core/reactiveUtils.js";import{generateBracedUUID as d}from"../../core/uuid.js";import{property as u}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/has.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveLayerCapabilities as p,getEffectiveEditingEnabled as f,isTable as g}from"../../layers/support/layerUtils.js";import{getDrawHelpMessage as m}from"../../views/draw/support/helpMessageUtils.js";import w from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{CreateFeaturesWorkflowData as v}from"./CreateFeaturesWorkflowData.js";import{isModelUpload as y,waitForModelUpload as _}from"./modelUploadUtils.js";import F from"./Workflow.js";import{shouldShowAttachmentsForCreateWorkflow as b,startCreatingNewFeature as I,findLayerInfo as M,updateGraphicSymbolWhenRequired as A,isTerminalUpdateEventType as k,getVisualVariableAttributes as V,startUpdatingFeature as C,createWorkflowSteps as S,avoidFeatureTemplateSelectionWithOnlyOneItem as j,showProgressCursor as E,visualVariableInteractiveUpdate as U,prepareAttachmentsForCreateWorkflow as G}from"./workflowUtils.js";var H;const O=Symbol();let D=H=class extends F{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._attachmentFileInfos=new Map,this._highlightHandles=new Map,this._preventDefaultActionOnCancel=!1,this._lastActiveGraphics=[]}get hasPendingEdits(){if(this.numPendingFeatures)return!0;const{data:e}=this,{upload:t}=e;return!(!t||t.error)||!!e.creationInfo?.geometryToPlace}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const a=e.layer.geometryType,i=t.sketchViewModel.createGraphic?.geometry;return m(a,i,t.view)}get numPendingFeatures(){return this.pendingFeatures.length}get pendingFeatures(){return this.data.viewModel.sketchViewModel.layer.graphics}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){const{creationInfo:e}=this.data;if(!e)return!1;const{layer:t}=e,a=t.capabilities?.operations.supportsAdd,i=p(t)?.operations.supportsAdd;return f(t)&&!t.editingEnabled||!!i&&!a}get shouldShowAttachments(){return!!(this.data&&this.data.creationInfo&&this.data.viewModel)&&b(this.data)}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get updating(){return this.updatingHandles.updating}get test(){return{addAttachment:(e,t)=>{this._attachmentFileInfos.set(e,t)}}}async enter(){}exit(){}async updatePendingFeature(e,a){return this._preventDefaultActionOnCancel=!0,this.data.viewModel.sketchViewModel.cancel(),t(this._lastActiveGraphics,e),this._startUpdating(e,a)}static create(e){const{addAttachmentsCallback:t,applyEditsCallback:a,creationInfo:i,startAt:r,viewModel:n}=e,o=new H({data:new v({creationInfo:i,viewModel:n}),onCommit:async e=>{const{creationInfo:i,viewModel:r}=e;if(!i)return;i.geometryToPlace&&(e.creationInfo=null);const n=r.sketchViewModel.layer.graphics.toArray(),{layer:s}=i,l=s.capabilities?.editing.supportsGlobalId&&"globalIdField"in s,c=o._attachmentFileInfos;if(l){const e=x(n,s,c);return void await a(s,e,{globalIdUsed:!0})}const d=await a(s,{addFeatures:n});if(c.size>0){const e=d?.addFeatureResults??[];await t(s,T(n,e,s,c))}}});return o._set("steps",this._createWorkflowSteps(o,r)),o}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",a((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,a((()=>e.opacity=t))}_highlight(e){const t=this.data.viewModel.view;"3d"===t?.type&&this._highlightHandles.set(e,t.highlight(e))}_removeHighlight(e){r(this._highlightHandles.get(e)),this._highlightHandles.delete(e)}async _startCreating(e){const{data:t}=this,{creationInfo:a}=t;if(a)return this.createFeatureState="create-new",I(t.viewModel.sketchViewModel,a,e)}async _startUpdating(e,t){const{creationInfo:a,viewModel:n}=this.data,{featureFormViewModel:o,layerInfos:s,sketchViewModel:l,view:c}=n;if(!c||!a)return;const d=a.layer,u=M(s,d),h=u?.formTemplate,p=c.spatialReference;return o.set({arcadeEditType:"INSERT",feature:e,formTemplate:h,spatialReference:p,view:c}),await A(e,t),r(this._featureFormHandle),this._featureFormHandle=i([o.on("value-change",(async()=>{e.attributes=o.getValues(),await A(e,t)})),l.on(["update","undo","redo"],(e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&k(e.toolEventInfo.type))&&o.notifyFeatureGeometryChanged()}))]),this._removeHighlight(e),this.createFeatureState="update-pending",this._visualVariableAttributes=V(e),g(d)?void 0:C({graphic:e,sketchViewModel:l,sourceLayer:d,visualVariables:this._visualVariableAttributes,webStyleCache:t})}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a,handles:n}=e,s=S(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],t,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(t){const{creationInfo:i,viewModel:r}=a,{view:s}=r;if(s)if(y(i)){const i=await _({view:s,data:a,signal:t,next:()=>e.next(),cancel:()=>r.cancelWorkflow()});o(t),n.add(i,this.id)}else a.creationInfo=null,n.add(r.featureTemplatesViewModel.on("select",(({item:e})=>{e&&(a.creationInfo=e,r.activeWorkflow?.next())})),this.id)},async tearDown(){n.remove(this.id)}}),"creating-features":()=>({id:"creating-features",async setUp(){if(n.has(this.id))return;const{viewModel:t}=a,{view:o}=t;if(!o)return;const s=new Map,c=[];e._lastActiveGraphics=[],e._featureFormHandle=r(e._featureFormHandle),e._visualVariableAttributes={rotation:null,size:null},G(t.attachmentsViewModel),c.push(l((()=>t.attachmentsViewModel.mode),(t=>{switch(t){case"add":e.go("adding-attachment");break;case"edit":e.go("editing-attachment")}})));const d=E(o);c.push(d);const u=e.data.creationInfo?.layer;try{g(u)||c.push(H._configureSketchViewModel(e,s));const t=a.creationInfo?.initialFeature;t?(e.pendingFeatures.add(t),await e._startUpdating(t,s)):await e._startCreating(s)}finally{d.remove()}const h=i([...c,d,e._featureFormHandle]);n.add(h,e._handleKeys.beforeCommit),n.add(h,this.id)},async tearDown(t){const{viewModel:i}=a;t.canceled&&(i.sketchViewModel.layer.removeAll(),n.remove([this.id,O]),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 j(a,s)}static _configureSketchViewModel(e,r){const{data:n,handles:o}=e,{viewModel:l}=n,{view:c}=l,d=l.sketchViewModel;let u=null;const h=[];if(!c)return a();const p=d.updateOnGraphicClick;return d.updateOnGraphicClick=!1,h.push(a((()=>d.updateOnGraphicClick=p))),"2d"===c.type&&n.creationInfo&&h.push(e._fadeExistingFeatures(n.creationInfo.layer)),h.push(d.on("create",(async t=>{if("cancel"===t.state){if(e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);if(e._lastActiveGraphics.length<1)return e._startCreating(r);const t=e._lastActiveGraphics.pop();return e._startUpdating(t,r)}if("complete"===t.state&&t.graphic)return e._startUpdating(t.graphic,r)})),d.on("update",(async t=>{const{viewModel:a}=n,{attachmentsViewModel:i,featureFormViewModel:l}=a,d=t.graphics[0];if("complete"===t.state){if(d!==u&&(e._lastActiveGraphics.push(d),e._highlight(d)),u=null,e.numPendingFeatures===n.creationInfo?.maxFeatures){const t=e._lastActiveGraphics.pop();return e._startUpdating(t,r)}if("add"!==i.mode&&"edit"!==i.mode||a.activeWorkflow?.previous(),t.aborted&&e._preventDefaultActionOnCancel)return void(e._preventDefaultActionOnCancel=!1);o.add([E(c),c.on("click",(e=>e.preventDefault()))],O),await s((()=>!l.updating)),o.remove(O),e._startCreating(r)}if("start"===t.state){e._removeHighlight(d),"add"!==i.mode&&"edit"!==i.mode||a.activeWorkflow?.previous(),i.fileInfos.removeAll(),i.graphic=d,i.mode="view";(e._attachmentFileInfos.get(d)||[]).forEach((({file:e,form:t})=>i.addFile(e,t)))}const h=e._visualVariableAttributes;await U(c,d,t,h,r);const p=d.attributes,{rotation:f,size:g}=h;if(null!=f){const{field:e}=f;l.setValue(e,p[e])}if(null!=g){const{field:e}=g;l.setValue(e,p[e])}})),d.on("delete",(async a=>{const i=a.graphics[0];t(e._lastActiveGraphics,i),u=i})),c.on("immediate-click",(async t=>{if(y(n.creationInfo))return;const{results:a}=await c.hitTest(t,{include:d.layer}),i=a.find((e=>"graphic"===e.type));if(!i)return;const o=i.graphic;if("transform"===d.activeTool||"reshape"===d.activeTool){if(d.updateGraphics.at(0)===o)return;await e.updatePendingFeature(o,r)}})),a((()=>d.cancel())),P(d,n)),i(h)}};function P(e,t){let r=null;const o=()=>e.snappingOptions.featureSources,s=()=>(r=new w({layer:e.layer}),o().add(r),r),d=()=>{null!=r&&(o().remove(r),r=n(r))};return i([l((()=>{const e=t.creationInfo?.layer,a=o().find((t=>t.layer===e));return{hasFeatureLayerSource:!!a,enabled:a?.enabled??!1}}),(({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return d();r??=s(),r.enabled=t}),c),a(d)])}function T(e,t,a,i){const r=[];return t.forEach(((t,n)=>{if(!t.error){const o=e[n],s=i.get(o)||[];o.attributes[a.objectIdField]=t.objectId,s.forEach((({form:e})=>r.push({feature:o,attachment:e})))}})),r}function x(e,t,a){const i=[],r=t.globalIdField;return e.forEach(((t,n)=>{e[n].attributes[r]??=d(),(a?.get(t)||[]).forEach((({file:e})=>i.push({feature:t,attachment:{globalId:d(),data:e}})))})),i.length?{addFeatures:e,addAttachments:i}:{addFeatures:e}}e([u()],D.prototype,"hasPendingEdits",null),e([u()],D.prototype,"helpMessage",null),e([u()],D.prototype,"keyboardCancellationEnabled",null),e([u()],D.prototype,"reliesOnOwnerAdminPrivileges",null),e([u()],D.prototype,"shouldShowAttachments",null),e([u()],D.prototype,"shouldAllowAttachmentEditing",null),e([u()],D.prototype,"updating",null),D=H=e([h("esri.widgets.Editor.CreateFeaturesWorkflow")],D);const W=D;export{W as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import{watch as t}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveLayerCapabilities as o,getEffectiveEditingEnabled as r}from"../../layers/support/layerUtils.js";import{getDrawHelpMessage as s}from"../../views/draw/support/helpMessageUtils.js";import n from"./CreateWorkflowData.js";import{Edits as d}from"./Edits.js";import l from"./Workflow.js";import{shouldShowAttachmentsForCreateWorkflow as c,createWorkflowSteps as w,avoidFeatureTemplateSelectionWithOnlyOneItem as p,setUpFeatureAdd as u,findLayerInfo as f,prepareAttachmentsForCreateWorkflow as m,getVisualVariableAttributes as h,startUpdatingFeature as g,visualVariableInteractiveUpdate as v,updateGraphicSymbolWhenRequired as y}from"./workflowUtils.js";var M;let V=M=class extends l{constructor(e){super(e),this.type="create"}get shouldShowAttachments(){return!!(this.data&&this.data.creationInfo&&this.data.viewModel)&&c(this.data)}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get hasPendingEdits(){return!0}get helpMessage(){if("editing-new-feature"!==this.stepId)return;const{creationInfo:e,viewModel:t}=this.data,a=t.sketchViewModel.createGraphic?.geometry,i=e.layer.geometryType;return s(i,a,t.view)}get reliesOnOwnerAdminPrivileges(){const{layer:e}=this.data.creationInfo,t=e.capabilities?.operations.supportsAdd,a=o(e)?.operations.supportsAdd;return r(e)&&!e.editingEnabled||!!a&&!t}static create(e,t,a){const i=new M({data:new n({edits:new d,viewModel:e}),onCommit:async e=>{await a(e.creationInfo.layer,{addFeatures:[e.edits.feature]})}});return i._set("steps",this._createWorkflowSteps(i,t)),i}static _createWorkflowSteps(e,a="awaiting-feature-creation-info"){const{data:i,handles:o}=e,r=new Map,s=w(["awaiting-feature-creation-info","awaiting-feature-to-create","editing-new-feature","adding-attachment","editing-attachment"],a,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){i.creationInfo=null,i.edits.feature=null,i.viewModel.featureTemplatesViewModel.select(null),o.add(i.viewModel.featureTemplatesViewModel.on("select",(({item:e})=>{e&&(i.creationInfo=e,i.viewModel.activeWorkflow?.next())})),this.id)},async tearDown(){o.remove(this.id)}}),"awaiting-feature-to-create":()=>({id:"awaiting-feature-to-create",async setUp(){o.add(await u(i.viewModel.sketchViewModel,i.creationInfo,(e=>{i.edits.feature=e,i.viewModel.activeWorkflow?.next()}),r),this.id)},async tearDown(){o.remove(this.id)}}),"editing-new-feature":()=>({id:"editing-new-feature",async setUp(){const e=i.edits.feature,a=e.sourceLayer,s=i.viewModel,n=s.sketchViewModel,d=f(s.layerInfos,a),l=d?.formTemplate,{spatialReference:c}=s.view;s.featureFormViewModel.set({arcadeEditType:"INSERT",feature:e,formTemplate:l,spatialReference:c}),n.allowDeleteKey=!1,m(s.attachmentsViewModel);const w=h(e);await g(n,e,a,w,r);const p=n.on("update",(async e=>{const t=e.graphics[0];if("complete"===e.state)return g(n,t,a,w,r);await v(n.view,t,e,w,r);const i=t.attributes;if(null!=w.rotation){const{field:e}=w.rotation;s.featureFormViewModel.setValue(e,i[e])}if(null!=w.size){const{field:e}=w.size;s.featureFormViewModel.setValue(e,i[e])}}));o.add([i.viewModel.featureFormViewModel.on("value-change",(async()=>{i.edits.updateAttributes(i.viewModel.featureFormViewModel.getValues()),e.attributes=i.edits.feature.attributes,"3d"===n.view.type&&await y(e,r)})),p,t((()=>i.viewModel.attachmentsViewModel.mode),(e=>{"add"===e&&i.viewModel.activeWorkflow.go("adding-attachment"),"edit"===e&&i.viewModel.activeWorkflow.go("editing-attachment")}))],this.id)},async tearDown(e){e.canceled&&i.viewModel.sketchViewModel.layer.removeAll(),o.remove(this.id)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-new-feature",async setUp(){},async tearDown(){i.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-new-feature",async setUp(){},async tearDown(){i.viewModel.attachmentsViewModel.mode="view"}})});return p(i,s)}};e([a()],V.prototype,"shouldShowAttachments",null),e([a()],V.prototype,"shouldAllowAttachmentEditing",null),e([a()],V.prototype,"hasPendingEdits",null),e([a()],V.prototype,"helpMessage",null),e([a()],V.prototype,"reliesOnOwnerAdminPrivileges",null),V=M=e([i("esri.widgets.Editor.CreateWorkflow")],V);const k=V;export{k as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import{watch as t}from"../../core/reactiveUtils.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{getEffectiveLayerCapabilities as o,getEffectiveEditingEnabled as r}from"../../layers/support/layerUtils.js";import{getDrawHelpMessage as s}from"../../views/draw/support/helpMessageUtils.js";import n from"./CreateWorkflowData.js";import{Edits as d}from"./Edits.js";import l from"./Workflow.js";import{shouldShowAttachmentsForCreateWorkflow as c,createWorkflowSteps as w,avoidFeatureTemplateSelectionWithOnlyOneItem as u,setUpFeatureAdd as p,findLayerInfo as f,prepareAttachmentsForCreateWorkflow as m,getVisualVariableAttributes as h,startUpdatingFeature as g,visualVariableInteractiveUpdate as y,updateGraphicSymbolWhenRequired as v}from"./workflowUtils.js";var M;let V=M=class extends l{constructor(e){super(e),this.type="create"}get shouldShowAttachments(){return!!(this.data&&this.data.creationInfo&&this.data.viewModel)&&c(this.data)}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get hasPendingEdits(){return!0}get helpMessage(){if("editing-new-feature"!==this.stepId)return;const{creationInfo:e,viewModel:t}=this.data,a=t.sketchViewModel.createGraphic?.geometry,i=e.layer.geometryType;return s(i,a,t.view)}get reliesOnOwnerAdminPrivileges(){const{layer:e}=this.data.creationInfo,t=e.capabilities?.operations.supportsAdd,a=o(e)?.operations.supportsAdd;return r(e)&&!e.editingEnabled||!!a&&!t}static create(e,t,a){const i=new M({data:new n({edits:new d,viewModel:e}),onCommit:async e=>{await a(e.creationInfo.layer,{addFeatures:[e.edits.feature]})}});return i._set("steps",this._createWorkflowSteps(i,t)),i}static _createWorkflowSteps(e,a="awaiting-feature-creation-info"){const{data:i,handles:o}=e,r=new Map,s=w(["awaiting-feature-creation-info","awaiting-feature-to-create","editing-new-feature","adding-attachment","editing-attachment"],a,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){i.creationInfo=null,i.edits.feature=null,i.viewModel.featureTemplatesViewModel.select(null),o.add(i.viewModel.featureTemplatesViewModel.on("select",(({item:e})=>{e&&(i.creationInfo=e,i.viewModel.activeWorkflow?.next())})),this.id)},async tearDown(){o.remove(this.id)}}),"awaiting-feature-to-create":()=>({id:"awaiting-feature-to-create",async setUp(){o.add(await p(i.viewModel.sketchViewModel,i.creationInfo,(e=>{i.edits.feature=e,i.viewModel.activeWorkflow?.next()}),r),this.id)},async tearDown(){o.remove(this.id)}}),"editing-new-feature":()=>({id:"editing-new-feature",async setUp(){const e=i.edits.feature,a=e.sourceLayer,s=i.viewModel,n=s.sketchViewModel,d=f(s.layerInfos,a),l=d?.formTemplate,{spatialReference:c}=s.view;s.featureFormViewModel.set({arcadeEditType:"INSERT",feature:e,formTemplate:l,spatialReference:c}),n.allowDeleteKey=!1,m(s.attachmentsViewModel);const w=h(e);await g({graphic:e,sketchViewModel:n,sourceLayer:a,visualVariables:w,webStyleCache:r});const u=n.on("update",(async e=>{const t=e.graphics[0];if("complete"===e.state)return g({graphic:t,sketchViewModel:n,sourceLayer:a,visualVariables:w,webStyleCache:r});await y(n.view,t,e,w,r);const i=t.attributes;if(null!=w.rotation){const{field:e}=w.rotation;s.featureFormViewModel.setValue(e,i[e])}if(null!=w.size){const{field:e}=w.size;s.featureFormViewModel.setValue(e,i[e])}}));o.add([i.viewModel.featureFormViewModel.on("value-change",(async()=>{i.edits.updateAttributes(i.viewModel.featureFormViewModel.getValues()),e.attributes=i.edits.feature.attributes,"3d"===n.view.type&&await v(e,r)})),u,t((()=>i.viewModel.attachmentsViewModel.mode),(e=>{"add"===e&&i.viewModel.activeWorkflow.go("adding-attachment"),"edit"===e&&i.viewModel.activeWorkflow.go("editing-attachment")}))],this.id)},async tearDown(e){e.canceled&&i.viewModel.sketchViewModel.layer.removeAll(),o.remove(this.id)}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-new-feature",async setUp(){},async tearDown(){i.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-new-feature",async setUp(){},async tearDown(){i.viewModel.attachmentsViewModel.mode="view"}})});return u(i,s)}};e([a()],V.prototype,"shouldShowAttachments",null),e([a()],V.prototype,"shouldAllowAttachmentEditing",null),e([a()],V.prototype,"hasPendingEdits",null),e([a()],V.prototype,"helpMessage",null),e([a()],V.prototype,"reliesOnOwnerAdminPrivileges",null),V=M=e([i("esri.widgets.Editor.CreateWorkflow")],V);const k=V;export{k as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import{createTask as e}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{deprecated as r}from"../../core/deprecate.js";import i from"../../core/Error.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import n from"../../core/Logger.js";import{abortMaybe as l}from"../../core/maybe.js";import{throwIfAborted as d}from"../../core/promiseUtils.js";import{watch as p,on as c,when as u,whenOnce as h,initial as w}from"../../core/reactiveUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import y from"../../layers/GraphicsLayer.js";import{isEditableLayer as k}from"../../layers/support/editableLayers.js";import{getOwningPortalUrl as g,getEffectiveLayerCapabilities as v,isFeatureLayer as b}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as W}from"../../portal/support/urlUtils.js";import _ from"../Attachments/AttachmentsViewModel.js";import F from"./CreateFeaturesWorkflow.js";import C from"./CreateWorkflow.js";import{workflowDeprecation as E}from"./deprecationUtils.js";import I from"./UpdateWorkflow.js";import{whenEditorLayerView as U}from"./workflowUtils.js";import{formTemplateHasInvalidFields as A,unsupportedDateFieldTypes as O}from"../FeatureForm/featureFormUtils.js";import V from"../FeatureForm/FeatureFormViewModel.js";import j from"../FeatureTemplates/FeatureTemplatesViewModel.js";import M from"../Sketch/SketchViewModel.js";import T from"../Spinner/SpinnerViewModel.js";const S="esri.widgets.Editor.EditorViewModel",L=n.getLogger(S),P=["create","create-features","update"];function D(t,e,a){L.error(new i(t,e,a))}function G(t,e){return t?t.find((t=>t.layer===e)):void 0}let x=class extends(o(s.EventedAccessor)){constructor(t){super(t),this._editableItems=new a,this._sketchGraphicsLayer=new y({listMode:"hide",internal:!0}),this._updateEditableItemsTask=null,this.activeWorkflow=null,this._activityQueue=[],this.failures=[],this.attachmentsViewModel=new _({capabilities:{editing:!0}}),this.featureFormViewModel=new V,this.featureTemplatesViewModel=new j,this.sketchViewModel=new M({layer:this._sketchGraphicsLayer}),this.spinnerViewModel=new T,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.useDeprecatedCreateWorkflow=!1,this.back=async()=>{this.canGoBack&&await(this.activeWorkflow?.back(this.showDiscardEditsPrompt))},this.saveWorkflow=async()=>{const{featureFormViewModel:t}=this;if(t.submit(),!t.submittable)return;const e=t.getValues();t.validateContingencyConstraints(e,{includeIncompleteViolations:!0}).length>0||await(this.activeWorkflow?.save())},this.selectFeature=(t,e=!1)=>{const a=this.activeWorkflow;this._candidateCommitted||"update"!==a?.type||(a.data.rootFeature=t,e&&(a.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([p((()=>{const t=this.view?.map?.editableLayers.filter((({parent:t,visible:e})=>t&&"visible"in t?e&&t.visible:e)),e=this.view?.allLayerViews,a=e?.filter((e=>!!t?.includes(e.layer)&&!e.suspended));return[t,a,this.layerInfos,this.allowedWorkflows]}),(()=>this._updateEditableItems()),w),c((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),c((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),u((()=>this.view?.map),(t=>t.add(this._sketchGraphicsLayer)),w),p((()=>this._editableItems.toArray()),(()=>{const{activeWorkflow:t}=this;if(this.refreshCreationTemplates(),!t)return;const{stepId:e}=t;"create"!==t.type?"update"===t.type&&("awaiting-feature-to-update"===e&&!this.canUpdate||"awaiting-update-feature-candidate"===e&&!t.data.candidates.some((t=>{const e=this._editableItems.find((e=>e.layer===t.layer));return e&&e.supports.includes("update")})))&&this._cancelWorkflow():"awaiting-feature-creation-info"!==e||this.canCreate||this._cancelWorkflow()})),p((()=>this.page),((t,e)=>{const a=this.pageStack.slice(),r=a.indexOf(t);-1===r&&e?a.push(e):a.splice(r),this.pageStack=a})),u((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1)),c((()=>this.featureTemplatesViewModel),"select",(async({item:t,oldItem:e})=>{const{activeWorkflow:a}=this,r=!!t&&t.id===e?.id,i="create-features"===a?.type&&a.data.upload?.error;if(a)try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return this.featureTemplatesViewModel.select(e,{emit:!1})}if(!t||r&&!i)return;const s={layer:t.layer,template:t.template};if(t.supportsUpload)return this.startCreateFeaturesWorkflow(s);this.useDeprecatedCreateWorkflow?this.startCreateWorkflowAtFeatureCreation(s):this.startCreateFeaturesWorkflowAtFeatureCreation(s)})),c((()=>this.view),"key-down",(t=>{"Escape"===t.key&&this.activeWorkflow?.keyboardCancellationEnabled&&this.back()}))])}destroy(){this._cancelWorkflow().then((()=>{this.view?.map&&this.view.map.remove(this._sketchGraphicsLayer),this.view=null})),this._updateEditableItemsTask=l(this._updateEditableItemsTask)}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(t){t&&0!==t.length||(t=[...P]),this._set("allowedWorkflows",t)}get canCreate(){return this._editableItems.some((t=>t.supports.includes("create")))}get canUpdate(){return this._editableItems.some((({attachmentsOnUpdateEnabled:t,layer:e,supports:a})=>{const r=a.includes("update")||a.includes("delete")||t,i=e.parent,s=!(i&&"visible"in i)||!!i.visible;return e.visible&&s&&r}))}get editableItems(){return this._editableItems}get labelOptions(){return this.sketchViewModel.labelOptions}set labelOptions(t){this.sketchViewModel.labelOptions=t}set layerInfos(t){t?.some((t=>("allowAttachments"in t&&r(L,"Property: layerInfo.allowAttachments",{replacement:"layerInfo.attachmentsOnCreateEnabled or layerInfo.attachmentsOnUpdateEnabled",version:"4.26"}),!0))),this._set("layerInfos",t)}get snappingOptions(){return this.sketchViewModel.snappingOptions}set snappingOptions(t){this.sketchViewModel.snappingOptions=t}get state(){if(!this.get("view.ready")||0===this._editableItems.length)return"disabled";const t=this.attachmentsViewModel.mode;if("add"===t)return"adding-attachment";if("edit"===t)return"editing-attachment";const{activeWorkflow:e}=this;return e?e.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get updating(){return this.updatingHandles.updating}get tooltipOptions(){return this.sketchViewModel.tooltipOptions}set tooltipOptions(t){this.sketchViewModel.tooltipOptions=t}set view(t){this.sketchViewModel.view=t,this.spinnerViewModel.view=t,this._set("view",t)}get page(){const{activeWorkflow:t,state:e}=this;return"awaiting-feature-to-update"===e||"awaiting-feature-to-create"===e||"create-features"===t?.type&&0===t.numPendingFeatures?"ready":e??"disabled"}get selectedTemplateItem(){const{activeWorkflow:t}=this;if("create-features"===t?.type&&0===t.numPendingFeatures){const e=t.data.creationInfo?.template;if(!e)return;for(const t of this.featureTemplatesViewModel.items)if("findByTemplate"in t){const a=t.findByTemplate(e);if(a)return a}else if(t.template===e)return t}}get featureFormDisabled(){const{activeWorkflow:t}=this;return"update"===t?.type&&!1==!!t.activeEditableItem?.attributeUpdatesEnabled}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:t}=this;return!!t&&"update"===t.type&&!!t.activeEditableItem?.supports.includes("delete")}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}async startCreateWorkflowAtFeatureTypeSelection(){if(E(L,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),await h((()=>!this.updating)),!this.canCreate)return void D("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateWorkflowAtFeatureCreation(t){if(E(L,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),await h((()=>!this.updating)),!this.canCreate)return void D("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("awaiting-feature-to-create");e.data.creationInfo=t,await e.start(),this._set("activeWorkflow",e)}async startCreateFeaturesWorkflowAtFeatureCreation(t){return this.startCreateFeaturesWorkflow(t,"creating-features")}async startCreateFeaturesWorkflow(t,e="awaiting-feature-creation-info"){if(await h((()=>!this.updating)),!this.canCreate)throw new i("editing:unsupported-workflow","Creating features is unsupported or disabled.");await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow(t,e);await a.start(),this._set("activeWorkflow",a)}async startCreateWorkflowAtFeatureEdit(t){if(E(L,"startCreateWorkflowAtFeatureEdit"),await h((()=>!this.updating)),!this.canCreate)return void D("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("editing-new-feature");e.data.edits.feature=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureSelection(){if(await h((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtMultipleFeatureSelection(t){if(await h((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("awaiting-update-feature-candidate");e.data.candidates=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureEdit(t){if(await h((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("editing-existing-feature");e.data.rootFeature=t,await e.start(),this._set("activeWorkflow",e)}async deleteFeatureFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?await t.deleteActiveFeature():D("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(t){return this._cancelWorkflow({warn:!0,...t})}findEditableItemForLayer(t){const e="subtype-sublayer"===t.type?t.parent:t;return this._editableItems.find((t=>t.layer===e))}itemHasInvalidFormTemplate(t){return!!t&&(this.findEditableItemForLayer(t.layer)?.hasInvalidFormTemplate??!1)}itemHasUnsupportedFields(t){return!!t&&(this.findEditableItemForLayer(t.layer)?.hasUnsupportedFields??!1)}refreshCreationTemplates(){const t=[];for(const{layer:e,supports:a}of this._editableItems)e.loaded&&a.includes("create")&&t.push(e);this.featureTemplatesViewModel.layers=t}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!0}):await this.startUpdateWorkflowAtFeatureSelection()))}async _updateEditableItems(){l(this._updateEditableItemsTask);const t=e((async t=>{const e=this.view?.allLayerViews,r=this.view?.map,i=r?.editableLayers.toArray()??[],s=r?.allTables.toArray().filter(b)??[];await Promise.all(s.map((t=>t.load())));const o=s.filter((t=>k(t))),n=[...i.reverse(),...o.reverse()];if(!e||!i)return;const l=[],p=[];for(const a of n){const r=e.find((t=>t.layer===a)),i=r?l:p;if("subtype-group"===a.type){await a.loadAll(),d(t);for(let t=a.sublayers.length-1;t>=0;--t)i.push(this._makeEditableItemForLayer(a.sublayers.at(t),!!r?.suspended))}else i.push(this._makeEditableItemForLayer(a,!!r?.suspended))}if(t.aborted)return;const c=this._editableItems;this._editableItems=new a(l.concat(p)),c.destroy()}));this.updatingHandles.addPromise(t.promise),this._updateEditableItemsTask=t}async _cancelWorkflow(t){const e=this.activeWorkflow;if(!e)return void(t&&t.warn&&D("editing:no-active-workflow","There is no active workflow to cancel."));if(!t||!1!==t.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await e.cancel(t);await e.cancel(t),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(t,e){return F.create(this,t,e,((t,e,a)=>this._applyEdits(t,e,a)),((t,e)=>this._addAttachments(t,e)))}_createCreateWorkflow(t){return C.create(this,t,((t,e,a)=>this._applyEdits(t,e,a)))}_createUpdateWorkflow(t){return I.create(this,t,((t,e)=>this._applyEdits(t,e)))}_addAttachments(t,e){const a=e.map((e=>this._addAttachment(t,e.feature,e.attachment)))??[];return Promise.all(a)}async _addAttachment(t,e,a){let r=null;if("geojson"===t.type||"scene"===t.type||"oriented-imagery"===t.type)throw new i("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(r=await(t.addAttachment?.(e,a).catch((t=>{throw t?.error||t})))??null,r))),r}async _applyEdits(t,e,a){let r=null;const i=t.url?await g(t.url):null,s={returnServiceEditsOption:(!i||!W(i))&&!RegExp("/hosted/","i").test(t.url)?"original-and-current-features":void 0,...a};return await this._queueOperation((async()=>{const a=await U(this.view,t).catch((()=>null));return r=await t.applyEdits(e,s),a&&await h((()=>!a.updating)),r})),r}_queueOperation(t){this._activityQueue.push(t),this.notifyChange("syncing");const e=(t,e)=>{const a=e.indexOf(t);a>-1&&e.splice(a,1)};return t().then((t=>{if("error"in t&&t.error)throw t.error;if("addFeatureResults"in t){const{addFeatureResults:e,deleteFeatureResults:a,updateFeatureResults:r}=t,i=e.find((t=>!!t.error))||r.find((t=>!!t.error))||a.find((t=>!!t.error));if(i)throw i.error}return t})).catch((a=>{D("editing:operation-error","An error occurred.",{error:a});const r={error:a,retry:()=>(e(r,this.failures),this._queueOperation(t)),cancel:()=>{e(r,this.failures)}};this._set("failures",[...this.failures,r])})).then((()=>{e(t,this._activityQueue),this.notifyChange("syncing")}))}_makeEditableItemForLayer(t,e=!0){const a=v(t),r=a?.operations,i=G(this.layerInfos,t),s=A(t),o=t.fields.some((({type:t})=>O.has(t))),n=s||o,{allowedWorkflows:l}=this,d=l.includes("create")||l.includes("create-features"),p=l.includes("update"),c=t=>!i||!1!==i.enabled&&!1!==i[t],u=d&&!!r?.supportsAdd&&c("addEnabled"),h=p&&!!r?.supportsUpdate&&c("updateEnabled"),w=!n&&p&&!!r?.supportsDelete&&c("deleteEnabled"),f=[];e||(u&&f.push("create"),h&&f.push("update"),w&&f.push("delete"));const m=h&&!n&&(!i||!1!==i.attributeUpdatesEnabled),y=h&&!n&&!!a?.editing?.supportsGeometryUpdate&&(!i||!1!==i.geometryUpdatesEnabled),k=!(!a?.data?.supportsAttachment||i&&!1===i.allowAttachments);return{layer:t,supports:f,attributeUpdatesEnabled:m,geometryUpdatesEnabled:y,hasAttachments:k,attachmentsOnCreateEnabled:k&&d&&(!i||!1!==i.attachmentsOnCreateEnabled),attachmentsOnUpdateEnabled:!n&&k&&(!i||!1!==i.attachmentsOnUpdateEnabled),hasInvalidFormTemplate:s,hasUnsupportedFields:o}}};t([f()],x.prototype,"_editableItems",void 0),t([f({readOnly:!0})],x.prototype,"activeWorkflow",void 0),t([f({readOnly:!0})],x.prototype,"_activityQueue",void 0),t([f({value:[...P]})],x.prototype,"allowedWorkflows",null),t([f({readOnly:!0})],x.prototype,"canCreate",null),t([f({readOnly:!0})],x.prototype,"canUpdate",null),t([f()],x.prototype,"editableItems",null),t([f({readOnly:!0})],x.prototype,"failures",void 0),t([f()],x.prototype,"attachmentsViewModel",void 0),t([f()],x.prototype,"featureFormViewModel",void 0),t([f()],x.prototype,"featureTemplatesViewModel",void 0),t([f()],x.prototype,"labelOptions",null),t([f()],x.prototype,"layerInfos",null),t([f()],x.prototype,"sketchViewModel",void 0),t([f()],x.prototype,"snappingOptions",null),t([f()],x.prototype,"spinnerViewModel",void 0),t([f()],x.prototype,"state",null),t([f({readOnly:!0})],x.prototype,"syncing",null),t([f()],x.prototype,"updating",null),t([f()],x.prototype,"tooltipOptions",null),t([f()],x.prototype,"view",null),t([f()],x.prototype,"pageStack",void 0),t([f()],x.prototype,"showDiscardEditsPrompt",void 0),t([f()],x.prototype,"_candidateCommitted",void 0),t([f()],x.prototype,"page",null),t([f()],x.prototype,"selectedTemplateItem",null),t([f()],x.prototype,"featureFormDisabled",null),t([f()],x.prototype,"canGoBack",null),t([f()],x.prototype,"shouldShowDeleteButton",null),t([f()],x.prototype,"hasPendingEdits",null),t([f()],x.prototype,"useDeprecatedCreateWorkflow",void 0),x=t([m(S)],x);const B=x;export{B as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import{createTask as e}from"../../core/asyncUtils.js";import a from"../../core/Collection.js";import{deprecated as r}from"../../core/deprecate.js";import i from"../../core/Error.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import n from"../../core/Logger.js";import{abortMaybe as l}from"../../core/maybe.js";import{throwIfAborted as d}from"../../core/promiseUtils.js";import{watch as p,on as c,when as u,whenOnce as h,initial as w}from"../../core/reactiveUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as m}from"../../core/accessorSupport/decorators/subclass.js";import y from"../../layers/GraphicsLayer.js";import{isEditableLayer as k}from"../../layers/support/editableLayers.js";import{getOwningPortalUrl as g,getEffectiveLayerCapabilities as v,isFeatureLayer as b}from"../../layers/support/layerUtils.js";import{parseKnownArcGISOnlineDomain as W}from"../../portal/support/urlUtils.js";import _ from"../Attachments/AttachmentsViewModel.js";import F from"./CreateFeaturesWorkflow.js";import C from"./CreateWorkflow.js";import{workflowDeprecation as E}from"./deprecationUtils.js";import I from"./UpdateWorkflow.js";import{whenEditorLayerView as U}from"./workflowUtils.js";import{formTemplateHasInvalidFields as A,unsupportedDateFieldTypes as O}from"../FeatureForm/featureFormUtils.js";import V from"../FeatureForm/FeatureFormViewModel.js";import M from"../FeatureTemplates/FeatureTemplatesViewModel.js";import j from"../Sketch/SketchViewModel.js";import T from"../Spinner/SpinnerViewModel.js";const S="esri.widgets.Editor.EditorViewModel",L=n.getLogger(S),P=["create","create-features","update"];function D(t,e,a){L.error(new i(t,e,a))}function G(t,e){return t?t.find((t=>t.layer===e)):void 0}let x=class extends(o(s.EventedAccessor)){constructor(t){super(t),this._editableItems=new a,this._sketchGraphicsLayer=new y({listMode:"hide",internal:!0}),this._updateEditableItemsTask=null,this.activeWorkflow=null,this._activityQueue=[],this.failures=[],this.attachmentsViewModel=new _({capabilities:{editing:!0}}),this.featureFormViewModel=new V,this.featureTemplatesViewModel=new M,this.sketchViewModel=new j({layer:this._sketchGraphicsLayer}),this.spinnerViewModel=new T,this.pageStack=[],this.showDiscardEditsPrompt=()=>Promise.resolve(!0),this._candidateCommitted=!1,this.useDeprecatedCreateWorkflow=!1,this.back=async()=>{this.canGoBack&&(this.activeWorkflow?.hasPreviousStep?await this.activeWorkflow.back(this.showDiscardEditsPrompt):await this._cancelWorkflow({force:!this.hasPendingEdits}))},this.saveWorkflow=async()=>{const{featureFormViewModel:t}=this;if(t.submit(),!t.submittable)return;const e=t.getValues();t.validateContingencyConstraints(e,{includeIncompleteViolations:!0}).length>0||await(this.activeWorkflow?.save())},this.selectFeature=(t,e=!1)=>{const a=this.activeWorkflow;this._candidateCommitted||"update"!==a?.type||(a.data.rootFeature=t,e&&(a.next(),this._candidateCommitted=!0))}}initialize(){this.addHandles([p((()=>{const t=this.view?.map?.editableLayers.filter((({parent:t,visible:e})=>t&&"visible"in t?e&&t.visible:e)),e=this.view?.allLayerViews,a=e?.filter((e=>!!t?.includes(e.layer)&&!e.suspended));return[t,a,this.layerInfos,this.allowedWorkflows]}),(()=>this._updateEditableItems()),w),c((()=>this.activeWorkflow),"cancel",(()=>this.emit("workflow-cancel"))),c((()=>this.activeWorkflow),"commit",(()=>this.emit("workflow-commit"))),c((()=>this.activeWorkflow),"complete",(()=>{this.emit("workflow-commit"),this._set("activeWorkflow",null)})),u((()=>this.view?.map),(t=>t.add(this._sketchGraphicsLayer)),w),p((()=>this._editableItems.toArray()),(()=>{const{activeWorkflow:t}=this;if(this.refreshCreationTemplates(),!t)return;const{stepId:e}=t;"create"!==t.type?"update"===t.type&&("awaiting-feature-to-update"===e&&!this.canUpdate||"awaiting-update-feature-candidate"===e&&!t.data.candidates.some((t=>{const e=this._editableItems.find((e=>e.layer===t.layer));return e&&e.supports.includes("update")})))&&this._cancelWorkflow():"awaiting-feature-creation-info"!==e||this.canCreate||this._cancelWorkflow()})),p((()=>this.page),((t,e)=>{const a=this.pageStack.slice(),r=a.indexOf(t);-1===r&&e?a.push(e):a.splice(r),this.pageStack=a})),u((()=>"awaiting-update-feature-candidate"===this.state),(()=>this._candidateCommitted=!1)),c((()=>this.featureTemplatesViewModel),"select",(async({item:t,oldItem:e})=>{const{activeWorkflow:a}=this,r=!!t&&t.id===e?.id,i="create-features"===a?.type&&a.data.upload?.error;if(a)try{await this.cancelWorkflow({force:!this.hasPendingEdits})}catch{return this.featureTemplatesViewModel.select(e,{emit:!1})}if(!t||r&&!i)return;const s={layer:t.layer,template:t.template};if(t.supportsUpload)return this.startCreateFeaturesWorkflow(s);this.useDeprecatedCreateWorkflow?this.startCreateWorkflowAtFeatureCreation(s):this.startCreateFeaturesWorkflowAtFeatureCreation(s)})),c((()=>this.view),"key-down",(t=>{"Escape"===t.key&&this.activeWorkflow?.keyboardCancellationEnabled&&this.back()}))])}destroy(){this._cancelWorkflow().then((()=>{this.view?.map&&this.view.map.remove(this._sketchGraphicsLayer),this.view=null})),this._updateEditableItemsTask=l(this._updateEditableItemsTask)}get allowedWorkflows(){return this._get("allowedWorkflows")}set allowedWorkflows(t){t&&0!==t.length||(t=[...P]),this._set("allowedWorkflows",t)}get canCreate(){return this._editableItems.some((t=>t.supports.includes("create")))}get canUpdate(){return this._editableItems.some((({attachmentsOnUpdateEnabled:t,layer:e,supports:a})=>{const r=a.includes("update")||a.includes("delete")||t,i=e.parent,s=!(i&&"visible"in i)||!!i.visible;return e.visible&&s&&r}))}get editableItems(){return this._editableItems}get labelOptions(){return this.sketchViewModel.labelOptions}set labelOptions(t){this.sketchViewModel.labelOptions=t}set layerInfos(t){t?.some((t=>("allowAttachments"in t&&r(L,"Property: layerInfo.allowAttachments",{replacement:"layerInfo.attachmentsOnCreateEnabled or layerInfo.attachmentsOnUpdateEnabled",version:"4.26"}),!0))),this._set("layerInfos",t)}get snappingOptions(){return this.sketchViewModel.snappingOptions}set snappingOptions(t){this.sketchViewModel.snappingOptions=t}get state(){if(!this.get("view.ready")||0===this._editableItems.length)return"disabled";const t=this.attachmentsViewModel.mode;if("add"===t)return"adding-attachment";if("edit"===t)return"editing-attachment";const{activeWorkflow:e}=this;return e?e.stepId:"ready"}get syncing(){return this._activityQueue.length>0}get updating(){return this.updatingHandles.updating}get tooltipOptions(){return this.sketchViewModel.tooltipOptions}set tooltipOptions(t){this.sketchViewModel.tooltipOptions=t}set view(t){this.sketchViewModel.view=t,this.spinnerViewModel.view=t,this._set("view",t)}get page(){const{activeWorkflow:t,state:e}=this;return"awaiting-feature-to-update"===e||"awaiting-feature-to-create"===e||"create-features"===t?.type&&0===t.numPendingFeatures?"ready":e??"disabled"}get selectedTemplateItem(){const{activeWorkflow:t}=this;if("create-features"===t?.type&&0===t.numPendingFeatures){const e=t.data.creationInfo?.template;if(!e)return;for(const t of this.featureTemplatesViewModel.items)if("findByTemplate"in t){const a=t.findByTemplate(e);if(a)return a}else if(t.template===e)return t}}get featureFormDisabled(){const{activeWorkflow:t}=this;return"update"===t?.type&&!1===t.activeEditableItem?.attributeUpdatesEnabled}get canGoBack(){return null!=this.activeWorkflow&&!this.syncing}get shouldShowDeleteButton(){const{activeWorkflow:t}=this;return!!t&&"update"===t.type&&!!t.activeEditableItem?.supports.includes("delete")}get hasPendingEdits(){return this.activeWorkflow?.hasPendingEdits??!1}async startCreateWorkflowAtFeatureTypeSelection(){if(E(L,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),await h((()=>!this.updating)),!this.canCreate)return void D("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createCreateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.startCreateFeaturesWorkflow()}async startCreateWorkflowAtFeatureCreation(t){if(E(L,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),await h((()=>!this.updating)),!this.canCreate)return void D("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("awaiting-feature-to-create");e.data.creationInfo=t,await e.start(),this._set("activeWorkflow",e)}async startCreateFeaturesWorkflowAtFeatureCreation(t){return this.startCreateFeaturesWorkflow(t,"creating-features")}async startCreateFeaturesWorkflow(t,e="awaiting-feature-creation-info"){if(await h((()=>!this.updating)),!this.canCreate)throw new i("editing:unsupported-workflow","Creating features is unsupported or disabled.");await this._cancelWorkflow();const a=this._createCreateFeaturesWorkflow(t,e);await a.start(),this._set("activeWorkflow",a)}async startCreateWorkflowAtFeatureEdit(t){if(E(L,"startCreateWorkflowAtFeatureEdit"),await h((()=>!this.updating)),!this.canCreate)return void D("editing:unsupported-workflow","Create workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createCreateWorkflow("editing-new-feature");e.data.edits.feature=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureSelection(){if(await h((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const t=this._createUpdateWorkflow();await t.start(),this._set("activeWorkflow",t)}async startUpdateWorkflowAtMultipleFeatureSelection(t){if(await h((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("awaiting-update-feature-candidate");e.data.candidates=t,await e.start(),this._set("activeWorkflow",e)}async startUpdateWorkflowAtFeatureEdit(t){if(await h((()=>!this.updating)),!this.canUpdate)return void D("editing:unsupported-workflow","Update workflow is unsupported or disabled.");await this._cancelWorkflow();const e=this._createUpdateWorkflow("editing-existing-feature");e.data.rootFeature=t,await e.start(),this._set("activeWorkflow",e)}async deleteFeatureFromWorkflow(){const{activeWorkflow:t}=this;t&&"update"===t.type?await t.deleteActiveFeature():D("editing:unsupported-workflow","Deleting requires an active update workflow.")}async cancelWorkflow(t){return this._cancelWorkflow({warn:!0,...t})}findEditableItemForLayer(t){const e="subtype-sublayer"===t.type?t.parent:t;return this._editableItems.find((t=>t.layer===e))}itemHasInvalidFormTemplate(t){return!!t&&(this.findEditableItemForLayer(t.layer)?.hasInvalidFormTemplate??!1)}itemHasUnsupportedFields(t){return!!t&&(this.findEditableItemForLayer(t.layer)?.hasUnsupportedFields??!1)}refreshCreationTemplates(){const t=[];for(const{layer:e,supports:a}of this._editableItems)e.loaded&&a.includes("create")&&t.push(e);this.featureTemplatesViewModel.layers=t}async toggleUpdateWorkflow(){this.canUpdate&&(this.hasPendingEdits&&!await this.showDiscardEditsPrompt()||(this.activeWorkflow&&"awaiting-feature-to-update"===this.state?await this.cancelWorkflow({force:!0}):await this.startUpdateWorkflowAtFeatureSelection()))}async _updateEditableItems(){l(this._updateEditableItemsTask);const t=e((async t=>{const e=this.view?.allLayerViews,r=this.view?.map,i=r?.editableLayers.toArray()??[],s=r?.allTables.toArray().filter(b)??[];await Promise.all(s.map((t=>t.load())));const o=s.filter((t=>k(t))),n=[...i.reverse(),...o.reverse()].filter((t=>"mesh"!==t.geometryType&&"multipatch"!==t.geometryType||"3d"===this.view?.type));if(!e||!i)return;const l=[],p=[];for(const a of n){const r=e.find((t=>t.layer===a)),i=r?l:p;if("subtype-group"===a.type){await a.loadAll(),d(t);for(let t=a.sublayers.length-1;t>=0;--t)i.push(this._makeEditableItemForLayer(a.sublayers.at(t),!!r?.suspended))}else i.push(this._makeEditableItemForLayer(a,!!r?.suspended))}if(t.aborted)return;const c=this._editableItems;this._editableItems=new a(l.concat(p)),c.destroy()}));this.updatingHandles.addPromise(t.promise),this._updateEditableItemsTask=t}async _cancelWorkflow(t){const e=this.activeWorkflow;if(!e)return void(t&&t.warn&&D("editing:no-active-workflow","There is no active workflow to cancel."));if(!t||!1!==t.force)return this.emit("workflow-cancel"),this._set("activeWorkflow",null),void await e.cancel(t);await e.cancel(t),this._set("activeWorkflow",null)}_createCreateFeaturesWorkflow(t,e){return F.create({viewModel:this,creationInfo:t,startAt:e,applyEditsCallback:(t,e,a)=>this._applyEdits(t,e,a),addAttachmentsCallback:(t,e)=>this._addAttachments(t,e)})}_createCreateWorkflow(t){return C.create(this,t,((t,e,a)=>this._applyEdits(t,e,a)))}_createUpdateWorkflow(t){return I.create(this,t,((t,e)=>this._applyEdits(t,e)))}_addAttachments(t,e){const a=e.map((e=>this._addAttachment(t,e.feature,e.attachment)))??[];return Promise.all(a)}async _addAttachment(t,e,a){let r=null;if("geojson"===t.type||"scene"===t.type||"oriented-imagery"===t.type)throw new i("editor:attachments-not-supported","Adding attachments is not supported for this layer type");return await this._queueOperation((async()=>(r=await(t.addAttachment?.(e,a).catch((t=>{throw t?.error||t})))??null,r))),r}async _applyEdits(t,e,a){let r=null;const i=t.url?await g(t.url):null,s={returnServiceEditsOption:(!i||!W(i))&&!RegExp("/hosted/","i").test(t.url)?"original-and-current-features":void 0,...a};return await this._queueOperation((async()=>{const a=await U(this.view,t).catch((()=>null));return r=await t.applyEdits(e,s),a&&await h((()=>!a.updating)),r})),r}_queueOperation(t){this._activityQueue.push(t),this.notifyChange("syncing");const e=(t,e)=>{const a=e.indexOf(t);a>-1&&e.splice(a,1)};return t().then((t=>{if("error"in t&&t.error)throw t.error;if("addFeatureResults"in t){const{addFeatureResults:e,deleteFeatureResults:a,updateFeatureResults:r}=t,i=e.find((t=>!!t.error))||r.find((t=>!!t.error))||a.find((t=>!!t.error));if(i)throw i.error}return t})).catch((a=>{D("editing:operation-error","An error occurred.",{error:a});const r={error:a,retry:()=>(e(r,this.failures),this._queueOperation(t)),cancel:()=>{e(r,this.failures)}};this._set("failures",[...this.failures,r])})).then((()=>{e(t,this._activityQueue),this.notifyChange("syncing")}))}_makeEditableItemForLayer(t,e=!0){const a=v(t),r=a?.operations,i=G(this.layerInfos,t),s=A(t),o=t.fields.some((({type:t})=>O.has(t))),n=s||o,{allowedWorkflows:l}=this,d=l.includes("create")||l.includes("create-features"),p=l.includes("update"),c=t=>!i||!1!==i.enabled&&!1!==i[t],u=d&&!!r?.supportsAdd&&c("addEnabled"),h=p&&!!r?.supportsUpdate&&c("updateEnabled"),w=!n&&p&&!!r?.supportsDelete&&c("deleteEnabled"),f=[];e||(u&&f.push("create"),h&&f.push("update"),w&&f.push("delete"));const m=h&&!n&&(!i||!1!==i.attributeUpdatesEnabled),y=h&&!n&&!!a?.editing?.supportsGeometryUpdate&&(!i||!1!==i.geometryUpdatesEnabled),k=!(!a?.data?.supportsAttachment||i&&!1===i.allowAttachments);return{layer:t,supports:f,attributeUpdatesEnabled:m,geometryUpdatesEnabled:y,hasAttachments:k,attachmentsOnCreateEnabled:k&&d&&(!i||!1!==i.attachmentsOnCreateEnabled),attachmentsOnUpdateEnabled:!n&&k&&(!i||!1!==i.attachmentsOnUpdateEnabled),hasInvalidFormTemplate:s,hasUnsupportedFields:o}}};t([f()],x.prototype,"_editableItems",void 0),t([f({readOnly:!0})],x.prototype,"activeWorkflow",void 0),t([f({readOnly:!0})],x.prototype,"_activityQueue",void 0),t([f({value:[...P]})],x.prototype,"allowedWorkflows",null),t([f({readOnly:!0})],x.prototype,"canCreate",null),t([f({readOnly:!0})],x.prototype,"canUpdate",null),t([f()],x.prototype,"editableItems",null),t([f({readOnly:!0})],x.prototype,"failures",void 0),t([f()],x.prototype,"attachmentsViewModel",void 0),t([f()],x.prototype,"featureFormViewModel",void 0),t([f()],x.prototype,"featureTemplatesViewModel",void 0),t([f()],x.prototype,"labelOptions",null),t([f()],x.prototype,"layerInfos",null),t([f()],x.prototype,"sketchViewModel",void 0),t([f()],x.prototype,"snappingOptions",null),t([f()],x.prototype,"spinnerViewModel",void 0),t([f()],x.prototype,"state",null),t([f({readOnly:!0})],x.prototype,"syncing",null),t([f()],x.prototype,"updating",null),t([f()],x.prototype,"tooltipOptions",null),t([f()],x.prototype,"view",null),t([f()],x.prototype,"pageStack",void 0),t([f()],x.prototype,"showDiscardEditsPrompt",void 0),t([f()],x.prototype,"_candidateCommitted",void 0),t([f()],x.prototype,"page",null),t([f()],x.prototype,"selectedTemplateItem",null),t([f()],x.prototype,"featureFormDisabled",null),t([f()],x.prototype,"canGoBack",null),t([f()],x.prototype,"shouldShowDeleteButton",null),t([f()],x.prototype,"hasPendingEdits",null),t([f()],x.prototype,"useDeprecatedCreateWorkflow",void 0),x=t([m(S)],x);const B=x;export{B as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Error.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{sceneLayerEditingEnabled as o,i3sPatchingEnabled as s}from"../../support/featureFlags.js";import{highlightsSupported as a}from"../../views/support/layerViewUtils.js";import l from"./UpdateFeatureWorkflowData.js";import{HANDLE_KEYS as n,UpdateRecordWorkflow as c}from"./UpdateRecordWorkflow.js";import{canCreateInteractiveEditSession as d,getVisualVariableAttributes as h,setUpGeometryUpdate as p,isTerminalUpdateEventType as u}from"./workflowUtils.js";var m;const y={...n,highlights:Symbol(),interactiveGraphics:Symbol(),geometryGraphics:Symbol()};let w=m=class extends c{constructor(e){super(e),this.type="update-feature",this._layerViewEditSession=null,this._webStyleCache=new Map}async initialize(){const{edits:{feature:e},layerView:t}=this.data;d(t)&&(this._layerViewEditSession=t.createInteractiveEditSession(e))}destroy(){this._layerViewEditSession?.rollback()}async commit(){this.removeHandles(y.interactiveGraphics);try{await super.commit(),this.removeHandles(y.geometryGraphics),this._layerViewEditSession?.commit()}catch(e){throw this.removeHandles(y.geometryGraphics),await this._configureSketchViewModel(),new t("editor-workflow:failed-to-commit","An error occurred when sending the updates to the service",{error:e})}}async enter(){await super.enter(),this.data.editableItem.geometryUpdatesEnabled?this.hasHandles(y.interactiveGraphics)||await this._configureSketchViewModel():this._configureHighlight()}exit(e={removeSketchHandles:!0}){super.exit(e),e.removeSketchHandles&&this.removeHandles([y.geometryGraphics,y.interactiveGraphics])}_configureFeatureFormViewModel(){super._configureFeatureFormViewModel();const{_layerViewEditSession:e}=this,{viewModel:t}=this.data;this.addHandles(t.featureFormViewModel.on("value-change",(t=>{e?.setAttribute(t.fieldName,t.value)})),y.exit)}_configureHighlight(){const{edits:e,layerView:t}=this.data;a(t)&&this.addHandles(t.highlight(e.feature),y.highlights)}async _configureSketchViewModel(){const{data:e,_layerViewEditSession:t}=this,{edits:r,viewModel:i}=e,a=r.feature,{featureFormViewModel:l,sketchViewModel:n,view:c}=i;n.allowDeleteKey=!1;const d=h(a),{interactive:m,visual:w}=await p(a,d,n,c,(({geometry:e,attributes:i},n)=>{if(r.updateAttributes(i),r.updateGeometry(e),l.feature.geometry=e,null!=d.rotation){const{field:e}=d.rotation;l.setValue(e,i[e])}if(null!=d.size){const{field:e}=d.size;l.setValue(e,i[e])}const{sourceLayer:c}=a;null!=c&&"scene"===c.type&&null!=c.infoFor3D&&o()&&s()&&t&&null!=e&&"mesh"===e.type&&t.setGeometry(e),("undo"===n.type||"redo"===n.type||"update"===n.type&&null!=n.toolEventInfo&&u(n.toolEventInfo.type))&&l.notifyFeatureGeometryChanged()}),this._webStyleCache);this.addHandles(m,y.interactiveGraphics),this.addHandles(w,y.geometryGraphics)}_onFullFeatureLoaded(e){super._onFullFeatureLoaded(e);const{edits:t}=this.data;t.updateGeometry(e.geometry),t.trackChanges()}static async create(e){const t=new m({data:await l.create(e),onCommit:this._onCommitFactory(e.applyEdits)});return t._set("steps",this._createWorkflowSteps(t)),t}};e([r()],w.prototype,"_layerViewEditSession",void 0),w=m=e([i("esri.widgets.Editor.UpdateFeatureWorkflow")],w);export{y as HANDLE_KEYS,w as UpdateFeatureWorkflow};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Error.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{sceneLayerEditingEnabled as o,i3sPatchingEnabled as s}from"../../support/featureFlags.js";import{highlightsSupported as a}from"../../views/support/layerViewUtils.js";import l from"./UpdateFeatureWorkflowData.js";import{HANDLE_KEYS as n,UpdateRecordWorkflow as c}from"./UpdateRecordWorkflow.js";import{canCreateInteractiveEditSession as d,getVisualVariableAttributes as h,setUpGeometryUpdate as p,isTerminalUpdateEventType as u}from"./workflowUtils.js";var m;const y={...n,highlights:Symbol(),interactiveGraphics:Symbol(),geometryGraphics:Symbol()};let w=m=class extends c{constructor(e){super(e),this.type="update-feature",this._layerViewEditSession=null,this._webStyleCache=new Map}async initialize(){const{edits:{feature:e},layerView:t}=this.data;d(t)&&(this._layerViewEditSession=t.createInteractiveEditSession(e))}destroy(){this._layerViewEditSession?.rollback()}async commit(){this.removeHandles(y.interactiveGraphics);try{const e=this.data.edits.stagedForDelete;await super.commit(),this.removeHandles(y.geometryGraphics);const t=this._layerViewEditSession;e?t?.rollback():t?.commit()}catch(e){throw this.removeHandles(y.geometryGraphics),await this._configureSketchViewModel(),new t("editor-workflow:failed-to-commit","An error occurred when sending the updates to the service",{error:e})}}async enter(){await super.enter(),this.data.editableItem.geometryUpdatesEnabled?this.hasHandles(y.interactiveGraphics)||await this._configureSketchViewModel():this._configureHighlight()}exit(e={removeSketchHandles:!0}){super.exit(e),e.removeSketchHandles&&this.removeHandles([y.geometryGraphics,y.interactiveGraphics])}_configureFeatureFormViewModel(){super._configureFeatureFormViewModel();const{_layerViewEditSession:e}=this,{viewModel:t}=this.data;this.addHandles(t.featureFormViewModel.on("value-change",(t=>{e?.setAttribute(t.fieldName,t.value)})),y.exit)}_configureHighlight(){const{edits:e,layerView:t}=this.data;a(t)&&this.addHandles(t.highlight(e.feature),y.highlights)}async _configureSketchViewModel(){const{data:e,_layerViewEditSession:t}=this,{edits:r,viewModel:i}=e,a=r.feature,{featureFormViewModel:l,sketchViewModel:n,view:c}=i;n.allowDeleteKey=!1;const d=h(a),{interactive:m,visual:w}=await p(a,d,n,c,(({geometry:e,attributes:i},n)=>{if(r.updateAttributes(i),r.updateGeometry(e),l.feature.geometry=e,null!=d.rotation){const{field:e}=d.rotation;l.setValue(e,i[e])}if(null!=d.size){const{field:e}=d.size;l.setValue(e,i[e])}const{sourceLayer:c}=a;null!=c&&"scene"===c.type&&null!=c.infoFor3D&&o()&&s()&&t&&null!=e&&"mesh"===e.type&&t.setGeometry(e),("undo"===n.type||"redo"===n.type||"update"===n.type&&null!=n.toolEventInfo&&u(n.toolEventInfo.type))&&l.notifyFeatureGeometryChanged()}),this._webStyleCache);this.addHandles(m,y.interactiveGraphics),this.addHandles(w,y.geometryGraphics)}_onFullFeatureLoaded(e){super._onFullFeatureLoaded(e);const{edits:t}=this.data;t.updateGeometry(e.geometry),t.trackChanges()}static async create(e){const t=new m({data:await l.create(e),onCommit:this._onCommitFactory(e.applyEdits)});return t._set("steps",this._createWorkflowSteps(t)),t}};e([r()],w.prototype,"_layerViewEditSession",void 0),w=m=e([i("esri.widgets.Editor.UpdateFeatureWorkflow")],w);export{y as HANDLE_KEYS,w as UpdateFeatureWorkflow};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Error.js";import{makeHandle as a}from"../../core/handleUtils.js";import{abortMaybe as i}from"../../core/maybe.js";import{onAbort as o,createAbortError as r,throwIfAborted as s,debounce as n}from"../../core/promiseUtils.js";import l from"../../core/Queue.js";import{whenOnce as d,watch as c}from"../../core/reactiveUtils.js";import{property as p}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as w}from"../../core/accessorSupport/decorators/subclass.js";import{isNonSpatialTable as u}from"../../layers/support/layerUtils.js";import{highlightsSupported as h}from"../../views/support/layerViewUtils.js";import{UpdateFeatureWorkflow as f}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as m}from"./UpdateRecordWorkflow.js";import g from"./UpdateWorkflowData.js";import k from"./Workflow.js";import{createWorkflowSteps as y,fetchCandidates as v}from"./workflowUtils.js";var W;const _="candidate-highlight",b="esri.widgets.Editor.UpdateWorkflow";let S=W=class extends k{constructor(t){super(t),this._workflowStack=new l((t=>{let e;for(e of t);return e})),this.type="update"}initialize(){const{featureFormViewModel:t}=this.data.viewModel,e=t.relatedRecordCallbacks;t.relatedRecordCallbacks={addRelatedRecord:()=>{},editRelatedRecord:({relatedFeature:t})=>this.startUpdating(t)},this.addHandles(a((()=>t.relatedRecordCallbacks=e)))}get activeEditableItem(){const{activeWorkflow:t}=this;return U(t)?t.data.editableItem:void 0}get activeWorkflow(){return this._workflowStack.last()}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return!!this.activeEditableItem?.attachmentsOnUpdateEnabled}get shouldAllowAttachmentEditing(){return!!this.activeEditableItem?.supports.includes("update")}get hasPendingEdits(){return Array.from(this._workflowStack).some((t=>t.hasPendingEdits))}get helpMessage(){return"awaiting-feature-to-update"===this.stepId?"select":void 0}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return!!this.activeEditableItem?.hasInvalidFormTemplate}get hasUnsupportedFields(){return!!this.activeEditableItem?.hasUnsupportedFields}get updating(){return this.updatingHandles.updating}async back(t){this.activeWorkflow?(this.activeWorkflow.hasPendingEdits&&await(t?.()),await this.cancelActiveWorkflow({force:!0})):this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0})}async cancelActiveWorkflow(t){await(this.activeWorkflow?.cancel(t)),await this._popWorkflow()}async commit(){await this._drainWorkflowStack((t=>t.commit())),await super.commit()}static create(t,e,a){const i=new W({data:new g({applyEditsCallback:a,viewModel:t}),onCommit:async()=>{}});return i._set("steps",this._createWorkflowSteps(i,e)),i}async save(){this.nestedWorkflowCount>1?(await(this.activeWorkflow?.commit()),await this._popWorkflow()):await this.commit()}async startUpdating(t){try{const e=await this._createNestedWorkflow(t);await this._pushWorkflow(e)}catch(a){throw new e("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:a})}}async deleteActiveFeature(){const{activeWorkflow:t}=this;if(!t)throw new e("editor:nothing-to-delete","There is no feature to delete");U(t)?await t.deleteAndCommit():await t.cancel()}async cancelAll(){await this._drainWorkflowStack((t=>t.cancel({force:!0})))}async _createNestedWorkflow(t){const e=u(t.sourceLayer)?m:f,{applyEditsCallback:a,viewModel:i}=this.data,o=await e.create({feature:t,viewModel:i,applyEdits:a});return await d((()=>!o.updating)),o}async _drainWorkflowStack(t){const e=this._workflowStack,a=[];for(;e.length>0;){const i=e.pop(),o=t(i).then((()=>i.destroy()));this.updatingHandles.addPromise(o),a.push(o)}await Promise.all(a)}_highlight(t){const e=this.data.viewModel.view;if(!e||!t)return;const a=t&&e.allLayerViews.items.find((({layer:e})=>e===t.layer||"subtype-sublayer"===t.layer?.type&&t.layer?.parent===e));h(a)&&this.handles.add(a.highlight(t),_)}async _popWorkflow(){this._workflowStack.pop()?.destroy();const t=await this._reconcileWorkflowStack();if(t.failureCount>0)throw new e("editor:next-workflow-failed","Popped the top workflow, but the next workflow in the stack failed to activate",t)}async _pushWorkflow(t){const a="update-feature"===t.type||"create-features"===t.type;this.activeWorkflow?.exit({removeSketchHandles:a}),await t.start(),this._workflowStack.push(t);const i=await this._reconcileWorkflowStack();if(i.failureCount>0)throw new e("editor:failed-to-start-updating-feature","Failed to enter the provided workflow.",i)}async _reconcileWorkflowStack(){const t=this._workflowStack;try{const e=t.peek();return await(e?.enter()),{activeWorkflow:e,failureCount:0}}catch(e){t.pop().destroy();const{activeWorkflow:a,failureCount:i}=await this._reconcileWorkflowStack();return{activeWorkflow:a,failureCount:i+1}}}_unhighlight(){this.handles.remove(_)}static _createWorkflowSteps(t,l="awaiting-feature-to-update"){const{data:p,handles:w}=t;return y(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],l,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:e}=p.viewModel,n=p.viewModel.view;let l=null;w.add(a((()=>{l=i(l)})),this.id),p.rootFeature=null,p.candidates=[];const d=n.on("immediate-click",(async a=>{e.location=a.mapPoint,e.visible=!0,l?.abort();const{editableItems:i}=p.viewModel;l=new AbortController;const d=await new Promise(((t,e)=>{o(l?.signal,(()=>e(r()))),t(v(i,n,a,l?.signal))}));s(l),p.candidates=d.reduce(((t,e)=>e.error?t:[...t,...e.value]),[]),e.visible=1===p.candidates.length,0!==p.candidates.length&&(1===p.candidates.length?(p.rootFeature=p.candidates[0],t.go("editing-existing-feature").catch((()=>{})).then((()=>e.visible=!1))):t.next())}));n.focus(),w.add(d,this.id)},async tearDown(){w.remove(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){p.rootFeature=null,w.add(c((()=>p.rootFeature),(e=>{t._unhighlight(),t._highlight(e)})),this.id)},async tearDown(){t._unhighlight(),w.remove(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){const{rootFeature:a,viewModel:i}=t.data;if(!a)throw new e("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until the root feature is defined");await t.startUpdating(a),i.spinnerViewModel.visible=!1;const o=n((async()=>{await d((()=>!t.updating)),t.previous()}));t.addHandles(c((()=>t.nestedWorkflowCount),((t,e)=>{0===t&&0!==e&&o()})))},async tearDown(){await t.cancelAll()}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){p.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){p.viewModel.attachmentsViewModel.mode="view"}})})}};t([p()],S.prototype,"activeEditableItem",null),t([p()],S.prototype,"activeWorkflow",null),t([p()],S.prototype,"nestedWorkflowCount",null),t([p()],S.prototype,"shouldShowAttachments",null),t([p()],S.prototype,"shouldAllowAttachmentEditing",null),t([p()],S.prototype,"hasPendingEdits",null),t([p()],S.prototype,"helpMessage",null),t([p()],S.prototype,"reliesOnOwnerAdminPrivileges",null),t([p()],S.prototype,"hasInvalidFormTemplate",null),t([p()],S.prototype,"hasUnsupportedFields",null),t([p()],S.prototype,"updating",null),S=W=t([w(b)],S);const U=t=>!!t&&/update-/.test(t.type),C=S;export{C as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i}from"../../core/handleUtils.js";import o from"../../core/Logger.js";import{abortMaybe as r}from"../../core/maybe.js";import{onAbort as s,createAbortError as n,throwIfAborted as l,debounce as d}from"../../core/promiseUtils.js";import c from"../../core/Queue.js";import{whenOnce as p,watch as u}from"../../core/reactiveUtils.js";import{property as h}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as w}from"../../core/accessorSupport/decorators/subclass.js";import{isEditableLayer as f}from"../../layers/support/editableLayers.js";import{isTable as m}from"../../layers/support/layerUtils.js";import{highlightsSupported as g}from"../../views/support/layerViewUtils.js";import k from"./CreateFeaturesWorkflow.js";import{UpdateFeatureWorkflow as y}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as v}from"./UpdateRecordWorkflow.js";import b from"./UpdateWorkflowData.js";import W from"./Workflow.js";import{createWorkflowSteps as _,fetchCandidates as C}from"./workflowUtils.js";import{isGraphicForRelatableFeatureSupportedLayer as S}from"../Feature/support/featureUtils.js";var F;const U="candidate-highlight",j="esri.widgets.Editor.UpdateWorkflow",A=o.getLogger(j);let M=F=class extends W{constructor(e){super(e),this._workflowStack=new c((e=>{let t;for(t of e);return t})),this.type="update"}initialize(){const{featureFormViewModel:e}=this.data.viewModel,t=e.relatedRecordCallbacks;e.relatedRecordCallbacks={addRelatedRecord:e=>this.startCreatingRelatedRecord(e),editRelatedRecord:({relatedFeature:e})=>this.startUpdating(e),showAllRelatedRecords:t=>e.relationshipId=t.relationshipId},this.addHandles(i((()=>e.relatedRecordCallbacks=t)))}get activeEditableItem(){const{activeWorkflow:e}=this;return I(e)?e.data.editableItem:void 0}get activeWorkflow(){return this._workflowStack.last()}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return!!this.activeEditableItem?.attachmentsOnUpdateEnabled}get shouldAllowAttachmentEditing(){return!!this.activeEditableItem?.supports.includes("update")}get hasPendingEdits(){return Array.from(this._workflowStack).some((e=>e.hasPendingEdits))}get helpMessage(){return"awaiting-feature-to-update"===this.stepId?"select":void 0}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return!!this.activeEditableItem?.hasInvalidFormTemplate}get hasUnsupportedFields(){return!!this.activeEditableItem?.hasUnsupportedFields}get updating(){return this.updatingHandles.updating}async back(e=(()=>Promise.resolve(!0))){const{featureFormViewModel:t}=this.data.viewModel;if(null==t.relationshipId)if(this.activeWorkflow){if(this.activeWorkflow.hasPendingEdits){if(!await e())return}this.activeWorkflow.hasPreviousStep?await this.activeWorkflow.previous({cancelCurrentStep:!0}):await this.cancelActiveWorkflow({force:!0})}else this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0});else t.relationshipId=null}async cancelActiveWorkflow(e){await(this.activeWorkflow?.cancel(e)),await this._popWorkflow()}async commit(){await this._drainWorkflowStack((e=>e.commit())),await super.commit()}static create(e,t,a){const i=new F({data:new b({applyEditsCallback:a,viewModel:e}),onCommit:async()=>{}});return i._set("steps",this._createWorkflowSteps(i,t)),i}async save(){this.nestedWorkflowCount>1?(await(this.activeWorkflow?.commit()),await this._popWorkflow()):await this.commit()}async startCreatingRelatedRecord(e){try{const t=await this._createNestedCreateFeaturesWorkflow(e);await this._pushWorkflow(t)}catch(t){throw new a("editor:unable-to-start-creating","Could not begin updating the provided feature or table record.",{error:t})}}async startUpdating(e){try{const t=await this._createNestedUpdateWorkflow(e);await this._pushWorkflow(t)}catch(t){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:t})}}async deleteActiveFeature(){const{activeWorkflow:e}=this;if(!e)throw new a("editor:nothing-to-delete","There is no feature to delete");I(e)?await e.deleteAndCommit():await e.cancel(),1===this.nestedWorkflowCount?this.emit("complete"):await this._popWorkflow()}async cancelAll(){await this._drainWorkflowStack((e=>e.cancel({force:!0})))}async _createNestedCreateFeaturesWorkflow(e){const{relatedLayer:i}=e,{addAttachmentsCallback:o,applyEditsCallback:r,viewModel:s}=this.data;if(!f(i))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const n=new t({sourceLayer:i,attributes:this._makeRelatedRecordAttributes(e)});return k.create({addAttachmentsCallback:o,applyEditsCallback:r,creationInfo:{layer:i,initialFeature:n,maxFeatures:1},startAt:"creating-features",viewModel:s})}async _createNestedUpdateWorkflow(e){const t=m(e.sourceLayer)?v:y,{applyEditsCallback:a,viewModel:i}=this.data,o=await t.create({feature:e,viewModel:i,applyEdits:a});return await p((()=>!o.updating)),o}async _drainWorkflowStack(e){const t=this._workflowStack,a=[];for(;t.length>0;){const i=t.pop(),o=e(i).then((()=>i.destroy()));this.updatingHandles.addPromise(o),a.push(o)}await Promise.all(a)}_highlight(e){const t=this.data.viewModel.view;if(!t||!e)return;const a=e&&t.allLayerViews.items.find((({layer:t})=>t===e.layer||"subtype-sublayer"===e.layer?.type&&e.layer?.parent===t));g(a)&&this.handles.add(a.highlight(e),U)}_makeRelatedRecordAttributes(e){const{parentFeature:t,relatedLayer:a,relationshipId:i}=e;if(!S(t))return;const o=a.relationships?.find((e=>e.id===i));if(!o)return void E("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the destination layer.");if("origin"===o.role)return void E("unsupported-role","Creating new related records in the 'origin' table of a relationship is not yet supported");const r=t.sourceLayer;o.relatedTableId!==r.layerId&&E("invalid-argument-combination","The given parent feature does not belong to the relationship designated by the given relationship ID.");const s=r.relationships?.find((e=>e.id===i));if(!s)return void E("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the origin layer.");const n=t.getAttribute(s.keyField);return n||E("no-key-on-origin-feature","The given parent feature does not have a value for the relationship's origin primary key field."),{[o.keyField]:n}}async _popWorkflow(){this._workflowStack.pop()?.destroy();const e=await this._reconcileWorkflowStack();if(e.failureCount>0)throw new a("editor:next-workflow-failed","Popped the top workflow, but the next workflow in the stack failed to activate",e)}async _pushWorkflow(e){const t="update-feature"===e.type||"create-features"===e.type;this.activeWorkflow?.exit({removeSketchHandles:t}),await e.start(),this._workflowStack.push(e);const i=await this._reconcileWorkflowStack();if(i.failureCount>0)throw new a("editor:failed-to-start-updating-feature","Failed to enter the provided workflow.",i)}async _reconcileWorkflowStack(){const e=this._workflowStack;try{const t=e.peek();return await(t?.enter()),{activeWorkflow:t,failureCount:0}}catch(t){e.pop().destroy();const{activeWorkflow:a,failureCount:i}=await this._reconcileWorkflowStack();return{activeWorkflow:a,failureCount:i+1}}}_unhighlight(){this.handles.remove(U)}static _createWorkflowSteps(e,t="awaiting-feature-to-update"){const{data:o,handles:c}=e;return _(["awaiting-feature-to-update","awaiting-update-feature-candidate","editing-existing-feature","adding-attachment","editing-attachment"],t,{"awaiting-feature-to-update":()=>({id:"awaiting-feature-to-update",async setUp(){const{spinnerViewModel:t}=o.viewModel,a=o.viewModel.view;let d=null;c.add(i((()=>{d=r(d)})),this.id),o.rootFeature=null,o.candidates=[];const p=a.on("immediate-click",(async i=>{t.location=i.mapPoint,t.visible=!0,d?.abort();const{editableItems:r}=o.viewModel;d=new AbortController;const c=await new Promise(((e,t)=>{s(d?.signal,(()=>t(n()))),e(C(r,a,i,d?.signal))}));l(d),o.candidates=c.reduce(((e,t)=>t.error?e:[...e,...t.value]),[]),t.visible=1===o.candidates.length,0!==o.candidates.length&&(1===o.candidates.length?(o.rootFeature=o.candidates[0],e.go("editing-existing-feature").catch((()=>{})).then((()=>t.visible=!1))):e.next())}));a.focus(),c.add(p,this.id)},async tearDown(){c.remove(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){o.rootFeature=null,c.add(u((()=>o.rootFeature),(t=>{e._unhighlight(),e._highlight(t)})),this.id)},async tearDown(){e._unhighlight(),c.remove(this.id)}}),"editing-existing-feature":()=>({id:"editing-existing-feature",async setUp(){const{rootFeature:t,viewModel:i}=e.data;if(!t)throw new a("editor:no-feature-specified","Cannot setup the 'updating-existing-feature' step until the root feature is defined");await e.startUpdating(t),i.spinnerViewModel.visible=!1;const o=d((async()=>{await p((()=>!e.updating)),e.previous()}));e.addHandles(u((()=>e.nestedWorkflowCount),((e,t)=>{0===e&&0!==t&&o()})))},async tearDown(){await e.cancelAll()}}),"adding-attachment":()=>({id:"adding-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){o.viewModel.attachmentsViewModel.mode="view"}}),"editing-attachment":()=>({id:"editing-attachment",parent:"editing-existing-feature",async setUp(){},async tearDown(){o.viewModel.attachmentsViewModel.mode="view"}})})}};e([h()],M.prototype,"activeEditableItem",null),e([h()],M.prototype,"activeWorkflow",null),e([h()],M.prototype,"nestedWorkflowCount",null),e([h()],M.prototype,"shouldShowAttachments",null),e([h()],M.prototype,"shouldAllowAttachmentEditing",null),e([h()],M.prototype,"hasPendingEdits",null),e([h()],M.prototype,"helpMessage",null),e([h()],M.prototype,"reliesOnOwnerAdminPrivileges",null),e([h()],M.prototype,"hasInvalidFormTemplate",null),e([h()],M.prototype,"hasUnsupportedFields",null),e([h()],M.prototype,"updating",null),M=F=e([w(j)],M);const E=(e,t)=>A.warn(`editor:${e}`,t,"The create operation will be allowed to proceed, but the resulting feature may not be related to the given parent feature."),I=e=>!!e&&/update-/.test(e.type),R=M;export{R as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as o}from"../../chunks/tslib.es6.js";import r from"../../core/Accessor.js";import{property as t}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";let e=class extends r{constructor(o){super(o),this.applyEditsCallback=null,this.candidates=null,this.rootFeature=null,this.viewModel=null}};o([t()],e.prototype,"applyEditsCallback",void 0),o([t()],e.prototype,"candidates",void 0),o([t()],e.prototype,"rootFeature",void 0),o([t()],e.prototype,"viewModel",void 0),e=o([s("esri.widgets.Editor.UpdateWorkflowData")],e);const p=e;export{p as default};
5
+ import{_ as o}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";let e=class extends t{constructor(o){super(o),this.addAttachmentsCallback=null,this.applyEditsCallback=null,this.candidates=null,this.rootFeature=null,this.viewModel=null}};o([r()],e.prototype,"addAttachmentsCallback",void 0),o([r()],e.prototype,"applyEditsCallback",void 0),o([r()],e.prototype,"candidates",void 0),o([r()],e.prototype,"rootFeature",void 0),o([r()],e.prototype,"viewModel",void 0),e=o([s("esri.widgets.Editor.UpdateWorkflowData")],e);const a=e;export{a as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Error.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import{abortMaybe as r}from"../../core/maybe.js";import{throwIfNotAbortError as i}from"../../core/promiseUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";let p=class extends(o(s.EventedAccessor)){constructor(t){super(t),this._indexHistory=[],this._lastStepIndex=-1,this._stepIndex=-1,this._setupAbortController=null,this._handleKeys={afterCommit:"after-commit",beforeCommit:"before-commit"},this.data=void 0,this.started=!1,this.steps=[],this.type=null}get hasNextStep(){const{steps:t}=this;return!!(t&&this._stepIndex<t.filter((t=>!t.parent)).length-1)}get hasPreviousStep(){return this._stepIndex>0}get reliesOnOwnerAdminPrivileges(){return!1}get hasInvalidFormTemplate(){return!1}get hasUnsupportedFields(){return!1}get shouldShowAttachments(){return!1}get shouldAllowAttachmentEditing(){return!1}get stepId(){const{steps:t}=this,e=t&&t[this._stepIndex];return e&&e.id}get helpMessage(){}get hasPendingEdits(){return!1}get keyboardCancellationEnabled(){return!0}async back(t){this.hasPendingEdits&&await(t?.()),this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0})}async cancel(t={force:!0}){return!1!==t.force?this._cancel(t):new Promise(((s,o)=>{this.emit("cancel-request",{controller:{allow:()=>{this._cancel({...t,force:!0}).then(s)},deny:()=>o(new e("workflow:cancel-denied","Request to cancel workflow was denied."))}})}))}async commit(){this.handles.remove(this._handleKeys.beforeCommit),await(this.onCommit?.(this.data)),this.handles.remove(this._handleKeys.afterCommit),this.emit("commit")}async go(t){const{steps:e}=this,s=e.findIndex((e=>e.id===t));this._indexHistory.push(this._stepIndex),await this._go(s)}async next(){this._indexHistory.push(this._stepIndex),await this._go(this._stepIndex+1)}async previous(t={cancelCurrentStep:!1}){await this._go(this._indexHistory.pop(),t.cancelCurrentStep)}async reset(){await this._cancel({notify:!1}),await this.start()}async save(){await this.commit(),await this.reset()}async start(){this._set("started",!0);const t=-1===this._stepIndex?0:this._stepIndex;await this._go(t)}async _cancel({notify:t=!0,error:e}={}){this.started&&(this._set("started",!1),await this.steps[this._stepIndex].tearDown({canceled:!0})),this.handles.remove([this._handleKeys.afterCommit,this._handleKeys.beforeCommit]),this._resetIndexing(t),t&&this.emit("cancel",{error:e})}async _go(t=-1,e=!1){const{steps:s}=this;if(t<=-1||t>=s.length)return;if(!this.started)return this._stepIndex=t,void this._notifyStepProps();this._lastStepIndex>-1&&(this._setupAbortController=r(this._setupAbortController),await s[this._lastStepIndex].tearDown({canceled:e})),this._setupAbortController=new AbortController;const o=this._setupAbortController.signal;try{await s[t].setUp(o)}catch(n){i(n)}this._setupAbortController.signal===o&&(this._setupAbortController=null),o.aborted||(this._lastStepIndex=t,this._stepIndex=t,this._notifyStepProps())}_resetIndexing(t=!0){this._stepIndex=-1,this._lastStepIndex=-1,this._indexHistory.length=0,t&&this._notifyStepProps()}_notifyStepProps(){this.notifyChange("stepId"),this.notifyChange("hasPreviousStep"),this.notifyChange("hasNextStep")}};t([n()],p.prototype,"data",void 0),t([n()],p.prototype,"hasNextStep",null),t([n()],p.prototype,"hasPreviousStep",null),t([n()],p.prototype,"onCommit",void 0),t([n()],p.prototype,"reliesOnOwnerAdminPrivileges",null),t([n()],p.prototype,"hasInvalidFormTemplate",null),t([n()],p.prototype,"hasUnsupportedFields",null),t([n()],p.prototype,"shouldShowAttachments",null),t([n()],p.prototype,"shouldAllowAttachmentEditing",null),t([n()],p.prototype,"started",void 0),t([n({readOnly:!0})],p.prototype,"stepId",null),t([n()],p.prototype,"steps",void 0),t([n({readOnly:!0})],p.prototype,"type",void 0),t([n()],p.prototype,"helpMessage",null),t([n()],p.prototype,"hasPendingEdits",null),t([n()],p.prototype,"keyboardCancellationEnabled",null),p=t([a("esri.widgets.Editor.Workflow")],p);const h=p;export{h as default};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Error.js";import s from"../../core/Evented.js";import{HandleOwnerMixin as o}from"../../core/HandleOwner.js";import{abortMaybe as r}from"../../core/maybe.js";import{throwIfNotAbortError as i}from"../../core/promiseUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{subclass as a}from"../../core/accessorSupport/decorators/subclass.js";let p=class extends(o(s.EventedAccessor)){constructor(t){super(t),this._indexHistory=[],this._lastStepIndex=-1,this._stepIndex=-1,this._setupAbortController=null,this._handleKeys={afterCommit:"after-commit",beforeCommit:"before-commit"},this.data=void 0,this.started=!1,this.steps=[],this.type=null}get hasNextStep(){const{steps:t}=this;return!!(t&&this._stepIndex<t.filter((t=>!t.parent)).length-1)}get hasPreviousStep(){return this._stepIndex>0}get reliesOnOwnerAdminPrivileges(){return!1}get hasInvalidFormTemplate(){return!1}get hasUnsupportedFields(){return!1}get shouldShowAttachments(){return!1}get shouldAllowAttachmentEditing(){return!1}get stepId(){const{steps:t}=this,e=t&&t[this._stepIndex];return e&&e.id}get helpMessage(){}get hasPendingEdits(){return!1}get keyboardCancellationEnabled(){return!0}async back(t=(()=>Promise.resolve(!0))){if(this.hasPendingEdits){if(!await t())return}this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0})}async cancel(t={force:!0}){return!1!==t.force?this._cancel(t):new Promise(((s,o)=>{this.emit("cancel-request",{controller:{allow:()=>{this._cancel({...t,force:!0}).then(s)},deny:()=>o(new e("workflow:cancel-denied","Request to cancel workflow was denied."))}})}))}async commit(){this.handles.remove(this._handleKeys.beforeCommit),await(this.onCommit?.(this.data)),this.handles.remove(this._handleKeys.afterCommit),this.emit("commit")}async go(t){const{steps:e}=this,s=e.findIndex((e=>e.id===t));this._indexHistory.push(this._stepIndex),await this._go(s)}async next(){this._indexHistory.push(this._stepIndex),await this._go(this._stepIndex+1)}async previous(t={cancelCurrentStep:!1}){await this._go(this._indexHistory.pop(),t.cancelCurrentStep)}async reset(){await this._cancel({notify:!1}),await this.start()}async save(){await this.commit(),await this.reset()}async start(){this._set("started",!0);const t=-1===this._stepIndex?0:this._stepIndex;await this._go(t)}async _cancel({notify:t=!0,error:e}={}){this.started&&(this._set("started",!1),await this.steps[this._stepIndex].tearDown({canceled:!0})),this.handles.remove([this._handleKeys.afterCommit,this._handleKeys.beforeCommit]),this._resetIndexing(t),t&&this.emit("cancel",{error:e})}async _go(t=-1,e=!1){const{steps:s}=this;if(t<=-1||t>=s.length)return;if(!this.started)return this._stepIndex=t,void this._notifyStepProps();this._lastStepIndex>-1&&(this._setupAbortController=r(this._setupAbortController),await s[this._lastStepIndex].tearDown({canceled:e})),this._setupAbortController=new AbortController;const o=this._setupAbortController.signal;try{await s[t].setUp(o)}catch(n){i(n)}this._setupAbortController.signal===o&&(this._setupAbortController=null),o.aborted||(this._lastStepIndex=t,this._stepIndex=t,this._notifyStepProps())}_resetIndexing(t=!0){this._stepIndex=-1,this._lastStepIndex=-1,this._indexHistory.length=0,t&&this._notifyStepProps()}_notifyStepProps(){this.notifyChange("stepId"),this.notifyChange("hasPreviousStep"),this.notifyChange("hasNextStep")}};t([n()],p.prototype,"data",void 0),t([n()],p.prototype,"hasNextStep",null),t([n()],p.prototype,"hasPreviousStep",null),t([n()],p.prototype,"onCommit",void 0),t([n()],p.prototype,"reliesOnOwnerAdminPrivileges",null),t([n()],p.prototype,"hasInvalidFormTemplate",null),t([n()],p.prototype,"hasUnsupportedFields",null),t([n()],p.prototype,"shouldShowAttachments",null),t([n()],p.prototype,"shouldAllowAttachmentEditing",null),t([n()],p.prototype,"started",void 0),t([n({readOnly:!0})],p.prototype,"stepId",null),t([n()],p.prototype,"steps",void 0),t([n({readOnly:!0})],p.prototype,"type",void 0),t([n()],p.prototype,"helpMessage",null),t([n()],p.prototype,"hasPendingEdits",null),t([n()],p.prototype,"keyboardCancellationEnabled",null),p=t([a("esri.widgets.Editor.Workflow")],p);const h=p;export{h as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../Graphic.js";import{createTask as t}from"../../core/asyncUtils.js";import"../../core/has.js";import{handlesGroup as r,makeHandle as n}from"../../core/handleUtils.js";import{clone as i}from"../../core/lang.js";import{throwIfAborted as a,whenOrAbort as s,eachAlways as l}from"../../core/promiseUtils.js";import{watch as o,whenOnce as c}from"../../core/reactiveUtils.js";import{px2pt as u}from"../../core/screenUtils.js";import{diff as p}from"../../core/accessorSupport/diffUtils.js";import{getDisplayFieldName as y}from"../../layers/support/fieldUtils.js";import{calculateTolerance as f}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as d}from"../../renderers/support/lengthUtils.js";import{getTransformationType as m,TransformationType as g}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{getRotationAngle as h,getSize as b}from"../../renderers/visualVariables/support/visualVariableUtils.js";import{sceneLayerEditingEnabled as w,i3sPatchingEnabled as v}from"../../support/featureFlags.js";import{to3D as S}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as j}from"../../symbols/support/symbolUtils.js";import{GraphicState as I}from"../../views/3d/layers/graphics/GraphicState.js";import{createQueryGeometry as U}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as V,filterGraphicHits as F}from"../../views/support/hitTestSelectUtils.js";function T(e){const t=e.sourceLayer;if(!t||"feature"!==t.type||!O(t.renderer))return{rotation:null,size:null};let r=null,n=null;const i=t.renderer.getVisualVariablesForType("rotation").filter((t=>(!t.axis||"heading"===t.axis)&&t.field&&!t.valueExpression&&null!=h(t,e)));1===i.length&&(r=z(i[0],t));const a=t.renderer.getVisualVariablesForType("size").filter((t=>t.field&&!t.useSymbolValue&&!t.valueExpression&&m(t)===g.RealWorldSize&&null!=b(t,e)));return 1===a.length&&(n=E(a[0],t)),{rotation:r,size:n}}function z(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,n=e.field,i=t.fields&&t.fields.filter((e=>e.name===n)),a=i&&1===i.length?i[0].type:"double",s={initial:0,current:0};return{field:n,fieldType:a,getDefault:()=>Promise.resolve(0),getValue:e=>(s.current=s.initial-r*e,A((s.current+360)%360,a)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function x(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function L(e,t,r){if(null==t)return 0;const{symbol:n}=S(t);if(null==n||"web-style"===n.type||"cim"===n.type)return 0;const i=n.symbolLayers.at(0);if(!i)return 0;switch(i.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return i.size||Math.min($.icon,(await e(i,$.icon))[0])||$.icon}case"text":return i.size||$.text;case"line":return i.size||$.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return x(await t(i,e.scale/$.viewScaleSizeFactor),r)}case"path":return(null!=i.width?i.width:i.height)||e.scale/$.viewScaleSizeFactor;case"extrude":return i.size||e.scale/$.viewScaleSizeFactor;default:return 0}}function E(e,t){const r=e.field,n=e.axis,i=t.fields&&t.fields.filter((e=>e.name===r)),a=i&&1===i.length?i[0].type:"double",s={updating:!1,initial:0,current:0},l=d[e.valueUnit]??1;let o;return o="area"===e.valueRepresentation?e=>(e*l/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*l/2:e=>e*l,{field:r,fieldType:a,getDefault:async(e,t)=>A(o(await L(t,e,n)),a),getValue:(e,t)=>(s.initial||(s.initial=t.pixelSizeAt(t.center)),s.current=s.initial*e,A(s.current,a)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1,displayUnit:ne(e.valueUnit),axis:e.axis}}function A(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function O(e){switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function M(e,t){const r=await j(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t});null!=p(e.symbol,r)&&(e.symbol=r)}function R(e){if(!e)throw new Error("no geometry type");return"multipatch"===e?"mesh":e}async function k(e,t,i,a){await G(e,t,a);const s=e.on("create",(async r=>{if("cancel"===r.state)return G(e,t,a);if("complete"===r.state){const e=r.graphic;e.sourceLayer||(e.sourceLayer=t.layer),e.attributes||(e.attributes={...t.template.prototype.attributes}),await M(e,a),i(e)}}));return r([s,n((()=>e.cancel()))])}async function G(e,t,r){const n=t.layer,i={...t.template.prototype.attributes};await P(e,n,i,r),e.layer.elevationInfo=n.elevationInfo,await e.create(R(n.geometryType),{graphicProperties:{attributes:i,sourceLayer:n},hasZ:n.capabilities.data.supportsZ,geometryToPlace:t.geometryToPlace??void 0})}async function P(t,r,n,i){const a=new e({sourceLayer:r,attributes:n}),{rotation:s,size:l}=T(a);let o=await j(a,{useSourceLayer:!0,webStyleCache:i}),c=!1;for(const e of[l,s]){if(null==e)continue;null==n[e.field]&&(n[e.field]=await e.getDefault(o,t.view),c=!0)}switch(c&&(o=await j(a,{useSourceLayer:!0,webStyleCache:i})),o?.type){case"simple-fill":case"polygon-3d":t.polygonSymbol=o;break;case"simple-line":case"line-3d":t.polylineSymbol=o;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":t.pointSymbol=o}D(t.tooltipOptions,l,s)}function D(e,t,r){e.visualVariables=null!=t||null!=r?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=r?{valueType:r.fieldType,rotationType:r.rotationType??"geographic"}:null}:null}function C(e,t){return e?e.find((e=>e.layer===t)):void 0}async function q(e,t,r,n){if(0===e.length)return[];const{updatable:i,graphicsByLayer:a}=await r.async((async()=>{const{results:i}=await s(V(t,r),n),a=new Map,l=e=>{const t=e.layer,r=a.get(t);if(!r){const e=new Array;return a.set(t,e),e}return r};F(i).forEach((({graphic:e})=>l(e).push(e)));const o=e.filter((({supports:e,layer:t})=>e.includes("update")&&a.has(t)));return 0!==o.length&&r.stopPropagation(),{updatable:o,graphicsByLayer:a}}));return s(l(i.map((async({layer:e})=>{const{objectIdField:t}=e,r="displayField"in e?e.displayField:null,i=[t];null!=r&&e.fieldsIndex.has(r)&&i.push(r);const s=a.get(e);if(!!s.some((e=>i.some((t=>!(t in e.attributes)))))){const t=e.createQuery();return t.outFields=i,t.returnGeometry=!1,t.objectIds=s.map((e=>e.getObjectId())),e.queryFeatures(t,{signal:n}).then((({features:e})=>e))}return s}))),n)}async function Z(e,t,r,n){if(0===e.length)return[];let i=null;const a=await r.async((async()=>{const{results:a}=await s(t.hitTest(r),n);if(0===a.length)return[];const l=new Set;i=F(a),i.forEach((({graphic:e})=>e&&l.add(e.layer)));const o=e.items.filter((({layer:e,supports:t,attachmentsOnUpdateEnabled:r})=>l.has(e)&&(t.includes("update")||t.includes("delete")||r)));return o.length>0&&r.stopPropagation(),o}));return s(l(a.map((({layer:e})=>{const a=e.objectIdField,s="displayField"in e?e.displayField:null,l=y({displayField:s,fields:e.fields}),o=[a];null!=l&&e.fieldsIndex.has(l)&&o.push(l);const c=e.createQuery();c.outFields=o,c.returnGeometry=!1;const u="renderer"in e?f({renderer:e.renderer,event:r}):0;return c.geometry=U(r.mapPoint,u,t),c.outSpatialReference=t.spatialReference,e.queryFeatures(c,{signal:n}).then((({features:t})=>(i?.forEach((({graphic:r})=>{r.layer!==e||t.some((e=>e.getObjectId()===r.getObjectId()))||t.push(r)})),t)))}))),n)}async function Q(e,t,r,n){switch(t.type){case"3d":return q(e,t,r,n);case"2d":return Z(e,t,r,n)}}async function B(e,t,r){const{sourceLayer:n}=e,i=n.createQuery();i.objectIds=[e.getAttribute(n.objectIdField)],i.outFields=["*"],i.outSpatialReference=t,i.returnM=n.capabilities.data.supportsM,i.returnZ=n.capabilities.data.supportsZ,w()&&v()&&"scene"===n.type&&null!=n.infoFor3D&&(i.returnGeometry=!0,i.formatOf3DObjects="3D_glb");const s=await n.queryFeatures(i,{signal:r});a(r);return s.features[0]}async function W(e,t,r,n,i){let a=!1;const{rotation:s,size:l}=n;[s,l].forEach((async r=>{if(null==r)return;const n=t.getAttribute(r.field);if(null!=n)r.initValue(n);else{const n=await r.getDefault(t.symbol,e.view);r.initValue(n),t.setAttribute(r.field,n),a=!0}})),a&&await M(t,i);const o={multipleSelectionEnabled:!1};return"point"===r.geometryType&&(o.enableRotation=null!=s,o.enableScaling=null!=l),D(e.tooltipOptions,l,s),e.layer.elevationInfo=r.elevationInfo,e.update(t,o)}function _(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function H(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function J(e,t,r,n,i){if(null==t.geometry||"point"!==t.geometry?.type)return;const a=n.rotation,s=_(r.toolEventInfo);if(null!=a&&null!=s)if("rotate-stop"===s.type)a.isUpdatingInteractively=!1,a.initValue();else{a.isUpdatingInteractively=!0;const{field:r,getValue:n}=a;t.setAttribute(r,n(s.angle,e))}const l=n.size,o=H(r.toolEventInfo);if(null!=l&&null!=o)if("scale-stop"===o.type)l.isUpdatingInteractively=!1,l.initValue();else{l.isUpdatingInteractively=!0;const{field:r,getValue:n}=l;t.setAttribute(r,n(o.xScale,e))}await M(t,i)}async function K(e,t,i,a,s,l){const c=pe(e);await M(c,l),a.map.add(i.layer),i.layer.add(c);const u=e.sourceLayer,p=le(a,u);await Y(a,c),await W(i,c,u,t,l);const y=N(i,e,c);let f=null;p.then((e=>f=e)).catch((()=>{}));const d=t.size,m=t.rotation,g=o((()=>e.attributes),(async e=>{let t=!1;for(const r in e){const n=e[r];n!==c.getAttribute(r)&&(c.setAttribute(r,n),null==d||d.isUpdatingInteractively||d.field!==r||d.initValue(n),null==m||m.isUpdatingInteractively||m.field!==r||m.initValue(n),(null==f||f.requiredFields.includes(r))&&(t=!0))}t&&await M(c,l)})),h=i.on("update",(async e=>{const r=e.graphics[0];if("complete"===e.state)return W(i,r,u,t,l);await J(a,r,e,t,l),s(pe(r),e)})),b=i.on(["undo","redo"],(async e=>{s(pe(e.graphics[0]),e)}));return{interactive:r([b,h,n((()=>i.cancel())),g]),visual:y}}function N(e,i,s){const l=e.view,o=i.sourceLayer,u=i.layer,p=i.getAttribute(u.objectIdField);let y=null;function f(e){y?.abort(),y=t((async t=>{const r=await le(l,o);a(t),r.setVisibility?.(p,e)}))}return f(!1),r([X(l,s,(e=>f(!e))),n((async()=>{f(!0);const t=await le(l,o);await c((()=>!t.updating)),e.layer.remove(s)}))])}function X(e,t,n){if("3d"===e.type){const i=new I({graphic:t});return r([e.trackGraphicState(i),o((()=>i.displaying),n)])}return o((()=>t.visible),n)}async function Y(e,t){if("3d"===e.type){const r=new I({graphic:t}),n=e.trackGraphicState(r);await c((()=>r.displaying)),n.remove()}else await c((()=>t.visible))}const $={icon:u(24),text:u(12),line:u(1),viewScaleSizeFactor:100};function ee(e,t,r){let n=!1;return e.filter((e=>!!n||(n=e===t,n))).map((e=>r[e]()))}function te(e){if(1!==e.length)return null;const t=e[0];if("items"in t){const e=t;return 1===e.items.length?e.items[0]:null}return t}function re(e,t){if(e.viewModel.refreshCreationTemplates(),"awaiting-feature-creation-info"===t[0].id){const r=te(e.viewModel.featureTemplatesViewModel.items);null==r||r.supportsUpload||(e.creationInfo=r,t.shift())}return t}function ne(e){switch(e){case"unknown":case"decimal-degrees":return null;default:return e}}function ie(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}function ae(e){const{creationInfo:t,viewModel:r}=e;if(!t)return!1;const{layer:n}=t,i=r.editableItems.find((e=>e.layer===n));if(i)return i.attachmentsOnCreateEnabled;const a=n.capabilities?.data,s=r.layerInfos?.find((e=>e.layer===n));return!(!(a&&"supportsAttachment"in a&&a.supportsAttachment)||s&&(!1===s.allowAttachments||!1===s.attachmentsOnUpdateEnabled))}const se=e=>/-stop/.test(e)||/vertex-/.test(e),le=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function oe(e){return"createInteractiveEditSession"in e}const ce=Symbol();function ue(e){return e&&"object"==typeof e&&ce in e}function pe(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=i(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function ye(e){const t=e.cursor;return e.cursor="progress",n((()=>e.cursor=t))}export{ce as UsesSketchViewModelSymbol,re as avoidFeatureTemplateSelectionWithOnlyOneItem,oe as canCreateInteractiveEditSession,pe as cloneGraphicExceptMesh,ee as createWorkflowSteps,Q as fetchCandidates,B as fetchFullFeature,C as findLayerInfo,T as getVisualVariableAttributes,se as isTerminalUpdateEventType,ie as prepareAttachmentsForCreateWorkflow,k as setUpFeatureAdd,K as setUpGeometryUpdate,ae as shouldShowAttachmentsForCreateWorkflow,ye as showProgressCursor,$ as sizeDefaults,ne as sizeVariableUnitToLengthUnit,G as startCreatingNewFeature,W as startUpdatingFeature,M as updateGraphicSymbolWhenRequired,J as visualVariableInteractiveUpdate,le as whenEditorLayerView,Y as whenGraphicDisplayed,ue as workflowUsesSketchViewModel};
5
+ import e from"../../Graphic.js";import{createTask as t}from"../../core/asyncUtils.js";import"../../core/has.js";import{handlesGroup as i,makeHandle as r}from"../../core/handleUtils.js";import{clone as n}from"../../core/lang.js";import{throwIfAborted as a,whenOrAbort as s,eachAlways as l}from"../../core/promiseUtils.js";import{watch as o,whenOnce as c}from"../../core/reactiveUtils.js";import{px2pt as u}from"../../core/screenUtils.js";import{diff as p}from"../../core/accessorSupport/diffUtils.js";import{getDisplayFieldName as y}from"../../layers/support/fieldUtils.js";import{calculateTolerance as d}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as f}from"../../renderers/support/lengthUtils.js";import{getTransformationType as m,TransformationType as h}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{getRotationAngle as g,getSize as b}from"../../renderers/visualVariables/support/visualVariableUtils.js";import{sceneLayerEditingEnabled as w,i3sPatchingEnabled as v}from"../../support/featureFlags.js";import{to3D as S}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as j}from"../../symbols/support/symbolUtils.js";import{GraphicState as I}from"../../views/3d/layers/graphics/GraphicState.js";import{createQueryGeometry as U}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as V,filterGraphicHits as F}from"../../views/support/hitTestSelectUtils.js";function L(e){const t=e.sourceLayer;if(!t||"feature"!==t.type||!O(t.renderer))return{rotation:null,size:null};let i=null,r=null;const n=t.renderer.getVisualVariablesForType("rotation").filter((t=>(!t.axis||"heading"===t.axis)&&t.field&&!t.valueExpression&&null!=g(t,e)));1===n.length&&(i=T(n[0],t));const a=t.renderer.getVisualVariablesForType("size").filter((t=>t.field&&!t.useSymbolValue&&!t.valueExpression&&m(t)===h.RealWorldSize&&null!=b(t,e)));return 1===a.length&&(r=k(a[0],t)),{rotation:i,size:r}}function T(e,t){const i="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,r=e.field,n=t.fields&&t.fields.filter((e=>e.name===r)),a=n&&1===n.length?n[0].type:"double",s={initial:0,current:0};return{field:r,fieldType:a,getDefault:()=>Promise.resolve(0),getValue:e=>(s.current=s.initial-i*e,E((s.current+360)%360,a)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function z(e,t){switch(t){case"width":return e[0];case"depth":return e[1];case"height":return e[2];default:return e[2]||e[1]||e[0]}}async function x(e,t,i){if(null==t)return 0;const{symbol:r}=S(t);if(null==r||"web-style"===r.type||"cim"===r.type)return 0;const n=r.symbolLayers.at(0);if(!n)return 0;switch(n.type){case"icon":{const{computeIconLayerResourceSize:e}=await import("../../symbols/support/symbolLayerUtils.js");return n.size||Math.min($.icon,(await e(n,$.icon))[0])||$.icon}case"text":return n.size||$.text;case"line":return n.size||$.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return z(await t(n,e.scale/$.viewScaleSizeFactor),i)}case"path":return(null!=n.width?n.width:n.height)||e.scale/$.viewScaleSizeFactor;case"extrude":return n.size||e.scale/$.viewScaleSizeFactor;default:return 0}}function k(e,t){const i=e.field,r=e.axis,n=t.fields&&t.fields.filter((e=>e.name===i)),a=n&&1===n.length?n[0].type:"double",s={updating:!1,initial:0,current:0},l=f[e.valueUnit]??1;let o;return o="area"===e.valueRepresentation?e=>(e*l/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*l/2:e=>e*l,{field:i,fieldType:a,getDefault:async(e,t)=>E(o(await x(t,e,r)),a),getValue:(e,t)=>(s.initial||(s.initial=t.pixelSizeAt(t.center)),s.current=s.initial*e,E(s.current,a)),initValue:e=>{s.initial=null!=e?e:s.current,s.current=0},isUpdatingInteractively:!1,displayUnit:re(e.valueUnit),axis:e.axis}}function E(e,t){switch(t){case"small-integer":case"integer":case"long":return Math.round(e);case"double":case"single":return e;default:return 0}}function O(e){switch(e?.type){case"class-breaks":case"simple":case"unique-value":case"dot-density":case"dictionary":case"pie-chart":return!0;default:return!1}}async function A(e,t){const i=await j(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t});null!=p(e.symbol,i)&&(e.symbol=i)}function M(e){if(!e)throw new Error("no geometry type");return"multipatch"===e?"mesh":e}async function C(e,t,n,a){await G(e,t,a);const s=e.on("create",(async i=>{if("cancel"===i.state)return G(e,t,a);if("complete"===i.state){const e=i.graphic;e.sourceLayer||(e.sourceLayer=t.layer),e.attributes||(e.attributes={...t.template?.prototype.attributes}),await A(e,a),n(e)}}));return i([s,r((()=>e.cancel()))])}async function G(e,t,i){const r=t.layer,n={...t.template?.prototype.attributes};await R(e,r,n,i),e.layer.elevationInfo=r.elevationInfo,await e.create(M(r.geometryType),{graphicProperties:{attributes:n,sourceLayer:r},hasZ:r.capabilities.data.supportsZ,geometryToPlace:t.geometryToPlace??void 0})}async function R(t,i,r,n){const a=new e({sourceLayer:i,attributes:r}),{rotation:s,size:l}=L(a);let o=await j(a,{useSourceLayer:!0,webStyleCache:n}),c=!1;for(const e of[l,s]){if(null==e)continue;null==r[e.field]&&(r[e.field]=await e.getDefault(o,t.view),c=!0)}switch(c&&(o=await j(a,{useSourceLayer:!0,webStyleCache:n})),o?.type){case"simple-fill":case"polygon-3d":t.polygonSymbol=o;break;case"simple-line":case"line-3d":t.polylineSymbol=o;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":t.pointSymbol=o}P(t.tooltipOptions,l,s)}function P(e,t,i){e.visualVariables=null!=t||null!=i?{size:null!=t?{unit:t.displayUnit,axis:t.axis,valueType:t.fieldType}:null,rotation:null!=i?{valueType:i.fieldType,rotationType:i.rotationType??"geographic"}:null}:null}function D(e,t){return e?e.find((e=>e.layer===t)):void 0}async function q(e,t,i,r){if(0===e.length)return[];const{updatable:n,graphicsByLayer:a}=await i.async((async()=>{const{results:n}=await s(V(t,i),r),a=new Map,l=e=>{const t=e.layer,i=a.get(t);if(!i){const e=new Array;return a.set(t,e),e}return i};F(n).forEach((({graphic:e})=>l(e).push(e)));const o=e.filter((({supports:e,layer:t})=>e.includes("update")&&a.has(t)));return 0!==o.length&&i.stopPropagation(),{updatable:o,graphicsByLayer:a}}));return s(l(n.map((async({layer:e})=>{const{objectIdField:t}=e,i="displayField"in e?e.displayField:null,n=[t];null!=i&&e.fieldsIndex.has(i)&&n.push(i);const s=a.get(e);if(!!s.some((e=>n.some((t=>!(t in e.attributes)))))){const t=e.createQuery();return t.outFields=n,t.returnGeometry=!1,t.objectIds=s.map((e=>e.getObjectId())),e.queryFeatures(t,{signal:r}).then((({features:e})=>e))}return s}))),r)}async function Z(e,t,i,r){if(0===e.length)return[];let n=null;const a=await i.async((async()=>{const{results:a}=await s(t.hitTest(i),r);if(0===a.length)return[];const l=new Set;n=F(a),n.forEach((({graphic:e})=>e&&l.add(e.layer)));const o=e.items.filter((({layer:e,supports:t,attachmentsOnUpdateEnabled:i})=>l.has(e)&&(t.includes("update")||t.includes("delete")||i)));return o.length>0&&i.stopPropagation(),o}));return s(l(a.map((({layer:e})=>{const a=e.objectIdField,s="displayField"in e?e.displayField:null,l=y({displayField:s,fields:e.fields}),o=[a];null!=l&&e.fieldsIndex.has(l)&&o.push(l);const c=e.createQuery();c.outFields=o,c.returnGeometry=!1;const u="renderer"in e?d({renderer:e.renderer,event:i}):0;return c.geometry=U(i.mapPoint,u,t),c.outSpatialReference=t.spatialReference,e.queryFeatures(c,{signal:r}).then((({features:t})=>(n?.forEach((({graphic:i})=>{i.layer!==e||t.some((e=>e.getObjectId()===i.getObjectId()))||t.push(i)})),t)))}))),r)}async function Q(e,t,i,r){switch(t.type){case"3d":return q(e,t,i,r);case"2d":return Z(e,t,i,r)}}async function B(e,t,i){const{sourceLayer:r}=e,n=r.createQuery();n.objectIds=[e.getAttribute(r.objectIdField)],n.outFields=["*"],n.outSpatialReference=t,n.returnM=r.capabilities.data.supportsM,n.returnZ=r.capabilities.data.supportsZ,w()&&v()&&"scene"===r.type&&null!=r.infoFor3D&&(n.returnGeometry=!0,n.formatOf3DObjects="3D_glb");const s=await r.queryFeatures(n,{signal:i});a(i);return s.features[0]}async function W(e){const{graphic:t,sketchViewModel:i,sourceLayer:r,visualVariables:n,webStyleCache:a}=e;let s=!1;const{rotation:l,size:o}=n;[l,o].forEach((async e=>{if(null==e)return;const r=t.getAttribute(e.field);if(null!=r)e.initValue(r);else{const r=await e.getDefault(t.symbol,i.view);e.initValue(r),t.setAttribute(e.field,r),s=!0}})),s&&await A(t,a);const c={multipleSelectionEnabled:!1};return"point"===r.geometryType&&(c.enableRotation=null!=l,c.enableScaling=null!=o),P(i.tooltipOptions,o,l),i.layer.elevationInfo=r.elevationInfo,i.update(t,c)}function _(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function H(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function J(e,t,i,r,n){if(null==t.geometry||"point"!==t.geometry?.type)return;const a=r.rotation,s=_(i.toolEventInfo);if(null!=a&&null!=s)if("rotate-stop"===s.type)a.isUpdatingInteractively=!1,a.initValue();else{a.isUpdatingInteractively=!0;const{field:i,getValue:r}=a;t.setAttribute(i,r(s.angle,e))}const l=r.size,o=H(i.toolEventInfo);if(null!=l&&null!=o)if("scale-stop"===o.type)l.isUpdatingInteractively=!1,l.initValue();else{l.isUpdatingInteractively=!0;const{field:i,getValue:r}=l;t.setAttribute(i,r(o.xScale,e))}await A(t,n)}async function K(e,t,n,a,s,l){const c=pe(e);await A(c,l),a.map.add(n.layer),n.layer.add(c);const u=e.sourceLayer,p=le(a,u);await Y(a,c),await W({graphic:c,sketchViewModel:n,sourceLayer:u,visualVariables:t,webStyleCache:l});const y=N(n,e,c);let d=null;p.then((e=>d=e)).catch((()=>{}));const f=t.size,m=t.rotation,h=o((()=>e.attributes),(async e=>{let t=!1;for(const i in e){const r=e[i];r!==c.getAttribute(i)&&(c.setAttribute(i,r),null==f||f.isUpdatingInteractively||f.field!==i||f.initValue(r),null==m||m.isUpdatingInteractively||m.field!==i||m.initValue(r),(null==d||d.requiredFields.includes(i))&&(t=!0))}t&&await A(c,l)})),g=n.on("update",(async e=>{const i=e.graphics[0];if("complete"===e.state)return W({graphic:i,sketchViewModel:n,sourceLayer:u,visualVariables:t,webStyleCache:l});await J(a,i,e,t,l),s(pe(i),e)})),b=n.on(["undo","redo"],(async e=>{s(pe(e.graphics[0]),e)})),w=n.updateOnGraphicClick;return{visual:i([y,r((()=>{n.updateOnGraphicClick=!1}))]),interactive:i([b,g,r((()=>n.cancel())),h,r((()=>{n.updateOnGraphicClick=w}))])}}function N(e,n,s){const l=e.view,o=n.sourceLayer,u=n.layer,p=n.getAttribute(u.objectIdField);let y=null;function d(e){y?.abort(),y=t((async t=>{const i=await le(l,o);a(t),i.setVisibility?.(p,e)}))}return d(!1),i([X(l,s,(e=>d(!e))),r((async()=>{d(!0);const t=await le(l,o);await c((()=>!t.updating)),e.layer.remove(s)}))])}function X(e,t,r){if("3d"===e.type){const n=new I({graphic:t});return i([e.trackGraphicState(n),o((()=>n.displaying),r)])}return o((()=>t.visible),r)}async function Y(e,t){if("3d"===e.type){const i=new I({graphic:t}),r=e.trackGraphicState(i);await c((()=>i.displaying)),r.remove()}else await c((()=>t.visible))}const $={icon:u(24),text:u(12),line:u(1),viewScaleSizeFactor:100};function ee(e,t,i){let r=!1;return e.filter((e=>!!r||(r=e===t,r))).map((e=>i[e]()))}function te(e){if(1!==e.length)return null;const t=e[0];if("items"in t){const e=t;return 1===e.items.length?e.items[0]:null}return t}function ie(e,t){if(e.viewModel.refreshCreationTemplates(),"awaiting-feature-creation-info"===t[0].id){const i=te(e.viewModel.featureTemplatesViewModel.items);null==i||i.supportsUpload||(e.creationInfo=i,t.shift())}return t}function re(e){switch(e){case"unknown":case"decimal-degrees":return null;default:return e}}function ne(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}function ae(e){const{creationInfo:t,viewModel:i}=e;if(!t)return!1;const{layer:r}=t,n=i.editableItems.find((e=>e.layer===r));if(n)return n.attachmentsOnCreateEnabled;const a=r.capabilities?.data,s=i.layerInfos?.find((e=>e.layer===r));return!(!(a&&"supportsAttachment"in a&&a.supportsAttachment)||s&&(!1===s.allowAttachments||!1===s.attachmentsOnUpdateEnabled))}const se=e=>/-stop/.test(e)||/vertex-/.test(e),le=(e,t)=>{const i="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(i)};function oe(e){return"createInteractiveEditSession"in e}const ce=Symbol();function ue(e){return e&&"object"==typeof e&&ce in e}function pe(e){const t=e.geometry;if("mesh"===t?.type){const i=e.cloneShallow();return i.attributes=n(e.attributes),i.geometry=t.cloneShallow(),i.geometry.transform=t.transform?.clone()??null,i}return e.clone()}function ye(e){const t=e.cursor;return e.cursor="progress",r((()=>e.cursor=t))}export{ce as UsesSketchViewModelSymbol,ie as avoidFeatureTemplateSelectionWithOnlyOneItem,oe as canCreateInteractiveEditSession,pe as cloneGraphicExceptMesh,ee as createWorkflowSteps,Q as fetchCandidates,B as fetchFullFeature,D as findLayerInfo,L as getVisualVariableAttributes,se as isTerminalUpdateEventType,ne as prepareAttachmentsForCreateWorkflow,C as setUpFeatureAdd,K as setUpGeometryUpdate,ae as shouldShowAttachmentsForCreateWorkflow,ye as showProgressCursor,$ as sizeDefaults,re as sizeVariableUnitToLengthUnit,G as startCreatingNewFeature,W as startUpdatingFeature,A as updateGraphicSymbolWhenRequired,J as visualVariableInteractiveUpdate,le as whenEditorLayerView,Y as whenGraphicDisplayed,ue as workflowUsesSketchViewModel};
package/widgets/Editor.js CHANGED
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{HandleOwnerMixin as s}from"../core/HandleOwner.js";import o from"../core/Logger.js";import{createResolver as n}from"../core/promiseUtils.js";import{watch as i,on as a,when as r,initial as l}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import{cast as d}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import{getDisplayFieldName as m}from"../layers/support/fieldUtils.js";import h from"./Attachments.js";import u from"./FeatureForm.js";import g from"./FeatureTemplates.js";import _ from"./Spinner.js";import f from"./Widget.js";import{workflowDeprecation as v}from"./Editor/deprecationUtils.js";import w from"./Editor/EditorViewModel.js";import{isModelUpload as y}from"./Editor/modelUploadUtils.js";import{renderItem as k,ItemList as b}from"./FeatureTemplates/ItemList.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{Heading as F,incrementHeadingLevel as M}from"./support/Heading.js";import A from"./support/SnappingControls.js";import{accessibleHandler as T}from"./support/decorators/accessibleHandler.js";import{messageBundle as E}from"./support/decorators/messageBundle.js";import{vmEvent as W}from"./support/decorators/vmEvent.js";import{tsx as L}from"./support/jsxFactory.js";import"./support/widgetUtils.js";import{SketchTooltipControls as I}from"./support/SketchTooltipControls/SketchTooltipControls.js";import{substitute as S}from"../intl/substitute.js";const P="esri-editor",U=`${P}__panel`,j=`${P}__prompt`,D={base:`${P} esri-widget esri-widget--panel`,actions:`${P}__actions`,helpMessage:`${P}__help-message`,panelToolbar:`${U}-toolbar`,panelContent:`${U}-content`,panelContentMessage:`${U}-content__message`,panelContentSection:`${U}-content__section`,panelContentSectionGroup:`${U}-content__section__group`,panelContentScrimContainer:`${U}-content__scrim-container`,settingsContainer:`${P}__settings`,featureTemplatesContainer:`${P}__feature-templates-container`,notice:`${P}__notice`,templateItemContentEnd:`${P}__template-item-content-end`,templateItemContentEndSuccess:`${P}__template-item-content-end--success`,templateItemContentEndError:`${P}__template-item-content-end--error`,templateItemLoader:`${P}__template-item-loader`,promptContainer:j,promptHeader:`${j}__header`,promptHeading:`${j}__header__heading`,promptMessage:`${j}__message`,promptDivider:`${j}__divider`,promptActions:`${j}__actions`,widgetIcon:"esri-icon-edit"},$={undoRedoButtons:!1,snappingControls:!0,snappingControlsElements:{header:!1,enabledToggle:!0,selfEnabledToggle:!0,featureEnabledToggle:!0,layerList:!0},sketchTooltipControls:!0};function B(e){requestAnimationFrame((()=>e.setFocus()))}const O="exclamation-mark-triangle",x="esri.widgets.Editor",H=o.getLogger(x);let N=class extends(s(f)){constructor(e,t){super(e,t),this._featureForm=new u,this._attachments=new h({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._featureTemplates=new g({enableListScroll:!1,renderItemContentEnd:e=>this._renderTemplateContentEnd(e),renderItemDescription:e=>this._renderTemplateDescription(e),renderItemLabel:e=>this._renderTemplateLabel(e),renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new _,this.headingLevel=4,this.iconClass=D.widgetIcon,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.supportingWidgetDefaults=null,this.viewModel=new w,this.visibleElements={...$},this._renderSelectIcon=()=>L("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({handleBack:e,heading:t,headingLevel:s,key:o},...n)=>{const{messagesCommon:i,viewModel:a,visibleElements:r}=this,l=a.sketchViewModel,c=a.syncing||this._attachments.submitting;return L("calcite-flow-item",{closable:!1,heading:t,headingLevel:s,key:o,loading:c,onCalciteFlowItemBack:e??void 0},L("div",{key:"panel-toolbar",class:D.panelToolbar},this._renderSettings(),r.undoRedoButtons&&[L("calcite-button",{key:"undo-button",label:i.undo,appearance:"transparent",kind:"neutral",alignment:"center",iconStart:"undo",scale:"l",disabled:!l.canUndo(),onclick:l.undo.bind(l)},i.undo),L("calcite-button",{key:"redo-button",label:i.redo,appearance:"transparent",kind:"neutral",alignment:"center",iconStart:"redo",scale:"l",disabled:!l.canRedo(),onclick:l.redo.bind(l)},i.redo)]),...n)},this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this;if("create-features"===t?.type&&y(t.data.creationInfo))return this._showPrompt({title:e.cancelUploadTitle,message:e.cancelUploadWarningMessage,yesLabel:e.discardUpload,noLabel:e.continueUpload});const s="create"===t?.type;return this._showPrompt({title:e[s?"cancelAddTitle":"cancelEditTitle"],message:e[s?"cancelAddWarningMessage":"cancelEditWarningMessage"],yesLabel:e[s?"discardFeature":"discardEdits"],noLabel:e[s?"continueAdding":"continueEditing"]})},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPrompt({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),this._onAttachmentDeleteConfirm=async()=>{const e=this._attachments,{activeWorkflow:t}=this.viewModel;t&&("create-features"===t.type?e.deleteFile():(await e.deleteAttachment(e.viewModel.activeAttachmentInfo),this._clearPrompt()),await t.previous(),this._clearPrompt())},this._onAttachmentsError=e=>{this._prompt={title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}}},this._clearPrompt=()=>{this._prompt=null},this._onBack=this._onBack.bind(this),this._onSave=this._onSave.bind(this),this._onDelete=this._onDelete.bind(this),this._onToggleUpdateWorkflow=this._onToggleUpdateWorkflow.bind(this),this._onAttachmentAdd=this._onAttachmentAdd.bind(this),this._onAttachmentUpdate=this._onAttachmentUpdate.bind(this),this._onAttachmentDelete=this._onAttachmentDelete.bind(this)}initialize(){this.addHandles([i((()=>M(this.headingLevel)),(e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e}),l),i((()=>this.viewModel.selectedTemplateItem),(e=>this._featureTemplates.select(e,{emit:!1}))),a((()=>this.viewModel.activeWorkflow),"cancel-request",(({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then((t=>t?e.allow():e.deny()))})),i((()=>this.viewModel),(e=>{this._featureForm.viewModel=e?.featureFormViewModel??null,this._attachments.viewModel=e?.attachmentsViewModel??null,this._featureTemplates.viewModel=e?.featureTemplatesViewModel??null,this._spinner.viewModel=e?.spinnerViewModel??null,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt}),l),i((()=>this.view),((e,t)=>{const s=`editor-${this.id}-spinner`;t?.ui.remove(this._spinner,s),e?.ui.add(this._spinner,{key:s,position:"manual"})}),l),r((()=>this.supportingWidgetDefaults),(e=>{this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel.set(e.sketch)}),l),r((()=>this._attachments?.error),(e=>this._onAttachmentsError(e))),r((()=>this.viewModel?.failures),(e=>{const{messages:t}=this,[{error:s,retry:o,cancel:n}]=e;this._prompt={title:t.errorWarningTitle,message:S(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{o(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{n(),this._clearPrompt()}}}}})),i((()=>this.viewModel?.state),(e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}})),i((()=>this.viewModel.featureFormDisabled),(e=>this._featureForm.disabled=e))])}destroy(){this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy()}loadDependencies(){return C({accordion:()=>import("@esri/calcite-components/dist/components/calcite-accordion.js"),"accordion-item":()=>import("@esri/calcite-components/dist/components/calcite-accordion-item.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),scrim:()=>import("@esri/calcite-components/dist/components/calcite-scrim.js")})}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger",type:"primary"}}get activeWorkflow(){return this.viewModel.activeWorkflow}get allowedWorkflows(){return this.viewModel.allowedWorkflows}set allowedWorkflows(e){this.viewModel.allowedWorkflows=e}get useDeprecatedCreateWorkflow(){return this.viewModel.useDeprecatedCreateWorkflow}set useDeprecatedCreateWorkflow(e){this.viewModel.useDeprecatedCreateWorkflow=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}castVisibleElements(e){return{...$,...e,snappingControlsElements:{...$.snappingControlsElements,...e?.snappingControlsElements}}}startCreateWorkflowAtFeatureTypeSelection(){return v(H,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),this.viewModel.startCreateWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateWorkflowAtFeatureCreation(e){return v(H,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),this.viewModel.startCreateWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateWorkflowAtFeatureEdit(e){return v(H,"startCreateWorkflowAtFeatureEdit"),this.viewModel.startCreateWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{viewModel:e}=this;if(!e)return L("div",{key:"empty",class:D.base});const{state:t}=e;return L("div",{key:"base",class:D.base},L("calcite-flow",{key:"flow"},e.pageStack.map((e=>this._renderPage(e,t))),this._renderPage(e.page,t)),this._renderPrompt())}_renderPage(e,t){switch(e){case"disabled":break;case"ready":return this._renderLanding(t);case"awaiting-feature-creation-info":return this._renderTemplates(t);case"creating-features":case"editing-new-feature":case"editing-existing-feature":return this._renderAttributeEditing(t);case"awaiting-update-feature-candidate":return this._renderFeatureList(t);case"adding-attachment":return this._renderAttachmentAdding(t);case"editing-attachment":return this._renderAttachmentEditing(t)}return L("div",null)}_renderTemplates(e){const{EditorPanel:t,headingLevel:s,messages:o,_onBack:n}=this;return L(t,{active:this._isPanelActive(e),key:"templates-panel",handleBack:n,heading:o.selectTemplate,headingLevel:s},L("div",{key:"feature-templates",class:D.panelContent},this._featureTemplates.render()))}_renderAttributeEditing(e){const{activeWorkflow:t,EditorPanel:s,messages:o,messagesCommon:n,headingLevel:i,_onBack:a,viewModel:r}=this;if(!t)return null;const l=t.type,c=r.featureFormViewModel,d="update"===l&&!t.hasPendingEdits||r.syncing||c.updating,p="update"===l?o.editFeature:o.createFeatures,m="update"===l?n.update:n.create,h="create-features"===l&&"create-new"===t.createFeatureState,u="create-features"===l?t.numPendingFeatures:0,g=u>1?S(o.createFeaturesTemplate,{numFeatures:u}):m,_=t.shouldShowAttachments,f=c.inputs.every((e=>!e.visible))&&!_?this._renderMessage(S(o.clickToFinishTemplate,{button:m})):L("div",{key:"panel-content-section",class:D.panelContentSection},this._renderNotices(t),L("div",{class:D.panelContentSectionGroup},this._featureForm.render(),_&&L("div",{key:"attachments"},L(F,{level:M(i)},o.attachments),this._attachments.render())));return L(s,{active:this._isPanelActive(e),key:"attribute-editing-panel",heading:p,headingLevel:i,handleBack:a},L("div",{key:"panel-content",class:this.classes(D.panelContent,{[D.panelContentScrimContainer]:h})},f,h&&L("calcite-scrim",null)),this._renderFooterActions([{clickHandler:this._onSave,disabled:d,label:g,type:"primary"},r.shouldShowDeleteButton?{...this._deleteButtonCommonInfo,clickHandler:this._onDelete,disabled:r.syncing,label:n.delete}:null]))}_renderNotices(e){return[this._renderOwnerAdminNotice(e),this._renderInvalidFormTemplateNotice(e),this._renderInvalidDateFieldNotice(e)]}_renderOwnerAdminNotice(e){return e?.reliesOnOwnerAdminPrivileges&&this._renderNotice(this.messages.ownerAdminNotice)}_renderInvalidFormTemplateNotice(e){return e?.hasInvalidFormTemplate&&this._renderNotice(this.messages.formFieldUpdateError,{icon:O})}_renderInvalidDateFieldNotice(e){return e?.hasUnsupportedFields&&this._renderNotice(this.messages.formFieldUnsupportedUpdateError,{icon:O})}_renderNotice(e,t){return L("calcite-notice",{open:!0,scale:"s",class:D.notice,...t},L("div",{slot:"message"},e))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:s}=this;let o=null;return e.group.items.some((e=>(s.itemHasUnsupportedFields(e)?o=t.formFieldUnsupportedCreateError:s.itemHasInvalidFormTemplate(e)&&(o=t.formFieldCreateError),o))),o?this._renderNotice(o,{icon:O}):null}_renderAttachmentAdding(e){const{_attachments:t,EditorPanel:s,_onBack:o,headingLevel:n,messages:i,messagesCommon:a}=this;return L(s,{active:this._isPanelActive(e),key:"attachment-adding-panel",heading:i.addAttachment,headingLevel:n,handleBack:o},L("div",{key:"attachments",class:D.panelContent},t.render()),this._renderFooterActions([{label:t.submitting?a.cancel:a.add,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._onAttachmentAdd}]))}_renderAttachmentEditing(e){const{_attachments:t,EditorPanel:s,_onBack:o,activeWorkflow:n,headingLevel:i,messages:a,messagesCommon:r}=this;return n?L(s,{active:this._isPanelActive(e),key:"attachment-editing-panel",heading:a.editAttachment,headingLevel:i,handleBack:o},L("div",{key:"attachments",class:D.panelContent},t.render()),n.shouldAllowAttachmentEditing?this._renderFooterActions([{label:r.update,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._onAttachmentUpdate},{...this._deleteButtonCommonInfo,clickHandler:this._onAttachmentDelete,disabled:t.submitting,label:r.delete}]):void 0):null}_renderMessage(e){return L("div",{key:"panel-content-message",class:D.panelContentMessage},e)}_renderFooterActions(e){return L("div",{key:"footer-actions",slot:"footer",class:D.actions},e.filter(t).map((({type:e,disabled:t,class:s,clickHandler:o,label:n,...i},a)=>L("calcite-button",{key:`action-${a}`,slot:"footer-actions",class:s,disabled:t??!1,onclick:o,width:"full",...i},n))))}_renderPrompt(){const e=this._prompt;if(!e)return null;const{title:t,message:s,context:o,actions:n}=e,i=n.secondary;let a;switch(o){case"danger":a="danger";break;case"info":a="brand";break;default:a="neutral"}const r=L("calcite-button",{afterCreate:B,appearance:"solid",key:"prompt-primary-button",kind:a,onclick:n.primary.action,scale:"m",width:i?"half":"full"},n.primary.label),l=i&&L("calcite-button",{appearance:"outline",key:"prompt-secondary-button",kind:a,onclick:i.action,scale:"m",width:"half"},i.label);return L("calcite-scrim",{key:"prompt"},L("div",{class:`${D.promptContainer}--${o}`},L("div",{class:D.promptHeader},L("calcite-icon",{icon:O}),L(F,{class:D.promptHeading,level:this.headingLevel},t)),L("div",{class:D.promptMessage},s),L("div",{class:D.promptDivider}),L("div",{class:D.promptActions},l,r)))}_renderLanding(e){const{EditorPanel:t,headingLevel:s,messages:o,viewModel:n}=this,{canUpdate:i}=n,a=this._featureTemplates.viewModel.numberOfFeatureTemplates,r=!i&&0===a;return L(t,{active:this._isPanelActive(e),key:"landing-panel",heading:o.widgetLabel,headingLevel:s},L("div",{key:"landing-content",class:D.panelContent},i&&L("div",{key:"edit-actions",class:D.panelContentSection},this._renderUpdateActions(e)),a>0&&L("div",{key:"create-actions",class:D.panelContentSection},this._renderCreateActions()),r&&L("div",{key:"no-content",class:D.panelContentMessage},o.noEditableLayers)),this._renderFooterHelpMessages())}_renderFooterHelpMessages(){const{activeWorkflow:e,messages:t,view:s}=this,o=e?.helpMessage,n=o?t["3d"===s?.type?"helpMessages3d":"helpMessages2d"]?.[o]:null;return n?L("div",{key:"footer-actions",slot:"footer",class:D.helpMessage},n):null}_renderUpdateActions(e){const{messages:t,messagesCommon:s}=this,o={id:"select",label:s.select};return L("div",{key:"update-actions"},L(F,{level:M(this.headingLevel)},t.editFeatures),L("calcite-list",{selectionMode:"single",selectionAppearance:"border"},k({grouped:!1,item:o,selectedItem:"awaiting-feature-to-update"===e?o:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){const{_featureTemplates:e,headingLevel:t,messages:s}=this;return L("div",{key:"create-actions"},L(F,{level:M(t)},s.createFeatures),L("div",{key:"templates",class:D.featureTemplatesContainer},e.render()))}_renderTemplateLabel(e){return e.label}_renderTemplateDescription(e){const t=this._getUploadForTemplateItem(e);if(!t)return null;const{messages:s}=this;switch(t.state){case"pending":return s?.uploadPending;case"error":return s?.uploadError;default:return null}}_renderTemplateContentEnd(e){const t=this._getUploadForTemplateItem(e),s=L("calcite-icon",{key:"upload-icon",class:D.templateItemContentEnd,icon:"upload-to"});if(!t)return e.supportsUpload?s:null;switch(t.state){case"success":return L("calcite-icon",{key:"success-icon",class:this.classes(D.templateItemContentEnd,D.templateItemContentEndSuccess),icon:"check"});case"error":return L("calcite-icon",{key:"error-icon",class:this.classes(D.templateItemContentEnd,D.templateItemContentEndError),icon:"exclamation-mark-circle-f"});case"pending":return L("calcite-loader",{class:D.templateItemLoader,inline:!0,key:"loader",label:"",scale:"s",type:"indeterminate"});case"canceled":case"default":return s}}_getUploadForTemplateItem(e){const t=this.activeWorkflow;if("create-features"!==t?.type)return null;const{data:s}=t,{creationInfo:o,upload:n}=s;return o?.template===e.template&&o?.layer===e.layer?n:null}_renderFeatureList(e){const{EditorPanel:s,_onBack:o,headingLevel:n,messages:i,messagesTemplates:a,viewModel:{activeWorkflow:r,editableItems:l}}=this;if("update"!==r?.type)return null;const c=r.data.candidates,d=S(i.multipleFeaturesTemplate,{total:c.length}),p=new Map;let m=0;c.map((e=>({label:this._getLabel(e),id:e.attributes[e.layer.objectIdField],data:e}))).filter((e=>{const{label:t,data:s}=e,o=this._filterText.toLowerCase(),{title:n}=s.layer,i=l.find((e=>e.layer===s.layer));if(!i)return null;const{attachmentsOnUpdateEnabled:a,supports:r}=i;return(r.includes("update")||r.includes("delete")||a)&&(!o||t?.toLowerCase().includes(o)||n?.toLowerCase().includes(o))})).filter(t).forEach((e=>{m++;const t=e.data.layer;p.has(t)?p.get(t)?.items.push(e):p.set(t,{id:`${t.id}`,label:t.title??"",items:[e]})}));const h=l.toArray().map((({layer:e})=>p.get(e))).filter(t),u=m>10||this._filterText.length>0;return L(s,{active:this._isPanelActive(e),key:"feature-list",heading:d,headingLevel:n,handleBack:o},L("div",{key:"feature-list",class:D.panelContent},L("div",{class:D.panelContentSection},b({enableListScroll:!1,filterEnabled:u,filterText:this._filterText,id:this.id,items:h,messages:{filterPlaceholder:a.filterPlaceholder,noItems:a.noItems,noMatches:a.noMatches},onFilterChange:e=>this._filterText=e,onItemMouseEnter:e=>this.viewModel.selectFeature(e.data),onItemMouseLeave:()=>this.viewModel.selectFeature(null),onItemSelect:e=>this.viewModel.selectFeature(e.data,!0)}))))}_isPanelActive(e){return this.viewModel.state===e}_renderSettings(){const e=this.visibleElements,t=e.snappingControls,s=e.sketchTooltipControls;return t||s?L("calcite-accordion",{key:"settings",class:D.settingsContainer,appearance:"transparent"},L("calcite-accordion-item",{heading:this.messagesCommon?.settings,iconStart:"gear"},s&&L(I,{tooltipOptions:this.tooltipOptions}),t&&L(A,{snappingOptions:this.snappingOptions,view:this.view,visibleElements:e.snappingControlsElements,afterCreate:e=>e.layerListOpen=!1}))):null}_getLabel(e){const t=e.layer;if(!t)return null;const s=t.fieldsIndex.get(t.objectIdField),o=s.alias||s.name,{attributes:n}=e,i=m(t);return i&&n[i]&&`${n[i]}`||`${o}: ${n[s.name]}`}_showPrompt({title:e,message:t,yesLabel:s,noLabel:o}){const i=n(),{view:a}=this,r=a?.focused;return this._prompt={title:e,message:t,context:"danger",actions:{primary:{label:s,action:()=>i.resolve(!0)},secondary:{label:o,action:()=>i.resolve(!1)}}},i.promise.finally((()=>{this._clearPrompt(),r&&a?.focus()}))}_onSave(){this.viewModel.saveWorkflow()}_onDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteFeatureFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepFeature,action:this._clearPrompt}}}}async _onBack(e){return e?.stopPropagation(),this.viewModel.back()}_onAttachmentAdd(){const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.addFile(),e.previous()):this._attachments.addAttachment().then((()=>e.previous())))}_onAttachmentUpdate(){const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.previous()):this._attachments.updateAttachment().then((()=>e.previous())))}_onAttachmentDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:this._onAttachmentDeleteConfirm},secondary:{label:e.keepAttachment,action:this._clearPrompt}}}}};e([c()],N.prototype,"_featureForm",void 0),e([c()],N.prototype,"_attachments",void 0),e([c()],N.prototype,"_featureTemplates",void 0),e([c()],N.prototype,"_filterText",void 0),e([c()],N.prototype,"_prompt",void 0),e([c()],N.prototype,"_spinner",void 0),e([c()],N.prototype,"_deleteButtonCommonInfo",null),e([c({readOnly:!0})],N.prototype,"activeWorkflow",null),e([c()],N.prototype,"allowedWorkflows",null),e([c()],N.prototype,"useDeprecatedCreateWorkflow",null),e([c()],N.prototype,"headingLevel",void 0),e([c()],N.prototype,"iconClass",void 0),e([c()],N.prototype,"label",null),e([c()],N.prototype,"labelOptions",null),e([c()],N.prototype,"layerInfos",null),e([c(),E("esri/widgets/Editor/t9n/Editor")],N.prototype,"messages",void 0),e([c(),E("esri/t9n/common")],N.prototype,"messagesCommon",void 0),e([c(),E("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],N.prototype,"messagesTemplates",void 0),e([c()],N.prototype,"snappingOptions",null),e([c()],N.prototype,"tooltipOptions",null),e([c()],N.prototype,"supportingWidgetDefaults",void 0),e([c()],N.prototype,"view",null),e([c(),W(["workflow-cancel","workflow-commit"])],N.prototype,"viewModel",void 0),e([c()],N.prototype,"visibleElements",void 0),e([d("visibleElements")],N.prototype,"castVisibleElements",null),e([T()],N.prototype,"_onSave",null),e([T()],N.prototype,"_onDelete",null),e([T()],N.prototype,"_onBack",null),e([T()],N.prototype,"_onAttachmentAdd",null),e([T()],N.prototype,"_onAttachmentUpdate",null),e([T()],N.prototype,"_onAttachmentDelete",null),N=e([p(x)],N);const V=N;export{V as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{isSome as t}from"../core/arrayUtils.js";import{HandleOwnerMixin as s}from"../core/HandleOwner.js";import o from"../core/Logger.js";import{createResolver as n}from"../core/promiseUtils.js";import{watch as a,on as i,when as r,initial as l}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import{cast as d}from"../core/accessorSupport/decorators/cast.js";import"../core/has.js";import{subclass as p}from"../core/accessorSupport/decorators/subclass.js";import{getDisplayFieldName as m}from"../layers/support/fieldUtils.js";import h from"./Attachments.js";import u from"./FeatureForm.js";import g from"./FeatureTemplates.js";import _ from"./Spinner.js";import f from"./Widget.js";import{workflowDeprecation as w}from"./Editor/deprecationUtils.js";import v from"./Editor/EditorViewModel.js";import{isModelUpload as y}from"./Editor/modelUploadUtils.js";import{renderItem as k,ItemList as b}from"./FeatureTemplates/ItemList.js";import{loadCalciteComponents as C}from"./support/componentsUtils.js";import{Heading as F,incrementHeadingLevel as M}from"./support/Heading.js";import A from"./support/SnappingControls.js";import{accessibleHandler as T}from"./support/decorators/accessibleHandler.js";import{messageBundle as E}from"./support/decorators/messageBundle.js";import{vmEvent as W}from"./support/decorators/vmEvent.js";import{tsx as L}from"./support/jsxFactory.js";import"./support/widgetUtils.js";import{SketchTooltipControls as I}from"./support/SketchTooltipControls/SketchTooltipControls.js";import{substitute as S}from"../intl/substitute.js";const P="esri-editor",U=`${P}__panel`,j=`${P}__prompt`,D={base:`${P} esri-widget esri-widget--panel`,actions:`${P}__actions`,helpMessage:`${P}__help-message`,panelToolbar:`${U}-toolbar`,panelContent:`${U}-content`,panelContentMessage:`${U}-content__message`,panelContentSection:`${U}-content__section`,panelContentSectionGroup:`${U}-content__section__group`,panelContentScrimContainer:`${U}-content__scrim-container`,settingsContainer:`${P}__settings`,featureTemplatesContainer:`${P}__feature-templates-container`,notice:`${P}__notice`,templateItemContentEnd:`${P}__template-item-content-end`,templateItemContentEndSuccess:`${P}__template-item-content-end--success`,templateItemContentEndError:`${P}__template-item-content-end--error`,templateItemLoader:`${P}__template-item-loader`,promptContainer:j,promptHeader:`${j}__header`,promptHeading:`${j}__header__heading`,promptMessage:`${j}__message`,promptDivider:`${j}__divider`,promptActions:`${j}__actions`,widgetIcon:"esri-icon-edit"},$={undoRedoButtons:!1,snappingControls:!0,snappingControlsElements:{header:!1,enabledToggle:!0,selfEnabledToggle:!0,featureEnabledToggle:!0,layerList:!0},sketchTooltipControls:!0};function B(e){requestAnimationFrame((()=>e.setFocus()))}const O="exclamation-mark-triangle",x="esri.widgets.Editor",H=o.getLogger(x);let N=class extends(s(f)){constructor(e,t){super(e,t),this._featureForm=new u,this._attachments=new h({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._featureTemplates=new g({enableListScroll:!1,renderItemContentEnd:e=>this._renderTemplateContentEnd(e),renderItemDescription:e=>this._renderTemplateDescription(e),renderItemLabel:e=>this._renderTemplateLabel(e),renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new _,this.headingLevel=4,this.iconClass=D.widgetIcon,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.supportingWidgetDefaults=null,this.viewModel=new v,this.visibleElements={...$},this._renderSelectIcon=()=>L("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({handleBack:e,heading:t,headingLevel:s,key:o},...n)=>{const{messagesCommon:a,viewModel:i,visibleElements:r}=this,l=i.sketchViewModel,c=i.syncing||this._attachments.submitting;return L("calcite-flow-item",{closable:!1,heading:t,headingLevel:s,key:o,loading:c,onCalciteFlowItemBack:e??void 0},L("div",{key:"panel-toolbar",class:D.panelToolbar},this._renderSettings(),r.undoRedoButtons&&[L("calcite-button",{key:"undo-button",label:a.undo,appearance:"transparent",kind:"neutral",alignment:"center",iconStart:"undo",scale:"l",disabled:!l.canUndo(),onclick:l.undo.bind(l)},a.undo),L("calcite-button",{key:"redo-button",label:a.redo,appearance:"transparent",kind:"neutral",alignment:"center",iconStart:"redo",scale:"l",disabled:!l.canRedo(),onclick:l.redo.bind(l)},a.redo)]),...n)},this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this;if("create-features"===t?.type&&y(t.data.creationInfo))return this._showPrompt({title:e.cancelUploadTitle,message:e.cancelUploadWarningMessage,yesLabel:e.discardUpload,noLabel:e.continueUpload});const s="create"===t?.type;return this._showPrompt({title:e[s?"cancelAddTitle":"cancelEditTitle"],message:e[s?"cancelAddWarningMessage":"cancelEditWarningMessage"],yesLabel:e[s?"discardFeature":"discardEdits"],noLabel:e[s?"continueAdding":"continueEditing"]})},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPrompt({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),this._onAttachmentDeleteConfirm=async()=>{const e=this._attachments,{activeWorkflow:t}=this.viewModel;t&&("create-features"===t.type?e.deleteFile():(await e.deleteAttachment(e.viewModel.activeAttachmentInfo),this._clearPrompt()),await t.back(),this._clearPrompt())},this._onAttachmentsError=e=>{this._prompt={title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}}},this._clearPrompt=()=>{this._prompt=null},this._onBack=this._onBack.bind(this),this._onSave=this._onSave.bind(this),this._onDelete=this._onDelete.bind(this),this._onToggleUpdateWorkflow=this._onToggleUpdateWorkflow.bind(this),this._onAttachmentAdd=this._onAttachmentAdd.bind(this),this._onAttachmentUpdate=this._onAttachmentUpdate.bind(this),this._onAttachmentDelete=this._onAttachmentDelete.bind(this)}initialize(){this.addHandles([a((()=>M(this.headingLevel)),(e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e}),l),a((()=>this.viewModel.selectedTemplateItem),(e=>this._featureTemplates.select(e,{emit:!1}))),i((()=>this.viewModel.activeWorkflow),"cancel-request",(({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then((t=>t?e.allow():e.deny()))})),a((()=>this.viewModel),(e=>{this._featureForm.viewModel=e?.featureFormViewModel??null,this._attachments.viewModel=e?.attachmentsViewModel??null,this._featureTemplates.viewModel=e?.featureTemplatesViewModel??null,this._spinner.viewModel=e?.spinnerViewModel??null,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt}),l),a((()=>this.view),((e,t)=>{const s=`editor-${this.id}-spinner`;t?.ui.remove(this._spinner,s),e?.ui.add(this._spinner,{key:s,position:"manual"})}),l),r((()=>this.supportingWidgetDefaults),(e=>{this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel.set(e.sketch)}),l),r((()=>this._attachments?.error),(e=>this._onAttachmentsError(e))),r((()=>this.viewModel?.failures),(e=>{const{messages:t}=this,[{error:s,retry:o,cancel:n}]=e;this._prompt={title:t.errorWarningTitle,message:S(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{o(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{n(),this._clearPrompt()}}}}})),a((()=>this.viewModel?.state),(e=>{switch(e){case"awaiting-feature-to-update":case"ready":case"disabled":this._filterText="",this._featureTemplates.filterText=""}})),a((()=>this.viewModel.featureFormDisabled),(e=>this._featureForm.disabled=e))])}destroy(){this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy()}loadDependencies(){return C({accordion:()=>import("@esri/calcite-components/dist/components/calcite-accordion.js"),"accordion-item":()=>import("@esri/calcite-components/dist/components/calcite-accordion-item.js"),button:()=>import("@esri/calcite-components/dist/components/calcite-button.js"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item.js"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow.js"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon.js"),list:()=>import("@esri/calcite-components/dist/components/calcite-list.js"),loader:()=>import("@esri/calcite-components/dist/components/calcite-loader.js"),notice:()=>import("@esri/calcite-components/dist/components/calcite-notice.js"),scrim:()=>import("@esri/calcite-components/dist/components/calcite-scrim.js")})}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger",type:"primary"}}get activeWorkflow(){return this.viewModel.activeWorkflow}get allowedWorkflows(){return this.viewModel.allowedWorkflows}set allowedWorkflows(e){this.viewModel.allowedWorkflows=e}get useDeprecatedCreateWorkflow(){return this.viewModel.useDeprecatedCreateWorkflow}set useDeprecatedCreateWorkflow(e){this.viewModel.useDeprecatedCreateWorkflow=e}get label(){return this.messages?.widgetLabel??""}set label(e){this._overrideIfSome("label",e)}get labelOptions(){return this.viewModel.labelOptions}set labelOptions(e){this.viewModel.labelOptions=e}get layerInfos(){return this.viewModel.layerInfos}set layerInfos(e){this.viewModel.layerInfos=e}get snappingOptions(){return this.viewModel.snappingOptions}set snappingOptions(e){this.viewModel.snappingOptions=e}get tooltipOptions(){return this.viewModel.tooltipOptions}set tooltipOptions(e){this.viewModel.tooltipOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}castVisibleElements(e){return{...$,...e,snappingControlsElements:{...$.snappingControlsElements,...e?.snappingControlsElements}}}startCreateWorkflowAtFeatureTypeSelection(){return w(H,"startCreateWorkflowAtFeatureTypeSelection","startCreateFeaturesWorkflowAtFeatureTypeSelection"),this.viewModel.startCreateWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateWorkflowAtFeatureCreation(e){return w(H,"startCreateWorkflowAtFeatureCreation","startCreateFeaturesWorkflowAtFeatureCreation"),this.viewModel.startCreateWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateWorkflowAtFeatureEdit(e){return w(H,"startCreateWorkflowAtFeatureEdit"),this.viewModel.startCreateWorkflowAtFeatureEdit(e)}startUpdateWorkflowAtFeatureSelection(){return this.viewModel.startUpdateWorkflowAtFeatureSelection()}startUpdateWorkflowAtMultipleFeatureSelection(e){return this.viewModel.startUpdateWorkflowAtMultipleFeatureSelection(e)}startUpdateWorkflowAtFeatureEdit(e){return this.viewModel.startUpdateWorkflowAtFeatureEdit(e)}deleteFeatureFromWorkflow(){return this.viewModel.deleteFeatureFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{viewModel:e}=this;if(!e)return L("div",{key:"empty",class:D.base});const{state:t}=e;return L("div",{key:"base",class:D.base},L("calcite-flow",{key:"flow"},e.pageStack.map((e=>this._renderPage(e,t))),this._renderPage(e.page,t)),this._renderPrompt())}_renderPage(e,t){switch(e){case"disabled":break;case"ready":return this._renderLanding(t);case"awaiting-feature-creation-info":return this._renderTemplates(t);case"creating-features":case"editing-new-feature":case"editing-existing-feature":return this._renderAttributeEditing(t);case"awaiting-update-feature-candidate":return this._renderFeatureList(t);case"adding-attachment":return this._renderAttachmentAdding(t);case"editing-attachment":return this._renderAttachmentEditing(t)}return L("div",null)}_renderTemplates(e){const{EditorPanel:t,headingLevel:s,messages:o,_onBack:n}=this;return L(t,{active:this._isPanelActive(e),key:"templates-panel",handleBack:n,heading:o.selectTemplate,headingLevel:s},L("div",{key:"feature-templates",class:D.panelContent},this._featureTemplates.render()))}_renderAttributeEditing(e){const{activeWorkflow:t,EditorPanel:s,messages:o,messagesCommon:n,headingLevel:a,_onBack:i,viewModel:r}=this;if(!t)return null;const l=t.type,c=r.featureFormViewModel,d="update"===l&&!t.hasPendingEdits||r.syncing||c.updating,p="update"===l?o.editFeature:o.createFeatures,m="update"===l?n.update:n.create,h="create-features"===l&&"create-new"===t.createFeatureState,u="create-features"===l?t.numPendingFeatures:0,g=u>1?S(o.createFeaturesTemplate,{numFeatures:u}):m,_=t.shouldShowAttachments,f=c.inputs.every((e=>!e.visible))&&!_?this._renderMessage(S(o.clickToFinishTemplate,{button:m})):L("div",{key:"panel-content-section",class:D.panelContentSection},this._renderNotices(t),L("div",{class:D.panelContentSectionGroup},this._featureForm.render(),_&&L("div",{key:"attachments"},L(F,{level:M(a)},o.attachments),this._attachments.render())));return L(s,{active:this._isPanelActive(e),key:"attribute-editing-panel",heading:p,headingLevel:a,handleBack:i},L("div",{key:"panel-content",class:this.classes(D.panelContent,{[D.panelContentScrimContainer]:h})},f,h&&L("calcite-scrim",null)),this._renderFooterActions([{clickHandler:this._onSave,disabled:d,label:g,type:"primary"},r.shouldShowDeleteButton?{...this._deleteButtonCommonInfo,clickHandler:this._onDelete,disabled:r.syncing,label:n.delete}:null]))}_renderNotices(e){return[this._renderOwnerAdminNotice(e),this._renderInvalidFormTemplateNotice(e),this._renderInvalidDateFieldNotice(e)]}_renderOwnerAdminNotice(e){return e?.reliesOnOwnerAdminPrivileges&&this._renderNotice(this.messages.ownerAdminNotice)}_renderInvalidFormTemplateNotice(e){return e?.hasInvalidFormTemplate&&this._renderNotice(this.messages.formFieldUpdateError,{icon:O})}_renderInvalidDateFieldNotice(e){return e?.hasUnsupportedFields&&this._renderNotice(this.messages.formFieldUnsupportedUpdateError,{icon:O})}_renderNotice(e,t){return L("calcite-notice",{open:!0,scale:"s",class:D.notice,...t},L("div",{slot:"message"},e))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:s}=this;let o=null;return e.group.items.some((e=>(s.itemHasUnsupportedFields(e)?o=t.formFieldUnsupportedCreateError:s.itemHasInvalidFormTemplate(e)&&(o=t.formFieldCreateError),o))),o?this._renderNotice(o,{icon:O}):null}_renderAttachmentAdding(e){const{_attachments:t,EditorPanel:s,_onBack:o,headingLevel:n,messages:a,messagesCommon:i}=this;return L(s,{active:this._isPanelActive(e),key:"attachment-adding-panel",heading:a.addAttachment,headingLevel:n,handleBack:o},L("div",{key:"attachments",class:D.panelContent},t.render()),this._renderFooterActions([{label:t.submitting?i.cancel:i.add,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._onAttachmentAdd}]))}_renderAttachmentEditing(e){const{_attachments:t,EditorPanel:s,_onBack:o,activeWorkflow:n,headingLevel:a,messages:i,messagesCommon:r}=this;return n?L(s,{active:this._isPanelActive(e),key:"attachment-editing-panel",heading:i.editAttachment,headingLevel:a,handleBack:o},L("div",{key:"attachments",class:D.panelContent},t.render()),n.shouldAllowAttachmentEditing?this._renderFooterActions([{label:r.update,disabled:t.submitting||!t.selectedFile,type:"primary",clickHandler:this._onAttachmentUpdate},{...this._deleteButtonCommonInfo,clickHandler:this._onAttachmentDelete,disabled:t.submitting,label:r.delete}]):void 0):null}_renderMessage(e){return L("div",{key:"panel-content-message",class:D.panelContentMessage},e)}_renderFooterActions(e){return L("div",{key:"footer-actions",slot:"footer",class:D.actions},e.filter(t).map((({type:e,disabled:t,class:s,clickHandler:o,label:n,...a},i)=>L("calcite-button",{key:`action-${i}`,slot:"footer-actions",class:s,disabled:t??!1,onclick:o,width:"full",...a},n))))}_renderPrompt(){const e=this._prompt;if(!e)return null;const{title:t,message:s,context:o,actions:n}=e,a=n.secondary;let i;switch(o){case"danger":i="danger";break;case"info":i="brand";break;default:i="neutral"}const r=L("calcite-button",{afterCreate:B,appearance:"solid",key:"prompt-primary-button",kind:i,onclick:n.primary.action,scale:"m",width:a?"half":"full"},n.primary.label),l=a&&L("calcite-button",{appearance:"outline",key:"prompt-secondary-button",kind:i,onclick:a.action,scale:"m",width:"half"},a.label);return L("calcite-scrim",{key:"prompt"},L("div",{class:`${D.promptContainer}--${o}`},L("div",{class:D.promptHeader},L("calcite-icon",{icon:O}),L(F,{class:D.promptHeading,level:this.headingLevel},t)),L("div",{class:D.promptMessage},s),L("div",{class:D.promptDivider}),L("div",{class:D.promptActions},l,r)))}_renderLanding(e){const{EditorPanel:t,headingLevel:s,messages:o,viewModel:n}=this,{canUpdate:a}=n,i=this._featureTemplates.viewModel.numberOfFeatureTemplates,r=!a&&0===i;return L(t,{active:this._isPanelActive(e),key:"landing-panel",heading:o.widgetLabel,headingLevel:s},L("div",{key:"landing-content",class:D.panelContent},a&&L("div",{key:"edit-actions",class:D.panelContentSection},this._renderUpdateActions(e)),i>0&&L("div",{key:"create-actions",class:D.panelContentSection},this._renderCreateActions()),r&&L("div",{key:"no-content",class:D.panelContentMessage},o.noEditableLayers)),this._renderFooterHelpMessages())}_renderFooterHelpMessages(){const{activeWorkflow:e,messages:t,view:s}=this,o=e?.helpMessage,n=o?t["3d"===s?.type?"helpMessages3d":"helpMessages2d"]?.[o]:null;return n?L("div",{key:"footer-actions",slot:"footer",class:D.helpMessage},n):null}_renderUpdateActions(e){const{messages:t,messagesCommon:s}=this,o={id:"select",label:s.select};return L("div",{key:"update-actions"},L(F,{level:M(this.headingLevel)},t.editFeatures),L("calcite-list",{selectionMode:"single",selectionAppearance:"border"},k({grouped:!1,item:o,selectedItem:"awaiting-feature-to-update"===e?o:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){const{_featureTemplates:e,headingLevel:t,messages:s}=this;return L("div",{key:"create-actions"},L(F,{level:M(t)},s.createFeatures),L("div",{key:"templates",class:D.featureTemplatesContainer},e.render()))}_renderTemplateLabel(e){return e.label}_renderTemplateDescription(e){const t=this._getUploadForTemplateItem(e);if(!t)return null;const{messages:s}=this;switch(t.state){case"pending":return s?.uploadPending;case"error":return s?.uploadError;default:return null}}_renderTemplateContentEnd(e){const t=this._getUploadForTemplateItem(e),s=L("calcite-icon",{key:"upload-icon",class:D.templateItemContentEnd,icon:"upload-to"});if(!t)return e.supportsUpload?s:null;switch(t.state){case"success":return L("calcite-icon",{key:"success-icon",class:this.classes(D.templateItemContentEnd,D.templateItemContentEndSuccess),icon:"check"});case"error":return L("calcite-icon",{key:"error-icon",class:this.classes(D.templateItemContentEnd,D.templateItemContentEndError),icon:"exclamation-mark-circle-f"});case"pending":return L("calcite-loader",{class:D.templateItemLoader,inline:!0,key:"loader",label:"",scale:"s",type:"indeterminate"});case"canceled":case"default":return s}}_getUploadForTemplateItem(e){const t=this.activeWorkflow;if("create-features"!==t?.type)return null;const{data:s}=t,{creationInfo:o,upload:n}=s;return o?.template===e.template&&o?.layer===e.layer?n:null}_renderFeatureList(e){const{EditorPanel:s,_onBack:o,headingLevel:n,messages:a,messagesTemplates:i,viewModel:{activeWorkflow:r,editableItems:l}}=this;if("update"!==r?.type)return null;const c=r.data.candidates,d=S(a.multipleFeaturesTemplate,{total:c.length}),p=new Map;let m=0;c.map((e=>({label:this._getLabel(e),id:e.attributes[e.layer.objectIdField],data:e}))).filter((e=>{const{label:t,data:s}=e,o=this._filterText.toLowerCase(),{title:n}=s.layer,a=l.find((e=>e.layer===s.layer));if(!a)return null;const{attachmentsOnUpdateEnabled:i,supports:r}=a;return(r.includes("update")||r.includes("delete")||i)&&(!o||t?.toLowerCase().includes(o)||n?.toLowerCase().includes(o))})).filter(t).forEach((e=>{m++;const t=e.data.layer;p.has(t)?p.get(t)?.items.push(e):p.set(t,{id:`${t.id}`,label:t.title??"",items:[e]})}));const h=l.toArray().map((({layer:e})=>p.get(e))).filter(t),u=m>10||this._filterText.length>0;return L(s,{active:this._isPanelActive(e),key:"feature-list",heading:d,headingLevel:n,handleBack:o},L("div",{key:"feature-list",class:D.panelContent},L("div",{class:D.panelContentSection},b({enableListScroll:!1,filterEnabled:u,filterText:this._filterText,id:this.id,items:h,messages:{filterPlaceholder:i.filterPlaceholder,noItems:i.noItems,noMatches:i.noMatches},onFilterChange:e=>this._filterText=e,onItemMouseEnter:e=>this.viewModel.selectFeature(e.data),onItemMouseLeave:()=>this.viewModel.selectFeature(null),onItemSelect:e=>this.viewModel.selectFeature(e.data,!0)}))))}_isPanelActive(e){return this.viewModel.state===e}_renderSettings(){const e=this.visibleElements,t=e.snappingControls,s=e.sketchTooltipControls;return t||s?L("calcite-accordion",{key:"settings",class:D.settingsContainer,appearance:"transparent"},L("calcite-accordion-item",{heading:this.messagesCommon?.settings,iconStart:"gear"},s&&L(I,{tooltipOptions:this.tooltipOptions}),t&&L(A,{snappingOptions:this.snappingOptions,view:this.view,visibleElements:e.snappingControlsElements,afterCreate:e=>e.layerListOpen=!1}))):null}_getLabel(e){const t=e.layer;if(!t)return null;const s=t.fieldsIndex.get(t.objectIdField),o=s.alias||s.name,{attributes:n}=e,a=m(t);return a&&n[a]&&`${n[a]}`||`${o}: ${n[s.name]}`}_showPrompt({title:e,message:t,yesLabel:s,noLabel:o}){const a=n(),{view:i}=this,r=i?.focused;return this._prompt={title:e,message:t,context:"danger",actions:{primary:{label:s,action:()=>a.resolve(!0)},secondary:{label:o,action:()=>a.resolve(!1)}}},a.promise.finally((()=>{this._clearPrompt(),r&&i?.focus()}))}_onSave(){this.viewModel.saveWorkflow()}_onDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteWarningTitle,message:e.deleteWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteFeatureFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepFeature,action:this._clearPrompt}}}}async _onBack(e){return e?.stopPropagation(),this.viewModel.back()}_onAttachmentAdd(){const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.addFile(),e.back()):this._attachments.addAttachment().then((()=>e.back())))}_onAttachmentUpdate(){const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.back()):this._attachments.updateAttachment().then((()=>e.back())))}_onAttachmentDelete(){const{messages:e,messagesCommon:t}=this;this._prompt={title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:this._onAttachmentDeleteConfirm},secondary:{label:e.keepAttachment,action:this._clearPrompt}}}}};e([c()],N.prototype,"_featureForm",void 0),e([c()],N.prototype,"_attachments",void 0),e([c()],N.prototype,"_featureTemplates",void 0),e([c()],N.prototype,"_filterText",void 0),e([c()],N.prototype,"_prompt",void 0),e([c()],N.prototype,"_spinner",void 0),e([c()],N.prototype,"_deleteButtonCommonInfo",null),e([c({readOnly:!0})],N.prototype,"activeWorkflow",null),e([c()],N.prototype,"allowedWorkflows",null),e([c()],N.prototype,"useDeprecatedCreateWorkflow",null),e([c()],N.prototype,"headingLevel",void 0),e([c()],N.prototype,"iconClass",void 0),e([c()],N.prototype,"label",null),e([c()],N.prototype,"labelOptions",null),e([c()],N.prototype,"layerInfos",null),e([c(),E("esri/widgets/Editor/t9n/Editor")],N.prototype,"messages",void 0),e([c(),E("esri/t9n/common")],N.prototype,"messagesCommon",void 0),e([c(),E("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],N.prototype,"messagesTemplates",void 0),e([c()],N.prototype,"snappingOptions",null),e([c()],N.prototype,"tooltipOptions",null),e([c()],N.prototype,"supportingWidgetDefaults",void 0),e([c()],N.prototype,"view",null),e([c(),W(["workflow-cancel","workflow-commit"])],N.prototype,"viewModel",void 0),e([c()],N.prototype,"visibleElements",void 0),e([d("visibleElements")],N.prototype,"castVisibleElements",null),e([T()],N.prototype,"_onSave",null),e([T()],N.prototype,"_onDelete",null),e([T()],N.prototype,"_onBack",null),e([T()],N.prototype,"_onAttachmentAdd",null),e([T()],N.prototype,"_onAttachmentUpdate",null),e([T()],N.prototype,"_onAttachmentDelete",null),N=e([p(x)],N);const V=N;export{V as default};