@arcgis/core 4.32.0-next.20250219 → 4.32.0-next.20250221

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 (198) hide show
  1. package/applications/ExperienceBuilder/sketchUtils.d.ts +1 -0
  2. package/applications/ExperienceBuilder/sketchUtils.js +1 -1
  3. package/arcade/featureSetUtils.js +1 -1
  4. package/arcade/functions/featuresetbase.js +1 -1
  5. package/assets/esri/core/workers/RemoteClient.js +1 -1
  6. package/assets/esri/core/workers/chunks/0c3930e40fc9f8a84599.js +2 -0
  7. package/assets/esri/core/workers/chunks/{ccee343fb8c415b59ce3.js.LICENSE.txt → 0c3930e40fc9f8a84599.js.LICENSE.txt} +1 -1
  8. package/assets/esri/core/workers/chunks/37323e58dbec303f5054.js +1 -0
  9. package/assets/esri/core/workers/chunks/486df1e042204b90b0dd.js.LICENSE.txt +1 -1
  10. package/assets/esri/core/workers/chunks/{c2d539359f321bba3432.js → 52c13b3c074c9f6dadde.js} +2 -2
  11. package/assets/esri/core/workers/chunks/{c2d539359f321bba3432.js.LICENSE.txt → 52c13b3c074c9f6dadde.js.LICENSE.txt} +1 -1
  12. package/assets/esri/core/workers/chunks/{f1c9595096c047e93145.js → 5341b86c2fb5347393c5.js} +1 -1
  13. package/assets/esri/core/workers/chunks/5693d9ce4472a4c5959f.js.LICENSE.txt +1 -1
  14. package/assets/esri/core/workers/chunks/5b56b271afb0fadf48b4.js.LICENSE.txt +1 -1
  15. package/assets/esri/core/workers/chunks/60d5cbfa9e1c6b3c98df.js +1 -0
  16. package/assets/esri/core/workers/chunks/{a5acbdb8347a809a26c0.js → 610c3249fe81e370af8c.js} +1 -1
  17. package/assets/esri/core/workers/chunks/6518954889df2e781c47.js.LICENSE.txt +1 -1
  18. package/assets/esri/core/workers/chunks/{d98c78e89d70ad0b8628.js → 6ab476f696290d190c6c.js} +1 -1
  19. package/assets/esri/core/workers/chunks/7292bb19b73f601d891b.js +1 -0
  20. package/assets/esri/core/workers/chunks/78c066e8fe167d4ab817.js +1 -0
  21. package/assets/esri/core/workers/chunks/80744ad7f7656ef918db.js +1 -0
  22. package/assets/esri/core/workers/chunks/8bbe8df40df2b8e54562.js +1 -0
  23. package/assets/esri/core/workers/chunks/b0952b81d5be214262dd.js.LICENSE.txt +1 -1
  24. package/assets/esri/core/workers/chunks/caf410ed75c40b3703eb.js +1 -0
  25. package/assets/esri/core/workers/chunks/df506c4f81affce248c4.js +1 -0
  26. package/assets/esri/core/workers/chunks/{4be39bc2d2edd94bdb75.js → e481e7d508274bc83c70.js} +1 -1
  27. package/assets/esri/core/workers/chunks/eefa1dfeb63ce965bb40.js +1 -0
  28. package/assets/esri/core/workers/chunks/fd8790291348fb7ead55.js +1 -0
  29. package/assets/esri/themes/base/widgets/_Editor.scss +7 -0
  30. package/assets/esri/themes/base/widgets/_ItemList.scss +14 -0
  31. package/assets/esri/themes/base/widgets/_ResponsiveToolbar.scss +9 -3
  32. package/assets/esri/themes/base/widgets/_Sketch.scss +32 -24
  33. package/assets/esri/themes/dark/main.css +1 -1
  34. package/assets/esri/themes/light/main.css +1 -1
  35. package/assets/esri/themes/light/view.css +1 -1
  36. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ar.json +1 -1
  37. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_bg.json +1 -1
  38. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_bs.json +1 -1
  39. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ca.json +1 -1
  40. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_cs.json +1 -1
  41. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_da.json +1 -1
  42. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_de.json +1 -1
  43. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_el.json +1 -1
  44. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_es.json +1 -1
  45. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_et.json +1 -1
  46. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_fi.json +1 -1
  47. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_fr.json +1 -1
  48. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_he.json +1 -1
  49. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_hr.json +1 -1
  50. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_hu.json +1 -1
  51. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_id.json +1 -1
  52. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_it.json +1 -1
  53. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ja.json +1 -1
  54. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ko.json +1 -1
  55. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_lt.json +1 -1
  56. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_lv.json +1 -1
  57. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_nl.json +1 -1
  58. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_no.json +1 -1
  59. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_pl.json +1 -1
  60. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_pt-BR.json +1 -1
  61. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_pt-PT.json +1 -1
  62. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ro.json +1 -1
  63. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_ru.json +1 -1
  64. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sk.json +1 -1
  65. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sl.json +1 -1
  66. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sr.json +1 -1
  67. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_sv.json +1 -1
  68. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_th.json +1 -1
  69. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_tr.json +1 -1
  70. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_uk.json +1 -1
  71. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_vi.json +1 -1
  72. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_zh-CN.json +1 -1
  73. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_zh-HK.json +1 -1
  74. package/assets/esri/widgets/BatchAttributeForm/t9n/BatchAttributeForm_zh-TW.json +1 -1
  75. package/copyright.txt +1 -1
  76. package/core/sql/AggregateFunctions.js +1 -1
  77. package/core/sql/DateOnly.js +1 -1
  78. package/core/sql/SqlInterval.js +1 -1
  79. package/core/sql/SqlTimestampOffset.js +1 -1
  80. package/core/sql/TimeOnly.js +1 -1
  81. package/core/sql/WhereClause.js +1 -1
  82. package/core/sql/WhereGrammar.js +1 -1
  83. package/core/sql/sqlCompareUtils.js +1 -1
  84. package/core/sql/sqlDateParsingUtils.js +1 -1
  85. package/editing/sharedTemplates/SharedTemplate.js +1 -1
  86. package/editing/sharedTemplates/SharedTemplateMetadata.js +1 -1
  87. package/editing/sharedTemplates/SharedTemplateProvider.js +1 -1
  88. package/editing/sharedTemplates/executor/support/createServiceEdit.js +1 -1
  89. package/editing/sharedTemplates/support/sharedTemplateErrors.js +1 -1
  90. package/editing/sharedTemplates/templateDefinitions/FeatureTemplateDefinition.js +1 -1
  91. package/editing/sharedTemplates/templateDefinitions/GroupTemplateDefinition.js +1 -1
  92. package/editing/sharedTemplates/templateDefinitions/PresetTemplateDefinition.js +1 -1
  93. package/editing/sharedTemplates/templateDefinitions/TemplateDefinitionBase.js +1 -1
  94. package/editing/sharedTemplates/templateDefinitions/parts/FeatureTemplateRelationshipPart.js +1 -1
  95. package/editing/sharedTemplates/templateDefinitions/parts/GroupTemplatePart.js +1 -1
  96. package/editing/sharedTemplates/templateDefinitions/parts/TemplatePartBase.js +1 -1
  97. package/interfaces.d.ts +480 -65
  98. package/layers/RouteLayer.js +1 -1
  99. package/layers/orientedImagery/core/coverageUtils.js +1 -1
  100. package/layers/orientedImagery/transformations/imageToWorld.js +1 -1
  101. package/layers/orientedImagery/transformations/rectifyMapPoint.js +1 -1
  102. package/layers/orientedImagery/transformations/utils.js +1 -1
  103. package/layers/orientedImagery/transformations/worldToImage.js +1 -1
  104. package/layers/support/Relationship.js +1 -1
  105. package/networks/RulesTable.js +1 -1
  106. package/networks/UtilityNetwork.js +1 -1
  107. package/package.json +2 -2
  108. package/rest/route.js +1 -1
  109. package/rest/support/PointBarrier.js +1 -1
  110. package/rest/support/RouteParameters.js +1 -1
  111. package/rest/support/RouteSolveResult.js +1 -1
  112. package/support/revision.js +1 -1
  113. package/symbols/cim/fitVectorMarker.js +1 -1
  114. package/undoredo/support/Services.js +1 -1
  115. package/views/2d/AnimationManager.js +1 -1
  116. package/views/2d/engine/webgl/TextureManager.js +1 -1
  117. package/views/2d/engine/webgl/Utils.js +1 -1
  118. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelTechnique.js +1 -1
  119. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
  120. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  121. package/views/2d/layers/RouteLayerView2D.js +1 -1
  122. package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
  123. package/views/2d/layers/features/sources/FeatureCache.js +1 -1
  124. package/views/2d/layers/features/sources/FeatureSource.js +1 -1
  125. package/views/2d/layers/features/sources/FeatureSourceQueryInfo.js +1 -1
  126. package/views/2d/layers/features/sources/strategies/chunks/Overrides.js +1 -1
  127. package/views/2d/layers/features/sources/strategies/support/snapshotUtils.js +5 -0
  128. package/views/2d/layers/features/support/whereUtils.js +1 -1
  129. package/views/3d/layers/I3SMeshView3D.js +1 -1
  130. package/views/View.js +1 -1
  131. package/views/animation/easing.js +1 -1
  132. package/webmap/utils.js +1 -1
  133. package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
  134. package/widgets/BatchAttributeForm/inputs/FieldInput.js +1 -1
  135. package/widgets/BatchAttributeForm/templates/support/createBatchFormTemplate.js +1 -1
  136. package/widgets/BatchAttributeForm.js +1 -1
  137. package/widgets/Directions/DirectionsViewModel.js +1 -1
  138. package/widgets/Directions.js +1 -1
  139. package/widgets/Editor/AddAssociationWorkflow.js +1 -1
  140. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  141. package/widgets/Editor/CreateFeaturesWorkflowData.js +1 -1
  142. package/widgets/Editor/Edits.js +1 -1
  143. package/widgets/Editor/UpdateWorkflow.js +1 -1
  144. package/widgets/Editor/components/PendingFeatureList.js +1 -1
  145. package/widgets/Editor/components/Prompt.js +1 -1
  146. package/widgets/Editor/workflowUtils.js +1 -1
  147. package/widgets/Editor.js +1 -1
  148. package/widgets/ElevationProfile/components/LegendItem.js +1 -1
  149. package/widgets/ElevationProfile/components/SettingsButton.js +1 -1
  150. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/AssociationDetails.js +1 -1
  151. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js +1 -1
  152. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js +1 -1
  153. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js +1 -1
  154. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/VisibleElements.js +5 -0
  155. package/widgets/FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js +1 -1
  156. package/widgets/FeatureForm/UtilityNetworkAssociationInput.js +1 -1
  157. package/widgets/FeatureForm/VisibleElements.js +5 -0
  158. package/widgets/FeatureForm/featureFormUtils.js +1 -1
  159. package/widgets/FeatureForm.js +1 -1
  160. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  161. package/widgets/FeatureTable/support/FeatureStore.js +1 -1
  162. package/widgets/Legend/styles/support/utils.js +1 -1
  163. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  164. package/widgets/OrientedImageryViewer/adapters/sketch/DataCaptureAdapter.js +5 -0
  165. package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
  166. package/widgets/OrientedImageryViewer/components/ImageOverlays.js +1 -1
  167. package/widgets/OrientedImageryViewer/components/ImageViewerViewModel.js +1 -1
  168. package/widgets/OrientedImageryViewer/components/OverlayLayersListViewModel.js +1 -1
  169. package/widgets/OrientedImageryViewer/constants.js +1 -1
  170. package/widgets/OrientedImageryViewer/dataCaptureUtils.js +5 -0
  171. package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
  172. package/widgets/OrientedImageryViewer/symbols.js +1 -1
  173. package/widgets/OrientedImageryViewer.js +1 -1
  174. package/widgets/Sketch/SketchViewModel.js +1 -1
  175. package/widgets/Sketch/support/ResponsiveToolbar/OverflowGroup.js +1 -1
  176. package/widgets/Sketch/support/ResponsiveToolbar/ResponsiveToolbar.js +1 -1
  177. package/widgets/Sketch/support/ResponsiveToolbar/SplitButton.js +1 -1
  178. package/widgets/Sketch/support/sketchUtils.js +1 -1
  179. package/widgets/Sketch.js +1 -1
  180. package/widgets/support/FilterCondition.js +1 -1
  181. package/widgets/support/GoTo.js +1 -1
  182. package/widgets/support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js +1 -1
  183. package/widgets/support/UtilityNetworkAssociations/utilityNetworkUtils.js +1 -1
  184. package/widgets/support/goToUtils.js +1 -1
  185. package/widgets/support/symbolPreviewUtils.js +1 -1
  186. package/assets/esri/core/workers/chunks/10ca2107c99fab6bcc3b.js +0 -1
  187. package/assets/esri/core/workers/chunks/122ed10cac9f192e1eec.js +0 -1
  188. package/assets/esri/core/workers/chunks/1b3a52ce3e8e5be4d196.js +0 -1
  189. package/assets/esri/core/workers/chunks/1bf646c9fc352f98d1ca.js +0 -1
  190. package/assets/esri/core/workers/chunks/35e4af82a08b4eadbfab.js +0 -1
  191. package/assets/esri/core/workers/chunks/6f007703662e714b2f0a.js +0 -1
  192. package/assets/esri/core/workers/chunks/8232a2c4bdc3011bb9e3.js +0 -1
  193. package/assets/esri/core/workers/chunks/8b8579d81728cb35bb29.js +0 -1
  194. package/assets/esri/core/workers/chunks/934857de20f6f5c15188.js +0 -1
  195. package/assets/esri/core/workers/chunks/b8fae500c69ca2cff62a.js +0 -1
  196. package/assets/esri/core/workers/chunks/ccee343fb8c415b59ce3.js +0 -2
  197. package/widgets/OrientedImageryViewer/adapters/sketch/DigitizationAdapter.js +0 -5
  198. package/widgets/OrientedImageryViewer/digitizationUtils.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import a from"../../core/Error.js";import{makeHandle as i,handlesGroup as r,abortHandle as s}from"../../core/handleUtils.js";import"../../core/has.js";import{removeMaybe as o,destroyMaybe as n}from"../../core/maybe.js";import{isPromiseLike as l,debounce as d}from"../../core/promiseUtils.js";import{watch as c,when as u,initial as h,whenOnce as p,syncAndInitial as m}from"../../core/reactiveUtils.js";import{generateBracedUUID as f}from"../../core/uuid.js";import{property as w}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as g}from"../../core/accessorSupport/decorators/subclass.js";import{isSharedTemplate as y,isSharedTemplateOrMetadata as v}from"../../editing/templateUtils.js";import{createTemplateExecutor as F}from"../../editing/sharedTemplates/executor/createTemplateExecutor.js";import _ from"../../layers/GraphicsLayer.js";import{isTable as b}from"../../layers/support/layerUtils.js";import{getDisplayedSymbol as M}from"../../symbols/support/symbolUtils.js";import{getDrawHelpMessage as V}from"../../views/draw/support/helpMessageUtils.js";import I from"../../views/draw/support/HighlightHelper.js";import k from"../../views/interactive/sketch/SketchOptions.js";import S from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as C}from"../../views/support/HighlightDefaults.js";import P from"./CreateFeaturesWorkflowData.js";import{isModelUpload as A,handleModelUpload as H}from"./modelUploadUtils.js";import E from"./Workflow.js";import{startCreatingNewFeature as T,findLayerInfo as j,updateGraphicSymbolWhenRequired as U,isTerminalUpdateEventType as L,getVisualVariableAttributes as x,startUpdatingFeatureGeometry as O,createWorkflowSteps as R,avoidFeatureTemplateSelectionWithOnlyOneItem as W,getCreationAttributes as D,getFullTemplateForCreationInfo as N,getServiceLayersById as G,prepareAttachmentsForCreateFeaturesWorkflow as z,showProgressCursor as Z,setUpSketchCreateWatchers as q,setVisualVariablesAndElevationInfoForUpdate as B,visualVariableInteractiveUpdate as K}from"./workflowUtils.js";import J from"../FeatureForm/FeatureFormViewModel.js";import Q from"../Sketch/SketchViewModel.js";var X;const Y=Symbol(),$=Symbol(),ee=Symbol(),te=Symbol(),ae={point:["point"],multipoint:["multipoint"],polygon:["polygon","freehandPolygon","rectangle","circle"],polyline:["polyline","freehandPolyline"],mesh:[],multipatch:[]};let ie=X=class extends E{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.data=void 0,this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._webStyleCache=new Map,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._featureFormViewModel=new J,this._sketchViewModel=null,this._attachmentFileInfos=new Map,this._isActive=!0}initialize(){this.isNested&&(this._isActive=!1),this._initializeSketchViewModel()}destroy(){this._sketchViewModel.destroy()}get featureFormViewModel(){return this._featureFormViewModel}get hasPendingEdits(){if(this.pendingFeatures.some((e=>!!this.data.getEditsForPendingFeature(e)?.modified)))return!0;const{creationInfo:e,upload:t}=this.data,a=this._sketchViewModel,{activeComponent:i}=a,r=a.createGraphic?.geometry?.type;return!("polyline"!==r&&"polygon"!==r&&"multipoint"!==r||"draw-2d"!==i?.type&&"draw-3d"!==i?.type)&&i.drawOperation.committedVertices.length>0||(!(!t||"pending"!==t.state&&"success"!==t.state)||!!e?.geometryToPlace)}get hasPreviousStep(){return this._stepIndex>0||"update-pending"===this.createFeatureState&&!!this.data.selectedPendingFeature}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const a=e.layer.geometryType,i=this._sketchViewModel.createGraphic;if("mesh"===a){this._getDrawMeshHelpMessage||import("../../views/draw/support/helpMessageUtils3d.js").then((e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage}));const{view:e}=t;return"3d"===e?.type?this._getDrawMeshHelpMessage?.(i,e):void 0}const r=this._sketchViewModel.activeCreateToolDrawMode,s=this._sketchViewModel.activeTool;return V("rectangle"===s?"rectangle":"circle"===s?"circle":a,i?.geometry,r)}get layer(){return this.data.creationInfo?.layer}get numPendingFeatures(){return this.pendingFeatures.length}get parent(){return this.data.parent}get parentLayer(){return this.parent?.data.editorItem.layer}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){return this.data.editorItem?.capabilities.create.reliesOnOwnerAdminPrivileges??!1}get shouldShowAttachments(){return(this.data.selectedPendingFeature&&this.data.editorItem?.capabilities.create.attachments.enabled)??!1}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get sketchViewModel(){return this._sketchViewModel}get test(){}get availableCreateTools(){const e=this.data.creationInfo?.layer.geometryType,t=this.data.viewModel.view;return e?this.data.creationInfo?.maxFeatures&&this.data.creationInfo.maxFeatures<=this.numPendingFeatures||"2d"!==t?.type&&"multipoint"===e?[]:[...ae[e]]:[]}get _attachmentsActive(){const e=this.data.viewModel.attachmentsViewModel.mode,t=this.stepId;return this.shouldShowAttachments&&("add"===e||"edit"===e||"adding-attachment"===t||"editing-attachment"===t)}async enter(){this._isActive=!0,"awaiting-feature-creation-info"!==this.stepId&&this._setUpCreatingFeaturesStep()}exit(){this._isActive=!1,this.removeHandles([ee])}async updatePendingFeature(e){if(e!==this.data.selectedPendingFeature)return this._sketchViewModel.cancel(),this._startUpdating({feature:e})}async start(){return await super.start(),b(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}async save(){const{featureFormViewModel:e}=this;if(e.pendingSubtypeChoice)return;e.submit(),this._stashValidationState();const t=this.data.selectedPendingFeature,a=this._hasValidationErrors(t)?t:this.data.pendingFeatures.find((e=>this._hasValidationErrors(e)));return a?(await this._startUpdating({feature:a}),void e?.submit()):super.save()}back(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||A(this.data.creationInfo)||this._attachmentsActive?super.back(e):this._clearSelectedFeature()}previous(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||A(this.data.creationInfo)||this._attachmentsActive?super.previous(e):this._clearSelectedFeature()}cancelFeature(e){this.data.removePendingFeature(e),this.sketchViewModel.layer.graphics.remove(e)}static create(e){const{addAttachmentsCallback:t,applyEditsCallback:a,applyEditsFeatureServiceCallback:i,isNested:r,creationInfo:s,parent:o,snappingManager:n,startAt:l,viewModel:d}=e,c=e.sketchOptions??new k,u=s?.layer,h=u?d.findEditorItemForLayer(u):void 0,p=new X({data:new P({creationInfo:s,editorItem:h,parent:o,sketchOptions:c,snappingManager:n,viewModel:d}),isNested:r,onCommit:async e=>{const{creationInfo:r}=e;if(!r)return;p._sketchViewModel.cancel();const s=e.pendingFeatures.toArray(),{layer:o}=r,n=o.capabilities?.editing.supportsGlobalId&&"globalIdField"in o,l=p._attachmentFileInfos,{fullTemplate:d,templateExecutorInfo:c}=e,u=d&&y(d)&&c?.completionResult;if(n){if(ne(s),u){const e=de(c.completionResult.edits,l);await i(d.featureService,e,{globalIdUsed:!0,gdbVersion:d.layer.gdbVersion??void 0})}else{const e=le(s,l);await a(o,e,{globalIdUsed:!0})}return}const h=u?await i(d.featureService,c.completionResult.edits,{gdbVersion:d.layer.gdbVersion??void 0}):[await a(o,{addFeatures:s})];h&&l.size>0&&await Promise.all(h.map((e=>{if(e?.addFeatureResults)return t(o,oe(s,e.addFeatureResults,o,l))})))}});return p._set("steps",this._createWorkflowSteps(p,l)),p}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",i((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,i((()=>e.opacity=t))}async _startCreating(){this.removeHandles($);const{data:e}=this;if(!e.creationInfo)return;const t=this.data.creationInfo?.maxFeatures;if(t&&this.numPendingFeatures>=t)return this.sketchViewModel.cancel(),void(this.numPendingFeatures&&await this._startUpdating({feature:this.pendingFeatures.at(-1)}));this.createFeatureState="create-new";const a=await T(this._sketchViewModel,e,this._webStyleCache);this.addHandles(a,$)}async _clearSelectedFeature(){const e=this._featureFormViewModel.pendingSubtypeChoice;e&&(e.resolve("undo"),await e.promise),this._stashValidationState(),this.sketchViewModel.cancel(),this.data.selectedPendingFeature=null,this._featureFormHandle=o(this._featureFormHandle),this._featureFormViewModel.feature=null;const t=this.data.viewModel.attachmentsViewModel;"add"!==t.mode&&"edit"!==t.mode||this.data.viewModel.activeWorkflow?.previous()}_stashValidationState(){const e=this._featureFormViewModel.feature,t=e&&this.data.getEditsForPendingFeature(e);t&&(t.submittable=this._featureFormViewModel.submittable)}async _selectFeatureForUpdate({feature:e,initialFeature:t=e}){this._stashValidationState();const{data:a,pendingFeatures:i,_webStyleCache:s}=this;i.includes(e)||a.addPendingFeature(e,t),a.selectedPendingFeature=e;const{_featureFormViewModel:n,_sketchViewModel:l}=this,{creationInfo:d,viewModel:u}=a,{attachmentsViewModel:h,layerInfos:p,view:m}=u;if(!m||!d)return;o(this._featureFormHandle);const f=e.sourceLayer,w=j(p,f),g=w?.formTemplate,y=m.spatialReference;n.set({arcadeEditType:"INSERT",feature:e,formTemplate:g,spatialReference:y,map:m.map}),"add"!==h.mode&&"edit"!==h.mode||u.activeWorkflow?.previous(),h.graphic=e,h.fileInfos.removeAll(),h.mode="view";(this._attachmentFileInfos.get(e)||[]).forEach((({file:e,form:t})=>h.addFile(e,t))),await U(e,s,"2d"===m.type?m.scale:null);const v=a.getEditsForPendingFeature(e);this._featureFormHandle=r([n.on("value-change",(async()=>{v?.updateAttributes(n.getValues()),await U(e,s,"2d"===m.type?m.scale:null)})),l.on(["update","undo","redo"],(e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&L(e.toolEventInfo.type))&&n.notifyFeatureGeometryChanged()})),c((()=>n.feature?.sourceLayer),(t=>e.sourceLayer=t)),c((()=>[n.feature,n.submittable]),(()=>this._stashValidationState()))]),this.createFeatureState="update-pending"}async _startUpdating({feature:e,initialFeature:t=e}){await this._selectFeatureForUpdate({feature:e,initialFeature:t});const{_sketchViewModel:a,data:i}=this,{creationInfo:r,viewModel:s}=i,{view:o}=s;if(!o||!r)return;const n=e.sourceLayer??r.layer;return b(n)?void 0:(this._visualVariableAttributes=x(e),O({graphic:e,sketchViewModel:a,sourceLayer:n,visualVariables:this._visualVariableAttributes,webStyleCache:this._webStyleCache}))}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=R(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],t,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){const{creationInfo:t,viewModel:i}=a,{view:r}=i;r&&(A(t)?e.addHandles(await H({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&e.addHandles(i.restrictFeatureTemplatesViewModelToLayer(t.layer),this.id),e.addHandles(i.featureTemplatesViewModel.on("select",(({item:t})=>{t&&(a.creationInfo={...a.creationInfo,layer:t.layer,template:t.template},e.next())})),this.id)))},async tearDown(){e.removeHandles(this.id)}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([ee,Y,$,te]),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 W(a,i)}static _configureSketchViewModel(e){const{data:t}=e,a=e._webStyleCache,{creationInfo:s,viewModel:o}=t,{view:n}=o,l=e._sketchViewModel,h=[];if(!n)return i();if("2d"===n.type){s&&h.push(e._fadeExistingFeatures(s.layer));const t=d(((e,t)=>Promise.all(e.map((e=>U(e,a,t))))));h.push(c((()=>n.scale),(e=>t(l.layer.graphics,e))))}const p=D(t.fullTemplate,s?.attributeOverrides),m=async i=>{if("start"!==i.state||e.hasHandles($)||e.addHandles(await q({creationAttributes:p,data:t,sketchViewModel:l,view:n,webStyleCache:a}),$),"cancel"!==i.state&&"complete"!==i.state||e.removeHandles($),"cancel"===i.state&&null!==n.activeTool&&n.activeTool!==e.sketchViewModel.activeComponent&&(await e._waitForActiveToolCleared(),await e._startCreating()),"complete"===i.state&&i.graphic){const t=await e._processEdits(i.graphic,{scale:"2d"===n.type?n.scale:null,useSourceLayer:!0,webStyleCache:e._webStyleCache});t&&(await e._waitForActiveToolCleared(),await e._startUpdating({feature:t}))}},f=async a=>{const{attachmentsViewModel:i}=o,{_featureFormViewModel:r}=e;if(a.graphics.length>1)return void await e._clearSelectedFeature();const d=a.graphics[0];if("complete"===a.state){const{submittable:t}=r;if(e.numPendingFeatures!==s?.maxFeatures&&t||r.submit(),await e._clearSelectedFeature(),"add"!==i.mode&&"edit"!==i.mode||o.activeWorkflow?.previous(),!a.aborted&&n.activeTool===e.sketchViewModel.activeComponent&&(await e.sketchViewModel.wait(),"ready"===e.sketchViewModel.state&&"mesh"!==e.data.creationInfo?.layer.geometryType))return e._startCreating()}else{if("start"===a.state)return d.sourceLayer??=t.creationInfo?.layer,await B({sketchViewModel:l,graphic:d,visualVariables:e._visualVariableAttributes,webStyleCache:e._webStyleCache,sourceLayer:d.sourceLayer}),e._selectFeatureForUpdate({feature:d});if("active"===a.state){await e.updatePendingFeature(d);const t=e._visualVariableAttributes;await K(n,d,a,t,e._webStyleCache);const i=d.attributes,{rotation:s,size:o}=t;if(null!=s){const{field:e}=s;r.setValue(e,i[e])}if(null!=o){const{field:e}=o;r.setValue(e,i[e])}}}},w=async a=>{if(a.graphics.forEach((e=>{t.removePendingFeature(e)})),!A(t.creationInfo))return e._startCreating()},g=async()=>{if(A(t.creationInfo))try{await e.data.viewModel.back()}catch{}return e._startCreating()};h.push(l.on("create",(t=>e._updatingHandles.addPromise(m(t)))),l.on("update",(t=>e._updatingHandles.addPromise(f(t)))),l.on("delete",(t=>e._updatingHandles.addPromise(w(t)))),u((()=>!e.numPendingFeatures),(()=>e._updatingHandles.addPromise(g()))),i((()=>{l.cancel()})),re(l,t),...se(t));const y=r(h);return l.addHandles(y),y}_initializeSketchViewModel(){const{data:e}=this,{view:t}=e.viewModel,a=new _({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:"hide",title:"createFeaturesWorkflow-internal"}),r=new Q({layer:a,creationMode:"single",sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},view:t});this._sketchViewModel=r,t?.map.add(a),this.addHandles([i((()=>{t?.destroyed||t?.map.remove(a),a.destroy()})),c((()=>this.numPendingFeatures>0),(e=>this._sketchViewModel.updateOnGraphicClick=e),h)])}_hasValidationErrors(e){return!!e&&(!this.data.isSubmittable(e)||!!this._featureFormViewModel.validateContingencyConstraints(e.attributes,{includeIncompleteViolations:!0})?.length)}async _processEdits(e,t){const{data:a}=this,{layerInfos:i,view:r}=a.viewModel,s=this._featureFormViewModel,{templateExecutorInfo:o}=a;if(!o){const t=e.clone();return t.geometry=null,a.addPendingFeature(e,t),e}const n=this.sketchViewModel.layer;n.remove(e);const{executor:d}=o,c=d(e.geometry,"completion"),u=l(c)?await c:c;o.completionResult=u,s.arcadeEditType="INSERT",s.map=r?.map,s.spatialReference=r?.spatialReference;for(const l of u.edits){let e=null;if(l.addFeatures)for(const r of l.addFeatures){const o=r.clone();o.geometry=null,r.symbol=await M(r,t),n.add(r);const l=a.addPendingFeature(r,o);r.sourceLayer!==e?.layer&&(e=j(i,r.sourceLayer)),s.feature=r,s.formTemplate=e?.formTemplate,await p((()=>!s.updating)),l.submittable=s.submittable}}s.feature=null,await p((()=>!s.updating));return u.edits.reduce(((e,t)=>e+(t.addFeatures?.length??0)),0)>1?null:u.primary?.graphic}async _setUpCreatingFeaturesStep(){if(this.hasHandles(ee))return;const{data:e,sketchViewModel:s}=this,{creationInfo:n,viewModel:l}=e,{attachmentsViewModel:d,view:u}=l;if(!u||!n?.layer)throw new a("missing-parameters","CreateFeaturesWorkflow requires a view and creationInfo.");const{initialFeature:p,layer:m}=n,f=[];if(this._featureFormHandle=o(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},e.editorItem=l.findEditorItemForLayer(n.layer),null===e.fullTemplate&&n.template){const t=await N(n,u);e.fullTemplate=t,t&&y(t)&&(e.templateExecutorInfo={completionResult:null,executor:await F(t),serviceLayersById:await G(n.layer,u)})}z(d),f.push(c((()=>d.mode),(e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}})));const w=Z(u);f.push(w);const g=b(n.layer);try{if(g){const{template:e}=n;if(e&&v(e))throw new a("Shared templates are not yet supported");const i=p??new t({attributes:{...e?.prototype.attributes,...n.attributeOverrides},sourceLayer:m});await this._startUpdating({feature:i})}else f.push(X._configureSketchViewModel(this)),p?(s.layer.add(p),await this._startUpdating({feature:p})):await this._startCreating()}finally{w.remove()}const _=i((()=>{for(const t of e.pendingFeatures)s.layer.remove(t),e.removePendingFeature(t)})),M=c((()=>u?.timeZone),(e=>this._featureFormViewModel.timeZone=e),h),V=i((()=>{A(n)&&l.cancelWorkflow({warnIfNoWorkflow:!1})}));this._featureFormHandle&&f.push(this._featureFormHandle),this.addHandles(f,this._handleKeys.beforeCommit),this.addHandles([i((()=>d.fileInfos.removeAll())),r(f),V,_,M],ee)}async _waitForActiveToolCleared(){const e=this.data.viewModel.view;if(null==e?.activeTool)return;const t=new AbortController;this.addHandles(s(t),te),await p((()=>null==e?.activeTool),t.signal),t.abort()}};function re(e,t){let a=null;const s=()=>e.snappingOptions.featureSources,o=()=>(a=new S({layer:e.layer}),s().add(a),a),l=()=>{null!=a&&(s().remove(a),a=n(a))};return r([c((()=>{const e=t.creationInfo?.layer,a=s().find((t=>t.layer===e));return{hasFeatureLayerSource:!!a,enabled:a?.enabled??!1}}),(({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return l();a??=o(),a.enabled=t}),m),i(l)])}function se(e){const t=e.viewModel.view;if(!t)return[];const a=[];if("3d"===t.type){const r=new I({view:t});a.push(c((()=>e.selectedPendingFeature),((e,t)=>{r.remove(e),r.add(t)})),i((()=>r.destroy())))}const r=new I({view:t,highlightName:C});return a.push(c((()=>e.temporaryHighlightFeature),(e=>{r.removeAll(),r.add(e)})),i((()=>r.destroy()))),a}function oe(e,t,a,i){const r=[];return t.forEach(((t,s)=>{if(!t.error){const o=e[s],n=i.get(o)||[];o.attributes[a.objectIdField]=t.objectId,n.forEach((({form:e})=>r.push({feature:o,attachment:e})))}})),r}function ne(e){for(const t of e){const{sourceLayer:e}=t;e&&"globalIdField"in e&&null!=e.globalIdField&&(t.attributes[e.globalIdField]??=f())}}function le(e,t){const a=[];if(!t||0===t.size)return{addFeatures:e};for(const[i,r]of t)for(const{file:e}of r)a.push({feature:i,attachment:{globalId:f(),data:e}});return a.length?{addFeatures:e,addAttachments:a}:{addFeatures:e}}function de(e,t){return e.map((e=>{const{addFeatures:a}=e;if(!a||0===a.length)return e;const i=[];for(const r of a){const e=t.get(r);if(e)for(const{file:t}of e)i.push({feature:r,attachment:{globalId:f(),data:t}})}return i.length?{...e,addAttachments:i}:e}))}e([w()],ie.prototype,"createFeatureState",void 0),e([w()],ie.prototype,"data",void 0),e([w({constructOnly:!0})],ie.prototype,"isNested",void 0),e([w()],ie.prototype,"featureFormViewModel",null),e([w()],ie.prototype,"hasPendingEdits",null),e([w()],ie.prototype,"hasPreviousStep",null),e([w()],ie.prototype,"_getDrawMeshHelpMessage",void 0),e([w()],ie.prototype,"helpMessage",null),e([w()],ie.prototype,"layer",null),e([w()],ie.prototype,"parent",null),e([w()],ie.prototype,"parentLayer",null),e([w()],ie.prototype,"keyboardCancellationEnabled",null),e([w()],ie.prototype,"reliesOnOwnerAdminPrivileges",null),e([w()],ie.prototype,"shouldShowAttachments",null),e([w()],ie.prototype,"shouldAllowAttachmentEditing",null),e([w()],ie.prototype,"sketchViewModel",null),e([w()],ie.prototype,"availableCreateTools",null),e([w()],ie.prototype,"_attachmentsActive",null),ie=X=e([g("esri.widgets.Editor.CreateFeaturesWorkflow")],ie);const ce=ie;export{ce 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,handlesGroup as r,abortHandle as s}from"../../core/handleUtils.js";import"../../core/has.js";import o from"../../core/Logger.js";import{removeMaybe as n,destroyMaybe as l}from"../../core/maybe.js";import{isPromiseLike as d,debounce as c}from"../../core/promiseUtils.js";import{watch as u,when as h,initial as p,whenOnce as m,syncAndInitial as f}from"../../core/reactiveUtils.js";import{generateBracedUUID as w}from"../../core/uuid.js";import{property as g}from"../../core/accessorSupport/decorators/property.js";import"../../core/RandomLCG.js";import{subclass as y}from"../../core/accessorSupport/decorators/subclass.js";import{isSharedTemplateOrMetadata as v,isSharedTemplate as F}from"../../editing/templateUtils.js";import{createTemplateExecutor as _}from"../../editing/sharedTemplates/executor/createTemplateExecutor.js";import b from"../../layers/GraphicsLayer.js";import{isTable as M}from"../../layers/support/layerUtils.js";import{getDisplayedSymbol as V}from"../../symbols/support/symbolUtils.js";import{getDrawHelpMessage as I}from"../../views/draw/support/helpMessageUtils.js";import k from"../../views/draw/support/HighlightHelper.js";import S from"../../views/interactive/sketch/SketchOptions.js";import C from"../../views/interactive/snapping/FeatureSnappingLayerSource.js";import{temporaryHighlightName as P}from"../../views/support/HighlightDefaults.js";import A from"./CreateFeaturesWorkflowData.js";import{isModelUpload as H,handleModelUpload as E}from"./modelUploadUtils.js";import T from"./Workflow.js";import{createToolFromGeometryType as j,setRelationshipFields as U,startCreatingNewFeature as L,findLayerInfo as x,updateGraphicSymbolWhenRequired as O,isTerminalUpdateEventType as R,getVisualVariableAttributes as W,startUpdatingFeatureGeometry as D,createWorkflowSteps as N,avoidFeatureTemplateSelectionWithOnlyOneItem as G,getCreationAttributes as z,getFullTemplateForCreationInfo as Z,getServiceLayersById as K,prepareAttachmentsForCreateFeaturesWorkflow as q,showProgressCursor as B,setUpSketchCreateWatchers as J,setVisualVariablesAndElevationInfoForUpdate as Q,visualVariableInteractiveUpdate as X}from"./workflowUtils.js";import Y from"../FeatureForm/FeatureFormViewModel.js";import $ from"../Sketch/SketchViewModel.js";var ee;const te=Symbol(),ae=Symbol(),ie=Symbol(),re=Symbol(),se={point:["point"],multipoint:["multipoint"],polygon:["polygon","freehandPolygon","rectangle","circle"],polyline:["polyline","freehandPolyline"],mesh:[],multipatch:[]};let oe=ee=class extends T{constructor(e){super(e),this.type="create-features",this.createFeatureState="create-new",this.data=void 0,this.isNested=!1,this._getDrawMeshHelpMessage=void 0,this._webStyleCache=new Map,this._featureFormHandle=null,this._visualVariableAttributes={rotation:null,size:null},this._featureFormViewModel=new Y,this._sketchViewModel=null,this._attachmentFileInfos=new Map,this._isActive=!0}initialize(){this.isNested&&(this._isActive=!1),this._initializeSketchViewModel()}destroy(){this._sketchViewModel.destroy()}get featureFormViewModel(){return this._featureFormViewModel}get hasPendingEdits(){if(this.pendingFeatures.some((e=>!!this.data.getEditsForPendingFeature(e)?.modified)))return!0;const{creationInfo:e,upload:t}=this.data,a=this._sketchViewModel,{activeComponent:i}=a,r=a.createGraphic?.geometry?.type;return!("polyline"!==r&&"polygon"!==r&&"multipoint"!==r||"draw-2d"!==i?.type&&"draw-3d"!==i?.type)&&i.drawOperation.committedVertices.length>0||(!(!t||"pending"!==t.state&&"success"!==t.state)||!!e?.geometryToPlace)}get hasPreviousStep(){return this._stepIndex>0||"update-pending"===this.createFeatureState&&!!this.data.selectedPendingFeature&&!this.parent&&!H(this.data.creationInfo)}get helpMessage(){const{creationInfo:e,viewModel:t}=this.data;if("creating-features"!==this.stepId||!e)return;const a=e.layer.geometryType,i=this._sketchViewModel.createGraphic;if("mesh"===a){this._getDrawMeshHelpMessage||import("../../views/draw/support/helpMessageUtils3d.js").then((e=>{this._getDrawMeshHelpMessage=e.getDrawMeshHelpMessage}));const{view:e}=t;return"3d"===e?.type?this._getDrawMeshHelpMessage?.(i,e):void 0}const r=this._sketchViewModel.activeCreateToolDrawMode,s=this._sketchViewModel.activeTool;return I("rectangle"===s?"rectangle":"circle"===s?"circle":a,i?.geometry,r)}get layer(){return this.data.creationInfo?.layer}get numPendingFeatures(){return this.pendingFeatures.length}get parent(){return this.data.parent}get parentLayer(){return this.parent?.data.editorItem.layer}get pendingFeatures(){return this.data.pendingFeatures}get keyboardCancellationEnabled(){return 0===this.numPendingFeatures}get reliesOnOwnerAdminPrivileges(){return this.data.editorItem?.capabilities.create.reliesOnOwnerAdminPrivileges??!1}get shouldShowAttachments(){return(this.data.selectedPendingFeature&&this.data.editorItem?.capabilities.create.attachments.enabled)??!1}get shouldAllowAttachmentEditing(){return this.shouldShowAttachments}get sketchViewModel(){return this._sketchViewModel}get test(){}get availableCreateTools(){const e=this.data.creationInfo?.layer.geometryType,t=this.data.viewModel.view;if(!e)return[];if(this.data.creationInfo?.maxFeatures&&this.data.creationInfo.maxFeatures<=this.numPendingFeatures)return[];if(v(this.data.fullTemplate)){const{tool:t}=j(e,this.data.fullTemplate);return[t]}return"2d"!==t?.type&&"multipoint"===e?[]:[...se[e]]}get _attachmentsActive(){const e=this.data.viewModel.attachmentsViewModel.mode,t=this.stepId;return this.shouldShowAttachments&&("add"===e||"edit"===e||"adding-attachment"===t||"editing-attachment"===t)}async enter(){this._isActive=!0,"awaiting-feature-creation-info"!==this.stepId&&this._setUpCreatingFeaturesStep()}exit(){this._isActive=!1,this.removeHandles([ie])}async updatePendingFeature(e){if(e!==this.data.selectedPendingFeature)return this._sketchViewModel.cancel(),this._startUpdating({feature:e})}async start(){return await super.start(),M(this.data.creationInfo?.layer)?null:{enter:async()=>{},exit:async()=>{},viewModel:this._sketchViewModel}}async save(){const{featureFormViewModel:e}=this;if(e.pendingSubtypeChoice)return;e.submit(),this._stashValidationState();const t=this.data.selectedPendingFeature,a=this._hasValidationErrors(t)?t:this.data.pendingFeatures.find((e=>this._hasValidationErrors(e)));return a?(await this._startUpdating({feature:a}),void e?.submit()):super.save()}back(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||H(this.data.creationInfo)||this._attachmentsActive||this.parent?super.back(e):this._clearSelectedFeature()}previous(e){return"update-pending"!==this.createFeatureState||!this.data.selectedPendingFeature||H(this.data.creationInfo)||this._attachmentsActive?super.previous(e):this._clearSelectedFeature()}cancelFeature(e){this.data.isSharedTemplateWorkflow?o.getLogger(this).warn("Cannot cancel individual features created by shared templates."):(this.data.removePendingFeature(e),this.sketchViewModel.layer.graphics.remove(e))}static create(e){const{addAttachmentsCallback:t,applyEditsCallback:a,applyEditsFeatureServiceCallback:i,isNested:r,creationInfo:s,parent:o,snappingManager:n,startAt:l,viewModel:d}=e,c=e.sketchOptions??new S,u=s?.layer,h=u?d.findEditorItemForLayer(u):void 0,p=new ee({data:new A({creationInfo:s,editorItem:h,parent:o,sketchOptions:c,snappingManager:n,viewModel:d}),isNested:r,onCommit:async e=>{const{creationInfo:r}=e;if(!r)return;p._sketchViewModel.cancel();const s=e.pendingFeatures.toArray(),{layer:o}=r,n=o.capabilities?.editing.supportsGlobalId&&"globalIdField"in o,l=p._attachmentFileInfos,{fullTemplate:d,templateExecutorInfo:c}=e;c?.completionResult&&U(c.completionResult.relationships);const u=d&&F(d)&&c?.completionResult;if(n){if(ce(s),u){const e=he(c.completionResult.edits,l);await i(d.featureService,e,{globalIdUsed:!0,gdbVersion:d.layer.gdbVersion??void 0})}else{const e=ue(s,l);await a(o,e,{globalIdUsed:!0})}return}const h=u?await i(d.featureService,c.completionResult.edits,{gdbVersion:d.layer.gdbVersion??void 0}):[await a(o,{addFeatures:s})];h&&l.size>0&&await Promise.all(h.map((e=>{if(e?.addFeatureResults)return t(o,de(s,e.addFeatureResults,o,l))})))}});return p._set("steps",this._createWorkflowSteps(p,l)),p}_fadeExistingFeatures(e){if("effect"in e){const t=e.effect;return e.effect="saturate(0.6) opacity(0.8)",i((()=>e.effect=t))}const t=e.opacity;return e.opacity=.7,i((()=>e.opacity=t))}async _startCreating(){this.removeHandles(ae);const{data:e}=this;if(!e.creationInfo)return;const t=this.data.creationInfo?.maxFeatures;if(t&&this.numPendingFeatures>=t)return this.sketchViewModel.cancel(),void(this.numPendingFeatures&&await this._startUpdating({feature:this.pendingFeatures.at(-1)}));this.createFeatureState="create-new";const a=await L(this._sketchViewModel,e,this._webStyleCache);this.addHandles(a,ae)}async _clearSelectedFeature(){const e=this._featureFormViewModel.pendingSubtypeChoice;e&&(e.resolve("undo"),await e.promise),this._stashValidationState(),this.sketchViewModel.cancel(),this.data.selectedPendingFeature=null,this._featureFormHandle=n(this._featureFormHandle),this._featureFormViewModel.feature=null;const t=this.data.viewModel.attachmentsViewModel;"add"!==t.mode&&"edit"!==t.mode||this.data.viewModel.activeWorkflow?.previous()}_stashValidationState(){const e=this._featureFormViewModel.feature,t=e&&this.data.getEditsForPendingFeature(e);t&&(t.submittable=this._featureFormViewModel.submittable)}async _selectFeatureForUpdate({feature:e,initialFeature:t=e}){this._stashValidationState();const{data:a,pendingFeatures:i,_webStyleCache:s}=this;i.includes(e)||a.addPendingFeature(e,t),a.selectedPendingFeature=e;const{_featureFormViewModel:o,_sketchViewModel:l}=this,{creationInfo:d,viewModel:c}=a,{attachmentsViewModel:h,layerInfos:p,view:m}=c;if(!m||!d)return;n(this._featureFormHandle);const f=e.sourceLayer,w=x(p,f),g=w?.formTemplate,y=m.spatialReference;o.set({arcadeEditType:"INSERT",feature:e,formTemplate:g,spatialReference:y,map:m.map}),"add"!==h.mode&&"edit"!==h.mode||c.activeWorkflow?.previous(),h.graphic=e,h.fileInfos.removeAll(),h.mode="view";(this._attachmentFileInfos.get(e)||[]).forEach((({file:e,form:t})=>h.addFile(e,t))),await O(e,s,"2d"===m.type?m.scale:null);const v=a.getEditsForPendingFeature(e);this._featureFormHandle=r([o.on("value-change",(async()=>{v?.updateAttributes(o.getValues()),await O(e,s,"2d"===m.type?m.scale:null)})),l.on(["update","undo","redo"],(e=>{("undo"===e.type||"redo"===e.type||"update"===e.type&&null!=e.toolEventInfo&&R(e.toolEventInfo.type))&&o.notifyFeatureGeometryChanged()})),u((()=>o.feature?.sourceLayer),(t=>e.sourceLayer=t)),u((()=>[o.feature,o.submittable]),(()=>this._stashValidationState()))]),this.createFeatureState="update-pending"}async _startUpdating({feature:e,initialFeature:t=e}){await this._selectFeatureForUpdate({feature:e,initialFeature:t});const{_sketchViewModel:a,data:i}=this,{creationInfo:r,viewModel:s}=i,{view:o}=s;if(!o||!r)return;const n=e.sourceLayer??r.layer;return M(n)?void 0:(this._visualVariableAttributes=W(e),D({graphic:e,sketchViewModel:a,sourceLayer:n,visualVariables:this._visualVariableAttributes,webStyleCache:this._webStyleCache}))}static _createWorkflowSteps(e,t="awaiting-feature-creation-info"){const{data:a}=e,i=N(["awaiting-feature-creation-info","creating-features","adding-attachment","editing-attachment"],t,{"awaiting-feature-creation-info":()=>({id:"awaiting-feature-creation-info",async setUp(){const{creationInfo:t,viewModel:i}=a,{view:r}=i;r&&(H(t)?e.addHandles(await E({view:r,data:a,next:()=>e.next(),cancel:()=>i.cancelWorkflow({warnIfNoWorkflow:!1})}),this.id):(a.parent&&t&&e.addHandles(i.restrictFeatureTemplatesViewModelToLayer(t.layer),this.id),e.addHandles(i.featureTemplatesViewModel.on("select",(({item:t})=>{t&&(a.creationInfo={...a.creationInfo,layer:t.layer,template:t.template},e.next())})),this.id)))},async tearDown(){e.removeHandles(this.id)}}),"creating-features":()=>({id:"creating-features",async setUp(){e._isActive&&await e._setUpCreatingFeaturesStep()},async tearDown(t){const{viewModel:i}=a;t.canceled&&(e.removeHandles([ie,te,ae,re]),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 G(a,i)}static _configureSketchViewModel(e){const{data:t}=e,a=e._webStyleCache,{creationInfo:s,viewModel:o}=t,{view:n}=o,l=e._sketchViewModel,d=[];if(!n)return i();if("2d"===n.type){s&&d.push(e._fadeExistingFeatures(s.layer));const t=c(((e,t)=>Promise.all(e.map((e=>O(e,a,t))))));d.push(u((()=>n.scale),(e=>t(l.layer.graphics,e))))}const p=z(t.fullTemplate,s?.attributeOverrides),m=async i=>{if("start"!==i.state||e.hasHandles(ae)||e.addHandles(await J({creationAttributes:p,data:t,sketchViewModel:l,view:n,webStyleCache:a}),ae),"cancel"!==i.state&&"complete"!==i.state||e.removeHandles(ae),"cancel"===i.state&&null!==n.activeTool&&n.activeTool!==e.sketchViewModel.activeComponent&&(await e._waitForActiveToolCleared(),await e._startCreating()),"complete"===i.state&&i.graphic){const t=await e._processEdits(i.graphic,{scale:"2d"===n.type?n.scale:null,useSourceLayer:!0,webStyleCache:e._webStyleCache});t&&(await e._waitForActiveToolCleared(),await e._startUpdating({feature:t}))}},f=async a=>{const{attachmentsViewModel:i}=o,{_featureFormViewModel:r}=e;if(a.graphics.length>1)return void await e._clearSelectedFeature();const d=a.graphics[0];if("complete"===a.state){const{submittable:t}=r;if(e.numPendingFeatures!==s?.maxFeatures&&t||r.submit(),await e._clearSelectedFeature(),"add"!==i.mode&&"edit"!==i.mode||o.activeWorkflow?.previous(),!a.aborted&&n.activeTool===e.sketchViewModel.activeComponent&&(await e.sketchViewModel.wait(),"ready"===e.sketchViewModel.state&&"mesh"!==e.data.creationInfo?.layer.geometryType))return e._startCreating()}else{if("start"===a.state)return d.sourceLayer??=t.creationInfo?.layer,await Q({sketchViewModel:l,graphic:d,visualVariables:e._visualVariableAttributes,webStyleCache:e._webStyleCache,sourceLayer:d.sourceLayer}),e._selectFeatureForUpdate({feature:d});if("active"===a.state){await e.updatePendingFeature(d);const t=e._visualVariableAttributes;await X(n,d,a,t,e._webStyleCache);const i=d.attributes,{rotation:s,size:o}=t;if(null!=s){const{field:e}=s;r.setValue(e,i[e])}if(null!=o){const{field:e}=o;r.setValue(e,i[e])}}}},w=async a=>{if(a.graphics.forEach((e=>{t.removePendingFeature(e)})),!H(t.creationInfo))return e._startCreating()},g=async()=>{if(H(t.creationInfo))try{await e.data.viewModel.back()}catch{}return e._startCreating()};d.push(l.on("create",(t=>e._updatingHandles.addPromise(m(t)))),l.on("update",(t=>e._updatingHandles.addPromise(f(t)))),l.on("delete",(t=>e._updatingHandles.addPromise(w(t)))),h((()=>!e.numPendingFeatures),(()=>e._updatingHandles.addPromise(g()))),i((()=>{l.cancel()})),ne(l,t),...le(t));const y=r(d);return l.addHandles(y),y}_initializeSketchViewModel(){const{data:e}=this,{view:t}=e.viewModel,a=new b({elevationInfo:e.creationInfo?.layer.elevationInfo,internal:!0,listMode:"hide",title:"createFeaturesWorkflow-internal"}),r=new $({layer:a,creationMode:"single",sketchOptions:e.sketchOptions,snappingManager:e.snappingManager,updateOnGraphicClick:!1,defaultUpdateOptions:{multipleSelectionEnabled:!1},view:t});this._sketchViewModel=r,t?.map.add(a),this.addHandles([i((()=>{t?.destroyed||t?.map.remove(a),a.destroy()})),u((()=>this.numPendingFeatures>0),(e=>this._sketchViewModel.updateOnGraphicClick=e),p)])}_hasValidationErrors(e){return!!e&&(!this.data.isSubmittable(e)||!!this._featureFormViewModel.validateContingencyConstraints(e.attributes,{includeIncompleteViolations:!0})?.length)}async _processEdits(e,t){const{data:a}=this,{layerInfos:i,view:r}=a.viewModel,s=this._featureFormViewModel,{templateExecutorInfo:o}=a;if(!o){const t=e.clone();return t.geometry=null,a.addPendingFeature(e,t),e}const n=this.sketchViewModel.layer;n.remove(e);const{executor:l}=o,c=l(e.geometry,"completion"),u=d(c)?await c:c;o.completionResult=u,U(u.relationships),s.arcadeEditType="INSERT",s.map=r?.map,s.spatialReference=r?.spatialReference;for(const d of u.edits){let e=null;if(d.addFeatures)for(const r of d.addFeatures){const o=r.clone();o.geometry=null,r.symbol=await V(r,t),n.add(r);const l=a.addPendingFeature(r,o);r.sourceLayer!==e?.layer&&(e=x(i,r.sourceLayer)),s.feature=r,s.formTemplate=e?.formTemplate,await m((()=>!s.updating)),l.submittable=s.submittable}}s.feature=null,await m((()=>!s.updating));return u.edits.reduce(((e,t)=>e+(t.addFeatures?.length??0)),0)>1?null:u.primary?.graphic}async _setUpCreatingFeaturesStep(){if(this.hasHandles(ie))return;const{data:e,sketchViewModel:s}=this,{creationInfo:o,viewModel:l}=e,{attachmentsViewModel:d,view:c}=l;if(!c||!o?.layer)throw new a("missing-parameters","CreateFeaturesWorkflow requires a view and creationInfo.");const{initialFeature:h,layer:m}=o,f=[];if(this._featureFormHandle=n(this._featureFormHandle),this._visualVariableAttributes={rotation:null,size:null},e.editorItem=l.findEditorItemForLayer(o.layer),null===e.fullTemplate&&o.template){const t=await Z(o,c);e.fullTemplate=t,t&&F(t)&&(e.templateExecutorInfo={completionResult:null,executor:await _(t),serviceLayersById:await K(o.layer,c)})}s.allowDeleteKey=!e.isSharedTemplateWorkflow,q(d),f.push(u((()=>d.mode),(e=>{switch(e){case"add":this.go("adding-attachment");break;case"edit":this.go("editing-attachment")}})));const w=B(c);f.push(w);const g=M(o.layer);try{if(g){const{template:e}=o;if(e&&v(e))throw new a("Shared templates are not yet supported");const i=h??new t({attributes:{...e?.prototype.attributes,...o.attributeOverrides},sourceLayer:m});await this._startUpdating({feature:i})}else f.push(ee._configureSketchViewModel(this)),h?(s.layer.add(h),await this._startUpdating({feature:h})):await this._startCreating()}finally{w.remove()}const y=i((()=>{for(const t of e.pendingFeatures)s.layer.remove(t),e.removePendingFeature(t)})),b=u((()=>c?.timeZone),(e=>{this._featureFormViewModel.timeZone=e,this.data.timeZone=e}),p),V=i((()=>{H(o)&&l.cancelWorkflow({warnIfNoWorkflow:!1})}));this._featureFormHandle&&f.push(this._featureFormHandle),this.addHandles(f,this._handleKeys.beforeCommit),this.addHandles([i((()=>d.fileInfos.removeAll())),r(f),V,y,b],ie)}async _waitForActiveToolCleared(){const e=this.data.viewModel.view;if(null==e?.activeTool)return;const t=new AbortController;this.addHandles(s(t),re),await m((()=>null==e?.activeTool),t.signal),t.abort()}};function ne(e,t){let a=null;const s=()=>e.snappingOptions.featureSources,o=()=>(a=new C({layer:e.layer}),s().add(a),a),n=()=>{null!=a&&(s().remove(a),a=l(a))};return r([u((()=>{const e=t.creationInfo?.layer,a=s().find((t=>t.layer===e));return{hasFeatureLayerSource:!!a,enabled:a?.enabled??!1}}),(({hasFeatureLayerSource:e,enabled:t})=>{if(!e)return n();a??=o(),a.enabled=t}),f),i(n)])}function le(e){const t=e.viewModel.view;if(!t)return[];const a=[];if("3d"===t.type){const r=new k({view:t});a.push(u((()=>e.selectedPendingFeature),((e,t)=>{r.remove(e),r.add(t)})),i((()=>r.destroy())))}const r=new k({view:t,highlightName:P});return a.push(u((()=>e.temporaryHighlightFeature),(e=>{r.removeAll(),r.add(e)})),i((()=>r.destroy()))),a}function de(e,t,a,i){const r=[];return t.forEach(((t,s)=>{if(!t.error){const o=e[s],n=i.get(o)||[];o.attributes[a.objectIdField]=t.objectId,n.forEach((({form:e})=>r.push({feature:o,attachment:e})))}})),r}function ce(e){for(const t of e){const{sourceLayer:e}=t;e&&"globalIdField"in e&&null!=e.globalIdField&&(t.attributes[e.globalIdField]??=w())}}function ue(e,t){const a=[];if(!t||0===t.size)return{addFeatures:e};for(const[i,r]of t)for(const{file:e}of r)a.push({feature:i,attachment:{globalId:w(),data:e}});return a.length?{addFeatures:e,addAttachments:a}:{addFeatures:e}}function he(e,t){return e.map((e=>{const{addFeatures:a}=e;if(!a||0===a.length)return e;const i=[];for(const r of a){const e=t.get(r);if(e)for(const{file:t}of e)i.push({feature:r,attachment:{globalId:w(),data:t}})}return i.length?{...e,addAttachments:i}:e}))}e([g()],oe.prototype,"createFeatureState",void 0),e([g()],oe.prototype,"data",void 0),e([g({constructOnly:!0})],oe.prototype,"isNested",void 0),e([g()],oe.prototype,"featureFormViewModel",null),e([g()],oe.prototype,"hasPendingEdits",null),e([g()],oe.prototype,"hasPreviousStep",null),e([g()],oe.prototype,"_getDrawMeshHelpMessage",void 0),e([g()],oe.prototype,"helpMessage",null),e([g()],oe.prototype,"layer",null),e([g()],oe.prototype,"parent",null),e([g()],oe.prototype,"parentLayer",null),e([g()],oe.prototype,"keyboardCancellationEnabled",null),e([g()],oe.prototype,"reliesOnOwnerAdminPrivileges",null),e([g()],oe.prototype,"shouldShowAttachments",null),e([g()],oe.prototype,"shouldAllowAttachmentEditing",null),e([g()],oe.prototype,"sketchViewModel",null),e([g()],oe.prototype,"availableCreateTools",null),e([g()],oe.prototype,"_attachmentsActive",null),oe=ee=e([y("esri.widgets.Editor.CreateFeaturesWorkflow")],oe);const pe=oe;export{pe 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.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import r from"../../core/Collection.js";import o from"../../core/Logger.js";import s from"../../core/ReactiveMap.js";import{property as i}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import a from"./Edits.js";const p=()=>o.getLogger("esri.widgets.Editor.CreateFeaturesWorkflowData");let l=class extends t{constructor(e){super(e),this.creationInfo=null,this.editorItem=null,this.fullTemplate=null,this.parent=null,this.temporaryHighlightFeature=null,this.sketchOptions=null,this.snappingManager=null,this.templateExecutorInfo=null,this.viewModel=null,this.upload=null,this._pendingEdits=new s}get pendingFeatures(){return new r([...this._pendingEdits.keys()])}set selectedPendingFeature(e){this._set("selectedPendingFeature",e),this.temporaryHighlightFeature=null}isSubmittable(e){return!!this._pendingEdits.get(e)?.submittable}addPendingFeature(e,t=e){this.temporaryHighlightFeature=null;const{_pendingEdits:r}=this;if(r.has(e))return r.get(e);e.sourceLayer||p().warn("source-layer-not-set","A feature added to `pendingFeatures` did not have `sourceLayer` set. This may cause problems throughout `CreateFeaturesWorkflow`.");const o=new a({feature:e});return o.trackChanges(t),r.set(e,o),o}getEditsForPendingFeature(e){return this._pendingEdits.get(e)}removePendingFeature(e){this.temporaryHighlightFeature=null;const{_pendingEdits:t}=this,r=t.get(e);r&&(r.destroy(),t.delete(e)),this.selectedPendingFeature===e&&(this.selectedPendingFeature=null)}};e([i()],l.prototype,"creationInfo",void 0),e([i()],l.prototype,"editorItem",void 0),e([i()],l.prototype,"fullTemplate",void 0),e([i()],l.prototype,"parent",void 0),e([i()],l.prototype,"pendingFeatures",null),e([i()],l.prototype,"selectedPendingFeature",null),e([i()],l.prototype,"temporaryHighlightFeature",void 0),e([i({constructOnly:!0})],l.prototype,"sketchOptions",void 0),e([i()],l.prototype,"snappingManager",void 0),e([i()],l.prototype,"templateExecutorInfo",void 0),e([i()],l.prototype,"viewModel",void 0),e([i()],l.prototype,"upload",void 0),l=e([n("esri.widgets.Editor.CreateFeaturesWorkflowData")],l);const d=l;export{d as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import r from"../../core/Collection.js";import o from"../../core/Logger.js";import i from"../../core/ReactiveMap.js";import{property as s}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import{isSharedTemplateOrMetadata as l}from"../../editing/templateUtils.js";import a from"./Edits.js";const p=()=>o.getLogger("esri.widgets.Editor.CreateFeaturesWorkflowData");let d=class extends t{constructor(e){super(e),this.creationInfo=null,this.editorItem=null,this.fullTemplate=null,this.parent=null,this.temporaryHighlightFeature=null,this.sketchOptions=null,this.snappingManager=null,this.templateExecutorInfo=null,this.viewModel=null,this.upload=null,this._pendingEdits=new i}get isSharedTemplateWorkflow(){return!!this.fullTemplate&&l(this.fullTemplate)}get pendingFeatures(){return new r([...this._pendingEdits.keys()])}set selectedPendingFeature(e){this._set("selectedPendingFeature",e),this.temporaryHighlightFeature=null}set timeZone(e){this._set("timeZone",e),this._pendingEdits.forEach((t=>{t.timeZone=e}))}isSubmittable(e){return!!this._pendingEdits.get(e)?.submittable}addPendingFeature(e,t=e){this.temporaryHighlightFeature=null;const{_pendingEdits:r}=this;if(r.has(e))return r.get(e);e.sourceLayer||p().warn("source-layer-not-set","A feature added to `pendingFeatures` did not have `sourceLayer` set. This may cause problems throughout `CreateFeaturesWorkflow`.");const o=new a({feature:e});return o.trackChanges(t),r.set(e,o),o}getEditsForPendingFeature(e){return this._pendingEdits.get(e)}removePendingFeature(e){this.temporaryHighlightFeature=null;const{_pendingEdits:t}=this,r=t.get(e);r&&(r.destroy(),t.delete(e)),this.selectedPendingFeature===e&&(this.selectedPendingFeature=null)}getFeatureTitle(e){return this._pendingEdits.get(e)?.displayTitle}};e([s()],d.prototype,"creationInfo",void 0),e([s()],d.prototype,"editorItem",void 0),e([s()],d.prototype,"fullTemplate",void 0),e([s()],d.prototype,"isSharedTemplateWorkflow",null),e([s()],d.prototype,"parent",void 0),e([s()],d.prototype,"pendingFeatures",null),e([s()],d.prototype,"selectedPendingFeature",null),e([s()],d.prototype,"temporaryHighlightFeature",void 0),e([s({constructOnly:!0})],d.prototype,"sketchOptions",void 0),e([s()],d.prototype,"snappingManager",void 0),e([s()],d.prototype,"templateExecutorInfo",void 0),e([s()],d.prototype,"viewModel",void 0),e([s()],d.prototype,"upload",void 0),e([s()],d.prototype,"timeZone",null),d=e([n("esri.widgets.Editor.CreateFeaturesWorkflowData")],d);const u=d;export{u 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.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import{attributesAreEquivalent as o}from"./support/editsUtils.js";function s(t){return null==t?null:JSON.stringify(t)}let a=class extends e{constructor(t){super(t),this._stagedForDelete=!1,this.feature=null,this.initialFeature=null,this.submittable=!1}get attributesModified(){return!o(this.initialFeature?.attributes,this.feature?.attributes)}get geometryModified(){return this._stringifyGeometry(this.feature)!==this._stringifyGeometry(this.initialFeature)}get stagedForDelete(){return this._stagedForDelete}get modified(){return this.attributesModified||this.geometryModified||this._stagedForDelete}stageDelete(){this._stagedForDelete=!0}unstageDelete(){this._stagedForDelete=!1}trackChanges(t=this.feature){this.initialFeature=t?.clone()}updateAttributes(t){const{feature:e}=this;e&&(e.attributes=t,this.notifyChange("attributesModified"))}updateGeometry(t){const{feature:e}=this;e&&(e.geometry=t,this.notifyChange("geometryModified"))}_stringifyGeometry(t){const e=t?.geometry;return s("mesh"===e?.type?{transform:e.transform,vertexSpace:e.vertexSpace}:e)}};t([r()],a.prototype,"_stagedForDelete",void 0),t([r()],a.prototype,"attributesModified",null),t([r()],a.prototype,"feature",void 0),t([r()],a.prototype,"geometryModified",null),t([r()],a.prototype,"initialFeature",void 0),t([r()],a.prototype,"modified",null),t([r()],a.prototype,"submittable",void 0),a=t([i("esri.widgets.Editor.Edits")],a);const u=a;export{u as default};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import{debounce as i}from"../../core/promiseUtils.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import{attributesAreEquivalent as o}from"./support/editsUtils.js";function a(e){return null==e?null:JSON.stringify(e)}let l=class extends t{constructor(e){super(e),this._stagedForDelete=!1,this.feature=null,this.initialFeature=null,this.submittable=!1,this.displayTitle=null,this._debouncedRefreshDisplayTitle=i(this._refreshDisplayTitle.bind(this),100)}get attributesModified(){return!o(this.initialFeature?.attributes,this.feature?.attributes)}get geometryModified(){return this._stringifyGeometry(this.feature)!==this._stringifyGeometry(this.initialFeature)}get stagedForDelete(){return this._stagedForDelete}get modified(){return this.attributesModified||this.geometryModified||this._stagedForDelete}set timeZone(e){this._set("timeZone",e),this._debouncedRefreshDisplayTitle()}stageDelete(){this._stagedForDelete=!0}unstageDelete(){this._stagedForDelete=!1}trackChanges(e=this.feature){this.initialFeature=e?.clone(),this._debouncedRefreshDisplayTitle()}updateAttributes(e){const{feature:t}=this;t&&(t.attributes=e,this.notifyChange("attributesModified")),this._debouncedRefreshDisplayTitle()}updateGeometry(e){const{feature:t}=this;t&&(t.geometry=e,this.notifyChange("geometryModified"))}_stringifyGeometry(e){const t=e?.geometry;return a("mesh"===t?.type?{transform:t.transform,vertexSpace:t.vertexSpace}:t)}async _refreshDisplayTitle(e){const t=this.feature,i=t?.sourceLayer;if(!i||!("getFeatureTitle"in i))return;const r=await i.getFeatureTitle(t,{fetchMissingFields:!1,timeZone:this.timeZone});e.aborted||(this.displayTitle=""===r?null:r)}};e([r()],l.prototype,"_stagedForDelete",void 0),e([r()],l.prototype,"attributesModified",null),e([r()],l.prototype,"feature",void 0),e([r()],l.prototype,"geometryModified",null),e([r()],l.prototype,"initialFeature",void 0),e([r()],l.prototype,"modified",null),e([r()],l.prototype,"submittable",void 0),e([r()],l.prototype,"displayTitle",void 0),e([r()],l.prototype,"timeZone",null),l=e([s("esri.widgets.Editor.Edits")],l);const n=l;export{n as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
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{createResolver as s,onAbort as n,createAbortError as l,throwIfAborted as d,debounce as c}from"../../core/promiseUtils.js";import p from"../../core/Queue.js";import{whenOnce as u,when as w,watch as h,sync as f}from"../../core/reactiveUtils.js";import{last as k}from"../../core/SetUtils.js";import{property as v}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as g}from"../../core/accessorSupport/decorators/subclass.js";import{getAllStandardFeatureTemplatesForLayer as m}from"../../editing/templateUtils.js";import{isEditableLayer as y}from"../../layers/support/editableLayers.js";import{isFeatureLayer as W,isSubtypeSublayer as b,isSubtypeGroupLayer as A,isTable as C}from"../../layers/support/layerUtils.js";import{createFeatureServices as _}from"../../rest/featureService/utils.js";import M from"../../views/draw/support/HighlightHelper.js";import{ViewEventPriorities as S}from"../../views/input/InputManager.js";import F from"../../views/interactive/sketch/SketchOptions.js";import{temporaryHighlightName as I}from"../../views/support/HighlightDefaults.js";import{AddAssociationWorkflow as E}from"./AddAssociationWorkflow.js";import j from"./CreateFeaturesWorkflow.js";import{UpdateFeatureWorkflow as U}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as V}from"./UpdateRecordWorkflow.js";import P from"./UpdateWorkflowData.js";import L from"./Workflow.js";import{createWorkflowSteps as x,fetchCandidates as T}from"./workflowUtils.js";import{findUtilityNetwork as O,isGraphicForRelatableFeatureSupportedLayer as R}from"../Feature/support/featureUtils.js";var N;const H="esri.widgets.Editor.UpdateWorkflow",D=()=>o.getLogger(H);let q=N=class extends L{constructor(e){super(e),this._workflowStack=new p(k),this._sketchStack=new p(k),this.data=void 0,this.type="update"}destroy(){this._drainWorkflowStack((e=>e.cancel({force:!0})))}get activeEditorItem(){return this.activeWorkflow?.data.editorItem??void 0}get activeFeatureFormViewModel(){return this.activeWorkflow?.featureFormViewModel}get activeUtilityNetworkAssociationAddAssociationViewModel(){return"add-association"===this.activeWorkflow?.type?this.activeWorkflow.utilityNetworkAssociationAddAssociationViewModel:null}get activeSketchViewModel(){return this._sketchStack.peek()?.viewModel}get canDeleteAssociation(){const{activeFeatureFormViewModel:e}=this;if(!this.activeWorkflow||!this.data.viewModel.view?.map||!e)return!1;const{activeAssociation:t,feature:a}=e;return!(!t||!a?.sourceLayer||!W(a?.sourceLayer)&&!b(a?.sourceLayer))}get activeWorkflow(){return this._workflowStack.last()}get updating(){return this._updatingHandles.updating||!!this.activeWorkflow?.updating}get hasPreviousStep(){const e=this.activeWorkflow?.featureFormViewModel;return this._stepIndex>0||this.nestedWorkflowCount>1||null!=e?.relationshipId||"view"!==this.data.viewModel.attachmentsViewModel.mode||null!=e?.associationId||null!=e?.associatedLayer}get hasUpdatableCandidates(){const{candidates:e,viewModel:t}=this.data;return e.some((({layer:e})=>t.findEditorItemForLayer(e)?.supportsUpdateWorkflow))}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return!!this.activeEditorItem?.capabilities.attachments.enabled}get shouldAllowAttachmentEditing(){return!!this.activeEditorItem?.capabilities.update.attachments.enabled}get hasPendingEdits(){return Array.from(this._workflowStack).some((e=>e.hasPendingEdits))}get helpMessage(){return this.activeWorkflow?.helpMessage?this.activeWorkflow.helpMessage:"awaiting-feature-to-update"===this.stepId?"select":void 0}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return!!this.activeEditorItem?.hasInvalidFormTemplate}async back(e=()=>Promise.resolve(!0)){const{activeWorkflow:t}=this,a=t?.featureFormViewModel;if(null==a?.relationshipId)if(null==a?.associatedLayer)if(null==a?.associationId)if("create-features"===t?.type&&t.hasPreviousStep)await t.previous({cancelCurrentStep:!0});else if(t){if(t.hasPendingEdits){if(!await e())return}t.hasPreviousStep?await t.previous({cancelCurrentStep:!0}):await this.cancelActiveWorkflow({force:!0})}else this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0});else a.associationId=null;else a.associatedLayer=null;else a.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){const{viewModel:t,snappingManager:a,startAt:i,addAttachmentsCallback:o,applyEditsCallback:r,applyEditsFeatureServiceCallback:s}=e,n=e.sketchOptions??new F,l=new N({data:new P({addAttachmentsCallback:o,applyEditsCallback:r,applyEditsFeatureServiceCallback:s,sketchOptions:n,snappingManager:a,viewModel:t}),onCommit:async()=>{}});return l._set("steps",this._createWorkflowSteps(l,i)),l}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,t){try{const a=await this._createNestedUpdateWorkflow(e,t);await this._pushWorkflow(a)}catch(i){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:i})}}async startAddAssociation(e,t,i){try{const a=await this._createNestedAddAssociationWorkflow(e,t,i);await this._pushWorkflow(a)}catch(o){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:o})}}async deleteActiveFeature(){const{activeWorkflow:e}=this;if(!e)throw new a("editor:nothing-to-delete","There is no feature to delete");Q(e)?await e.deleteAndCommit():await e.cancel(),1===this.nestedWorkflowCount?await this.reset():(await this._popWorkflow(),await this._returnToPageWithContent())}async deleteActiveAssociation(){if(!this.canDeleteAssociation)throw new a("editor:nothing-to-delete","There is no association to delete");await this._deleteActiveAssociation(),await this._popWorkflow(),await this._returnToPageWithContent()}async cancelAll(){await this._drainWorkflowStack((e=>e.cancel({force:!0})))}async _deleteActiveAssociation(){const{activeFeatureFormViewModel:e,data:t}=this,{activeAssociation:i,feature:o}=e,{applyEditsFeatureServiceCallback:r,viewModel:s}=t,{sourceLayer:n}=o,l=b(n)&&n.parent?n.parent:n,d=_([l]),c=d.values().next().value?.featureService;if(!c)throw new a("editor:failed-to-delete-association","Could not retrieve feature service needed to delete association");await(c?.load());const p=s.view.map,u=O(p,l),w=u?.generateDeleteAssociations([i]);if(!w)throw new a("editor:failed-to-delete-association","Could not create payload needed to delete association");const h=u?.gdbVersion??void 0;await r(c,[w],{gdbVersion:h,globalIdUsed:!0})}async _returnToPageWithContent(){const{activeFeatureFormViewModel:e}=this;if(!e?.activeAssociationInput)return;const{activeAssociationInput:t,associationId:a}=e;await t.refresh(),t.associatedLayer&&!t.associatedFeatures?.length&&(e.associatedLayer=null),null==a||t.associatedFeatureInfos.size||(e.associationId=null)}async _createNestedCreateFeaturesWorkflow(e){const{relatedLayer:t}=e,{addAttachmentsCallback:i,applyEditsCallback:o,applyEditsFeatureServiceCallback:r,sketchOptions:s,snappingManager:n,viewModel:l}=this.data;if(!y(t))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const d=this._getCreationInfoForNestedCreateFeaturesWorkflow(e),c=d.template||d.initialFeature?"creating-features":"awaiting-feature-creation-info",p="create-features"!==this.activeWorkflow?.type&&"add-association"!==this.activeWorkflow?.type?this.activeWorkflow:void 0;return j.create({addAttachmentsCallback:i,applyEditsCallback:o,applyEditsFeatureServiceCallback:r,creationInfo:d,isNested:!0,parent:p,sketchOptions:s,snappingManager:n,startAt:c,viewModel:l})}_getCreationInfoForNestedCreateFeaturesWorkflow(e){const{relatedLayer:i}=e;if(!y(i)||A(i))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const o={layer:i,maxFeatures:1},r=this._makeRelatedRecordAttributes(e),s=m(i);return s?.length>0?(o.attributeOverrides=r,1===s.length&&(o.template=s[0])):o.initialFeature=new t({sourceLayer:i,attributes:r}),o}async _createNestedUpdateWorkflow(e,t){const a=C(e.sourceLayer)?V:U,{applyEditsCallback:i,applyEditsFeatureServiceCallback:o,sketchOptions:r,snappingManager:s,viewModel:n}=this.data,l="create-features"!==this.activeWorkflow?.type&&"add-association"!==this.activeWorkflow?.type?this.activeWorkflow:void 0,d=await a.create({association:t,feature:e,parent:l,sketchOptions:r,snappingManager:s,viewModel:n,applyEdits:i,applyEditsFeatureService:o,featureFormCallbacks:{addRelatedRecord:async e=>await this.startCreatingRelatedRecord(e),editRelatedRecord:async({relatedFeature:e})=>await this.startUpdating(e),selectAssociatedFeature:async({feature:e,association:t})=>await this.startUpdating(e,t),addAssociation:async e=>await this.startAddAssociation(e.feature,e.utilityNetwork,e.associationType)}});return await u((()=>!d.updating)),d}async _createNestedAddAssociationWorkflow(e,t,a){const i=E,{applyEditsCallback:o,applyEditsFeatureServiceCallback:r,viewModel:s}=this.data,n="create-features"!==this.activeWorkflow?.type&&"add-association"!==this.activeWorkflow?.type?this.activeWorkflow:void 0,l=this.activeFeatureFormViewModel?.activeAssociationInput,d=await i.create({utilityNetwork:t,associationType:a,feature:e,parent:n,viewModel:s,associationInput:l,applyEdits:o,applyEditsFeatureService:r});return await u((()=>!d.updating)),d}async _drainWorkflowStack(e){const t=this._workflowStack,a=[];for(;t.length>0;){const i=t.pop();this._sketchStack.pop();const o=e(i).then((()=>i.destroy()));this._updatingHandles.addPromise(o),a.push(o)}await Promise.all(a)}_makeRelatedRecordAttributes(e){const{parentFeature:t,relatedLayer:a,relationshipId:i}=e;if(!R(t))return;const o=a.relationships?.find((e=>e.id===i));if(!o)return void z("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 z("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&&z("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 z("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the origin layer.");const n=G(r,s),l=t.getAttribute(n);l||z("no-key-on-origin-feature","The given parent feature does not have a value for the relationship's origin primary key field.");const d=G(a,o);return{[d]:l}}async _popWorkflow(){this._workflowStack.pop()?.destroy(),this._sketchStack.pop();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=this._workflowRequiresSketchViewModel(e);this.activeWorkflow?.exit({removeSketchHandles:t});const i=this._sketchStack,o=await(e?.start()),r=i.peek();o?(r?.exit(),i.push(o)):i.push(this._cloneSketchController(r)),this._workflowStack.push(e);const s=await this._reconcileWorkflowStack();if(s.failureCount>0)throw new a("editor:failed-to-start-updating-feature","Failed to enter the provided workflow.",s)}async _reconcileWorkflowStack(){const e=this._workflowStack,t=this._sketchStack;try{const a=e.peek();return await(a?.enter()),await(t.peek()?.enter()),{activeWorkflow:a,failureCount:0}}catch(a){e.pop().destroy(),t.pop();const{activeWorkflow:i,failureCount:o}=await this._reconcileWorkflowStack();return{activeWorkflow:i,failureCount:o+1}}}_cloneSketchController(e){return{enter:e?.enter??(async()=>{}),exit:e?.exit??(async()=>{}),viewModel:e?.viewModel}}_workflowRequiresSketchViewModel(e){const{type:t}=e;return"update-feature"===t||"create-features"===t&&!C(e.data.creationInfo?.layer)}static _createWorkflowSteps(e,t="awaiting-feature-to-update"){const{data:o}=e;return x(["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;a.activeTool=null;let c=null;e.addHandles(i((()=>{c=r(c)})),this.id),o.rootFeature=null,o.candidates=[];const p=a.on("immediate-click",(async i=>{const r=s();e._updatingHandles.addPromise(r.promise);try{t.location=i.mapPoint,t.visible=!0,c?.abort();const{editorItems:r}=o.viewModel;c=new AbortController;const s=await i.async((()=>new Promise(((e,t)=>{n(c?.signal,(()=>t(l()))),e(T(r,a,i,c?.signal))}))));if(d(c),o.candidates=s.filter((e=>"fulfilled"===e.status)).flatMap((e=>e.value)).filter((e=>!e.isAggregate)),t.visible=1===o.candidates.length,0===o.candidates.length)return;i.stopPropagation(),1===o.candidates.length?(o.rootFeature=o.candidates[0],e.go("editing-existing-feature").catch((()=>{})).then((()=>t.visible=!1))):e.next()}finally{r.resolve()}}),S.TOOL),u=w((()=>null!=a.activeTool),(()=>e.cancel({force:!0})),{once:!0});a.focus(),e.addHandles([p,u],this.id)},async tearDown(){0===o.candidates.length&&(o.viewModel.spinnerViewModel.visible=!1),e.removeHandles(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){o.rootFeature=null;const{view:t}=o.viewModel;if(!t)return;const a=new M({view:t,highlightName:I});e.addHandles([h((()=>o.rootFeature),((e,t)=>{a.remove(t),a.add(e)}),f),i((()=>a.removeAll()))],this.id)},async tearDown(){e.removeHandles(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=c((async()=>{await u((()=>!e.updating)),e.previous()}));e.addHandles([h((()=>e.nestedWorkflowCount),((e,t)=>{0===e&&0!==t&&o()}),f)],this.id)},async tearDown(){await e.cancelAll(),e.removeHandles(this.id)}}),"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"}})})}};function G(e,{keyField:t}){return e.getField(t)?.name??t}e([v()],q.prototype,"activeEditorItem",null),e([v()],q.prototype,"activeFeatureFormViewModel",null),e([v()],q.prototype,"activeUtilityNetworkAssociationAddAssociationViewModel",null),e([v()],q.prototype,"activeSketchViewModel",null),e([v()],q.prototype,"canDeleteAssociation",null),e([v()],q.prototype,"activeWorkflow",null),e([v()],q.prototype,"updating",null),e([v()],q.prototype,"data",void 0),e([v()],q.prototype,"hasPreviousStep",null),e([v()],q.prototype,"hasUpdatableCandidates",null),e([v()],q.prototype,"nestedWorkflowCount",null),e([v()],q.prototype,"shouldShowAttachments",null),e([v()],q.prototype,"shouldAllowAttachmentEditing",null),e([v()],q.prototype,"hasPendingEdits",null),e([v()],q.prototype,"helpMessage",null),e([v()],q.prototype,"reliesOnOwnerAdminPrivileges",null),e([v()],q.prototype,"hasInvalidFormTemplate",null),q=N=e([g(H)],q);const z=(e,t)=>D().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."),Q=e=>!!e&&/update-/.test(e.type),$=q;export{$ 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{createResolver as s,onAbort as n,createAbortError as l,throwIfAborted as d,debounce as c}from"../../core/promiseUtils.js";import p from"../../core/Queue.js";import{whenOnce as u,when as w,watch as h,sync as f}from"../../core/reactiveUtils.js";import{last as v}from"../../core/SetUtils.js";import{property as k}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as g}from"../../core/accessorSupport/decorators/subclass.js";import{getAllStandardFeatureTemplatesForLayer as m}from"../../editing/templateUtils.js";import{isEditableLayer as y}from"../../layers/support/editableLayers.js";import{isFeatureLayer as W,isSubtypeSublayer as b,isSubtypeGroupLayer as A,isTable as C}from"../../layers/support/layerUtils.js";import{createFeatureServices as M}from"../../rest/featureService/utils.js";import _ from"../../views/draw/support/HighlightHelper.js";import{ViewEventPriorities as S}from"../../views/input/InputManager.js";import F from"../../views/interactive/sketch/SketchOptions.js";import{temporaryHighlightName as I}from"../../views/support/HighlightDefaults.js";import{AddAssociationWorkflow as E}from"./AddAssociationWorkflow.js";import j from"./CreateFeaturesWorkflow.js";import{UpdateFeatureWorkflow as U}from"./UpdateFeatureWorkflow.js";import{UpdateRecordWorkflow as V}from"./UpdateRecordWorkflow.js";import P from"./UpdateWorkflowData.js";import L from"./Workflow.js";import{createWorkflowSteps as x,fetchCandidates as O}from"./workflowUtils.js";import{findUtilityNetwork as T,isGraphicForRelatableFeatureSupportedLayer as N}from"../Feature/support/featureUtils.js";var R;const H="esri.widgets.Editor.UpdateWorkflow",D=()=>o.getLogger(H);let q=R=class extends L{constructor(e){super(e),this._workflowStack=new p(v),this._sketchStack=new p(v),this.data=void 0,this.type="update"}destroy(){this._drainWorkflowStack((e=>e.cancel({force:!0})))}get activeEditorItem(){return this.activeWorkflow?.data.editorItem??void 0}get activeFeatureFormViewModel(){return this.activeWorkflow?.featureFormViewModel}get activeUtilityNetworkAssociationAddAssociationViewModel(){return"add-association"===this.activeWorkflow?.type?this.activeWorkflow.utilityNetworkAssociationAddAssociationViewModel:null}get activeSketchViewModel(){return this._sketchStack.peek()?.viewModel}get canDeleteAssociation(){const{activeFeatureFormViewModel:e}=this;if(!this.activeWorkflow||!this.data.viewModel.view?.map||!e)return!1;const{activeAssociation:t,feature:a}=e;return!(!t||!a?.sourceLayer||!W(a?.sourceLayer)&&!b(a?.sourceLayer))}get activeWorkflow(){return this._workflowStack.last()}get updating(){return this._updatingHandles.updating||!!this.activeWorkflow?.updating}get hasPreviousStep(){const e=this.activeWorkflow?.featureFormViewModel;return this._stepIndex>0||this.nestedWorkflowCount>1||null!=e?.relationshipId||"view"!==this.data.viewModel.attachmentsViewModel.mode||null!=e?.associationId||null!=e?.associatedLayer}get hasUpdatableCandidates(){const{candidates:e,viewModel:t}=this.data;return e.some((({layer:e})=>t.findEditorItemForLayer(e)?.supportsUpdateWorkflow))}get nestedWorkflowCount(){return this._workflowStack.length}get shouldShowAttachments(){return!!this.activeEditorItem?.capabilities.attachments.enabled}get shouldAllowAttachmentEditing(){return!!this.activeEditorItem?.capabilities.update.attachments.enabled}get hasPendingEdits(){return Array.from(this._workflowStack).some((e=>e.hasPendingEdits))}get helpMessage(){return this.activeWorkflow?.helpMessage?this.activeWorkflow.helpMessage:"awaiting-feature-to-update"===this.stepId?"select":void 0}get reliesOnOwnerAdminPrivileges(){return this.activeWorkflow?.reliesOnOwnerAdminPrivileges??!1}get hasInvalidFormTemplate(){return!!this.activeEditorItem?.hasInvalidFormTemplate}async back(e=()=>Promise.resolve(!0)){const{activeWorkflow:t}=this,a=t?.featureFormViewModel;if(null==a?.relationshipId){if("add-association"===t?.type){const{activeUtilityNetworkAssociationAddAssociationViewModel:e}=this;if(e?.filterOptionsVisible)return void(e.filterOptionsVisible=!1)}if(null==a?.associatedLayer)if(null==a?.associationId)if("create-features"===t?.type&&t.hasPreviousStep)await t.previous({cancelCurrentStep:!0});else if(t){if(t.hasPendingEdits){if(!await e())return}t.hasPreviousStep?await t.previous({cancelCurrentStep:!0}):await this.cancelActiveWorkflow({force:!0})}else this.hasPreviousStep?await this.previous({cancelCurrentStep:!0}):await this.cancel({force:!0});else a.associationId=null;else a.associatedLayer=null}else a.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){const{viewModel:t,snappingManager:a,startAt:i,addAttachmentsCallback:o,applyEditsCallback:r,applyEditsFeatureServiceCallback:s}=e,n=e.sketchOptions??new F,l=new R({data:new P({addAttachmentsCallback:o,applyEditsCallback:r,applyEditsFeatureServiceCallback:s,sketchOptions:n,snappingManager:a,viewModel:t}),onCommit:async()=>{}});return l._set("steps",this._createWorkflowSteps(l,i)),l}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,t){try{const a=await this._createNestedUpdateWorkflow(e,t);await this._pushWorkflow(a)}catch(i){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:i})}}async startAddAssociation(e,t,i){try{const a=await this._createNestedAddAssociationWorkflow(e,t,i);await this._pushWorkflow(a)}catch(o){throw new a("editor:unable-to-start-updating","Could not begin updating the provided feature or table record.",{error:o})}}async deleteActiveFeature(){const{activeWorkflow:e}=this;if(!e)throw new a("editor:nothing-to-delete","There is no feature to delete");Q(e)?await e.deleteAndCommit():await e.cancel(),1===this.nestedWorkflowCount?await this.reset():(await this._popWorkflow(),await this._returnToPageWithContent())}async deleteActiveAssociation(){if(!this.canDeleteAssociation)throw new a("editor:nothing-to-delete","There is no association to delete");await this._deleteActiveAssociation(),await this._popWorkflow(),await this._returnToPageWithContent()}async cancelAll(){await this._drainWorkflowStack((e=>e.cancel({force:!0})))}async _deleteActiveAssociation(){const{activeFeatureFormViewModel:e,data:t}=this,{activeAssociation:i,feature:o}=e,{applyEditsFeatureServiceCallback:r,viewModel:s}=t,{sourceLayer:n}=o,l=b(n)&&n.parent?n.parent:n,d=M([l]),c=d.values().next().value?.featureService;if(!c)throw new a("editor:failed-to-delete-association","Could not retrieve feature service needed to delete association");await(c?.load());const p=s.view.map,u=T(p,l),w=u?.generateDeleteAssociations([i]);if(!w)throw new a("editor:failed-to-delete-association","Could not create payload needed to delete association");const h=u?.gdbVersion??void 0;await r(c,[w],{gdbVersion:h,globalIdUsed:!0})}async _returnToPageWithContent(){const{activeFeatureFormViewModel:e}=this;if(!e?.activeAssociationInput)return;const{activeAssociationInput:t,associationId:a}=e;await t.refresh(),t.associatedLayer&&!t.associatedFeatures?.length&&(e.associatedLayer=null),null==a||t.associatedFeatureInfos.size||(e.associationId=null)}async _createNestedCreateFeaturesWorkflow(e){const{relatedLayer:t}=e,{addAttachmentsCallback:i,applyEditsCallback:o,applyEditsFeatureServiceCallback:r,sketchOptions:s,snappingManager:n,viewModel:l}=this.data;if(!y(t))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const d=this._getCreationInfoForNestedCreateFeaturesWorkflow(e),c=d.template||d.initialFeature?"creating-features":"awaiting-feature-creation-info",p="create-features"!==this.activeWorkflow?.type&&"add-association"!==this.activeWorkflow?.type?this.activeWorkflow:void 0;return j.create({addAttachmentsCallback:i,applyEditsCallback:o,applyEditsFeatureServiceCallback:r,creationInfo:d,isNested:!0,parent:p,sketchOptions:s,snappingManager:n,startAt:c,viewModel:l})}_getCreationInfoForNestedCreateFeaturesWorkflow(e){const{relatedLayer:i}=e;if(!y(i)||A(i))throw new a("editor:unsupported-layer","Editing is not supported on the provided layer");const o={layer:i,maxFeatures:1},r=this._makeRelatedRecordAttributes(e),s=m(i);return s?.length>0?(o.attributeOverrides=r,1===s.length&&(o.template=s[0])):o.initialFeature=new t({sourceLayer:i,attributes:r}),o}async _createNestedUpdateWorkflow(e,t){const a=C(e.sourceLayer)?V:U,{applyEditsCallback:i,applyEditsFeatureServiceCallback:o,sketchOptions:r,snappingManager:s,viewModel:n}=this.data,l="create-features"!==this.activeWorkflow?.type&&"add-association"!==this.activeWorkflow?.type?this.activeWorkflow:void 0,d=await a.create({association:t,feature:e,parent:l,sketchOptions:r,snappingManager:s,viewModel:n,applyEdits:i,applyEditsFeatureService:o,featureFormCallbacks:{addRelatedRecord:async e=>await this.startCreatingRelatedRecord(e),editRelatedRecord:async({relatedFeature:e})=>await this.startUpdating(e),selectAssociatedFeature:async({feature:e,association:t})=>await this.startUpdating(e,t),addAssociation:async e=>await this.startAddAssociation(e.feature,e.utilityNetwork,e.associationType)}});return await u((()=>!d.updating)),d}async _createNestedAddAssociationWorkflow(e,t,a){const i=E,{applyEditsCallback:o,applyEditsFeatureServiceCallback:r,viewModel:s}=this.data,n="create-features"!==this.activeWorkflow?.type&&"add-association"!==this.activeWorkflow?.type?this.activeWorkflow:void 0,l=this.activeFeatureFormViewModel?.activeAssociationInput,d=await i.create({utilityNetwork:t,associationType:a,feature:e,parent:n,viewModel:s,associationInput:l,applyEdits:o,applyEditsFeatureService:r});return await u((()=>!d.updating)),d}async _drainWorkflowStack(e){const t=this._workflowStack,a=[];for(;t.length>0;){const i=t.pop();this._sketchStack.pop();const o=e(i).then((()=>i.destroy()));this._updatingHandles.addPromise(o),a.push(o)}await Promise.all(a)}_makeRelatedRecordAttributes(e){const{parentFeature:t,relatedLayer:a,relationshipId:i}=e;if(!N(t))return;const o=a.relationships?.find((e=>e.id===i));if(!o)return void z("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 z("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&&z("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 z("relationship-not-found","Could not begin creating a related record because the relationship specified could not be found on the origin layer.");const n=G(r,s),l=t.getAttribute(n);l||z("no-key-on-origin-feature","The given parent feature does not have a value for the relationship's origin primary key field.");const d=G(a,o);return{[d]:l}}async _popWorkflow(){this._workflowStack.pop()?.destroy(),this._sketchStack.pop();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=this._workflowRequiresSketchViewModel(e);this.activeWorkflow?.exit({removeSketchHandles:t});const i=this._sketchStack,o=await(e?.start()),r=i.peek();o?(r?.exit(),i.push(o)):i.push(this._cloneSketchController(r)),this._workflowStack.push(e);const s=await this._reconcileWorkflowStack();if(s.failureCount>0)throw new a("editor:failed-to-start-updating-feature","Failed to enter the provided workflow.",s)}async _reconcileWorkflowStack(){const e=this._workflowStack,t=this._sketchStack;try{const a=e.peek();return await(a?.enter()),await(t.peek()?.enter()),{activeWorkflow:a,failureCount:0}}catch(a){e.pop().destroy(),t.pop();const{activeWorkflow:i,failureCount:o}=await this._reconcileWorkflowStack();return{activeWorkflow:i,failureCount:o+1}}}_cloneSketchController(e){return{enter:e?.enter??(async()=>{}),exit:e?.exit??(async()=>{}),viewModel:e?.viewModel}}_workflowRequiresSketchViewModel(e){const{type:t}=e;return"update-feature"===t||"create-features"===t&&!C(e.data.creationInfo?.layer)}static _createWorkflowSteps(e,t="awaiting-feature-to-update"){const{data:o}=e;return x(["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;a.activeTool=null;let c=null;e.addHandles(i((()=>{c=r(c)})),this.id),o.rootFeature=null,o.candidates=[];const p=a.on("immediate-click",(async i=>{const r=s();e._updatingHandles.addPromise(r.promise);try{t.location=i.mapPoint,t.visible=!0,c?.abort();const{editorItems:r}=o.viewModel;c=new AbortController;const s=await i.async((()=>new Promise(((e,t)=>{n(c?.signal,(()=>t(l()))),e(O(r,a,i,c?.signal))}))));if(d(c),o.candidates=s.filter((e=>"fulfilled"===e.status)).flatMap((e=>e.value)).filter((e=>!e.isAggregate)),t.visible=1===o.candidates.length,0===o.candidates.length)return;i.stopPropagation(),1===o.candidates.length?(o.rootFeature=o.candidates[0],e.go("editing-existing-feature").catch((()=>{})).then((()=>t.visible=!1))):e.next()}finally{r.resolve()}}),S.TOOL),u=w((()=>null!=a.activeTool),(()=>e.cancel({force:!0})),{once:!0});a.focus(),e.addHandles([p,u],this.id)},async tearDown(){0===o.candidates.length&&(o.viewModel.spinnerViewModel.visible=!1),e.removeHandles(this.id)}}),"awaiting-update-feature-candidate":()=>({id:"awaiting-update-feature-candidate",async setUp(){o.rootFeature=null;const{view:t}=o.viewModel;if(!t)return;const a=new _({view:t,highlightName:I});e.addHandles([h((()=>o.rootFeature),((e,t)=>{a.remove(t),a.add(e)}),f),i((()=>a.removeAll()))],this.id)},async tearDown(){e.removeHandles(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=c((async()=>{await u((()=>!e.updating)),e.previous()}));e.addHandles([h((()=>e.nestedWorkflowCount),((e,t)=>{0===e&&0!==t&&o()}),f)],this.id)},async tearDown(){await e.cancelAll(),e.removeHandles(this.id)}}),"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"}})})}};function G(e,{keyField:t}){return e.getField(t)?.name??t}e([k()],q.prototype,"activeEditorItem",null),e([k()],q.prototype,"activeFeatureFormViewModel",null),e([k()],q.prototype,"activeUtilityNetworkAssociationAddAssociationViewModel",null),e([k()],q.prototype,"activeSketchViewModel",null),e([k()],q.prototype,"canDeleteAssociation",null),e([k()],q.prototype,"activeWorkflow",null),e([k()],q.prototype,"updating",null),e([k()],q.prototype,"data",void 0),e([k()],q.prototype,"hasPreviousStep",null),e([k()],q.prototype,"hasUpdatableCandidates",null),e([k()],q.prototype,"nestedWorkflowCount",null),e([k()],q.prototype,"shouldShowAttachments",null),e([k()],q.prototype,"shouldAllowAttachmentEditing",null),e([k()],q.prototype,"hasPendingEdits",null),e([k()],q.prototype,"helpMessage",null),e([k()],q.prototype,"reliesOnOwnerAdminPrivileges",null),e([k()],q.prototype,"hasInvalidFormTemplate",null),q=R=e([g(H)],q);const z=(e,t)=>D().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."),Q=e=>!!e&&/update-/.test(e.type),$=q;export{$ as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";import o from"../../Widget.js";import{css as i}from"../css.js";import{loadCalciteComponents as s}from"../../support/componentsUtils.js";import{Heading as a,incrementHeadingLevel as n}from"../../support/Heading.js";import{ItemList as c}from"../../support/ItemList.js";import{fetchThumbnail as l}from"../../support/symbolPreviewUtils.js";import"../../support/widgetUtils.js";import{messageBundle as d}from"../../support/decorators/messageBundle.js";import{tsx as p,tsxFragment as m}from"../../support/jsxFactory.js";let u=class extends o{constructor(){super(...arguments),this.workflow=null,this.headingLevel=4,this._iconIntersectionObserver=new IntersectionObserver(((e,t)=>{e.forEach((async e=>{if(e.isIntersecting){const r=e.target;if(f(r))return void t.unobserve(r);const o=h(r),{graphic:i}=o,s=i.sourceLayer??this.workflow?.data.creationInfo?.layer;if(!s||!i)return;g(r,!0);const a=await l(i,s).catch((()=>(g(r,!1),null)));if(null==a)return;r.appendChild(a)}}))})),this.messages=null,this._renderItemIcon=e=>p("span",{afterCreate:this._afterItemCreateOrUpdate,afterRemoved:this._afterItemRemoved,afterUpdate:this._afterItemCreateOrUpdate,"data-has-icon":!1,"data-item":e,key:"icon"}),this._afterItemCreateOrUpdate=e=>{this._iconIntersectionObserver?.observe(e)},this._afterItemRemoved=e=>{this._iconIntersectionObserver?.unobserve(e)}}loadDependencies(){return s({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list")})}destroy(){this._iconIntersectionObserver?.disconnect(),this._iconIntersectionObserver=null}render(){const e=this.workflow;if(!e)return p(m,null,void 0);const t=this.messages,r=e.pendingFeatures.map(((r,o)=>{const i=e.data.isSubmittable(r);return{disabled:!1,id:`${o}`,graphic:r,label:i?t.createFeaturesSelectionList.featureReadyToSubmit:t.createFeaturesSelectionList.featureNotReadyToSubmit,submittable:i}})).toArray();return p("div",null,p(a,{level:n(this.headingLevel)},t.createFeaturesSelectionList.heading),p("calcite-list",{label:t.createFeaturesSelectionList.heading},c({enableListScroll:!1,filterEnabled:!1,filterText:"",id:"update-features-pick-list",items:r,messages:{filterPlaceholder:"",noItems:"",noMatches:""},renderIcon:this._renderItemIcon,renderItemTitle:e=>e.label,renderItemLabel:e=>e.id,onItemMouseEnter:t=>e.data.temporaryHighlightFeature=t.graphic,onItemMouseLeave:()=>e.data.temporaryHighlightFeature=null,onItemSelect:t=>e.updatePendingFeature(t.graphic),renderItemContentEnd:({graphic:t})=>[e.data.isSubmittable(t)?void 0:p("calcite-icon",{class:i.pendingFeatureListIcon,icon:"exclamation-mark-triangle",scale:"s",slot:"content-end"})],renderItemActionEnd:({graphic:r})=>p(m,null,p("calcite-action",{appearance:"transparent",icon:"zoom-to-object",onblur:()=>{e.data.temporaryHighlightFeature=null},onclick:()=>e.data.viewModel.zoomTo(r),onfocus:()=>{e.data.temporaryHighlightFeature=r},scale:"s",slot:"actions-end",text:t.zoomTo,title:t.zoomTo}),p("calcite-action",{appearance:"transparent",icon:"trash",onblur:()=>{e.data.temporaryHighlightFeature=null},onclick:()=>e.cancelFeature(r),onfocus:()=>{e.data.temporaryHighlightFeature=r},scale:"s",slot:"actions-end",text:t.createFeaturesSelectionList.discard,title:t.createFeaturesSelectionList.discard}))})))}};function h(e){return e?.["data-item"]}function f(e){return!!e?.["data-has-icon"]}function g(e,t){e&&(e["data-has-icon"]=t)}e([t()],u.prototype,"workflow",void 0),e([t()],u.prototype,"headingLevel",void 0),e([t(),d("esri/widgets/Editor/t9n/Editor")],u.prototype,"messages",void 0),u=e([r("esri.widgets.Editor.components.PendingFeatureList")],u);const b=u;export{b as default};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import{property as t}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";import o from"../../Widget.js";import{css as i}from"../css.js";import{loadCalciteComponents as s}from"../../support/componentsUtils.js";import{Heading as a,incrementHeadingLevel as n}from"../../support/Heading.js";import{ItemList as c}from"../../support/ItemList.js";import{fetchThumbnail as l}from"../../support/symbolPreviewUtils.js";import"../../support/widgetUtils.js";import{messageBundle as d}from"../../support/decorators/messageBundle.js";import{tsx as m,tsxFragment as p}from"../../support/jsxFactory.js";let u=class extends o{constructor(){super(...arguments),this.workflow=null,this.headingLevel=4,this._iconIntersectionObserver=new IntersectionObserver(((e,t)=>{e.forEach((async e=>{if(e.isIntersecting){const r=e.target;if(g(r))return void t.unobserve(r);const o=h(r),{graphic:i}=o,s=i.sourceLayer??this.workflow?.data.creationInfo?.layer;if(!s||!i)return;f(r,!0);const a=await l(i,s).catch((()=>(f(r,!1),null)));if(null==a)return;r.appendChild(a)}}))})),this.messages=null,this._renderActionEnd=({graphic:e})=>{const{workflow:t,messages:r}=this;if(!t)return;const o=e.geometry?m("calcite-action",{appearance:"transparent",icon:"zoom-to-object",onblur:()=>{t.data.temporaryHighlightFeature=null},onclick:()=>t.data.viewModel.zoomTo(e),onfocus:()=>{t.data.temporaryHighlightFeature=e},scale:"s",slot:"actions-end",text:this.messages.zoomTo,title:this.messages.zoomTo}):void 0,i=t.data.isSharedTemplateWorkflow?void 0:m("calcite-action",{appearance:"transparent",icon:"trash",onblur:()=>{t.data.temporaryHighlightFeature=null},onclick:()=>t.cancelFeature(e),onfocus:()=>{t.data.temporaryHighlightFeature=e},scale:"s",slot:"actions-end",text:r.createFeaturesSelectionList.discard,title:r.createFeaturesSelectionList.discard});return m(p,null,o,i)},this._renderItemContentEnd=({graphic:e})=>{const{workflow:t}=this,r=t?.data.isSubmittable(e);return[r?void 0:m("calcite-icon",{class:i.pendingFeatureListIcon,icon:"exclamation-mark-triangle",scale:"s",slot:"content-end"})]},this._renderItemIcon=e=>{if(null!=e?.graphic?.geometry)return m("span",{afterCreate:this._afterItemCreateOrUpdate,afterRemoved:this._afterItemRemoved,afterUpdate:this._afterItemCreateOrUpdate,"data-has-icon":!1,"data-item":e,key:"icon"})},this._afterItemCreateOrUpdate=e=>{this._iconIntersectionObserver?.observe(e)},this._afterItemRemoved=e=>{this._iconIntersectionObserver?.unobserve(e)}}loadDependencies(){return s({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list")})}destroy(){this._iconIntersectionObserver?.disconnect(),this._iconIntersectionObserver=null}render(){const e=this.workflow;if(!e)return m(p,null,void 0);const t=this.messages,r=e.pendingFeatures.map(((r,o)=>{const i=e.data.isSubmittable(r),s=i?t.createFeaturesSelectionList.featureReadyToSubmit:t.createFeaturesSelectionList.featureNotReadyToSubmit;return{disabled:!1,id:`${e.data.getFeatureTitle(r)??o}`,graphic:r,label:s,submittable:i}})).toArray();return m("div",null,m(a,{level:n(this.headingLevel)},t.createFeaturesSelectionList.heading),m("calcite-list",{label:t.createFeaturesSelectionList.heading},c({enableListScroll:!1,filterEnabled:!1,filterText:"",id:"update-features-pick-list",items:r,messages:{filterPlaceholder:"",noItems:"",noMatches:""},renderIcon:this._renderItemIcon,renderItemTitle:e=>e.label,renderItemLabel:e=>e.id,onItemMouseEnter:t=>e.data.temporaryHighlightFeature=t.graphic,onItemMouseLeave:()=>e.data.temporaryHighlightFeature=null,onItemSelect:t=>e.updatePendingFeature(t.graphic),renderItemContentEnd:this._renderItemContentEnd,renderItemActionEnd:this._renderActionEnd})))}};function h(e){return e?.["data-item"]}function g(e){return!!e?.["data-has-icon"]}function f(e,t){e&&(e["data-has-icon"]=t)}e([t()],u.prototype,"workflow",void 0),e([t()],u.prototype,"headingLevel",void 0),e([t(),d("esri/widgets/Editor/t9n/Editor")],u.prototype,"messages",void 0),u=e([r("esri.widgets.Editor.components.PendingFeatureList")],u);const b=u;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.32/esri/copyright.txt for details.
4
4
  */
5
- import{loadCalciteComponents as t}from"../../support/componentsUtils.js";import{Heading as e}from"../../support/Heading.js";import{iconByKind as o}from"../../support/iconUtils.js";import{setFocus as i}from"../../support/widgetUtils.js";import{tsx as a}from"../../support/jsxFactory.js";const c="esri-editor__prompt",n={base:c,header:`${c}__header`,heading:`${c}__header__heading`,message:`${c}__message`,divider:`${c}__divider`,actions:`${c}__actions`},s=()=>t({button:()=>import("@esri/calcite-components/dist/components/calcite-button"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),scrim:()=>import("@esri/calcite-components/dist/components/calcite-scrim"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group")});function r({actions:t,context:c,headingLevel:s,message:r,title:p,...d}){const{primary:m,secondary:u}=t;let b;switch(c){case"danger":b="danger";break;case"info":b="brand";break;default:b="neutral"}const g=a("calcite-button",{afterCreate:t=>i(t),appearance:"solid","data-testid":"primary-prompt-button",key:"prompt-primary-button",kind:b,onclick:m.action,width:"full"},m.label),h=u&&a("calcite-button",{appearance:"outline","data-testid":"secondary-prompt-button",key:"prompt-secondary-button",kind:b,onclick:u.action,width:"full"},u.label);return a("calcite-scrim",{"data-testid":"prompt",key:"prompt"},a("div",{class:`${n.base}--${c}`},a("div",{class:n.header},a("calcite-icon",{icon:o.warning}),a(e,{class:n.heading,level:s},p)),a("div",{class:n.message},r),l(d)??a("div",{class:n.divider}),a("div",{class:n.actions},h,g)))}function l({radios:t,onRadioSelection:e,defaultRadioSelection:o}){return t?.length?a("calcite-radio-button-group",{name:"PromptChoiceList"},t.map((t=>a("calcite-label",{layout:"inline"},a("calcite-radio-button",{checked:t.value===o,value:t.value,onCalciteRadioButtonChange:()=>e?.(t.value)}),t.label)))):void 0}export{r as Prompt,n as css,s as loadPromptComponents};
5
+ import{loadCalciteComponents as t}from"../../support/componentsUtils.js";import{Heading as e}from"../../support/Heading.js";import{iconByKind as o}from"../../support/iconUtils.js";import{setFocus as i}from"../../support/widgetUtils.js";import{tsx as a}from"../../support/jsxFactory.js";const c="esri-editor__prompt",n={base:c,header:`${c}__header`,heading:`${c}__header__heading`,message:`${c}__message`,divider:`${c}__divider`,actions:`${c}__actions`,halfWidthButton:`${c}__half-width-button`},s=()=>t({button:()=>import("@esri/calcite-components/dist/components/calcite-button"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),scrim:()=>import("@esri/calcite-components/dist/components/calcite-scrim"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),"radio-button":()=>import("@esri/calcite-components/dist/components/calcite-radio-button"),"radio-button-group":()=>import("@esri/calcite-components/dist/components/calcite-radio-button-group")});function r({actions:t,context:c,headingLevel:s,message:r,title:d,...p}){const{primary:m,secondary:u}=t;let b;switch(c){case"danger":b="danger";break;case"info":b="brand";break;default:b="neutral"}const h=a("calcite-button",{afterCreate:t=>i(t),appearance:"solid",classes:{[n.halfWidthButton]:!!u},"data-testid":"primary-prompt-button",key:"prompt-primary-button",kind:b,onclick:m.action,width:"full"},m.label),g=u&&a("calcite-button",{appearance:"outline",class:n.halfWidthButton,"data-testid":"secondary-prompt-button",key:"prompt-secondary-button",kind:b,onclick:u.action,width:"full"},u.label);return a("calcite-scrim",{"data-testid":"prompt",key:"prompt"},a("div",{class:`${n.base}--${c}`},a("div",{class:n.header},a("calcite-icon",{icon:o.warning}),a(e,{class:n.heading,level:s},d)),a("div",{class:n.message},r),l(p)??a("div",{class:n.divider}),a("div",{class:n.actions},g,h)))}function l({radios:t,onRadioSelection:e,defaultRadioSelection:o}){return t?.length?a("calcite-radio-button-group",{name:"PromptChoiceList"},t.map((t=>a("calcite-label",{layout:"inline"},a("calcite-radio-button",{checked:t.value===o,value:t.value,onCalciteRadioButtonChange:()=>e?.(t.value)}),t.label)))):void 0}export{r as Prompt,n as css,s as loadPromptComponents};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.32/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../Color.js";import t from"../../Graphic.js";import{addMany as r,equals as i}from"../../core/arrayUtils.js";import{createTask as n}from"../../core/asyncUtils.js";import"../../core/has.js";import a from"../../core/Error.js";import{handlesGroup as o,makeHandle as s,abortHandle as l}from"../../core/handleUtils.js";import{clone as c}from"../../core/lang.js";import u from"../../core/Logger.js";import{getOrCreateMapValue as p}from"../../core/MapUtils.js";import{whenOrAbort as d,throwIfAborted as y,debounce as f,isPromiseLike as m}from"../../core/promiseUtils.js";import{watch as g,on as h,whenOnce as w}from"../../core/reactiveUtils.js";import{px2pt as b}from"../../core/screenUtils.js";import{diff as v}from"../../core/accessorSupport/diffUtils.js";import{isSharedGroupTemplate as S,isSharedPresetTemplate as j,isStandardFeatureTemplate as I,isSharedFeatureTemplate as T,getAllStandardFeatureTemplatesForLayer as U,isSharedTemplate as V,isSharedTemplateOrMetadata as L}from"../../editing/templateUtils.js";import k from"../../editing/sharedTemplates/SharedTemplate.js";import{getSharedTemplateProvider as O}from"../../editing/sharedTemplates/SharedTemplateProvider.js";import F from"../../layers/GraphicsLayer.js";import{featureHasFields as z,fixFields as x,getDisplayFieldName as A}from"../../layers/support/fieldUtils.js";import{isSubtypeSublayer as M}from"../../layers/support/layerUtils.js";import{calculateTolerance as P}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as C}from"../../renderers/support/lengthUtils.js";import{getTransformationType as E,TransformationType as R}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{getRotationAngle as G,getSize as D}from"../../renderers/visualVariables/support/visualVariableUtils.js";import Z from"../../symbols/SimpleFillSymbol.js";import q from"../../symbols/SimpleLineSymbol.js";import B from"../../symbols/SimpleMarkerSymbol.js";import{to3D as N}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as Q}from"../../symbols/support/symbolUtils.js";import{getServices as J}from"../../undoredo/support/Services.js";import{GraphicState as W}from"../../views/3d/layers/graphics/GraphicState.js";import{defaultDrawingMode as H}from"../../views/draw/DrawingMode.js";import{createQueryGeometry as K}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as X,filterGraphicHits as Y}from"../../views/support/hitTestSelectUtils.js";import{isDrawGraphicTool as $}from"../Sketch/support/sketchUtils.js";const _=()=>u.getLogger("esri.widgets.Editor.workflowUtils");function ee(e){return"update"===e.type}function te(e){const t=e.sourceLayer;if(!t||"feature"!==t.type||!se(t.renderer))return{rotation:null,size:null};let r=null,i=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&&(r=re(n[0],t));const a=t.renderer.getVisualVariablesForType("size").filter((t=>t.field&&!t.useSymbolValue&&!t.valueExpression&&E(t)===R.RealWorldSize&&null!=D(t,e)));return 1===a.length&&(i=ae(a[0],t)),{rotation:r,size:i}}function re(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,i=e.field,n=t.fields&&t.fields.filter((e=>e.name===i)),a=n&&1===n.length?n[0].type:"double",o={initial:0,current:0};return{field:i,fieldType:a,getDefault:()=>Promise.resolve(0),getValue:e=>(o.current=o.initial-r*e,oe((o.current+360)%360,a)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function ie(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 ne(e,t,r){if(null==t)return 0;const{symbol:i}=N(t);if(null==i||"web-style"===i.type||"cim"===i.type)return 0;const n=i.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(Pe.icon,(await e(n,Pe.icon))[0])||Pe.icon}case"text":return n.size||Pe.text;case"line":return n.size||Pe.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return ie(await t(n,e.scale/Pe.viewScaleSizeFactor),r)}case"path":return(null!=n.width?n.width:n.height)||e.scale/Pe.viewScaleSizeFactor;case"extrude":return n.size||e.scale/Pe.viewScaleSizeFactor;default:return 0}}function ae(e,t){const r=e.field,i=e.axis,n=t.fields&&t.fields.filter((e=>e.name===r)),a=n&&1===n.length?n[0].type:"double",o={initial:0,current:0},s=C[e.valueUnit]??1;let l;return l="area"===e.valueRepresentation?e=>(e*s/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*s/2:e=>e*s,{field:r,fieldType:a,getDefault:async(e,t)=>oe(l(await ne(t,e,i)),a),getValue:(e,t)=>(o.initial||(o.initial=t.pixelSizeAt(t.center)),o.current=o.initial*e,oe(o.current,a)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,displayUnit:Re(e.valueUnit),axis:e.axis}}function oe(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 se(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 le(e,t,r){const i=await Q(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t,scale:r});null!=v(e.symbol,i)&&(e.symbol=i)}function ce(e,t){if(!e||!t)throw new Error("no geometry type");if("multipatch"===e)return{tool:"mesh",createOptions:{mode:"hybrid"}};const r=new Map;r.set("circle",{mode:"freehand"}),r.set("rectangle",{mode:"freehand"});const i={mode:H,optionsPerTool:r};if(L(t)){const n=t.defaultTool,a=S(t)?t.definition?.inputGeometryType??e:e;switch(n){case"freehand":case"stream-line":return{tool:"polyline"===a?"freehandPolyline":"freehandPolygon",createOptions:i};case"autocomplete-freehand-polygons":case"stream-polygon":return{tool:"freehandPolygon",createOptions:i};case"autocomplete-polygons":case"difference-polygon":case"create-structures":case"polygon":case"trace":return{tool:"polygon"===a?"polygon":"polyline",createOptions:i};case"circle":return r.get("circle").preserveAspectRatio=!0,{tool:"circle",createOptions:i};case"ellipse":return r.get("circle").preserveAspectRatio=!1,{tool:"circle",createOptions:i};case"create-points-along-line":case"multipoint":return{tool:"multipoint",createOptions:i};case"line":case"radial-line":case"right-angle-line":case"split":case"two-point-line":return{tool:"polyline",createOptions:i};case"rectangle":case"regular-polygon":case"right-angle-polygon":return{tool:"rectangle",createOptions:i};case"elevation-point-from-contour":case"elevation-point-from-dem":case"parcel-seed":case"point":case"point-and-rotation":case"point-at-end-of-line":return{tool:"point",createOptions:i}}}else{const n=t.drawingTool;if("circle"===n||"ellipse"===n)return r.get("circle").preserveAspectRatio="circle"===n,{tool:"circle",createOptions:i};if("rectangle"===n)return{tool:"rectangle",createOptions:i};if("freehand"===n)return{tool:"polygon"===e?"freehandPolygon":"freehandPolyline",createOptions:i}}return{tool:e,createOptions:i}}async function ue(e,t,r){const{creationInfo:i,fullTemplate:n}=t;if(!i)throw new a("No creation info provided.");const o=i.layer,s=he(n,i.attributeOverrides),{view:l}=e,c="2d"===l?.type;S(n)||j(n)||await we(e,o,s,r,c?l.scale:null);const{capabilities:u}=o;e.layer.elevationInfo=o.elevationInfo;const p=ce(o.geometryType,n);return e.defaultCreateOptions={graphicProperties:{attributes:s,sourceLayer:o},mode:p.createOptions.mode,optionsPerTool:p.createOptions.optionsPerTool,preserveAspectRatio:p.createOptions.preserveAspectRatio,hasZ:u.data.supportsZ,defaultZ:(c?u.editing.zDefault:null)??e.defaultCreateOptions.defaultZ},null==i.geometryToPlace?await e.create(p.tool):await e.place(i.geometryToPlace,{graphicProperties:{attributes:s,sourceLayer:o}}),pe({creationAttributes:s,data:t,sketchViewModel:e,view:l,webStyleCache:r})}async function pe(e){return o([await de(e),await ye(e)])}async function de({creationAttributes:e,data:t,sketchViewModel:r,view:i,webStyleCache:n}){const{creationInfo:a}=t,{fullTemplate:o}=t;if(!a||"2d"!==i?.type||S(o)||j(o))return null;const s=f((t=>we(r,a.layer,e,n,t)));return g((()=>i.scale),(e=>s(e)))}async function ye({data:t,sketchViewModel:r,view:i}){const{templateExecutorInfo:n}=t;if(!n)return null;const l=r.activeComponent;if(!i||!$(l))return _().error(new a("Failed to set up template feedback.")),null;const c=new F({effect:"saturate(0.6) opacity(0.8)",listMode:"hide",title:"Shared Template Feedback Graphics"});i.map?.add(c);const{executor:u,serviceLayersById:p}=n,d=i.theme?.accentColor??new e([255,165,0,1]);return o([h((()=>l),["cursor-update","vertex-add"],(()=>{c.removeAll();const e=l.graphic?.geometry;if(!e||!fe(e))return;const t=u(e,"digitizing");if(!m(t))for(const r of t.edits){const e=p.get(r.id);if(e&&r.addFeatures&&0!==r.addFeatures.length)for(const t of e)if(!t.isTable)for(const e of r.addFeatures){const t=me(e,d);t&&c.add(t)}}})),s((()=>{i.map.remove(c),c.destroy()}))])}function fe(e){switch(e.type){case"point":case"multipoint":return!0;case"polyline":return e.paths[0].length>1;case"polygon":{const t=e.rings[0];return i(t.at(0),t.at(-1))?t.length>2:t.length>1}default:return!1}}function me(e,r){let i=null;switch(e.geometry?.type){case"point":case"multipoint":i=new B({angle:0,color:r,outline:new q({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:1}),path:"undefined",size:8,style:"circle",xoffset:0,yoffset:0});break;case"polygon":i=new Z({color:r,outline:new q({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:3}),style:"none"});break;case"polyline":i=new q({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:2});break;default:return null}return new t({geometry:e.geometry,symbol:i,attributes:{...e.attributes}})}async function ge(e,t){const r=await J(t).load(),i=M(e)?e.parent:e,n=r.tablesAndLayersLookup.get(i);if(!n)return new Map;const a=new Map;for(const o of n.layersAndTables)p(a,o.layerId,(()=>[])).push(o);return a}function he(e,t={}){return S(e)||j(e)?{}:I(e)?{...e.prototype.attributes,...t}:T(e)?{...e.definition?.defaultValues,...t}:{...t}}async function we(e,r,i,n,a){const o=new t({sourceLayer:r,attributes:i}),{rotation:s,size:l}=te(o);let c=await Q(o,{useSourceLayer:!0,webStyleCache:n,scale:a}),u=!1;for(const t of[l,s]){if(null==t)continue;null==i[t.field]&&(i[t.field]=await t.getDefault(c,e.view),u=!0)}switch(u&&(c=await Q(o,{useSourceLayer:!0,webStyleCache:n,scale:a})),c?.type){case"simple-fill":case"polygon-3d":e.polygonSymbol=c;break;case"simple-line":case"line-3d":e.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":e.pointSymbol=c;break;case"mesh-3d":e.meshSymbol=c}be(e.tooltipOptions,l,s)}function be(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 ve(e,t){return e?.find((e=>e.layer===t))}async function Se(e,t,r,i){switch(t.type){case"3d":return je(e,t,r,i);case"2d":return Ie(e,t,r,i)}}async function je(e,t,i,n){if(0===e.length)return[];const{updatable:a,graphicsByLayer:o}=await i.async((async()=>{const{results:r}=await d(X(t,i),n),a=new Map,o=e=>{const t=e.layer,r=a.get(t);if(!r){const e=new Array;return a.set(t,e),e}return r};Y(r).forEach((({graphic:e})=>o(e).push(e)));const s=e.filter((({capabilities:e,layer:t})=>e.update.enabled&&a.has(t)));return 0!==s.length&&i.stopPropagation(),{updatable:s,graphicsByLayer:a}}));return d(Promise.allSettled(a.map((async({layer:e})=>{const t=o.get(e),i=Te(e);if(t.every((e=>z(i,e))))return t;const a=[];for(const n of t){a.push(n.getObjectId());const e=Object.keys(n.attributes);r(i,e)}const s=e.createQuery();return s.returnGeometry=!1,s.objectIds=a,s.outFields=x(e.fieldsIndex,i),e.queryFeatures(s,{signal:n}).then((({features:e})=>e))}))),n)}async function Ie(e,t,r,i){if(0===e.length)return[];const{mapPoint:n}=r;if(null==n)return[];let a=null;const o=await r.async((async()=>{const{results:n}=await d(t.hitTest(r),i);if(0===n.length)return[];const o=new Set;a=Y(n),a.forEach((({graphic:e})=>e&&o.add(e.layer)));const s=e.filter((e=>o.has(e.layer)&&e.supportsUpdateWorkflow));return s.length>0&&r.stopPropagation(),s}));return d(Promise.allSettled(o.map((async({layer:e})=>{const o=e.createQuery();o.returnGeometry=!1,o.outFields=Te(e);const s="renderer"in e?P({renderer:e.renderer,pointerType:r.pointerType}):0;o.geometry=K(n,s,t),o.outSpatialReference=t.spatialReference;const{features:l}=await e.queryFeatures(o,{signal:i});return a?.forEach((({graphic:t})=>{t.layer!==e||l.some((e=>e.getObjectId()===t.getObjectId()))||l.push(t)})),l}))),i)}function Te(e){return x(e.fieldsIndex,[e.objectIdField,A({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function Ue(e,t,r){const{sourceLayer:i}=e,n=i.createQuery();n.objectIds=[e.getAttribute(i.objectIdField)],n.outFields=["*"],n.returnM=i.capabilities.data.supportsM,n.returnZ=i.capabilities.data.supportsZ,"scene"===i.type&&null!=i.infoFor3D||(n.outSpatialReference=t);const a=await i.queryFeatures(n,{signal:r});y(r);return a.features[0]}async function Ve(e){const{graphic:t,sketchViewModel:r,sourceLayer:i,visualVariables:n}=e;await Le(e);const a={multipleSelectionEnabled:!1};return"point"===i.geometryType&&(a.enableRotation=null!=n.rotation,a.enableScaling=null!=n.size),r.update(t,a)}async function Le(e){const{graphic:t,sketchViewModel:r,sourceLayer:i,visualVariables:n,webStyleCache:a}=e;let o=!1;const{rotation:s,size:l}=n;if([s,l].forEach((async e=>{if(null==e)return;const i=t.getAttribute(e.field);if(null!=i)e.setInitialValue(i);else{const i=await e.getDefault(t.symbol,r.view);e.setInitialValue(i),t.setAttribute(e.field,i),o=!0}})),o){const e="2d"===r.view?.type?r.view.scale:null;await le(t,a,e)}be(r.tooltipOptions,l,s),r.layer.elevationInfo=i.elevationInfo}function ke(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function Oe(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function Fe(e,t,r,i,n){if(null==t.geometry||"point"!==t.geometry?.type)return;const a=i.rotation,o=ke(r.toolEventInfo);if(null!=a&&null!=o){const{field:r,getValue:i}=a;"rotate-stop"===o.type?(a.isUpdatingInteractively=!1,a.setInitialValue(t.getAttribute(r))):(a.isUpdatingInteractively=!0,t.setAttribute(r,i(o.angle,e)))}const s=i.size,l=Oe(r.toolEventInfo);if(null!=s&&null!=l){const{field:r,getValue:i}=s;"scale-stop"===l.type?(s.isUpdatingInteractively=!1,s.setInitialValue(t.getAttribute(r))):(s.isUpdatingInteractively=!0,t.setAttribute(r,i(l.xScale,e)))}await le(t,n,"2d"===e.type?e.scale:null)}async function ze({feature:e,featureClone:t,visualVariableAttributes:r,sketchViewModel:i,view:n,onUpdate:a,webStyleCache:c,addUpdatingPromise:u,addHandle:p}){await le(t,c,"2d"===n.type?n.scale:null);let d=null;if("2d"===i?.view?.type){const e=f((e=>le(t,c,e)));d=g((()=>i?.view?.scale),(t=>e(t)))}const y=t.sourceLayer,m=Ze(n,y);await Ve({graphic:t,sketchViewModel:i,sourceLayer:y,visualVariables:r,webStyleCache:c});let h=null;m.then((e=>h=e)).catch((()=>{}));const b=r.size,v=r.rotation,S=g((()=>e.attributes),(async e=>{let r=!1;for(const i in e){const n=e[i];n!==t.getAttribute(i)&&(t.setAttribute(i,n),null==b||b.isUpdatingInteractively||b.field!==i||b.setInitialValue(n),null==v||v.isUpdatingInteractively||v.field!==i||v.setInitialValue(n),(null==h||h.requiredFields.includes(i))&&(r=!0))}r&&await le(t,c,"2d"===n.type?n.scale:null)})),j=i.on("update",(async e=>{const t=e.graphics[0],o={graphic:t,sketchViewModel:i,sourceLayer:y,visualVariables:r,webStyleCache:c};if("complete"===e.state){if(null===n.activeTool)return Ve(o);const e=new AbortController,t=l(e);return p(t),u(w((()=>null===n.activeTool),e.signal).then((()=>(e.abort(),Ve(o)))))}await Fe(n,t,e,r,c),a(Be(t),e)})),I=i.on(["undo","redo"],(async e=>{a(Be(e.graphics[0]),e)}));return o([I,j,s((()=>i.cancel())),S,d])}async function xe(e,t,r){const i=e.view;e.layer.add(r);const a=t.sourceLayer,l=t.layer,c=t.getAttribute(l.objectIdField);let u=null;function p(e){u?.abort(),u=n((async t=>{const r=await Ze(i,a);y(t),r.setVisibility?.(c,e)}))}return await Me(i,r),p(!1),o([Ae(i,r,(e=>p(!e))),s((async()=>{p(!0);try{const e=await Ze(i,a);await w((()=>!e.updating))}finally{e.layer.remove(r)}}))])}function Ae(e,t,r){if("3d"===e.type){const i=new W({graphic:t});return o([e.trackGraphicState(i),g((()=>i.displaying),r)])}return g((()=>t.visible),r)}async function Me(e,t){if("3d"===e.type){const r=new W({graphic:t}),i=e.trackGraphicState(r);await w((()=>r.displaying||r.error)),i.remove()}else await w((()=>t.visible))}const Pe={icon:b(24),text:b(12),line:b(1),viewScaleSizeFactor:100};function Ce(e,t,r){let i=!1;return e.filter((e=>!!i||(i=e===t,i))).map((e=>r[e]()))}function Ee(e,t){e.viewModel.syncFeatureTemplates();const r=e.creationInfo;if("awaiting-feature-creation-info"===t[0].id&&r){const e=r.layer,i=U(e);1===i.length&&"scene"!==e.type&&(r.template=i[0],t.shift())}return t}function Re(e){return"unknown"===e?null:e}function Ge(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}const De=e=>/-stop/.test(e)||/vertex-/.test(e),Ze=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function qe(e){return"createInteractiveEditSession"in e}function Be(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=c(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function Ne(e){const t=e.cursor;return e.cursor="progress",s((()=>e.cursor=t))}async function Qe(e,t){const{template:r}=e;if(null==r)return null;if(V(r))return r.load();if(L(r)){const e=O(t,{makeSharedTemplateFromJSON:Je}),i=await e.getTemplates({templateIds:[r.templateId],featureService:r.featureService});if(0===i.length)throw new a("editor:failed-to-load-template","Unable to load the provided template");return i[0].load()}return r}const Je=e=>k.fromJSON(e);export{Ee as avoidFeatureTemplateSelectionWithOnlyOneItem,qe as canCreateInteractiveEditSession,Be as cloneGraphicExceptMesh,Ce as createWorkflowSteps,Se as fetchCandidates,Ue as fetchFullFeature,ve as findLayerInfo,he as getCreationAttributes,Qe as getFullTemplateForCreationInfo,ge as getServiceLayersById,te as getVisualVariableAttributes,De as isTerminalUpdateEventType,ee as isUpdateWorkflow,Ge as prepareAttachmentsForCreateFeaturesWorkflow,ze as setUpGeometryUpdate,pe as setUpSketchCreateWatchers,Le as setVisualVariablesAndElevationInfoForUpdate,Ne as showProgressCursor,Pe as sizeDefaults,Re as sizeVariableUnitToLengthUnit,ue as startCreatingNewFeature,Ve as startUpdatingFeatureGeometry,xe as swapForEditingSession,le as updateGraphicSymbolWhenRequired,Fe as visualVariableInteractiveUpdate,Ze as whenEditorLayerView,Me as whenGraphicDisplayed};
5
+ import e from"../../Color.js";import t from"../../Graphic.js";import{addMany as r,equals as i}from"../../core/arrayUtils.js";import{createTask as n}from"../../core/asyncUtils.js";import"../../core/has.js";import a from"../../core/Error.js";import{handlesGroup as o,makeHandle as s,abortHandle as l}from"../../core/handleUtils.js";import{clone as c}from"../../core/lang.js";import u from"../../core/Logger.js";import{getOrCreateMapValue as p}from"../../core/MapUtils.js";import{whenOrAbort as d,throwIfAborted as y,debounce as f,isPromiseLike as m}from"../../core/promiseUtils.js";import{watch as g,on as h,whenOnce as w}from"../../core/reactiveUtils.js";import{px2pt as b}from"../../core/screenUtils.js";import{diff as v}from"../../core/accessorSupport/diffUtils.js";import{isSharedTemplateOrMetadata as S,isSharedGroupTemplate as j,isSharedPresetTemplate as I,isStandardFeatureTemplate as T,isSharedFeatureTemplate as U,getAllStandardFeatureTemplatesForLayer as V,isSharedTemplate as L}from"../../editing/templateUtils.js";import k from"../../editing/sharedTemplates/SharedTemplate.js";import{getSharedTemplateProvider as F}from"../../editing/sharedTemplates/SharedTemplateProvider.js";import O from"../../layers/GraphicsLayer.js";import{featureHasFields as A,fixFields as z,getDisplayFieldName as x}from"../../layers/support/fieldUtils.js";import{isSubtypeSublayer as M}from"../../layers/support/layerUtils.js";import{calculateTolerance as P}from"../../renderers/support/clickToleranceUtils.js";import{meterIn as C}from"../../renderers/support/lengthUtils.js";import{getTransformationType as E,TransformationType as R}from"../../renderers/visualVariables/support/sizeVariableUtils.js";import{getRotationAngle as G,getSize as D}from"../../renderers/visualVariables/support/visualVariableUtils.js";import Z from"../../symbols/SimpleFillSymbol.js";import q from"../../symbols/SimpleLineSymbol.js";import B from"../../symbols/SimpleMarkerSymbol.js";import{to3D as N}from"../../symbols/support/symbolConversion.js";import{getDisplayedSymbol as Q}from"../../symbols/support/symbolUtils.js";import{getServices as J}from"../../undoredo/support/Services.js";import{GraphicState as W}from"../../views/3d/layers/graphics/GraphicState.js";import{defaultDrawingMode as H}from"../../views/draw/DrawingMode.js";import{createQueryGeometry as K}from"../../views/support/drapedUtils.js";import{hitTestSelectSimilarDistance as X,filterGraphicHits as Y}from"../../views/support/hitTestSelectUtils.js";import{isDrawGraphicTool as $}from"../Sketch/support/sketchUtils.js";const _=()=>u.getLogger("esri.widgets.Editor.workflowUtils");function ee(e){return"update"===e.type}function te(e){const t=e.sourceLayer;if(!t||"feature"!==t.type||!se(t.renderer))return{rotation:null,size:null};let r=null,i=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&&(r=re(n[0],t));const a=t.renderer.getVisualVariablesForType("size").filter((t=>t.field&&!t.useSymbolValue&&!t.valueExpression&&E(t)===R.RealWorldSize&&null!=D(t,e)));return 1===a.length&&(i=ae(a[0],t)),{rotation:r,size:i}}function re(e,t){const r="heading"===(e.axis||"heading")&&"arithmetic"===e.rotationType?-1:1,i=e.field,n=t.fields&&t.fields.filter((e=>e.name===i)),a=n&&1===n.length?n[0].type:"double",o={initial:0,current:0};return{field:i,fieldType:a,getDefault:()=>Promise.resolve(0),getValue:e=>(o.current=o.initial-r*e,oe((o.current+360)%360,a)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,rotationType:e.rotationType??"geographic"}}function ie(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 ne(e,t,r){if(null==t)return 0;const{symbol:i}=N(t);if(null==i||"web-style"===i.type||"cim"===i.type)return 0;const n=i.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(Pe.icon,(await e(n,Pe.icon))[0])||Pe.icon}case"text":return n.size||Pe.text;case"line":return n.size||Pe.line;case"object":{const{computeObjectLayerResourceSize:t}=await import("../../symbols/support/symbolLayerUtils.js");return ie(await t(n,e.scale/Pe.viewScaleSizeFactor),r)}case"path":return(null!=n.width?n.width:n.height)||e.scale/Pe.viewScaleSizeFactor;case"extrude":return n.size||e.scale/Pe.viewScaleSizeFactor;default:return 0}}function ae(e,t){const r=e.field,i=e.axis,n=t.fields&&t.fields.filter((e=>e.name===r)),a=n&&1===n.length?n[0].type:"double",o={initial:0,current:0},s=C[e.valueUnit]??1;let l;return l="area"===e.valueRepresentation?e=>(e*s/2)**2*Math.PI:"radius"===e.valueRepresentation||"distance"===e.valueRepresentation?e=>e*s/2:e=>e*s,{field:r,fieldType:a,getDefault:async(e,t)=>oe(l(await ne(t,e,i)),a),getValue:(e,t)=>(o.initial||(o.initial=t.pixelSizeAt(t.center)),o.current=o.initial*e,oe(o.current,a)),setInitialValue:e=>{o.initial=e,o.current=0},isUpdatingInteractively:!1,displayUnit:Re(e.valueUnit),axis:e.axis}}function oe(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 se(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 le(e,t,r){const i=await Q(e,{useSourceLayer:!0,ignoreGraphicSymbol:!0,webStyleCache:t,scale:r});null!=v(e.symbol,i)&&(e.symbol=i)}function ce(e,t){if(!e||!t)throw new Error("no geometry type");if("multipatch"===e)return{tool:"mesh",createOptions:{mode:"hybrid"}};const r=new Map;r.set("circle",{mode:"freehand"}),r.set("rectangle",{mode:"freehand"});const i={mode:H,optionsPerTool:r};if(S(t)){const n=t.defaultTool,a=j(t)?t.definition?.inputGeometryType??e:e;switch(n){case"freehand":case"stream-line":return{tool:"polyline"===a?"freehandPolyline":"freehandPolygon",createOptions:i};case"autocomplete-freehand-polygons":case"stream-polygon":return{tool:"freehandPolygon",createOptions:i};case"autocomplete-polygons":case"difference-polygon":case"create-structures":case"polygon":case"trace":return{tool:"polygon"===a?"polygon":"polyline",createOptions:i};case"circle":return r.get("circle").preserveAspectRatio=!0,{tool:"circle",createOptions:i};case"ellipse":return r.get("circle").preserveAspectRatio=!1,{tool:"circle",createOptions:i};case"create-points-along-line":case"multipoint":return{tool:"multipoint",createOptions:i};case"line":case"radial-line":case"right-angle-line":case"split":case"two-point-line":return{tool:"polyline",createOptions:i};case"rectangle":case"regular-polygon":case"right-angle-polygon":return{tool:"rectangle",createOptions:i};case"elevation-point-from-contour":case"elevation-point-from-dem":case"parcel-seed":case"point":case"point-and-rotation":case"point-at-end-of-line":return{tool:"point",createOptions:i}}}else{const n=t.drawingTool;if("circle"===n||"ellipse"===n)return r.get("circle").preserveAspectRatio="circle"===n,{tool:"circle",createOptions:i};if("rectangle"===n)return{tool:"rectangle",createOptions:i};if("freehand"===n)return{tool:"polygon"===e?"freehandPolygon":"freehandPolyline",createOptions:i}}return{tool:e,createOptions:i}}async function ue(e,t,r){const{creationInfo:i,fullTemplate:n}=t;if(!i)throw new a("No creation info provided.");const o=i.layer,s=he(n,i.attributeOverrides),{view:l}=e,c="2d"===l?.type;j(n)||I(n)||await we(e,o,s,r,c?l.scale:null);const{capabilities:u}=o;e.layer.elevationInfo=o.elevationInfo;const p=ce(o.geometryType,n);return e.defaultCreateOptions={graphicProperties:{attributes:s,sourceLayer:o},mode:p.createOptions.mode,optionsPerTool:p.createOptions.optionsPerTool,preserveAspectRatio:p.createOptions.preserveAspectRatio,hasZ:u.data.supportsZ,defaultZ:(c?u.editing.zDefault:null)??e.defaultCreateOptions.defaultZ},null==i.geometryToPlace?await e.create(p.tool):await e.place(i.geometryToPlace,{graphicProperties:{attributes:s,sourceLayer:o}}),pe({creationAttributes:s,data:t,sketchViewModel:e,view:l,webStyleCache:r})}async function pe(e){return o([await de(e),await ye(e)])}async function de({creationAttributes:e,data:t,sketchViewModel:r,view:i,webStyleCache:n}){const{creationInfo:a}=t,{fullTemplate:o}=t;if(!a||"2d"!==i?.type||j(o)||I(o))return null;const s=f((t=>we(r,a.layer,e,n,t)));return g((()=>i.scale),(e=>s(e)))}async function ye({data:t,sketchViewModel:r,view:i}){const{templateExecutorInfo:n}=t;if(!n)return null;const l=r.activeComponent;if(!i||!$(l))return _().error(new a("Failed to set up template feedback.")),null;const c=new O({effect:"saturate(0.6) opacity(0.8)",listMode:"hide",title:"Shared Template Feedback Graphics"});i.map?.add(c);const{executor:u,serviceLayersById:p}=n,d=i.theme?.accentColor??new e([255,165,0,1]);return o([h((()=>l),["cursor-update","vertex-add"],(()=>{c.removeAll();const e=l.graphic?.geometry;if(!e||!fe(e))return;const t=u(e,"digitizing");if(!m(t))for(const r of t.edits){const e=p.get(r.id);if(e&&r.addFeatures&&0!==r.addFeatures.length)for(const t of e)if(!t.isTable)for(const e of r.addFeatures){const t=me(e,d);t&&c.add(t)}}})),s((()=>{i.map.remove(c),c.destroy()}))])}function fe(e){switch(e.type){case"point":case"multipoint":return!0;case"polyline":return e.paths[0].length>1;case"polygon":{const t=e.rings[0];return i(t.at(0),t.at(-1))?t.length>2:t.length>1}default:return!1}}function me(e,r){let i=null;switch(e.geometry?.type){case"point":case"multipoint":i=new B({angle:0,color:r,outline:new q({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:1}),path:"undefined",size:8,style:"circle",xoffset:0,yoffset:0});break;case"polygon":i=new Z({color:r,outline:new q({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:3}),style:"none"});break;case"polyline":i=new q({cap:"round",color:r,join:"round",miterLimit:1,style:"solid",width:2});break;default:return null}return new t({geometry:e.geometry,symbol:i,attributes:{...e.attributes}})}async function ge(e,t){const r=await J(t).load(),i=M(e)?e.parent:e,n=r.tablesAndLayersLookup.get(i);if(!n)return new Map;const a=new Map;for(const o of n.layersAndTables)p(a,o.layerId,(()=>[])).push(o);return a}function he(e,t={}){return j(e)||I(e)?{}:T(e)?{...e.prototype.attributes,...t}:U(e)?{...e.definition?.defaultValues,...t}:{...t}}async function we(e,r,i,n,a){const o=new t({sourceLayer:r,attributes:i}),{rotation:s,size:l}=te(o);let c=await Q(o,{useSourceLayer:!0,webStyleCache:n,scale:a}),u=!1;for(const t of[l,s]){if(null==t)continue;null==i[t.field]&&(i[t.field]=await t.getDefault(c,e.view),u=!0)}switch(u&&(c=await Q(o,{useSourceLayer:!0,webStyleCache:n,scale:a})),c?.type){case"simple-fill":case"polygon-3d":e.polygonSymbol=c;break;case"simple-line":case"line-3d":e.polylineSymbol=c;break;case"simple-marker":case"picture-marker":case"point-3d":case"cim":e.pointSymbol=c;break;case"mesh-3d":e.meshSymbol=c}be(e.tooltipOptions,l,s)}function be(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 ve(e,t){return e?.find((e=>e.layer===t))}async function Se(e,t,r,i){switch(t.type){case"3d":return je(e,t,r,i);case"2d":return Ie(e,t,r,i)}}async function je(e,t,i,n){if(0===e.length)return[];const{updatable:a,graphicsByLayer:o}=await i.async((async()=>{const{results:r}=await d(X(t,i),n),a=new Map,o=e=>{const t=e.layer,r=a.get(t);if(!r){const e=new Array;return a.set(t,e),e}return r};Y(r).forEach((({graphic:e})=>o(e).push(e)));const s=e.filter((({capabilities:e,layer:t})=>e.update.enabled&&a.has(t)));return 0!==s.length&&i.stopPropagation(),{updatable:s,graphicsByLayer:a}}));return d(Promise.allSettled(a.map((async({layer:e})=>{const t=o.get(e),i=Te(e);if(t.every((e=>A(i,e))))return t;const a=[];for(const n of t){a.push(n.getObjectId());const e=Object.keys(n.attributes);r(i,e)}const s=e.createQuery();return s.returnGeometry=!1,s.objectIds=a,s.outFields=z(e.fieldsIndex,i),e.queryFeatures(s,{signal:n}).then((({features:e})=>e))}))),n)}async function Ie(e,t,r,i){if(0===e.length)return[];const{mapPoint:n}=r;if(null==n)return[];let a=null;const o=await r.async((async()=>{const{results:n}=await d(t.hitTest(r),i);if(0===n.length)return[];const o=new Set;a=Y(n),a.forEach((({graphic:e})=>e&&o.add(e.layer)));const s=e.filter((e=>o.has(e.layer)&&e.supportsUpdateWorkflow));return s.length>0&&r.stopPropagation(),s}));return d(Promise.allSettled(o.map((async({layer:e})=>{const o=e.createQuery();o.returnGeometry=!0,o.outFields=Te(e);const s="renderer"in e?P({renderer:e.renderer,pointerType:r.pointerType}):0;o.geometry=K(n,s,t),o.outSpatialReference=t.spatialReference;const{features:l}=await e.queryFeatures(o,{signal:i});return a?.forEach((({graphic:t})=>{t.layer!==e||l.some((e=>e.getObjectId()===t.getObjectId()))||l.push(t)})),l}))),i)}function Te(e){return z(e.fieldsIndex,[e.objectIdField,x({displayField:"displayField"in e?e.displayField:null,fields:e.fields})])}async function Ue(e,t,r){const{sourceLayer:i}=e,n=i.createQuery();n.objectIds=[e.getAttribute(i.objectIdField)],n.outFields=["*"],n.returnM=i.capabilities.data.supportsM,n.returnZ=i.capabilities.data.supportsZ,"scene"===i.type&&null!=i.infoFor3D||(n.outSpatialReference=t);const a=await i.queryFeatures(n,{signal:r});y(r);return a.features[0]}async function Ve(e){const{graphic:t,sketchViewModel:r,sourceLayer:i,visualVariables:n}=e;await Le(e);const a={multipleSelectionEnabled:!1};return"point"===i.geometryType&&(a.enableRotation=null!=n.rotation,a.enableScaling=null!=n.size),r.update(t,a)}async function Le(e){const{graphic:t,sketchViewModel:r,sourceLayer:i,visualVariables:n,webStyleCache:a}=e;let o=!1;const{rotation:s,size:l}=n;if([s,l].forEach((async e=>{if(null==e)return;const i=t.getAttribute(e.field);if(null!=i)e.setInitialValue(i);else{const i=await e.getDefault(t.symbol,r.view);e.setInitialValue(i),t.setAttribute(e.field,i),o=!0}})),o){const e="2d"===r.view?.type?r.view.scale:null;await le(t,a,e)}be(r.tooltipOptions,l,s),r.layer.elevationInfo=i.elevationInfo}function ke(e){return null==e||"rotate-start"!==e.type&&"rotate"!==e.type&&"rotate-stop"!==e.type?null:e}function Fe(e){return null==e||"scale-start"!==e.type&&"scale"!==e.type&&"scale-stop"!==e.type?null:e}async function Oe(e,t,r,i,n){if(null==t.geometry||"point"!==t.geometry?.type)return;const a=i.rotation,o=ke(r.toolEventInfo);if(null!=a&&null!=o){const{field:r,getValue:i}=a;"rotate-stop"===o.type?(a.isUpdatingInteractively=!1,a.setInitialValue(t.getAttribute(r))):(a.isUpdatingInteractively=!0,t.setAttribute(r,i(o.angle,e)))}const s=i.size,l=Fe(r.toolEventInfo);if(null!=s&&null!=l){const{field:r,getValue:i}=s;"scale-stop"===l.type?(s.isUpdatingInteractively=!1,s.setInitialValue(t.getAttribute(r))):(s.isUpdatingInteractively=!0,t.setAttribute(r,i(l.xScale,e)))}await le(t,n,"2d"===e.type?e.scale:null)}async function Ae({feature:e,featureClone:t,visualVariableAttributes:r,sketchViewModel:i,view:n,onUpdate:a,webStyleCache:c,addUpdatingPromise:u,addHandle:p}){await le(t,c,"2d"===n.type?n.scale:null);let d=null;if("2d"===i?.view?.type){const e=f((e=>le(t,c,e)));d=g((()=>i?.view?.scale),(t=>e(t)))}const y=t.sourceLayer,m=Ze(n,y);await Ve({graphic:t,sketchViewModel:i,sourceLayer:y,visualVariables:r,webStyleCache:c});let h=null;m.then((e=>h=e)).catch((()=>{}));const b=r.size,v=r.rotation,S=g((()=>e.attributes),(async e=>{let r=!1;for(const i in e){const n=e[i];n!==t.getAttribute(i)&&(t.setAttribute(i,n),null==b||b.isUpdatingInteractively||b.field!==i||b.setInitialValue(n),null==v||v.isUpdatingInteractively||v.field!==i||v.setInitialValue(n),(null==h||h.requiredFields.includes(i))&&(r=!0))}r&&await le(t,c,"2d"===n.type?n.scale:null)})),j=i.on("update",(async e=>{const t=e.graphics[0],o={graphic:t,sketchViewModel:i,sourceLayer:y,visualVariables:r,webStyleCache:c};if("complete"===e.state){if(null===n.activeTool)return Ve(o);const e=new AbortController,t=l(e);return p(t),u(w((()=>null===n.activeTool),e.signal).then((()=>(e.abort(),Ve(o)))))}await Oe(n,t,e,r,c),a(Be(t),e)})),I=i.on(["undo","redo"],(async e=>{a(Be(e.graphics[0]),e)}));return o([I,j,s((()=>i.cancel())),S,d])}async function ze(e,t,r){const i=e.view;e.layer.add(r);const a=t.sourceLayer,l=t.layer,c=t.getAttribute(l.objectIdField);let u=null;function p(e){u?.abort(),u=n((async t=>{const r=await Ze(i,a);y(t),r.setVisibility?.(c,e)}))}return await Me(i,r),p(!1),o([xe(i,r,(e=>p(!e))),s((async()=>{p(!0);try{const e=await Ze(i,a);await w((()=>!e.updating))}finally{e.layer.remove(r)}}))])}function xe(e,t,r){if("3d"===e.type){const i=new W({graphic:t});return o([e.trackGraphicState(i),g((()=>i.displaying),r)])}return g((()=>t.visible),r)}async function Me(e,t){if("3d"===e.type){const r=new W({graphic:t}),i=e.trackGraphicState(r);await w((()=>r.displaying||r.error)),i.remove()}else await w((()=>t.visible))}const Pe={icon:b(24),text:b(12),line:b(1),viewScaleSizeFactor:100};function Ce(e,t,r){let i=!1;return e.filter((e=>!!i||(i=e===t,i))).map((e=>r[e]()))}function Ee(e,t){e.viewModel.syncFeatureTemplates();const r=e.creationInfo;if("awaiting-feature-creation-info"===t[0].id&&r){const e=r.layer,i=V(e);1===i.length&&"scene"!==e.type&&(r.template=i[0],t.shift())}return t}function Re(e){return"unknown"===e?null:e}function Ge(e){e.filesEnabled=!0,e.mode="view",e.capabilities={editing:!0,operations:{add:!0,update:!0,delete:!0}}}const De=e=>/-stop/.test(e)||/vertex-/.test(e),Ze=(e,t)=>{const r="subtype-sublayer"===t.type?t.parent:t;return e.whenLayerView(r)};function qe(e){return"createInteractiveEditSession"in e}function Be(e){const t=e.geometry;if("mesh"===t?.type){const r=e.cloneShallow();return r.attributes=c(e.attributes),r.geometry=t.cloneShallow(),r.geometry.transform=t.transform?.clone()??null,r}return e.clone()}function Ne(e){const t=e.cursor;return e.cursor="progress",s((()=>e.cursor=t))}async function Qe(e,t){const{template:r}=e;if(null==r)return null;if(L(r))return r.load();if(S(r)){const e=F(t,{makeSharedTemplateFromJSON:We}),i=await e.getTemplates({templateIds:[r.templateId],featureService:r.featureService});if(0===i.length)throw new a("editor:failed-to-load-template","Unable to load the provided template");return i[0].load()}return r}function Je(e){for(const t of e){const{destinationGraphic:e,destinationField:r,sourceGraphic:i,sourceField:n}=t;e.setAttribute(r,i.getAttribute(n))}}const We=e=>k.fromJSON(e);export{Ee as avoidFeatureTemplateSelectionWithOnlyOneItem,qe as canCreateInteractiveEditSession,Be as cloneGraphicExceptMesh,ce as createToolFromGeometryType,Ce as createWorkflowSteps,Se as fetchCandidates,Ue as fetchFullFeature,ve as findLayerInfo,he as getCreationAttributes,Qe as getFullTemplateForCreationInfo,ge as getServiceLayersById,te as getVisualVariableAttributes,De as isTerminalUpdateEventType,ee as isUpdateWorkflow,Ge as prepareAttachmentsForCreateFeaturesWorkflow,Je as setRelationshipFields,Ae as setUpGeometryUpdate,pe as setUpSketchCreateWatchers,Le as setVisualVariablesAndElevationInfoForUpdate,Ne as showProgressCursor,Pe as sizeDefaults,Re as sizeVariableUnitToLengthUnit,ue as startCreatingNewFeature,Ve as startUpdatingFeatureGeometry,ze as swapForEditingSession,le as updateGraphicSymbolWhenRequired,Oe as visualVariableInteractiveUpdate,Ze as whenEditorLayerView,Me as whenGraphicDisplayed};
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.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{destroyMaybe as t,mappedFind as s,abortMaybe as o}from"../core/maybe.js";import{createResolver as i}from"../core/promiseUtils.js";import{watch as a,initial as r,on as n,when as l}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import m from"../views/interactive/sketch/SketchValueOptions.js";import h from"./Attachments.js";import p from"./FeatureForm.js";import u from"./FeatureTemplates.js";import g from"./Spinner.js";import w from"./Widget.js";import{css as _}from"./Editor/css.js";import v from"./Editor/EditorViewModel.js";import{isModelUpload as f}from"./Editor/modelUploadUtils.js";import y from"./Editor/VisibleElements.js";import{loadCreateFeaturesPanelContentComponents as k,CreateFeaturesPanelContent as b}from"./Editor/components/CreateFeaturesPanelContent.js";import{loadFeatureListComponents as A,FeatureList as F}from"./Editor/components/FeatureList.js";import{loadFooterActionsComponents as M,FooterActions as T}from"./Editor/components/FooterActions.js";import{loadNoticesComponents as C,Notice as W}from"./Editor/components/Notices.js";import{loadPanelContentComponents as E,PanelContent as P,PanelContentSection as L,PanelContentMessage as S}from"./Editor/components/PanelContent.js";import{PanelToolbar as I,loadPanelToolbarComponents as j}from"./Editor/components/PanelToolbar.js";import{loadPromptComponents as U,Prompt as D}from"./Editor/components/Prompt.js";import{loadUpdateFeaturePanelContentComponents as V,UpdateFeaturePanelContent as O}from"./Editor/components/UpdateFeaturePanelContent.js";import{loadUploadDetailsComponents as x,UploadDetails as B}from"./Editor/components/UploadDetails.js";import N from"./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js";import z from"./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js";import{VisibleElements as R,CreateToolVisibilityMap as G}from"./Sketch/VisibleElements.js";import{loadCalciteComponents as H}from"./support/componentsUtils.js";import{globalCss as q}from"./support/globalCss.js";import{incrementHeadingLevel as Z,Heading as K}from"./support/Heading.js";import{renderItem as $}from"./support/ItemList.js";import{connectDelayedLoading as J}from"./support/loaderUtils.js";import"./support/widgetUtils.js";import{messageBundle as Q}from"./support/decorators/messageBundle.js";import{vmEvent as X}from"./support/decorators/vmEvent.js";import{tsx as Y}from"./support/jsxFactory.js";import{substitute as ee}from"../intl/substitute.js";const te=Symbol("sketch-setup-handles");let se=class extends w{constructor(e,t){super(e,t),this._featureForm=new p,this._sketchToolbar=null,this._attachments=new h({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._associationItemList=new N,this._associationSettings=new z,this._featureTemplates=new u({enableListScroll:!1,renderItemContentEnd:e=>e.supportsUpload?Y("calcite-icon",{class:_.templateItemContentEnd,icon:"upload-to",key:"upload-icon"}):null,renderItemLabel:e=>e.label,renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new g,this._loading=!1,this.headingLevel=4,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.messagesFeature=null,this.supportingWidgetDefaults=null,this.viewModel=new v,this.visibleElements=new y,this._renderAttachments=()=>this._attachments.render(),this._renderFeatureForm=()=>this._featureForm.render(),this._renderAssociationItemList=()=>this._associationItemList.render(),this._renderAssociationSettings=()=>this._associationSettings.render(),this._renderFeatureTemplates=()=>this._featureTemplates.render(),this._renderSketch=()=>this._sketchToolbar?Y("div",{class:_.sketchContainer,key:"editor-sketch-container"},this._sketchToolbar?.render()):void 0,this._renderSelectIcon=()=>Y("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({heading:e,key:t,selected:s},...o)=>{const{visibleElements:i}=this;return Y("calcite-flow-item",{closable:!1,heading:e,headingLevel:this.headingLevel,key:t,loading:this._loading,selected:s,onCalciteFlowItemBack:this._onBack},i.zoomToButton&&this.viewModel.canZoomTo?Y("calcite-action",{alignment:"center",appearance:"transparent",icon:"zoom-to-object",key:"zoom-to-button",onclick:()=>this.viewModel.zoomTo(),slot:"header-actions-end",text:this.messages.zoomTo,title:this.messages.zoomTo}):null,i.settingsMenu?Y(I,{editorViewModel:this.viewModel,messagesCommon:this.messagesCommon,visibleElements:i}):null,...o)},this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this,s={title:e.cancelEditTitle,message:e.cancelEditWarningMessage,yesLabel:e.discardEdits,noLabel:e.continueEditing};return"create-features"===t?.type&&f(t.data.creationInfo)?this._showPromptAndWait("success"===t.data.upload?.state?e.modelUploads.cancelPlacementPrompt:e.modelUploads.cancelUploadPrompt):"update"===t?.type&&t.activeFeatureFormViewModel?.activeAssociation?this._showPromptAndWait({...s,message:e.cancelAssociationEditWarning}):this._showPromptAndWait(s)},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPromptAndWait({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._showPrompt=e=>{this._prompt?.cancel?.(),this._prompt=e},this._clearPrompt=()=>{this._prompt=null},this._onSave=()=>{this.viewModel.saveWorkflow()},this._onDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({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}}})},this._onDeleteAssociation=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAssociationTitle,message:e.deleteAssociationMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteAssociationFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepAssociation,action:this._clearPrompt}}})},this._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),this._onBack=e=>(e?.stopPropagation(),this.viewModel.back()),this._onAttachmentAdd=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type||"update"===e.type&&"create-features"===e.activeWorkflow?.type?(this._attachments.addFile(),e.back()):this._attachments.addAttachment().then((()=>e.back())))},this._onAttachmentUpdate=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.back()):this._attachments.updateAttachment().then((()=>e.back())))},this._onAttachmentDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:this._onAttachmentDeleteConfirm},secondary:{label:e.keepAttachment,action:this._clearPrompt}}})},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._showPrompt({title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}})}}initialize(){this._featureForm.showPrompt=this._showPrompt,this._featureForm.clearPrompt=this._clearPrompt,this.addHandles([a((()=>Z(this.headingLevel)),(e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e}),r),n((()=>this.viewModel.activeWorkflow),"cancel-request",(({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then((t=>t?e.allow():e.deny()))})),l((()=>this.viewModel.featureFormViewModel),(e=>{this._featureForm.viewModel=e}),r),l((()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel),(e=>{this._associationItemList.viewModel=e}),r),l((()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel?.association),(()=>{this._setUpAssociationSettings()})),a((()=>this.viewModel),(e=>{this._attachments.viewModel=e?.attachmentsViewModel??null,this._featureTemplates.viewModel=e?.featureTemplatesViewModel??null,this._spinner.viewModel=e?.spinnerViewModel??null,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt}),r),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"})}),r),a((()=>[this.supportingWidgetDefaults,this.viewModel.sketchViewModel]),(([e])=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel?.set(e.sketch))}),r),l((()=>this._attachments?.error),(e=>this._onAttachmentsError(e))),l((()=>this.viewModel?.failures),(e=>{const{messages:t}=this,[{error:s,retry:o,cancel:i}]=e;this._showPrompt({title:t.errorWarningTitle,message:ee(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{o(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{i(),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)),a((()=>this.visibleElements.sketch),(()=>this._setupSketch()),r),J({getLoading:()=>{const{viewModel:e}=this;return e.syncing||e.updating||this._attachments.submitting},setEffectiveLoading:e=>{this._loading=e}})])}destroy(){this._associationItemList.destroy(),this._associationSettings.destroy(),this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._sketchToolbar=t(this._sketchToolbar)}loadDependencies(){return Promise.all([H({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list")}),k(),A(),M(),C(),E(),j(),U(),V(),x()])}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger"}}get activeWorkflow(){return this.viewModel.activeWorkflow}get hideTemplatesForInactiveLayers(){return this.viewModel.hideTemplatesForInactiveLayers}set hideTemplatesForInactiveLayers(e){this.viewModel.hideTemplatesForInactiveLayers=e}get icon(){return"pencil"}set icon(e){this._overrideIfSome("icon",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 valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureEdit(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureEdit(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()}deleteAssociationFromWorkflow(){return this.viewModel.deleteAssociationFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{visibleElements:e,viewModel:t}=this,s=this.classes(_.base,q.widget,q.panel);if(!t)return Y("div",{class:s,key:"empty"});const{pageStack:o}=t,i=o.length-1,a=o.map(((e,t)=>this._renderPage(e,t===i)));return Y("div",{class:s,key:"base"},e.flow?Y("calcite-flow",{key:"flow"},a):a,this._prompt?Y(D,{...this._prompt,headingLevel:this.headingLevel}):void 0)}_renderPage(e,t){const s={selected:t};switch(e){case"disabled":break;case"ready":return this._renderReady(s);case"awaiting-feature-creation-info":return this._renderAwaitingFeatureCreationInfo(s);case"creating-features-upload-details":return this._renderUploadDetails(s);case"creating-features":return this._renderCreatingFeatures(s);case"editing-existing-feature":case"editing-attributes":return this._renderUpdateFeature(s);case"awaiting-update-feature-candidate":return this._renderFeatureList(s);case"adding-attachment":return this._renderAttachmentAdding(s);case"editing-attachment":return this._renderAttachmentEditing(s);case"viewing-associated-layers":case"viewing-associated-features":return this._renderViewAssociatedLayers(s);case"add-association-select-layer":case"add-association-select-feature":return this._renderSelectFeature(s);case"add-association-create-association":return this._renderAddAssociation(s)}return Y("div",{key:"empty-page"})}_renderAwaitingFeatureCreationInfo(e){const{EditorPanel:t,messages:s}=this;return Y(t,{heading:s.selectTemplate,key:"templates-panel",...e},Y(P,{key:"feature-templates"},Y(L,null,this._renderFeatureTemplates())))}_renderUploadDetails(e){const{EditorPanel:t,activeWorkflow:s,messages:o}=this;if("create-features"!==s?.type)return null;const i=s.data.upload;return i?Y(t,{heading:o.createFeatures,key:"upload-details-panel",...e},Y(B,{helpMessage:this._helpMessage,messages:o,upload:i})):null}_renderCreatingFeatures(e){const{EditorPanel:t,activeWorkflow:s,messages:o,messagesCommon:i,headingLevel:a,viewModel:r}=this;if(!s)return null;const n="create-features"===s.type&&s.numPendingFeatures>0||"update"===s.type&&"create-features"===s?.activeWorkflow?.type&&s.activeWorkflow?.numPendingFeatures>0;return Y(t,{heading:o.createFeatures,key:"create-features-panel",...e},n?Y(O,{editorViewModel:r,headingLevel:a,messages:o,messagesCommon:i,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}):Y(b,{helpMessage:this._helpMessage,renderSketchToolbar:this._renderSketch}))}_renderUpdateFeature(e){const{EditorPanel:t,messages:s,messagesCommon:o,headingLevel:i,viewModel:a}=this;return Y(t,{heading:s.editFeature,key:"update-feature-panel",...e},Y(O,{editorViewModel:a,headingLevel:i,messages:s,messagesCommon:o,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}))}_getAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.editFeature;if(e.title)return e.title;const{messagesFeature:s}=this;switch(e.type){case"attachment":return s.associationsAttachments;case"connectivity":return s.associationsConnectivity;case"structure":return s.associationsStructure;case"content":return s.associationsContents;case"container":return s.associationsContainer}}_getAddAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.editFeature;const s=t.associations;switch(e.type){case"attachment":return s.addAttachment;case"connectivity":return s.addConnectivity;case"structure":return s.addStructure;case"content":return s.addContent;case"container":return s.addContainer}}_renderViewAssociatedLayers(e){const{EditorPanel:t,messages:s,messagesCommon:o,headingLevel:i,viewModel:a}=this,r=a.featureFormViewModel?.activeAssociationInput?.activeAssociationType,n=this._getAssociationTypeTitle(r);return Y(t,{heading:n,key:"viewing-associated-layers-panel",...e},Y(O,{editorViewModel:a,headingLevel:i,messages:s,messagesCommon:o,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}))}_renderSelectFeature(e){const{_associationItemList:t,EditorPanel:s,viewModel:o,messagesCommon:i}=this,a=o.utilityNetworkAssociationAddAssociationViewModel,r=this._getAddAssociationTypeTitle(a?.associationType),n="ready"!==a?.state;return Y(s,{heading:r,key:"add-association-select-feature",...e},Y(P,{key:"select-feature"},Y(L,null,this._renderAssociationItemList())),Y(T,{buttons:[t.filterOptionsVisible?{appearance:"solid",label:i.apply,disabled:n,onClick:()=>t.applyFilterOptions(),type:"button"}:void 0,{appearance:"outline",label:i.cancel,disabled:n,onClick:()=>{"update"===o.activeWorkflow?.type&&o.activeWorkflow.cancelActiveWorkflow()},type:"button"}]}))}_setUpAssociationSettings(){const{viewModel:e,_associationSettings:t}=this,s=e.utilityNetworkAssociationAddAssociationViewModel,o="update"===e.activeWorkflow?.type?e.activeWorkflow:null,i=o?o.activeWorkflow:null,a="add-association"===i?.type?i.fullFeature:null,r=s?.selectedFeature,n=s?.association,l=s?.utilityNetwork;a&&r&&n&&l&&(t.sourceFeature=a,t.targetFeature=r,t.association=n,t.utilityNetwork=l)}_renderAddAssociation(e){const{EditorPanel:t,viewModel:s,messagesCommon:o}=this,i=s.utilityNetworkAssociationAddAssociationViewModel,a=this._getAddAssociationTypeTitle(i?.associationType),r="ready"!==i?.state;return Y(t,{heading:a,key:"add-association",...e},Y(P,{key:"add-association-content"},Y(L,null,this._renderAssociationSettings())),Y(T,{buttons:[{label:o.add,disabled:r||!i.canAddAssociation,onClick:()=>this._onSave(),type:"button"},{appearance:"outline",label:o.cancel,disabled:r,onClick:()=>{"update"===s.activeWorkflow?.type&&s.activeWorkflow.cancelActiveWorkflow()},type:"button"}]}))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:o}=this,i=s(e.group.items,(e=>o.itemHasInvalidFormTemplate(e)?t.formFieldCreateError:void 0));return i?Y(W,{kind:"warning",message:i}):null}_renderAttachmentAdding(e){const{EditorPanel:t,_attachments:s,messages:o,messagesCommon:i}=this;return Y(t,{heading:o.addAttachment,key:"attachment-adding-panel",...e},Y(P,{key:"attachments"},this._renderAttachments()),Y(T,{buttons:[{label:s.submitting?i.cancel:i.add,disabled:s.submitting||!s.selectedFile,onClick:this._onAttachmentAdd,type:"button"}]}))}_renderAttachmentEditing(e){const{EditorPanel:t,_attachments:s,activeWorkflow:o,messages:i,messagesCommon:a}=this;return o?Y(t,{heading:i.editAttachment,key:"attachment-editing-panel",...e},Y(P,{key:"attachments"},this._renderAttachments()),o.shouldAllowAttachmentEditing?Y(T,{buttons:[{label:a.update,disabled:s.submitting||!s.selectedFile,onClick:this._onAttachmentUpdate,type:"button"},{...this._deleteButtonCommonInfo,onClick:this._onAttachmentDelete,disabled:s.submitting,label:a.delete,type:"button"}]}):void 0):null}_renderReady(e){const{EditorPanel:t,messages:s,viewModel:o,visibleElements:i}=this,a=this._helpMessage;return Y(t,{heading:s.widgetLabel,key:"landing-panel",...e},Y(P,{key:"landing-content"},o.editorItems.length?[i.editFeaturesSection?Y(L,{key:"edit-actions"},this._renderUpdateActions()):null,i.createFeaturesSection&&o.canCreateVisible?Y(L,{key:"create-actions"},this._renderCreateActions()):null]:Y(S,{key:"no-content"},s.noEditableLayers)),a?Y("div",{class:_.helpMessage,key:"footer-actions",slot:"footer"},a):void 0)}get _helpMessage(){const{activeWorkflow:e,messages:t,view:s}=this,o=e?.helpMessage;return o?t["3d"===s?.type?"helpMessages3d":"helpMessages2d"]?.[o]:void 0}_renderUpdateActions(){const{messages:e,messagesCommon:t,viewModel:s}=this,o={id:"select",label:t.select};return Y("div",{class:_.updateActions,key:"update-actions"},Y(K,{level:Z(this.headingLevel)},e.editFeatures),Y("calcite-list",{class:_.updateActionsList,label:e.editFeaturesList,selectionAppearance:"border",selectionMode:"single"},$({disabled:!s.canUpdateVisible,grouped:!1,item:o,selectedItem:"awaiting-feature-to-update"===s.activeWorkflow?.stepId?o:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){return Y("div",{key:"create-actions"},Y(K,{level:Z(this.headingLevel)},this.messages.createFeatures),Y("div",{class:_.featureTemplatesContainer,key:"templates"},this._renderFeatureTemplates()))}_renderFeatureList(e){const{EditorPanel:t,viewModel:s}=this,{activeWorkflow:o}=s;if("update"!==o?.type)return null;const i=o.data.candidates,a=ee(this.messages.multipleFeaturesTemplate,{total:i.length});return Y(t,{heading:a,key:"feature-list",...e},Y(F,{editorItems:s.editorItems,editorMessages:this.messages,filterText:this._filterText,id:this.id,messagesTemplates:this.messagesTemplates,workflow:o,onFilterTextChange:e=>this._filterText=e,onSelectFeature:(e,t)=>s.selectFeature(e,t),onZoomTo:e=>s.zoomTo(e)}))}_showPromptAndWait({title:e,message:t,yesLabel:s,noLabel:o}){const a=i(),{view:r}=this,n=r?.focused;return this._showPrompt({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(),n&&r?.focus()}))}async _setupSketch(){if(!!!this.visibleElements.sketch)return this._sketchImportAbortController=o(this._sketchImportAbortController),this._sketchToolbar=t(this._sketchToolbar),void this.removeHandles(te);if(this._sketchImportAbortController)return;const e=new AbortController;this._sketchImportAbortController=e;const s=await import("./Sketch.js");if(!e.signal.aborted)try{this._sketchToolbar=new s.default({toolbarKind:"docked",contextualToolLocation:"inline-end",scale:"s",visibleElements:new R({deleteButton:!1,settingsMenu:!1,directionModePicker:!1,selectionCountLabel:!1,duplicateButton:!1,createTools:new G({freehandPolygon:!0,freehandPolyline:!0})})}),this.addHandles([a((()=>this.viewModel.activeLeafWorkflow?.availableCreateTools),(e=>{this._sketchToolbar&&(this._sketchToolbar.availableCreateTools=e)}),r),a((()=>this.visibleElements.undoRedoButtons),(e=>{this._sketchToolbar&&(this._sketchToolbar.visibleElements.undoRedoMenu=e)}),r),l((()=>this.viewModel?.sketchViewModel),(e=>{this._sketchToolbar&&(this._sketchToolbar.viewModel=e)}),r)],te)}finally{this._sketchImportAbortController=null}}get test(){return{sketch:this._sketchToolbar}}};e([c()],se.prototype,"_featureForm",void 0),e([c()],se.prototype,"_sketchToolbar",void 0),e([c()],se.prototype,"_attachments",void 0),e([c()],se.prototype,"_associationItemList",void 0),e([c()],se.prototype,"_associationSettings",void 0),e([c()],se.prototype,"_featureTemplates",void 0),e([c()],se.prototype,"_filterText",void 0),e([c()],se.prototype,"_prompt",void 0),e([c()],se.prototype,"_spinner",void 0),e([c()],se.prototype,"_deleteButtonCommonInfo",null),e([c()],se.prototype,"_loading",void 0),e([c({readOnly:!0})],se.prototype,"activeWorkflow",null),e([c()],se.prototype,"headingLevel",void 0),e([c()],se.prototype,"hideTemplatesForInactiveLayers",null),e([c()],se.prototype,"icon",null),e([c()],se.prototype,"label",null),e([c()],se.prototype,"labelOptions",null),e([c()],se.prototype,"layerInfos",null),e([c(),Q("esri/widgets/Editor/t9n/Editor")],se.prototype,"messages",void 0),e([c(),Q("esri/t9n/common")],se.prototype,"messagesCommon",void 0),e([c(),Q("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],se.prototype,"messagesTemplates",void 0),e([c(),Q("esri/widgets/Feature/t9n/Feature")],se.prototype,"messagesFeature",void 0),e([c()],se.prototype,"snappingOptions",null),e([c()],se.prototype,"tooltipOptions",null),e([c()],se.prototype,"supportingWidgetDefaults",void 0),e([c({type:m,nonNullable:!0})],se.prototype,"valueOptions",null),e([c()],se.prototype,"view",null),e([c(),X(["sketch-create","sketch-delete","sketch-update","workflow-cancel","workflow-commit"])],se.prototype,"viewModel",void 0),e([c({type:y,nonNullable:!0})],se.prototype,"visibleElements",void 0),e([c()],se.prototype,"_helpMessage",null),se=e([d("esri.widgets.Editor")],se);const oe=se;export{oe as default};
5
+ import{_ as e}from"../chunks/tslib.es6.js";import"../intl.js";import{destroyMaybe as t,mappedFind as s,abortMaybe as o}from"../core/maybe.js";import{createResolver as i}from"../core/promiseUtils.js";import{watch as a,initial as r,on as n,when as l}from"../core/reactiveUtils.js";import{property as c}from"../core/accessorSupport/decorators/property.js";import"../core/has.js";import"../core/Logger.js";import"../core/RandomLCG.js";import{subclass as d}from"../core/accessorSupport/decorators/subclass.js";import m from"../views/interactive/sketch/SketchValueOptions.js";import h from"./Attachments.js";import p from"./FeatureForm.js";import u from"./FeatureTemplates.js";import g from"./Spinner.js";import w from"./Widget.js";import{css as _}from"./Editor/css.js";import v from"./Editor/EditorViewModel.js";import{isModelUpload as f}from"./Editor/modelUploadUtils.js";import y from"./Editor/VisibleElements.js";import{loadCreateFeaturesPanelContentComponents as k,CreateFeaturesPanelContent as b}from"./Editor/components/CreateFeaturesPanelContent.js";import{loadFeatureListComponents as A,FeatureList as F}from"./Editor/components/FeatureList.js";import{loadFooterActionsComponents as M,FooterActions as T}from"./Editor/components/FooterActions.js";import{loadNoticesComponents as C,Notice as W}from"./Editor/components/Notices.js";import{loadPanelContentComponents as E,PanelContent as P,PanelContentSection as L,PanelContentMessage as S}from"./Editor/components/PanelContent.js";import{PanelToolbar as I,loadPanelToolbarComponents as j}from"./Editor/components/PanelToolbar.js";import{loadPromptComponents as U,Prompt as D}from"./Editor/components/Prompt.js";import{loadUpdateFeaturePanelContentComponents as V,UpdateFeaturePanelContent as O}from"./Editor/components/UpdateFeaturePanelContent.js";import{loadUploadDetailsComponents as x,UploadDetails as B}from"./Editor/components/UploadDetails.js";import N from"./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationItemList.js";import z from"./FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js";import{VisibleElements as R,CreateToolVisibilityMap as G}from"./Sketch/VisibleElements.js";import{loadCalciteComponents as H}from"./support/componentsUtils.js";import{globalCss as q}from"./support/globalCss.js";import{incrementHeadingLevel as Z,Heading as K}from"./support/Heading.js";import{renderItem as $}from"./support/ItemList.js";import{connectDelayedLoading as J}from"./support/loaderUtils.js";import"./support/widgetUtils.js";import{messageBundle as Q}from"./support/decorators/messageBundle.js";import{vmEvent as X}from"./support/decorators/vmEvent.js";import{tsx as Y}from"./support/jsxFactory.js";import{substitute as ee}from"../intl/substitute.js";const te=Symbol("sketch-setup-handles");let se=class extends w{constructor(e,t){super(e,t),this._featureForm=new p,this._sketchToolbar=null,this._attachments=new h({visibleElements:{addSubmitButton:!1,cancelAddButton:!1,cancelUpdateButton:!1,deleteButton:!1,errorMessage:!1,progressBar:!1,updateButton:!1}}),this._associationItemList=new N,this._associationSettings=new z,this._featureTemplates=new u({enableListScroll:!1,renderItemContentEnd:e=>e.supportsUpload?Y("calcite-icon",{class:_.templateItemContentEnd,icon:"upload-to",key:"upload-icon"}):null,renderItemLabel:e=>e.label,renderCustomGroupContent:e=>this._renderCustomTemplateGroupContent(e)}),this._filterText="",this._prompt=null,this._spinner=new g,this._loading=!1,this.headingLevel=4,this.messages=null,this.messagesCommon=null,this.messagesTemplates=null,this.messagesFeature=null,this.supportingWidgetDefaults=null,this.viewModel=new v,this.visibleElements=new y,this._renderAttachments=()=>this._attachments.render(),this._renderFeatureForm=()=>this._featureForm.render(),this._renderAssociationItemList=()=>this._associationItemList.render(),this._renderAssociationSettings=()=>this._associationSettings.render(),this._renderFeatureTemplates=()=>this._featureTemplates.render(),this._renderSketch=()=>this._sketchToolbar?Y("div",{class:_.sketchContainer,key:"editor-sketch-container"},this._sketchToolbar?.render()):void 0,this._renderSelectIcon=()=>Y("calcite-icon",{icon:"cursor",slot:"content-start"}),this.EditorPanel=({heading:e,key:t,selected:s},...o)=>{const{visibleElements:i}=this;return Y("calcite-flow-item",{closable:!1,heading:e,headingLevel:this.headingLevel,key:t,loading:this._loading,selected:s,onCalciteFlowItemBack:this._onBack},i.zoomToButton&&this.viewModel.canZoomTo?Y("calcite-action",{alignment:"center",appearance:"transparent",icon:"zoom-to-object",key:"zoom-to-button",onclick:()=>this.viewModel.zoomTo(),slot:"header-actions-end",text:this.messages.zoomTo,title:this.messages.zoomTo}):null,i.settingsMenu?Y(I,{editorViewModel:this.viewModel,messagesCommon:this.messagesCommon,visibleElements:i}):null,...o)},this._showDiscardEditsPrompt=()=>{const{messages:e,activeWorkflow:t}=this,s={title:e.cancelEditTitle,message:e.cancelEditWarningMessage,yesLabel:e.discardEdits,noLabel:e.continueEditing};return"create-features"===t?.type&&f(t.data.creationInfo)?this._showPromptAndWait("success"===t.data.upload?.state?e.modelUploads.cancelPlacementPrompt:e.modelUploads.cancelUploadPrompt):"update"===t?.type&&t.activeFeatureFormViewModel?.activeAssociation?this._showPromptAndWait({...s,message:e.cancelAssociationEditWarning}):this._showPromptAndWait(s)},this._showGenericCancelPrompt=()=>{const{messages:e,messagesCommon:t}=this;return this._showPromptAndWait({title:e.cancelRequestTitle,message:e.cancelRequestWarningMessage,yesLabel:t.form.yes,noLabel:t.form.no})},this._showPrompt=e=>{this._prompt?.cancel?.(),this._prompt=e},this._clearPrompt=()=>{this._prompt=null},this._onSave=()=>{this.viewModel.saveWorkflow()},this._onDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({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}}})},this._onDeleteAssociation=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAssociationTitle,message:e.deleteAssociationMessage,context:"danger",actions:{primary:{label:t.delete,action:()=>{this.deleteAssociationFromWorkflow(),this._clearPrompt()}},secondary:{label:e.keepAssociation,action:this._clearPrompt}}})},this._onToggleUpdateWorkflow=()=>this.viewModel.toggleUpdateWorkflow(),this._onBack=e=>(e?.stopPropagation(),this.viewModel.back()),this._onAttachmentAdd=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type||"update"===e.type&&"create-features"===e.activeWorkflow?.type?(this._attachments.addFile(),e.back()):this._attachments.addAttachment().then((()=>e.back())))},this._onAttachmentUpdate=()=>{const{activeWorkflow:e}=this.viewModel;e&&("create-features"===e.type?(this._attachments.updateFile(),e.back()):this._attachments.updateAttachment().then((()=>e.back())))},this._onAttachmentDelete=()=>{const{messages:e,messagesCommon:t}=this;this._showPrompt({title:e.deleteAttachmentWarningTitle,message:e.deleteAttachmentWarningMessage,context:"danger",actions:{primary:{label:t.delete,action:this._onAttachmentDeleteConfirm},secondary:{label:e.keepAttachment,action:this._clearPrompt}}})},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._showPrompt({title:this.messages.errorWarningTitle,message:e.message,context:"warning",actions:{primary:{label:this.messagesCommon.form.ok,action:this._clearPrompt}}})}}initialize(){this._featureForm.showPrompt=this._showPrompt,this._featureForm.clearPrompt=this._clearPrompt,this.addHandles([a((()=>Z(this.headingLevel)),(e=>{this._featureForm.headingLevel=e,this._featureTemplates.headingLevel=e}),r),n((()=>this.viewModel.activeWorkflow),"cancel-request",(({controller:e})=>{(this.viewModel.hasPendingEdits?this._showDiscardEditsPrompt():this._showGenericCancelPrompt()).then((t=>t?e.allow():e.deny()))})),l((()=>this.viewModel.featureFormViewModel),(e=>{this._featureForm.viewModel=e}),r),l((()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel),(e=>{this._associationItemList.viewModel=e}),r),l((()=>this.viewModel.utilityNetworkAssociationAddAssociationViewModel?.association),(()=>{this._setUpAssociationSettings()})),a((()=>this.viewModel),(e=>{this._attachments.viewModel=e?.attachmentsViewModel??null,this._featureTemplates.viewModel=e?.featureTemplatesViewModel??null,this._spinner.viewModel=e?.spinnerViewModel??null,e.showDiscardEditsPrompt=this._showDiscardEditsPrompt}),r),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"})}),r),a((()=>[this.supportingWidgetDefaults,this.viewModel.sketchViewModel]),(([e])=>{e&&(this._featureForm.set(e.featureForm),this._attachments.set(e.attachments),this._featureTemplates.set(e.featureTemplates),this.viewModel.sketchViewModel?.set(e.sketch))}),r),l((()=>this._attachments?.error),(e=>this._onAttachmentsError(e))),l((()=>this.viewModel?.failures),(e=>{const{messages:t}=this,[{error:s,retry:o,cancel:i}]=e;this._showPrompt({title:t.errorWarningTitle,message:ee(t.errorWarningMessageTemplate,{errorMessage:s.message}),context:"warning",actions:{primary:{label:t.retry,action:()=>{o(),this._clearPrompt()}},secondary:{label:t.ignore,action:()=>{i(),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)),a((()=>this.visibleElements.sketch),(()=>this._setupSketch()),r),J({getLoading:()=>{const{viewModel:e}=this;return e.syncing||e.updating||this._attachments.submitting},setEffectiveLoading:e=>{this._loading=e}})])}destroy(){this._associationItemList.destroy(),this._associationSettings.destroy(),this._attachments.destroy(),this._featureForm.destroy(),this._featureTemplates.destroy(),this._sketchToolbar=t(this._sketchToolbar)}loadDependencies(){return Promise.all([H({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),flow:()=>import("@esri/calcite-components/dist/components/calcite-flow"),"flow-item":()=>import("@esri/calcite-components/dist/components/calcite-flow-item"),icon:()=>import("@esri/calcite-components/dist/components/calcite-icon"),list:()=>import("@esri/calcite-components/dist/components/calcite-list")}),k(),A(),M(),C(),E(),j(),U(),V(),x()])}get _deleteButtonCommonInfo(){return{appearance:"outline",kind:"danger"}}get activeWorkflow(){return this.viewModel.activeWorkflow}get hideTemplatesForInactiveLayers(){return this.viewModel.hideTemplatesForInactiveLayers}set hideTemplatesForInactiveLayers(e){this.viewModel.hideTemplatesForInactiveLayers=e}get icon(){return"pencil"}set icon(e){this._overrideIfSome("icon",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 valueOptions(){return this.viewModel.valueOptions}set valueOptions(e){this.viewModel.valueOptions=e}get view(){return this.viewModel.view}set view(e){this.viewModel.view=e}startCreateFeaturesWorkflowAtFeatureTypeSelection(){return this.viewModel.startCreateFeaturesWorkflowAtFeatureTypeSelection()}startCreateFeaturesWorkflowAtFeatureCreation(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureCreation(e)}startCreateFeaturesWorkflowAtFeatureEdit(e){return this.viewModel.startCreateFeaturesWorkflowAtFeatureEdit(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()}deleteAssociationFromWorkflow(){return this.viewModel.deleteAssociationFromWorkflow()}cancelWorkflow(e){return this.viewModel.cancelWorkflow(e)}render(){const{visibleElements:e,viewModel:t}=this,s=this.classes(_.base,q.widget,q.panel);if(!t)return Y("div",{class:s,key:"empty"});const{pageStack:o}=t,i=o.length-1,a=o.map(((e,t)=>this._renderPage(e,t===i)));return Y("div",{class:s,key:"base"},e.flow?Y("calcite-flow",{key:"flow"},a):a,this._prompt?Y(D,{...this._prompt,headingLevel:this.headingLevel}):void 0)}_renderPage(e,t){const s={selected:t};switch(e){case"disabled":break;case"ready":return this._renderReady(s);case"awaiting-feature-creation-info":return this._renderAwaitingFeatureCreationInfo(s);case"creating-features-upload-details":return this._renderUploadDetails(s);case"creating-features":return this._renderCreatingFeatures(s);case"editing-existing-feature":case"editing-attributes":return this._renderUpdateFeature(s);case"awaiting-update-feature-candidate":return this._renderFeatureList(s);case"adding-attachment":return this._renderAttachmentAdding(s);case"editing-attachment":return this._renderAttachmentEditing(s);case"viewing-associated-layers":case"viewing-associated-features":return this._renderViewAssociatedLayers(s);case"add-association-select-layer":case"add-association-select-feature":return this._renderSelectFeature(s);case"add-association-create-association":return this._renderAddAssociation(s)}return Y("div",{key:"empty-page"})}_renderAwaitingFeatureCreationInfo(e){const{EditorPanel:t,messages:s}=this;return Y(t,{heading:s.selectTemplate,key:"templates-panel",...e},Y(P,{key:"feature-templates"},Y(L,null,this._renderFeatureTemplates())))}_renderUploadDetails(e){const{EditorPanel:t,activeWorkflow:s,messages:o}=this;if("create-features"!==s?.type)return null;const i=s.data.upload;return i?Y(t,{heading:o.createFeatures,key:"upload-details-panel",...e},Y(B,{helpMessage:this._helpMessage,messages:o,upload:i})):null}_renderCreatingFeatures(e){const{EditorPanel:t,activeWorkflow:s,messages:o,messagesCommon:i,headingLevel:a,viewModel:r}=this;if(!s)return null;const n="create-features"===s.type&&s.numPendingFeatures>0||"update"===s.type&&"create-features"===s?.activeWorkflow?.type&&s.activeWorkflow?.numPendingFeatures>0;return Y(t,{heading:o.createFeatures,key:"create-features-panel",...e},n?Y(O,{editorViewModel:r,headingLevel:a,messages:o,messagesCommon:i,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}):Y(b,{helpMessage:this._helpMessage,renderSketchToolbar:this._renderSketch}))}_renderUpdateFeature(e){const{EditorPanel:t,messages:s,messagesCommon:o,headingLevel:i,viewModel:a}=this;return Y(t,{heading:s.editFeature,key:"update-feature-panel",...e},Y(O,{editorViewModel:a,headingLevel:i,messages:s,messagesCommon:o,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}))}_getAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.editFeature;if(e.title)return e.title;const{messagesFeature:s}=this;switch(e.type){case"attachment":return s.associationsAttachments;case"connectivity":return s.associationsConnectivity;case"structure":return s.associationsStructure;case"content":return s.associationsContents;case"container":return s.associationsContainer}}_getAddAssociationTypeTitle(e){const{messages:t}=this;if(!e)return t.editFeature;const s=t.associations;switch(e.type){case"attachment":return s.addAttachment;case"connectivity":return s.addConnectivity;case"structure":return s.addStructure;case"content":return s.addContent;case"container":return s.addContainer}}_renderViewAssociatedLayers(e){const{EditorPanel:t,messages:s,messagesCommon:o,headingLevel:i,viewModel:a}=this,r=a.featureFormViewModel?.activeAssociationInput?.activeAssociationType,n=this._getAssociationTypeTitle(r);return Y(t,{heading:n,key:"viewing-associated-layers-panel",...e},Y(O,{editorViewModel:a,headingLevel:i,messages:s,messagesCommon:o,renderAttachments:this._renderAttachments,renderFeatureForm:this._renderFeatureForm,renderSketchToolbar:this._renderSketch,onDelete:this._onDelete,onDeleteAssociation:this._onDeleteAssociation,onSave:this._onSave}))}_renderSelectFeature(e){const{_associationItemList:t,EditorPanel:s,viewModel:o,messagesCommon:i}=this,a=o.utilityNetworkAssociationAddAssociationViewModel,r=this._getAddAssociationTypeTitle(a?.associationType),n="ready"!==a?.state;return Y(s,{heading:r,key:"add-association-select-feature",...e},Y(P,{key:"select-feature"},Y(L,null,this._renderAssociationItemList())),Y(T,{buttons:[t.filterOptionsVisible?{appearance:"solid",label:i.apply,disabled:n,onClick:()=>t.applyFilterOptions(),type:"button"}:void 0,{appearance:"outline",label:i.cancel,disabled:n,onClick:()=>{"update"===o.activeWorkflow?.type&&o.activeWorkflow.cancelActiveWorkflow()},type:"button"}]}))}_setUpAssociationSettings(){const{viewModel:e,_associationSettings:t}=this,s=e.utilityNetworkAssociationAddAssociationViewModel,o="update"===e.activeWorkflow?.type?e.activeWorkflow:null,i=o?o.activeWorkflow:null,a="add-association"===i?.type?i.sourceFeatureItem:null,r=s?.selectedFeature,n=s?.association,l=s?.utilityNetwork;a&&r&&n&&l&&(t.sourceFeature=a,t.targetFeature=r,t.association=n,t.utilityNetwork=l)}_renderAddAssociation(e){const{EditorPanel:t,viewModel:s,messagesCommon:o}=this,i=s.utilityNetworkAssociationAddAssociationViewModel,a=this._getAddAssociationTypeTitle(i?.associationType),r="ready"!==i?.state;return Y(t,{heading:a,key:"add-association",...e},Y(P,{key:"add-association-content"},Y(L,null,this._renderAssociationSettings())),Y(T,{buttons:[{label:o.add,disabled:r||!i.canAddAssociation,onClick:()=>this._onSave(),type:"button"},{appearance:"outline",label:o.cancel,disabled:r,onClick:()=>{"update"===s.activeWorkflow?.type&&s.activeWorkflow.cancelActiveWorkflow()},type:"button"}]}))}_renderCustomTemplateGroupContent(e){const{messages:t,viewModel:o}=this,i=s(e.group.items,(e=>o.itemHasInvalidFormTemplate(e)?t.formFieldCreateError:void 0));return i?Y(W,{kind:"warning",message:i}):null}_renderAttachmentAdding(e){const{EditorPanel:t,_attachments:s,messages:o,messagesCommon:i}=this;return Y(t,{heading:o.addAttachment,key:"attachment-adding-panel",...e},Y(P,{key:"attachments"},this._renderAttachments()),Y(T,{buttons:[{label:s.submitting?i.cancel:i.add,disabled:s.submitting||!s.selectedFile,onClick:this._onAttachmentAdd,type:"button"}]}))}_renderAttachmentEditing(e){const{EditorPanel:t,_attachments:s,activeWorkflow:o,messages:i,messagesCommon:a}=this;return o?Y(t,{heading:i.editAttachment,key:"attachment-editing-panel",...e},Y(P,{key:"attachments"},this._renderAttachments()),o.shouldAllowAttachmentEditing?Y(T,{buttons:[{label:a.update,disabled:s.submitting||!s.selectedFile,onClick:this._onAttachmentUpdate,type:"button"},{...this._deleteButtonCommonInfo,onClick:this._onAttachmentDelete,disabled:s.submitting,label:a.delete,type:"button"}]}):void 0):null}_renderReady(e){const{EditorPanel:t,messages:s,viewModel:o,visibleElements:i}=this,a=this._helpMessage;return Y(t,{heading:s.widgetLabel,key:"landing-panel",...e},Y(P,{key:"landing-content"},o.editorItems.length?[i.editFeaturesSection?Y(L,{key:"edit-actions"},this._renderUpdateActions()):null,i.createFeaturesSection&&o.canCreateVisible?Y(L,{key:"create-actions"},this._renderCreateActions()):null]:Y(S,{key:"no-content"},s.noEditableLayers)),a?Y("div",{class:_.helpMessage,key:"footer-actions",slot:"footer"},a):void 0)}get _helpMessage(){const{activeWorkflow:e,messages:t,view:s}=this,o=e?.helpMessage;return o?t["3d"===s?.type?"helpMessages3d":"helpMessages2d"]?.[o]:void 0}_renderUpdateActions(){const{messages:e,messagesCommon:t,viewModel:s}=this,o={id:"select",label:t.select};return Y("div",{class:_.updateActions,key:"update-actions"},Y(K,{level:Z(this.headingLevel)},e.editFeatures),Y("calcite-list",{class:_.updateActionsList,label:e.editFeaturesList,selectionAppearance:"border",selectionMode:"single"},$({disabled:!s.canUpdateVisible,grouped:!1,item:o,selectedItem:"awaiting-feature-to-update"===s.activeWorkflow?.stepId?o:void 0,renderIcon:this._renderSelectIcon,onItemSelect:this._onToggleUpdateWorkflow})))}_renderCreateActions(){return Y("div",{key:"create-actions"},Y(K,{level:Z(this.headingLevel)},this.messages.createFeatures),Y("div",{class:_.featureTemplatesContainer,key:"templates"},this._renderFeatureTemplates()))}_renderFeatureList(e){const{EditorPanel:t,viewModel:s}=this,{activeWorkflow:o}=s;if("update"!==o?.type)return null;const i=o.data.candidates,a=ee(this.messages.multipleFeaturesTemplate,{total:i.length});return Y(t,{heading:a,key:"feature-list",...e},Y(F,{editorItems:s.editorItems,editorMessages:this.messages,filterText:this._filterText,id:this.id,messagesTemplates:this.messagesTemplates,workflow:o,onFilterTextChange:e=>this._filterText=e,onSelectFeature:(e,t)=>s.selectFeature(e,t),onZoomTo:e=>s.zoomTo(e)}))}_showPromptAndWait({title:e,message:t,yesLabel:s,noLabel:o}){const a=i(),{view:r}=this,n=r?.focused;return this._showPrompt({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(),n&&r?.focus()}))}async _setupSketch(){if(!!!this.visibleElements.sketch)return this._sketchImportAbortController=o(this._sketchImportAbortController),this._sketchToolbar=t(this._sketchToolbar),void this.removeHandles(te);if(this._sketchImportAbortController)return;const e=new AbortController;this._sketchImportAbortController=e;const s=await import("./Sketch.js");if(!e.signal.aborted)try{this._sketchToolbar=new s.default({toolbarKind:"docked",contextualToolLocation:"inline-end",scale:"s",visibleElements:new R({deleteButton:!1,settingsMenu:!1,directionModePicker:!1,selectionCountLabel:!1,duplicateButton:!1,createTools:new G({freehandPolygon:!0,freehandPolyline:!0})})}),this.addHandles([a((()=>this.viewModel.activeLeafWorkflow?.availableCreateTools),(e=>{this._sketchToolbar&&(this._sketchToolbar.availableCreateTools=e)}),r),a((()=>this.visibleElements.undoRedoButtons),(e=>{this._sketchToolbar&&(this._sketchToolbar.visibleElements.undoRedoMenu=e)}),r),l((()=>this.viewModel?.sketchViewModel),(e=>{this._sketchToolbar&&(this._sketchToolbar.viewModel=e)}),r)],te)}finally{this._sketchImportAbortController=null}}get test(){return{sketch:this._sketchToolbar,showPrompt:this._showPromptAndWait.bind(this)}}};e([c()],se.prototype,"_featureForm",void 0),e([c()],se.prototype,"_sketchToolbar",void 0),e([c()],se.prototype,"_attachments",void 0),e([c()],se.prototype,"_associationItemList",void 0),e([c()],se.prototype,"_associationSettings",void 0),e([c()],se.prototype,"_featureTemplates",void 0),e([c()],se.prototype,"_filterText",void 0),e([c()],se.prototype,"_prompt",void 0),e([c()],se.prototype,"_spinner",void 0),e([c()],se.prototype,"_deleteButtonCommonInfo",null),e([c()],se.prototype,"_loading",void 0),e([c({readOnly:!0})],se.prototype,"activeWorkflow",null),e([c()],se.prototype,"headingLevel",void 0),e([c()],se.prototype,"hideTemplatesForInactiveLayers",null),e([c()],se.prototype,"icon",null),e([c()],se.prototype,"label",null),e([c()],se.prototype,"labelOptions",null),e([c()],se.prototype,"layerInfos",null),e([c(),Q("esri/widgets/Editor/t9n/Editor")],se.prototype,"messages",void 0),e([c(),Q("esri/t9n/common")],se.prototype,"messagesCommon",void 0),e([c(),Q("esri/widgets/FeatureTemplates/t9n/FeatureTemplates")],se.prototype,"messagesTemplates",void 0),e([c(),Q("esri/widgets/Feature/t9n/Feature")],se.prototype,"messagesFeature",void 0),e([c()],se.prototype,"snappingOptions",null),e([c()],se.prototype,"tooltipOptions",null),e([c()],se.prototype,"supportingWidgetDefaults",void 0),e([c({type:m,nonNullable:!0})],se.prototype,"valueOptions",null),e([c()],se.prototype,"view",null),e([c(),X(["sketch-create","sketch-delete","sketch-update","workflow-cancel","workflow-commit"])],se.prototype,"viewModel",void 0),e([c({type:y,nonNullable:!0})],se.prototype,"visibleElements",void 0),e([c()],se.prototype,"_helpMessage",null),se=e([d("esri.widgets.Editor")],se);const oe=se;export{oe 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.32/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../intl.js";import{destroyMaybe as t}from"../../../core/maybe.js";import{watch as s}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";import r from"../../Widget.js";import{legendItemCss as c}from"../css.js";import{Statistics as l}from"./Statistics.js";import{getTranslatedLineTitle as n}from"../support/intlUtils.js";import{loadCalciteComponents as a}from"../../support/componentsUtils.js";import"../../support/widgetUtils.js";import{tsx as p,tsxFragment as d}from"../../support/jsxFactory.js";import{substitute as h}from"../../../intl/substitute.js";let m=class extends r{constructor(e,t){super(e,t),this.checkboxVisible=!0,this.expanded=!1}loadDependencies(){return a({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),checkbox:()=>import("@esri/calcite-components/dist/components/calcite-checkbox"),label:()=>import("@esri/calcite-components/dist/components/calcite-label"),tooltip:()=>import("@esri/calcite-components/dist/components/calcite-tooltip")})}initialize(){this._statistics=new l(this._statisticsProps),this.addHandles(s((()=>this._statisticsProps),(e=>this._statistics.set(e))))}destroy(){this._statistics=t(this._statistics)}render(){const e=this.expanded;return p("div",{class:this.classes(c.base,{[c.disabled]:this.disabled,[c.expanded]:e}),key:this},this._renderColorIndicator(),p("div",{class:c.header,key:"header"},this._renderLabelWithCheckbox(),this._renderCollapseToggleButton()),e?p("div",{class:c.content,key:"content"},this._statistics.render()):null)}get disabled(){return!this.line.available}get _statisticsProps(){return{line:this.line,effectiveUnits:this.effectiveUnits}}_renderColorIndicator(){return p("div",{class:c.colorIndicator,key:"color-indicator",styles:{backgroundColor:this.line.color.toCss()}})}_renderCollapseToggleButton(){const{expanded:e,messages:t}=this,s=e?t.hideDetails:t.showDetails;return p("calcite-action",{appearance:"transparent",bind:this,class:c.collapseToggle,"data-testid":"legend-toggle",icon:e?"chevron-up":"chevron-down",key:"collapse-toggle",onclick:this._onCollapseToggleClick,scale:"s",text:s,title:s})}_onCollapseToggleClick(){this.onExpandedToggle()}_renderLabelWithCheckbox(){const{line:e,checkboxVisible:t,disabled:s,messages:o}=this,i=`label-${e.id}`;return p("calcite-label",{class:c.label,disabled:s,key:i,layout:"inline"},t?this._renderCheckbox(e.id):null,n(e,o))}_renderCheckbox(e){const{disabled:t,line:s,messages:o}=this,i=s.visible,r=`${e}-checkbox`,l=i?o.hideProfile:o.showProfile,a=h(l,{name:n(s,o)});return p(d,null,p("calcite-checkbox",{checked:i,class:c.checkbox,disabled:t,id:r,key:"checkbox",onCalciteCheckboxChange:()=>s.toggleVisibility()}),p("calcite-tooltip",{overlayPositioning:"fixed",placement:"top",referenceElement:r},a))}};e([o()],m.prototype,"checkboxVisible",void 0),e([o()],m.prototype,"disabled",null),e([o({nonNullable:!0})],m.prototype,"effectiveUnits",void 0),e([o()],m.prototype,"expanded",void 0),e([o({nonNullable:!0})],m.prototype,"line",void 0),e([o()],m.prototype,"messages",void 0),e([o()],m.prototype,"onExpandedToggle",void 0),e([o()],m.prototype,"_statistics",void 0),m=e([i("esri.widgets.ElevationProfile.components.LegendItem")],m);export{m as LegendItem};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../intl.js";import{destroyMaybe as t}from"../../../core/maybe.js";import{watch as s}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as i}from"../../../core/accessorSupport/decorators/subclass.js";import r from"../../Widget.js";import{legendItemCss as l}from"../css.js";import{Statistics as c}from"./Statistics.js";import{getTranslatedLineTitle as n}from"../support/intlUtils.js";import{loadCalciteComponents as a}from"../../support/componentsUtils.js";import"../../support/widgetUtils.js";import{tsx as d}from"../../support/jsxFactory.js";import{substitute as p}from"../../../intl/substitute.js";let h=class extends r{constructor(e,t){super(e,t),this.checkboxVisible=!0,this.expanded=!1}loadDependencies(){return a({action:()=>import("@esri/calcite-components/dist/components/calcite-action"),checkbox:()=>import("@esri/calcite-components/dist/components/calcite-checkbox"),label:()=>import("@esri/calcite-components/dist/components/calcite-label")})}initialize(){this._statistics=new c(this._statisticsProps),this.addHandles(s((()=>this._statisticsProps),(e=>this._statistics.set(e))))}destroy(){this._statistics=t(this._statistics)}render(){const e=this.expanded;return d("div",{class:this.classes(l.base,{[l.disabled]:this.disabled,[l.expanded]:e}),key:this},this._renderColorIndicator(),d("div",{class:l.header,key:"header"},this._renderLabelWithCheckbox(),this._renderCollapseToggleButton()),e?d("div",{class:l.content,key:"content"},this._statistics.render()):null)}get disabled(){return!this.line.available}get _statisticsProps(){return{line:this.line,effectiveUnits:this.effectiveUnits}}_renderColorIndicator(){return d("div",{class:l.colorIndicator,key:"color-indicator",styles:{backgroundColor:this.line.color.toCss()}})}_renderCollapseToggleButton(){const{expanded:e,messages:t}=this,s=e?t.hideDetails:t.showDetails;return d("calcite-action",{appearance:"transparent",bind:this,class:l.collapseToggle,"data-testid":"legend-toggle",icon:e?"chevron-up":"chevron-down",key:"collapse-toggle",onclick:this._onCollapseToggleClick,scale:"s",text:s,title:s})}_onCollapseToggleClick(){this.onExpandedToggle()}_renderLabelWithCheckbox(){const{line:e,checkboxVisible:t,disabled:s,messages:o}=this;return d("calcite-label",{class:l.label,disabled:s,key:`label-${e.id}`,layout:"inline"},t?this._renderCheckbox():null,n(e,o))}_renderCheckbox(){const{disabled:e,line:t,messages:s}=this,o=t.visible,i=o?s.hideProfile:s.showProfile,r=p(i,{name:n(t,s)});return d("calcite-checkbox",{checked:o,class:l.checkbox,disabled:e,title:r,onCalciteCheckboxChange:()=>t.toggleVisibility()})}};e([o()],h.prototype,"checkboxVisible",void 0),e([o()],h.prototype,"disabled",null),e([o({nonNullable:!0})],h.prototype,"effectiveUnits",void 0),e([o()],h.prototype,"expanded",void 0),e([o({nonNullable:!0})],h.prototype,"line",void 0),e([o()],h.prototype,"messages",void 0),e([o()],h.prototype,"onExpandedToggle",void 0),e([o()],h.prototype,"_statistics",void 0),h=e([i("esri.widgets.ElevationProfile.components.LegendItem")],h);export{h as LegendItem};